Author: sichen
Date: Wed Nov 29 13:47:26 2006
New Revision: 480727
URL:
http://svn.apache.org/viewvc?view=rev&rev=480727Log:
Fix potential divide by zero bug in create invoice services. NEVER USE .equals() WITH BIGDECIMALS
Modified:
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?view=diff&rev=480727&r1=480726&r2=480727==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Wed Nov 29 13:47:26 2006
@@ -774,7 +774,8 @@
String invoiceIdIn = (String) context.get("invoiceId");
String invoiceItemSeqIdIn = (String) context.get("invoiceItemSeqId");
BigDecimal amountTotal = InvoiceWorker.getInvoiceTotalBd(delegator, invoiceIdIn);
- if (amountTotal.equals(ZERO)) {
+ // never use equals for BigDecimal - use either signum or compareTo
+ if (amountTotal.signum() == 0) {
Debug.logWarning("Invoice [" + invoiceIdIn + "] has an amount total of [" + amountTotal + "], so no commission invoice will be created", module);
return ServiceUtil.returnSuccess(UtilProperties.getMessage(resource,"AccountingInvoiceCommissionZeroInvoiceAmount",locale));
}