IDEMPIERE-3352 Enhancement of Batch Level Costing. Fixed checking of Reversal_ID not working when productionplan is use.

This commit is contained in:
Heng Sin Low 2017-07-04 17:25:27 +08:00
parent d70a8c07f3
commit e20c9b3be5
2 changed files with 13 additions and 11 deletions

View File

@ -1263,7 +1263,8 @@ public class MCostDetail extends X_M_CostDetail
} }
else if (addition) else if (addition)
{ {
if (getM_ProductionLine().getM_Production().getReversal_ID() < 0) MProductionLine productionLine = (MProductionLine) getM_ProductionLine();
if (productionLine.getProductionReversalId() <= 0)
cost.add(amt, qty); cost.add(amt, qty);
else else
cost.setCurrentQty(cost.getCurrentQty().add(qty)); cost.setCurrentQty(cost.getCurrentQty().add(qty));

View File

@ -78,7 +78,8 @@ public class MProductionLine extends X_M_ProductionLine {
* @return "" for success, error string if failed * @return "" for success, error string if failed
*/ */
public String createTransactions(Timestamp date, boolean mustBeStocked) { public String createTransactions(Timestamp date, boolean mustBeStocked) {
if (getParent().getReversal_ID() <= 0 ) int reversalId = getProductionReversalId ();
if (reversalId <= 0 )
{ {
// delete existing ASI records // delete existing ASI records
int deleted = deleteMA(); int deleted = deleteMA();
@ -106,7 +107,7 @@ public class MProductionLine extends X_M_ProductionLine {
if (log.isLoggable(Level.FINEST)) log.log(Level.FINEST, "asi Description is: " + asiString); if (log.isLoggable(Level.FINEST)) log.log(Level.FINEST, "asi Description is: " + asiString);
// create transactions for finished goods // create transactions for finished goods
if ( getM_Product_ID() == getEndProduct_ID()) { if ( getM_Product_ID() == getEndProduct_ID()) {
if (getParent().getReversal_ID() <= 0 && isAutoGenerateLot && getM_AttributeSetInstance_ID() == 0) if (reversalId <= 0 && isAutoGenerateLot && getM_AttributeSetInstance_ID() == 0)
{ {
asi = MAttributeSetInstance.generateLot(getCtx(), (MProduct)getM_Product(), get_TrxName()); asi = MAttributeSetInstance.generateLot(getCtx(), (MProduct)getM_Product(), get_TrxName());
setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID()); setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
@ -394,16 +395,16 @@ public class MProductionLine extends X_M_ProductionLine {
return true; return true;
} }
/** /**
* Get Parent * Get Reversal_ID of parent production
* @return parent * @return Reversal_ID
*/ */
public MProduction getParent() { public int getProductionReversalId() {
if (productionParent == null) if (getM_Production_ID() > 0)
productionParent = new MProduction (getCtx(), getM_Production_ID(), get_TrxName()); return DB.getSQLValueEx(get_TrxName(), "SELECT Reversal_ID FROM M_Production WHERE M_Production_ID=?", getM_Production_ID());
return productionParent; else
} // getParent return DB.getSQLValueEx(get_TrxName(), "SELECT p.Reversal_ID FROM M_ProductionPlan pp INNER JOIN M_Production p ON (pp.M_Production_ID = p.M_Production_ID) WHERE pp.M_ProductionPlan_ID=?", getM_ProductionPlan_ID());
}
/** /**
* *