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();
if (product.isStocked())
{
p_Error = "No Costs for " + line.getProduct().getName();
log.log(Level.WARNING, p_Error);
return null;
//ok if we have purchased zero cost item from vendor before
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)",
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
continue;
@ -387,6 +397,7 @@ public class Doc_InOut extends Doc
DocLine line = p_lines[i];
BigDecimal costs = null;
MProduct product = line.getProduct();
MOrderLine orderLine = null;
if (!isReversal(line))
{
//get costing method for product
@ -399,7 +410,7 @@ public class Doc_InOut extends Doc
// Low - check if c_orderline_id is valid
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
C_Currency_ID = orderLine.getC_Currency_ID();
//
@ -424,7 +435,7 @@ public class Doc_InOut extends Doc
costs = costs.multiply(line.getQty());
}
else
{
{
p_Error = "Resubmit - No Costs for " + product.getName() + " (required order line)";
log.log(Level.WARNING, p_Error);
return null;
@ -438,9 +449,17 @@ public class Doc_InOut extends Doc
if (costs == null || costs.signum() == 0)
{
p_Error = "Resubmit - No Costs for " + product.getName();
log.log(Level.WARNING, p_Error);
return null;
//ok if purchase price is actually zero
if (orderLine != null && orderLine.getPriceActual().signum() == 0)
{
costs = BigDecimal.ZERO;
}
else
{
p_Error = "Resubmit - No Costs for " + product.getName();
log.log(Level.WARNING, p_Error);
return null;
}
}
}
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()
+ ",Qty=" + getQty() + ",InOutQty=" + m_receiptLine.getMovementQty());
// Invoice Price Variance
BigDecimal ipv = dr.getSourceBalance().negate();
if (ipv.signum() != 0)
{
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 = fact.createLine (null, expense, as.getC_Currency_ID(), null, Env.ONE);
cr.setAmtAcctCr(BigDecimal.ZERO);
cr.setAmtSourceCr(BigDecimal.ZERO);
}
cr.setQty(getQty().negate());
temp = cr.getAcctBalance();