IDEMPIERE-1173 1003754 Landed cost issue -- related to IDEMPIERE-1285. Fixed issues with one landed cost invoice line match against multiple receipt line. Handle incompatibility between average invoice and average po costing method.
This commit is contained in:
parent
8835fdb149
commit
5080fb0eed
|
@ -147,7 +147,7 @@ public class MCostDetail extends X_M_CostDetail
|
||||||
BigDecimal Amt, BigDecimal Qty,
|
BigDecimal Amt, BigDecimal Qty,
|
||||||
String Description, String trxName)
|
String Description, String trxName)
|
||||||
{
|
{
|
||||||
MCostDetail cd = get (as.getCtx(), "C_InvoiceLine_ID=? AND Coalesce(M_CostElement_ID,0)="+M_CostElement_ID,
|
MCostDetail cd = get (as.getCtx(), "C_InvoiceLine_ID=? AND Coalesce(M_CostElement_ID,0)="+M_CostElement_ID+" AND M_Product_ID="+M_Product_ID,
|
||||||
C_InvoiceLine_ID, M_AttributeSetInstance_ID, as.getC_AcctSchema_ID(), trxName);
|
C_InvoiceLine_ID, M_AttributeSetInstance_ID, as.getC_AcctSchema_ID(), trxName);
|
||||||
//
|
//
|
||||||
if (cd == null) // createNew
|
if (cd == null) // createNew
|
||||||
|
@ -921,6 +921,16 @@ public class MCostDetail extends X_M_CostDetail
|
||||||
private boolean process (MAcctSchema as, MProduct product, MCostElement ce,
|
private boolean process (MAcctSchema as, MProduct product, MCostElement ce,
|
||||||
int Org_ID, int M_ASI_ID)
|
int Org_ID, int M_ASI_ID)
|
||||||
{
|
{
|
||||||
|
//handle compatibility issue between average invoice and average po
|
||||||
|
String costingMethod = product.getCostingMethod(as);
|
||||||
|
if (X_M_Cost.COSTINGMETHOD_AverageInvoice.equals(costingMethod)) {
|
||||||
|
if (ce.isAveragePO())
|
||||||
|
return true;
|
||||||
|
} else if (X_M_Cost.COSTINGMETHOD_AveragePO.equals(costingMethod)) {
|
||||||
|
if (ce.isAverageInvoice())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
MCost cost = MCost.get(product, M_ASI_ID, as,
|
MCost cost = MCost.get(product, M_ASI_ID, as,
|
||||||
Org_ID, ce.getM_CostElement_ID(), get_TrxName());
|
Org_ID, ce.getM_CostElement_ID(), get_TrxName());
|
||||||
|
|
||||||
|
@ -1139,7 +1149,7 @@ public class MCostDetail extends X_M_CostDetail
|
||||||
{
|
{
|
||||||
if (adjustment)
|
if (adjustment)
|
||||||
{
|
{
|
||||||
String costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
|
costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
|
||||||
if (MCostElement.COSTINGMETHOD_AverageInvoice.equals(costingMethod))
|
if (MCostElement.COSTINGMETHOD_AverageInvoice.equals(costingMethod))
|
||||||
{
|
{
|
||||||
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
|
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
|
||||||
|
@ -1164,7 +1174,7 @@ public class MCostDetail extends X_M_CostDetail
|
||||||
{
|
{
|
||||||
if (adjustment)
|
if (adjustment)
|
||||||
{
|
{
|
||||||
String costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
|
costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
|
||||||
if (MCostElement.COSTINGMETHOD_AveragePO.equals(costingMethod))
|
if (MCostElement.COSTINGMETHOD_AveragePO.equals(costingMethod))
|
||||||
{
|
{
|
||||||
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
|
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
|
||||||
|
@ -1234,7 +1244,7 @@ public class MCostDetail extends X_M_CostDetail
|
||||||
{
|
{
|
||||||
if (adjustment)
|
if (adjustment)
|
||||||
{
|
{
|
||||||
String costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
|
costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
|
||||||
if (MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod))
|
if (MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod))
|
||||||
{
|
{
|
||||||
cost.add(amt.multiply(cost.getCurrentQty()), qty);
|
cost.add(amt.multiply(cost.getCurrentQty()), qty);
|
||||||
|
|
Loading…
Reference in New Issue