Search in sources :

Example 1 with BudgetOverrideForFixed

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);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) BudgetOverrideValue(org.estatio.module.budgetassignment.dom.override.BudgetOverrideValue) BudgetOverrideForFixed(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 2 with BudgetOverrideForFixed

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);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) BudgetOverrideForFixed(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with 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;
}
Also used : BudgetOverrideForFixed(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed)

Example 4 with BudgetOverrideForFixed

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;
}
Also used : BudgetOverrideForFlatRate(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFlatRate) BudgetOverrideForMax(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax) BudgetOverrideImportExport(org.estatio.module.budgetassignment.imports.BudgetOverrideImportExport) ArrayList(java.util.ArrayList) BudgetOverrideForFixed(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed) BigDecimal(java.math.BigDecimal)

Aggregations

BudgetOverrideForFixed (org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed)4 BigDecimal (java.math.BigDecimal)3 Charge (org.estatio.module.charge.dom.Charge)2 Lease (org.estatio.module.lease.dom.Lease)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 BudgetOverrideForFlatRate (org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFlatRate)1 BudgetOverrideForMax (org.estatio.module.budgetassignment.dom.override.BudgetOverrideForMax)1 BudgetOverrideValue (org.estatio.module.budgetassignment.dom.override.BudgetOverrideValue)1 BudgetOverrideImportExport (org.estatio.module.budgetassignment.imports.BudgetOverrideImportExport)1