From a54bead4cef437a3fb08b61d303ed8c42182b5c6 Mon Sep 17 00:00:00 2001 From: Yazeed Loonat Date: Thu, 31 Aug 2023 15:00:26 -0700 Subject: [PATCH] feat: creating new SMC ami charts (#640) --- .../ami-chart-import-files/SMC-HUD-2023.ts | 248 ++++++++++ .../ami-chart-import-files/SMC-HUD-2023.txt | 6 + .../ami-chart-import-files/SMC-TCAC-2023.ts | 448 ++++++++++++++++++ .../ami-chart-import-files/SMC-TCAC-2023.txt | 11 + ...t-import-script.sh => ami-chart-import.sh} | 24 +- .../1693242578397-new-smc-ami-charts-2023.ts | 29 ++ 6 files changed, 752 insertions(+), 14 deletions(-) create mode 100644 backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.ts create mode 100644 backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.txt create mode 100644 backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.ts create mode 100644 backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.txt rename backend/core/scripts/{ami-chart-import-script.sh => ami-chart-import.sh} (79%) create mode 100644 backend/core/src/migration/1693242578397-new-smc-ami-charts-2023.ts diff --git a/backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.ts b/backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.ts new file mode 100644 index 0000000000..00734319a0 --- /dev/null +++ b/backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.ts @@ -0,0 +1,248 @@ +import { AmiChartCreateDto } from "../../src/ami-charts/dto/ami-chart.dto" +import { BaseEntity } from "typeorm" +// THIS FILE WAS AUTOMATICALLY GENERATED FROM SMC-HUD-2023.txt. +export const ami: Omit = { + name: "San Mateo County HUD 2023", + items: [ + { + percentOfAmi: 15, + householdSize: 1, + income: 18400, + }, + { + percentOfAmi: 15, + householdSize: 2, + income: 21000, + }, + { + percentOfAmi: 15, + householdSize: 3, + income: 23650, + }, + { + percentOfAmi: 15, + householdSize: 4, + income: 26250, + }, + { + percentOfAmi: 15, + householdSize: 5, + income: 28350, + }, + { + percentOfAmi: 15, + householdSize: 6, + income: 30450, + }, + { + percentOfAmi: 15, + householdSize: 7, + income: 32550, + }, + { + percentOfAmi: 15, + householdSize: 8, + income: 34650, + }, + { + percentOfAmi: 30, + householdSize: 1, + income: 39150, + }, + { + percentOfAmi: 30, + householdSize: 2, + income: 44750, + }, + { + percentOfAmi: 30, + householdSize: 3, + income: 50350, + }, + { + percentOfAmi: 30, + householdSize: 4, + income: 55900, + }, + { + percentOfAmi: 30, + householdSize: 5, + income: 60400, + }, + { + percentOfAmi: 30, + householdSize: 6, + income: 64850, + }, + { + percentOfAmi: 30, + householdSize: 7, + income: 69350, + }, + { + percentOfAmi: 30, + householdSize: 8, + income: 73800, + }, + { + percentOfAmi: 50, + householdSize: 1, + income: 65250, + }, + { + percentOfAmi: 50, + householdSize: 2, + income: 74600, + }, + { + percentOfAmi: 50, + householdSize: 3, + income: 83900, + }, + { + percentOfAmi: 50, + householdSize: 4, + income: 93200, + }, + { + percentOfAmi: 50, + householdSize: 5, + income: 100700, + }, + { + percentOfAmi: 50, + householdSize: 6, + income: 108150, + }, + { + percentOfAmi: 50, + householdSize: 7, + income: 115600, + }, + { + percentOfAmi: 50, + householdSize: 8, + income: 123050, + }, + { + percentOfAmi: 80, + householdSize: 1, + income: 104400, + }, + { + percentOfAmi: 80, + householdSize: 2, + income: 119300, + }, + { + percentOfAmi: 80, + householdSize: 3, + income: 134200, + }, + { + percentOfAmi: 80, + householdSize: 4, + income: 149100, + }, + { + percentOfAmi: 80, + householdSize: 5, + income: 161050, + }, + { + percentOfAmi: 80, + householdSize: 6, + income: 173000, + }, + { + percentOfAmi: 80, + householdSize: 7, + income: 184900, + }, + { + percentOfAmi: 80, + householdSize: 8, + income: 196850, + }, + { + percentOfAmi: 100, + householdSize: 1, + income: 122500, + }, + { + percentOfAmi: 100, + householdSize: 2, + income: 140000, + }, + { + percentOfAmi: 100, + householdSize: 3, + income: 157500, + }, + { + percentOfAmi: 100, + householdSize: 4, + income: 175000, + }, + { + percentOfAmi: 100, + householdSize: 5, + income: 189000, + }, + { + percentOfAmi: 100, + householdSize: 6, + income: 203000, + }, + { + percentOfAmi: 100, + householdSize: 7, + income: 217000, + }, + { + percentOfAmi: 100, + householdSize: 8, + income: 231000, + }, + { + percentOfAmi: 120, + householdSize: 1, + income: 147000, + }, + { + percentOfAmi: 120, + householdSize: 2, + income: 168000, + }, + { + percentOfAmi: 120, + householdSize: 3, + income: 189000, + }, + { + percentOfAmi: 120, + householdSize: 4, + income: 210000, + }, + { + percentOfAmi: 120, + householdSize: 5, + income: 226800, + }, + { + percentOfAmi: 120, + householdSize: 6, + income: 243600, + }, + { + percentOfAmi: 120, + householdSize: 7, + income: 260400, + }, + { + percentOfAmi: 120, + householdSize: 8, + income: 277200, + }, + ], +} diff --git a/backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.txt b/backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.txt new file mode 100644 index 0000000000..c28ad6e1d6 --- /dev/null +++ b/backend/core/scripts/ami-chart-import-files/SMC-HUD-2023.txt @@ -0,0 +1,6 @@ +15 18400 21000 23650 26250 28350 30450 32550 34650 +30 39150 44750 50350 55900 60400 64850 69350 73800 +50 65250 74600 83900 93200 100700 108150 115600 123050 +80 104400 119300 134200 149100 161050 173000 184900 196850 +100 122500 140000 157500 175000 189000 203000 217000 231000 +120 147000 168000 189000 210000 226800 243600 260400 277200 diff --git a/backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.ts b/backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.ts new file mode 100644 index 0000000000..8335d168dd --- /dev/null +++ b/backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.ts @@ -0,0 +1,448 @@ +import { AmiChartCreateDto } from "../../src/ami-charts/dto/ami-chart.dto" +import { BaseEntity } from "typeorm" +// THIS FILE WAS AUTOMATICALLY GENERATED FROM SMC-TCAC-2023.txt. +export const ami: Omit = { + name: "San Mateo County TCAC 2023", + items: [ + { + percentOfAmi: 100, + householdSize: 1, + income: 130100, + }, + { + percentOfAmi: 100, + householdSize: 2, + income: 148700, + }, + { + percentOfAmi: 100, + householdSize: 3, + income: 167300, + }, + { + percentOfAmi: 100, + householdSize: 4, + income: 185800, + }, + { + percentOfAmi: 100, + householdSize: 5, + income: 200700, + }, + { + percentOfAmi: 100, + householdSize: 6, + income: 215600, + }, + { + percentOfAmi: 100, + householdSize: 7, + income: 230400, + }, + { + percentOfAmi: 100, + householdSize: 8, + income: 245300, + }, + { + percentOfAmi: 80, + householdSize: 1, + income: 104080, + }, + { + percentOfAmi: 80, + householdSize: 2, + income: 118960, + }, + { + percentOfAmi: 80, + householdSize: 3, + income: 133840, + }, + { + percentOfAmi: 80, + householdSize: 4, + income: 148640, + }, + { + percentOfAmi: 80, + householdSize: 5, + income: 160560, + }, + { + percentOfAmi: 80, + householdSize: 6, + income: 172480, + }, + { + percentOfAmi: 80, + householdSize: 7, + income: 184320, + }, + { + percentOfAmi: 80, + householdSize: 8, + income: 196240, + }, + { + percentOfAmi: 70, + householdSize: 1, + income: 91070, + }, + { + percentOfAmi: 70, + householdSize: 2, + income: 104090, + }, + { + percentOfAmi: 70, + householdSize: 3, + income: 117110, + }, + { + percentOfAmi: 70, + householdSize: 4, + income: 130060, + }, + { + percentOfAmi: 70, + householdSize: 5, + income: 140490, + }, + { + percentOfAmi: 70, + householdSize: 6, + income: 150920, + }, + { + percentOfAmi: 70, + householdSize: 7, + income: 161280, + }, + { + percentOfAmi: 70, + householdSize: 8, + income: 171710, + }, + { + percentOfAmi: 60, + householdSize: 1, + income: 78060, + }, + { + percentOfAmi: 60, + householdSize: 2, + income: 89220, + }, + { + percentOfAmi: 60, + householdSize: 3, + income: 100380, + }, + { + percentOfAmi: 60, + householdSize: 4, + income: 111480, + }, + { + percentOfAmi: 60, + householdSize: 5, + income: 120420, + }, + { + percentOfAmi: 60, + householdSize: 6, + income: 129360, + }, + { + percentOfAmi: 60, + householdSize: 7, + income: 138240, + }, + { + percentOfAmi: 60, + householdSize: 8, + income: 147180, + }, + { + percentOfAmi: 55, + householdSize: 1, + income: 71555, + }, + { + percentOfAmi: 55, + householdSize: 2, + income: 81785, + }, + { + percentOfAmi: 55, + householdSize: 3, + income: 92015, + }, + { + percentOfAmi: 55, + householdSize: 4, + income: 102190, + }, + { + percentOfAmi: 55, + householdSize: 5, + income: 110385, + }, + { + percentOfAmi: 55, + householdSize: 6, + income: 118580, + }, + { + percentOfAmi: 55, + householdSize: 7, + income: 126720, + }, + { + percentOfAmi: 55, + householdSize: 8, + income: 134915, + }, + { + percentOfAmi: 50, + householdSize: 1, + income: 65050, + }, + { + percentOfAmi: 50, + householdSize: 2, + income: 74350, + }, + { + percentOfAmi: 50, + householdSize: 3, + income: 83650, + }, + { + percentOfAmi: 50, + householdSize: 4, + income: 92900, + }, + { + percentOfAmi: 50, + householdSize: 5, + income: 100350, + }, + { + percentOfAmi: 50, + householdSize: 6, + income: 107800, + }, + { + percentOfAmi: 50, + householdSize: 7, + income: 115200, + }, + { + percentOfAmi: 50, + householdSize: 8, + income: 122650, + }, + { + percentOfAmi: 45, + householdSize: 1, + income: 58545, + }, + { + percentOfAmi: 45, + householdSize: 2, + income: 66915, + }, + { + percentOfAmi: 45, + householdSize: 3, + income: 75285, + }, + { + percentOfAmi: 45, + householdSize: 4, + income: 83610, + }, + { + percentOfAmi: 45, + householdSize: 5, + income: 90315, + }, + { + percentOfAmi: 45, + householdSize: 6, + income: 97020, + }, + { + percentOfAmi: 45, + householdSize: 7, + income: 103680, + }, + { + percentOfAmi: 45, + householdSize: 8, + income: 110385, + }, + { + percentOfAmi: 40, + householdSize: 1, + income: 52040, + }, + { + percentOfAmi: 40, + householdSize: 2, + income: 59480, + }, + { + percentOfAmi: 40, + householdSize: 3, + income: 66920, + }, + { + percentOfAmi: 40, + householdSize: 4, + income: 74320, + }, + { + percentOfAmi: 40, + householdSize: 5, + income: 80280, + }, + { + percentOfAmi: 40, + householdSize: 6, + income: 86240, + }, + { + percentOfAmi: 40, + householdSize: 7, + income: 92160, + }, + { + percentOfAmi: 40, + householdSize: 8, + income: 98120, + }, + { + percentOfAmi: 35, + householdSize: 1, + income: 45535, + }, + { + percentOfAmi: 35, + householdSize: 2, + income: 52045, + }, + { + percentOfAmi: 35, + householdSize: 3, + income: 58555, + }, + { + percentOfAmi: 35, + householdSize: 4, + income: 65030, + }, + { + percentOfAmi: 35, + householdSize: 5, + income: 70245, + }, + { + percentOfAmi: 35, + householdSize: 6, + income: 75460, + }, + { + percentOfAmi: 35, + householdSize: 7, + income: 80640, + }, + { + percentOfAmi: 35, + householdSize: 8, + income: 85855, + }, + { + percentOfAmi: 30, + householdSize: 1, + income: 39030, + }, + { + percentOfAmi: 30, + householdSize: 2, + income: 44610, + }, + { + percentOfAmi: 30, + householdSize: 3, + income: 50190, + }, + { + percentOfAmi: 30, + householdSize: 4, + income: 55740, + }, + { + percentOfAmi: 30, + householdSize: 5, + income: 60210, + }, + { + percentOfAmi: 30, + householdSize: 6, + income: 64680, + }, + { + percentOfAmi: 30, + householdSize: 7, + income: 69120, + }, + { + percentOfAmi: 30, + householdSize: 8, + income: 73590, + }, + { + percentOfAmi: 20, + householdSize: 1, + income: 26020, + }, + { + percentOfAmi: 20, + householdSize: 2, + income: 29740, + }, + { + percentOfAmi: 20, + householdSize: 3, + income: 33460, + }, + { + percentOfAmi: 20, + householdSize: 4, + income: 37160, + }, + { + percentOfAmi: 20, + householdSize: 5, + income: 40140, + }, + { + percentOfAmi: 20, + householdSize: 6, + income: 43120, + }, + { + percentOfAmi: 20, + householdSize: 7, + income: 46080, + }, + { + percentOfAmi: 20, + householdSize: 8, + income: 49060, + }, + ], +} diff --git a/backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.txt b/backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.txt new file mode 100644 index 0000000000..3e058e94d2 --- /dev/null +++ b/backend/core/scripts/ami-chart-import-files/SMC-TCAC-2023.txt @@ -0,0 +1,11 @@ +100 130100 148700 167300 185800 200700 215600 230400 245300 +80 104080 118960 133840 148640 160560 172480 184320 196240 +70 91070 104090 117110 130060 140490 150920 161280 171710 +60 78060 89220 100380 111480 120420 129360 138240 147180 +55 71555 81785 92015 102190 110385 118580 126720 134915 +50 65050 74350 83650 92900 100350 107800 115200 122650 +45 58545 66915 75285 83610 90315 97020 103680 110385 +40 52040 59480 66920 74320 80280 86240 92160 98120 +35 45535 52045 58555 65030 70245 75460 80640 85855 +30 39030 44610 50190 55740 60210 64680 69120 73590 +20 26020 29740 33460 37160 40140 43120 46080 49060 29740 33460 37160 40140 43120 46080 49060 diff --git a/backend/core/scripts/ami-chart-import-script.sh b/backend/core/scripts/ami-chart-import.sh similarity index 79% rename from backend/core/scripts/ami-chart-import-script.sh rename to backend/core/scripts/ami-chart-import.sh index 0aca83ecb7..77644a8989 100644 --- a/backend/core/scripts/ami-chart-import-script.sh +++ b/backend/core/scripts/ami-chart-import.sh @@ -2,19 +2,15 @@ if [ -z "$1" ]; then cat << EOF -Usage: ami-chart-import-script path/to/FILE - +Usage: ami-chart-import path/to/FILE WARNING: overwrites the file path/to/FILE.ts - This script takes a formatted text file and writes a .ts file containing the JSON representation of the AMI chart data. It is expecting 9 columns, the first one being the AMI percentage and then 8 columns representing the income for a household with 1..8 people corresponding to that AMI. Ex: 20% 10,000 11,000 12,000 13,000 14,000 15,000 16,000 17,000 30% 15,000 16,000 17,000 18,000 19,000 20,000 21,000 22,000 - This format is based on the PDF format for published MSHDA charts. Output note: there must be a newline at the end of the file or the last row will not be read in. - Once you have the generated ts file, you can create a migration that uses that ts file to create the new ami chart EOF exit @@ -30,13 +26,13 @@ OUTPUT_FILE="$DIRECTORY/$FILENAME.ts" echo "Generating $OUTPUT_FILE" cat << EOF > $OUTPUT_FILE -import { AmiChartCreateDto } from "../../../ami-charts/dto/ami-chart.dto" +import { AmiChartCreateDto } from "../../src/ami-charts/dto/ami-chart.dto" import { BaseEntity } from "typeorm" - // THIS FILE WAS AUTOMATICALLY GENERATED FROM $FILE. -export const $FILENAME: Omit = { - name: "$FILENAME", - items: [ +export const ami: Omit = { + "name": "$FILENAME", + "jurisdiction_id": "> $OUTPUT_FILE { - percentOfAmi: $AMI, - householdSize: $i, - income: ${INCOME[$i]}, + "percentOfAmi": $AMI, + "householdSize": $i, + "income": ${INCOME[$i]}, }, EOF done @@ -60,4 +56,4 @@ EOF cat << EOF >> $OUTPUT_FILE ], } -EOF +EOF \ No newline at end of file diff --git a/backend/core/src/migration/1693242578397-new-smc-ami-charts-2023.ts b/backend/core/src/migration/1693242578397-new-smc-ami-charts-2023.ts new file mode 100644 index 0000000000..e1ddc8e8a8 --- /dev/null +++ b/backend/core/src/migration/1693242578397-new-smc-ami-charts-2023.ts @@ -0,0 +1,29 @@ +import { MigrationInterface, QueryRunner } from "typeorm" +import { ami as SMC_HUD_2023 } from "../../scripts/ami-chart-import-files/SMC-HUD-2023" +import { ami as SMC_TCAC_2023 } from "../../scripts/ami-chart-import-files/SMC-TCAC-2023" + +export class newSmcAmiCharts20231693242578397 implements MigrationInterface { + name = "newSmcAmiCharts20231693242578397" + + public async up(queryRunner: QueryRunner): Promise { + const [{ id: smcJuris }] = await queryRunner.query( + `SELECT id FROM jurisdictions WHERE name = 'San Mateo'` + ) + + await queryRunner.query(` + INSERT INTO ami_chart + (name, items, jurisdiction_id) + VALUES ('${SMC_HUD_2023.name}', '${JSON.stringify(SMC_HUD_2023.items)}', '${smcJuris}') + `) + + await queryRunner.query(` + INSERT INTO ami_chart + (name, items, jurisdiction_id) + VALUES ('${SMC_TCAC_2023.name}', '${JSON.stringify(SMC_TCAC_2023.items)}', '${smcJuris}') + `) + } + + public async down(queryRunner: QueryRunner): Promise { + // there is no down migration + } +}