use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class Order_Test method minimalRequiredDataToComplete_consitent_dimensions_for_property_budgetItem.
@Test
public void minimalRequiredDataToComplete_consitent_dimensions_for_property_budgetItem() throws Exception {
// given
Order order = new Order();
OrderItem item1 = new OrderItem();
order.getItems().add(item1);
order.setOrderNumber("123");
order.setBuyer(new Organisation());
order.setSeller(new Organisation());
item1.setNetAmount(new BigDecimal("100"));
item1.setDescription("blah");
item1.setGrossAmount(BigDecimal.ZERO);
item1.setCharge(new Charge());
item1.setStartDate(new LocalDate());
item1.setEndDate(new LocalDate());
// when
item1.setBudgetItem(new BudgetItem());
String result = order.reasonIncomplete();
// then
assertThat(result).isEqualTo("(on item) when budget item filled in then property required");
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem 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);
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem 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);
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class BudgetAssignmentService method getDetailedCalculationResults.
public List<DetailedCalculationResultViewmodel> getDetailedCalculationResults(final Lease lease, final Budget budget, final BudgetCalculationType type) {
List<DetailedCalculationResultViewmodel> results = new ArrayList<>();
BudgetCalculationRun runForLease = budgetCalculationRunRepository.findUnique(lease, budget, type);
if (runForLease == null) {
return results;
}
for (BudgetCalculationResult result : runForLease.getBudgetCalculationResults()) {
// scenario: one override for incoming charge
if (result.overrideValueForInvoiceCharge() != null) {
results.add(new DetailedCalculationResultViewmodel(lease.primaryOccupancy().get().getUnit(), "Override for total " + result.getInvoiceCharge().getDescription(), result.getValue().add(result.getShortfall()), result.getValue(), result.getShortfall(), null, result.getInvoiceCharge()));
} else {
for (BudgetCalculation calculation : result.getBudgetCalculations()) {
BigDecimal effectiveValueForIncomingCharge = calculation.getEffectiveValue();
BigDecimal shortFallForIncomingCharge = BigDecimal.ZERO;
BigDecimal valueInBudget = BigDecimal.ZERO;
DetailedCalculationResultViewmodel vm = new DetailedCalculationResultViewmodel(calculation.getUnit(), calculation.getIncomingCharge().getDescription(), calculation.getEffectiveValue(), valueInBudget, effectiveValueForIncomingCharge, shortFallForIncomingCharge, calculation.getInvoiceCharge());
// set value in Budget
PartitionItem partitionItem = calculation.getPartitionItem();
BudgetItem budgetItem = calculation.getBudgetItem();
BigDecimal valueForBudgetItem = type == BudgetCalculationType.BUDGETED ? budgetItem.getBudgetedValue() : budgetItem.getAuditedValue();
valueInBudget = valueForBudgetItem;
vm.setTotalValueInBudget(valueInBudget);
// set possible overrides for incoming charge
for (BudgetOverrideValue overrideValue : result.getOverrideValues()) {
if (overrideValue.getBudgetOverride().getIncomingCharge() == calculation.getIncomingCharge() && overrideValue.getType() == type) {
effectiveValueForIncomingCharge = overrideValue.getValue().multiply(calculation.getPartitionItem().getPartitioning().getFractionOfYear());
shortFallForIncomingCharge = calculation.getEffectiveValue().subtract(effectiveValueForIncomingCharge);
}
}
if (effectiveValueForIncomingCharge != BigDecimal.ZERO) {
vm.setEffectiveValueForLease(effectiveValueForIncomingCharge);
vm.setShortfall(shortFallForIncomingCharge);
}
results.add(vm);
}
}
}
return results;
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class BudgetImportExport method importData.
@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
if (previousRow == null) {
removeExistingBudgetItemsIfNotLinked();
}
Charge incomingCharge = fetchCharge(getIncomingChargeReference());
BudgetItem budgetItem = findOrCreateBudgetAndBudgetItem(incomingCharge);
if (getOutgoingChargeReference() != null && getKeyTableName() != null && getFoundationValueType() != null && getKeyValueMethod() != null && percentage != null) {
findOrCreatePartitionItem(budgetItem);
}
return Lists.newArrayList(budgetItem.getBudget());
}
Aggregations