I’m building an app to manage a pipeline of loans a loan officer may be handling.
The relevant tables to this question are as follows.
TABLE RELATIONSHIPS
LOAN
LOAN ITEMS (LOAN is parent table, related by LOAN ID in this table)
LOAN ITEMS TEMPLATES (this table has no relationships.)
TABLE DESCRIPTIONS
LOAN (has all the relevant information about the loan: name, address, loan type, etc)
LOAN ITEMS (this has the checklists that are relevant to the LOAN its associated to.)
LOAN ITEMS TEMPLATES (This table holds a list of checklist items that are relevant to a given loan type)
LOAN ITEMS is basically an EAV table. We track status on each of these items. Its columns are like this…
ID, LOAN TYPE, CHECKLIST ITEM, STATUS, START DATE, END DATE
So one LOAN TYPE may have 50 entries in LOAN ITEMS TEMPLATES and another LOAN TYPE may have 70 entries in LOAN ITEMS TEMPLATES
PROBLEM STATEMENT
When I create a LOAN record, I then want to populate my LOAN ITEMS table with the relevent LOAN ITEMS TEMPLATES items based on the LOAN TYPE I selected when I created the loan.
PSEUDOCODE - Here is the logic I want to implement and I’m looking for the community to point me in the right direction. I can share my existing app if need be, right?
- Click Default Items ACTION from LOAN card
- Popup appears
- select loan type of Purchase or REFI
- If Purchase select FHA or VA or CONV or USDA
- select * from LOAN ITEMS TEMPLATES where FHA column = TRUE
- select * from LOAN ITEMS TEMPLATES where VA column = TRUE
- select * from LOAN ITEMS TEMPLATES where CONV column = TRUE
- select * from LOAN ITEMS TEMPLATES where USDA column = TRUE
- Now map fields from LOAN ITEMS TEMPLATES to LOAN ITEMS and push to LOAN ITEMS using LOAN.ID as LOAN ITEMS.ID
- If REFI
- Select * from LOAN ITEMS TEMPLATES where REFI column = TRUE
- Now map fields from LOAN ITEMS TEMPLATES to LOAN ITEMS and push to LOAN ITEMS using LOAN.ID as LOAN ITEMS.ID
- Select * from LOAN ITEMS TEMPLATES where REFI column = TRUE
- If Purchase select FHA or VA or CONV or USDA
- Click Optional Items ACTION from LOAN card
- Popup appears
- Select loan type of Purchase or REFI
- If purchase then select * from LOAN ITEMS TEMPLATES where Optional – Purchase = TRUE
- Now I want to be presented with these as rows in a table and I want to select them with checkboxes.
- For the ones I selected, now map fields from LOAN ITEMS TEMPLATES to LOAN ITEMS and push to LOAN ITEMS using LOAN.ID as LOAN ITEMS.ID
- Now I want to be presented with these as rows in a table and I want to select them with checkboxes.
- If REFI then select * from LOAN ITEMS TEMPLATES where Optional – REFI = TRUE
- Now I want to be presented with these as rows in a table and I want to select them with checkboxes.
- For the ones I selected, now map fields from LOAN ITEMS to LOAN ITEMS and push to LOAN ITEMS using LOAN.ID as LOAN.ID
- Now I want to be presented with these as rows in a table and I want to select them with checkboxes.
- If purchase then select * from LOAN ITEMS TEMPLATES where Optional – Purchase = TRUE