Search in sources :

Example 1 with InvoiceStatus

use of org.estatio.module.invoice.dom.InvoiceStatus 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)

Aggregations

Property (org.estatio.module.asset.dom.Property)1 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 BankAccount (org.estatio.module.financial.dom.BankAccount)1 InvoiceStatus (org.estatio.module.invoice.dom.InvoiceStatus)1 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)1 Party (org.estatio.module.party.dom.Party)1 LocalDate (org.joda.time.LocalDate)1 Test (org.junit.Test)1