Fix [2904193] - Posting zero for interest bank statement line
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2904193&group_id=176962 Found a bigger problem with this - in postgresql reading a zero can lead to read a 0E-12 (zero with scale 12) and the comparison of this number .equals(Env.ZERO) return false - comparing with compareTo returns true SF Tracker: 2904193
This commit is contained in:
parent
837badd6ae
commit
6fbc51b639
|
@ -230,20 +230,22 @@ public final class FactLine extends X_Fact_Acct
|
||||||
if (AmtSourceCr != null)
|
if (AmtSourceCr != null)
|
||||||
setAmtSourceCr (AmtSourceCr);
|
setAmtSourceCr (AmtSourceCr);
|
||||||
// one needs to be non zero
|
// one needs to be non zero
|
||||||
if (getAmtSourceDr().equals(Env.ZERO) && getAmtSourceCr().equals(Env.ZERO))
|
if (getAmtSourceDr().compareTo(Env.ZERO)==0 && getAmtSourceCr().compareTo(Env.ZERO)==0)
|
||||||
return false;
|
return false;
|
||||||
// Currency Precision
|
// Currency Precision
|
||||||
int precision = MCurrency.getStdPrecision(getCtx(), C_Currency_ID);
|
int precision = MCurrency.getStdPrecision(getCtx(), C_Currency_ID);
|
||||||
if (AmtSourceDr != null && AmtSourceDr.scale() > precision)
|
if (AmtSourceDr != null && AmtSourceDr.scale() > precision)
|
||||||
{
|
{
|
||||||
BigDecimal AmtSourceDr1 = AmtSourceDr.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
BigDecimal AmtSourceDr1 = AmtSourceDr.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
||||||
log.warning("Source DR Precision " + AmtSourceDr + " -> " + AmtSourceDr1);
|
if (AmtSourceDr1.compareTo(AmtSourceDr) != 0)
|
||||||
|
log.warning("Source DR Precision " + AmtSourceDr + " -> " + AmtSourceDr1);
|
||||||
setAmtSourceDr(AmtSourceDr1);
|
setAmtSourceDr(AmtSourceDr1);
|
||||||
}
|
}
|
||||||
if (AmtSourceCr != null && AmtSourceCr.scale() > precision)
|
if (AmtSourceCr != null && AmtSourceCr.scale() > precision)
|
||||||
{
|
{
|
||||||
BigDecimal AmtSourceCr1 = AmtSourceCr.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
BigDecimal AmtSourceCr1 = AmtSourceCr.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
||||||
log.warning("Source CR Precision " + AmtSourceCr + " -> " + AmtSourceCr1);
|
if (AmtSourceCr1.compareTo(AmtSourceCr) != 0)
|
||||||
|
log.warning("Source CR Precision " + AmtSourceCr + " -> " + AmtSourceCr1);
|
||||||
setAmtSourceCr(AmtSourceCr1);
|
setAmtSourceCr(AmtSourceCr1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class Matcher
|
||||||
BigDecimal qty1 = rs.getBigDecimal(8);
|
BigDecimal qty1 = rs.getBigDecimal(8);
|
||||||
BigDecimal qty2 = rs.getBigDecimal(9);
|
BigDecimal qty2 = rs.getBigDecimal(9);
|
||||||
BigDecimal Qty = qty1.min(qty2);
|
BigDecimal Qty = qty1.min(qty2);
|
||||||
if (Qty.equals(Env.ZERO))
|
if (Qty.compareTo(Env.ZERO)==0)
|
||||||
continue;
|
continue;
|
||||||
Timestamp dateTrx1 = rs.getTimestamp(6);
|
Timestamp dateTrx1 = rs.getTimestamp(6);
|
||||||
Timestamp dateTrx2 = rs.getTimestamp(7);
|
Timestamp dateTrx2 = rs.getTimestamp(7);
|
||||||
|
|
|
@ -263,19 +263,19 @@ public class ProductInfo
|
||||||
// Try to find non ZERO Price
|
// Try to find non ZERO Price
|
||||||
String costSource = "PriceList-PO";
|
String costSource = "PriceList-PO";
|
||||||
BigDecimal costs = getPriceList (as, true);
|
BigDecimal costs = getPriceList (as, true);
|
||||||
if (costs == null || costs.equals(Env.ZERO))
|
if (costs == null || costs.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
costSource = "PO Cost";
|
costSource = "PO Cost";
|
||||||
costs = getPOCost(as);
|
costs = getPOCost(as);
|
||||||
}
|
}
|
||||||
if (costs == null || costs.equals(Env.ZERO))
|
if (costs == null || costs.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
costSource = "PriceList";
|
costSource = "PriceList";
|
||||||
costs = getPriceList (as, false);
|
costs = getPriceList (as, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not found use $1 (to be able to do material transactions)
|
// if not found use $1 (to be able to do material transactions)
|
||||||
if (costs == null || costs.equals(Env.ZERO))
|
if (costs == null || costs.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
costSource = "Not Found";
|
costSource = "Not Found";
|
||||||
costs = new BigDecimal("1");
|
costs = new BigDecimal("1");
|
||||||
|
@ -341,12 +341,12 @@ public class ProductInfo
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BigDecimal price = PriceLimit; // best bet
|
BigDecimal price = PriceLimit; // best bet
|
||||||
if (price == null || price.equals(Env.ZERO))
|
if (price == null || price.compareTo(Env.ZERO)==0)
|
||||||
price = PriceStd;
|
price = PriceStd;
|
||||||
if (price == null || price.equals(Env.ZERO))
|
if (price == null || price.compareTo(Env.ZERO)==0)
|
||||||
price = PriceList;
|
price = PriceList;
|
||||||
// Convert
|
// Convert
|
||||||
if (price != null && !price.equals(Env.ZERO))
|
if (price != null && price.compareTo(Env.ZERO)!=0)
|
||||||
price = MConversionRate.convert (as.getCtx(),
|
price = MConversionRate.convert (as.getCtx(),
|
||||||
price, C_Currency_ID, as.getC_Currency_ID(),
|
price, C_Currency_ID, as.getC_Currency_ID(),
|
||||||
as.getAD_Client_ID(), 0);
|
as.getAD_Client_ID(), 0);
|
||||||
|
@ -396,12 +396,12 @@ public class ProductInfo
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BigDecimal cost = PriceLastPO; // best bet
|
BigDecimal cost = PriceLastPO; // best bet
|
||||||
if (cost == null || cost.equals(Env.ZERO))
|
if (cost == null || cost.compareTo(Env.ZERO)==0)
|
||||||
cost = PricePO;
|
cost = PricePO;
|
||||||
if (cost == null || cost.equals(Env.ZERO))
|
if (cost == null || cost.compareTo(Env.ZERO)==0)
|
||||||
cost = PriceList;
|
cost = PriceList;
|
||||||
// Convert - standard precision!! - should be costing precision
|
// Convert - standard precision!! - should be costing precision
|
||||||
if (cost != null && !cost.equals(Env.ZERO))
|
if (cost != null && cost.compareTo(Env.ZERO)!=0)
|
||||||
cost = MConversionRate.convert (as.getCtx(),
|
cost = MConversionRate.convert (as.getCtx(),
|
||||||
cost, C_Currency_ID, as.getC_Currency_ID(), m_AD_Client_ID, m_AD_Org_ID);
|
cost, C_Currency_ID, as.getC_Currency_ID(), m_AD_Client_ID, m_AD_Org_ID);
|
||||||
return cost;
|
return cost;
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class CalloutTimeExpense extends CalloutEngine
|
||||||
// Converted Amount = Unit price
|
// Converted Amount = Unit price
|
||||||
BigDecimal ConvertedAmt = ExpenseAmt;
|
BigDecimal ConvertedAmt = ExpenseAmt;
|
||||||
// convert if required
|
// convert if required
|
||||||
if (!ConvertedAmt.equals(Env.ZERO) && C_Currency_To_ID != C_Currency_From_ID.intValue())
|
if (ConvertedAmt.compareTo(Env.ZERO)!=0 && C_Currency_To_ID != C_Currency_From_ID.intValue())
|
||||||
{
|
{
|
||||||
int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
|
int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
|
||||||
int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
|
int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class MAsset extends X_A_Asset
|
||||||
public BigDecimal getQty ()
|
public BigDecimal getQty ()
|
||||||
{
|
{
|
||||||
BigDecimal qty = super.getQty();
|
BigDecimal qty = super.getQty();
|
||||||
if (qty == null || qty.equals(Env.ZERO))
|
if (qty == null || qty.compareTo(Env.ZERO)==0)
|
||||||
setQty(Env.ONE);
|
setQty(Env.ONE);
|
||||||
return super.getQty();
|
return super.getQty();
|
||||||
} // getQty
|
} // getQty
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class MConversionRate extends X_C_Conversion_Rate
|
||||||
{
|
{
|
||||||
if (Amt == null)
|
if (Amt == null)
|
||||||
throw new IllegalArgumentException("Required parameter missing - Amt");
|
throw new IllegalArgumentException("Required parameter missing - Amt");
|
||||||
if (CurFrom_ID == CurTo_ID || Amt.equals(Env.ZERO))
|
if (CurFrom_ID == CurTo_ID || Amt.compareTo(Env.ZERO)==0)
|
||||||
return Amt;
|
return Amt;
|
||||||
// Get Rate
|
// Get Rate
|
||||||
BigDecimal retValue = getRate (CurFrom_ID, CurTo_ID,
|
BigDecimal retValue = getRate (CurFrom_ID, CurTo_ID,
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class MUOMConversion extends X_C_UOM_Conversion
|
||||||
static public BigDecimal convert (Properties ctx,
|
static public BigDecimal convert (Properties ctx,
|
||||||
int C_UOM_ID, int C_UOM_To_ID, BigDecimal qty)
|
int C_UOM_ID, int C_UOM_To_ID, BigDecimal qty)
|
||||||
{
|
{
|
||||||
if (qty == null || qty.equals(Env.ZERO) || C_UOM_ID == C_UOM_To_ID)
|
if (qty == null || qty.compareTo(Env.ZERO)==0 || C_UOM_ID == C_UOM_To_ID)
|
||||||
return qty;
|
return qty;
|
||||||
BigDecimal retValue = getRate (ctx, C_UOM_ID, C_UOM_To_ID);
|
BigDecimal retValue = getRate (ctx, C_UOM_ID, C_UOM_To_ID);
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
|
@ -397,7 +397,7 @@ public class MUOMConversion extends X_C_UOM_Conversion
|
||||||
BigDecimal qty, boolean StdPrecision)
|
BigDecimal qty, boolean StdPrecision)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
if (qty == null || qty.equals(Env.ZERO)
|
if (qty == null || qty.compareTo(Env.ZERO)==0
|
||||||
|| C_UOM_From_ID == C_UOM_To_ID)
|
|| C_UOM_From_ID == C_UOM_To_ID)
|
||||||
return qty;
|
return qty;
|
||||||
//
|
//
|
||||||
|
@ -530,7 +530,7 @@ public class MUOMConversion extends X_C_UOM_Conversion
|
||||||
int M_Product_ID, int C_UOM_To_ID, BigDecimal qtyPrice)
|
int M_Product_ID, int C_UOM_To_ID, BigDecimal qtyPrice)
|
||||||
{
|
{
|
||||||
// No conversion
|
// No conversion
|
||||||
if (qtyPrice == null || qtyPrice.equals(Env.ZERO)
|
if (qtyPrice == null || qtyPrice.compareTo(Env.ZERO)==0
|
||||||
|| C_UOM_To_ID == 0|| M_Product_ID == 0)
|
|| C_UOM_To_ID == 0|| M_Product_ID == 0)
|
||||||
{
|
{
|
||||||
s_log.fine("No Conversion - QtyPrice=" + qtyPrice);
|
s_log.fine("No Conversion - QtyPrice=" + qtyPrice);
|
||||||
|
|
|
@ -365,12 +365,12 @@ public class ProductCost
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Costs
|
// Return Costs
|
||||||
if (costType != null && cost != null && !cost.equals(Env.ZERO))
|
if (costType != null && cost != null && cost.compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
log.fine("Costs=" + cost);
|
log.fine("Costs=" + cost);
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
else if (current != null && !current.equals(Env.ZERO))
|
else if (current != null && current.compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
log.fine("Current=" + current);
|
log.fine("Current=" + current);
|
||||||
return current;
|
return current;
|
||||||
|
@ -414,19 +414,19 @@ public class ProductCost
|
||||||
// Try to find non ZERO Price
|
// Try to find non ZERO Price
|
||||||
String costSource = "PriceList-PO";
|
String costSource = "PriceList-PO";
|
||||||
BigDecimal costs = getPriceList (as, true);
|
BigDecimal costs = getPriceList (as, true);
|
||||||
if (costs == null || costs.equals(Env.ZERO))
|
if (costs == null || costs.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
costSource = "PO Cost";
|
costSource = "PO Cost";
|
||||||
costs = getPOCost(as);
|
costs = getPOCost(as);
|
||||||
}
|
}
|
||||||
if (costs == null || costs.equals(Env.ZERO))
|
if (costs == null || costs.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
costSource = "PriceList";
|
costSource = "PriceList";
|
||||||
costs = getPriceList (as, false);
|
costs = getPriceList (as, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not found use $1 (to be able to do material transactions)
|
// if not found use $1 (to be able to do material transactions)
|
||||||
if (costs == null || costs.equals(Env.ZERO))
|
if (costs == null || costs.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
costSource = "Not Found";
|
costSource = "Not Found";
|
||||||
costs = new BigDecimal("1");
|
costs = new BigDecimal("1");
|
||||||
|
@ -492,12 +492,12 @@ public class ProductCost
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BigDecimal price = PriceLimit; // best bet
|
BigDecimal price = PriceLimit; // best bet
|
||||||
if (price == null || price.equals(Env.ZERO))
|
if (price == null || price.compareTo(Env.ZERO)==0)
|
||||||
price = PriceStd;
|
price = PriceStd;
|
||||||
if (price == null || price.equals(Env.ZERO))
|
if (price == null || price.compareTo(Env.ZERO)==0)
|
||||||
price = PriceList;
|
price = PriceList;
|
||||||
// Convert
|
// Convert
|
||||||
if (price != null && !price.equals(Env.ZERO))
|
if (price != null && price.compareTo(Env.ZERO)!=0)
|
||||||
price = MConversionRate.convert (as.getCtx(),
|
price = MConversionRate.convert (as.getCtx(),
|
||||||
price, C_Currency_ID, as.getC_Currency_ID(),
|
price, C_Currency_ID, as.getC_Currency_ID(),
|
||||||
as.getAD_Client_ID(), 0);
|
as.getAD_Client_ID(), 0);
|
||||||
|
@ -547,12 +547,12 @@ public class ProductCost
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BigDecimal cost = PriceLastPO; // best bet
|
BigDecimal cost = PriceLastPO; // best bet
|
||||||
if (cost == null || cost.equals(Env.ZERO))
|
if (cost == null || cost.compareTo(Env.ZERO)==0)
|
||||||
cost = PricePO;
|
cost = PricePO;
|
||||||
if (cost == null || cost.equals(Env.ZERO))
|
if (cost == null || cost.compareTo(Env.ZERO)==0)
|
||||||
cost = PriceList;
|
cost = PriceList;
|
||||||
// Convert - standard precision!! - should be costing precision
|
// Convert - standard precision!! - should be costing precision
|
||||||
if (cost != null && !cost.equals(Env.ZERO))
|
if (cost != null && cost.compareTo(Env.ZERO)!=0)
|
||||||
cost = MConversionRate.convert (as.getCtx(),
|
cost = MConversionRate.convert (as.getCtx(),
|
||||||
cost, C_Currency_ID, as.getC_Currency_ID(), as.getAD_Client_ID(), as.getAD_Org_ID());
|
cost, C_Currency_ID, as.getC_Currency_ID(), as.getAD_Client_ID(), as.getAD_Org_ID());
|
||||||
return cost;
|
return cost;
|
||||||
|
|
|
@ -526,7 +526,7 @@ public class POSManager
|
||||||
cashLine.setWriteOffAmt(writeOffAmount);
|
cashLine.setWriteOffAmt(writeOffAmount);
|
||||||
cashLine.setDiscountAmt(discountAmt);
|
cashLine.setDiscountAmt(discountAmt);
|
||||||
|
|
||||||
if(!(discountAmt.equals(Env.ZERO)))
|
if(!(discountAmt.compareTo(Env.ZERO)==0))
|
||||||
{
|
{
|
||||||
cashLine.setAmount(invoice.getGrandTotal().subtract(discountAmt).subtract(writeOffAmount));
|
cashLine.setAmount(invoice.getGrandTotal().subtract(discountAmt).subtract(writeOffAmount));
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ public class POSManager
|
||||||
paymentCreated = true;
|
paymentCreated = true;
|
||||||
BigDecimal amt = null;
|
BigDecimal amt = null;
|
||||||
|
|
||||||
if(!(discountAmt.equals(Env.ZERO)))
|
if(!(discountAmt.compareTo(Env.ZERO)==0))
|
||||||
{
|
{
|
||||||
amt = invoice.getGrandTotal().subtract(discountAmt).subtract(writeOffAmount);
|
amt = invoice.getGrandTotal().subtract(discountAmt).subtract(writeOffAmount);
|
||||||
}
|
}
|
||||||
|
@ -833,7 +833,7 @@ public class POSManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!subTotal.equals(Env.ZERO))
|
if(subTotal.compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -891,11 +891,11 @@ public class POSManager
|
||||||
totalLines = totalLines.add(bean.getLineNetAmt());
|
totalLines = totalLines.add(bean.getLineNetAmt());
|
||||||
totalTax = totalTax.add(bean.getTaxAmt());
|
totalTax = totalTax.add(bean.getTaxAmt());
|
||||||
totalQty=totalQty.add(bean.getQtyTotal());
|
totalQty=totalQty.add(bean.getQtyTotal());
|
||||||
if (bean.getDiscountAmt()!=null && !bean.getDiscountAmt().equals(Env.ZERO))
|
if (bean.getDiscountAmt()!=null && bean.getDiscountAmt().compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
discountAmt = bean.getDiscountAmt();
|
discountAmt = bean.getDiscountAmt();
|
||||||
}
|
}
|
||||||
if (bean.getWriteOffAmt()!=null && !bean.getWriteOffAmt().equals(Env.ZERO))
|
if (bean.getWriteOffAmt()!=null && bean.getWriteOffAmt().compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
writeOffAmt = bean.getWriteOffAmt();
|
writeOffAmt = bean.getWriteOffAmt();
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class ShoppingcartManager
|
||||||
//weird logic!
|
//weird logic!
|
||||||
|
|
||||||
BigDecimal discountedTotal = bean.getPayAmt();
|
BigDecimal discountedTotal = bean.getPayAmt();
|
||||||
/*if(bean.getDiscountAmt()!=null && bean.getDiscountAmt().equals(Env.ZERO))
|
/*if(bean.getDiscountAmt()!=null && bean.getDiscountAmt().compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
discountedTotal = null;
|
discountedTotal = null;
|
||||||
} */
|
} */
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class POSSalesReportManager
|
||||||
|
|
||||||
taxAmt = webOrderLineBean.getTaxAmt();
|
taxAmt = webOrderLineBean.getTaxAmt();
|
||||||
|
|
||||||
if(taxAmt.equals(Env.ZERO))
|
if(taxAmt.compareTo(Env.ZERO)==0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(order.getOrderType().equals(UDIOrderTypes.POS_ORDER.getOrderType()))
|
if(order.getOrderType().equals(UDIOrderTypes.POS_ORDER.getOrderType()))
|
||||||
|
@ -859,7 +859,7 @@ public class POSSalesReportManager
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!sales.equals(Env.ZERO))
|
if (sales.compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
BigDecimal profit = sales.subtract(cost);
|
BigDecimal profit = sales.subtract(cost);
|
||||||
|
|
||||||
|
|
|
@ -318,13 +318,13 @@ public class StockManager
|
||||||
discountedLineTotal = bean.getPrice();
|
discountedLineTotal = bean.getPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discountPercentOnLine != null && !discountPercentOnLine.equals(Env.ZERO))
|
if (discountPercentOnLine != null && discountPercentOnLine.compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
BigDecimal discFactor = (Env.ONEHUNDRED.subtract(discountPercentOnLine)).divide(Env.ONEHUNDRED, 12, RoundingMode.HALF_DOWN);
|
BigDecimal discFactor = (Env.ONEHUNDRED.subtract(discountPercentOnLine)).divide(Env.ONEHUNDRED, 12, RoundingMode.HALF_DOWN);
|
||||||
actualLineInclTotalPrice = (lineTotal).multiply(discFactor).setScale(2, RoundingMode.HALF_UP);
|
actualLineInclTotalPrice = (lineTotal).multiply(discFactor).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (discountedLineInclUnitPrice != null && !discountedLineInclUnitPrice.equals(Env.ZERO))
|
else if (discountedLineInclUnitPrice != null && discountedLineInclUnitPrice.compareTo(Env.ZERO)!=0)
|
||||||
{
|
{
|
||||||
if(isTaxIncluded)
|
if(isTaxIncluded)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue