mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 04:04:47 -04:00
Triggered actions on invoice
This commit is contained in:
parent
95a2eab410
commit
94a98f744e
@ -215,6 +215,8 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
event(new InvoiceWasCreated($invoice, $invoice->company));
|
event(new InvoiceWasCreated($invoice, $invoice->company));
|
||||||
|
|
||||||
|
$invoice = $invoice->service()->triggeredActions($request)->save();
|
||||||
|
|
||||||
return $this->itemResponse($invoice);
|
return $this->itemResponse($invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ use App\Services\Invoice\HandleCancellation;
|
|||||||
use App\Services\Invoice\HandleReversal;
|
use App\Services\Invoice\HandleReversal;
|
||||||
use App\Services\Invoice\MarkInvoicePaid;
|
use App\Services\Invoice\MarkInvoicePaid;
|
||||||
use App\Services\Invoice\MarkSent;
|
use App\Services\Invoice\MarkSent;
|
||||||
|
use App\Services\Invoice\TriggeredActions;
|
||||||
use App\Services\Invoice\UpdateBalance;
|
use App\Services\Invoice\UpdateBalance;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
@ -136,6 +137,13 @@ class InvoiceService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function triggeredActions($request)
|
||||||
|
{
|
||||||
|
$this->invoice = (new TriggeredActions($this->invoice, $request))->run();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function markViewed()
|
public function markViewed()
|
||||||
{
|
{
|
||||||
$this->invoice->last_viewed = Carbon::now()->format('Y-m-d H:i');
|
$this->invoice->last_viewed = Carbon::now()->format('Y-m-d H:i');
|
||||||
|
44
app/Services/Invoice/TriggeredActions.php
Normal file
44
app/Services/Invoice/TriggeredActions.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
|
use App\Factory\PaymentFactory;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Services\AbstractService;
|
||||||
|
use App\Services\Client\ClientService;
|
||||||
|
use App\Services\Payment\PaymentService;
|
||||||
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TriggeredActions extends AbstractService
|
||||||
|
{
|
||||||
|
use GeneratesCounter;
|
||||||
|
|
||||||
|
private $request;
|
||||||
|
|
||||||
|
private $invoice;
|
||||||
|
|
||||||
|
public function __construct(Invoice $invoice, Request $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
//the request may have buried in it additional actions we should automatically perform on the invoice
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user