Skip to content

Commit 68664a0

Browse files
authored
26980 - Split Credits into PAD and ONLINE Banking Credits (#3455)
1 parent 2bffd86 commit 68664a0

File tree

11 files changed

+1240
-261
lines changed

11 files changed

+1240
-261
lines changed

auth-web/src/components/auth/account-settings/transaction/Transactions.vue

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,28 @@
2121
{{ title }}
2222
</h2>
2323
</header>
24-
<section v-if="showCredit && credit !== 0">
24+
<section v-if="showCredit && (hasPadCredit || hasObCredit)">
2525
<v-divider class="mb-8" />
26-
<h2>Account Credit: <span class="cad-credit ml-4">CAD</span> ${{ credit.toFixed(2) }}</h2>
26+
<div class="credit-header-row">
27+
<span class="font-weight-bold">Account Credit Available:</span>
28+
<span
29+
v-if="hasPadCredit"
30+
class="credit-method-amount ml-4"
31+
>
32+
<span class="font-weight-bold credit-method-name">{{ paymentTypeDisplay.PAD }}</span>
33+
<span class="font-weight-bold ml-1">CAD ${{ padCredit.toFixed(2) }}</span>
34+
</span>
35+
<span
36+
v-if="hasObCredit"
37+
class="credit-method-amount ml-4"
38+
>
39+
<span class="font-weight-bold credit-method-name">{{ paymentTypeDisplay.ONLINE_BANKING }}</span>
40+
<span class="font-weight-bold ml-1">${{ obCredit.toFixed(2) }}</span>
41+
</span>
42+
</div>
2743
<p class="credit-details mt-1">
28-
You have a credit of ${{ credit.toFixed(2) }} on this account.
44+
Credit for different payment methods are not transferable. To use your credit, please navigate
45+
to the Product and Payment page and select the related payment method.
2946
</p>
3047
<v-divider class="mb-8 mt-8" />
3148
</section>
@@ -126,6 +143,7 @@ import { StatusCodes } from 'http-status-codes'
126143
import TransactionsDataTable from './TransactionsDataTable.vue'
127144
import { getTransactionTableHeaders } from '@/resources/table-headers'
128145
import moment from 'moment'
146+
import { paymentTypeDisplay } from '@/resources/display-mappers/payment-type-display'
129147
import { useOrgStore } from '@/stores/org'
130148
131149
export default defineComponent({
@@ -151,7 +169,12 @@ export default defineComponent({
151169
const { clearAllFilters, getTransactionReport, loadTransactionList, setViewAll, defaultSearchToOneYear } = useTransactions()
152170
153171
const state = reactive({
154-
isLoading: false
172+
isLoading: false,
173+
obCredit: 0,
174+
padCredit: 0,
175+
paymentMethod: null,
176+
hasPadCredit: computed(() => state.padCredit > 0),
177+
hasObCredit: computed(() => state.obCredit > 0)
155178
})
156179
157180
// FUTURE: vue3 we can set this fn explicitly in the resource instead of doing it here
@@ -186,8 +209,6 @@ export default defineComponent({
186209
})
187210
})
188211
189-
const credit = ref(0)
190-
191212
const isTransactionsAllowed = computed((): boolean => {
192213
return orgStore.hasPermission(Permission.TRANSACTION_HISTORY)
193214
})
@@ -196,9 +217,13 @@ export default defineComponent({
196217
const accountId = currentOrgPaymentDetails.value?.accountId
197218
if (!accountId || Number(accountId) !== currentOrganization.value?.id) {
198219
const paymentDetails: OrgPaymentDetails = await orgStore.getOrgPayments(currentOrganization.value?.id)
199-
credit.value = Number(paymentDetails?.credit || 0)
220+
state.obCredit = Number(paymentDetails?.obCredit || 0)
221+
state.padCredit = Number(paymentDetails?.padCredit || 0)
222+
state.paymentMethod = paymentDetails.paymentMethod || ''
200223
} else {
201-
credit.value = Number(currentOrgPaymentDetails.value?.credit || 0)
224+
state.obCredit = Number(currentOrgPaymentDetails.value?.obCredit || 0)
225+
state.padCredit = Number(currentOrgPaymentDetails.value?.padCredit || 0)
226+
state.paymentMethod = currentOrgPaymentDetails.value?.paymentMethod || ''
202227
}
203228
}
204229
@@ -245,8 +270,8 @@ export default defineComponent({
245270
headerSelections,
246271
headersSelected,
247272
sortedHeaders,
248-
credit,
249-
exportCSV
273+
exportCSV,
274+
paymentTypeDisplay
250275
}
251276
}
252277
})
@@ -341,4 +366,16 @@ export default defineComponent({
341366
.loading-container {
342367
background: rgba(255,255,255, 0.8);
343368
}
369+
370+
.credit-header-row {
371+
display: flex;
372+
align-items: center;
373+
font-size: 1.15rem;
374+
}
375+
.credit-method-amount {
376+
font-size: 1.15rem;
377+
}
378+
.credit-method-name {
379+
color: $gray7;
380+
}
344381
</style>

auth-web/src/components/pay/PayWithCreditCard.vue

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,25 @@
4141
</template>
4242

4343
<script lang="ts">
44+
import { defineComponent } from '@vue/composition-api'
4445
45-
import { Component, Prop, Vue } from 'vue-property-decorator'
46-
47-
@Component({})
48-
export default class PayWithCreditCard extends Vue {
49-
@Prop({ default: false }) showPayWithOnlyCC: boolean
50-
@Prop({ default: 0 }) totalBalanceDue: number
51-
@Prop({ default: false }) partialCredit: boolean
52-
}
46+
export default defineComponent({
47+
name: 'PayWithCreditCard',
48+
props: {
49+
showPayWithOnlyCC: {
50+
type: Boolean,
51+
default: false
52+
},
53+
totalBalanceDue: {
54+
type: Number,
55+
default: 0
56+
},
57+
partialCredit: {
58+
type: Boolean,
59+
default: false
60+
}
61+
}
62+
})
5363
</script>
5464

5565
<style lang="scss" scoped>

auth-web/src/components/pay/PayWithOnlineBanking.vue

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<v-card elevation="0">
33
<v-card-text class="heading-info py-7 px-8">
44
<h2 class="mb-2">
5-
Balance Due: <span class="ml-2">{{ overCredit ? '-': '' }}${{ totalBalanceDue.toFixed(2) }}</span>
5+
Transaction Amount: <span class="ml-2">${{ originalAmount.toFixed(2) }}</span><br>
6+
Balance Due: <span class="ml-2">${{ totalBalanceDue.toFixed(2) }}</span>
67
</h2>
78
<template v-if="overCredit">
89
<p class="mb-6">
@@ -56,42 +57,55 @@
5657
</template>
5758

5859
<script lang="ts">
60+
import { defineComponent, onMounted, reactive, toRefs, watch } from '@vue/composition-api'
5961
60-
import { Component, Prop, Watch } from 'vue-property-decorator'
61-
import Vue from 'vue'
62+
export default defineComponent({
63+
name: 'PayWithOnlineBanking',
64+
props: {
65+
onlineBankingData: {
66+
type: Object,
67+
required: true
68+
},
69+
showPayWithOnlyCC: {
70+
type: Boolean,
71+
default: false
72+
}
73+
},
74+
setup (props) {
75+
const state = reactive({
76+
payWithCreditCard: false,
77+
totalBalanceDue: 0,
78+
cfsAccountId: '',
79+
payeeName: '',
80+
overCredit: false,
81+
creditBalance: 0,
82+
partialCredit: false,
83+
credit: 0,
84+
originalAmount: 0
85+
})
6286
63-
@Component
64-
export default class PayWithOnlineBanking extends Vue {
65-
@Prop() onlineBankingData: any
66-
@Prop({ default: false }) showPayWithOnlyCC: boolean
67-
private payWithCreditCard: boolean = false
68-
private totalBalanceDue = 0
69-
private cfsAccountId: string = ''
70-
private payeeName: string = ''
71-
private overCredit:boolean = false
72-
private creditBalance = 0
73-
private partialCredit:boolean = false
74-
private credit = 0
87+
const updateOnlineBankingData = () => {
88+
state.totalBalanceDue = props.onlineBankingData?.totalBalanceDue || 0
89+
state.payeeName = props.onlineBankingData?.payeeName
90+
state.cfsAccountId = props.onlineBankingData?.cfsAccountId || ''
91+
state.overCredit = props.onlineBankingData?.overCredit || false
92+
state.partialCredit = props.onlineBankingData?.partialCredit || false
93+
state.creditBalance = props.onlineBankingData?.creditBalance || 0
94+
state.credit = props.onlineBankingData?.credit || 0
95+
state.originalAmount = props.onlineBankingData?.originalAmount || 0
96+
}
7597
76-
@Watch('onlineBankingData', { deep: true })
77-
async updateonlineBankingData () {
78-
this.setData()
79-
}
98+
watch(() => props.onlineBankingData, updateOnlineBankingData, { deep: true })
8099
81-
private setData () {
82-
this.totalBalanceDue = this.onlineBankingData?.totalBalanceDue || 0
83-
this.payeeName = this.onlineBankingData?.payeeName
84-
this.cfsAccountId = this.onlineBankingData?.cfsAccountId || ''
85-
this.overCredit = this.onlineBankingData?.overCredit || false
86-
this.partialCredit = this.onlineBankingData?.partialCredit || false
87-
this.creditBalance = this.onlineBankingData?.creditBalance || 0
88-
this.credit = this.onlineBankingData?.credit || 0
89-
}
100+
onMounted(() => {
101+
updateOnlineBankingData()
102+
})
90103
91-
private mounted () {
92-
this.setData()
104+
return {
105+
...toRefs(state)
106+
}
93107
}
94-
}
108+
})
95109
</script>
96110

97111
<style lang="scss" scoped>

0 commit comments

Comments
 (0)