Search in sources :

Example 1 with BudgetItemValue

use of org.estatio.module.budget.dom.budgetitem.BudgetItemValue in project estatio by estatio.

the class BudgetItemValueRepository_IntegTest method findUniqueTest.

@Test
public void findUniqueTest() {
    // given
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, new LocalDate(2015, 01, 01));
    BudgetItem budgetItem = budget.getItems().first();
    // when
    BudgetItemValue result = budgetItemValueRepository.findUnique(budgetItem, new LocalDate(2015, 01, 01), BudgetCalculationType.BUDGETED);
    // then
    assertThat(result.getDate()).isEqualTo(new LocalDate(2015, 01, 01));
    // and when
    result = budgetItemValueRepository.findUnique(budgetItem, new LocalDate(2015, 01, 02), BudgetCalculationType.BUDGETED);
    // then
    assertThat(result).isNull();
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 2 with BudgetItemValue

use of org.estatio.module.budget.dom.budgetitem.BudgetItemValue in project estatio by estatio.

the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Update.

@Test
public void updateOrCreateTest_Update() {
    // given
    LocalDate budgetStart = new LocalDate(2015, 01, 01);
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, budgetStart);
    BudgetItem budgetItem = budget.getItems().first();
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetItem.getValues().first().getValue()).isEqualTo(new BigDecimal("30000.55"));
    // when
    BudgetItemValue result = wrap(budgetItemValueRepository).updateOrCreateBudgetItemValue(new BigDecimal("33333.00"), budgetItem, budgetStart, BudgetCalculationType.BUDGETED);
    // then
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with BudgetItemValue

use of org.estatio.module.budget.dom.budgetitem.BudgetItemValue in project estatio by estatio.

the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Create.

@Test
public void updateOrCreateTest_Create() {
    // given
    LocalDate budgetStart = new LocalDate(2015, 1, 1);
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, budgetStart);
    BudgetItem budgetItem = budget.getItems().first();
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetItem.getValues().first().getValue()).isEqualTo(new BigDecimal("30000.55"));
    // when
    BudgetItemValue result = wrap(budgetItemValueRepository).updateOrCreateBudgetItemValue(new BigDecimal("33333.00"), budgetItem, budgetStart, BudgetCalculationType.ACTUAL);
    transactionService.flushTransaction();
    // then
    assertThat(budgetItem.getValues().size()).isEqualTo(2);
    assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
    assertThat(result.getType()).isEqualTo(BudgetCalculationType.ACTUAL);
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 4 with BudgetItemValue

use of org.estatio.module.budget.dom.budgetitem.BudgetItemValue in project estatio by estatio.

the class BudgetItemValueRepository_IntegTest method findByBudgetItemAndType.

@Test
public void findByBudgetItemAndType() {
    // given
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, new LocalDate(2015, 01, 01));
    BudgetItem budgetItem = budget.getItems().first();
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    // when
    List<BudgetItemValue> results = budgetItemValueRepository.findByBudgetItemAndType(budgetItem, BudgetCalculationType.BUDGETED);
    // then
    assertThat(results.size()).isEqualTo(1);
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

Property (org.estatio.module.asset.dom.Property)4 Budget (org.estatio.module.budget.dom.budget.Budget)4 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)4 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 LocalDate (org.joda.time.LocalDate)4 Test (org.junit.Test)4 BigDecimal (java.math.BigDecimal)2