use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.
the class ProjectInvoiceItemTransferManager_Test method getInvoiceItemsHavingNoOrder_works.
@Test
public void getInvoiceItemsHavingNoOrder_works() throws Exception {
// given
Project source = new Project();
ProjectInvoiceItemTransferManager manager = new ProjectInvoiceItemTransferManager(null, source);
manager.incomingInvoiceItemRepository = mockIncomingInvoiceItemRepository;
manager.orderItemInvoiceItemLinkRepository = mockOrderItemInvoiceItemLinkRepository;
IncomingInvoiceItem itemLinked = new IncomingInvoiceItem();
IncomingInvoiceItem itemNotLinked = new IncomingInvoiceItem();
OrderItemInvoiceItemLink link = new OrderItemInvoiceItemLink();
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceItemRepository).findByProject(source);
will(returnValue(Arrays.asList(itemLinked, itemNotLinked)));
oneOf(mockOrderItemInvoiceItemLinkRepository).findByInvoiceItem(itemLinked);
will(returnValue(Optional.of(link)));
oneOf(mockOrderItemInvoiceItemLinkRepository).findByInvoiceItem(itemNotLinked);
will(returnValue(Optional.empty()));
}
});
// when
List<IncomingInvoiceItem> items = manager.getInvoiceItemsHavingNoOrder();
// then
Assertions.assertThat(items).contains(itemNotLinked);
Assertions.assertThat(items).doesNotContain(itemLinked);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.
the class ProjectService_Test method moveIncomingInvoiceItemToProject_works_when_invoice_item_not_linked.
@Test
public void moveIncomingInvoiceItemToProject_works_when_invoice_item_not_linked() throws Exception {
// given
ProjectService projectService = new ProjectService();
projectService.orderItemInvoiceItemLinkRepository = mockOrderItemInvoiceItemLinkRepository;
IncomingInvoiceItem incomingInvoiceItem = new IncomingInvoiceItem();
Project project = new Project();
// expect
context.checking(new Expectations() {
{
oneOf(mockOrderItemInvoiceItemLinkRepository).findByInvoiceItem(incomingInvoiceItem);
will(returnValue(Optional.empty()));
}
});
// when
projectService.moveIncomingInvoiceItemToProject(incomingInvoiceItem, project);
// then
Assertions.assertThat(incomingInvoiceItem.getProject()).isEqualTo(project);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem 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);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.
the class OrderItem_Test method isInvoiced_works.
@Test
public void isInvoiced_works() 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 OrderItem_Test method newIncomingInvoiceItem.
private IncomingInvoiceItem newIncomingInvoiceItem() {
final IncomingInvoiceItem incomingInvoiceItem = new IncomingInvoiceItem();
final IncomingInvoice incomingInvoice = new IncomingInvoice() {
@Override
protected EventBusService getEventBusService() {
return mockEventBusService;
}
};
context.ignoring(mockEventBusService);
incomingInvoiceItem.setInvoice(incomingInvoice);
return incomingInvoiceItem;
}
Aggregations