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