1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Refactor: Use native error i18n lookup (#1076)

This commit is contained in:
Pedro Carmona 2024-08-13 01:38:58 +01:00 committed by GitHub
parent 150fce41a8
commit 14c4b9e93c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 103 additions and 26 deletions

View file

@ -204,7 +204,14 @@ class Account::Entry < ApplicationRecord
current_qty = account.holding_qty(account_trade.security)
if current_qty < account_trade.qty.abs
errors.add(:base, "cannot sell #{account_trade.qty.abs} shares of #{account_trade.security.ticker} because you only own #{current_qty} shares")
# i18n-tasks-use t('activerecord.errors.models.account/entry.attributes.base.invalid_sell_quantity')
errors.add(
:base,
:invalid_sell_quantity,
sell_qty: account_trade.qty.abs,
ticker: account_trade.security.ticker,
current_qty: current_qty
)
end
end
end