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)
{
Timestamp dateMPolicy= null;
MStorageOnHand[] storages = null;
if (line.getMovementQty().compareTo(Env.ZERO) > 0) {
// Find Date Material Policy bases on ASI
storages = MStorageOnHand.getWarehouse(getCtx(), 0,
line.getM_Product_ID(), line
.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(product
.getMMPolicy()), false, line
.getM_Locator_ID(), get_TrxName());
}
else{
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
line.getM_Locator_ID(), get_TrxName());
} else {
//Case of reversal
storages = MStorageOnHand
.getWarehouse(getCtx(), 0, line.getM_Product_ID(),
line.getM_AttributeSetInstanceTo_ID(), null,
MClient.MMPOLICY_FiFo.equals(product
.getMMPolicy()), false, line
.getM_LocatorTo_ID(), get_TrxName());
storages = MStorageOnHand.getWarehouse(getCtx(), 0,
line.getM_Product_ID(), line.getM_AttributeSetInstanceTo_ID(), null,
MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false,
line.getM_LocatorTo_ID(), get_TrxName());
}
for (MStorageOnHand storage : storages) {
if (storage.getQtyOnHand().compareTo(
line.getMovementQty()) >= 0) {
if (storage.getQtyOnHand().compareTo(line.getMovementQty()) >= 0) {
dateMPolicy = storage.getDateMaterialPolicy();
break;
}
@ -506,11 +499,10 @@ public class MMovement extends X_M_Movement implements DocAction
if (dateMPolicy == null && storages.length > 0)
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();
dateMPolicy = asi.getCreated();
}
else if(dateMPolicy==null )
} else if(dateMPolicy==null)
dateMPolicy = getMovementDate();
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;
}
//TO may have Different material policy
I_M_AttributeSetInstance asiTo = line.getM_AttributeSetInstanceTo();
Timestamp dateMPolicyTo= null;
//Update Storage
MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
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
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.QtyOnHand,s.DateLastInventory,s.DateMaterialPolicy "
+ "s.QtyOnHand,s.DateLastInventory,s.M_StorageOnHand_UU,s.DateMaterialPolicy "
+ "FROM M_StorageOnHand s"
+ " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) ";
if (M_Locator_ID > 0)