=== LOAN APPROVAL TRACKING TEST === 1. Checking recent loan offers and their approval records: -------------------------------------------------------------------------------- Loan ID: 194 Application Number: ESS1760601877552 Approval Status: CANCELLED Approvals in normalized table: - Type: initial, Status: pending, Pending Loan ID: 193 Application Number: ESS1760513972933 Approval Status: CANCELLED Approvals in normalized table: - Type: initial, Status: pending, Pending Loan ID: 192 Application Number: ESS1760344847982 Approval Status: CANCELLED Approvals in normalized table: - Type: initial, Status: pending, Pending Loan ID: 191 Application Number: ESS1760343957904 Approval Status: CANCELLED Approvals in normalized table: - Type: initial, Status: pending, Pending Loan ID: 190 Application Number: ESS1760024270030 Approval Status: CANCELLED Approvals in normalized table: - Type: initial, Status: pending, Pending 2. Checking for data consistency: -------------------------------------------------------------------------------- ⚠️ Found 6 approved loans without approval records: - Loan ID: 119, Application: HHR1724849980680 - Loan ID: 120, Application: HHR1699454053069 - Loan ID: 121, Application: HHR1705484746062 - Loan ID: 122, Application: HHR1735641813231 - Loan ID: 124, Application: HHR1720025637637 - Loan ID: 125, Application: HHR1736493128671 ✅ All rejected loans have corresponding approval records 3. Summary Statistics: -------------------------------------------------------------------------------- Loan Offers Table: Total Loans: 154 Approved: 44 Rejected: 25 Pending: 8 Loan Offer Approvals Table: Total Records: 217 Approved: 51 Rejected: 32 Pending: 134 4. Test Recommendations: -------------------------------------------------------------------------------- To test the approval tracking: 1. Go to /loan-offers in your browser 2. Find a pending loan and click Edit 3. Change the Approval field to APPROVED or REJECTED 4. Save the changes 5. Run this script again to verify the loan_offer_approvals table was updated Alternatively, test bulk operations: 1. Select multiple loans in the index page 2. Use the bulk approve/reject action 3. Check that loan_offer_approvals records are created === END OF TEST ===