From e6f06f56cbb312b8d28fbef7d794f44c8e2a7e87 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 16 Jan 2025 07:17:30 -0800 Subject: [PATCH] Move payment method filter up, fix for EJV / EFT --- .../payment/AccountPaymentMethods.vue | 2 +- .../product/ProductPayment.vue | 41 +++++++++++++++---- .../src/components/auth/common/Product.vue | 12 +----- .../create-account/SelectProductPayment.vue | 30 ++++++++++++-- auth-web/src/stores/org.ts | 15 ++----- .../auth/create-account/AccountSetupView.vue | 2 +- .../create-account/GovmAccountSetupView.vue | 2 +- .../non-bcsc/NonBcscAccountSetupView.vue | 2 +- 8 files changed, 69 insertions(+), 37 deletions(-) diff --git a/auth-web/src/components/auth/account-settings/payment/AccountPaymentMethods.vue b/auth-web/src/components/auth/account-settings/payment/AccountPaymentMethods.vue index 12538b201..7544c3b8b 100644 --- a/auth-web/src/components/auth/account-settings/payment/AccountPaymentMethods.vue +++ b/auth-web/src/components/auth/account-settings/payment/AccountPaymentMethods.vue @@ -215,7 +215,7 @@ export default defineComponent({ const isPaymentViewAllowed = computed(() => { // checking permission instead of roles to give access for staff - return [Permission.VIEW_PAYMENT_METHODS, Permission.MAKE_PAYMENT].some(per => permissions.value.includes(per)) + return [Permission.VIEW_REQUEST_PRODUCT_PACKAGE, Permission.MAKE_PAYMENT].some(per => permissions.value.includes(per)) }) async function initialize () { diff --git a/auth-web/src/components/auth/account-settings/product/ProductPayment.vue b/auth-web/src/components/auth/account-settings/product/ProductPayment.vue index 7ee672da4..103d319f7 100644 --- a/auth-web/src/components/auth/account-settings/product/ProductPayment.vue +++ b/auth-web/src/components/auth/account-settings/product/ProductPayment.vue @@ -152,6 +152,7 @@ import { AccessType, Account, AccountStatus, + PaymentTypes, Product as ProductEnum, ProductStatus, Role, @@ -199,7 +200,9 @@ export default defineComponent({ fetchOrgProductFeeCodes, updateAccountFees, needStaffReview, - removeOrgProduct + removeOrgProduct, + currentOrgPaymentDetails, + currentOrganization } = useOrgStore() const { @@ -207,7 +210,6 @@ export default defineComponent({ } = useCodesStore() const { - currentOrganization, productList, currentSelectedProducts } = storeToRefs(useOrgStore()) @@ -231,7 +233,7 @@ export default defineComponent({ displayRemoveProductDialog: false, addProductOnAccountAdmin: undefined, // true if add product, false if remove product isVariableFeeAccount: computed(() => { - const accessType:any = currentOrganization.value.accessType + const accessType:any = currentOrganization.accessType return ([AccessType.GOVM, AccessType.GOVN].includes(accessType)) || false }), canManageAccounts: computed((): boolean => { @@ -253,7 +255,30 @@ export default defineComponent({ ) }), // Not deconstructed otherwise name conflicts. - productPaymentMethods: computed(() => useCodesStore().productPaymentMethods), + productPaymentMethods: computed(() => { + const codesStore = useCodesStore() + const ppMethods = codesStore.productPaymentMethods + + let exclusionSet = [PaymentTypes.INTERNAL, PaymentTypes.EFT, PaymentTypes.EJV] + let inclusionSet = [] + + if (currentOrganization.accessType === AccessType.GOVM) { + inclusionSet = [PaymentTypes.EJV] + } else if (currentOrgPaymentDetails?.eftEnable) { + exclusionSet = [PaymentTypes.INTERNAL, PaymentTypes.EJV] + } + + Object.keys(ppMethods).forEach((product) => { + ppMethods[product] = ppMethods[product].filter((method) => { + if (inclusionSet.length > 0) { + return inclusionSet.includes(method as PaymentTypes) + } + return !exclusionSet.includes(method as PaymentTypes) + }) + }) + + return ppMethods + }), displayCancelOnDialog: computed(() => !state.staffReviewClear || state.displayRemoveProductDialog), submitDialogText: computed(() => { if (state.displayCancelOnDialog && !state.dialogError) { @@ -272,7 +297,7 @@ export default defineComponent({ const loadProduct = async () => { try { - await getOrgProducts(currentOrganization.value.id) + await getOrgProducts(currentOrganization.id) } catch (err) { // eslint-disable-next-line no-console console.log('Error while loading products ', err) @@ -286,7 +311,7 @@ export default defineComponent({ await loadProduct() // if staff need to load product fee also if (state.canManageAccounts) { - state.orgProductsFees = await syncCurrentAccountFees(currentOrganization.value.id) + state.orgProductsFees = await syncCurrentAccountFees(currentOrganization.id) state.orgProductFeeCodes = await fetchOrgProductFeeCodes() } state.isLoading = false @@ -408,12 +433,12 @@ export default defineComponent({ } const saveProductFee = async (accountFees) => { - const accountFee = { accoundId: currentOrganization.value.id, accountFees } + const accountFee = { accoundId: currentOrganization.id, accountFees } state.isProductActionLoading = true state.isProductActionCompleted = false try { await updateAccountFees(accountFee) - state.orgProductsFees = await syncCurrentAccountFees(currentOrganization.value.id) + state.orgProductsFees = await syncCurrentAccountFees(currentOrganization.id) } catch (err) { // eslint-disable-next-line no-console console.log('Error while updating product fee ', err) diff --git a/auth-web/src/components/auth/common/Product.vue b/auth-web/src/components/auth/common/Product.vue index 3fa1048c5..e0095b387 100644 --- a/auth-web/src/components/auth/common/Product.vue +++ b/auth-web/src/components/auth/common/Product.vue @@ -161,7 +161,7 @@ Supported payment methods:

{ return TOS_NEEDED_PRODUCT.includes(props.productDetails.code) }), - filteredPaymentMethods: computed(() => { - // TODO - Needs EFT - EJV todo as well - // if (orgStore.isGovmOrg) { - // return props.paymentMethods.filter((method) => method === PaymentTypes.EJV) - // } - return props.paymentMethods.filter((method) => - ![PaymentTypes.INTERNAL, PaymentTypes.EFT, PaymentTypes.EJV].includes(method as PaymentTypes)) - }), paymentMethodSupported: computed(() => { const paymentMethod = orgStore.currentOrgPaymentType === PaymentTypes.CREDIT_CARD ? PaymentTypes.DIRECT_PAY : orgStore.currentOrgPaymentType - return !orgStore.currentOrgPaymentType || state.filteredPaymentMethods?.includes(paymentMethod) + return !orgStore.currentOrgPaymentType || props.paymentMethods.includes(paymentMethod) }), hasDecisionNotBeenMade: computed(() => { // returns true if create account flow diff --git a/auth-web/src/components/auth/create-account/SelectProductPayment.vue b/auth-web/src/components/auth/create-account/SelectProductPayment.vue index ebd6669bb..728b89fda 100644 --- a/auth-web/src/components/auth/create-account/SelectProductPayment.vue +++ b/auth-web/src/components/auth/create-account/SelectProductPayment.vue @@ -112,12 +112,12 @@