Skip to content

Commit

Permalink
#3178 - Updates to Provincial Daily Disbursement Report Sent to Finan…
Browse files Browse the repository at this point in the history
…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
lewischen-aot authored Jul 16, 2024
1 parent b6db791 commit 7602475
Show file tree
Hide file tree
Showing 12 changed files with 500 additions and 25 deletions.
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",
),
);
}
}
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"),
);
}
}
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'
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DELETE FROM
sims.notification_messages
WHERE
ID = 28;
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';
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';
Loading

0 comments on commit 7602475

Please sign in to comment.