Skip to content

Commit a2e3fa2

Browse files
authored
28456 - Fix for when account credit covers entire amount and partial refund e… (#3482)
1 parent c6ac139 commit a2e3fa2

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,17 @@ export default defineComponent({
378378
}
379379
380380
const hasDropdownContent = (item: Transaction): boolean => {
381+
const hasPartialRefunds = item.partialRefunds?.length > 0
382+
let hasAppliedCreditsWithRemaining = false
381383
if (item.appliedCredits?.length > 0) {
382384
const totalAppliedCredits = item.appliedCredits.reduce((sum, credit) => sum + credit.amountApplied, 0)
383385
const remainingAmount = item.total - totalAppliedCredits
384-
return remainingAmount > 0
386+
hasAppliedCreditsWithRemaining = remainingAmount > 0
385387
}
386388
387-
const hasContent = item.statusCode === InvoiceStatus.CREDITED ||
388-
item.partialRefunds?.length > 0 ||
389-
item.statusCode === InvoiceStatus.REFUNDED
390-
return hasContent
389+
const hasRefundStatus = item.statusCode === InvoiceStatus.CREDITED ||
390+
item.statusCode === InvoiceStatus.REFUNDED
391+
return hasPartialRefunds || hasAppliedCreditsWithRemaining || hasRefundStatus
391392
}
392393
393394
const expandedState = computed(() => {

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,4 +394,42 @@ describe('TransactionsDataTable tests', () => {
394394
{ type: 'Refund as credits', paymentMethod: 'Account Credit' }
395395
])
396396
})
397+
398+
it('PAID with full applied credit AND partial credit [PAD] - should show both applied credit and partial credit in dropdown', async () => {
399+
const transaction = createTestTransaction({
400+
statusCode: InvoiceStatus.PAID,
401+
paymentMethod: PaymentTypes.PAD,
402+
total: 100,
403+
appliedCredits: [createAppliedCredit({ id: 1, amountApplied: 100 })], // Covers full amount
404+
partialRefunds: [createPartialRefund({
405+
isCredit: true,
406+
refundAmount: 30,
407+
createdName: 'Test User',
408+
createdBy: 'testuser',
409+
id: 1,
410+
createdOn: new Date('2023-01-01T10:00:00Z')
411+
})]
412+
})
413+
414+
const { wrapper: testWrapper } = await setupTransactionTest(transaction, wrapper)
415+
416+
expect(testWrapper.vm.hasDropdownContent(transaction)).toBe(true)
417+
418+
const dropdownItems = testWrapper.vm.getDropdownItems(transaction)
419+
420+
expect(dropdownItems).toHaveLength(2)
421+
422+
const appliedCreditItem = dropdownItems.find(item => item.id === 'credit-1')
423+
expect(appliedCreditItem).toBeTruthy()
424+
expect(appliedCreditItem.amount).toBe('$100.00')
425+
expect(appliedCreditItem.paymentMethod).toBe('Account Credit')
426+
expect(appliedCreditItem.isRefund).toBe(false)
427+
428+
const partialCreditItem = dropdownItems.find(item => item.isRefund)
429+
expect(partialCreditItem).toBeTruthy()
430+
expect(partialCreditItem.amount).toBe('-$30.00')
431+
expect(partialCreditItem.paymentMethod).toBe('Account Credit')
432+
expect(partialCreditItem.type).toBe('Refund as credits')
433+
expect(partialCreditItem.status).toBe('Partially Credited')
434+
})
397435
})

0 commit comments

Comments
 (0)