Search in sources :

Example 1 with BudgetOverrideForMax

use of org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax in project estatio by estatio.

the class BudgetOverrideForMaxBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("lease", executionContext, Lease.class);
    checkParam("invoiceCharge", executionContext, Charge.class);
    checkParam("maxValue", executionContext, BigDecimal.class);
    defaultParam("budgetCalculationType", executionContext, BudgetCalculationType.BUDGETED);
    defaultParam("reason", executionContext, BudgetOverrideType.CEILING.reason);
    BudgetOverrideForMax budgetOverride = budgetOverrideRepository.newBudgetOverrideForMax(maxValue, lease, startDate, endDate, invoiceCharge, incomingCharge, budgetCalculationType, reason);
    executionContext.addResult(this, budgetOverride);
    object = budgetOverride;
}
Also used : BudgetOverrideForMax(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax)

Example 2 with BudgetOverrideForMax

use of org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax in project estatio by estatio.

the class BudgetImportExportService method createOverrides.

private List<BudgetOverrideImportExport> createOverrides(final BudgetOverride override, final BudgetImportExportManager manager) {
    List<BudgetOverrideImportExport> result = new ArrayList<>();
    String incomingChargeRef;
    if (override.getIncomingCharge() == null) {
        incomingChargeRef = null;
    } else {
        incomingChargeRef = override.getIncomingCharge().getReference();
    }
    String typeName;
    if (override.getType() == null) {
        typeName = null;
    } else {
        typeName = override.getType().name();
    }
    BigDecimal maxValue = BigDecimal.ZERO;
    if (override.getClass() == BudgetOverrideForMax.class) {
        BudgetOverrideForMax o = (BudgetOverrideForMax) override;
        maxValue = maxValue.add(o.getMaxValue());
    }
    BigDecimal fixedValue = BigDecimal.ZERO;
    if (override.getClass() == BudgetOverrideForFixed.class) {
        BudgetOverrideForFixed o = (BudgetOverrideForFixed) override;
        fixedValue = fixedValue.add(o.getFixedValue());
    }
    BigDecimal valuePerM2 = BigDecimal.ZERO;
    BigDecimal weightedArea = BigDecimal.ZERO;
    if (override.getClass() == BudgetOverrideForFlatRate.class) {
        BudgetOverrideForFlatRate o = (BudgetOverrideForFlatRate) override;
        valuePerM2 = valuePerM2.add(o.getValuePerM2());
        weightedArea = weightedArea.add(o.getWeightedArea());
    }
    result.add(new BudgetOverrideImportExport(override.getLease().getReference(), override.getStartDate(), override.getEndDate(), override.getInvoiceCharge().getReference(), incomingChargeRef, typeName, override.getReason(), override.getClass().getSimpleName(), maxValue, fixedValue, valuePerM2, weightedArea));
    return result;
}
Also used : BudgetOverrideForFlatRate(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFlatRate) BudgetOverrideForMax(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax) BudgetOverrideImportExport(org.estatio.module.budgetassignment.imports.BudgetOverrideImportExport) ArrayList(java.util.ArrayList) BudgetOverrideForFixed(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed) BigDecimal(java.math.BigDecimal)

Aggregations

BudgetOverrideForMax (org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 BudgetOverrideForFixed (org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed)1 BudgetOverrideForFlatRate (org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFlatRate)1 BudgetOverrideImportExport (org.estatio.module.budgetassignment.imports.BudgetOverrideImportExport)1