Search in sources :

Example 21 with Organisation

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);
}
Also used : OrganisationNameNumberViewModel(org.estatio.module.party.app.services.OrganisationNameNumberViewModel) Expectations(org.jmock.Expectations) Organisation(org.estatio.module.party.dom.Organisation) Country(org.incode.module.country.dom.impl.Country) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Example 22 with Organisation

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);
}
Also used : Order(org.estatio.module.capex.dom.order.Order) Expectations(org.jmock.Expectations) Organisation(org.estatio.module.party.dom.Organisation) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Test(org.junit.Test)

Example 23 with Organisation

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);
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) BankAccount(org.estatio.module.financial.dom.BankAccount) BankAccountRepository(org.estatio.module.financial.dom.BankAccountRepository) Test(org.junit.Test)

Example 24 with Organisation

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();
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Example 25 with Organisation

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();
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Aggregations

Organisation (org.estatio.module.party.dom.Organisation)37 Test (org.junit.Test)26 Expectations (org.jmock.Expectations)18 Party (org.estatio.module.party.dom.Party)13 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)9 BankAccount (org.estatio.module.financial.dom.BankAccount)7 LocalDate (org.joda.time.LocalDate)7 Action (org.apache.isis.applib.annotation.Action)6 Property (org.estatio.module.asset.dom.Property)5 BigDecimal (java.math.BigDecimal)4 ArrayList (java.util.ArrayList)4 Charge (org.estatio.module.charge.dom.Charge)4 Order (org.estatio.module.capex.dom.order.Order)3 Person (org.estatio.module.party.dom.Person)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)2 IncomingInvoiceMenu (org.estatio.module.capex.app.IncomingInvoiceMenu)2 Project (org.estatio.module.capex.dom.project.Project)2 Country (org.incode.module.country.dom.impl.Country)2 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)1