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

[Fix] Fix second payment method reports #352

Merged
merged 1 commit into from
Feb 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
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
Loading