Skip to content

Commit 4df7325

Browse files
authored
31950 - Fix dropdown item missing in Staff Dashboard transactions (#3573)
1 parent e9cbc0c commit 4df7325

File tree

5 files changed

+112
-9
lines changed

5 files changed

+112
-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.10.31",
3+
"version": "2.10.32",
44
"appName": "Auth Web",
55
"sbcName": "SBC Common Components",
66
"private": true,

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,42 @@
217217
:key="dropdownItem.id"
218218
class="dropdown-row"
219219
>
220+
<td
221+
v-if="isColumnVisible('accountName')"
222+
class="dropdown-cell"
223+
>
224+
<span class="dropdown-item-name">{{ dropdownItem.accountName || 'N/A' }}</span>
225+
</td>
226+
<td
227+
v-if="isColumnVisible('product')"
228+
class="dropdown-cell"
229+
>
230+
<span class="dropdown-item-product">{{ dropdownItem.product }}</span>
231+
</td>
232+
<td
233+
v-if="isColumnVisible('lineItems')"
234+
class="dropdown-cell"
235+
>
236+
<span
237+
class="dropdown-item-lineitems"
238+
v-html="dropdownItem.lineItems"
239+
/>
240+
</td>
241+
<td
242+
v-if="isColumnVisible('details')"
243+
class="dropdown-cell"
244+
>
245+
<span
246+
class="dropdown-item-details"
247+
v-html="dropdownItem.details"
248+
/>
249+
</td>
250+
<td
251+
v-if="isColumnVisible('businessIdentifier')"
252+
class="dropdown-cell"
253+
>
254+
<span class="dropdown-item-businessid">{{ dropdownItem.businessIdentifier }}</span>
255+
</td>
220256
<td
221257
v-if="isColumnVisible('lineItemsAndDetails')"
222258
class="dropdown-cell"
@@ -314,7 +350,9 @@
314350
<v-icon color="primary">
315351
mdi-file-pdf-outline
316352
</v-icon>
317-
<span>Receipt</span>
353+
<span>
354+
Receipt
355+
</span>
318356
</div>
319357
<!-- Empty cell for downloads column -->
320358
<div v-else />
@@ -335,6 +373,7 @@
335373
import { BaseVDataTable, DatePicker, IconTooltip } from '@/components'
336374
import { InvoiceStatus, LDFlags, PaymentTypes, SessionStorageKeys } from '@/util/constants'
337375
import { Ref, computed, defineComponent, nextTick, reactive, ref, toRefs, watch } from '@vue/composition-api'
376+
import { getApplicationType, getLineItemsDescription, getTransactionDetails } from '@/resources/table-headers/transactions-table/headers'
338377
import { invoiceStatusDisplay, paymentTypeDisplay } from '@/resources/display-mappers'
339378
import { BaseTableHeaderI } from '@/components/datatable/interfaces'
340379
import CommonUtils from '@/util/common-util'
@@ -499,6 +538,11 @@ export default defineComponent({
499538
folioNumber: item.folioNumber,
500539
createdName: item.createdName,
501540
invoiceNumber: item.invoiceNumber,
541+
accountName: item.paymentAccount.accountName,
542+
lineItems: getLineItemsDescription(item),
543+
details: getTransactionDetails(item),
544+
businessIdentifier: item.businessIdentifier || 'N/A',
545+
product: getApplicationType(item),
502546
...overrides
503547
})
504548
@@ -534,6 +578,7 @@ export default defineComponent({
534578
// Add remaining amount if any
535579
if (remainingAmount > 0) {
536580
items.push(createDropdownItem(item, {
581+
name: item.createdName || 'N/A',
537582
id: `remaining-${item.id}`,
538583
type: '',
539584
date: item.appliedCredits[0].createdOn,

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ import CommonUtils from '@/util/common-util'
55
import { Transaction } from '@/models/transaction'
66
import moment from 'moment'
77

8+
export const getLineItemsDescription = (val: Transaction): string => {
9+
return val.lineItems.reduce((resp, lineItem) => `${resp + lineItem.description}<br/>`, '')
10+
}
11+
12+
export const getTransactionDetails = (val: Transaction): string => {
13+
return val.details?.reduce((resp, detail) => `${resp}${detail.label || ''} ${detail.value}<br/>`, '') || 'N/A'
14+
}
15+
16+
export const getApplicationType = (val: Transaction): string => {
17+
return (Object.keys(productDisplay)).includes(val.product) ? productDisplay[val.product] : ''
18+
}
19+
820
export const TransactionTableHeaders: BaseTableHeaderI[] = [
921
{
1022
col: 'accountName',
@@ -41,7 +53,7 @@ export const TransactionTableHeaders: BaseTableHeaderI[] = [
4153
value: ''
4254
},
4355
hasFilter: true,
44-
itemFn: (val: Transaction) => (Object.keys(productDisplay)).includes(val.product) ? productDisplay[val.product] : '',
56+
itemFn: getApplicationType,
4557
minWidth: '200px',
4658
value: 'Application Type'
4759
},
@@ -68,7 +80,7 @@ export const TransactionTableHeaders: BaseTableHeaderI[] = [
6880
},
6981
hasFilter: true,
7082
itemClass: 'line-item',
71-
itemFn: (val: Transaction) => val.lineItems.reduce((resp, lineItem) => `${resp + lineItem.description}<br/>`, ''),
83+
itemFn: getLineItemsDescription,
7284
minWidth: '200px',
7385
value: 'Transaction Type'
7486
},
@@ -81,7 +93,7 @@ export const TransactionTableHeaders: BaseTableHeaderI[] = [
8193
value: ''
8294
},
8395
hasFilter: true,
84-
itemFn: (val: Transaction) => val.details?.reduce((resp, detail) => `${resp}${detail.label || ''} ${detail.value}<br/>`, '') || 'N/A',
96+
itemFn: getTransactionDetails,
8597
minWidth: '200px',
8698
value: 'Transaction Details'
8799
},
@@ -226,7 +238,7 @@ export const TransactionTableHeaders: BaseTableHeaderI[] = [
226238
{ text: invoiceStatusDisplay[InvoiceStatus.DELETED], value: InvoiceStatus.DELETED },
227239
// These are FE only on the backend they are PAID
228240
{ text: invoiceStatusDisplay[InvoiceStatus.PARTIALLY_CREDITED], value: InvoiceStatus.PARTIALLY_CREDITED },
229-
{ text: invoiceStatusDisplay[InvoiceStatus.PARTIALLY_REFUNDED], value: InvoiceStatus.PARTIALLY_REFUNDED },
241+
{ text: invoiceStatusDisplay[InvoiceStatus.PARTIALLY_REFUNDED], value: InvoiceStatus.PARTIALLY_REFUNDED }
230242
],
231243
label: 'Status',
232244
type: 'select',

auth-web/tests/unit/components/TransactionsDataTable.spec.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../test-utils/composition-api-setup' // important to import this first
2-
import { InvoiceStatus, PaymentTypes, LDFlags } from '@/util/constants'
2+
import { InvoiceStatus, LDFlags, PaymentTypes } from '@/util/constants'
33
import { Wrapper, createLocalVue, mount } from '@vue/test-utils'
44
import { BaseVDataTable } from '@/components/datatable'
55
import { DatePicker } from '@/components'
@@ -458,4 +458,50 @@ describe('TransactionsDataTable tests', () => {
458458
expect(wrapper.vm.canDownloadReceipt(creditedTransaction, false)).toBe(true)
459459
expect(wrapper.vm.canDownloadReceipt(creditedTransaction, true)).toBe(true)
460460
})
461+
462+
it('dropdown should populate all fields from createDropdownItem correctly', async () => {
463+
const transaction = createTestTransaction({
464+
statusCode: InvoiceStatus.REFUNDED,
465+
paymentMethod: PaymentTypes.DIRECT_PAY,
466+
total: 100,
467+
refundDate: '2023-01-02T10:00:00Z',
468+
lineItems: [
469+
{ description: 'Change of Director', quantity: 1, price: 100 },
470+
{ description: 'Annual Report', quantity: 1, price: 50 }
471+
],
472+
details: [
473+
{ label: 'Incorporation Number:', value: 'BC0888888' },
474+
{ label: 'Company Name:', value: 'Test Company' }
475+
],
476+
businessIdentifier: 'BC0888888',
477+
folioNumber: 'FOLIO456',
478+
createdName: 'Joe Doe',
479+
invoiceNumber: 'INV456'
480+
})
481+
482+
const { wrapper: testWrapper } = await setupTransactionTest(transaction, wrapper)
483+
484+
const dropdownItems = testWrapper.vm.getDropdownItems(transaction)
485+
expect(dropdownItems.length).toBeGreaterThan(0)
486+
487+
const refundItem = dropdownItems[0]
488+
489+
expect(refundItem.accountName).toBe(transaction.paymentAccount.accountName)
490+
expect(refundItem.folioNumber).toBe(transaction.folioNumber)
491+
expect(refundItem.createdName).toBe(transaction.createdName)
492+
expect(refundItem.invoiceNumber).toBe(transaction.invoiceNumber)
493+
expect(refundItem.lineItems).toContain('Change of Director')
494+
expect(refundItem.lineItems).toContain('Annual Report')
495+
expect(refundItem.lineItems).toContain('<br/>')
496+
expect(refundItem.details).toContain('Incorporation Number:')
497+
expect(refundItem.details).toContain('BC0888888')
498+
expect(refundItem.details).toContain('Company Name:')
499+
expect(refundItem.details).toContain('Test Company')
500+
expect(refundItem.details).toContain('<br/>')
501+
expect(refundItem.businessIdentifier).toBe('BC0888888')
502+
expect(refundItem.type).toBe('Refund')
503+
expect(refundItem.amount).toBe('-$100.00')
504+
expect(refundItem.isRefund).toBe(true)
505+
expect(refundItem.status).toBe('Refunded')
506+
})
461507
})

0 commit comments

Comments
 (0)