use of org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationState in project estatio by estatio.
the class IncomingInvoiceApprovalState_IntegTest method refund_by_supplier_skips_bank_account_verification_and_creates_check_task_for_treasury.
@Test
public void refund_by_supplier_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.REFUND_BY_SUPPLIER));
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);
}
use of org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationState in project estatio by estatio.
the class BankAccount_detachIbanProof method disableAct.
public String disableAct() {
final List<Paperclip> ibanProofPaperclips = findIbanProofPaperclips();
final int numProof = ibanProofPaperclips.size();
switch(numProof) {
case 0:
return "No documents to detach";
case 1:
// otherwise get into the complication of having to move the IBAN back into unverified...
final BankAccountVerificationState currentState = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
if (currentState == BankAccountVerificationState.VERIFIED) {
return "Cannot remove only iban proof - attach other proof first";
}
default:
return null;
}
}
use of org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationState 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);
}
Aggregations