Search in sources :

Example 1 with BankAccount

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

the class PaymentBatch method doGetCreditTransfers.

private List<CreditTransfer> doGetCreditTransfers() {
    List<CreditTransfer> transfers = Lists.newArrayList();
    final Map<BankAccount, List<PaymentLine>> lineBySeller = Lists.newArrayList(getLines()).stream().sorted(Comparator.comparing(PaymentLine::getSequence)).collect(groupingBy(PaymentLine::getCreditorBankAccount, TreeMap::new, toSortedList(Comparator.comparing(PaymentLine::getSequence))));
    for (Map.Entry<BankAccount, List<PaymentLine>> linesByBankAccount : lineBySeller.entrySet()) {
        final CreditTransfer creditTransfer = new CreditTransfer();
        creditTransfer.setBatch(this);
        final BankAccount bankAccount = linesByBankAccount.getKey();
        final List<PaymentLine> lines = linesByBankAccount.getValue();
        final String sequenceNums = extractAndJoin(lines, line -> "" + line.getSequence(), "-");
        final String endToEndId = String.format("%s-%s", getId(), sequenceNums);
        creditTransfer.setEndToEndId(endToEndId);
        creditTransfer.setSellerBankAccount(bankAccount);
        creditTransfer.setLines(lines);
        final BigDecimal amount = lines.stream().map(PaymentLine::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
        if (!lines.isEmpty()) {
            // should always be non-empty, just playing safe...
            final PaymentLine firstLine = lines.get(0);
            creditTransfer.setCurrency(firstLine.getCurrency());
        }
        creditTransfer.setAmount(amount);
        // -PM-19229-12-2016-2-RO
        // -2017-01-04-RO
        // -L 17-01-302-RO
        // -FC-1702CS1-0002-RO
        // -AF1T2017ASL-RO
        final String remittanceInformation = extractAndJoin(lines, line -> line.getInvoice().getInvoiceNumber(), ";");
        creditTransfer.setRemittanceInformation(remittanceInformation);
        creditTransfer.setSeller(bankAccount.getOwner());
        creditTransfer.setSellerPostalAddressCountry(ctryFor(bankAccount.getOwner()));
        transfers.add(creditTransfer);
    }
    return transfers;
}
Also used : BankAccount(org.estatio.module.financial.dom.BankAccount) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) TreeMap(java.util.TreeMap) BigDecimal(java.math.BigDecimal)

Example 2 with BankAccount

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

the class EstatioAppHomePage_verifyBankAccounts method act.

@Action(semantics = SemanticsOf.IDEMPOTENT, restrictTo = RestrictTo.PROTOTYPING)
@ActionLayout(position = ActionLayout.Position.PANEL)
public EstatioAppHomePage act(final List<IncomingInvoice> invoices, @Nullable final String comment) {
    for (IncomingInvoice invoice : invoices) {
        final BankAccount bankAccount = invoice.getBankAccount();
        factoryService.mixin(BankAccount_verify.class, bankAccount).act(comment);
        factoryService.mixin(IncomingInvoice_checkApprovalState.class, invoice).act();
    }
    return homePage;
}
Also used : BankAccount_verify(org.estatio.module.capex.dom.bankaccount.verification.triggers.BankAccount_verify) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) IncomingInvoice_checkApprovalState(org.estatio.module.capex.dom.invoice.approval.tasks.IncomingInvoice_checkApprovalState) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 3 with BankAccount

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

the class BankAccountVerificationChecker method isBankAccountVerifiedFor.

@Programmatic
public boolean isBankAccountVerifiedFor(final IncomingInvoice incomingInvoice) {
    final BankAccount bankAccount = incomingInvoice.getBankAccount();
    BankAccountVerificationState state = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
    return state == BankAccountVerificationState.VERIFIED;
}
Also used : BankAccount(org.estatio.module.financial.dom.BankAccount) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with BankAccount

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

the class BankAccountVerificationStateSubscriber method triggerBankVerificationState.

private void triggerBankVerificationState(final IncomingInvoice incomingInvoice) {
    final BankAccount bankAccount = incomingInvoice.getBankAccount();
    if (bankAccount == null) {
        return;
    }
    if (stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class) == null) {
        stateTransitionService.trigger(bankAccount, BankAccountVerificationStateTransitionType.INSTANTIATE, null, null);
    }
    // create the required pending transition, if none already.
    stateTransitionService.triggerPending(bankAccount, BankAccountVerificationStateTransitionType.VERIFY_BANK_ACCOUNT);
}
Also used : BankAccount(org.estatio.module.financial.dom.BankAccount)

Example 5 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)

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