Fix discount computation. #343
This commit is contained in:
parent
d439a411a8
commit
a15b45173c
2 changed files with 3 additions and 8 deletions
|
|
@ -59,8 +59,7 @@ class Invoice
|
||||||
*/
|
*/
|
||||||
protected $items;
|
protected $items;
|
||||||
|
|
||||||
// total discount (amount, not %) for resq
|
// total discount (amount, not %)
|
||||||
// for cmb, discount is the percentage
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="decimal", precision=9, scale=2)
|
* @ORM\Column(type="decimal", precision=9, scale=2)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -385,17 +385,13 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface
|
||||||
|
|
||||||
protected function processDiscount(&$total, InvoiceCriteria $criteria, Invoice $invoice)
|
protected function processDiscount(&$total, InvoiceCriteria $criteria, Invoice $invoice)
|
||||||
{
|
{
|
||||||
$rate = 0;
|
$discount = 0;
|
||||||
$meta = $criteria->getMeta();
|
$meta = $criteria->getMeta();
|
||||||
if (isset($meta['discount']))
|
if (isset($meta['discount']))
|
||||||
$rate = $meta['discount'];
|
$discount = $meta['discount'];
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// compute discount
|
|
||||||
$rate = $rate * 0.01;
|
|
||||||
$discount = round($total['sell_price'] * $rate, 2);
|
|
||||||
|
|
||||||
// if discount is higher than 0, display in invoice
|
// if discount is higher than 0, display in invoice
|
||||||
if ($discount > 0)
|
if ($discount > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue