diff --git a/base/src/org/eevolution/model/MPPProductPlanning.java b/base/src/org/eevolution/model/MPPProductPlanning.java index c5e741dc4d..6a3c7dcb87 100644 --- a/base/src/org/eevolution/model/MPPProductPlanning.java +++ b/base/src/org/eevolution/model/MPPProductPlanning.java @@ -25,6 +25,7 @@ import org.compiere.model.Query; import org.compiere.util.CLogMgt; import org.compiere.util.CLogger; import org.compiere.util.DB; +import org.compiere.util.Env; /** * Product Data Planning @@ -140,7 +141,7 @@ public class MPPProductPlanning extends X_PP_Product_Planning * @param trxName Transaction Name * @return MPPProductPlanning Planning Data **/ - public static MPPProductPlanning find (Properties ctx, int AD_Client_ID, int AD_Org_ID, + public static MPPProductPlanning find (Properties ctx, int AD_Org_ID, int M_Warehouse_ID, int S_Resource_ID, int M_Product_ID, String trxName) { @@ -149,7 +150,7 @@ public class MPPProductPlanning extends X_PP_Product_Planning + " AND (M_Warehouse_ID IN (0,?) OR M_Warehouse_ID IS NULL)" + " AND (S_Resource_ID IN (0,?) OR S_Resource_ID IS NULL)"; return new Query(ctx, Table_Name, whereClause, trxName) - .setParameters(new Object[]{AD_Client_ID, M_Product_ID, AD_Org_ID, M_Warehouse_ID, S_Resource_ID}) + .setParameters(new Object[]{Env.getAD_Client_ID(ctx), M_Product_ID, AD_Org_ID, M_Warehouse_ID, S_Resource_ID}) .setOrderBy("AD_Org_ID DESC NULLS LAST, M_Warehouse_ID DESC NULLS LAST, S_Resource_ID DESC NULLS LAST") .first(); } diff --git a/base/src/org/eevolution/process/MRP.java b/base/src/org/eevolution/process/MRP.java index 00a03612e4..161ee12cbf 100644 --- a/base/src/org/eevolution/process/MRP.java +++ b/base/src/org/eevolution/process/MRP.java @@ -445,7 +445,7 @@ public class MRP extends SvrProcess private void setProduct(int AD_Client_ID , int AD_Org_ID, int S_Resource_ID , int M_Warehouse_ID, MProduct product) { //find data product planning demand - MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Client_ID ,AD_Org_ID , M_Warehouse_ID, S_Resource_ID , product.getM_Product_ID(), get_TrxName()); + MPPProductPlanning pp = MPPProductPlanning.find(getCtx() ,AD_Org_ID , M_Warehouse_ID, S_Resource_ID , product.getM_Product_ID(), get_TrxName()); DatePromisedTo = null; DatePromisedFrom = null; if (pp != null) @@ -513,7 +513,7 @@ public class MRP extends SvrProcess } } - QtyProjectOnHand = MPPMRP.getQtyOnHand(AD_Client_ID , m_product_planning.getM_Warehouse_ID() , m_product_planning.getM_Product_ID(), get_TrxName()); + QtyProjectOnHand = MPPMRP.getQtyOnHand(getCtx(), m_product_planning.getM_Warehouse_ID() , m_product_planning.getM_Product_ID(), get_TrxName()); if(m_product_planning.getSafetyStock().signum() > 0 && m_product_planning.getSafetyStock().compareTo(QtyProjectOnHand) > 0) { @@ -738,7 +738,7 @@ public class MRP extends SvrProcess M_Shipper_ID = network_line.getM_Shipper_ID(); } - BigDecimal QtyOrdered = QtyPlanned; //.multiply(network_line.getPercent()).divide(Env.ONEHUNDRED); + BigDecimal QtyOrdered = QtyPlanned.multiply(network_line.getPercent()).divide(Env.ONEHUNDRED); MDDOrderLine oline = new MDDOrderLine(getCtx(), 0 , get_TrxName()); oline.setDD_Order_ID(order.getDD_Order_ID()); @@ -749,6 +749,7 @@ public class MRP extends SvrProcess oline.setDatePromised(DemandDateStartSchedule); oline.setQtyEntered(QtyOrdered); oline.setQtyOrdered(QtyOrdered); + oline.setTargetQty(MPPMRP.getQtyReserved(getCtx(), target.getM_Warehouse_ID(), m_product_planning.getM_Product_ID(), DemandDateStartSchedule, get_TrxName())); oline.setIsInvoiced(false); oline.saveEx(); diff --git a/base/src/org/eevolution/process/RollupBillOfMaterial.java b/base/src/org/eevolution/process/RollupBillOfMaterial.java index 43cfb63a97..fd7021623c 100644 --- a/base/src/org/eevolution/process/RollupBillOfMaterial.java +++ b/base/src/org/eevolution/process/RollupBillOfMaterial.java @@ -167,8 +167,7 @@ public class RollupBillOfMaterial extends SvrProcess { log.info("ElementType: "+CostElementType); BigDecimal costPriceLL = Env.ZERO; - MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), - getAD_Client_ID(), AD_Org_ID, + MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Org_ID, 0, // M_Warehouse_ID 0, // S_Resource_ID product.getM_Product_ID(), diff --git a/base/src/org/eevolution/process/RollupWorkflow.java b/base/src/org/eevolution/process/RollupWorkflow.java index 26dc499f7e..dfe755578f 100644 --- a/base/src/org/eevolution/process/RollupWorkflow.java +++ b/base/src/org/eevolution/process/RollupWorkflow.java @@ -138,7 +138,7 @@ public class RollupWorkflow extends SvrProcess private BigDecimal getCost(String CostElementType ,int AD_Client_ID , int AD_Org_ID , MProduct product , int M_CostType_ID , int C_AcctSchema_ID) { BigDecimal cost = Env.ZERO; - MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Client_ID, AD_Org_ID , 0 , 0 , product.getM_Product_ID(), get_TrxName()); + MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Org_ID , 0 , 0 , product.getM_Product_ID(), get_TrxName()); int AD_Workflow_ID = 0; if(pp != null ) AD_Workflow_ID = pp.getAD_Workflow_ID(); diff --git a/client/src/org/eevolution/form/VMRPDetailed.java b/client/src/org/eevolution/form/VMRPDetailed.java index 3afac0aae2..30c12f4696 100644 --- a/client/src/org/eevolution/form/VMRPDetailed.java +++ b/client/src/org/eevolution/form/VMRPDetailed.java @@ -772,7 +772,7 @@ public class VMRPDetailed */ private void fillHead() { - MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Client_ID, + MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), getAD_Org_ID(), getM_Warehouse_ID(), getS_Resource_ID(), getM_Product_ID(), null); if (pp == null) pp = new MPPProductPlanning(getCtx(), 0, null);