Search in sources :

Example 11 with PartyRoleType

use of org.estatio.module.party.dom.role.PartyRoleType in project estatio by estatio.

the class PersonRepository method findByRoleType.

@Programmatic
public List<Person> findByRoleType(final IPartyRoleType iPartyRoleType) {
    PartyRoleType partyRoleType = iPartyRoleType.findOrCreateUsing(partyRoleTypeRepository);
    final List<Party> parties = partyRepository.findByRoleType(partyRoleType);
    return personsFor(parties);
}
Also used : IPartyRoleType(org.estatio.module.party.dom.role.IPartyRoleType) PartyRoleType(org.estatio.module.party.dom.role.PartyRoleType) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 12 with PartyRoleType

use of org.estatio.module.party.dom.role.PartyRoleType in project estatio by estatio.

the class IncomingInvoiceApprovalState_IntegTest method paid_by_credit_card_skips_bank_account_verification_and_creates_check_task_for_treasury.

@Test
public void paid_by_credit_card_skips_bank_account_verification_and_creates_check_task_for_treasury() {
    // given
    PartyRoleType typeForTreasurer = partyRoleTypeRepository.findByKey(PartyRoleTypeEnum.TREASURER.getKey());
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(Person_enum.JonathanPropertyManagerGb.getRef().toLowerCase(), (Runnable) () -> wrap(incomingInvoice).changePaymentMethod(PaymentMethod.CREDIT_CARD));
    sudoService.sudo(Person_enum.JonathanPropertyManagerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_complete.class, incomingInvoice)).act("PROPERTY_MANAGER", null, null));
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(Person_enum.PeterPanProjectManagerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_approve.class, incomingInvoice)).act("COUNTRY_DIRECTOR", null, null, false));
    List<Task> tasksForTreasury = taskRepository.findIncompleteByRole(typeForTreasurer);
    assertThat(tasksForTreasury).isEmpty();
    BankAccount bankAccount = incomingInvoice.getBankAccount();
    assertThat(bankAccount).isNotNull();
    BankAccountVerificationState state = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
    assertThat(state).isEqualTo(BankAccountVerificationState.NOT_VERIFIED);
    // when
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(Person_enum.OscarCountryDirectorGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_approveAsCountryDirector.class, incomingInvoice)).act(null, false));
    // then
    assertThat(incomingInvoice.getApprovalState()).isEqualTo(IncomingInvoiceApprovalState.PAYABLE);
    List<IncomingInvoiceApprovalStateTransition> transitions = incomingInvoiceStateTransitionRepository.findByDomainObject(incomingInvoice);
    assertThat(transitions.size()).isEqualTo(7);
    assertThat(transitions.get(0).getTransitionType()).isEqualTo(IncomingInvoiceApprovalStateTransitionType.CHECK_PAYMENT);
    tasksForTreasury = taskRepository.findIncompleteByRole(typeForTreasurer);
    assertThat(tasksForTreasury.size()).isEqualTo(1);
    assertThat(tasksForTreasury.get(0).getDescription()).isEqualTo("Check Payment");
    // and still
    state = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
    assertThat(state).isEqualTo(BankAccountVerificationState.NOT_VERIFIED);
    // and when
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(Person_enum.EmmaTreasurerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_checkPayment.class, incomingInvoice)).act(null, false));
    // then
    assertThat(incomingInvoice.getApprovalState()).isEqualTo(IncomingInvoiceApprovalState.PAID);
}
Also used : Task(org.estatio.module.capex.dom.task.Task) BankAccountVerificationState(org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationState) IncomingInvoiceApprovalStateTransition(org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition) PartyRoleType(org.estatio.module.party.dom.role.PartyRoleType) BankAccount(org.estatio.module.financial.dom.BankAccount) BankAccountVerificationStateTransition(org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransition) Test(org.junit.Test)

Example 13 with PartyRoleType

use of org.estatio.module.party.dom.role.PartyRoleType in project estatio by estatio.

