From 23aa779df5ba2a6761af67b67ac8d402a5bd9608 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sat, 11 Jan 2020 11:19:23 +0100 Subject: [PATCH] Fixed: Bug when order contains adjustments with NULL amount (OFBIZ-11316) The issue was introduced by OFBIZ-7012 where adding isTaxIncludedInPrice was missing at line 565. Because the compared amount in this line (in the adjustment) is different from 0 and equals to amountAlreadyIncluded only if the tax is included in price Thanks: Amine Azzi --- .../org/apache/ofbiz/accounting/invoice/InvoiceServices.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java index 920625f2da..4abfdaa0ad 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java @@ -558,11 +558,11 @@ public class InvoiceServices { // Set adjustment amount as amountAlreadyIncluded to continue invoice item creation process Boolean isTaxIncludedInPrice = "VAT_TAX".equals(adj.getString("orderAdjustmentTypeId")) && UtilValidate.isNotEmpty(adj.getBigDecimal("amountAlreadyIncluded")) && adj.getBigDecimal("amountAlreadyIncluded").signum() != 0; - if ((adj.getBigDecimal("amount").signum() == 0) && isTaxIncludedInPrice) { + if (isTaxIncludedInPrice && (adj.getBigDecimal("amount").signum() == 0)) { adj.set("amount", adj.getBigDecimal("amountAlreadyIncluded")); } // If the absolute invoiced amount >= the abs of the adjustment amount, the full amount has already been invoiced, so skip this adjustment - if (adjAlreadyInvoicedAmount.abs().compareTo(adj.getBigDecimal("amount").setScale(invoiceTypeDecimals, ROUNDING).abs()) > 0) { + if (isTaxIncludedInPrice && adjAlreadyInvoicedAmount.abs().compareTo(adj.getBigDecimal("amount").setScale(invoiceTypeDecimals, ROUNDING).abs()) > 0) { continue; }