From 67bdcfffebd74a9aeab393b88d604e100039a133 Mon Sep 17 00:00:00 2001 From: Tony Vincent Yesudas Date: Thu, 9 Jan 2025 18:02:46 +0100 Subject: [PATCH] feat: Add loan start date --- app/controllers/loans_controller.rb | 2 +- app/views/loans/_form.html.erb | 5 +++++ app/views/loans/_overview.html.erb | 4 ++++ config/locales/views/loans/en.yml | 2 ++ db/migrate/20250109165633_add_start_date_to_loans.rb | 5 +++++ db/schema.rb | 3 ++- 6 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20250109165633_add_start_date_to_loans.rb diff --git a/app/controllers/loans_controller.rb b/app/controllers/loans_controller.rb index b9968faf76b..408e62b2954 100644 --- a/app/controllers/loans_controller.rb +++ b/app/controllers/loans_controller.rb @@ -2,6 +2,6 @@ class LoansController < ApplicationController include AccountableResource permitted_accountable_attributes( - :id, :rate_type, :interest_rate, :term_months + :id, :rate_type, :interest_rate, :term_months, :start_date ) end diff --git a/app/views/loans/_form.html.erb b/app/views/loans/_form.html.erb index bceee9688ce..4184a731563 100644 --- a/app/views/loans/_form.html.erb +++ b/app/views/loans/_form.html.erb @@ -21,6 +21,11 @@ label: t("loans.form.term_months"), placeholder: t("loans.form.term_months_placeholder") %> + +
+ <%= loan_form.date_field :start_date, + label: t("loans.form.start_date") %> +
<% end %> <% end %> diff --git a/app/views/loans/_overview.html.erb b/app/views/loans/_overview.html.erb index db6824fb53c..26a8721efd2 100644 --- a/app/views/loans/_overview.html.erb +++ b/app/views/loans/_overview.html.erb @@ -42,6 +42,10 @@ <%= summary_card title: t(".type") do %> <%= account.loan.rate_type&.titleize || t(".unknown") %> <% end %> + + <%= summary_card title: t(".start_date") do %> + <%= account.loan.start_date&.strftime("%B %d, %Y") || t(".unknown") %> + <% end %>
diff --git a/config/locales/views/loans/en.yml b/config/locales/views/loans/en.yml index 930af8dfc43..5b64e136e52 100644 --- a/config/locales/views/loans/en.yml +++ b/config/locales/views/loans/en.yml @@ -9,11 +9,13 @@ en: rate_type: Rate type term_months: Term (months) term_months_placeholder: '360' + start_date: Loan start date new: title: Enter loan details overview: interest_rate: Interest Rate monthly_payment: Monthly Payment + start_date: Start Date not_applicable: N/A original_principal: Original Principal remaining_principal: Remaining Principal diff --git a/db/migrate/20250109165633_add_start_date_to_loans.rb b/db/migrate/20250109165633_add_start_date_to_loans.rb new file mode 100644 index 00000000000..784d5dca423 --- /dev/null +++ b/db/migrate/20250109165633_add_start_date_to_loans.rb @@ -0,0 +1,5 @@ +class AddStartDateToLoans < ActiveRecord::Migration[7.2] + def change + add_column :loans, :start_date, :date + end +end diff --git a/db/schema.rb b/db/schema.rb index 0bdce796d6b..d26c0a4f7ec 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_12_27_142333) do +ActiveRecord::Schema[7.2].define(version: 2025_01_09_165633) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -447,6 +447,7 @@ t.string "rate_type" t.decimal "interest_rate", precision: 10, scale: 3 t.integer "term_months" + t.date "start_date" end create_table "merchants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|