Search in sources :

Example 21 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class PartitioningBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("budget", executionContext, Budget.class);
    defaultParam("startDate", executionContext, budget.getStartDate());
    defaultParam("endDate", executionContext, budget.getEndDate());
    defaultParam("budgetCalculationType", executionContext, BudgetCalculationType.BUDGETED);
    Partitioning partitioning = partitioningRepository.newPartitioning(budget, startDate, endDate, budgetCalculationType);
    executionContext.addResult(this, partitioning);
    for (ItemSpec spec : itemSpec) {
        final Charge itemCharge = spec.itemCharge;
        final BudgetItem budgetItem = budget.findByCharge(itemCharge);
        PartitionItem partitionItem = partitionItemRepository.newPartitionItem(partitioning, spec.charge, spec.keyTable, budgetItem, spec.percentage);
        executionContext.addResult(this, partitionItem);
    }
    object = partitioning;
}
Also used : Partitioning(org.estatio.module.budget.dom.partioning.Partitioning) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem)

Example 22 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class PartitionItemImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    Property property = propertyRepository.findPropertyByReference(propertyReference);
    if (property == null)
        throw new ApplicationException(String.format("Property with reference [%s] not found.", propertyReference));
    final Budget budget = budgetRepository.findOrCreateBudget(property, startDate, endDate);
    final KeyTable keyTable = keyTableRepository.findOrCreateBudgetKeyTable(budget, keyTableName, FoundationValueType.MANUAL, KeyValueMethod.PERCENT, 6);
    findOrCreateBudgetKeyItem(keyTable, unitRepository.findUnitByReference(unitReference), keyValue, sourceValue);
    final Charge charge = fetchCharge(budgetChargeReference);
    final BudgetItem butgetItem = findOrCreateBudgetItem(budget, charge, budgetValue);
    final Charge scheduleCharge = fetchCharge(invoiceChargeReference);
    final Partitioning partitioning = findOrCreatePartitioning(budget);
    findOrCreatePartitionItem(partitioning, scheduleCharge, butgetItem, keyTable, percentage);
    return Lists.newArrayList();
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Partitioning(org.estatio.module.budget.dom.partioning.Partitioning) Charge(org.estatio.module.charge.dom.Charge) Budget(org.estatio.module.budget.dom.budget.Budget) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 23 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class ProjectImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    if (previousRow != null) {
    // TODO: support sparse sheets ?
    }
    Project parent = null;
    if (getParentReference() != null) {
        parent = projectRepository.findByReference(getParentReference());
        if (parent == null) {
            throw new ApplicationException(String.format("Parent with reference %s not found.", getParentReference()));
        }
        if (!parent.getAtPath().equals(getAtPath())) {
            throw new ApplicationException(String.format("AtPath parent %s does not match %s.", getParentReference(), getAtPath()));
        }
        if (!parent.getItems().isEmpty()) {
            // TODO: (ECP-438) until we find out more about the process, prevent a the choice of a project having items
            throw new ApplicationException(String.format("Parent with reference %s has items and cannot be a parent therefore.", getAtPath()));
        }
    }
    Project project = findOrCreateProjectAndUpdateParent(getReference(), getName(), getStartDate(), getEndDate(), getAtPath(), parent);
    if (getItemChargeReference() != null) {
        Charge charge = chargeRepository.findByReference(getItemChargeReference());
        Property property = propertyRepository.findPropertyByReference(getItemPropertyReference());
        Tax tax = taxRepository.findByReference(getItemTaxReference());
        wrapperFactory.wrap(project).addItem(charge, getItemDescription(), getItemBudgetedAmount(), getItemStartDate(), getItemEndDate(), property, tax);
    }
    return Lists.newArrayList(project);
}
Also used : Project(org.estatio.module.capex.dom.project.Project) ApplicationException(org.apache.isis.applib.ApplicationException) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 24 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class BudgetOverride_IntegTest method findOrCreateValuesTest.

@Test
public void findOrCreateValuesTest() {
    // given
    Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
    Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
    BigDecimal overrideValue = new BigDecimal("1234.56");
    String reason = "Some reason";
    budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
    assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(0);
    // when
    budgetOverrideForFixed.findOrCreateValues(new LocalDate(2015, 01, 01));
    // then
    assertThat(budgetOverrideForFixed.getValues().size()).isEqualTo(2);
    assertThat(budgetOverrideForFixed.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetOverrideForFixed.getValues().last().getType()).isEqualTo(BudgetCalculationType.ACTUAL);
    // and when again
    budgetOverrideForFixed.findOrCreateValues(new LocalDate(2015, 01, 01));
    // then still
    assertThat(budgetOverrideForFixed.getValues().size()).isEqualTo(2);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 25 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class OrderItemRepository_Test method orderItemsWithoutProjectItem_works.

@Test
public void orderItemsWithoutProjectItem_works() throws Exception {
    // given
    Project project = new Project();
    ProjectItem item1 = new ProjectItem();
    Charge chargeOnProjectItem = new Charge();
    item1.setCharge(chargeOnProjectItem);
    project.getItems().add(item1);
    Charge chargeNOTOnProjectItem = new Charge();
    OrderItem orderItemToBeFound = new OrderItem();
    orderItemToBeFound.setCharge(chargeNOTOnProjectItem);
    OrderItem orderItemNOTToBeFound = new OrderItem();
    orderItemNOTToBeFound.setCharge(chargeOnProjectItem);
    OrderItemRepository orderItemRepository = new OrderItemRepository() {

        @Override
        public List<OrderItem> findByProject(final Project project) {
            return Arrays.asList(orderItemNOTToBeFound, orderItemToBeFound);
        }
    };
    // when
    List<OrderItem> result = orderItemRepository.orderItemsNotOnProjectItem(project);
    // then
    Assertions.assertThat(result.size()).isEqualTo(1);
    Assertions.assertThat(result.get(0)).isEqualTo(orderItemToBeFound);
    Assertions.assertThat(result.get(0).getCharge()).isEqualTo(chargeNOTOnProjectItem);
}
Also used : Project(org.estatio.module.capex.dom.project.Project) ProjectItem(org.estatio.module.capex.dom.project.ProjectItem) Charge(org.estatio.module.charge.dom.Charge) Test(org.junit.Test)

Aggregations

Charge (org.estatio.module.charge.dom.Charge)41 Test (org.junit.Test)18 BigDecimal (java.math.BigDecimal)14 LocalDate (org.joda.time.LocalDate)14 Lease (org.estatio.module.lease.dom.Lease)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)9 Project (org.estatio.module.capex.dom.project.Project)9 Tax (org.estatio.module.tax.dom.Tax)9 Property (org.estatio.module.asset.dom.Property)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)6 ApplicationException (org.apache.isis.applib.ApplicationException)4 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)4 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)4 Action (org.apache.isis.applib.annotation.Action)3 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)3 Organisation (org.estatio.module.party.dom.Organisation)3 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)3 Expectations (org.jmock.Expectations)3 ArrayList (java.util.ArrayList)2