From 8390b8ed1692a82709cf0bbba1342a3b433c2724 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 17 Jul 2013 22:12:21 -0500 Subject: [PATCH] Backed out changeset 4c2a0e55b08a / wrong commit affecting two tickets and with a bug introduced, will fix in next IDEMPIERE-1174 --- .../src/org/compiere/model/MInOut.java | 1 + .../src/org/compiere/model/MInOutLine.java | 8 +--- .../src/org/compiere/model/MInvoiceLine.java | 39 ++++--------------- .../src/org/compiere/model/MMatchPO.java | 13 +------ 4 files changed, 12 insertions(+), 49 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index a2071bcd7a..e9eb47a446 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1630,6 +1630,7 @@ public class MInOut extends X_M_InOut implements DocAction addDocsPostProcess(po); if (po.getMatchInvCreated() != null) { addDocsPostProcess(po.getMatchInvCreated()); + po.setMatchInvCreated(null); } } // Update PO with ASI diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLine.java b/org.adempiere.base/src/org/compiere/model/MInOutLine.java index 0479bda181..2489de1d82 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLine.java @@ -651,12 +651,8 @@ public class MInOutLine extends X_M_InOutLine MInvoiceLine m_il = MInvoiceLine.getOfInOutLine(this); if (m_il == null) { - m_il = MInvoiceLine.getOfInOutLineFromMatchInv(this); - if (m_il == null) - { - log.severe("No Invoice Line for: " + this.toString()); - return Env.ZERO; - } + log.severe("No Invoice Line for: " + this.toString()); + return Env.ZERO; } return this.getMovementQty().multiply(m_il.getPriceActual()); // Actual delivery } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index b087747a1e..f55d4f5c05 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -52,7 +52,7 @@ public class MInvoiceLine extends X_C_InvoiceLine /** * */ - private static final long serialVersionUID = 6157080330492848409L; + private static final long serialVersionUID = -5113860437274708398L; /** * Get Invoice Line referencing InOut Line @@ -78,29 +78,6 @@ public class MInvoiceLine extends X_C_InvoiceLine return retValue; } // getOfInOutLine - /** - * Get Invoice Line referencing InOut Line - from MatchInv - * @param sLine shipment line - * @return (first) invoice line - */ - public static MInvoiceLine getOfInOutLineFromMatchInv(MInOutLine sLine) { - if (sLine == null) - return null; - final String whereClause = "C_InvoiceLine_ID IN (SELECT C_InvoiceLine_ID FROM M_MatchInv WHERE M_InOutLine_ID=?)"; - List list = new Query(sLine.getCtx(),I_C_InvoiceLine.Table_Name,whereClause,sLine.get_TrxName()) - .setParameters(sLine.getM_InOutLine_ID()) - .list(); - - MInvoiceLine retValue = null; - if (list.size() > 0) { - retValue = list.get(0); - if (list.size() > 1) - s_log.warning("More than one C_InvoiceLine of " + sLine); - } - - return retValue; - } - /** Static Logger */ private static CLogger s_log = CLogger.getCLogger (MInvoiceLine.class); @@ -1076,9 +1053,9 @@ public class MInvoiceLine extends X_C_InvoiceLine // end MZ if (base.signum() != 0) { - BigDecimal result = getLineNetAmt().multiply(base); - result = result.divide(total, BigDecimal.ROUND_HALF_UP); - lca.setAmt(result.doubleValue(), getPrecision()); + double result = getLineNetAmt().multiply(base).doubleValue(); + result /= total.doubleValue(); + lca.setAmt(result, getPrecision()); } if (!lca.save()){ msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca); @@ -1102,8 +1079,6 @@ public class MInvoiceLine extends X_C_InvoiceLine lca.setM_Product_ID(iol.getM_Product_ID()); lca.setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID()); BigDecimal base = iol.getBase(lc.getLandedCostDistribution()); - if (base.signum() == 0) - return "Base value is 0 - " + lc.getLandedCostDistribution(); lca.setBase(base); lca.setAmt(getLineNetAmt()); // MZ Goodwill @@ -1199,9 +1174,9 @@ public class MInvoiceLine extends X_C_InvoiceLine // end MZ if (base.signum() != 0) { - BigDecimal result = getLineNetAmt().multiply(base); - result = result.divide(total, BigDecimal.ROUND_HALF_UP); - lca.setAmt(result.doubleValue(), getPrecision()); + double result = getLineNetAmt().multiply(base).doubleValue(); + result /= total.doubleValue(); + lca.setAmt(result, getPrecision()); } if (!lca.save()){ msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca); diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index 8bc2e6e388..99bf94df30 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -551,24 +551,15 @@ public class MMatchPO extends X_M_MatchPO private MMatchInv m_matchInv; - /** * Register the match inv created for immediate accounting purposes * @param matchInv */ - private void setMatchInvCreated(MMatchInv matchInv) { + public void setMatchInvCreated(MMatchInv matchInv) { m_matchInv = matchInv; } - - /** - * Get the match inv created for immediate accounting purposes - * Is cleared after read, so if you read twice second time it returns null - * @param matchInv - */ public MMatchInv getMatchInvCreated() { - MMatchInv tmp = m_matchInv; - m_matchInv = null; - return tmp; + return m_matchInv; } /** Static Logger */