Search in sources :

Example 1 with Budget

use of org.estatio.module.budget.dom.budget.Budget in project estatio by estatio.

the class KeyItemImportExportLineItem method getKeyTable.

@Programmatic
public KeyTable getKeyTable() {
    if (keyTable == null) {
        Budget budget = budgetRepository.findByPropertyAndStartDate(getProperty(), getStartDate());
        keyTable = keyTableRepository.findByBudgetAndName(budget, getKeyTableName());
    }
    return keyTable;
}
Also used : Budget(org.estatio.module.budget.dom.budget.Budget) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with Budget

use of org.estatio.module.budget.dom.budget.Budget in project estatio by estatio.

the class BudgetOverride method getCalculatedValueByBudget.

@Programmatic
BigDecimal getCalculatedValueByBudget(final LocalDate budgetStartDate, final BudgetCalculationType type) {
    BigDecimal value = BigDecimal.ZERO;
    List<Unit> unitsForLease = new ArrayList<>();
    List<BudgetCalculation> calculationsForLeaseAndCharges = new ArrayList<>();
    for (Occupancy occupancy : getLease().getOccupancies()) {
        unitsForLease.add(occupancy.getUnit());
    }
    Budget budget = budgetRepository.findByPropertyAndDate(getLease().getProperty(), budgetStartDate);
    if (getIncomingCharge() == null) {
        for (Unit unit : unitsForLease) {
            calculationsForLeaseAndCharges.addAll(budgetCalculationRepository.findByBudgetAndUnitAndInvoiceChargeAndType(budget, unit, getInvoiceCharge(), type));
        }
    } else {
        for (Unit unit : unitsForLease) {
            calculationsForLeaseAndCharges.addAll(budgetCalculationRepository.findByBudgetAndUnitAndInvoiceChargeAndIncomingChargeAndType(budget, unit, getInvoiceCharge(), getIncomingCharge(), type));
        }
    }
    for (BudgetCalculation calculation : calculationsForLeaseAndCharges) {
        value = value.add(calculation.getEffectiveValue());
    }
    return value;
}
Also used : Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) ArrayList(java.util.ArrayList) Budget(org.estatio.module.budget.dom.budget.Budget) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) BudgetCalculation(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 3 with Budget

use of org.estatio.module.budget.dom.budget.Budget 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 4 with Budget

use of org.estatio.module.budget.dom.budget.Budget 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 5 with Budget

use of org.estatio.module.budget.dom.budget.Budget in project estatio by estatio.

the class BudgetImportExport method removeExistingBudgetItemsIfNotLinked.

private void removeExistingBudgetItemsIfNotLinked() {
    Property property = propertyRepository.findPropertyByReference(getPropertyReference());
    Budget budget = budgetRepository.findOrCreateBudget(property, getBudgetStartDate(), getBudgetEndDate());
    for (BudgetItem item : budget.getItems()) {
        if (orderItemRepository.findByBudgetItem(item).size() == 0 && incomingInvoiceItemRepository.findByBudgetItem(item).size() == 0) {
            for (PartitionItem pItem : item.getPartitionItems()) {
                pItem.remove();
            }
            repositoryService.removeAndFlush(item);
        }
    }
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) Property(org.estatio.module.asset.dom.Property) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem)

Aggregations

Budget (org.estatio.module.budget.dom.budget.Budget)16 Property (org.estatio.module.asset.dom.Property)8 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)8 LocalDate (org.joda.time.LocalDate)7 Action (org.apache.isis.applib.annotation.Action)4 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 Test (org.junit.Test)4 BigDecimal (java.math.BigDecimal)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 ArrayList (java.util.ArrayList)2 ApplicationException (org.apache.isis.applib.ApplicationException)2 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)2 Lease (org.estatio.module.lease.dom.Lease)2 LeaseRepository (org.estatio.module.lease.dom.LeaseRepository)2 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)2 List (java.util.List)1 SortedSet (java.util.SortedSet)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1