Search in sources :

Example 16 with IncomingInvoice

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;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice)

Example 17 with 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();
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 18 with IncomingInvoice

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);
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Test(org.junit.Test)

Example 19 with IncomingInvoice

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);
}
Also used : Party(org.estatio.module.party.dom.Party) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) BankAccount(org.estatio.module.financial.dom.BankAccount) LocalDate(org.joda.time.LocalDate) InvoiceStatus(org.estatio.module.invoice.dom.InvoiceStatus) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 20 with IncomingInvoice

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;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch) PaymentLine(org.estatio.module.capex.dom.payment.PaymentLine)

Aggregations

IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)57 Test (org.junit.Test)27 Expectations (org.jmock.Expectations)20 BankAccount (org.estatio.module.financial.dom.BankAccount)14 Action (org.apache.isis.applib.annotation.Action)11 BigDecimal (java.math.BigDecimal)9 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)9 Organisation (org.estatio.module.party.dom.Organisation)9 Party (org.estatio.module.party.dom.Party)9 IncomingInvoiceMenu (org.estatio.module.capex.app.IncomingInvoiceMenu)8 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)7 Document (org.incode.module.document.dom.impl.docs.Document)7 LocalDate (org.joda.time.LocalDate)7 ArrayList (java.util.ArrayList)5 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 Property (org.estatio.module.asset.dom.Property)3 UpcomingPaymentTotal (org.estatio.module.capex.app.invoice.UpcomingPaymentTotal)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)3 OrderItem (org.estatio.module.capex.dom.order.OrderItem)3