Search in sources :

Example 11 with MRequisition

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

the class Doc_Requisition method loadDocumentDetails.

//	Doc_Requisition
/**
	 *	Load Specific Document Details
	 *  @return error message or null
	 */
protected String loadDocumentDetails() {
    setC_Currency_ID(NO_CURRENCY);
    MRequisition req = (MRequisition) getPO();
    setDateDoc(req.getDateDoc());
    setDateAcct(req.getDateDoc());
    // Amounts
    setAmount(AMTTYPE_Gross, req.getTotalLines());
    setAmount(AMTTYPE_Net, req.getTotalLines());
    // Contained Objects
    p_lines = loadLines(req);
    // log.fine( "Lines=" + p_lines.length + ", Taxes=" + m_taxes.length);
    return null;
}
Also used : MRequisition(org.compiere.model.MRequisition)

Example 12 with MRequisition

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

the class MRPSchedule method schedule.

// doIt
private void schedule(MPPMRP mrp) {
    if (!mrp.is_Changed())
        return;
    processRecords++;
    if (MPPMRP.ORDERTYPE_Forecast.equals(mrp.getOrderType())) {
        MForecastLine forecastLine = (MForecastLine) mrp.getM_ForecastLine();
        if (forecastLine != null) {
            forecastLine.setDatePromised(mrp.getDatePromised());
            forecastLine.setSalesRep_ID(mrp.getPlanner_ID());
            forecastLine.saveEx();
        }
    } else if (MPPMRP.ORDERTYPE_MaterialRequisition.equals(mrp.getOrderType())) {
        MRequisition requisition = (MRequisition) mrp.getM_Requisition();
        if (requisition != null) {
            requisition.setDateDoc(mrp.getDateStartSchedule());
            requisition.setDateRequired(mrp.getDatePromised());
            requisition.setAD_User_ID(mrp.getPlanner_ID());
            requisition.setPriorityRule(mrp.getPriority());
            requisition.saveEx();
        }
    } else if (MPPMRP.ORDERTYPE_ManufacturingOrder.equals(mrp.getOrderType())) {
        MPPOrder order = (MPPOrder) mrp.getPP_Order();
        if (order != null) {
            order.setDateStartSchedule(mrp.getDateStartSchedule());
            order.setDateFinishSchedule(mrp.getDateFinishSchedule());
            order.setDatePromised(mrp.getDatePromised());
            order.setPlanner_ID(mrp.getPlanner_ID());
            if (mrp.getPriority() != null)
                order.setPriorityRule(mrp.getPriority());
            order.setLine(lineNo);
            order.saveEx();
        }
    } else if (MPPMRP.ORDERTYPE_DistributionOrder.equals(mrp.getOrderType())) {
        MDDOrderLine orderLine = (MDDOrderLine) mrp.getDD_OrderLine();
        if (orderLine != null) {
            orderLine.setDateOrdered(mrp.getDateStartSchedule());
            orderLine.setDatePromised(mrp.getDatePromised());
            orderLine.saveEx();
            MDDOrder order = orderLine.getParent();
            order.setSalesRep_ID(mrp.getPlanner_ID());
            order.setPriorityRule(mrp.getPriority());
            order.saveEx();
        }
    } else if (MPPMRP.ORDERTYPE_SalesOrder.equals(mrp.getOrderType())) {
        MOrderLine orderLine = (MOrderLine) mrp.getC_OrderLine();
        if (orderLine != null) {
            orderLine.setDateOrdered(mrp.getDateStartSchedule());
            orderLine.setDatePromised(mrp.getDatePromised());
            orderLine.saveEx();
            MOrder order = orderLine.getParent();
            order.setSalesRep_ID(mrp.getPlanner_ID());
            order.setPriorityRule(mrp.getPriority());
            order.saveEx();
        }
    } else if (MPPMRP.ORDERTYPE_PurchaseOrder.equals(mrp.getOrderType())) {
        MOrderLine orderLine = (MOrderLine) mrp.getC_OrderLine();
        if (orderLine != null) {
            orderLine.setDateOrdered(mrp.getDateStartSchedule());
            orderLine.setDatePromised(mrp.getDatePromised());
            orderLine.saveEx();
            MOrder order = orderLine.getParent();
            order.setSalesRep_ID(mrp.getPlanner_ID());
            order.setPriorityRule(mrp.getPriority());
            order.saveEx();
        }
    }
}
Also used : MForecastLine(org.compiere.model.MForecastLine) MDDOrderLine(org.eevolution.model.MDDOrderLine) MOrder(org.compiere.model.MOrder) MDDOrder(org.eevolution.model.MDDOrder) MOrderLine(org.compiere.model.MOrderLine) MRequisition(org.compiere.model.MRequisition) MPPOrder(org.eevolution.model.MPPOrder)

