Skip to content

main-2308

@andrewsignori-aot andrewsignori-aot tagged this 09 Apr 00:15
### Bulk Insert

Created the bulk insert trying to use as much as possible the Typeorm
methods to avoid creating the e SQL. This was part of the agreement
during the technical details.
We need a team agreement to decide if it is worth keeping it as it is or
if we change it to the raw SQL file.

#### Sample Typeorm Generated SQL

```sql
INSERT INTO
    sims.student_loan_balances (student_id, csl_balance, balance_date, creator) (
        SELECT
            "studentLoanBalance"."student_id" AS "studentId",
            0 AS "cslBalance",
            $1 AS "balanceDate",
            $2 AS "creator"
        FROM
            "sims"."student_loan_balances" "studentLoanBalance"
        WHERE
            "studentLoanBalance"."csl_balance" > 0
            AND "studentLoanBalance"."balance_date" = $3
            AND NOT EXISTS (
                SELECT
                    1
                FROM
                    "sims"."student_loan_balances" "studentLoanBalanceExists"
                WHERE
                    student_id = "studentLoanBalance".student_id
                    AND balance_date = $1
            )
    ) -- PARAMETERS: ["2023-12-31T00:00:00.000Z",13,"2023-11-30T00:00:00.000Z"]
```

### E2E Tests Added
- Should add a zero balance record for a student with a positive balance
in the previous month when the same student is no longer in the most
recently received file.
- Should ignore a student with a zero balance in the previous month when
a new file is imported and the student is not in the file records.
- Should create a new balance when the student has a zero balance record
in the previous balance and a new positive balance is received.
Assets 2
Loading