mirror of
https://github.com/we-promise/sure.git
synced 2026-05-09 21:54:58 +00:00
Fix avg_cost to return per-share cost basis
This commit is contained in:
@@ -51,8 +51,8 @@ class Holding < ApplicationRecord
|
||||
# - If locked (user-set), trust the value even if 0 (valid for airdrops)
|
||||
# - Otherwise require positive since providers sometimes return 0 when unknown
|
||||
if cost_basis.present?
|
||||
if cost_basis_locked? || cost_basis.positive?
|
||||
return Money.new(cost_basis, currency)
|
||||
if (cost_basis_locked? || cost_basis.positive?) && qty.to_f > 0
|
||||
return Money.new(cost_basis / qty, currency)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user