mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 13:04:30 -04:00
Triggered actions for Credits / Quotes
This commit is contained in:
parent
1f1e366903
commit
2bd58d5d0e
75
app/Jobs/Quote/QuoteCheckExpired.php
Normal file
75
app/Jobs/Quote/QuoteCheckExpired.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Jobs\Quote;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Quote;
|
||||||
|
use App\Repositories\BaseRepository;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class QuoteCheckExpired implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*/
|
||||||
|
public function __construct() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if (! config('ninja.db.multi_db_enabled'))
|
||||||
|
return $this->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){
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -45,6 +45,22 @@ class TriggeredActions extends AbstractService
|
|||||||
$this->credit = $this->credit->service()->markSent()->save();
|
$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;
|
return $this->credit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,22 @@ class TriggeredActions extends AbstractService
|
|||||||
// $this->purchase_order = $this->purchase_order->service()->handleCancellation()->save();
|
// $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;
|
return $this->purchase_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user