From a15b45173c660f0d33a10490e18d0068c44ad50e Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 17 Feb 2020 01:02:41 +0000 Subject: [PATCH] Fix discount computation. #343 --- src/Entity/Invoice.php | 3 +-- src/Service/InvoiceGenerator/CMBInvoiceGenerator.php | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Entity/Invoice.php b/src/Entity/Invoice.php index 2353b925..305c7d84 100644 --- a/src/Entity/Invoice.php +++ b/src/Entity/Invoice.php @@ -59,8 +59,7 @@ class Invoice */ protected $items; - // total discount (amount, not %) for resq - // for cmb, discount is the percentage + // total discount (amount, not %) /** * @ORM\Column(type="decimal", precision=9, scale=2) */ diff --git a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php index fa13b752..f1563d63 100644 --- a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php @@ -385,17 +385,13 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface protected function processDiscount(&$total, InvoiceCriteria $criteria, Invoice $invoice) { - $rate = 0; + $discount = 0; $meta = $criteria->getMeta(); if (isset($meta['discount'])) - $rate = $meta['discount']; + $discount = $meta['discount']; else 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 > 0) {