Search in sources :

Example 1 with BudgetCalculationType

use of org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType in project estatio by estatio.

the class BudgetOverrideImportExport method importData.

// @Override
// public List<Class> importAfter() {
// return Lists.newArrayList();
// }
@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
    if (getInvoiceChargeReference() == null) {
        throw new ApplicationException("Incoming charge reference cannot be empty");
    }
    if (getReason() == null) {
        throw new ApplicationException("Reason cannot be empty");
    }
    BudgetCalculationType budgetCalculationType;
    budgetCalculationType = getType() == null ? null : BudgetCalculationType.valueOf(getType());
    BudgetOverride budgetOverride;
    Charge incomingCharge = getIncomingChargeReference() == null ? null : fetchCharge(getIncomingChargeReference());
    switch(getClassName()) {
        case "BudgetOverrideForMax":
            validate();
            budgetOverride = budgetOverrideRepository.newBudgetOverrideForMax(getMaxValue(), fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
            break;
        case "BudgetOverrideForFixed":
            validate();
            budgetOverride = budgetOverrideRepository.newBudgetOverrideForFixed(getFixedValue(), fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
            break;
        case "BudgetOverrideForFlatRate":
            validate();
            budgetOverride = budgetOverrideRepository.newBudgetOverrideForFlatRate(getValuePerM2(), getWeightedArea(), fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
            break;
        default:
            throw new ApplicationException(String.format("Classname %s is not valid.", getClassName()));
    }
    return Lists.newArrayList(budgetOverride);
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) BudgetCalculationType(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType) Charge(org.estatio.module.charge.dom.Charge) Programmatic(org.apache.isis.applib.annotation.Programmatic) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride)

Example 2 with BudgetCalculationType

use of org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType in project estatio by estatio.

the class BudgetOverrideImportExport method validate.

private void validate() {
    Charge incomingCharge = getIncomingChargeReference() == null ? null : fetchCharge(getIncomingChargeReference());
    BudgetCalculationType budgetCalculationType;
    budgetCalculationType = getType() == null ? null : BudgetCalculationType.valueOf(getType());
    String invalidReason = budgetOverrideRepository.validateNewBudgetOverride(fetchLease(getLeaseReference()), getStartDate(), getEndDate(), fetchCharge(getInvoiceChargeReference()), incomingCharge, budgetCalculationType, getReason());
    if (invalidReason != null) {
        throw new ApplicationException(String.format(invalidReason));
    }
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BudgetCalculationType(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType) Charge(org.estatio.module.charge.dom.Charge)

Aggregations

ApplicationException (org.apache.isis.applib.ApplicationException)2 BudgetCalculationType (org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType)2 Charge (org.estatio.module.charge.dom.Charge)2 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 BudgetOverride (org.estatio.module.budgetassignment.dom.override.BudgetOverride)1