IDEMPIERE-2564 / IDEMPIERE-2615 Date Material Policy not respected in movement / peer review

This commit is contained in:
Carlos Ruiz 2015-05-13 17:47:35 -05:00
parent cc72307e71
commit 758ef67e76
2 changed files with 13 additions and 27 deletions

View File

@ -475,29 +475,22 @@ public class MMovement extends X_M_Movement implements DocAction
if (trxFrom == null) if (trxFrom == null)
{ {
Timestamp dateMPolicy= null; Timestamp dateMPolicy= null;
MStorageOnHand[] storages = null; MStorageOnHand[] storages = null;
if (line.getMovementQty().compareTo(Env.ZERO) > 0) { if (line.getMovementQty().compareTo(Env.ZERO) > 0) {
// Find Date Material Policy bases on ASI // Find Date Material Policy bases on ASI
storages = MStorageOnHand.getWarehouse(getCtx(), 0, storages = MStorageOnHand.getWarehouse(getCtx(), 0,
line.getM_Product_ID(), line line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), null,
.getM_AttributeSetInstance_ID(), null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
MClient.MMPOLICY_FiFo.equals(product line.getM_Locator_ID(), get_TrxName());
.getMMPolicy()), false, line } else {
.getM_Locator_ID(), get_TrxName());
}
else{
//Case of reversal //Case of reversal
storages = MStorageOnHand storages = MStorageOnHand.getWarehouse(getCtx(), 0,
.getWarehouse(getCtx(), 0, line.getM_Product_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstanceTo_ID(), null,
line.getM_AttributeSetInstanceTo_ID(), null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
MClient.MMPOLICY_FiFo.equals(product line.getM_LocatorTo_ID(), get_TrxName());
.getMMPolicy()), false, line
.getM_LocatorTo_ID(), get_TrxName());
} }
for (MStorageOnHand storage : storages) { for (MStorageOnHand storage : storages) {
if (storage.getQtyOnHand().compareTo( if (storage.getQtyOnHand().compareTo(line.getMovementQty()) >= 0) {
line.getMovementQty()) >= 0) {
dateMPolicy = storage.getDateMaterialPolicy(); dateMPolicy = storage.getDateMaterialPolicy();
break; break;
} }
@ -506,11 +499,10 @@ public class MMovement extends X_M_Movement implements DocAction
if (dateMPolicy == null && storages.length > 0) if (dateMPolicy == null && storages.length > 0)
dateMPolicy = storages[0].getDateMaterialPolicy(); dateMPolicy = storages[0].getDateMaterialPolicy();
if(dateMPolicy==null && line.getM_AttributeSetInstanceTo_ID()!=0){ if (dateMPolicy==null && line.getM_AttributeSetInstanceTo_ID()!=0) {
I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance(); I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance();
dateMPolicy = asi.getCreated(); dateMPolicy = asi.getCreated();
} } else if(dateMPolicy==null)
else if(dateMPolicy==null )
dateMPolicy = getMovementDate(); dateMPolicy = getMovementDate();
MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName()); MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName());
@ -526,12 +518,6 @@ public class MMovement extends X_M_Movement implements DocAction
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
//TO may have Different material policy
I_M_AttributeSetInstance asiTo = line.getM_AttributeSetInstanceTo();
Timestamp dateMPolicyTo= null;
//Update Storage //Update Storage
MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName()); MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
if (!MStorageOnHand.add(getCtx(),locatorTo.getM_Warehouse_ID(), if (!MStorageOnHand.add(getCtx(),locatorTo.getM_Warehouse_ID(),

View File

@ -324,7 +324,7 @@ public class MStorageOnHand extends X_M_StorageOnHand
// Specific Attribute Set Instance // Specific Attribute Set Instance
String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID," String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
+ "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy," + "s.AD_Client_ID,s.AD_Org_ID,s.IsActive,s.Created,s.CreatedBy,s.Updated,s.UpdatedBy,"
+ "s.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy " + "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s" + "FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) "; + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ";
if (M_Locator_ID > 0) if (M_Locator_ID > 0)