Search in sources :

Example 1 with X_M_ReplenishPlanLine

use of org.compiere.model.X_M_ReplenishPlanLine in project adempiere by adempiere.

the class CalculateReplenishPlan method insertTotalSupplyProductionLine.

/**
	 * Insert total supply of production line
	 * 
	 * @author Sachin Bhimani
	 * @param miniMrpProduct
	 * @param subTotalSupplyLine
	 * @param isPlanned
	 */
public void insertTotalSupplyProductionLine(MiniMRPProduct miniMrpProduct, Map<Integer, BigDecimal> subTotalSupplyLine, boolean isPlanned) {
    if (!subTotalSupplyLine.isEmpty()) {
        X_M_ReplenishPlanLine miniMRP = getX_M_ReplenishPlanLine(miniMrpProduct, lineNo, isPlanned ? TYPE_TOTAL_SUPPLY_PLANNED_LINE : TYPE_TOTAL_SUPPLY_NONPLANNED_LINE);
        // Insert Total Supply Production as per docType.
        for (Integer week : subTotalSupplyLine.keySet()) {
            BigDecimal qty = subTotalSupplyLine.get(week);
            setWeeklyData(miniMRP, week, qty);
        }
        miniMRP.saveEx();
    }
    lineNo += 10;
}
Also used : X_M_ReplenishPlanLine(org.compiere.model.X_M_ReplenishPlanLine) BigDecimal(java.math.BigDecimal)

Example 2 with X_M_ReplenishPlanLine

use of org.compiere.model.X_M_ReplenishPlanLine in project adempiere by adempiere.

the class CalculateReplenishPlan method insertTotalLine.

/**
	 * Insert total line [Demand/Supply line]
	 * 
	 * @author Sachin Bhimani
	 * @param miniMrpProduct
	 * @param totalLine
	 * @param lineType
	 */
public void insertTotalLine(MiniMRPProduct miniMrpProduct, Map<Integer, BigDecimal> totalLine, String lineType) {
    if (!totalLine.isEmpty()) {
        X_M_ReplenishPlanLine miniMRP = getX_M_ReplenishPlanLine(miniMrpProduct, lineNo, lineType);
        for (Integer week : totalLine.keySet()) {
            BigDecimal qty = totalLine.get(week);
            setWeeklyData(miniMRP, week, qty);
        }
        miniMRP.saveEx();
    }
    lineNo += 10;
}
Also used : X_M_ReplenishPlanLine(org.compiere.model.X_M_ReplenishPlanLine) BigDecimal(java.math.BigDecimal)

Example 3 with X_M_ReplenishPlanLine

use of org.compiere.model.X_M_ReplenishPlanLine in project adempiere by adempiere.

the class CalculateReplenishPlan method insertOpeningBalanceLine.

/**
	 * Insert Opening Balance Line
	 * 
	 * @author Sachin Bhimani
	 * @param miniMrpProduct
	 * @param openingBalanceLine
	 */
public void insertOpeningBalanceLine(MiniMRPProduct miniMrpProduct, Map<Integer, BigDecimal> openingBalanceLine) {
    if (!openingBalanceLine.isEmpty()) {
        X_M_ReplenishPlanLine miniMRP = getX_M_ReplenishPlanLine(miniMrpProduct, 10, TYPE_OPENING_BALANCE_LINE + (miniMrpProduct.isPhantom ? " - Phantom Product" : ""));
        for (Integer week : openingBalanceLine.keySet()) {
            setWeeklyData(miniMRP, week, openingBalanceLine.get(week));
        }
        miniMRP.saveEx();
    }
}
Also used : X_M_ReplenishPlanLine(org.compiere.model.X_M_ReplenishPlanLine)

Example 4 with X_M_ReplenishPlanLine

use of org.compiere.model.X_M_ReplenishPlanLine in project adempiere by adempiere.

the class CalculateReplenishPlan method insertSupplyLinePO.

/**
	 * Insert Purchase Order and Requisition lines
	 * 
	 * @author Sachin Bhimani
	 * @param miniMrpProduct
	 * @param totalSupplyLine
	 * @param subTotalSupplyLine
	 * @param isPO
	 */
