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