added viewed status to invoice factory
This commit is contained in:
		@@ -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')));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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')));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user