Search in sources :

Example 1 with IncomingInvoiceApprovalStateTransitionType

use of org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransitionType in project estatio by estatio.

the class BankAccountVerificationStateSubscriber method toCheckIbanProof.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void toCheckIbanProof(final IncomingInvoiceApprovalStateTransitionType.TransitionEvent ev) {
    final StateTransitionEvent.Phase phase = ev.getPhase();
    if (phase == StateTransitionEvent.Phase.TRANSITIONED) {
        final IncomingInvoiceApprovalStateTransitionType transitionType = ev.getTransitionType();
        final IncomingInvoice incomingInvoice = ev.getDomainObject();
        switch(transitionType) {
            // do so as early as possible so that verification can run in parallel with approval
            case COMPLETE:
            case // belt-n-braces, do late as well
            CHECK_BANK_ACCOUNT:
                if (bankAccountVerificationChecker.isBankAccountVerifiedFor(incomingInvoice) || Arrays.asList(PaymentMethod.MANUAL_PROCESS, PaymentMethod.CREDIT_CARD, PaymentMethod.REFUND_BY_SUPPLIER).contains(incomingInvoice.getPaymentMethod())) {
                    return;
                }
                triggerBankVerificationState(incomingInvoice);
                attachDocumentAsPossibleIbanProofIfNone(incomingInvoice);
                break;
            default:
                break;
        }
    }
}
Also used : IncomingInvoiceApprovalStateTransitionType(org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransitionType) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) StateTransitionEvent(org.estatio.module.capex.dom.state.StateTransitionEvent) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)1 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 IncomingInvoiceApprovalStateTransitionType (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransitionType)1 StateTransitionEvent (org.estatio.module.capex.dom.state.StateTransitionEvent)1