* [ 1647734 ] incorrect cost used in Shipment and MM (Avg PO costing)

This commit is contained in:
Heng Sin Low 2007-03-26 03:44:30 +00:00
parent 7227891daa
commit f1a78ab8c9
2 changed files with 77 additions and 51 deletions

View File

@ -21,6 +21,7 @@ import java.sql.*;
import java.util.*;
import org.compiere.model.*;
import java.util.logging.*;
import org.compiere.util.*;
@ -62,7 +63,7 @@ public class Doc_InOut extends Doc
} // loadDocumentDetails
/**
* Load Invoice Line
* Load InOut Line
* @param inout shipment/receipt
* @return DocLine Array
*/
@ -199,8 +200,25 @@ public class Doc_InOut extends Doc
for (int i = 0; i < p_lines.length; i++)
{
DocLine line = p_lines[i];
BigDecimal costs = line.getProductCosts(as, line.getAD_Org_ID(), false); // non-zero costs
BigDecimal costs = null;
MProduct product = line.getProduct();
//get costing method for product
String costingMethod = as.getCostingMethod();
MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(),
product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), getTrxName());
if (pca.getCostingMethod() != null)
costingMethod = pca.getCostingMethod();
if (MAcctSchema.COSTINGMETHOD_AveragePO.equals(costingMethod) ||
MAcctSchema.COSTINGMETHOD_LastPOPrice.equals(costingMethod) )
{
int C_OrderLine_ID = line.getC_OrderLine_ID();
MOrderLine orderLine = new MOrderLine (getCtx(), C_OrderLine_ID, getTrxName());
costs = orderLine.getPriceCost();
}
else
{
costs = line.getProductCosts(as, line.getAD_Org_ID(), false); // current costs
}
if (costs == null || costs.signum() == 0)
{
p_Error = "Resubmit - No Costs for " + product.getName();

View File

@ -147,16 +147,20 @@ public class Doc_MatchPO extends Doc
poCost, getQty(), // Delivered
m_oLine.getDescription(), getTrxName());
// Current Costs
// Calculate PPV for standard costing
String costingMethod = as.getCostingMethod();
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(),
product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), getTrxName());
if (pca.getCostingMethod() != null)
costingMethod = pca.getCostingMethod();
BigDecimal costs = m_pc.getProductCosts(as, getAD_Org_ID(),
costingMethod, m_C_OrderLine_ID, false); // non-zero costs
//get standard cost and also makesure cost for other costing method is updated
BigDecimal costs = m_pc.getProductCosts(as, getAD_Org_ID(),
MAcctSchema.COSTINGMETHOD_StandardCosting, m_C_OrderLine_ID, false); // non-zero costs
if (MAcctSchema.COSTINGMETHOD_StandardCosting.equals(costingMethod))
{
// No Costs yet - no PPV
if (costs == null || costs.signum() == 0)
{
@ -171,7 +175,6 @@ public class Doc_MatchPO extends Doc
if (difference.signum() == 0)
{
log.log(Level.FINE, "No Cost Difference for M_Product_ID=" + getM_Product_ID());
facts.add(fact);
return facts;
}
@ -210,6 +213,11 @@ public class Doc_MatchPO extends Doc
//
facts.add(fact);
return facts;
}
else
{
return facts;
}
} // createFact
/**