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

holding: Add multi-currency support for average costs calculations. (#2153)

Fixes: #2051.
This commit is contained in:
Joseph Ho 2025-05-06 12:12:44 -04:00 committed by GitHub
parent 60c3a04a48
commit 8c10e87387
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 11 deletions

View file

@ -28,20 +28,20 @@ module EntriesTestHelper
Entry.create! entry_defaults.merge(attributes)
end
def create_trade(security, account:, qty:, date:, price: nil)
def create_trade(security, account:, qty:, date:, price: nil, currency: "USD")
trade_price = price || Security::Price.find_by!(security: security, date: date).price
trade = Trade.new \
qty: qty,
security: security,
price: trade_price,
currency: "USD"
price: trade_price,
currency: currency
account.entries.create! \
name: "Trade",
date: date,
amount: qty * trade_price,
currency: "USD",
currency: currency,
entryable: trade
end
end