Search in sources :

Example 51 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice 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)

Example 52 with IncomingInvoice

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

the class IncomingInvoiceApprovalStateSubscriber method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(IncomingInvoice.ObjectPersistedEvent ev) {
    // nb: note that the incoming invoice at this stage has no items attached to it,
    // so there is a limit as to what we can safely do.
    // however, it *is* ok to just create the state chart for the invoice.
    final IncomingInvoice incomingInvoice = ev.getSource();
    IncomingInvoiceApprovalState approvalState = incomingInvoice.getApprovalState();
    if (approvalState == IncomingInvoiceApprovalStateTransitionType.INSTANTIATE.getToState()) {
        // ie was set in the persisting callback
        stateTransitionService.trigger(incomingInvoice, IncomingInvoiceApprovalStateTransitionType.INSTANTIATE, null, null);
    }
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 53 with IncomingInvoice

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

the class IncomingInvoiceApprovalStateSubscriber method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(BankAccountVerificationStateTransitionType.TransitionEvent ev) {
    final StateTransitionEvent.Phase phase = ev.getPhase();
    if (phase == StateTransitionEvent.Phase.TRANSITIONED) {
        final BankAccountVerificationStateTransitionType transitionType = ev.getTransitionType();
        final BankAccount bankAccount = ev.getDomainObject();
        switch(transitionType) {
            case INSTANTIATE:
                break;
            case VERIFY_BANK_ACCOUNT:
                final List<IncomingInvoice> incomingInvoices = findIncomingInvoicesUsing(bankAccount);
                for (IncomingInvoice incomingInvoice : incomingInvoices) {
                    stateTransitionService.trigger(incomingInvoice, CONFIRM_BANK_ACCOUNT_VERIFIED, null, null);
                }
                break;
            case REJECT_PROOF:
                break;
            case PROOF_UPDATED:
                break;
            case RESET:
                break;
        }
    }
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccountVerificationStateTransitionType(org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransitionType) BankAccount(org.estatio.module.financial.dom.BankAccount) StateTransitionEvent(org.estatio.module.capex.dom.state.StateTransitionEvent) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 54 with IncomingInvoice

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

the class IncomingInvoice_approveAsCountryDirector method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "fa-thumbs-up")
public Object act(@Nullable final String comment, final boolean goToNext) {
    final IncomingInvoice next = nextAfterPendingIfRequested(goToNext);
    trigger(comment, null);
    return objectToReturn(next);
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 55 with IncomingInvoice

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

the class IncomingInvoice_checkPayment method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "fa-thumbs-o-up")
public Object act(@Nullable final String comment, final boolean goToNext) {
    final IncomingInvoice next = nextAfterPendingIfRequested(goToNext);
    trigger(comment, null);
    return objectToReturn(next);
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)57 Test (org.junit.Test)27 Expectations (org.jmock.Expectations)20 BankAccount (org.estatio.module.financial.dom.BankAccount)14 Action (org.apache.isis.applib.annotation.Action)11 BigDecimal (java.math.BigDecimal)9 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)9 Organisation (org.estatio.module.party.dom.Organisation)9 Party (org.estatio.module.party.dom.Party)9 IncomingInvoiceMenu (org.estatio.module.capex.app.IncomingInvoiceMenu)8 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)7 Document (org.incode.module.document.dom.impl.docs.Document)7 LocalDate (org.joda.time.LocalDate)7 ArrayList (java.util.ArrayList)5 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 Property (org.estatio.module.asset.dom.Property)3 UpcomingPaymentTotal (org.estatio.module.capex.app.invoice.UpcomingPaymentTotal)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)3 OrderItem (org.estatio.module.capex.dom.order.OrderItem)3