added invoice paid calculation event
This commit is contained in:
parent
0d8f524fad
commit
c63515c21c
@ -3,6 +3,7 @@
|
|||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
|
use App\Events\Sale\InvoicePaidCalculated;
|
||||||
use App\Models\Setting\Tax;
|
use App\Models\Setting\Tax;
|
||||||
use App\Traits\Currencies;
|
use App\Traits\Currencies;
|
||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
@ -115,7 +116,13 @@ abstract class DocumentModel extends Model
|
|||||||
|
|
||||||
$this->setAttribute('reconciled', $reconciled);
|
$this->setAttribute('reconciled', $reconciled);
|
||||||
|
|
||||||
return round($paid, $precision);
|
// TODO: find a cleaner way compatible with observer pattern
|
||||||
|
$i = new \stdClass();
|
||||||
|
$i->paid = $paid;
|
||||||
|
|
||||||
|
event(new InvoicePaidCalculated($i));
|
||||||
|
|
||||||
|
return round($i->paid, $precision);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the status label.
|
* Get the status label.
|
||||||
|
22
app/Events/Sale/InvoicePaidCalculated.php
Normal file
22
app/Events/Sale/InvoicePaidCalculated.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Sale;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class InvoicePaidCalculated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $invoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $invoice
|
||||||
|
*/
|
||||||
|
public function __construct($invoice)
|
||||||
|
{
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user