Search in sources :

Example 1 with ProjectItem_InvoicedAmount

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

the class ProjectItem_InvoicedAmount_Test method invoicedAmount_works.

@Test
public void invoicedAmount_works() throws Exception {
    // given
    BigDecimal expectedTotalInvoicedNetAmountOnItems = new BigDecimal("100.00");
    BigDecimal netAmountOnItem1 = new BigDecimal("55.00");
    BigDecimal netAmountOnItem2 = new BigDecimal("45.00");
    BigDecimal netAmountOnItem3_discarded = new BigDecimal("12345.67");
    ProjectItem projectItem = new ProjectItem();
    ProjectItem_InvoicedAmount mixin = new ProjectItem_InvoicedAmount(projectItem);
    mixin.incomingInvoiceItemRepository = mockIncomingInvoiceItemRepository;
    IncomingInvoiceItem item1 = new IncomingInvoiceItem();
    item1.setInvoice(newIncomingInvoice());
    item1.setNetAmount(netAmountOnItem1);
    IncomingInvoiceItem item2 = new IncomingInvoiceItem();
    item2.setInvoice(newIncomingInvoice());
    item2.setNetAmount(netAmountOnItem2);
    IncomingInvoiceItem item3_discarded = new IncomingInvoiceItem() {

        @Override
        public boolean isDiscarded() {
            return true;
        }
    };
    item3_discarded.setInvoice(newIncomingInvoice());
    item3_discarded.setNetAmount(netAmountOnItem3_discarded);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockIncomingInvoiceItemRepository).findByProjectAndCharge(null, null);
            will(returnValue(Arrays.asList(item1, item2, item3_discarded)));
        }
    });
    // when
    BigDecimal orderedAmount = mixin.invoicedAmount();
    // then
    Assertions.assertThat(orderedAmount).isEqualTo(expectedTotalInvoicedNetAmountOnItems);
}
Also used : Expectations(org.jmock.Expectations) ProjectItem_InvoicedAmount(org.estatio.module.capex.dom.invoice.contributions.ProjectItem_InvoicedAmount) ProjectItem(org.estatio.module.capex.dom.project.ProjectItem) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)1 ProjectItem_InvoicedAmount (org.estatio.module.capex.dom.invoice.contributions.ProjectItem_InvoicedAmount)1 ProjectItem (org.estatio.module.capex.dom.project.ProjectItem)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1