mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Auto archive invoice - Mark Paid
This commit is contained in:
parent
4c721e5027
commit
55839d66ed
@ -35,10 +35,9 @@ class InvoiceWorkflowSettings implements ShouldQueue
|
|||||||
* @param Invoice $invoice
|
* @param Invoice $invoice
|
||||||
* @param Client|null $client
|
* @param Client|null $client
|
||||||
*/
|
*/
|
||||||
public function __construct(Invoice $invoice, Client $client = null)
|
public function __construct(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
$this->client = $client ?? $invoice->client;
|
|
||||||
$this->base_repository = new BaseRepository();
|
$this->base_repository = new BaseRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +48,8 @@ class InvoiceWorkflowSettings implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$this->client = $this->invoice->client;
|
||||||
|
|
||||||
if ($this->client->getSetting('auto_archive_invoice')) {
|
if ($this->client->getSetting('auto_archive_invoice')) {
|
||||||
/* Throws: Payment amount xxx does not match invoice totals. */
|
/* Throws: Payment amount xxx does not match invoice totals. */
|
||||||
$this->base_repository->archive($this->invoice);
|
$this->base_repository->archive($this->invoice);
|
||||||
|
@ -14,6 +14,7 @@ namespace App\Services\Invoice;
|
|||||||
use App\Events\Invoice\InvoiceWasPaid;
|
use App\Events\Invoice\InvoiceWasPaid;
|
||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
use App\Factory\PaymentFactory;
|
use App\Factory\PaymentFactory;
|
||||||
|
use App\Jobs\Invoice\InvoiceWorkflowSettings;
|
||||||
use App\Jobs\Payment\EmailPayment;
|
use App\Jobs\Payment\EmailPayment;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
@ -90,6 +91,8 @@ class MarkPaid extends AbstractService
|
|||||||
->updatePaidToDate($payment->amount)
|
->updatePaidToDate($payment->amount)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
InvoiceWorkflowSettings::dispatchNow($this->invoice);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user