diff --git a/app/Jobs/Quote/QuoteCheckExpired.php b/app/Jobs/Quote/QuoteCheckExpired.php new file mode 100644 index 000000000000..4c3a82dd1436 --- /dev/null +++ b/app/Jobs/Quote/QuoteCheckExpired.php @@ -0,0 +1,75 @@ +checkForExpiredQuotes(); + + foreach (MultiDB::$dbs as $db) { + + MultiDB::setDB($db); + + $this->checkForExpiredQuotes(); + + } + + } + + private function checkForExpiredQuotes() + { + Quote::query() + ->where('status_id', Quote::STATUS_SENT) + ->where('is_deleted', false) + ->whereNull('deleted_at') + ->whereNotNull('due_date') + ->whereHas('client', function ($query) { + $query->where('is_deleted', 0) + ->where('deleted_at', null); + }) + ->whereHas('company', function ($query) { + $query->where('is_disabled', 0); + }) + // ->where('due_date', '<='. now()->toDateTimeString()) + ->whereBetween('due_date', [now()->subDay(), now()]) + ->cursor() + ->each(function ($quote){ + + }); + } + +} diff --git a/app/Services/Credit/TriggeredActions.php b/app/Services/Credit/TriggeredActions.php index dc4424be8d30..e08151736c48 100644 --- a/app/Services/Credit/TriggeredActions.php +++ b/app/Services/Credit/TriggeredActions.php @@ -45,6 +45,22 @@ class TriggeredActions extends AbstractService $this->credit = $this->credit->service()->markSent()->save(); } + if($this->request->has('save_default_footer') && $this->request->input('save_default_footer') == 'true') { + $company = $this->credit->company; + $settings = $company->settings; + $settings->credit_footer = $this->credit->footer; + $company->settings = $settings; + $company->save(); + } + + if($this->request->has('save_default_terms') && $this->request->input('save_default_terms') == 'true') { + $company = $this->credit->company; + $settings = $company->settings; + $settings->credit_terms = $this->credit->terms; + $company->settings = $settings; + $company->save(); + } + return $this->credit; } diff --git a/app/Services/PurchaseOrder/TriggeredActions.php b/app/Services/PurchaseOrder/TriggeredActions.php index b6f1f3eee32d..a325a9cc5eef 100644 --- a/app/Services/PurchaseOrder/TriggeredActions.php +++ b/app/Services/PurchaseOrder/TriggeredActions.php @@ -52,6 +52,22 @@ class TriggeredActions extends AbstractService // $this->purchase_order = $this->purchase_order->service()->handleCancellation()->save(); // } + if($this->request->has('save_default_footer') && $this->request->input('save_default_footer') == 'true') { + $company = $this->purchase_order->company; + $settings = $company->settings; + $settings->purchase_order_footer = $this->purchase_order->footer; + $company->settings = $settings; + $company->save(); + } + + if($this->request->has('save_default_terms') && $this->request->input('save_default_terms') == 'true') { + $company = $this->purchase_order->company; + $settings = $company->settings; + $settings->purchase_order_terms = $this->purchase_order->terms; + $company->settings = $settings; + $company->save(); + } + return $this->purchase_order; }