diff --git a/app/Filters/DesignFilters.php b/app/Filters/DesignFilters.php index 06ad08b074eb..88593f219845 100644 --- a/app/Filters/DesignFilters.php +++ b/app/Filters/DesignFilters.php @@ -61,11 +61,11 @@ class DesignFilters extends QueryFilters */ public function entityFilter(): Builder { - //19-03-2023 change the scope for the design filters - return $this->builder->where(function ($query) { - $query->where('company_id', auth()->user()->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc'); - // return $this->builder->where('company_id', auth()->user()->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc'); + /** @var \App\Models\User $user */ + $user = auth()->user(); + return $this->builder->where(function ($query) use($user){ + $query->where('company_id', $user->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc'); }); } diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 26c9228e3804..ccc61a03d555 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -243,7 +243,7 @@ class CreditService public function triggeredActions($request) { - $this->invoice = (new TriggeredActions($this->credit, $request))->run(); + $this->credit = (new TriggeredActions($this->credit, $request))->run(); return $this; } diff --git a/app/Services/Credit/TriggeredActions.php b/app/Services/Credit/TriggeredActions.php index fb909373959b..40eba04bce18 100644 --- a/app/Services/Credit/TriggeredActions.php +++ b/app/Services/Credit/TriggeredActions.php @@ -61,6 +61,10 @@ class TriggeredActions extends AbstractService $company->save(); } + if ($this->request->has('mark_paid') && $this->request->input('mark_paid') == 'true') { + $this->credit->service()->markPaid()->save(); + } + return $this->credit; }