You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2011/10/28 04:06:37 UTC
svn commit: r1190134 -
/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
Author: apatel
Date: Fri Oct 28 02:06:37 2011
New Revision: 1190134
URL: http://svn.apache.org/viewvc?rev=1190134&view=rev
Log:
[OFBIZ-4519] Bug fix while Prorating adjustments for orderItem when its partially canceled. Martin Kreidenweis, Thanks for the fix and helping me understand the problem.
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=1190134&r1=1190133&r2=1190134&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Fri Oct 28 02:06:37 2011
@@ -522,27 +522,30 @@ public class InvoiceServices {
continue;
}
+ BigDecimal originalOrderItemQuantity = OrderReadHelper.getOrderItemQuantity(originalOrderItem);
BigDecimal amount = ZERO;
- if (adj.get("amount") != null) {
- // pro-rate the amount
- // set decimals = 100 means we don't round this intermediate value, which is very important
- amount = adj.getBigDecimal("amount").divide(originalOrderItem.getBigDecimal("quantity"), 100, ROUNDING);
- amount = amount.multiply(billingQuantity);
- // Tax needs to be rounded differently from other order adjustments
- if (adj.getString("orderAdjustmentTypeId").equals("SALES_TAX")) {
- amount = amount.setScale(TAX_DECIMALS, TAX_ROUNDING);
- } else {
+ if (originalOrderItemQuantity.signum() != 0) {
+ if (adj.get("amount") != null) {
+ // pro-rate the amount
+ // set decimals = 100 means we don't round this intermediate value, which is very important
+ amount = adj.getBigDecimal("amount").divide(originalOrderItemQuantity, 100, ROUNDING);
+ amount = amount.multiply(billingQuantity);
+ // Tax needs to be rounded differently from other order adjustments
+ if (adj.getString("orderAdjustmentTypeId").equals("SALES_TAX")) {
+ amount = amount.setScale(TAX_DECIMALS, TAX_ROUNDING);
+ } else {
+ amount = amount.setScale(invoiceTypeDecimals, ROUNDING);
+ }
+ } else if (adj.get("sourcePercentage") != null) {
+ // pro-rate the amount
+ // set decimals = 100 means we don't round this intermediate value, which is very important
+ BigDecimal percent = adj.getBigDecimal("sourcePercentage");
+ percent = percent.divide(new BigDecimal(100), 100, ROUNDING);
+ amount = billingAmount.multiply(percent);
+ amount = amount.divide(originalOrderItemQuantity, 100, ROUNDING);
+ amount = amount.multiply(billingQuantity);
amount = amount.setScale(invoiceTypeDecimals, ROUNDING);
}
- } else if (adj.get("sourcePercentage") != null) {
- // pro-rate the amount
- // set decimals = 100 means we don't round this intermediate value, which is very important
- BigDecimal percent = adj.getBigDecimal("sourcePercentage");
- percent = percent.divide(new BigDecimal(100), 100, ROUNDING);
- amount = billingAmount.multiply(percent);
- amount = amount.divide(originalOrderItem.getBigDecimal("quantity"), 100, ROUNDING);
- amount = amount.multiply(billingQuantity);
- amount = amount.setScale(invoiceTypeDecimals, ROUNDING);
}
if (amount.signum() != 0) {
Map<String, Object> createInvoiceItemAdjContext = FastMap.newInstance();