diff --git a/app/models/account/holding.rb b/app/models/account/holding.rb index 7f0bad7a..3b6ce472 100644 --- a/app/models/account/holding.rb +++ b/app/models/account/holding.rb @@ -8,7 +8,6 @@ class Account::Holding < ApplicationRecord validates :qty, :currency, :date, :price, :amount, presence: true validates :qty, :price, :amount, numericality: { greater_than_or_equal_to: 0 } - validate :amount_matches_qty_and_price scope :chronological, -> { order(:date) } scope :for, ->(security) { where(security_id: security).order(:date) } @@ -64,13 +63,4 @@ class Account::Holding < ApplicationRecord current: amount_money, previous: start_amount end - - def amount_matches_qty_and_price - return if qty.blank? || price.blank? || amount.blank? - - expected_amount = qty * price - return if amount == expected_amount - - errors.add(:amount, "must equal qty * price (expected: #{expected_amount})") - end end