mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Match Plaid holding values on current day (#2212)
* Match Plaid holding values on current day * Fix chart timezone issue * Add timezone tests for syncs * Hide sidebars on trades test
This commit is contained in:
@@ -18,6 +18,26 @@ class Holding::ForwardCalculatorTest < ActiveSupport::TestCase
|
||||
assert_equal [], calculated
|
||||
end
|
||||
|
||||
test "holding generation respects user timezone and last generated date is current user date" do
|
||||
# Simulate user in EST timezone
|
||||
Time.zone = "America/New_York"
|
||||
|
||||
# Set current time to 1am UTC on Jan 5, 2025
|
||||
# This would be 8pm EST on Jan 4, 2025 (user's time, and the last date we should generate holdings for)
|
||||
travel_to Time.utc(2025, 01, 05, 1, 0, 0)
|
||||
|
||||
voo = Security.create!(ticker: "VOO", name: "Vanguard S&P 500 ETF")
|
||||
Security::Price.create!(security: voo, date: "2025-01-02", price: 500)
|
||||
Security::Price.create!(security: voo, date: "2025-01-03", price: 500)
|
||||
Security::Price.create!(security: voo, date: "2025-01-04", price: 500)
|
||||
create_trade(voo, qty: 10, date: "2025-01-03", price: 500, account: @account)
|
||||
|
||||
expected = [ [ "2025-01-02", 0 ], [ "2025-01-03", 5000 ], [ "2025-01-04", 5000 ] ]
|
||||
calculated = Holding::ForwardCalculator.new(@account).calculate
|
||||
|
||||
assert_equal expected, calculated.map { |b| [ b.date.to_s, b.amount ] }
|
||||
end
|
||||
|
||||
test "forward portfolio calculation" do
|
||||
load_prices
|
||||
|
||||
|
||||
Reference in New Issue
Block a user