Search in sources :

Example 21 with BankAccount

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();
}
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 22 with BankAccount

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);
}
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 23 with BankAccount

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();
}
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 24 with BankAccount

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;
}
Also used : BankAccount(org.estatio.module.financial.dom.BankAccount)

Example 25 with 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();
}
Also used : Expectations(org.jmock.Expectations) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

BankAccount (org.estatio.module.financial.dom.BankAccount)37 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)14 Test (org.junit.Test)13 Party (org.estatio.module.party.dom.Party)12 Programmatic (org.apache.isis.applib.annotation.Programmatic)11 Expectations (org.jmock.Expectations)9 Organisation (org.estatio.module.party.dom.Organisation)7 ArrayList (java.util.ArrayList)5 Action (org.apache.isis.applib.annotation.Action)4 Property (org.estatio.module.asset.dom.Property)4 BankAccountVerificationStateTransition (org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransition)4 FinancialAccount (org.estatio.module.financial.dom.FinancialAccount)4 BigDecimal (java.math.BigDecimal)3 List (java.util.List)3 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)3 Inject (javax.inject.Inject)2 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 Blob (org.apache.isis.applib.value.Blob)2 FixedAssetFinancialAccount (org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount)2 BankMandate (org.estatio.module.bankmandate.dom.BankMandate)2