Skip to content

Commit

Permalink
Fix second payment method reports (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
leogjhuang committed Feb 25, 2024
1 parent 35571cf commit f1a7b00
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ export type ApplicationsReportColumn =
| 'PAYMENT_METHOD'
| 'FEE_AMOUNT'
| 'DONATION_AMOUNT'
| 'SECOND_PAYMENT_METHOD'
| 'SECOND_FEE_AMOUNT'
| 'SECOND_DONATION_AMOUNT'
| 'TOTAL_AMOUNT';

export type ApplicationsResult = {
Expand Down
6 changes: 4 additions & 2 deletions lib/reports/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ export const generateApplicationsReport: Resolver<
dateOfBirth: dateOfBirth && formatDateYYYYMMDD(dateOfBirth),
applicationDate: createdAt ? formatDateYYYYMMDDLocal(createdAt, true) : null,
applicantName: formatFullName(firstName, middleName, lastName),
processingFee: `$${Prisma.Decimal.add(processingFee, secondProcessingFee || 0)}`,
donationAmount: `$${Prisma.Decimal.add(donationAmount, secondDonationAmount || 0)}`,
processingFee: `$${processingFee}`,
donationAmount: `$${donationAmount}`,
secondProcessingFee: `$${secondProcessingFee || 0}`,
secondDonationAmount: `$${secondDonationAmount || 0}`,
totalAmount: `$${Prisma.Decimal.add(
Prisma.Decimal.add(processingFee, donationAmount),
Prisma.Decimal.add(secondProcessingFee || 0, secondDonationAmount || 0)
Expand Down
3 changes: 3 additions & 0 deletions lib/reports/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default gql`
PAYMENT_METHOD
FEE_AMOUNT
DONATION_AMOUNT
SECOND_PAYMENT_METHOD
SECOND_FEE_AMOUNT
SECOND_DONATION_AMOUNT
TOTAL_AMOUNT
}
Expand Down
15 changes: 15 additions & 0 deletions tools/admin/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ export const APPLICATIONS_COLUMNS: Array<{
value: 'DONATION_AMOUNT',
reportColumnId: 'donationAmount',
},
{
name: 'Second Payment Method',
value: 'SECOND_PAYMENT_METHOD',
reportColumnId: 'secondPaymentMethod',
},
{
name: 'Second Fee Amount',
value: 'SECOND_FEE_AMOUNT',
reportColumnId: 'secondProcessingFee',
},
{
name: 'Second Donation Amount',
value: 'SECOND_DONATION_AMOUNT',
reportColumnId: 'secondDonationAmount',
},
{
name: 'Total Amount',
value: 'TOTAL_AMOUNT',
Expand Down

0 comments on commit f1a7b00

Please sign in to comment.