1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 03:55:20 +02:00

Add test cases for multi-currency investment syncing

This commit is contained in:
Zach Gollwitzer 2024-08-13 16:32:07 -04:00
parent 0691041d37
commit 993be6615a
5 changed files with 101 additions and 23 deletions

View file

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