use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.
the class BudgetAssignmentService method getDetailedCalculationResults.
public List<DetailedCalculationResultViewmodel> getDetailedCalculationResults(final Lease lease, final Budget budget, final BudgetCalculationType type) {
List<DetailedCalculationResultViewmodel> results = new ArrayList<>();
BudgetCalculationRun runForLease = budgetCalculationRunRepository.findUnique(lease, budget, type);
if (runForLease == null) {
return results;
}
for (BudgetCalculationResult result : runForLease.getBudgetCalculationResults()) {
// scenario: one override for incoming charge
if (result.overrideValueForInvoiceCharge() != null) {
results.add(new DetailedCalculationResultViewmodel(lease.primaryOccupancy().get().getUnit(), "Override for total " + result.getInvoiceCharge().getDescription(), result.getValue().add(result.getShortfall()), result.getValue(), result.getShortfall(), null, result.getInvoiceCharge()));
} else {
for (BudgetCalculation calculation : result.getBudgetCalculations()) {
BigDecimal effectiveValueForIncomingCharge = calculation.getEffectiveValue();
BigDecimal shortFallForIncomingCharge = BigDecimal.ZERO;
BigDecimal valueInBudget = BigDecimal.ZERO;
DetailedCalculationResultViewmodel vm = new DetailedCalculationResultViewmodel(calculation.getUnit(), calculation.getIncomingCharge().getDescription(), calculation.getEffectiveValue(), valueInBudget, effectiveValueForIncomingCharge, shortFallForIncomingCharge, calculation.getInvoiceCharge());
// set value in Budget
PartitionItem partitionItem = calculation.getPartitionItem();
BudgetItem budgetItem = calculation.getBudgetItem();
BigDecimal valueForBudgetItem = type == BudgetCalculationType.BUDGETED ? budgetItem.getBudgetedValue() : budgetItem.getAuditedValue();
valueInBudget = valueForBudgetItem;
vm.setTotalValueInBudget(valueInBudget);
// set possible overrides for incoming charge
for (BudgetOverrideValue overrideValue : result.getOverrideValues()) {
if (overrideValue.getBudgetOverride().getIncomingCharge() == calculation.getIncomingCharge() && overrideValue.getType() == type) {
effectiveValueForIncomingCharge = overrideValue.getValue().multiply(calculation.getPartitionItem().getPartitioning().getFractionOfYear());
shortFallForIncomingCharge = calculation.getEffectiveValue().subtract(effectiveValueForIncomingCharge);
}
}
if (effectiveValueForIncomingCharge != BigDecimal.ZERO) {
vm.setEffectiveValueForLease(effectiveValueForIncomingCharge);
vm.setShortfall(shortFallForIncomingCharge);
}
results.add(vm);
}
}
}
return results;
}
use of org.estatio.module.budget.dom.partioning.PartitionItem in project estatio by estatio.
the class BudgetImportExportService method createLines.
private List<BudgetImportExport> createLines(final BudgetItem item, final BudgetImportExportManager manager) {
List<BudgetImportExport> lines = new ArrayList<>();
String propertyReference = manager.getBudget().getProperty().getReference();
LocalDate budgetStartDate = manager.getBudget().getStartDate();
LocalDate budgetEndDate = manager.getBudget().getEndDate();
String budgetChargeReference = item.getCharge().getReference();
BigDecimal budgetedValue = item.getBudgetedValue();
BigDecimal auditedValue = item.getAuditedValue();
if (item.getPartitionItems().size() == 0) {
// create 1 line
lines.add(new BudgetImportExport(propertyReference, budgetStartDate, budgetEndDate, budgetChargeReference, budgetedValue, auditedValue, null, null, null, null, null));
} else {
// create a line for each partion item
for (PartitionItem partitionItem : item.getPartitionItems()) {
String keyTableName = partitionItem.getKeyTable().getName();
String foundationValueType = partitionItem.getKeyTable().getFoundationValueType().toString();
String keyValueMethod = partitionItem.getKeyTable().getKeyValueMethod().toString();
String allocationChargeReference = partitionItem.getCharge().getReference();
BigDecimal percentage = partitionItem.getPercentage();
lines.add(new BudgetImportExport(propertyReference, budgetStartDate, budgetEndDate, budgetChargeReference, budgetedValue, auditedValue, keyTableName, foundationValueType, keyValueMethod, allocationChargeReference, percentage));
}
}
return lines;
}
Aggregations