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;
}
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;
}
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();
}
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"));
}
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);
}
}
}
Aggregations