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_no_bankaccount_and_property.
@Test
public void unique_Debtor_Account_To_Pay_works_when_no_bankaccount_and_property() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
service.fixedAssetFinancialAccountRepository = mockFixedAssetFinancialAccountRepository;
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
Property property = new Property();
invoice.setProperty(property);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
oneOf(mockFixedAssetFinancialAccountRepository).findByFixedAsset(property);
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
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_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.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_no_bankaccount_and_no_property.
@Test
public void unique_Debtor_Account_To_Pay_works_when_no_bankaccount_and_no_property() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
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_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.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceMenu_Test method filterOrFindByDocumentName_filter_works.
@Test
public void filterOrFindByDocumentName_filter_works() {
IncomingInvoiceMenu.IncomingInvoiceFinder builder;
// given
builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
IncomingInvoice invoice1 = new IncomingInvoice();
IncomingInvoice invoice2 = new IncomingInvoice();
builder.setResult(Arrays.asList(invoice1, invoice2));
Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceRepository).findIncomingInvoiceByDocumentName("123");
will(returnValue(Arrays.asList(invoice1)));
}
});
// when
builder.filterOrFindByDocumentName("123");
// then
Assertions.assertThat(builder.getResult().size()).isEqualTo(1);
}
Aggregations