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);
}
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));
}
}
Aggregations