IDEMPIERE-1174 Found a matchinv created on matchpo was not being posted on immediate accounting / follow recommendation from Heng Sin about privacy of method

This commit is contained in:
Carlos Ruiz 2013-07-17 22:04:15 -05:00
parent 46585842d2
commit 61b9cd9508
4 changed files with 49 additions and 12 deletions

View File

@ -1630,7 +1630,6 @@ public class MInOut extends X_M_InOut implements DocAction
addDocsPostProcess(po); addDocsPostProcess(po);
if (po.getMatchInvCreated() != null) { if (po.getMatchInvCreated() != null) {
addDocsPostProcess(po.getMatchInvCreated()); addDocsPostProcess(po.getMatchInvCreated());
po.setMatchInvCreated(null);
} }
} }
// Update PO with ASI // Update PO with ASI

View File

@ -650,10 +650,14 @@ public class MInOutLine extends X_M_InOutLine
{ {
MInvoiceLine m_il = MInvoiceLine.getOfInOutLine(this); MInvoiceLine m_il = MInvoiceLine.getOfInOutLine(this);
if (m_il == null) if (m_il == null)
{
m_il = MInvoiceLine.getOfInOutLineFromMatchInv(this);
if (m_il == null)
{ {
log.severe("No Invoice Line for: " + this.toString()); log.severe("No Invoice Line for: " + this.toString());
return Env.ZERO; return Env.ZERO;
} }
}
return this.getMovementQty().multiply(m_il.getPriceActual()); // Actual delivery return this.getMovementQty().multiply(m_il.getPriceActual()); // Actual delivery
} }
else if (MLandedCost.LANDEDCOSTDISTRIBUTION_Line.equals(CostDistribution)) else if (MLandedCost.LANDEDCOSTDISTRIBUTION_Line.equals(CostDistribution))

View File

@ -52,7 +52,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
/** /**
* *
*/ */
private static final long serialVersionUID = -5113860437274708398L; private static final long serialVersionUID = 6157080330492848409L;
/** /**
* Get Invoice Line referencing InOut Line * Get Invoice Line referencing InOut Line
@ -78,6 +78,29 @@ public class MInvoiceLine extends X_C_InvoiceLine
return retValue; return retValue;
} // getOfInOutLine } // 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<MInvoiceLine> 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 */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MInvoiceLine.class); private static CLogger s_log = CLogger.getCLogger (MInvoiceLine.class);
@ -1053,9 +1076,9 @@ public class MInvoiceLine extends X_C_InvoiceLine
// end MZ // end MZ
if (base.signum() != 0) if (base.signum() != 0)
{ {
double result = getLineNetAmt().multiply(base).doubleValue(); BigDecimal result = getLineNetAmt().multiply(base);
result /= total.doubleValue(); result = result.divide(total, BigDecimal.ROUND_HALF_UP);
lca.setAmt(result, getPrecision()); lca.setAmt(result.doubleValue(), getPrecision());
} }
if (!lca.save()){ if (!lca.save()){
msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca); msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca);
@ -1079,6 +1102,8 @@ public class MInvoiceLine extends X_C_InvoiceLine
lca.setM_Product_ID(iol.getM_Product_ID()); lca.setM_Product_ID(iol.getM_Product_ID());
lca.setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID()); lca.setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID());
BigDecimal base = iol.getBase(lc.getLandedCostDistribution()); BigDecimal base = iol.getBase(lc.getLandedCostDistribution());
if (base.signum() == 0)
return "Base value is 0 - " + lc.getLandedCostDistribution();
lca.setBase(base); lca.setBase(base);
lca.setAmt(getLineNetAmt()); lca.setAmt(getLineNetAmt());
// MZ Goodwill // MZ Goodwill
@ -1174,9 +1199,9 @@ public class MInvoiceLine extends X_C_InvoiceLine
// end MZ // end MZ
if (base.signum() != 0) if (base.signum() != 0)
{ {
double result = getLineNetAmt().multiply(base).doubleValue(); BigDecimal result = getLineNetAmt().multiply(base);
result /= total.doubleValue(); result = result.divide(total, BigDecimal.ROUND_HALF_UP);
lca.setAmt(result, getPrecision()); lca.setAmt(result.doubleValue(), getPrecision());
} }
if (!lca.save()){ if (!lca.save()){
msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca); msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca);

View File

@ -551,15 +551,24 @@ public class MMatchPO extends X_M_MatchPO
private MMatchInv m_matchInv; private MMatchInv m_matchInv;
/** /**
* Register the match inv created for immediate accounting purposes * Register the match inv created for immediate accounting purposes
* @param matchInv * @param matchInv
*/ */
public void setMatchInvCreated(MMatchInv matchInv) { private void setMatchInvCreated(MMatchInv matchInv) {
m_matchInv = 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() { public MMatchInv getMatchInvCreated() {
return m_matchInv; MMatchInv tmp = m_matchInv;
m_matchInv = null;
return tmp;
} }
/** Static Logger */ /** Static Logger */