use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class IncomingInvoice method copyWithLinks.
private IncomingInvoiceItem copyWithLinks(final IncomingInvoiceItem itemToReverse, final Sort sort) {
final IncomingInvoiceType type = itemToReverse.getIncomingInvoiceType();
final String description = itemToReverse.getDescription();
final Charge charge = itemToReverse.getCharge();
final BigDecimal netAmount = itemToReverse.getNetAmount();
final BigDecimal vatAmount = itemToReverse.getVatAmount();
final BigDecimal grossAmount = itemToReverse.getGrossAmount();
final Tax tax = itemToReverse.getTax();
final LocalDate dueDate = itemToReverse.getDueDate();
final String period = itemToReverse.getPeriod();
final FixedAsset fixedAsset = itemToReverse.getFixedAsset();
final Project project = itemToReverse.getProject();
final BudgetItem budgetItem = itemToReverse.getBudgetItem();
final IncomingInvoiceItem copyItem = addItemToThis(type, charge, sort.prefixTo(description), sort.adjust(netAmount), sort.adjust(vatAmount), sort.adjust(grossAmount), tax, dueDate, period, fixedAsset, project, budgetItem);
if (sort == Sort.REVERSAL) {
copyItem.setReversalOf(itemToReverse);
}
final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(itemToReverse);
linkIfAny.ifPresent(link -> {
orderItemInvoiceItemLinkRepository.createLink(link.getOrderItem(), copyItem, sort.adjust(link.getNetAmount()));
});
return copyItem;
}
use of org.estatio.module.budget.dom.budgetitem.BudgetItem in project estatio by estatio.
the class BudgetItemChooser method choicesBudgetItemFor.
@Programmatic
public List<BudgetItem> choicesBudgetItemFor(final Property property, final Charge charge) {
List<BudgetItem> result = Lists.newArrayList();
boolean hasProperty = property != null;
boolean hasCharge = charge != null;
if (hasProperty) {
for (BudgetItem budgetItem : budgetItemRepository.findByProperty(property)) {
if (hasCharge && charge == budgetItem.getCharge()) {
result.add(budgetItem);
} else {
result.add(budgetItem);
}
}
} else {
if (hasCharge) {
result = budgetItemRepository.allBudgetItems().stream().filter(x -> Objects.equals(x.getCharge(), charge)).collect(Collectors.toList());
} else {
result = budgetItemRepository.allBudgetItems();
}
}
return result;
}
Aggregations