IDEMPIERE-386 IDEMPIERE-1770 - inventory count create broken when DateMaterialPolicy used with same ASI

This commit is contained in:
Carlos Ruiz 2015-01-14 17:05:28 -05:00
parent 28d5c48882
commit 6e03e56b32
1 changed files with 3 additions and 20 deletions

View File

@ -26,7 +26,6 @@ import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MAttributeSet;
import org.compiere.model.MInventory; import org.compiere.model.MInventory;
import org.compiere.model.MInventoryLine; import org.compiere.model.MInventoryLine;
import org.compiere.model.MInventoryLineMA; import org.compiere.model.MInventoryLineMA;
@ -278,22 +277,6 @@ public class InventoryCountCreate extends SvrProcess
private int createInventoryLine (int M_Locator_ID, int M_Product_ID, private int createInventoryLine (int M_Locator_ID, int M_Product_ID,
int M_AttributeSetInstance_ID, BigDecimal QtyOnHand, int M_AttributeSet_ID,Timestamp dateMPolicy) int M_AttributeSetInstance_ID, BigDecimal QtyOnHand, int M_AttributeSet_ID,Timestamp dateMPolicy)
{ {
boolean oneLinePerASI = false;
if (M_AttributeSet_ID != 0)
{
MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
oneLinePerASI = mas.isInstanceAttribute();
}
if (oneLinePerASI)
{
MInventoryLine line = new MInventoryLine (m_inventory, M_Locator_ID,
M_Product_ID, M_AttributeSetInstance_ID,
QtyOnHand, QtyOnHand); // book/count
if (line.save())
return 1;
return 0;
}
if (QtyOnHand.signum() == 0) if (QtyOnHand.signum() == 0)
M_AttributeSetInstance_ID = 0; M_AttributeSetInstance_ID = 0;
@ -312,12 +295,12 @@ public class InventoryCountCreate extends SvrProcess
return 0; return 0;
} }
// Save Old Line info // Save Old Line info
else if (m_line.getM_AttributeSetInstance_ID() != 0) else if (m_line.getM_AttributeSetInstance_ID() != 0 || oldDateMPolicy != null)
{ {
MInventoryLineMA ma = new MInventoryLineMA (m_line, MInventoryLineMA ma = new MInventoryLineMA (m_line,
m_line.getM_AttributeSetInstance_ID(), m_line.getQtyBook(),oldDateMPolicy,true); m_line.getM_AttributeSetInstance_ID(), m_line.getQtyBook(),oldDateMPolicy,true);
if (!ma.save()) if (!ma.save())
; log.warning("Could not save " + ma);
} }
m_line.setM_AttributeSetInstance_ID(0); m_line.setM_AttributeSetInstance_ID(0);
m_line.setQtyBook(m_line.getQtyBook().add(QtyOnHand)); m_line.setQtyBook(m_line.getQtyBook().add(QtyOnHand));
@ -328,7 +311,7 @@ public class InventoryCountCreate extends SvrProcess
MInventoryLineMA ma = new MInventoryLineMA (m_line, MInventoryLineMA ma = new MInventoryLineMA (m_line,
M_AttributeSetInstance_ID, QtyOnHand,dateMPolicy,true); M_AttributeSetInstance_ID, QtyOnHand,dateMPolicy,true);
if (!ma.save()) if (!ma.save())
; log.warning("Could not save " + ma);
return 0; return 0;
} }
// new line // new line