-
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.
- Loading branch information
1 parent
087250a
commit 37148d4
Showing
4 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...-migrations/src/migrations/1732672366956-UpdateDisbursementsWithoutValidSupplierReport.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 UpdateDisbursementsWithoutValidSupplierReport1732672366956 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Update-disbursements-without-valid-supplier-report.sql", | ||
"Reports", | ||
), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-update-disbursements-without-valid-supplier-report.sql", | ||
"Reports", | ||
), | ||
); | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
...igrations/src/sql/Reports/Rollback-update-disbursements-without-valid-supplier-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,55 @@ | ||
UPDATE | ||
sims.report_configs | ||
SET | ||
report_sql = ( | ||
'SELECT | ||
users.first_name AS "Given Name", | ||
users.last_name AS "Last Name", | ||
sin_validations.sin AS "SIN", | ||
users.identity_provider_type AS "Profile Type", | ||
students.contact_info -> ''address'' ->> ''addressLine1'' AS "Address Line 1", | ||
students.contact_info -> ''address'' ->> ''city'' AS "City", | ||
students.contact_info -> ''address'' ->> ''provinceState'' AS "Province", | ||
students.contact_info -> ''address'' ->> ''country'' AS "Country", | ||
students.contact_info -> ''address'' ->> ''postalCode'' AS "Postal Code", | ||
students.disability_status AS "Disability Status", | ||
SUM( | ||
CASE | ||
WHEN disbursement_values.value_code = ''BCAG'' THEN disbursement_values.effective_amount | ||
ELSE 0 | ||
END | ||
) AS "BCAG", | ||
SUM( | ||
CASE | ||
WHEN disbursement_values.value_code = ''SBSD'' THEN disbursement_values.effective_amount | ||
ELSE 0 | ||
END | ||
) AS "SBSD", | ||
SUM( | ||
CASE | ||
WHEN disbursement_values.value_code = ''BGPD'' THEN disbursement_values.effective_amount | ||
ELSE 0 | ||
END | ||
) AS "BGPD" | ||
FROM | ||
sims.students students | ||
INNER JOIN sims.users users ON students.user_id = users.id | ||
INNER JOIN sims.sin_validations sin_validations ON students.id = sin_validations.student_id | ||
INNER JOIN sims.cas_suppliers cas_suppliers ON cas_suppliers.student_id = students.id | ||
INNER JOIN sims.applications applications ON applications.student_id = students.id | ||
INNER JOIN sims.student_assessments student_assessments ON student_assessments.application_id = applications.id | ||
INNER JOIN sims.disbursement_schedules disbursement_schedules ON disbursement_schedules.student_assessment_id = student_assessments.id | ||
INNER JOIN sims.disbursement_values disbursement_values ON disbursement_values.disbursement_schedule_id = disbursement_schedules.id | ||
WHERE | ||
disbursement_schedules.disbursement_schedule_status = ''Sent'' | ||
AND disbursement_schedules.date_sent BETWEEN :startDate | ||
AND :endDate | ||
AND cas_suppliers.is_valid = false | ||
GROUP BY | ||
users.id, | ||
sin_validations.sin, | ||
students.contact_info, | ||
students.disability_status;' | ||
) | ||
WHERE | ||
report_name = 'Disbursements_Without_Valid_Supplier_Report'; |
55 changes: 55 additions & 0 deletions
55
...apps/db-migrations/src/sql/Reports/Update-disbursements-without-valid-supplier-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,55 @@ | ||
UPDATE | ||
sims.report_configs | ||
SET | ||
report_sql = ( | ||
'SELECT | ||
users.first_name AS "Given Name", | ||
users.last_name AS "Last Name", | ||
sin_validations.sin AS "SIN", | ||
users.identity_provider_type AS "Profile Type", | ||
students.contact_info -> ''address'' ->> ''addressLine1'' AS "Address Line 1", | ||
students.contact_info -> ''address'' ->> ''city'' AS "City", | ||
students.contact_info -> ''address'' ->> ''provinceState'' AS "Province", | ||
students.contact_info -> ''address'' ->> ''country'' AS "Country", | ||
students.contact_info -> ''address'' ->> ''postalCode'' AS "Postal Code", | ||
students.disability_status AS "Disability Status", | ||
SUM( | ||
CASE | ||
WHEN disbursement_values.value_code = ''BCAG'' THEN disbursement_values.effective_amount | ||
ELSE 0 | ||
END | ||
) AS "BCAG", | ||
SUM( | ||
CASE | ||
WHEN disbursement_values.value_code = ''SBSD'' THEN disbursement_values.effective_amount | ||
ELSE 0 | ||
END | ||
) AS "SBSD", | ||
SUM( | ||
CASE | ||
WHEN disbursement_values.value_code = ''BGPD'' THEN disbursement_values.effective_amount | ||
ELSE 0 | ||
END | ||
) AS "BGPD" | ||
FROM | ||
sims.students students | ||
INNER JOIN sims.users users ON students.user_id = users.id | ||
INNER JOIN sims.sin_validations sin_validations ON students.sin_validation_id = sin_validations.id | ||
INNER JOIN sims.cas_suppliers cas_suppliers ON students.cas_supplier_id = cas_suppliers.id | ||
INNER JOIN sims.applications applications ON applications.student_id = students.id | ||
INNER JOIN sims.student_assessments student_assessments ON student_assessments.application_id = applications.id | ||
INNER JOIN sims.disbursement_schedules disbursement_schedules ON disbursement_schedules.student_assessment_id = student_assessments.id | ||
INNER JOIN sims.disbursement_values disbursement_values ON disbursement_values.disbursement_schedule_id = disbursement_schedules.id | ||
WHERE | ||
disbursement_schedules.disbursement_schedule_status = ''Sent'' | ||
AND disbursement_schedules.date_sent BETWEEN :startDate | ||
AND :endDate | ||
AND cas_suppliers.is_valid = false | ||
GROUP BY | ||
users.id, | ||
sin_validations.sin, | ||
students.contact_info, | ||
students.disability_status;' | ||
) | ||
WHERE | ||
report_name = 'Disbursements_Without_Valid_Supplier_Report'; |