diff --git a/app/controllers/account/transfers_controller.rb b/app/controllers/account/transfers_controller.rb index 4fbf4268..c8fd4877 100644 --- a/app/controllers/account/transfers_controller.rb +++ b/app/controllers/account/transfers_controller.rb @@ -40,6 +40,6 @@ class Account::TransfersController < ApplicationController end def transfer_params - params.require(:account_transfer).permit(:from_account_id, :to_account_id, :amount, :currency, :date, :name) + params.require(:account_transfer).permit(:from_account_id, :to_account_id, :amount, :date, :name) end end diff --git a/app/models/account/entry.rb b/app/models/account/entry.rb index 345fe26b..56754cb6 100644 --- a/app/models/account/entry.rb +++ b/app/models/account/entry.rb @@ -204,7 +204,6 @@ class Account::Entry < ApplicationRecord current_qty = account.holding_qty(account_trade.security) if current_qty < account_trade.qty.abs - # i18n-tasks-use t('activerecord.errors.models.account/entry.attributes.base.invalid_sell_quantity') errors.add( :base, :invalid_sell_quantity, diff --git a/app/models/account/transfer.rb b/app/models/account/transfer.rb index 402c3776..370d53a2 100644 --- a/app/models/account/transfer.rb +++ b/app/models/account/transfer.rb @@ -46,7 +46,7 @@ class Account::Transfer < ApplicationRecord def build_from_accounts(from_account, to_account, date:, amount:, currency:, name:) outflow = from_account.entries.build \ amount: amount.abs, - currency: currency, + currency: from_account.currency, date: date, name: name, marked_as_transfer: true, @@ -54,7 +54,7 @@ class Account::Transfer < ApplicationRecord inflow = to_account.entries.build \ amount: amount.abs * -1, - currency: currency, + currency: from_account.currency, date: date, name: name, marked_as_transfer: true, @@ -72,27 +72,23 @@ class Account::Transfer < ApplicationRecord def transaction_count unless entries.size == 2 - # i18n-tasks-use t('activerecord.errors.models.account/transfer.attributes.entries.must_have_exactly_2_entries') errors.add :entries, :must_have_exactly_2_entries end end def from_different_accounts accounts = entries.map { |e| e.account_id }.uniq - # i18n-tasks-use t('activerecord.errors.models.account/transfer.attributes.entries.must_be_from_different_accounts') errors.add :entries, :must_be_from_different_accounts if accounts.size < entries.size end def net_zero_flows unless entries.sum(&:amount).zero? - # i18n-tasks-use t('activerecord.errors.models.account/transfer.attributes.entries.must_have_an_inflow_and_outflow_that_net_to_zero') errors.add :entries, :must_have_an_inflow_and_outflow_that_net_to_zero end end def all_transactions_marked unless entries.all?(&:marked_as_transfer) - # i18n-tasks-use t('activerecord.errors.models.account/transfer.attributes.entries.must_be_marked_as_transfer') errors.add :entries, :must_be_marked_as_transfer end end diff --git a/app/models/import.rb b/app/models/import.rb index 590e94f4..2cb1e634 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -179,7 +179,6 @@ class Import < ApplicationRecord begin CSV.parse(raw_file_str || "", col_sep:) rescue CSV::MalformedCSVError - # i18n-tasks-use t('activerecord.errors.models.import.attributes.raw_file_str.invalid_csv_format') errors.add(:raw_file_str, :invalid_csv_format) end end diff --git a/app/models/time_series/trend.rb b/app/models/time_series/trend.rb index e4959bc9..b93db2bd 100644 --- a/app/models/time_series/trend.rb +++ b/app/models/time_series/trend.rb @@ -83,21 +83,17 @@ class TimeSeries::Trend def values_must_be_of_same_type unless current.class == previous.class || [ previous, current ].any?(&:nil?) - # i18n-tasks-use t('activemodel.errors.models.time_series/trend.attributes.current.must_be_of_the_same_type_as_previous') errors.add :current, :must_be_of_the_same_type_as_previous - # i18n-tasks-use t('activemodel.errors.models.time_series/trend.attributes.previous.must_be_of_the_same_type_as_current') errors.add :previous, :must_be_of_the_same_type_as_current end end def values_must_be_of_known_type unless current.is_a?(Money) || current.is_a?(Numeric) || current.nil? - # i18n-tasks-use t('activemodel.errors.models.time_series/trend.attributes.current.must_be_of_type_money_numeric_or_nil') errors.add :current, :must_be_of_type_money_numeric_or_nil end unless previous.is_a?(Money) || previous.is_a?(Numeric) || previous.nil? - # i18n-tasks-use t('activemodel.errors.models.time_series/trend.attributes.previous.must_be_of_type_money_numeric_or_nil') errors.add :previous, :must_be_of_type_money_numeric_or_nil end end diff --git a/app/models/time_series/value.rb b/app/models/time_series/value.rb index c02dc3e4..390343e1 100644 --- a/app/models/time_series/value.rb +++ b/app/models/time_series/value.rb @@ -40,7 +40,6 @@ class TimeSeries::Value def value_must_be_of_known_type unless value.is_a?(Money) || value.is_a?(Numeric) - # i18n-tasks-use t('activemodel.errors.models.time_series/value.attributes.value.must_be_a_money_or_numeric') errors.add :value, :must_be_a_money_or_numeric end end diff --git a/app/models/user.rb b/app/models/user.rb index a4a9dd04..7a1cca57 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -55,7 +55,6 @@ class User < ApplicationRecord def can_deactivate if admin? && family.users.count > 1 - # i18n-tasks-use t('activerecord.errors.models.user.attributes.base.cannot_deactivate_admin_with_other_users') errors.add(:base, :cannot_deactivate_admin_with_other_users) end end @@ -84,7 +83,6 @@ class User < ApplicationRecord def profile_image_size if profile_image.attached? && profile_image.byte_size > 5.megabytes - # i18n-tasks-use t('activerecord.errors.models.user.attributes.profile_image.invalid_file_size') errors.add(:profile_image, :invalid_file_size, max_megabytes: 5) end end diff --git a/app/views/account/transfers/_form.html.erb b/app/views/account/transfers/_form.html.erb index 84e0b914..3d68dc8a 100644 --- a/app/views/account/transfers/_form.html.erb +++ b/app/views/account/transfers/_form.html.erb @@ -30,7 +30,6 @@ <%= f.collection_select :from_account_id, Current.family.accounts.alphabetically, :id, :name, { prompt: t(".select_account"), label: t(".from") }, required: true %> <%= f.collection_select :to_account_id, Current.family.accounts.alphabetically, :id, :name, { prompt: t(".select_account"), label: t(".to") }, required: true %> <%= money_field f, :amount_money, label: t(".amount"), required: true %> - <%= f.hidden_field :currency, value: Current.family.currency %> <%= f.date_field :date, value: transfer.date, label: t(".date"), required: true, max: Date.current %> diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 028f9607..67ca3f64 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -26,6 +26,8 @@ search: ignore_unused: - 'activerecord.attributes.*' # i18n-tasks does not detect these on forms, forms validations (https://github.com/glebm/i18n-tasks/blob/0b4b483c82664f26c5696fb0f6aa1297356e4683/templates/config/i18n-tasks.yml#L146) - 'activerecord.models.*' # i18n-tasks does not detect use in dynamic model names (e.g. object.model_name.human) + - 'activerecord.errors.models*' + - 'activemodel.errors.models.*' - 'helpers.submit.*' # i18n-tasks does not detect used at forms - 'helpers.label.*' # i18n-tasks does not detect used at forms - 'accounts.show.sync_message_*' # messages generated in the sync ActiveJob diff --git a/test/controllers/account/transfers_controller_test.rb b/test/controllers/account/transfers_controller_test.rb index a41426bf..06289fd5 100644 --- a/test/controllers/account/transfers_controller_test.rb +++ b/test/controllers/account/transfers_controller_test.rb @@ -18,7 +18,6 @@ class Account::TransfersControllerTest < ActionDispatch::IntegrationTest to_account_id: accounts(:credit_card).id, date: Date.current, amount: 100, - currency: "USD", name: "Test Transfer" } }