Search in sources :

Example 21 with BudgetItem

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;
}
Also used : Project(org.estatio.module.capex.dom.project.Project) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) FixedAsset(org.estatio.module.asset.dom.FixedAsset) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal)

Example 22 with BudgetItem

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;
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)22 Property (org.estatio.module.asset.dom.Property)11 Charge (org.estatio.module.charge.dom.Charge)9 LocalDate (org.joda.time.LocalDate)9 Test (org.junit.Test)9 BigDecimal (java.math.BigDecimal)8 Budget (org.estatio.module.budget.dom.budget.Budget)8 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)5 Project (org.estatio.module.capex.dom.project.Project)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 Tax (org.estatio.module.tax.dom.Tax)4 ArrayList (java.util.ArrayList)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 ApplicationException (org.apache.isis.applib.ApplicationException)2 Action (org.apache.isis.applib.annotation.Action)2 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 Partitioning (org.estatio.module.budget.dom.partioning.Partitioning)2 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)2 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)2 Organisation (org.estatio.module.party.dom.Organisation)2