use of org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed in project estatio by estatio.
the class BudgetOverrideValueRepository_IntegTest method findOrCreateBudgetOverrideValueWorks.
@Test
public void findOrCreateBudgetOverrideValueWorks() {
BudgetOverrideForFixed budgetOverrideForFixed;
BudgetOverrideValue budgetOverrideValue;
BigDecimal calculatedValue = new BigDecimal("1234.56");
// given
Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
BigDecimal overrideValue = new BigDecimal("1234.56");
String reason = "Some reason";
budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(0);
// when
budgetOverrideValue = wrap(budgetOverrideValueRepository).findOrCreateOverrideValue(calculatedValue, budgetOverrideForFixed, BudgetCalculationType.BUDGETED);
// then
assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(1);
assertThat(budgetOverrideValue.getValue()).isEqualTo(calculatedValue);
assertThat(budgetOverrideValue.getBudgetOverride()).isEqualTo(budgetOverrideForFixed);
assertThat(budgetOverrideValue.getType()).isEqualTo(BudgetCalculationType.BUDGETED);
assertThat(budgetOverrideValue.getStatus()).isEqualTo(Status.NEW);
assertThat(budgetOverrideValue.getApplicationTenancy()).isEqualTo(budgetOverrideForFixed.getApplicationTenancy());
// and when again
budgetOverrideValue = wrap(budgetOverrideValueRepository).findOrCreateOverrideValue(calculatedValue, budgetOverrideForFixed, BudgetCalculationType.BUDGETED);
// then still
assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(1);
}
use of org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed in project estatio by estatio.
the class BudgetOverrideRepository_IntegTest method findByLeaseAndInvoiceCharge.
@Test
public void findByLeaseAndInvoiceCharge() {
// given
Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
BigDecimal overrideValue = new BigDecimal("1234.56");
String reason = "Some reason";
// when
BudgetOverrideForFixed budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
// then
assertThat(budgetOverrideRepository.findByLeaseAndInvoiceCharge(leaseTopModel, invoiceCharge).size()).isEqualTo(1);
assertThat(budgetOverrideRepository.findByLeaseAndInvoiceCharge(leaseTopModel, invoiceCharge).get(0)).isEqualTo(budgetOverrideForFixed);
}
use of org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed in project estatio by estatio.
the class BudgetOverrideForFixedBuilder method execute.
@Override
protected void execute(final ExecutionContext executionContext) {
checkParam("lease", executionContext, Lease.class);
checkParam("invoiceCharge", executionContext, Charge.class);
checkParam("fixedValue", executionContext, BigDecimal.class);
defaultParam("budgetCalculationType", executionContext, BudgetCalculationType.BUDGETED);
defaultParam("reason", executionContext, "agreed on fixed amount");
BudgetOverrideForFixed budgetOverride = budgetOverrideRepository.newBudgetOverrideForFixed(fixedValue, lease, startDate, endDate, invoiceCharge, incomingCharge, budgetCalculationType, reason);
executionContext.addResult(this, budgetOverride);
object = budgetOverride;
}
use of org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed 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