From 38c438a614b160ac9c7fd29af4a2ffb94460cfc4 Mon Sep 17 00:00:00 2001 From: Elvis De Abreu <7027367+EdeAbreu23@users.noreply.github.com> Date: Wed, 6 May 2026 16:02:22 -0500 Subject: [PATCH] Fix avg_cost to return per-share cost basis --- app/models/holding.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/holding.rb b/app/models/holding.rb index 0b18b3e9c..123eef9c3 100644 --- a/app/models/holding.rb +++ b/app/models/holding.rb @@ -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