use of org.estatio.module.financial.dom.BankAccount 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();
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_one_preferred.
@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_one_preferred() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
BankAccount bankAccount = new BankAccount();
BankAccount preferredBankAccount = new BankAccount();
preferredBankAccount.setPreferred(true);
List<BankAccount> bankAccounts = new ArrayList<>();
bankAccounts.add(bankAccount);
bankAccounts.add(preferredBankAccount);
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)).isEqualTo(preferredBankAccount);
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_none_preferred.
@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_none_preferred() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
BankAccount bankAccount1 = new BankAccount();
BankAccount bankAccount2 = new BankAccount();
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();
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class PaymentBatch_Test method newBankAccount.
BankAccount newBankAccount(final String iban, final String bic, final Party owner) {
BankAccount bankAccount = new BankAccount();
bankAccount.setIban(iban);
bankAccount.setBic(bic);
bankAccount.setOwner(owner);
return bankAccount;
}
use of org.estatio.module.financial.dom.BankAccount 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