Skip to content

Commit

Permalink
Move payment method filter up, fix for EJV / EFT
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 committed Jan 16, 2025
1 parent 8b631dc commit e6f06f5
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ import {
AccessType,
Account,
AccountStatus,
PaymentTypes,
Product as ProductEnum,
ProductStatus,
Role,
Expand Down Expand Up @@ -199,15 +200,16 @@ export default defineComponent({
fetchOrgProductFeeCodes,
updateAccountFees,
needStaffReview,
removeOrgProduct
removeOrgProduct,
currentOrgPaymentDetails,
currentOrganization
} = useOrgStore()
const {
getProductPaymentMethods
} = useCodesStore()
const {
currentOrganization,
productList,
currentSelectedProducts
} = storeToRefs(useOrgStore())
Expand All @@ -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 => {
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 2 additions & 10 deletions auth-web/src/components/auth/common/Product.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
Supported payment methods:
</P>
<v-chip
v-for="method in filteredPaymentMethods"
v-for="method in paymentMethods"
:key="method"
small
label
Expand Down Expand Up @@ -247,18 +247,10 @@ export default defineComponent({
isTOSNeeded: computed(() => {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@
</template>

<script lang="ts">
import { AccessType, PaymentTypes } from '@/util/constants'
import { computed, defineComponent, onMounted, reactive, ref, toRefs } from '@vue/composition-api'
import { BcolProfile } from '@/models/bcol'
import ConfirmCancelButton from '@/components/auth/common/ConfirmCancelButton.vue'
import NextPageMixin from '../mixins/NextPageMixin.vue'
import PaymentMethods from '@/components/auth/common/PaymentMethods.vue'
import { PaymentTypes } from '@/util/constants'
import Product from '@/components/auth/common/Product.vue'
import Steppable from '@/components/auth/common/stepper/Steppable.vue'
import { useAccountCreate } from '@/composables/account-create-factory'
Expand All @@ -140,13 +140,37 @@ export default defineComponent({
emits: ['final-step-action', 'emit-bcol-info'],
setup (props, { root, emit }) {
const form = ref(null)
const { currentOrganization, currentOrgPaymentDetails } = useOrgStore()
const orgStore = useOrgStore()
const codesStore = useCodesStore()
const state = reactive({
isLoading: false,
expandedProductCode: '',
productList: computed(() => orgStore.productList),
productPaymentMethods: computed(() => codesStore.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
}),
currentSelectedProducts: computed(() => orgStore.currentSelectedProducts),
isFormValid: computed(() => state.currentSelectedProducts && state.currentSelectedProducts.length > 0),
selectedPaymentMethod: '',
Expand Down Expand Up @@ -217,7 +241,7 @@ export default defineComponent({
async function save () {
orgStore.setResetAccountTypeOnSetupAccount(true)
useAccountCreate().save(state, createAccount)
await useAccountCreate().save(state, createAccount)
}
function createAccount () {
Expand Down
15 changes: 3 additions & 12 deletions auth-web/src/stores/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ export const useOrgStore = defineStore('org', () => {

async function resetAccountSetupProgress (): Promise<void> {
setCurrentOrganization(undefined)
setSelectedAccountType(undefined)
setCurrentOrganizationType(undefined)
setSelectedAccountType(Account.PREMIUM)
setCurrentOrganizationType(Account.PREMIUM)
setCurrentOrganizationPaymentType(undefined)
setCurrentOrganizationPADInfo(undefined)
await resetoCurrentSelectedProducts()
Expand Down Expand Up @@ -1074,14 +1074,6 @@ export const useOrgStore = defineStore('org', () => {
return response?.data
}

// Called from three flows: Create GOVM, Premium and NON BCSC.
async function resetOrgInfoForCreateAccount () {
setSelectedAccountType(Account.PREMIUM)
setCurrentOrganizationType(Account.PREMIUM)
setCurrentOrganizationPaymentType(null)
setCurrentOrganizationPADInfo(null)
}

return {
...toRefs(state),
isPremiumAccount,
Expand Down Expand Up @@ -1186,7 +1178,6 @@ export const useOrgStore = defineStore('org', () => {
isGovnGovmOrg,
updateOrgMailingAddress,
needStaffReview,
removeOrgProduct,
resetOrgInfoForCreateAccount
removeOrgProduct
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default defineComponent({
}
onMounted(() => {
useOrgStore().resetOrgInfoForCreateAccount()
useOrgStore().resetAccountSetupProgress()
useOrgStore().setAccessType(AccessType.REGULAR)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default defineComponent({
]
onMounted(() => {
useOrgStore().resetOrgInfoForCreateAccount()
useOrgStore().resetAccountSetupProgress()
useOrgStore().setAccessType(AccessType.GOVM)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default defineComponent({
})
onMounted(async () => {
useOrgStore().resetOrgInfoForCreateAccount()
useOrgStore().resetAccountSetupProgress()
useOrgStore().setAccessType(AccessType.REGULAR_BCEID)
// on re-upload need show some pages are in view only mode
state.readOnly = !!props.orgId
Expand Down

0 comments on commit e6f06f5

Please sign in to comment.