Example 13 with MRequisition

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

the class MRPApproval method createSupply.

// doIt
private void createSupply(MPPMRP mrp, String orderType) {
    PO document = null;
    if (MPPMRP.ORDERTYPE_MaterialRequisition.equals(orderType)) {
        if (getBusinessPartnerId() <= 0)
            throw new AdempiereException("@BPartnerNotFound@");
        document = createRequisition(mrp);
    }
    if (MPPMRP.ORDERTYPE_ManufacturingOrder.equals(orderType) && getResourcePlantId() > 0 && getBOMFormulaId() > 0 && getWorkflowId() > 0) {
        document = createManufacturingOrder(mrp);
    }
    if (MPPMRP.ORDERTYPE_DistributionOrder.equals(orderType) && getWarehouseinTransitId() > 0 && getShipperId() > 0 && getLocatorId() > 0 && getLocatorToId() > 0 && getBusinessPartnerId() > 0) {
        document = createDistributionOrder(mrp);
    }
    if (MPPMRP.ORDERTYPE_MaterialRequisition.equals(mrp.getOrderType()) && document != null && document.get_ID() > 0) {
        MRequisition requisition = (MRequisition) mrp.getM_Requisition();
        requisition.deleteEx(true);
    }
    if (MPPMRP.ORDERTYPE_ManufacturingOrder.equals(mrp.getOrderType()) && document != null && document.get_ID() > 0) {
        MPPOrder order = (MPPOrder) mrp.getPP_Order();
        order.deleteEx(true);
    }
    if (MPPMRP.ORDERTYPE_DistributionOrder.equals(mrp.getOrderType()) && document != null && document.get_ID() > 0) {
        MDDOrder order = (MDDOrder) mrp.getDD_Order();
        order.deleteEx(true);
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) MDDOrder(org.eevolution.model.MDDOrder) MRequisition(org.compiere.model.MRequisition) MPPOrder(org.eevolution.model.MPPOrder) PO(org.compiere.model.PO)

Example 14 with MRequisition

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

the class ReplenishReport method createRequisition.

//	createPO
/**
	 * 	Create Requisition
	 */
private void createRequisition() {
    int noReqs = 0;
    String info = "";
    //
    MRequisition requisition = null;
    MWarehouse wh = null;
    X_T_Replenish[] replenishs = getReplenish("M_WarehouseSource_ID IS NULL");
    for (int i = 0; i < replenishs.length; i++) {
        X_T_Replenish replenish = replenishs[i];
        if (wh == null || wh.getM_Warehouse_ID() != replenish.getM_Warehouse_ID())
            wh = MWarehouse.get(getCtx(), replenish.getM_Warehouse_ID());
        //
        if (requisition == null || requisition.getM_Warehouse_ID() != replenish.getM_Warehouse_ID()) {
            requisition = new MRequisition(getCtx(), 0, get_TrxName());
            requisition.setAD_User_ID(getAD_User_ID());
            requisition.setC_DocType_ID(p_C_DocType_ID);
            requisition.setDescription(Msg.getMsg(getCtx(), "Replenishment"));
            //	Set Org/WH
            requisition.setAD_Org_ID(wh.getAD_Org_ID());
            requisition.setM_Warehouse_ID(wh.getM_Warehouse_ID());
            if (!requisition.save())
                return;
            log.fine(requisition.toString());
            noReqs++;
            info += " - " + requisition.getDocumentNo();
        }
        //
        MRequisitionLine line = new MRequisitionLine(requisition);
        line.setM_Product_ID(replenish.getM_Product_ID());
        line.setC_BPartner_ID(replenish.getC_BPartner_ID());
        line.setQty(replenish.getQtyToOrder());
        line.setPrice();
        line.saveEx();
    }
    m_info = "#" + noReqs + info;
    log.info(m_info);
}
Also used : X_T_Replenish(org.compiere.model.X_T_Replenish) MRequisitionLine(org.compiere.model.MRequisitionLine) MRequisition(org.compiere.model.MRequisition) MWarehouse(org.compiere.model.MWarehouse)

Example 15 with MRequisition

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

the class CalculateReplenishPlan method doRunCreatePOandProductionOrder.

/**
	 * This method will process to create Production Order and Purchase order as
	 * per required quantity.
	 * 
	 * @author Sachin Bhimani
	 * @param miniMrpProducts
	 */
private void doRunCreatePOandProductionOrder(Map<Integer, MiniMRPProduct> miniMrpProducts) {
    MRequisition requisition = null;
    // Calculate Required and production QTY
    runProcessCalculatePlannedQty(miniMrpProducts);
    // Create Requisition Order with Lines
    for (Integer productID : mapRequirePlanningQty.keySet()) {
        MiniMRPProduct mrp = miniMrpProducts.get(productID);
        Map<Date, BigDecimal> weeklyProductionQty = new TreeMap<Date, BigDecimal>(mapRequirePlanningQty.get(productID));
        for (Date date : weeklyProductionQty.keySet()) {
            if (weeklyProductionQty.get(date).compareTo(Env.ZERO) == 0)
                continue;
            if (!mrp.isBOM() && mrp.isPurchased() && !mrp.isPhantom()) {
                requisition = createRequisitionHeader(date);
                createRequisitionLine(requisition, mrp, weeklyProductionQty.get(date));
            } else if (mrp.isBOM() && !mrp.isPhantom()) {
                createProductionOrder(mrp, weeklyProductionQty.get(date), new Timestamp(date.getTime()));
            }
        }
    }
    infoMsg.append(" No of Docs created: Requisition:" + countReq);
    infoMsg.append(" and Planned Production:" + countProd);
    infoMsg.append("\n Requisition Docs List: " + requisitionDocs);
    infoMsg.append("\n Planned Docs List: " + productionDocs);
    log.log(Level.INFO, infoMsg.toString());
}
Also used : TreeMap(java.util.TreeMap) Timestamp(java.sql.Timestamp) MRequisition(org.compiere.model.MRequisition) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Aggregations

MRequisition (org.compiere.model.MRequisition)18 MRequisitionLine (org.compiere.model.MRequisitionLine)8 Timestamp (java.sql.Timestamp)5 BigDecimal (java.math.BigDecimal)3 TreeMap (java.util.TreeMap)3 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MOrder (org.compiere.model.MOrder)3 MOrderLine (org.compiere.model.MOrderLine)3 Date (java.util.Date)2 MForecastLine (org.compiere.model.MForecastLine)2 MWarehouse (org.compiere.model.MWarehouse)2 Query (org.compiere.model.Query)2 X_T_Replenish (org.compiere.model.X_T_Replenish)2 MDDOrder (org.eevolution.model.MDDOrder)2 MPPOrder (org.eevolution.model.MPPOrder)2 SQLException (java.sql.SQLException)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1