1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Working on Invoice and Payment Jobs

This commit is contained in:
David Bomba 2019-05-10 07:50:21 +10:00
parent 98d1480450
commit 4cae3fdcfb
4 changed files with 100 additions and 2 deletions

View 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
}
}

View File

@ -2,6 +2,9 @@
namespace App\Jobs\Invoice;
use App\Jobs\Invoice\InvoiceNotification;
use App\Jobs\Payment\PaymentNotification;
use App\Models\Invoice;
use App\Repositories\InvoiceRepository;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@ -69,6 +72,8 @@ class StoreInvoice implements ShouldQueue
$this->invoice = $invoice_repo->markSent($this->invoice);
//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'])
@ -86,6 +91,8 @@ class StoreInvoice implements ShouldQueue
if($payment)
{
//fire payment notifications here
PaymentNotification::dipatch($payment);
}
if(isset($data['download_invoice']) && (bool)$this->data['download_invoice'])

View 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
}
}

View File

@ -46,7 +46,7 @@ class InvoiceRepository extends BaseRepository
$invoice->save();
return $invoice;
}
@ -61,9 +61,10 @@ class InvoiceRepository extends BaseRepository
{
if($invoice->status_id >= Invoice::STATUS_SENT)
return;
return $invoice;
$invoice->status_id = Invoice::STATUS_SENT;
$invoice->save();
return $invoice;