Fix discount computation. #343

This commit is contained in:
Korina Cordero 2020-02-17 01:02:41 +00:00
parent d439a411a8
commit a15b45173c
2 changed files with 3 additions and 8 deletions

View file

@ -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)
*/ */

View file

@ -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)
{ {