public void insertSupplyLinePO(MiniMRPProduct miniMrpProduct, Map<Integer, BigDecimal> totalSupplyLine, Map<Integer, BigDecimal> subTotalSupplyLine, boolean isPO) {
    Map<Integer, Map<Integer, BigDecimal>> supplyLine;
    String typeSupply;
    if (isPO) {
        supplyLine = miniMrpProduct.getSupplyLinePO();
        typeSupply = TYPE_SUPPLY_LINE_PO;
    } else {
        supplyLine = miniMrpProduct.getSupplyLineRQ();
        typeSupply = TYPE_SUPPLY_LINE_RQ;
    }
    if (!supplyLine.isEmpty()) {
        // columnID is C_Order_ID or M_Requisition_ID
        for (Integer columnID : supplyLine.keySet()) {
            Map<Integer, BigDecimal> weeklyDemand = supplyLine.get(columnID);
            if (weeklyDemand.size() > 0) {
                X_M_ReplenishPlanLine miniMRP = getX_M_ReplenishPlanLine(miniMrpProduct, lineNo, typeSupply);
                Timestamp date1;
                String docNo = null;
                if (isPO) {
                    miniMRP.setC_Order_ID(columnID);
                    MOrder order = new MOrder(ctx, columnID, trx);
                    date1 = order.getDatePromised();
                    docNo = order.getDocumentNo();
                } else {
                    miniMRP.setM_Requisition_ID(columnID);
                    MRequisition req = new MRequisition(ctx, columnID, trx);
                    date1 = req.getDateRequired();
                    docNo = req.getDocumentNo();
                }
                String datePromised = requiredFormat.format(date1);
                miniMRP.setOrderInfo(docNo + " - " + datePromised);
                for (Integer week : weeklyDemand.keySet()) {
                    BigDecimal qty = weeklyDemand.get(week);
                    setWeeklyData(miniMRP, week, qty);
                    if (totalSupplyLine.containsKey(week)) {
                        qty = qty.add(totalSupplyLine.get(week));
                    }
                    totalSupplyLine.put(week, qty);
                    BigDecimal qtyProd = weeklyDemand.get(week);
                    if (subTotalSupplyLine.containsKey(week)) {
                        qtyProd = qtyProd.add(subTotalSupplyLine.get(week));
                    }
                    subTotalSupplyLine.put(week, qtyProd);
                }
                miniMRP.saveEx();
            }
            lineNo += 10;
        }
    }
}
Also used : MOrder(org.compiere.model.MOrder) X_M_ReplenishPlanLine(org.compiere.model.X_M_ReplenishPlanLine) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) MRequisition(org.compiere.model.MRequisition)

Example 5 with X_M_ReplenishPlanLine

use of org.compiere.model.X_M_ReplenishPlanLine in project adempiere by adempiere.

the class CalculateReplenishPlan method getX_M_ReplenishPlanLine.

/**
	 * @author Sachin Bhimani
	 * @param miniMrpProduct
	 * @param line
	 * @param type
	 * @return miniM_ReplenishPlanLine
	 */
private X_M_ReplenishPlanLine getX_M_ReplenishPlanLine(MiniMRPProduct miniMrpProduct, int line, String type) {
    X_M_ReplenishPlanLine miniMRP = new X_M_ReplenishPlanLine(ctx, 0, trx);
    miniMRP.setM_Product_ID(miniMrpProduct.getM_Product_ID());
    miniMRP.setM_Product_Category_ID(miniMrpProduct.getM_Product_Category_ID());
    miniMRP.setProductName(miniMrpProduct.getName());
    miniMRP.setLine(line);
    miniMRP.setM_ReplenishPlan_ID(mrpRunID);
    miniMRP.setRecordType(type);
    miniMRP.setDateStart(dateFrom);
    miniMRP.setDateFinish(dateTo);
    return miniMRP;
}
Also used : X_M_ReplenishPlanLine(org.compiere.model.X_M_ReplenishPlanLine)

Aggregations

X_M_ReplenishPlanLine (org.compiere.model.X_M_ReplenishPlanLine)10 BigDecimal (java.math.BigDecimal)7 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 MOrder (org.compiere.model.MOrder)2 MProduction (org.compiere.model.MProduction)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MRequisition (org.compiere.model.MRequisition)1