Skip to content

Commit 8bec776

Browse files
Implementation of receipt downloads on Transactions table
1 parent 6d89667 commit 8bec776

File tree

7 files changed

+54
-9
lines changed

7 files changed

+54
-9
lines changed

auth-web/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

auth-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auth-web",
3-
"version": "2.7.8",
3+
"version": "2.7.9",
44
"appName": "Auth Web",
55
"sbcName": "SBC Common Components",
66
"private": true,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ export default defineComponent({
146146
})
147147
148148
// dynamic header selection stuff
149-
let preSelectedHeaders = ['createdOn', 'total', 'paymentMethod', 'statusCode', 'actions']
150-
if (props.extended) preSelectedHeaders = ['accountName', 'appType', 'lineItems', ...preSelectedHeaders]
149+
let preSelectedHeaders = ['createdOn', 'total', 'paymentMethod', 'statusCode', 'downloads', 'actions']
150+
if (props.extended) preSelectedHeaders = ['accountName', 'appType', 'lineItems', 'downloads', ...preSelectedHeaders]
151151
else preSelectedHeaders = ['lineItemsAndDetails', ...preSelectedHeaders]
152152
153153
const headerSelections: BaseTableHeaderI[] = [] // what the user sees in the dropdown

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,22 @@
139139
</v-col>
140140
</v-row>
141141
</template>
142+
<template #item-slot-downloads="{ item }">
143+
<div
144+
v-if="item.statusCode === InvoiceStatus.COMPLETED"
145+
class="receipt"
146+
@click="downloadReceipt(item)"
147+
>
148+
<v-icon
149+
color="primary"
150+
>
151+
mdi-file-pdf-outline
152+
</v-icon>
153+
<span>
154+
Receipt
155+
</span>
156+
</div>
157+
</template>
142158
</BaseVDataTable>
143159
</div>
144160
</template>
@@ -151,6 +167,7 @@ import { BaseTableHeaderI } from '@/components/datatable/interfaces'
151167
import CommonUtils from '@/util/common-util'
152168
import { DEFAULT_DATA_OPTIONS } from '@/components/datatable/resources'
153169
import { DataOptions } from 'vuetify'
170+
import PaymentService from '@/services/payment.services'
154171
import { Transaction } from '@/models'
155172
import _ from 'lodash'
156173
import { invoiceStatusDisplay } from '@/resources/display-mappers'
@@ -254,6 +271,13 @@ export default defineComponent({
254271
}
255272
})
256273
274+
async function downloadReceipt (item: Transaction) {
275+
const receipt = await PaymentService.postReceipt(item.id);
276+
console.log(item);
277+
const filename = `bcregistry-receipts-${item.id}.pdf`
278+
CommonUtils.fileDownload(receipt.data, filename, 'application/pdf')
279+
}
280+
257281
const displayDate = (val: string) => {
258282
const date = moment.utc(val).toDate()
259283
return CommonUtils.formatDisplayDate(date, 'MMMM DD, YYYY')
@@ -289,13 +313,18 @@ export default defineComponent({
289313
updateDateRange,
290314
loadTransactionList,
291315
getInvoiceStatus,
292-
datePickerValue
316+
datePickerValue,
317+
downloadReceipt
293318
}
294319
}
295320
})
296321
</script>
297322

298323
<style lang="scss" scoped>
324+
.receipt {
325+
cursor: pointer;
326+
color: var(--v-primary-base);
327+
}
299328
.section-heading {
300329
background-color: $app-background-blue;
301330
border-radius: 5px 5px 0 0;

auth-web/src/resources/table-headers/transactions-table/headers.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,12 @@ export const TransactionTableHeaders: BaseTableHeaderI[] = [
223223
minWidth: '164px',
224224
value: '',
225225
width: '164px'
226-
}
226+
},
227+
{
228+
col: 'downloads',
229+
hasFilter: false,
230+
itemClass: 'line-item',
231+
width: '164px',
232+
value: 'Downloads'
233+
},
227234
]

auth-web/src/resources/table-headers/transactions-table/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export const getTransactionTableHeaders = (extended = false): BaseTableHeaderI[]
77
let headerTitles = []
88
if (extended) {
99
headerTitles = ['accountName', 'product', 'lineItems', 'details', 'businessIdentifier', 'folioNumber',
10-
'createdName', 'createdOn', 'total', 'id', 'invoiceNumber', 'paymentMethod', 'statusCode', 'actions']
10+
'createdName', 'createdOn', 'total', 'id', 'invoiceNumber', 'paymentMethod', 'statusCode', 'downloads', 'actions']
1111
} else {
1212
headerTitles = ['lineItemsAndDetails', 'folioNumber', 'createdName', 'createdOn',
13-
'total', 'id', 'invoiceNumber', 'paymentMethod', 'statusCode', 'actions']
13+
'total', 'id', 'invoiceNumber', 'paymentMethod', 'statusCode', 'downloads', 'actions']
1414
}
1515

1616
for (const i in headerTitles) {

auth-web/src/services/payment.services.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ export default class PaymentService {
5252
return axios.post(url, refundPayload)
5353
}
5454

55+
static postReceipt (invoiceId: string | number): AxiosPromise<any> {
56+
const url = `${ConfigHelper.getPayAPIURL()}/payment-requests/${invoiceId}/receipts`
57+
const headers = { 'Accept': 'application/pdf' }
58+
const body = {
59+
filingDateTime: new Date().toLocaleDateString('en-CA', { year: 'numeric', month: 'long', day: 'numeric' })
60+
}
61+
return axios.post(url, body, { headers, responseType: 'blob' as 'json' })
62+
}
63+
5564
static refundEFT (refundPayload: EftRefundRequest): AxiosPromise<any> {
5665
const url = `${ConfigHelper.getPayAPIURL()}/eft-shortnames/shortname-refund`
5766
return axios.post(url, refundPayload)

0 commit comments

Comments
 (0)