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");
}
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");
}
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));
}
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());
}
Aggregations