From 56ca5af7b1465031ec660221f729ac1dbdd726e6 Mon Sep 17 00:00:00 2001
From: Prakash M <prakash@qualiantech.com>
Date: Thu, 17 Dec 2020 18:26:41 +0530
Subject: [PATCH] Fixed BUG-45474: Fixes By Total discount is applied to a line
 of Free Product

---
 .../js/promotion-by-total-utils.js                          | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/web/org.openbravo.retail.discounts.bytotal/js/promotion-by-total-utils.js b/web/org.openbravo.retail.discounts.bytotal/js/promotion-by-total-utils.js
index 3a34d3f..c204b13 100644
--- a/web/org.openbravo.retail.discounts.bytotal/js/promotion-by-total-utils.js
+++ b/web/org.openbravo.retail.discounts.bytotal/js/promotion-by-total-utils.js
@@ -75,7 +75,7 @@ OB.Model.Discounts.DISCT = {
               price = OB.DEC.sub(price, (p.amt || 0));
             }
 
-          } else if (!discountRule.isAmount) {
+          } else {
             if (p.ruleId !== discountRule.id) {
               price = OB.DEC.sub(price, (p.amt || 0));
             }
@@ -124,6 +124,10 @@ OB.Model.Discounts.DISCT = {
 
         linePrice = getDiscountedLinePrice(l);
 
+        if (linePrice.price <= 0) {
+          return; //continue
+        }
+
         // total for PIT includes taxes and for no PIT does not
         total = OB.DEC.add(total, linePrice.price);
 
-- 
2.20.1

