use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceMenu_Test method filterOrFindByGrossAmount_negative_amounts_filter_works.
@Test
public void filterOrFindByGrossAmount_negative_amounts_filter_works() {
IncomingInvoiceMenu.IncomingInvoiceFinder builder;
// given
builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
IncomingInvoice invoice1 = new IncomingInvoice();
invoice1.setGrossAmount(new BigDecimal("-9.50"));
IncomingInvoice invoice2 = new IncomingInvoice();
invoice2.setGrossAmount(new BigDecimal("-9.49"));
builder.setResult(Arrays.asList(invoice1, invoice2));
final BigDecimal amountSearchedFor = new BigDecimal("-10.00");
Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
// when
builder.filterOrFindByGrossAmount(amountSearchedFor);
// then
Assertions.assertThat(builder.getResult().size()).isEqualTo(1);
Assertions.assertThat(builder.getResult()).contains(invoice1);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceMenu_Test method filterOrFindBySeller_filter_works.
@Test
public void filterOrFindBySeller_filter_works() {
IncomingInvoiceMenu.IncomingInvoiceFinder builder;
// given
builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
IncomingInvoice invoice1 = new IncomingInvoice();
Person personToBeFiltered = new Person();
Organisation seller = new Organisation();
invoice1.setSeller(seller);
IncomingInvoice invoice2 = new IncomingInvoice();
builder.setResult(Arrays.asList(invoice1, invoice2));
Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
// expect
context.checking(new Expectations() {
{
oneOf(mockPartyRepository).findParties("*abc*");
will(returnValue(Arrays.asList(seller, personToBeFiltered)));
}
});
// when
builder.filterOrFindBySeller("abc");
// then
Assertions.assertThat(builder.getResult().size()).isEqualTo(1);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class PaymentBatch_Test method newInvoice.
IncomingInvoice newInvoice(final LocalDate invoiceDate, final Party seller, final BankAccount sellerBankAccount, final String currencyRef, final String grossAmount, final String invoiceNumber) {
final IncomingInvoice invoice = new IncomingInvoice();
invoice.setInvoiceDate(invoiceDate);
invoice.setSeller(seller);
invoice.setBankAccount(sellerBankAccount);
invoice.setGrossAmount(new BigDecimal(grossAmount));
invoice.setInvoiceNumber(invoiceNumber);
final Currency currency = new Currency();
currency.setReference(currencyRef);
invoice.setCurrency(currency);
return invoice;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class PaymentBatch_Test method aggregates_transfers_ok.
@Test
public void aggregates_transfers_ok() throws Exception {
// given
final IncomingInvoice invoice1 = newInvoice(new LocalDate(2017, 7, 7), seller1, seller1BankAccount, "EUR", "361754.46", "AF3T2017");
final IncomingInvoice invoice2 = newInvoice(new LocalDate(2017, 6, 30), seller2, seller2BankAccount, "EUR", "15251.76", "DGD 11420 - 170522");
final IncomingInvoice invoice3 = newInvoice(new LocalDate(2017, 6, 5), seller1, seller1BankAccount, "EUR", "-172805.79", "REDD2016VT");
// sequence = 1
paymentBatch.addLineIfRequired(invoice1);
// sequence = 2
paymentBatch.addLineIfRequired(invoice2);
// sequence = 3
paymentBatch.addLineIfRequired(invoice3);
// then
List<CreditTransfer> transfers = paymentBatch.getTransfers();
assertThat(transfers).hasSize(2);
final CreditTransfer transfer1 = transfers.get(0);
final CreditTransfer transfer2 = transfers.get(1);
assertThat(transfer1.getBatch()).isEqualTo(paymentBatch);
assertThat(transfer1.getSellerName()).isEqualTo(seller1.getName());
assertThat(transfer1.getAmount()).isEqualTo(invoice1.getGrossAmount().add(invoice3.getGrossAmount()));
// the "1-3" suffix indicates payment lines with sequence 1 and 3 together
assertThat(transfer1.getEndToEndId()).isEqualTo("97834-1-3");
assertThat(transfer1.getRemittanceInformation()).isEqualTo("AF3T2017;REDD2016VT");
assertThat(transfer1.getSellerBankAccount()).isEqualTo(seller1BankAccount);
assertThat(transfer1.getSellerBic()).isEqualTo(seller1BankAccount.getBic());
assertThat(transfer1.getSellerIban()).isEqualTo(seller1BankAccount.getIban());
assertThat(transfer1.getSellerPostalAddressCountry()).isEqualTo("FR");
assertThat(transfer2.getBatch()).isEqualTo(paymentBatch);
assertThat(transfer2.getSellerName()).isEqualTo(seller2.getName());
assertThat(transfer2.getAmount()).isEqualTo(invoice2.getGrossAmount());
assertThat(transfer2.getEndToEndId()).isEqualTo("97834-2");
assertThat(transfer2.getRemittanceInformation()).isEqualTo("DGD 11420 - 170522");
assertThat(transfer2.getSellerBankAccount()).isEqualTo(seller2BankAccount);
assertThat(transfer2.getSellerBic()).isEqualTo(seller2BankAccount.getBic());
assertThat(transfer2.getSellerIban()).isEqualTo(seller2BankAccount.getIban());
assertThat(transfer2.getSellerPostalAddressCountry()).isEqualTo("FR");
// and also
final CreditTransferTransactionInformation10 cdtTrf1 = transfer1.asXml();
assertThat(cdtTrf1.getCdtr().getNm()).isEqualTo(transfer1.getSellerName());
assertThat(cdtTrf1.getAmt().getInstdAmt().getValue()).isEqualTo(transfer1.getAmount());
assertThat(cdtTrf1.getAmt().getInstdAmt().getCcy()).isEqualTo("EUR");
assertThat(cdtTrf1.getPmtId().getEndToEndId()).isEqualTo(transfer1.getEndToEndId());
assertThat(cdtTrf1.getRmtInf().getUstrds().get(0)).isEqualTo(transfer1.getRemittanceInformation());
assertThat(cdtTrf1.getCdtrAgt().getFinInstnId().getBIC()).isEqualTo(transfer1.getSellerBic());
assertThat(cdtTrf1.getCdtrAcct().getId().getIBAN()).isEqualTo(transfer1.getSellerIban());
assertThat(cdtTrf1.getCdtr().getPstlAdr().getCtry()).isEqualTo(transfer1.getSellerPostalAddressCountry());
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class PaymentLine_Test method getUpstreamCreditNoteFound_works.
@Test
public void getUpstreamCreditNoteFound_works() throws Exception {
// given
PaymentLine paymentLine = new PaymentLine();
paymentLine.incomingInvoiceRepository = mockIncomingInvoiceRepository;
BankAccount creditorBankAccount = new BankAccount();
paymentLine.setCreditorBankAccount(creditorBankAccount);
IncomingInvoice invoice = new IncomingInvoice();
// expect
context.checking(new Expectations() {
{
allowing(mockIncomingInvoiceRepository).findByBankAccount(creditorBankAccount);
will(returnValue(Arrays.asList(invoice)));
}
});
// when
invoice.setApprovalState(IncomingInvoiceApprovalState.COMPLETED);
invoice.setNetAmount(new BigDecimal("-0.01"));
// then
Assertions.assertThat(paymentLine.getUpstreamCreditNoteFound()).isTrue();
// when approval state gets checked
invoice.setApprovalState(IncomingInvoiceApprovalState.NEW);
invoice.setNetAmount(new BigDecimal("-0.01"));
// then
Assertions.assertThat(paymentLine.getUpstreamCreditNoteFound()).isFalse();
// when approval state is null
invoice.setApprovalState(null);
invoice.setNetAmount(new BigDecimal("-0.01"));
// then
Assertions.assertThat(paymentLine.getUpstreamCreditNoteFound()).isFalse();
// and when net amount gets checked
invoice.setApprovalState(IncomingInvoiceApprovalState.COMPLETED);
invoice.setNetAmount(new BigDecimal("0.01"));
// then
Assertions.assertThat(paymentLine.getUpstreamCreditNoteFound()).isFalse();
// and when net amount is null
invoice.setApprovalState(IncomingInvoiceApprovalState.COMPLETED);
invoice.setNetAmount(null);
// then
Assertions.assertThat(paymentLine.getUpstreamCreditNoteFound()).isFalse();
}
Aggregations