Search in sources :

Example 6 with BankAccount

use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.

the class BankAccountVerificationStateSubscriber method titleOf.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void titleOf(BankAccount.TitleUiEvent ev) {
    final BankAccount bankAccount = ev.getSource();
    final BankAccountVerificationState state = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
    final String title = String.format("%s - %s (%s)", bankAccount.getName(), bankAccount.getOwner().getReference(), Enums.getFriendlyNameOf(state));
    ev.setTitle(title);
}
Also used : BankAccount(org.estatio.module.financial.dom.BankAccount) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 7 with BankAccount

use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.

the class BankAccountSubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final BankAccount.RemoveEvent ev) {
    BankAccount sourceBankAccount = ev.getSource();
    List<FixedAssetFinancialAccount> results;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            results = fixedAssetFinancialAccountRepository.findByFinancialAccount(sourceBankAccount);
            if (results.size() > 0) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("This bank account is assigned to a fixed asset: remove the bank account from the fixed asset. In use by the following fixed assets: ");
                for (FixedAssetFinancialAccount fixedAssetFinancialAccount : results) {
                    stringBuilder.append(fixedAssetFinancialAccount.getFixedAsset().getName() + "\n");
                }
                ev.invalidate(stringBuilder.toString());
            }
            break;
        default:
            break;
    }
}
Also used : FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) BankAccount(org.estatio.module.financial.dom.BankAccount) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 8 with BankAccount

use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.

the class BankAccount_verify_Test method setUp.

@Before
public void setUp() throws Exception {
    bankAccount = new BankAccount();
    mixin = new BankAccount_verify(bankAccount);
    mixin.paperclipRepository = mockPaperclipRepository;
}
Also used : PaperclipForBankAccount(org.estatio.module.financial.dom.paperclips.PaperclipForBankAccount) BankAccount(org.estatio.module.financial.dom.BankAccount) Before(org.junit.Before)

Example 9 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_bankaccounts_and_one_for_property.

@Test
public void unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    service.fixedAssetFinancialAccountRepository = mockFixedAssetFinancialAccountRepository;
    BankAccount bankAccount = new BankAccount();
    BankAccount bankAccountForProperty = new BankAccount();
    FixedAssetFinancialAccount fixedAssetFinancialAccount = new FixedAssetFinancialAccount();
    fixedAssetFinancialAccount.setFinancialAccount(bankAccountForProperty);
    List<BankAccount> bankAccounts = new ArrayList<>();
    bankAccounts.add(bankAccount);
    bankAccounts.add(bankAccountForProperty);
    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);
            will(returnValue(bankAccounts));
            oneOf(mockFixedAssetFinancialAccountRepository).findByFixedAsset(property);
            will(returnValue(Arrays.asList(fixedAssetFinancialAccount)));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccountForProperty);
}
Also used : Expectations(org.jmock.Expectations) FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) 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) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 10 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_one_bankaccount_and_no_property.

@Test
public void unique_Debtor_Account_To_Pay_works_when_one_bankaccount_and_no_property() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    BankAccount bankAccount = new BankAccount();
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(Arrays.asList(bankAccount)));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccount);
}
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) BankAccount(org.estatio.module.financial.dom.BankAccount) 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