use of org.estatio.module.budget.dom.keyitem.KeyItem in project estatio by estatio.
the class KeyValueMethod_Test method testIsValid.
@Test
public void testIsValid() {
// given
KeyValueMethod method = KeyValueMethod.PROMILLE;
KeyTable keyTable = new KeyTable();
SortedSet<KeyItem> budgetKeyItems = new TreeSet<>();
for (int i = 0; i < 1; i = i + 1) {
KeyItem budgetKeyItem = new KeyItem();
budgetKeyItem.setValue(BigDecimal.valueOf(999.9999));
budgetKeyItems.add(budgetKeyItem);
}
keyTable.setItems(budgetKeyItems);
keyTable.setPrecision(3);
// then
assertThat(method.keySum(keyTable)).isEqualTo(new BigDecimal(1000).setScale(3, BigDecimal.ROUND_HALF_UP));
assertThat(method.isValid(keyTable)).isTrue();
}
use of org.estatio.module.budget.dom.keyitem.KeyItem in project estatio by estatio.
the class KeyItemImportExportManager method importBlob.
// endregion
// region > import (action)
@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(named = "Import", cssClassFa = "fa-upload")
@MemberOrder(name = "keyItems", sequence = "2")
public List<KeyItemImportExportLineItem> importBlob(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet) {
WorksheetSpec spec = new WorksheetSpec(KeyItemImportExportLineItem.class, "keyItems");
List<KeyItemImportExportLineItem> lineItems = excelService.fromExcel(spreadsheet, spec);
container.informUser(lineItems.size() + " items imported");
List<KeyItemImportExportLineItem> newItems = new ArrayList<>();
for (KeyItemImportExportLineItem item : lineItems) {
item.validate();
newItems.add(new KeyItemImportExportLineItem(item));
}
for (KeyItem keyItem : keyTable.getItems()) {
Boolean keyItemFound = false;
for (KeyItemImportExportLineItem lineItem : newItems) {
if (lineItem.getUnitReference().equals(keyItem.getUnit().getReference())) {
keyItemFound = true;
break;
}
}
if (!keyItemFound) {
KeyItemImportExportLineItem deletedItem = new KeyItemImportExportLineItem(keyItem);
deletedItem.setStatus(Status.DELETED);
newItems.add(deletedItem);
}
}
return newItems;
}
Aggregations