diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java b/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java index b04b9f942f..09ebc9256c 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_InOut.java @@ -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 diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java index 9450906b0d..ef47927faa 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java @@ -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();