Skip to content

Instantly share code, notes, and snippets.

@RichardOrnelas
Last active August 26, 2020 17:15
Show Gist options
  • Save RichardOrnelas/a5a39bdbc9e315a1f4982b3494293c52 to your computer and use it in GitHub Desktop.
Save RichardOrnelas/a5a39bdbc9e315a1f4982b3494293c52 to your computer and use it in GitHub Desktop.
initial models. Looking for some guidance on the relationships, and examples of common patterns

Models

Users

  • Relationships
    • has_many :assignments, class_name: "Loan"
    • belongs_to :branch <-- do they?
      • Tracks Session IDs
  • Attributes
    • first_name
    • last_name
    • email
    • phone
    • role
    • job_title
    • profile_image
    • slack
    • last_login
    • google_token
    • google_refresh_token

Branch

  • Relationships
    • Has Users
    • has_many :loans
  • Attributes
    • Corporation (enum)

Entity ( this could probably just be done as a User)

  • belongs_to :user
  • has_many :borrowers
  • has_many :loans, through: :borrowers
  • name
  • first/last name
  • type:string (STI column Person/Business)

Borrowers

  • Relationships
    • belongs_to :entity
    • belongs_to :loan
      • has_many :incomes
      • has_many :liabilities
      • has_many :residences
      • has_many :assets
  • Attributes
    • first_name
    • last_name
    • middle_name
    • suffix []
    • email
    • mobile_phone
    • home_phone
    • date_of_birth
    • gender []
    • marital_status []
    • ssn
    • borrower_type []
    • current_address_street
    • current_address_city
    • current_address_state
    • current_address_zip
    • purpose_for_transaction (Loan)
    • estimated_annual_income (non_calculated)
    • current_monthly_housing_expenses (non_calc)
    • base_fico_score (non_calc)
    • authorized_credit_report?
    • alimony_child_support_obligation?
    • currently_employed?
    • us_citizen?
    • bankruptcy_history?
    • foreclosure_history?
    • first_time_homeowner?

Incomes

  • Relationships
    • belongs_to :borrower
    • has_one :loan, through: :borrower
    • has_one :entity, through: :borrower
  • Attributes
    • income_type []
      • base
      • commissions
      • overtime
      • bonus
      • dividends_interest
      • net_rental_income
      • self_employed
      • other
    • self_employed_form []
    • amount
    • description
    • current?

Liabilities

  • Relationships
    • belongs_to :borrower
    • has_one :loan, through: :borrower
    • has_one :entity, through: :borrower
  • Attributes
    • liability_type []
      • job_related_expenses
      • alimony
      • automobile
      • student_loans
      • mortage
    • self_employed_income_type []
      • OtherDescription
    • self_employed_form []
    • amount
    • description
    • current?

Assets

  • Relationships
    • belongs_to :borrower
    • has_one :loan, through: :borrower
    • has_one :entity, through: :borrower
  • Attributes
    • asset_type []
      • life_insurance
      • retirement_fund
      • net_worth_of_business_owned
      • stock
      • automobile
      • cash_on_hand
      • other_non_liquid
    • description
    • amount

Residences

  • Relationships
    • belongs_to :borrower
    • has_one :loan, through: :borrower
    • has_one :entity, through: :borrower
  • Attributes

======================

Loans

  • Relationships
    • has_many :borrowers
    • has_many :entities, through: :borrowers
      • belongs_to :branch
      • belongs_to :Property <- can you get loans on other things? Boat/Plane/Car/Business? - what about multiple things/set-of-things?
    • belongs_to :loan_officer, class_name: "User"
      • has one or more Agents
      • has one of more Fees
      • has one of more Documents
  • Attributes
    • loan_officer_id:bigint
    • :milestone state machine
      • :loan_processor as user
      • :broker_lender
      • :underwriter
      • branch
      • sellers_agent as Agent
      • buyers_agent as Agent
      • == attributes ===
      • id
      • encompass_id
      • purpose[]
      • mortgage_type[]
      • occupancy_type[]
      • closing_cost_program[]
      • loan_program[]
      • credit_score_to_use
      • loan_amount
      • down_payment
      • down_payment_percentage
      • ltv
      • cash_from_borrower
      • maturity_date
      • rate
      • terms
      • lender_channel []
      • == non-calculated ==
      • proposed_first_mortgage_amount
      • proposed_hazard_insurance_amount
      • proposed_housing_expenses_total
      • proposed_mortgage_insurance_amount
      • proposed_real_estate_taxes_amount
      • proposed_purchase_price_amount
      • proposed_interest_rate
      • requested_interest_rate
      • == booleans ==

Properties

  • Relationships
    • has one or more Loans
  • Attributes

Agents

  • Relationships
    • has one or more Loans
  • Attributes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment