Search in sources :

Example 6 with IncomingInvoiceItem

use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.

the class OrderItem_Test method isInvoiced_works_when_no_netamount_on_invoiceItem.

@Test
public void isInvoiced_works_when_no_netamount_on_invoiceItem() throws Exception {
    // given
    OrderItem orderItem = new OrderItem();
    orderItem.setNetAmount(new BigDecimal("100.00"));
    IncomingInvoiceItem item1 = newIncomingInvoiceItem();
    IncomingInvoiceItem item2 = newIncomingInvoiceItem();
    // when
    // explicit for this test
    item1.setNetAmount(null);
    item2.setNetAmount(new BigDecimal("50.00"));
    orderItem.orderItemInvoiceItemLinkRepository = setupOrderItemInvoiceItemLinkRepository(item1, item2);
    // then
    assertThat(orderItem.isInvoiced()).isFalse();
}
Also used : IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 7 with IncomingInvoiceItem

use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.

the class OrderItem_Test method isInvoiced_works_with_discarded_invoice.

@Test
public void isInvoiced_works_with_discarded_invoice() throws Exception {
    // given
    OrderItem orderItem = new OrderItem();
    orderItem.setNetAmount(new BigDecimal("100.00"));
    IncomingInvoice discardedInvoice = new IncomingInvoice();
    discardedInvoice.setApprovalState(IncomingInvoiceApprovalState.DISCARDED);
    IncomingInvoiceItem item1 = newIncomingInvoiceItem();
    item1.setInvoice(discardedInvoice);
    IncomingInvoice invoice = new IncomingInvoice();
    IncomingInvoiceItem item2 = newIncomingInvoiceItem();
    item2.setInvoice(invoice);
    // when
    // should be discarded
    item1.setNetAmount(new BigDecimal("45.00"));
    item2.setNetAmount(new BigDecimal("55.00"));
    orderItem.orderItemInvoiceItemLinkRepository = setupOrderItemInvoiceItemLinkRepository(item1, item2);
    // then
    assertThat(orderItem.isInvoiced()).isFalse();
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 8 with IncomingInvoiceItem

use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.

the class OrderItem_Test method isInvoiced_works_with_negative_amounts.

@Test
public void isInvoiced_works_with_negative_amounts() throws Exception {
    // given
    OrderItem orderItem = new OrderItem();
    orderItem.setNetAmount(new BigDecimal("-100.00"));
    IncomingInvoiceItem item1 = newIncomingInvoiceItem();
    IncomingInvoiceItem item2 = newIncomingInvoiceItem();
    // when
    item1.setNetAmount(new BigDecimal("-50.00"));
    item2.setNetAmount(new BigDecimal("-49.99"));
    orderItem.orderItemInvoiceItemLinkRepository = setupOrderItemInvoiceItemLinkRepository(item1, item2);
    // then
    assertThat(orderItem.isInvoiced()).isFalse();
    // and when
    item1.setNetAmount(new BigDecimal("-50.00"));
    item2.setNetAmount(new BigDecimal("-50.00"));
    orderItem.orderItemInvoiceItemLinkRepository = setupOrderItemInvoiceItemLinkRepository(item1, item2);
    // then
    assertThat(orderItem.isInvoiced()).isTrue();
    // and when
    item1.setNetAmount(new BigDecimal("-50.00"));
    item2.setNetAmount(new BigDecimal("-50.01"));
    orderItem.orderItemInvoiceItemLinkRepository = setupOrderItemInvoiceItemLinkRepository(item1, item2);
    // then
    assertThat(orderItem.isInvoiced()).isTrue();
}
Also used : IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 9 with IncomingInvoiceItem

use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.

the class OrderItemInvoiceItemLinkRepository_Test method createLink.

private static OrderItemInvoiceItemLink createLink(final BigDecimal netAmount2) {
    OrderItemInvoiceItemLink link = new OrderItemInvoiceItemLink();
    link.setInvoiceItem(new IncomingInvoiceItem());
    link.setNetAmount(netAmount2);
    return link;
}
Also used : IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)

Example 10 with IncomingInvoiceItem

use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.

the class OrderItemInvoiceItemLinkRepository_Test method calculateNetAmountNotLinkedFromInvoiceItem_works_when_netAmount_is_null.

@Test
public void calculateNetAmountNotLinkedFromInvoiceItem_works_when_netAmount_is_null() {
    // given
    OrderItemInvoiceItemLinkRepository orderItemInvoiceItemLinkRepository = new OrderItemInvoiceItemLinkRepository() {

        @Override
        public BigDecimal calculateNetAmountLinkedFromInvoiceItem(final IncomingInvoiceItem invoiceItem) {
            return new BigDecimal("123.45");
        }
    };
    IncomingInvoiceItem invoiceItem = new IncomingInvoiceItem();
    // when
    invoiceItem.setNetAmount(null);
    // then
    assertThat(orderItemInvoiceItemLinkRepository.calculateNetAmountNotLinkedFromInvoiceItem(invoiceItem)).isEqualTo(BigDecimal.ZERO);
}
Also used : IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)25 Test (org.junit.Test)14 BigDecimal (java.math.BigDecimal)8 OrderItem (org.estatio.module.capex.dom.order.OrderItem)7 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)6 OrderItemInvoiceItemLink (org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink)5 Expectations (org.jmock.Expectations)5 Action (org.apache.isis.applib.annotation.Action)3 ArrayList (java.util.ArrayList)2 Project (org.estatio.module.capex.dom.project.Project)2 Charge (org.estatio.module.charge.dom.Charge)2 ToString (lombok.ToString)1 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 IncomingInvoiceType (org.estatio.module.capex.dom.invoice.IncomingInvoiceType)1 ProjectItem_InvoicedAmount (org.estatio.module.capex.dom.invoice.contributions.ProjectItem_InvoicedAmount)1 Order (org.estatio.module.capex.dom.order.Order)1 IncomingInvoiceItem_createOrderItemLink (org.estatio.module.capex.dom.orderinvoice.IncomingInvoiceItem_createOrderItemLink)1 ProjectItem (org.estatio.module.capex.dom.project.ProjectItem)1 Party (org.estatio.module.party.dom.Party)1