mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on Invoice and Payment Jobs
This commit is contained in:
parent
98d1480450
commit
4cae3fdcfb
45
app/Jobs/Invoice/InvoiceNotification.php
Normal file
45
app/Jobs/Invoice/InvoiceNotification.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Invoice;
|
||||||
|
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Repositories\InvoiceRepository;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class InvoiceNotification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $invoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Invoice $invoice)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
|
||||||
|
//notification for the invoice.
|
||||||
|
//
|
||||||
|
//could mean a email, sms, slack, push
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Invoice;
|
namespace App\Jobs\Invoice;
|
||||||
|
|
||||||
|
use App\Jobs\Invoice\InvoiceNotification;
|
||||||
|
use App\Jobs\Payment\PaymentNotification;
|
||||||
|
use App\Models\Invoice;
|
||||||
use App\Repositories\InvoiceRepository;
|
use App\Repositories\InvoiceRepository;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -69,6 +72,8 @@ class StoreInvoice implements ShouldQueue
|
|||||||
$this->invoice = $invoice_repo->markSent($this->invoice);
|
$this->invoice = $invoice_repo->markSent($this->invoice);
|
||||||
|
|
||||||
//fire invoice job (the job performs the filtering logic of the email recipients... if any.)
|
//fire invoice job (the job performs the filtering logic of the email recipients... if any.)
|
||||||
|
InvoiceNotification::dispatch($invoice);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->data['mark_paid']) && (bool)$this->data['mark_paid'])
|
if(isset($this->data['mark_paid']) && (bool)$this->data['mark_paid'])
|
||||||
@ -86,6 +91,8 @@ class StoreInvoice implements ShouldQueue
|
|||||||
if($payment)
|
if($payment)
|
||||||
{
|
{
|
||||||
//fire payment notifications here
|
//fire payment notifications here
|
||||||
|
PaymentNotification::dipatch($payment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['download_invoice']) && (bool)$this->data['download_invoice'])
|
if(isset($data['download_invoice']) && (bool)$this->data['download_invoice'])
|
||||||
|
45
app/Jobs/Payment/PaymentNotification.php
Normal file
45
app/Jobs/Payment/PaymentNotification.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Payment;
|
||||||
|
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Repositories\InvoiceRepository;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class PaymentNotification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $payment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Payment $payment)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->payment = $payment;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
|
||||||
|
//notification for the payment.
|
||||||
|
//
|
||||||
|
//could mean a email, sms, slack, push
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,9 +61,10 @@ class InvoiceRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
|
|
||||||
if($invoice->status_id >= Invoice::STATUS_SENT)
|
if($invoice->status_id >= Invoice::STATUS_SENT)
|
||||||
return;
|
return $invoice;
|
||||||
|
|
||||||
$invoice->status_id = Invoice::STATUS_SENT;
|
$invoice->status_id = Invoice::STATUS_SENT;
|
||||||
|
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user