Search in sources :

Example 11 with KeyTable

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

the class KeyItemRepository_Test method negativeKeyValue.

@Test
public void negativeKeyValue() {
    // given
    KeyTable keyTable = new KeyTable();
    Unit unit = new Unit();
    BigDecimal sourcevalue = new BigDecimal(1);
    BigDecimal keyValue = BigDecimal.valueOf(-0.001);
    // when
    String validateNewBudgetKeyItem = keyItemRepository.validateNewItem(keyTable, unit, sourcevalue, keyValue);
    // then
    assertThat(validateNewBudgetKeyItem).isEqualTo("keyValue cannot be 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)

Example 12 with KeyTable

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

the class KeyItem_Test method testValidateChangeValue.

@Test
public void testValidateChangeValue() {
    // given
    KeyTable table = new KeyTable();
    table.setPrecision(3);
    KeyItem item = new KeyItem();
    item.setValue(new BigDecimal(2));
    item.setKeyTable(table);
    assertTrue(item.getValue().equals(new BigDecimal(2)));
    // when, then
    assertEquals(item.validateChangeValue(BigDecimal.valueOf(-0.001)), "Value cannot be less than zero");
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) BigDecimal(java.math.BigDecimal) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 13 with KeyTable

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

the class KeyItem_Test method testChangeValue.

@Test
public void testChangeValue() {
    // given
    KeyTable table = new KeyTable();
    table.setPrecision(3);
    KeyItem item = new KeyItem();
    item.setValue(new BigDecimal(2));
    item.setKeyTable(table);
    assertTrue(item.getValue().equals(new BigDecimal(2)));
    // when
    item.changeValue(BigDecimal.valueOf(2.3335));
    // then
    assertEquals(item.getValue(), BigDecimal.valueOf(2.334).setScale(3, BigDecimal.ROUND_HALF_UP));
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) BigDecimal(java.math.BigDecimal) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 14 with KeyTable

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

the class BudgetImportExport method findOrCreatePartitionItem.

private PartitionItem findOrCreatePartitionItem(final BudgetItem budgetItem) {
    Charge targetCharge = fetchCharge(getOutgoingChargeReference());
    KeyTable keyTable = findOrCreateKeyTable(budgetItem.getBudget(), getKeyTableName(), getFoundationValueType(), getKeyValueMethod());
    return budgetItem.updateOrCreatePartitionItem(targetCharge, keyTable, getPercentage());
}
Also used : Charge(org.estatio.module.charge.dom.Charge) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable)

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