use of org.estatio.module.budget.dom.DistributionService in project estatio by estatio.
the class KeyTable method generateItems.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
public KeyTable generateItems() {
// delete old items
for (Iterator<KeyItem> it = this.getItems().iterator(); it.hasNext(); ) {
it.next().deleteBudgetKeyItem();
}
/*
create list of input pairs: identifier - sourcevalue
sourcevalue is determined by FoundationValueType
*/
List<Distributable> input = new ArrayList<>();
for (Unit unit : unitRepository.findByProperty(this.getBudget().getProperty())) {
if (unitIntervalValidForThisKeyTable(unit)) {
BigDecimal sourceValue;
if (getFoundationValueType().valueOf(unit) != null) {
sourceValue = getFoundationValueType().valueOf(unit);
} else {
sourceValue = BigDecimal.ZERO;
}
KeyItem newItem = new KeyItem();
newItem.setSourceValue(sourceValue);
newItem.setValue(BigDecimal.ZERO);
newItem.setUnit(unit);
newItem.setKeyTable(this);
persistIfNotAlready(newItem);
input.add(newItem);
}
}
/*
call distribute method
*/
DistributionService distributionService = new DistributionService();
distributionService.distribute(input, getKeyValueMethod().divider(this), getPrecision());
return this;
}
use of org.estatio.module.budget.dom.DistributionService in project estatio by estatio.
the class KeyTable method distributeSourceValues.
// //////////////////////////////////////
@MemberOrder(name = "items", sequence = "4")
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
public KeyTable distributeSourceValues() {
DistributionService distributionService = new DistributionService();
distributionService.distribute(new ArrayList(getItems()), getKeyValueMethod().divider(this), getPrecision());
return this;
}
Aggregations