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