Search in sources :

Example 6 with KeyTable

use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.

the class BudgetImportExportManager method importKeyTables.

private void importKeyTables(final List<BudgetImportExport> budgetItemLines, final List<List<?>> objects) {
    List<KeyTable> keyTablesToImport = keyTablesToImport(budgetItemLines);
    List<KeyItemImportExportLineItem> keyItemLines = (List<KeyItemImportExportLineItem>) objects.get(1);
    // filter case where no key items are filled in
    if (keyItemLines.size() == 0) {
        return;
    }
    for (KeyTable keyTable : keyTablesToImport) {
        List<KeyItemImportExportLineItem> itemsToImportForKeyTable = new ArrayList<>();
        for (KeyItemImportExportLineItem keyItemLine : keyItemLines) {
            if (keyItemLine.getKeyTableName().equals(keyTable.getName())) {
                itemsToImportForKeyTable.add(new KeyItemImportExportLineItem(keyItemLine));
            }
        }
        for (KeyItem keyItem : keyTable.getItems()) {
            Boolean keyItemFound = false;
            for (KeyItemImportExportLineItem lineItem : itemsToImportForKeyTable) {
                if (lineItem.getUnitReference().equals(keyItem.getUnit().getReference())) {
                    keyItemFound = true;
                    break;
                }
            }
            if (!keyItemFound) {
                KeyItemImportExportLineItem deletedItem = new KeyItemImportExportLineItem(keyItem);
                deletedItem.setStatus(Status.DELETED);
                itemsToImportForKeyTable.add(deletedItem);
            }
        }
        for (KeyItemImportExportLineItem item : itemsToImportForKeyTable) {
            serviceRegistry2.injectServicesInto(item);
            item.validate();
            item.apply();
        }
    }
}
Also used : KeyItemImportExportLineItem(org.estatio.module.budgetassignment.imports.KeyItemImportExportLineItem) ArrayList(java.util.ArrayList) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) ArrayList(java.util.ArrayList) List(java.util.List) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem)

Example 7 with KeyTable

use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.

the class BudgetItem method createCopyFor.

@Programmatic
public BudgetItem createCopyFor(final Budget budget) {
    // only copies of budgeted values are made
    BudgetItem newBudgetItemCopy = budget.newBudgetItem(getBudgetedValue(), getCharge());
    for (PartitionItem partitionItem : partitionItemRepository.findByBudgetItem(this)) {
        // only copies of budgeted items are made
        if (partitionItem.getPartitioning().getType() == BudgetCalculationType.BUDGETED) {
            String keyTableName = partitionItem.getKeyTable().getName();
            KeyTable correspondingTableOnbudget = keyTableRepository.findByBudgetAndName(budget, keyTableName);
            newBudgetItemCopy.createPartitionItemForBudgeting(partitionItem.getCharge(), correspondingTableOnbudget, partitionItem.getPercentage());
        }
    }
    return newBudgetItemCopy;
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 8 with KeyTable

use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.

the class KeyTableBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("budget", executionContext, Budget.class);
    checkParam("name", executionContext, String.class);
    defaultParam("foundationValueType", executionContext, fakeDataService.enums().anyOf(FoundationValueType.class));
    defaultParam("keyValueMethod", executionContext, fakeDataService.enums().anyOf(KeyValueMethod.class));
    defaultParam("numberOfDigits", executionContext, 3);
    final KeyTable keyTable = keyTableRepository.newKeyTable(budget, name, foundationValueType, keyValueMethod, numberOfDigits);
    keyTable.generateItems();
    executionContext.addResult(this, name, keyTable);
    object = keyTable;
}
Also used : FoundationValueType(org.estatio.module.budget.dom.keytable.FoundationValueType) KeyValueMethod(org.estatio.module.budget.dom.keytable.KeyValueMethod) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable)

Example 9 with KeyTable

use of org.estatio.module.budget.dom.keytable.KeyTable 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 10 with KeyTable

use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.

the class KeyItemRepository_Test method negativeSourceValue.

@Test
public void negativeSourceValue() {
    // given
    KeyTable keyTable = new KeyTable();
    Unit unit = new Unit();
    BigDecimal sourcevalue = BigDecimal.valueOf(-0.001);
    BigDecimal keyValue = new BigDecimal(10);
    // when
    String validateNewBudgetKeyItem = keyItemRepository.validateNewItem(keyTable, unit, sourcevalue, keyValue);
    // then
    assertThat(validateNewBudgetKeyItem).isEqualTo("sourceValue cannot be zero or less than zero");
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

KeyTable (org.estatio.module.budget.dom.keytable.KeyTable)14 BigDecimal (java.math.BigDecimal)9 Test (org.junit.Test)9 KeyItem (org.estatio.module.budget.dom.keyitem.KeyItem)7 AbstractBeanPropertiesTest (org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest)6 Unit (org.estatio.module.asset.dom.Unit)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 Charge (org.estatio.module.charge.dom.Charge)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ApplicationException (org.apache.isis.applib.ApplicationException)1 Property (org.estatio.module.asset.dom.Property)1 Budget (org.estatio.module.budget.dom.budget.Budget)1 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)1 FoundationValueType (org.estatio.module.budget.dom.keytable.FoundationValueType)1 KeyValueMethod (org.estatio.module.budget.dom.keytable.KeyValueMethod)1 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)1 Partitioning (org.estatio.module.budget.dom.partioning.Partitioning)1 KeyItemImportExportLineItem (org.estatio.module.budgetassignment.imports.KeyItemImportExportLineItem)1