IDEMPIERE-2142 Update Standard Cost Process: Cost adjustment document should include only products that have changes to the product's current cost.

This commit is contained in:
Heng Sin Low 2014-08-13 14:46:14 +08:00
parent ce672a5221
commit ec2ad9af8b
1 changed files with 25 additions and 18 deletions

View File

@ -279,7 +279,7 @@ public class CostUpdate extends SvrProcess
MClient client = MClient.get(getCtx()); MClient client = MClient.get(getCtx());
MAcctSchema primarySchema = client.getAcctSchema(); MAcctSchema primarySchema = client.getAcctSchema();
MInventory inventoryDoc = null; MInventory inventoryDoc = null;
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, m_ce.getM_CostElement_ID()); pstmt.setInt (1, m_ce.getM_CostElement_ID());
if (p_M_Product_Category_ID != 0) if (p_M_Product_Category_ID != 0)
pstmt.setInt (2, p_M_Product_Category_ID); pstmt.setInt (2, p_M_Product_Category_ID);
@ -381,16 +381,20 @@ public class CostUpdate extends SvrProcess
{ {
cost.setFutureCostPrice(costs); cost.setFutureCostPrice(costs);
updated = true; updated = true;
}
if (lines != null) if (lines != null)
{ {
MInventoryLine line = new MInventoryLine(getCtx(), 0, get_TrxName()); BigDecimal currentCost = cost.getCurrentCostPrice();
line.setM_Product_ID(cost.getM_Product_ID()); if (currentCost == null || currentCost.compareTo(costs) != 0) {
line.setCurrentCostPrice(cost.getCurrentCostPrice()); MInventoryLine line = new MInventoryLine(getCtx(), 0, get_TrxName());
line.setNewCostPrice(costs); line.setM_Product_ID(cost.getM_Product_ID());
line.setM_Locator_ID(0); line.setCurrentCostPrice(cost.getCurrentCostPrice());
lines.add(line); line.setNewCostPrice(costs);
} line.setM_Locator_ID(0);
lines.add(line);
}
}
}
} }
else else
{ {
@ -401,13 +405,16 @@ public class CostUpdate extends SvrProcess
BigDecimal costs = getCosts(cost, p_SetStandardCostTo); BigDecimal costs = getCosts(cost, p_SetStandardCostTo);
if (costs != null && costs.signum() != 0) if (costs != null && costs.signum() != 0)
{ {
MInventoryLine line = new MInventoryLine(getCtx(), 0, get_TrxName()); BigDecimal currentCost = cost.getCurrentCostPrice();
line.setM_Product_ID(cost.getM_Product_ID()); if (currentCost == null || currentCost.compareTo(costs) != 0) {
line.setCurrentCostPrice(cost.getCurrentCostPrice()); MInventoryLine line = new MInventoryLine(getCtx(), 0, get_TrxName());
line.setNewCostPrice(costs); line.setM_Product_ID(cost.getM_Product_ID());
line.setM_Locator_ID(0); line.setCurrentCostPrice(cost.getCurrentCostPrice());
lines.add(line); line.setNewCostPrice(costs);
updated = true; line.setM_Locator_ID(0);
lines.add(line);
updated = true;
}
} }
} }
} }