use of org.estatio.module.budgetassignment.imports.BudgetOverrideImportExport 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;
}
Aggregations