Search in sources :

Example 1 with MPPPeriodDefinition

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

the class CreatePeriods method doIt.

// prepare
/**
	 * Process
	 * 
	 * @return info
	 * @throws Exception
	 */
protected String doIt() throws Exception {
    MPPPeriodDefinition definition = new MPPPeriodDefinition(getCtx(), p_M_PeriodDefinition_ID, get_TrxName());
    if (p_M_PeriodDefinition_ID == 0 || definition.get_ID() != p_M_PeriodDefinition_ID)
        throw new AdempiereUserError("@NotFound@: @M_PeriodDefinition_ID@ - " + p_M_PeriodDefinition_ID);
    log.info(definition.toString());
    //
    if (definition.createPeriods(null, p_StartDate, p_DateFormat, p_NoPeriods))
        return "@OK@";
    return "@Error@";
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) MPPPeriodDefinition(org.eevolution.model.MPPPeriodDefinition)

Example 2 with MPPPeriodDefinition

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

the class ForecastRunCreate method generateForecastResult.

// doIt
/**
	 * Generate Forecast Result based on Forecast Detail and Forecast Definition
	 * 
	 * @param M_Warehouse_ID
	 * @return no records processed
	 */
private int generateForecastResult(int M_Warehouse_ID) {
    // Preview Calculate Data
    deleteData();
    // Get Period Base
    m_period_definition_base = new MPPPeriodDefinition(getCtx(), m_run.getRef_DefinitionPeriod_ID(), get_TrxName());
    m_period_definition_target = new MPPPeriodDefinition(getCtx(), m_run.getPP_PeriodDefinition_ID(), get_TrxName());
    m_forecast_rule = (MPPForecastRule) m_run.getPP_ForecastRule();
    // Get Periods
    List<MPPPeriod> m_period_history = m_period_definition_base.getPeriodsOfHistory(m_run.getPeriodHistory());
    // Generate Forecast Run Master
    int selection = generateForecastRunMaster(m_run, m_forecast_definition, m_period_history.get(m_period_history.size() - 1), m_period_history.get(0));
    if (selection <= 0)
        throw new IllegalArgumentException("@FindZeroRecords@");
    for (MPPForecastRunMaster master : MPPForecastRunMaster.getLines(getCtx(), p_PP_ForecastRun_ID, get_TrxName())) {
        // Generate Forecast Detail for each period
        for (MPPPeriod period : m_period_history) {
            // Create Forecast Run Detail
            createForecastRunDetail(master, period);
        }
    }
    // Create Forecast Run Entry based on Forecast Run Detail
    return createForecastRunResult(M_Warehouse_ID);
}
Also used : MPPPeriod(org.eevolution.model.MPPPeriod) MPPForecastRunMaster(org.eevolution.model.MPPForecastRunMaster) MPPPeriodDefinition(org.eevolution.model.MPPPeriodDefinition)

Aggregations

MPPPeriodDefinition (org.eevolution.model.MPPPeriodDefinition)2 AdempiereUserError (org.compiere.util.AdempiereUserError)1 MPPForecastRunMaster (org.eevolution.model.MPPForecastRunMaster)1 MPPPeriod (org.eevolution.model.MPPPeriod)1