diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb index d8e6be4d4..9df64209a 100644 --- a/app/models/account_activity.rb +++ b/app/models/account_activity.rb @@ -13,6 +13,9 @@ class AccountActivity < ApplicationRecord def update_balance account.balance += sum account.save + + self.new_balance = account.balance + save end class << self diff --git a/app/views/registrar/account_activities/index.html.erb b/app/views/registrar/account_activities/index.html.erb index c5eaf2063..aefcdd47f 100644 --- a/app/views/registrar/account_activities/index.html.erb +++ b/app/views/registrar/account_activities/index.html.erb @@ -14,7 +14,7 @@
+ | <%= sort_link(@q, 'description') %> | @@ -26,6 +26,9 @@ | <%= sort_link(@q, 'sum') %> | ++ <%= sort_link(@q, 'new_balance', 'New balance') %> + | <%= s %> | ++ <%= x.new_balance.present? ? "#{currency(x.new_balance)} EUR" : 'N/A' %> + | <% end %> diff --git a/db/migrate/20210215101019_add_new_balance_to_account_activity.rb b/db/migrate/20210215101019_add_new_balance_to_account_activity.rb new file mode 100644 index 000000000..64c829833 --- /dev/null +++ b/db/migrate/20210215101019_add_new_balance_to_account_activity.rb @@ -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 diff --git a/db/structure.sql b/db/structure.sql index acf134a55..de2243597 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -226,7 +226,8 @@ CREATE TABLE public.account_activities ( creator_str character varying, updator_str 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'), ('20200910085157'), ('20200910102028'), -('20200916125326'); +('20200916125326'), +('20210215101019');
---|