use of org.estatio.module.party.dom.Organisation in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method bankaccount_is_set_when_creating_seller.
@Test
public void bankaccount_is_set_when_creating_seller() {
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
viewModel.organisationRepository = mockOrganisationRepo;
viewModel.bankAccountRepository = mockBankAccountRepository;
Country country = new Country();
Organisation seller = new Organisation();
BankAccount bankAccount = new BankAccount();
String sellerName = "some name";
OrganisationNameNumberViewModel candidate = new OrganisationNameNumberViewModel(sellerName, null);
String iban = "NL02RABO0313246581";
// expect
context.checking(new Expectations() {
{
oneOf(mockOrganisationRepo).newOrganisation(null, true, sellerName, country);
will(returnValue(seller));
oneOf(mockBankAccountRepository).newBankAccount(seller, iban, null);
will(returnValue(bankAccount));
oneOf(mockBankAccountRepository).getFirstBankAccountOfPartyOrNull(seller);
will(returnValue(bankAccount));
}
});
// when
viewModel.createSeller(candidate, country, iban);
// then
Assertions.assertThat(viewModel.getSeller()).isEqualTo(seller);
Assertions.assertThat(viewModel.getBankAccount()).isEqualTo(bankAccount);
}
use of org.estatio.module.party.dom.Organisation in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method choices_orderItem_filters_discarded.
@Test
public void choices_orderItem_filters_discarded() {
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
viewModel.orderItemRepository = mockOrderItemRepo;
Organisation seller = new Organisation();
viewModel.setSeller(seller);
Order order = new Order();
order.setApprovalState(OrderApprovalState.DISCARDED);
OrderItem item = new OrderItem();
item.setOrdr(order);
// expect
context.checking(new Expectations() {
{
allowing(mockOrderItemRepo).findBySeller(seller);
will(returnValue(Arrays.asList(item)));
}
});
// when discarded
List<OrderItem> orderItemChoices = viewModel.choicesOrderItem();
// then
Assertions.assertThat(orderItemChoices).isEmpty();
// and when not discarded
order.setApprovalState(OrderApprovalState.APPROVED);
orderItemChoices = viewModel.choicesOrderItem();
// then
Assertions.assertThat(orderItemChoices).contains(item);
// and when order has no approval state
order.setApprovalState(null);
orderItemChoices = viewModel.choicesOrderItem();
// then
Assertions.assertThat(orderItemChoices).contains(item);
}
use of org.estatio.module.party.dom.Organisation in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_autoCompleteBankAccount_Test method autoCompleteBankAccount_works.
@Test
public void autoCompleteBankAccount_works() throws Exception {
List<BankAccount> result;
// given
IncomingDocAsInvoiceViewModel vm = new IncomingDocAsInvoiceViewModel() {
IncomingDocAsInvoiceViewModel setBankAccountRepository(BankAccountRepository bankAccountRepository) {
this.bankAccountRepository = bankAccountRepository;
return this;
}
}.setBankAccountRepository(mockBankAccountRepository);
BankAccount acc1 = new BankAccount();
BankAccount acc2 = new BankAccount();
Party owner = new Organisation();
acc2.setOwner(owner);
// expect
context.checking(new Expectations() {
{
allowing(mockBankAccountRepository).autoComplete(with(any(String.class)));
will(returnValue(Arrays.asList(acc1, acc2)));
oneOf(mockBankAccountRepository).findBankAccountsByOwner(owner);
will(returnValue(Arrays.asList(acc2)));
}
});
// when
result = vm.autoCompleteBankAccount("some searchstring");
// then
assertThat(result.size()).isEqualTo(2);
// and when seller is set
vm.setSeller(owner);
result = vm.autoCompleteBankAccount("3");
// then
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(acc2);
}
use of org.estatio.module.party.dom.Organisation 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.party.dom.Organisation 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();
}
Aggregations