diff --git a/app/Jobs/Invoice/InvoiceNotification.php b/app/Jobs/Invoice/InvoiceNotification.php new file mode 100644 index 000000000000..b25eee6eda77 --- /dev/null +++ b/app/Jobs/Invoice/InvoiceNotification.php @@ -0,0 +1,45 @@ +invoice = $invoice; + + } + + /** + * Execute the job. + * + * + * @return void + */ + public function handle() + { + + //notification for the invoice. + // + //could mean a email, sms, slack, push + + } +} diff --git a/app/Jobs/Invoice/StoreInvoice.php b/app/Jobs/Invoice/StoreInvoice.php index 01f57b3c142b..22c25f5ef7fe 100644 --- a/app/Jobs/Invoice/StoreInvoice.php +++ b/app/Jobs/Invoice/StoreInvoice.php @@ -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']) diff --git a/app/Jobs/Payment/PaymentNotification.php b/app/Jobs/Payment/PaymentNotification.php new file mode 100644 index 000000000000..1a3e41115aa0 --- /dev/null +++ b/app/Jobs/Payment/PaymentNotification.php @@ -0,0 +1,45 @@ +payment = $payment; + + } + + /** + * Execute the job. + * + * + * @return void + */ + public function handle() + { + + //notification for the payment. + // + //could mean a email, sms, slack, push + + } +} diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index 24872bf0a9ca..513b1c3f1f4e 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -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;