mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Integrate money-rails gem (#268)
* Integrate money-rails gem * Fix Lint issues * Basic test for monetize feature * Merge main branch * Changes to monetize balance field --------- Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
This commit is contained in:
parent
323a8ccf50
commit
1182ab39bd
12 changed files with 176 additions and 14 deletions
|
@ -30,7 +30,7 @@ class AccountsController < ApplicationController
|
|||
private
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:name, :accountable_type, :balance, :subtype)
|
||||
params.require(:account).permit(:name, :accountable_type, :balance, :balance_cents, :subtype)
|
||||
end
|
||||
|
||||
def account_type_class
|
||||
|
|
|
@ -4,4 +4,6 @@ class Account < ApplicationRecord
|
|||
delegated_type :accountable, types: %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle], dependent: :destroy
|
||||
|
||||
delegate :type_name, to: :accountable
|
||||
|
||||
monetize :balance_cents
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<%= account.accountable %>
|
||||
</div>
|
||||
<p class="text-sm text-right">
|
||||
<span class="block mb-1"><%= number_to_currency account.balance %></span>
|
||||
<span class="block mb-1"><%= humanized_money_with_symbol account.balance %></span>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
|
||||
<label for="account_balance" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Balance</label>
|
||||
<div class="flex">
|
||||
<%= f.number_field :balance, placeholder: "$0.00", in: 0.00..100000000.00, required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
|
||||
<%= f.number_field :balance, placeholder: "$0.00", in: 0.00..100000000.00, step: :any, required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<%= account.name %>
|
||||
</div>
|
||||
<p class="text-sm text-right">
|
||||
<span class="block mb-1"><%= number_to_currency account.balance %></span>
|
||||
<span class="block mb-1"><%= humanized_money_with_symbol account.balance %></span>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue