mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-07 06:25:19 +02:00
Add reconciliation manager (#2459)
* Add reconciliation manager * Fix notes editing
This commit is contained in:
parent
89cc64418e
commit
52333e3fa6
11 changed files with 273 additions and 64 deletions
|
@ -28,19 +28,4 @@ class Investment < ApplicationRecord
|
|||
"line-chart"
|
||||
end
|
||||
end
|
||||
|
||||
def holdings_value_for_date(date)
|
||||
# Find the most recent holding for each security on or before the given date
|
||||
# Using a subquery to get the max date for each security
|
||||
account.holdings
|
||||
.where(currency: account.currency)
|
||||
.where("date <= ?", date)
|
||||
.where("(security_id, date) IN (
|
||||
SELECT security_id, MAX(date) as max_date
|
||||
FROM holdings
|
||||
WHERE account_id = ? AND date <= ?
|
||||
GROUP BY security_id
|
||||
)", account.id, date)
|
||||
.sum(:amount)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue