Search in sources :

Example 1 with MForecastLine

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

the class LiberoValidator method modelChange.

//	initialize
public String modelChange(PO po, int type) throws Exception {
    log.info(po.get_TableName() + " Type: " + type);
    boolean isChange = (TYPE_AFTER_NEW == type || (TYPE_AFTER_CHANGE == type && MPPMRP.isChanged(po)));
    boolean isDelete = (TYPE_BEFORE_DELETE == type);
    boolean isReleased = false;
    boolean isVoided = false;
    //Update MRP Change Net 
    if (MPPMRP.isChanged(po) && (TYPE_AFTER_CHANGE == type || TYPE_AFTER_NEW == type)) {
        MPPMRP.setIsRequired(po, MPPProductPlanning.COLUMNNAME_IsRequiredMRP, true, po.get_TrxName());
    }
    DocAction doc = null;
    if (po instanceof DocAction) {
        doc = (DocAction) po;
    } else if (po instanceof MOrderLine) {
        doc = ((MOrderLine) po).getParent();
    }
    if (doc != null) {
        String docStatus = doc.getDocStatus();
        isReleased = DocAction.STATUS_InProgress.equals(docStatus) || DocAction.STATUS_Completed.equals(docStatus);
        isVoided = DocAction.STATUS_Voided.equals(docStatus);
    }
    // Can we change M_Product.C_UOM_ID ?
    if (po instanceof MProduct && TYPE_BEFORE_CHANGE == type && po.is_ValueChanged(MProduct.COLUMNNAME_C_UOM_ID) && MPPMRP.hasProductRecords((MProduct) po)) {
        throw new AdempiereException("@SaveUomError@");
    }
    //
    if (isDelete || isVoided || !po.isActive()) {
        if (MOrder.Table_Name.equals(po.get_TableName()) || MOrderLine.Table_Name.equals(po.get_TableName()) || MPPOrder.Table_Name.equals(po.get_TableName()) || MPPOrderBOMLine.Table_Name.equals(po.get_TableName()) || MDDOrder.Table_Name.equals(po.get_TableName()) || MDDOrderLine.Table_Name.equals(po.get_TableName()) || MRequisition.Table_Name.equals(po.get_TableName()) || MRequisitionLine.Table_Name.equals(po.get_TableName()) || MForecast.Table_Name.equals(po.get_TableName()) || MForecastLine.Table_Name.equals(po.get_TableName()))
            MPPMRP.deleteMRP(po);
    } else if (po instanceof MOrder) {
        MOrder order = (MOrder) po;
        // or when you change DatePromised or DocStatus and is Purchase Order
        if (isChange && !order.isSOTrx()) {
            MPPMRP.C_Order(order);
        } else // or you change DatePromised
        if (type == TYPE_AFTER_CHANGE && order.isSOTrx()) {
            if (isReleased || MPPMRP.isChanged(order)) {
                MPPMRP.C_Order(order);
            }
        }
    } else // 
    if (po instanceof MOrderLine && isChange) {
        MOrderLine ol = (MOrderLine) po;
        MOrder order = ol.getParent();
        // Create/Update a planning supply when isPurchase Order or you change relevant fields
        if (!order.isSOTrx()) {
            MPPMRP.C_OrderLine(ol);
        } else // you change relevant fields
        if (order.isSOTrx() && isReleased) {
            MPPMRP.C_OrderLine(ol);
        }
    } else //
    if (po instanceof MRequisition && isChange) {
        MRequisition r = (MRequisition) po;
        MPPMRP.M_Requisition(r);
    } else //
    if (po instanceof MRequisitionLine && isChange) {
        MRequisitionLine rl = (MRequisitionLine) po;
        MPPMRP.M_RequisitionLine(rl);
    } else //
    if (po instanceof MForecast && isChange) {
        MForecast fl = (MForecast) po;
        MPPMRP.M_Forecast(fl);
    } else //
    if (po instanceof MForecastLine && isChange) {
        MForecastLine fl = (MForecastLine) po;
        MPPMRP.M_ForecastLine(fl);
    } else if (po instanceof MDDOrder && isChange) {
        MDDOrder order = (MDDOrder) po;
        MPPMRP.DD_Order(order);
    } else //
    if (po instanceof MDDOrderLine && isChange) {
        MDDOrderLine ol = (MDDOrderLine) po;
        MPPMRP.DD_OrderLine(ol);
    } else //
    if (po instanceof MPPOrder && isChange) {
        MPPOrder order = (MPPOrder) po;
        MPPMRP.PP_Order(order);
    } else //
    if (po instanceof MPPOrderBOMLine && isChange) {
        MPPOrderBOMLine obl = (MPPOrderBOMLine) po;
        MPPMRP.PP_Order_BOMLine(obl);
    }
    //
    return null;
}
Also used : MProduct(org.compiere.model.MProduct) DocAction(org.compiere.process.DocAction) MForecast(org.compiere.model.MForecast) MOrder(org.compiere.model.MOrder) MForecastLine(org.compiere.model.MForecastLine) AdempiereException(org.adempiere.exceptions.AdempiereException) MOrderLine(org.compiere.model.MOrderLine) MRequisitionLine(org.compiere.model.MRequisitionLine) MRequisition(org.compiere.model.MRequisition)

Example 2 with MForecastLine

use of org.compiere.model.MForecastLine 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 3 with MForecastLine

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

the class ProcessingForecast method doIt.

//	prepare
/**
	 * 	Process
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() {
    MForecast forecast = new MForecast(getCtx(), p_M_Forecast_ID, get_TrxName());
    forecast.setProcessed(true);
    forecast.saveEx();
    for (MForecastLine fl : forecast.getLines(true)) {
        MPPMRP.M_ForecastLine(fl);
    }
    return "@M_Forecast_ID@ : " + forecast.getName() + " @Processed@";
}
Also used : MForecastLine(org.compiere.model.MForecastLine) MForecast(org.compiere.model.MForecast)

Example 4 with MForecastLine

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

the class ImportForecast method importForecast.

/**
	 * Import Forecast using X_I_Forecast table
	 * 
	 * @param X_I_Forecast
	 *            X_I_Forecast
	 * @return MForecastLine Forecast Line
	 */
private MForecastLine importForecast(X_I_Forecast ifl) {
    MForecastLine fl = new MForecastLine(getCtx(), ifl.getM_ForecastLine_ID(), get_TrxName());
    MForecast f = (MForecast) ifl.getM_Forecast();
    if (fl == null || fl.get_ID() <= 0) {
        fl = new MForecastLine(Env.getCtx(), 0, get_TrxName());
        fl.setAD_Org_ID(ifl.getAD_Org_ID());
        fl.setM_Forecast_ID(ifl.getM_Forecast_ID());
        fl.setM_Product_ID(ifl.getM_Product_ID());
        fl.setM_Warehouse_ID(ifl.getM_Warehouse_ID());
    }
    fl.setQty(ifl.getQty());
    fl.setIsActive(true);
    fl.setSalesRep_ID(ifl.getSalesRep_ID());
    fl.setDatePromised(ifl.getDatePromised());
    MPPPeriod period = MPPPeriod.findByCalendar(getCtx(), ifl.getDatePromised(), f.getPP_Calendar_ID(), get_TrxName());
    if (period == null) {
        ifl.setI_ErrorMsg(Msg.parseTranslation(ifl.getCtx(), "@PP_Period_ID@ @NotFound@ @To@ @DatePromised@" + ifl.getDatePromised()));
        isImported = false;
        return null;
    }
    fl.setPP_Period_ID(period.get_ID());
    fl.saveEx();
    isImported = true;
    return fl;
}
Also used : MPPPeriod(org.eevolution.model.MPPPeriod) MForecastLine(org.compiere.model.MForecastLine) MForecast(org.compiere.model.MForecast)

Example 5 with MForecastLine

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

the class ImportForecast method importRecords.

// doIt
/**
	 * import records using Import Forecast table
	 */
private void importRecords() {
    for (X_I_Forecast ifl : getRecords(false, m_IsImportOnlyNoErrors)) {
        isImported = false;
        MForecastLine fl = importForecast(ifl);
        if (fl != null)
            isImported = true;
        if (isImported) {
            ifl.setM_ForecastLine_ID(fl.getM_ForecastLine_ID());
            ifl.setI_IsImported(true);
            ifl.setProcessed(true);
            ifl.setI_ErrorMsg("");
            ifl.saveEx();
            imported++;
        } else {
            ifl.setI_IsImported(false);
            ifl.setProcessed(true);
            ifl.saveEx();
            notimported++;
        }
    }
}
Also used : MForecastLine(org.compiere.model.MForecastLine) X_I_Forecast(org.eevolution.model.X_I_Forecast)

Aggregations

MForecastLine (org.compiere.model.MForecastLine)5 MForecast (org.compiere.model.MForecast)3 MOrder (org.compiere.model.MOrder)2 MOrderLine (org.compiere.model.MOrderLine)2 MRequisition (org.compiere.model.MRequisition)2 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MProduct (org.compiere.model.MProduct)1 MRequisitionLine (org.compiere.model.MRequisitionLine)1 DocAction (org.compiere.process.DocAction)1 MDDOrder (org.eevolution.model.MDDOrder)1 MDDOrderLine (org.eevolution.model.MDDOrderLine)1 MPPOrder (org.eevolution.model.MPPOrder)1 MPPPeriod (org.eevolution.model.MPPPeriod)1 X_I_Forecast (org.eevolution.model.X_I_Forecast)1