Search in sources :

Example 1 with MPPForecastRun

use of org.eevolution.model.MPPForecastRun in project adempiere by adempiere.

the class ForecastRunCreate method doIt.

// prepare
/**
	 * Process
	 * 
	 * @return message
	 * @throws Exception
	 */
protected String doIt() throws Exception {
    m_run = new MPPForecastRun(getCtx(), p_PP_ForecastRun_ID, get_TrxName());
    // Get Forecast Definition
    m_forecast_definition = (MPPForecastDefinition) m_run.getPP_ForecastDefinition();
    if (m_run.get_ID() == 0)
        throw new IllegalArgumentException("@NotFound@ @PP_ForecastRun_ID@");
    if (m_forecast_definition.get_ID() == 0)
        throw new IllegalArgumentException("@NotFound@ @PP_ForecastDefinition_ID@");
    if (!m_run.deleteEntries(true))
        throw new IllegalArgumentException("Cannot delete existing entries");
    return "@PP_ForecastRunMaster_ID@ #" + generateForecastResult(m_run.getM_Warehouse_ID());
}
Also used : MPPForecastRun(org.eevolution.model.MPPForecastRun)

Example 2 with MPPForecastRun

use of org.eevolution.model.MPPForecastRun in project adempiere by adempiere.

the class GenerateForecast method doIt.

// prepare
/**
	 * Process
	 * 
	 * @return message
	 * @throws Exception
	 */
protected String doIt() throws Exception {
    // Validate Data
    MForecast forecast = new MForecast(getCtx(), p_M_Forecast_ID, get_TrxName());
    MPPForecastRun fr = new MPPForecastRun(getCtx(), p_PP_ForecastRun_ID, get_TrxName());
    if (fr.getAD_Org_ID() != forecast.getAD_Org_ID())
        throw new AdempiereException("@AD_Org_ID@  @NotMatched@ @M_Forecast_ID@");
    if (fr.getPP_Calendar_ID() != forecast.getPP_Calendar_ID())
        throw new AdempiereException("@PP_Calendar_ID@  @NotMatched@ @M_Forecast_ID@");
    if (fr.getPP_PeriodDefinition_ID() != forecast.getPP_PeriodDefinition_ID())
        throw new AdempiereException("@PP_PeriodDefinition_ID@ @NotMatched@ @M_Forecast_ID@");
    StringBuilder result = new StringBuilder();
    int deletedRecord = 0;
    int updatedRecord = 0;
    int createdRecord = 0;
    if (p_SalesRep_ID <= 0)
        p_SalesRep_ID = Env.getAD_User_ID(getCtx());
    if ("R".equals(p_ForecastActionType)) {
        deletedRecord = deleteData();
        createdRecord = insertForecast();
    } else if ("M".equals(p_ForecastActionType)) {
        updatedRecord = updateForecast();
        createdRecord = insertForecast();
    }
    String desc = fr.getDocumentNo() + " " + fr.getDescription();
    forecast.setDescription(forecast.getDescription() != null ? forecast.getDescription() + " " + desc : desc);
    forecast.saveEx();
    fr.setProcessed(true);
    fr.saveEx();
    result.append("@M_Forecast_ID@ # @Deleted@ = ").append(deletedRecord).append(" @Updated@ = ").append(updatedRecord).append(" @Created@ = ").append(createdRecord);
    return result.toString();
}
Also used : MPPForecastRun(org.eevolution.model.MPPForecastRun) AdempiereException(org.adempiere.exceptions.AdempiereException) MForecast(org.compiere.model.MForecast)

Aggregations

MPPForecastRun (org.eevolution.model.MPPForecastRun)2 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MForecast (org.compiere.model.MForecast)1