-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3178 - Updates to Provincial Daily Disbursement Report Sent to Finan…
…ce - CSV Sent By Email (Part 3) (#3506) As part of the story, the following changes are completed in this PR: - Created the new GC Notify template. - Created the DB migration for the new GC notify. - Prepared the manual SQL script to update email contacts on PROD and TEST. - Adjusted the report config `Daily_Disbursement_File` - Considered only the BC funding (BC or BP) - Ensured the following data from EDU.PBC.DIS.yyyyjjj.001 file is captured in each report. (See mockups for mapping) - **Full Time BC Loan** (DISB-TOT-DISB-AMT, total Federal or BC loan disbursed amount) - **Full Time BC Grant** (DISB-TOT-GRANT-DISB, total Federal or BC grant disbursed amount) - **Full Time BC Total** (SUM of the above two fields, i.e. FT BC loans + FT BC Grants) - **Part Time BC Grant** (DISB-TOT-GRANT-DISB - total Federal or BC grant disbursed amount) - **Part Time BC Total** (same as above field, i.e. PT BC Grants, because there are no BC loans) - **BC Total** (FT+PT) (NEW) (SUM of FT BC Total + PT BC total) - **Total Records** - **File Date** (NEW) (Row 11 in File Layouts) (Note: this reflects the date when the NSLSC file was produced) - **Batch Run Date** (NEW) This should correspond to the date the disbursement receipts were received through EDU.PBC.DIS.yyyyjjj.001. - **Sequence Number** (NEW) (Row 10 in Excel) (Note: this reflects sequence number as produced by NSLSC report - Generated the CSV from the scheduler after every file is imported, e.g. "Daily_Disbursement_File_2024-07-11.csv". - Added E2E tests - Updated fake email contacts before running E2E test cases. - Checked if the notification attachment is present. - Checked if the notification attachment has the expected values. Screenshot of the new GC Notify template: SIMS Daily Disbursement File ![image](https://github.com/bcgov/SIMS/assets/148148914/b3cb9a0e-ffe5-4c45-b3a4-645ee2ed92eb) Manual SQL script to update email contacts on **PROD**: ```sql UPDATE sims.notification_messages set email_contacts = '{"[email protected]","[email protected]","[email protected]"}' WHERE id = 27; ``` Manual SQL script to update email contacts on **TEST**: ```sql UPDATE sims.notification_messages set email_contacts = '{"[email protected]"}' WHERE id = 27; ``` Screenshot of the received email containing the daily disbursement file ![image](https://github.com/bcgov/SIMS/assets/148148914/e7f8fad5-35f3-4b1d-a34c-654ac8a5ecf6) Screenshot of an example for the daily disbursement CSV file ![image](https://github.com/user-attachments/assets/16147266-6d45-4813-b27a-ecb0f23c5725)
- Loading branch information
1 parent
b6db791
commit 7602475
Showing
12 changed files
with
500 additions
and
25 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...c/migrations/1720568459914-InsertMinistryNotificationProvincialDailyDisbursementReport.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class InsertMinistryNotificationProvincialDailyDisbursementReport1720568459914 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Insert-ministry-notification-provincial-daily-disbursement-report.sql", | ||
"NotificationMessages", | ||
), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-insert-ministry-notification-provincial-daily-disbursement-report.sql", | ||
"NotificationMessages", | ||
), | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...es/backend/apps/db-migrations/src/migrations/1720568581752-UpdateDailyDisbursementFile.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class UpdateDailyDisbursementFile1720568581752 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Update-daily-disbursement-file.sql", "Reports"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Rollback-update-daily-disbursement-file.sql", "Reports"), | ||
); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...otificationMessages/Insert-ministry-notification-provincial-daily-disbursement-report.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
INSERT INTO | ||
sims.notification_messages(id, description, template_id) | ||
VALUES | ||
( | ||
28, | ||
'Ministry notification for provincial daily disbursement report.', | ||
'730db0dc-967b-4adb-afa2-38235ad9f051' | ||
); |
4 changes: 4 additions & 0 deletions
4
...onMessages/Rollback-insert-ministry-notification-provincial-daily-disbursement-report.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DELETE FROM | ||
sims.notification_messages | ||
WHERE | ||
ID = 28; |
20 changes: 20 additions & 0 deletions
20
...es/backend/apps/db-migrations/src/sql/Reports/Rollback-update-daily-disbursement-file.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
UPDATE | ||
sims.report_configs | ||
SET | ||
report_sql = ( | ||
'select | ||
sum(dr.total_disbursed_amount) as "BC Student Loan", | ||
sum(drv.grant_amount) as "BC Student Grant", | ||
( | ||
sum(dr.total_disbursed_amount) + sum(drv.grant_amount) | ||
) as "BC Total", | ||
count(dr.id) as "Total Records" | ||
from | ||
sims.disbursement_receipts dr | ||
inner join sims.disbursement_receipt_values drv on dr.id = drv.disbursement_receipt_id | ||
where | ||
dr.batch_run_date = :batchRunDate | ||
and dr.funding_type = ''BC''' | ||
) | ||
WHERE | ||
report_name = 'Daily_Disbursement_File'; |
105 changes: 105 additions & 0 deletions
105
...es/packages/backend/apps/db-migrations/src/sql/Reports/Update-daily-disbursement-file.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
UPDATE | ||
sims.report_configs | ||
SET | ||
report_sql = ( | ||
'WITH disbursement_receipt_dataset AS ( | ||
SELECT | ||
disbursement_receipts.id, | ||
disbursement_receipts.total_disbursed_amount, | ||
disbursement_receipts.total_disbursed_grant_amount, | ||
disbursement_receipts.funding_type, | ||
disbursement_receipts.file_date, | ||
disbursement_receipts.batch_run_date, | ||
disbursement_receipts.sequence_number | ||
FROM | ||
sims.disbursement_receipts disbursement_receipts | ||
WHERE | ||
disbursement_receipts.funding_type IN (''BC'', ''BP'') | ||
AND disbursement_receipts.file_date = :fileDate | ||
AND disbursement_receipts.sequence_number = :sequenceNumber | ||
) | ||
SELECT | ||
SUM( | ||
disbursement_receipts."Full Time BC Student Loan" | ||
) AS "Full Time BC Student Loan", | ||
SUM( | ||
disbursement_receipts."Full Time BC Student Grant" | ||
) AS "Full Time BC Student Grant", | ||
SUM(disbursement_receipts."Full Time BC Total") AS "Full Time BC Total", | ||
SUM( | ||
disbursement_receipts."Part Time BC Student Grant" | ||
) AS "Part Time BC Student Grant", | ||
SUM(disbursement_receipts."Part Time BC Total") AS "Part Time BC Total", | ||
SUM(disbursement_receipts."BC Total") as "BC Total", | ||
SUM(disbursement_receipts."Total Records") AS "Total Records", | ||
CAST( | ||
disbursement_receipts."File Date" AS varchar | ||
) AS "File Date", | ||
CAST( | ||
disbursement_receipts."Batch Run Date" AS varchar | ||
) AS "Batch Run Date", | ||
disbursement_receipts."Sequence Number" | ||
FROM | ||
( | ||
SELECT | ||
SUM( | ||
full_time_disbursement_receipts.total_disbursed_amount | ||
) AS "Full Time BC Student Loan", | ||
SUM( | ||
full_time_disbursement_receipts.total_disbursed_grant_amount | ||
) AS "Full Time BC Student Grant", | ||
SUM( | ||
full_time_disbursement_receipts.total_disbursed_amount | ||
) AS "Full Time BC Total", | ||
0 AS "Part Time BC Student Grant", | ||
0 AS "Part Time BC Total", | ||
SUM( | ||
full_time_disbursement_receipts.total_disbursed_amount | ||
) AS "BC Total", | ||
COUNT(full_time_disbursement_receipts.id) AS "Total Records", | ||
full_time_disbursement_receipts.file_date AS "File Date", | ||
full_time_disbursement_receipts.batch_run_date AS "Batch Run Date", | ||
full_time_disbursement_receipts.sequence_number AS "Sequence Number" | ||
FROM | ||
disbursement_receipt_dataset full_time_disbursement_receipts | ||
WHERE | ||
full_time_disbursement_receipts.funding_type = ''BC'' | ||
GROUP BY | ||
"File Date", | ||
"Batch Run Date", | ||
"Sequence Number" | ||
UNION | ||
ALL | ||
SELECT | ||
0 AS "Full Time BC Student Loan", | ||
0 AS "Full Time BC Student Grant", | ||
0 AS "Full Time BC Total", | ||
SUM( | ||
part_time_disbursement_receipts.total_disbursed_grant_amount | ||
) AS "Part Time BC Student Grant", | ||
SUM( | ||
part_time_disbursement_receipts.total_disbursed_amount | ||
) AS "Part Time BC Total", | ||
SUM( | ||
part_time_disbursement_receipts.total_disbursed_amount | ||
) AS "BC Total", | ||
COUNT(part_time_disbursement_receipts.id) AS "Total Records", | ||
part_time_disbursement_receipts.file_date as "File Date", | ||
part_time_disbursement_receipts.batch_run_date as "Batch Run Date", | ||
part_time_disbursement_receipts.sequence_number as "Sequence Number" | ||
FROM | ||
disbursement_receipt_dataset part_time_disbursement_receipts | ||
WHERE | ||
part_time_disbursement_receipts.funding_type = ''BP'' | ||
GROUP BY | ||
"File Date", | ||
"Batch Run Date", | ||
"Sequence Number" | ||
) AS disbursement_receipts | ||
GROUP BY | ||
disbursement_receipts."File Date", | ||
disbursement_receipts."Batch Run Date", | ||
disbursement_receipts."Sequence Number";' | ||
) | ||
WHERE | ||
report_name = 'Daily_Disbursement_File'; |
Oops, something went wrong.