mirror of
https://github.com/internetee/registry.git
synced 2025-08-12 20:49:36 +02:00
Track account balance dynamically in AccountActivity
This commit is contained in:
parent
416390a3c4
commit
27e441bc24
4 changed files with 19 additions and 3 deletions
|
@ -13,6 +13,9 @@ class AccountActivity < ApplicationRecord
|
||||||
def update_balance
|
def update_balance
|
||||||
account.balance += sum
|
account.balance += sum
|
||||||
account.save
|
account.save
|
||||||
|
|
||||||
|
self.new_balance = account.balance
|
||||||
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<table class="table table-hover table-condensed">
|
<table class="table table-hover table-condensed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-xs-5">
|
<th class="col-xs-3">
|
||||||
<%= sort_link(@q, 'description') %>
|
<%= sort_link(@q, 'description') %>
|
||||||
</th>
|
</th>
|
||||||
<th class="col-xs-2">
|
<th class="col-xs-2">
|
||||||
|
@ -26,6 +26,9 @@
|
||||||
<th class="col-xs-2">
|
<th class="col-xs-2">
|
||||||
<%= sort_link(@q, 'sum') %>
|
<%= sort_link(@q, 'sum') %>
|
||||||
</th>
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= sort_link(@q, 'new_balance', 'New balance') %>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -45,6 +48,9 @@
|
||||||
<td class="<%= c %>">
|
<td class="<%= c %>">
|
||||||
<%= s %>
|
<%= s %>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= x.new_balance.present? ? "#{currency(x.new_balance)} EUR" : 'N/A' %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddNewBalanceToAccountActivity < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :account_activities, :new_balance, :decimal, precision: 10, scale: 2, null: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -226,7 +226,8 @@ CREATE TABLE public.account_activities (
|
||||||
creator_str character varying,
|
creator_str character varying,
|
||||||
updator_str character varying,
|
updator_str character varying,
|
||||||
activity_type character varying,
|
activity_type character varying,
|
||||||
price_id integer
|
price_id integer,
|
||||||
|
new_balance numeric(10,2)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -4959,6 +4960,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20200908131554'),
|
('20200908131554'),
|
||||||
('20200910085157'),
|
('20200910085157'),
|
||||||
('20200910102028'),
|
('20200910102028'),
|
||||||
('20200916125326');
|
('20200916125326'),
|
||||||
|
('20210215101019');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue