use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class ProjectItem_InvoicedAmount_Test method newIncomingInvoice.
private IncomingInvoice newIncomingInvoice() {
final IncomingInvoice incomingInvoice = new IncomingInvoice() {
@Override
protected EventBusService getEventBusService() {
return mockEventBusService;
}
};
context.ignoring(mockEventBusService);
return incomingInvoice;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice 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.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceRepository_IntegTest method findByInvoiceNumberAndSellerAndInvoiceDate_works.
@Test
public void findByInvoiceNumberAndSellerAndInvoiceDate_works() throws Exception {
// given
IncomingInvoice invoice = createIncomingInvoice();
// when
IncomingInvoice invoiceFound = incomingInvoiceRepository.findByInvoiceNumberAndSellerAndInvoiceDate(invoiceNumber, seller, invoiceDate);
// then
assertThat(invoiceFound).isEqualTo(invoice);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceRepository_IntegTest method upsert_works.
@Test
public void upsert_works() throws Exception {
// given
IncomingInvoice existingInvoice = createIncomingInvoice();
IncomingInvoice invoice = incomingInvoiceRepository.findByInvoiceNumberAndSellerAndInvoiceDate(invoiceNumber, seller, invoiceDate);
assertThat(invoice.getInvoiceNumber()).isEqualTo(invoiceNumber);
assertThat(invoice.getAtPath()).isEqualTo(atPath);
assertThat(invoice.getBuyer()).isEqualTo(buyer);
assertThat(invoice.getDueDate()).isEqualTo(dueDate);
assertThat(invoice.getPaymentMethod()).isEqualTo(paymentMethod);
assertThat(invoice.getStatus()).isEqualTo(invoiceStatus);
assertThat(invoice.getDateReceived()).isNull();
assertThat(invoice.getBankAccount()).isNull();
// when
String updatedAtPath = "/NLD";
Party updatedBuyer = Organisation_enum.HelloWorldNl.findUsing(serviceRegistry);
LocalDate updatedDueDate = dueDate.minusWeeks(1);
PaymentMethod updatedPaymentMethod = PaymentMethod.DIRECT_DEBIT;
InvoiceStatus updatedStatus = InvoiceStatus.INVOICED;
LocalDate updatedDateReceived = new LocalDate(2017, 1, 2);
BankAccount updatedBankAccount = bankAccountRepository.allBankAccounts().get(0);
Property property = existingInvoice.getProperty();
IncomingInvoice updatedInvoice = incomingInvoiceRepository.upsert(IncomingInvoiceType.CAPEX, invoiceNumber, property, updatedAtPath, updatedBuyer, seller, invoiceDate, updatedDueDate, updatedPaymentMethod, updatedStatus, updatedDateReceived, updatedBankAccount, null);
// then
assertThat(updatedInvoice.getInvoiceNumber()).isEqualTo(invoiceNumber);
assertThat(updatedInvoice.getSeller()).isEqualTo(seller);
assertThat(updatedInvoice.getInvoiceDate()).isEqualTo(invoiceDate);
assertThat(updatedInvoice.getAtPath()).isEqualTo(updatedAtPath);
assertThat(updatedInvoice.getBuyer()).isEqualTo(updatedBuyer);
assertThat(updatedInvoice.getDueDate()).isEqualTo(updatedDueDate);
assertThat(updatedInvoice.getPaymentMethod()).isEqualTo(updatedPaymentMethod);
assertThat(updatedInvoice.getStatus()).isEqualTo(updatedStatus);
assertThat(updatedInvoice.getDateReceived()).isEqualTo(updatedDateReceived);
assertThat(updatedInvoice.getBankAccount()).isEqualTo(updatedBankAccount);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class EstatioAppHomePage method findIncomingInvoicesWithin.
private List<IncomingInvoice> findIncomingInvoicesWithin(final List<PaymentBatch> batches) {
final List<IncomingInvoice> invoices = Lists.newArrayList();
for (PaymentBatch completedBatch : batches) {
invoices.addAll(Lists.newArrayList(completedBatch.getLines()).stream().map(PaymentLine::getInvoice).collect(Collectors.toList()));
}
invoices.sort(Ordering.natural().nullsLast().onResultOf(IncomingInvoice::getInvoiceDate));
return invoices;
}
Aggregations