use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class CreditTransferExportService_Test method isFirstUseBankAccount_works_when_just_invoices_in_transfer_found.
@Test
public void isFirstUseBankAccount_works_when_just_invoices_in_transfer_found() throws Exception {
// given
CreditTransferExportService service = new CreditTransferExportService();
service.incomingInvoiceRepository = mockIncomingInvoiceRepository;
CreditTransfer transfer = new CreditTransfer();
// when
IncomingInvoice invoiceInPaymentLine1 = new IncomingInvoice();
IncomingInvoice invoiceInPaymentLine2 = new IncomingInvoice();
PaymentLine line1 = new PaymentLine();
line1.setInvoice(invoiceInPaymentLine1);
PaymentLine line2 = new PaymentLine();
line2.setInvoice(invoiceInPaymentLine2);
transfer.setLines(Arrays.asList(line1, line2));
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceRepository).findByBankAccount(transfer.getSellerBankAccount());
// when ..
will(returnValue(Arrays.asList(invoiceInPaymentLine1, invoiceInPaymentLine2)));
}
});
// then
Assertions.assertThat(service.isFirstUseBankAccount(transfer)).isTrue();
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class CreditTransferExportService_Test method isFirstUseBankAccount_works_when_other_invoices_than_in_transfer_found.
@Test
public void isFirstUseBankAccount_works_when_other_invoices_than_in_transfer_found() throws Exception {
// given
CreditTransferExportService service = new CreditTransferExportService();
service.incomingInvoiceRepository = mockIncomingInvoiceRepository;
CreditTransfer transfer = new CreditTransfer();
// when
IncomingInvoice invoiceInPaymentLine1 = new IncomingInvoice();
IncomingInvoice invoiceInPaymentLine2 = new IncomingInvoice();
PaymentLine line1 = new PaymentLine();
line1.setInvoice(invoiceInPaymentLine1);
PaymentLine line2 = new PaymentLine();
line2.setInvoice(invoiceInPaymentLine2);
transfer.setLines(Arrays.asList(line1, line2));
IncomingInvoice otherInvoice = new IncomingInvoice();
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceRepository).findByBankAccount(transfer.getSellerBankAccount());
// when ..
will(returnValue(Arrays.asList(invoiceInPaymentLine1, invoiceInPaymentLine2, otherInvoice)));
}
});
// then
Assertions.assertThat(service.isFirstUseBankAccount(transfer)).isFalse();
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class BuyerFinder_Test method testerWhenNullOrTooShort.
private void testerWhenNullOrTooShort(final String documentName) {
// given
IncomingInvoice invoice = new IncomingInvoice();
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
// expect
context.checking(new Expectations() {
{
oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
will(returnValue(optional));
}
});
// when
finder.buyerDerivedFromDocumentName(invoice);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class BuyerFinder_Test method testWhenParamIsInvoice.
private void testWhenParamIsInvoice(final String documentName, final String derivedPartyReference) {
// given
IncomingInvoice invoice = new IncomingInvoice();
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
// expect
context.checking(new Expectations() {
{
oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
will(returnValue(optional));
oneOf(mockPartyRepository).findPartyByReference(derivedPartyReference);
}
});
// when
finder.buyerDerivedFromDocumentName(invoice);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_multiple_preferred.
@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_multiple_preferred() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
BankAccount bankAccount1 = new BankAccount();
bankAccount1.setPreferred(true);
BankAccount bankAccount2 = new BankAccount();
bankAccount2.setPreferred(true);
List<BankAccount> bankAccounts = new ArrayList<>();
bankAccounts.add(bankAccount1);
bankAccounts.add(bankAccount2);
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
will(returnValue(bankAccounts));
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
Aggregations