Search in sources :

Example 16 with BudgetItem

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");
}
Also used : Organisation(org.estatio.module.party.dom.Organisation) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 17 with BudgetItem

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);
}
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 18 with BudgetItem

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);
}
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 19 with BudgetItem

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;
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) ArrayList(java.util.ArrayList) BudgetOverrideValue(org.estatio.module.budgetassignment.dom.override.BudgetOverrideValue) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun) BigDecimal(java.math.BigDecimal) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) BudgetCalculation(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation)

Example 20 with BudgetItem

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());
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)22 Property (org.estatio.module.asset.dom.Property)11 Charge (org.estatio.module.charge.dom.Charge)9 LocalDate (org.joda.time.LocalDate)9 Test (org.junit.Test)9 BigDecimal (java.math.BigDecimal)8 Budget (org.estatio.module.budget.dom.budget.Budget)8 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)5 Project (org.estatio.module.capex.dom.project.Project)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 Tax (org.estatio.module.tax.dom.Tax)4 ArrayList (java.util.ArrayList)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 ApplicationException (org.apache.isis.applib.ApplicationException)2 Action (org.apache.isis.applib.annotation.Action)2 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 Partitioning (org.estatio.module.budget.dom.partioning.Partitioning)2 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)2 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)2 Organisation (org.estatio.module.party.dom.Organisation)2