use of org.estatio.module.budgetassignment.dom.override.BudgetOverride 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.budgetassignment.dom.override.BudgetOverride in project estatio by estatio.
the class Budget_Remove method removeBudget.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public void removeBudget(@ParameterLayout(named = "This will delete the budget and all associated data including keytables, calculations, runs, results and lease terms. (You may consider downloading the budget and the keytables beforehand.) Are you sure?") final boolean areYouSure) {
// delete results and runs
for (BudgetCalculationRun run : budgetCalculationRunRepository.allBudgetCalculationRuns().stream().filter(x -> x.getBudget().equals(budget)).collect(Collectors.toList())) {
for (BudgetCalculationResult result : run.getBudgetCalculationResults()) {
// delete links and lease terms
for (BudgetCalculationResultLink link : budgetCalculationResultLinkRepository.findByCalculationResult(result)) {
LeaseTermForServiceCharge leaseTermToRemove = null;
if (link.getLeaseTermForServiceCharge() != null) {
leaseTermToRemove = link.getLeaseTermForServiceCharge();
}
link.remove();
if (leaseTermToRemove != null) {
leaseTermToRemove.remove();
}
}
}
run.remove();
}
// delete overrides and values
for (Lease lease : leaseRepository.findByAssetAndActiveOnDate(budget.getProperty(), budget.getStartDate())) {
for (BudgetOverride override : budgetOverrideRepository.findByLease(lease)) {
override.remove();
}
}
// delete partition items
for (BudgetItem budgetItem : budget.getItems()) {
for (PartitionItem item : partitionItemRepository.findByBudgetItem(budgetItem)) {
item.remove();
}
}
budget.remove();
}
Aggregations