Skip to content

Commit

Permalink
[Version] Release 0.3.2 (#359)
Browse files Browse the repository at this point in the history
* Matthew Wang (#356)

* [Fix] Fix formatting of date in donation tax receipt number (#357)

* Fix month value indexing and padding in tax receipt number

* Switch to using formatDate function from date util

* Update permit holders report 2 (#358)

* Update permit holders report 2

* Format postal code

---------

Co-authored-by: Chinemerem <[email protected]>
Co-authored-by: Matthew Wang <[email protected]>
  • Loading branch information
3 people authored Apr 11, 2024
1 parent b94f013 commit b775102
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
8 changes: 7 additions & 1 deletion lib/invoices/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ const donationPdfDefinition = (input: {
nonNullEmail,
} = input;

const zeroPad = (num: number) => {
return ('0' + num.toString()).slice(-2);
};

return {
footer: function (currentPage: number, pageCount: number) {
return currentPage == pageCount
Expand Down Expand Up @@ -467,7 +471,9 @@ const donationPdfDefinition = (input: {
body: [
[
{ text: 'Tax Receipt #:' },
`PPD_${dateIssued.getFullYear()}${dateIssued.getMonth()}${dateIssued.getDate()}_${appNumber}`,
`PPD_${dateIssued.getFullYear()}` +
`${zeroPad(dateIssued.getMonth() + 1)}` +
`${zeroPad(dateIssued.getDate())}_${appNumber}`,
],
[
{ text: 'Donated by:' },
Expand Down
39 changes: 24 additions & 15 deletions lib/reports/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {
PaymentType,
} from '@lib/graphql/types';
import { SortOrder } from '@tools/types';
import { formatAddress, formatFullName, formatPhoneNumber } from '@lib/utils/format'; // Formatting utils
import {
formatFullName,
formatPhoneNumber,
formatPostalCode,
formatStreetAddress,
} from '@lib/utils/format'; // Formatting utils
import {
formatDateTimeYYYYMMDDHHMMSS,
formatDateYYYYMMDD,
Expand Down Expand Up @@ -107,8 +112,6 @@ export const generatePermitHoldersReport: Resolver<
dateOfBirth,
addressLine1,
addressLine2,
city,
province,
postalCode,
guardian,
permits,
Expand All @@ -121,7 +124,8 @@ export const generatePermitHoldersReport: Resolver<
applicantName: formatFullName(firstName, middleName, lastName),
dateOfBirth: formatDateYYYYMMDD(dateOfBirth),
age: moment().diff(dateOfBirth, 'years'),
homeAddress: formatAddress(addressLine1, addressLine2, city, postalCode, province),
address: formatStreetAddress(addressLine1, addressLine2),
postalCode: formatPostalCode(postalCode),
phone: formatPhoneNumber(phone),
rcdPermitId: `#${permits[0].rcdPermitId}`,
permitType: permits[0].type,
Expand All @@ -130,21 +134,26 @@ export const generatePermitHoldersReport: Resolver<
guardianPOAName:
guardian && formatFullName(guardian.firstName, guardian.middleName, guardian.lastName),
guardianAddress:
guardian &&
formatAddress(
guardian.addressLine1,
guardian.addressLine2,
guardian.city,
guardian.postalCode,
guardian.province
),
guardian && formatStreetAddress(guardian.addressLine1, guardian.addressLine2),
guardianCity: guardian && guardian.city,
guardianPostalCode:
guardian && guardian.postalCode && formatPostalCode(guardian.postalCode),
guardianProvince: guardian && guardian.province,
};
}
);

const csvHeaders = PERMIT_HOLDERS_COLUMNS.filter(({ value }) => columnsSet.has(value)).map(
({ name, reportColumnId }) => ({ id: reportColumnId, title: name })
);
const filteredColumns = PERMIT_HOLDERS_COLUMNS.filter(({ value }) => columnsSet.has(value));
const csvHeaders: Array<{ id: string; title: string }> = [];
for (const { name, reportColumnId } of filteredColumns) {
if (typeof reportColumnId === 'string') {
csvHeaders.push({ id: reportColumnId, title: name });
} else {
for (const [columnLabel, columnId] of reportColumnId) {
csvHeaders.push({ id: columnId, title: columnLabel });
}
}
}

// Generate CSV string from csv object.
const csvStringifier = createObjectCsvStringifier({
Expand Down
5 changes: 5 additions & 0 deletions prisma/dev-seed-utils/employees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const employees = [
lastName: 'Moraes',
email: '[email protected]',
},
{
firstName: 'Matthew',
lastName: 'Wang',
email: '[email protected]',
},
];

/**
Expand Down
16 changes: 13 additions & 3 deletions tools/admin/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const APPLICATIONS_COLUMNS: Array<{
export const PERMIT_HOLDERS_COLUMNS: Array<{
name: string;
value: PermitHoldersReportColumn;
reportColumnId: string;
reportColumnId: string | Array<[string, string]>;
}> = [
{
name: 'User ID',
Expand All @@ -105,7 +105,12 @@ export const PERMIT_HOLDERS_COLUMNS: Array<{
{
name: 'Home Address',
value: 'HOME_ADDRESS',
reportColumnId: 'homeAddress',
reportColumnId: [
['Address', 'address'],
['City', 'city'],
['Province', 'province'],
['Postal Code', 'postalCode'],
],
},
{
name: 'Email',
Expand All @@ -130,7 +135,12 @@ export const PERMIT_HOLDERS_COLUMNS: Array<{
{
name: 'Guardian/POA Address',
value: 'GUARDIAN_POA_ADDRESS',
reportColumnId: 'guardianAddress',
reportColumnId: [
['Guardian/POA Address', 'guardianAddress'],
['Guardian/POA City', 'guardianCity'],
['Guardian/POA Province', 'guardianProvince'],
['Guardian/POA Postal Code', 'guardianPostalCode'],
],
},
{
name: 'Recent APP Number',
Expand Down

0 comments on commit b775102

Please sign in to comment.