IDEMPIERE-216 Average Costing: Zero Costing Item From Vendor.

This commit is contained in:
Heng Sin Low 2013-07-03 17:44:15 +08:00
parent 84cb0a829f
commit a9d61ac0a4
2 changed files with 30 additions and 29 deletions

View File

@ -184,9 +184,19 @@ public class Doc_InOut extends Doc
MProduct product = line.getProduct(); MProduct product = line.getProduct();
if (product.isStocked()) if (product.isStocked())
{ {
p_Error = "No Costs for " + line.getProduct().getName(); //ok if we have purchased zero cost item from vendor before
log.log(Level.WARNING, p_Error); int count = DB.getSQLValue(null, "SELECT Count(*) FROM M_CostDetail WHERE M_Product_ID=? AND Processed='Y' AND Amt=0.00 AND Qty > 0 AND (C_OrderLine_ID > 0 OR C_InvoiceLine_ID > 0)",
return null; product.getM_Product_ID());
if (count > 0)
{
costs = BigDecimal.ZERO;
}
else
{
p_Error = "No Costs for " + line.getProduct().getName();
log.log(Level.WARNING, p_Error);
return null;
}
} }
else // ignore service else // ignore service
continue; continue;
@ -387,6 +397,7 @@ public class Doc_InOut extends Doc
DocLine line = p_lines[i]; DocLine line = p_lines[i];
BigDecimal costs = null; BigDecimal costs = null;
MProduct product = line.getProduct(); MProduct product = line.getProduct();
MOrderLine orderLine = null;
if (!isReversal(line)) if (!isReversal(line))
{ {
//get costing method for product //get costing method for product
@ -399,7 +410,7 @@ public class Doc_InOut extends Doc
// Low - check if c_orderline_id is valid // Low - check if c_orderline_id is valid
if (C_OrderLine_ID > 0) if (C_OrderLine_ID > 0)
{ {
MOrderLine orderLine = new MOrderLine (getCtx(), C_OrderLine_ID, getTrxName()); orderLine = new MOrderLine (getCtx(), C_OrderLine_ID, getTrxName());
// Elaine 2008/06/26 // Elaine 2008/06/26
C_Currency_ID = orderLine.getC_Currency_ID(); C_Currency_ID = orderLine.getC_Currency_ID();
// //
@ -424,7 +435,7 @@ public class Doc_InOut extends Doc
costs = costs.multiply(line.getQty()); costs = costs.multiply(line.getQty());
} }
else else
{ {
p_Error = "Resubmit - No Costs for " + product.getName() + " (required order line)"; p_Error = "Resubmit - No Costs for " + product.getName() + " (required order line)";
log.log(Level.WARNING, p_Error); log.log(Level.WARNING, p_Error);
return null; return null;
@ -438,9 +449,17 @@ public class Doc_InOut extends Doc
if (costs == null || costs.signum() == 0) if (costs == null || costs.signum() == 0)
{ {
p_Error = "Resubmit - No Costs for " + product.getName(); //ok if purchase price is actually zero
log.log(Level.WARNING, p_Error); if (orderLine != null && orderLine.getPriceActual().signum() == 0)
return null; {
costs = BigDecimal.ZERO;
}
else
{
p_Error = "Resubmit - No Costs for " + product.getName();
log.log(Level.WARNING, p_Error);
return null;
}
} }
} }
else else

View File

@ -205,27 +205,9 @@ public class Doc_MatchInv extends Doc
if (log.isLoggable(Level.FINE)) log.fine("Line Net Amt=0 - M_Product_ID=" + getM_Product_ID() if (log.isLoggable(Level.FINE)) log.fine("Line Net Amt=0 - M_Product_ID=" + getM_Product_ID()
+ ",Qty=" + getQty() + ",InOutQty=" + m_receiptLine.getMovementQty()); + ",Qty=" + getQty() + ",InOutQty=" + m_receiptLine.getMovementQty());
// Invoice Price Variance cr = fact.createLine (null, expense, as.getC_Currency_ID(), null, Env.ONE);
BigDecimal ipv = dr.getSourceBalance().negate(); cr.setAmtAcctCr(BigDecimal.ZERO);
if (ipv.signum() != 0) cr.setAmtSourceCr(BigDecimal.ZERO);
{
MInvoice m_invoice = m_invoiceLine.getParent();
int C_Currency_ID = m_invoice.getC_Currency_ID();
FactLine pv = fact.createLine(null,
m_pc.getAccount(ProductCost.ACCTTYPE_P_IPV, as),
C_Currency_ID, ipv);
pv.setC_Activity_ID(m_invoiceLine.getC_Activity_ID());
pv.setC_Campaign_ID(m_invoiceLine.getC_Campaign_ID());
pv.setC_Project_ID(m_invoiceLine.getC_Project_ID());
pv.setC_ProjectPhase_ID(m_invoiceLine.getC_ProjectPhase_ID());
pv.setC_ProjectTask_ID(m_invoiceLine.getC_ProjectTask_ID());
pv.setC_UOM_ID(m_invoiceLine.getC_UOM_ID());
pv.setUser1_ID(m_invoiceLine.getUser1_ID());
pv.setUser2_ID(m_invoiceLine.getUser2_ID());
}
if (log.isLoggable(Level.FINE)) log.fine("IPV=" + ipv + "; Balance=" + fact.getSourceBalance());
facts.add(fact);
return facts;
} }
cr.setQty(getQty().negate()); cr.setQty(getQty().negate());
temp = cr.getAcctBalance(); temp = cr.getAcctBalance();