Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21999 - EFT screens enhancements - Numerical formatting changes from Finance #2935

Merged
merged 7 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auth-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth-web",
"version": "2.6.56",
"version": "2.6.57",
"appName": "Auth Web",
"sbcName": "SBC Common Components",
"private": true,
Expand Down
8 changes: 7 additions & 1 deletion auth-web/src/components/pay/eft/ShortNameTransactions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
>
mdi-format-list-bulleted
</v-icon>
Payment History
Short Name Payment History
</h2>
</template>
<template #header-filter-slot />
Expand All @@ -46,6 +46,7 @@
</template>
<template #item-slot-transactionAmount="{ item }">
<span>{{ formatTransactionAmount(item) }}</span>
<span class="transaction-details">{{ formatBalanceAmount(item) }}</span>
</template>
</BaseVDataTable>
</template>
Expand Down Expand Up @@ -158,8 +159,13 @@ export default defineComponent({
}
return amount
}
function formatBalanceAmount (item: any) {
if (item.balance === undefined) return ''
return `Balance: ${CommonUtils.formatAmount(item.balance)}`
}

return {
formatBalanceAmount,
formatTransactionAmount,
formatDate: CommonUtils.formatDisplayDate,
formatAccountDisplayName: CommonUtils.formatAccountDisplayName,
Expand Down
7 changes: 6 additions & 1 deletion auth-web/src/util/common-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ export default class CommonUtils {

// Format amount for displaying dollar currency
static formatAmount (amount: number): string {
return `$${amount.toFixed(2)}`
return amount.toLocaleString('en-CA', {
style: 'currency',
currency: 'CAD',
minimumFractionDigits: 2,
maximumFractionDigits: 2
})
}

// Formatting date in the desired format for displaying in the template
Expand Down
3 changes: 2 additions & 1 deletion auth-web/tests/unit/components/LinkedShortNameTable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Wrapper, createLocalVue, mount } from '@vue/test-utils'
import { BaseVDataTable } from '@/components'
import CommonUtils from '@/util/common-util'
import LinkedShortNameTableVue from '@/components/pay/LinkedShortNameTable.vue'
import { VueConstructor } from 'vue'
import Vuetify from 'vuetify'
Expand Down Expand Up @@ -112,7 +113,7 @@ describe('LinkedShortNameTable.vue', () => {
expect(columns.at(1).text()).toBe(linkedShortNameResponse.items[i].accountName)
expect(columns.at(2).text()).toBe(linkedShortNameResponse.items[i].accountBranch)
expect(columns.at(3).text()).toBe(linkedShortNameResponse.items[i].accountId)
expect(columns.at(4).text()).toBe(`$${linkedShortNameResponse.items[i].amountOwing.toFixed(2)}`)
expect(columns.at(4).text()).toBe(`${CommonUtils.formatAmount(linkedShortNameResponse.items[i].amountOwing)}`)
expect(columns.at(5).text()).toBe(linkedShortNameResponse.items[i].statementId.toString())
}
})
Expand Down
4 changes: 2 additions & 2 deletions auth-web/tests/unit/components/Statements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ describe('Statements.vue', () => {
})
expect(wrapper.vm.formatAmount(0)).toBe('$0.00')
expect(wrapper.vm.formatAmount(1)).toBe('$1.00')
expect(wrapper.vm.formatAmount(1000)).toBe('$1000.00')
expect(wrapper.vm.formatAmount(1000.1)).toBe('$1000.10')
expect(wrapper.vm.formatAmount(1000)).toBe('$1,000.00')
expect(wrapper.vm.formatAmount(1000.1)).toBe('$1,000.10')
wrapper.destroy()
})

Expand Down
4 changes: 4 additions & 0 deletions auth-web/tests/unit/util/common-util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ describe('Common Util Test', () => {
expect(CommonUtil.trimTrailingSlashURL('abc/')).toBe('abc')
})

it('formatAmount returns formatted amount', () => {
expect(CommonUtil.formatAmount(1234.567)).toBe('$1,234.57')
})

afterEach(() => {
window.location.pathname = pathname
})
Expand Down
Loading