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);
}
Aggregations