mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-03 04:25:21 +02:00
Account Activity View + Account Forms (#1406)
* Remove balance mode, sketch out refactor * Activity view checkpoint * Entry partials, checkpoint * Finish txn partial * Give entries context when editing for different turbo responses * Calculate change of balance for each entry * Account tabs consolidation * Translations, linting, brakeman updates * Account actions concern * Finalize forms, get account system tests passing * Get tests passing * Lint, rubocop, schema updates * Improve routing and stream responses * Fix broken routes * Add import option for adding accounts * Fix system test * Fix test specificity * Fix sparklines * Improve account redirects
This commit is contained in:
parent
12e4f1067d
commit
65db49273c
216 changed files with 2043 additions and 1620 deletions
26
app/views/loans/_form.html.erb
Normal file
26
app/views/loans/_form.html.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<%# locals: (account:, url:) %>
|
||||
|
||||
<%= render "accounts/form", account: account, url: url do |form| %>
|
||||
<hr class="my-4">
|
||||
|
||||
<div class="space-y-2">
|
||||
<%= form.fields_for :accountable do |loan_form| %>
|
||||
<div class="flex items-center gap-2">
|
||||
<%= loan_form.number_field :interest_rate,
|
||||
label: t("loans.form.interest_rate"),
|
||||
placeholder: t("loans.form.interest_rate_placeholder"),
|
||||
min: 0,
|
||||
step: 0.01 %>
|
||||
<%= loan_form.select :rate_type,
|
||||
[["Fixed", "fixed"], ["Variable", "variable"], ["Adjustable", "adjustable"]],
|
||||
{ label: t("loans.form.rate_type") } %>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<%= loan_form.number_field :term_months,
|
||||
label: t("loans.form.term_months"),
|
||||
placeholder: t("loans.form.term_months_placeholder") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
49
app/views/loans/_overview.html.erb
Normal file
49
app/views/loans/_overview.html.erb
Normal file
|
@ -0,0 +1,49 @@
|
|||
<%# locals: (account:) %>
|
||||
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<%= summary_card title: t(".original_principal") do %>
|
||||
<%= format_money account.original_balance %>
|
||||
<% end %>
|
||||
|
||||
<%= summary_card title: t(".remaining_principal") do %>
|
||||
<%= format_money account.balance_money %>
|
||||
<% end %>
|
||||
|
||||
<%= summary_card title: t(".interest_rate") do %>
|
||||
<% if account.loan.interest_rate.present? %>
|
||||
<%= number_to_percentage(account.loan.interest_rate, precision: 2) %>
|
||||
<% else %>
|
||||
<%= t(".unknown") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= summary_card title: t(".monthly_payment") do %>
|
||||
<% if account.loan.rate_type.present? && account.loan.rate_type != 'fixed' %>
|
||||
<%= t(".not_applicable") %>
|
||||
<% elsif account.loan.rate_type == 'fixed' && account.loan.monthly_payment.present? %>
|
||||
<%= format_money(account.loan.monthly_payment) %>
|
||||
<% else %>
|
||||
<%= t(".unknown") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= summary_card title: t(".term") do %>
|
||||
<% if account.loan.term_months.present? %>
|
||||
<% if account.loan.term_months < 12 %>
|
||||
<%= pluralize(account.loan.term_months, "month") %>
|
||||
<% else %>
|
||||
<%= pluralize(account.loan.term_months / 12, "year") %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= t(".unknown") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= summary_card title: t(".type") do %>
|
||||
<%= account.loan.rate_type&.titleize || t(".unknown") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center py-8">
|
||||
<%= link_to "Edit loan details", edit_loan_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>
|
||||
</div>
|
3
app/views/loans/edit.html.erb
Normal file
3
app/views/loans/edit.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<%= modal_form_wrapper title: t(".edit", account: @account.name) do %>
|
||||
<%= render "form", account: @account, url: loan_path(@account) %>
|
||||
<% end %>
|
7
app/views/loans/new.html.erb
Normal file
7
app/views/loans/new.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<% if params[:step] == "method_select" %>
|
||||
<%= render "accounts/new/method_selector", path: new_loan_path(institution_id: params[:institution_id], return_to: params[:return_to]) %>
|
||||
<% else %>
|
||||
<%= modal_form_wrapper title: t(".title") do %>
|
||||
<%= render "loans/form", account: @account, url: loans_path %>
|
||||
<% end %>
|
||||
<% end %>
|
6
app/views/loans/show.html.erb
Normal file
6
app/views/loans/show.html.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
<%= render "accounts/show/template",
|
||||
account: @account,
|
||||
tabs: render("accounts/show/tabs", account: @account, tabs: [
|
||||
{ key: "overview", contents: render("loans/overview", account: @account) },
|
||||
{ key: "activity", contents: render("accounts/show/activity", account: @account) }
|
||||
]) %>
|
Loading…
Add table
Add a link
Reference in a new issue