added viewed status to invoice factory

This commit is contained in:
denisdulici
2020-01-23 17:54:39 +03:00
parent 967849bda7
commit 80f0aee1fc
5 changed files with 41 additions and 28 deletions

View File

@@ -3,10 +3,13 @@
namespace App\Listeners\Sale;
use App\Events\Sale\InvoiceSent as Event;
use App\Models\Sale\InvoiceHistory;
use App\Jobs\Sale\CreateInvoiceHistory;
use App\Traits\Jobs;
class MarkInvoiceSent
{
use Jobs;
/**
* Handle the event.
*
@@ -15,20 +18,12 @@ class MarkInvoiceSent
*/
public function handle(Event $event)
{
// Mark invoice as sent
if ($event->invoice->status != 'partial') {
$event->invoice->status = 'sent';
$event->invoice->save();
}
// Add invoice history
InvoiceHistory::create([
'company_id' => $event->invoice->company_id,
'invoice_id' => $event->invoice->id,
'status' => 'sent',
'notify' => 0,
'description' => trans('invoices.mark_sent'),
]);
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.mark_sent')));
}
}

View File

@@ -3,9 +3,13 @@
namespace App\Listeners\Sale;
use App\Events\Sale\InvoiceViewed as Event;
use App\Jobs\Sale\CreateInvoiceHistory;
use App\Traits\Jobs;
class MarkInvoiceViewed
{
use Jobs;
/**
* Handle the event.
*
@@ -24,5 +28,7 @@ class MarkInvoiceViewed
$invoice->status = 'viewed';
$invoice->save();
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, trans('invoices.mark_viewed')));
}
}