the class BankAccountVerificationState_IntegTest method reject_then_discard_then_update_proof_works_test.

@Test
public void reject_then_discard_then_update_proof_works_test() {
    // given
    Person personEmmaTreasurer = Person_enum.EmmaTreasurerGb.findUsing(serviceRegistry);
    PartyRoleType typeForTreasurer = partyRoleTypeRepository.findByKey(PartyRoleTypeEnum.TREASURER.getKey());
    PartyRoleType typeForPropertyManager = partyRoleTypeRepository.findByKey(FixedAssetRoleTypeEnum.PROPERTY_MANAGER.getKey());
    assertThat(taskRepository.findIncompleteByRole(typeForPropertyManager).size()).isEqualTo(2);
    // when
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(personEmmaTreasurer.getUsername(), (Runnable) () -> wrap(mixin(BankAccount_rejectProof.class, bankAccount)).act("PROPERTY_MANAGER", null, "NO GOOD"));
    // then
    assertState(bankAccount, BankAccountVerificationState.AWAITING_PROOF);
    assertThat(taskRepository.findIncompleteByRole(typeForTreasurer).size()).isEqualTo(0);
    assertThat(taskRepository.findIncompleteByRole(typeForPropertyManager).size()).isEqualTo(3);
    // and given
    Person jonathanPropManager = Person_enum.JonathanPropertyManagerGb.findUsing(serviceRegistry);
    // and when
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(jonathanPropManager.getUsername(), (Runnable) () -> wrap(mixin(BankAccount_discard.class, bankAccount)).act("DISCARDING"));
    // then
    assertState(bankAccount, BankAccountVerificationState.DISCARDED);
    assertThat(taskRepository.findIncompleteByRole(typeForTreasurer).size()).isEqualTo(0);
    assertThat(taskRepository.findIncompleteByRole(typeForPropertyManager).size()).isEqualTo(2);
    // and when 'resurrecting'
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(jonathanPropManager.getUsername(), (Runnable) () -> wrap(mixin(BankAccount_proofUpdated.class, bankAccount)).act("TREASURER", null, null));
    // then
    assertState(bankAccount, BankAccountVerificationState.NOT_VERIFIED);
    assertThat(taskRepository.findIncompleteByRole(typeForTreasurer).size()).isEqualTo(1);
    assertThat(taskRepository.findIncompleteByRole(typeForPropertyManager).size()).isEqualTo(2);
    // and when discarding again by treasurer
    // workaround: clear MeService#me cache
    queryResultsCache.resetForNextTransaction();
    sudoService.sudo(personEmmaTreasurer.getUsername(), (Runnable) () -> wrap(mixin(BankAccount_discard.class, bankAccount)).act("DISCARDING"));
    assertState(bankAccount, BankAccountVerificationState.DISCARDED);
    assertThat(taskRepository.findIncompleteByRole(typeForTreasurer).size()).isEqualTo(0);
}
Also used : PartyRoleType(org.estatio.module.party.dom.role.PartyRoleType) Person(org.estatio.module.party.dom.Person) Test(org.junit.Test)

Aggregations

PartyRoleType (org.estatio.module.party.dom.role.PartyRoleType)13 Person (org.estatio.module.party.dom.Person)9 Task (org.estatio.module.capex.dom.task.Task)6 Test (org.junit.Test)5 Programmatic (org.apache.isis.applib.annotation.Programmatic)4 BankAccountVerificationStateTransition (org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransition)3 BankAccount (org.estatio.module.financial.dom.BankAccount)3 IPartyRoleType (org.estatio.module.party.dom.role.IPartyRoleType)3 PartyRole (org.estatio.module.party.dom.role.PartyRole)3 BankAccountVerificationState (org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationState)2 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)2 DisabledException (org.apache.isis.applib.services.wrapper.DisabledException)1 AbstractBeanPropertiesTest (org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest)1 Expectations (org.jmock.Expectations)1 LocalDateTime (org.joda.time.LocalDateTime)1 Before (org.junit.Before)1