Skip to content

Commit

Permalink
feat: Add loan start date
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyvince committed Jan 9, 2025
1 parent 46e1293 commit 67bdcff
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/loans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions app/views/loans/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
label: t("loans.form.term_months"),
placeholder: t("loans.form.term_months_placeholder") %>
</div>

<div class="flex items-center gap-2">
<%= loan_form.date_field :start_date,
label: t("loans.form.start_date") %>
</div>
<% end %>
</div>
<% end %>
4 changes: 4 additions & 0 deletions app/views/loans/_overview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</div>

<div class="flex justify-center py-8">
Expand Down
2 changes: 2 additions & 0 deletions config/locales/views/loans/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20250109165633_add_start_date_to_loans.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddStartDateToLoans < ActiveRecord::Migration[7.2]
def change
add_column :loans, :start_date, :date
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 67bdcff

Please sign in to comment.