Search in sources :

Example 6 with OrderItemInvoiceItemLink

use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink in project estatio by estatio.

the class OrderItem_Test method setupOrderItemInvoiceItemLinkRepository.

private OrderItemInvoiceItemLinkRepository setupOrderItemInvoiceItemLinkRepository(final IncomingInvoiceItem item1, final IncomingInvoiceItem item2) {
    OrderItemInvoiceItemLink link1 = new OrderItemInvoiceItemLink();
    OrderItemInvoiceItemLink link2 = new OrderItemInvoiceItemLink();
    link1.setInvoiceItem(item1);
    link1.setNetAmount(item1.getNetAmount());
    link2.setInvoiceItem(item2);
    link2.setNetAmount(item2.getNetAmount());
    OrderItemInvoiceItemLinkRepository orderItemInvoiceItemLinkRepository = new OrderItemInvoiceItemLinkRepository() {

        @Override
        public List<OrderItemInvoiceItemLink> findByOrderItem(final OrderItem orderItem) {
            return Arrays.asList(link1, link2);
        }
    };
    return orderItemInvoiceItemLinkRepository;
}
Also used : OrderItemInvoiceItemLinkRepository(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLinkRepository) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink)

Example 7 with OrderItemInvoiceItemLink

use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink in project estatio by estatio.

the class IncomingDocAsInvoiceViewModel method init.

@Programmatic
public void init() {
    IncomingInvoice incomingInvoice = getDomainObject();
    setIncomingInvoiceType(incomingInvoice.getType());
    setInvoiceNumber(incomingInvoice.getInvoiceNumber());
    setBuyer(incomingInvoice.getBuyer());
    setSeller(incomingInvoice.getSeller());
    setInvoiceDate(incomingInvoice.getInvoiceDate());
    setDueDate(incomingInvoice.getDueDate());
    setPaymentMethod(incomingInvoice.getPaymentMethod());
    setDateReceived(incomingInvoice.getDateReceived());
    setBankAccount(incomingInvoice.getBankAccount());
    setCurrency(incomingInvoice.getCurrency());
    final Optional<IncomingInvoiceItem> firstItemIfAny = getFirstItemIfAny();
    if (firstItemIfAny.isPresent()) {
        IncomingInvoiceItem invoiceItem = firstItemIfAny.get();
        setCharge(invoiceItem.getCharge());
        setDescription(invoiceItem.getDescription());
        setNetAmount(invoiceItem.getNetAmount());
        setVatAmount(invoiceItem.getVatAmount());
        setGrossAmount(invoiceItem.getGrossAmount());
        setTax(invoiceItem.getTax());
        setDueDate(invoiceItem.getDueDate());
        setPeriod(periodFrom(invoiceItem.getStartDate(), invoiceItem.getEndDate()));
        setProperty((org.estatio.module.asset.dom.Property) invoiceItem.getFixedAsset());
        setProject(invoiceItem.getProject());
        setBudgetItem(invoiceItem.getBudgetItem());
        final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(invoiceItem);
        linkIfAny.ifPresent(link -> {
            final OrderItem linkOrderItem = link.getOrderItem();
            IncomingDocAsInvoiceViewModel.this.setOrderItem(linkOrderItem);
        });
    } else {
        // for the first time we edit there will be no first item,
        // so we instead get the property from the header invoice
        setProperty(incomingInvoice.getProperty());
    }
}
Also used : OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) OrderItem(org.estatio.module.capex.dom.order.OrderItem) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 8 with OrderItemInvoiceItemLink

use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink in project estatio by estatio.

the class ProjectService method moveIncomingInvoiceItemToProject.

public void moveIncomingInvoiceItemToProject(final IncomingInvoiceItem incomingInvoiceItem, final Project project) {
    Optional linkToOrderItemIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(incomingInvoiceItem);
    if (linkToOrderItemIfAny.isPresent()) {
        OrderItemInvoiceItemLink link = (OrderItemInvoiceItemLink) linkToOrderItemIfAny.get();
        OrderItem linkedOrderItem = link.getOrderItem();
        for (OrderItemInvoiceItemLink itemLinked : orderItemInvoiceItemLinkRepository.findByOrderItem(linkedOrderItem)) {
            itemLinked.getInvoiceItem().setProjectByPassingInvalidateApproval(project);
        }
        linkedOrderItem.setProject(project);
    } else {
        incomingInvoiceItem.setProjectByPassingInvalidateApproval(project);
    }
}
Also used : Optional(java.util.Optional) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) OrderItem(org.estatio.module.capex.dom.order.OrderItem)

Example 9 with OrderItemInvoiceItemLink

use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink 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)

Aggregations

OrderItemInvoiceItemLink (org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink)9 OrderItem (org.estatio.module.capex.dom.order.OrderItem)6 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)5 Expectations (org.jmock.Expectations)3 Test (org.junit.Test)3 BigDecimal (java.math.BigDecimal)2 Action (org.apache.isis.applib.annotation.Action)2 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)2 Project (org.estatio.module.capex.dom.project.Project)2 Charge (org.estatio.module.charge.dom.Charge)2 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 FixedAsset (org.estatio.module.asset.dom.FixedAsset)1 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)1 IncomingInvoiceType (org.estatio.module.capex.dom.invoice.IncomingInvoiceType)1 Order (org.estatio.module.capex.dom.order.Order)1 OrderItemInvoiceItemLinkRepository (org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLinkRepository)1