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

Plaid portfolio sync algorithm and calculation improvements (#1526)

* Start tests rework

* Cash balance on schema

* Add reverse syncer

* Reverse balance sync with holdings

* Reverse holdings sync

* Reverse holdings sync should work with only trade entries

* Consolidate brokerage cash

* Add forward sync option

* Update new balance info after syncs

* Intraday balance calculator and sync fixes

* Show only balance for trade entries

* Tests passing

* Update Gemfile.lock

* Cleanup, performance improvements

* Remove account reloads for reliable sync outputs

* Simplify valuation view logic

* Special handling for Plaid cash holding
This commit is contained in:
Zach Gollwitzer 2024-12-10 17:41:20 -05:00 committed by GitHub
parent a59ca5b7c6
commit 49c353e10c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 1152 additions and 1046 deletions

View file

@ -1,5 +0,0 @@
<%# locals: (account:) %>
<%= turbo_frame_tag dom_id(account, :cash), src: account_cashes_path(account_id: account.id) do %>
<%= render "account/entries/loading" %>
<% end %>

View file

@ -1,21 +0,0 @@
<%# locals: (account:, **args) %>
<div id="<%= dom_id(account, :chart) %>" class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg">
<div class="p-4 flex justify-between">
<div class="space-y-2">
<div class="flex items-center gap-1">
<%= tag.p t(".value"), class: "text-sm font-medium text-gray-500" %>
</div>
<%= tag.p format_money(account.value), class: "text-gray-900 text-3xl font-medium" %>
</div>
</div>
<div class="relative h-64 flex items-center justify-center">
<%= image_tag "placeholder-graph.svg", class: "w-full h-full object-cover rounded-bl-lg rounded-br-lg opacity-50" %>
<div class="absolute top-0 left-0 w-full h-full flex flex-col items-center justify-center space-y-1">
<p class="text-gray-900 text-sm">Historical investment data coming soon.</p>
<p class="text-gray-500 text-sm">We're working to bring you the full picture.</p>
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
<%# locals: (value:, cash:) %>
<%# locals: (balance:, holdings:, cash:) %>
<div data-controller="tooltip" data-tooltip-placement-value="right" data-tooltip-offset-value=10 data-tooltip-cross-axis-value=50>
<%= lucide_icon("info", class: "w-4 h-4 shrink-0 text-gray-500") %>
@ -7,14 +7,6 @@
<%= t(".total_value_tooltip") %>
</div>
<div class="flex pt-3">
<div class="text-gray-300">
<%= t(".holdings") %>
</div>
<div class="text-white ml-auto">
<%= tag.p format_money(value, precision: 0) %>
</div>
</div>
<div class="flex">
<div class="text-gray-300">
<%= t(".cash") %>
</div>
@ -22,5 +14,24 @@
<%= tag.p format_money(cash, precision: 0) %>
</div>
</div>
<div class="flex">
<div class="text-gray-300">
<%= t(".holdings") %>
</div>
<div class="text-white ml-auto">
<%= tag.p format_money(holdings, precision: 0) %>
</div>
</div>
<hr class="my-2 border-gray-500">
<div class="flex">
<div class="text-gray-300">
<%= t(".total") %>
</div>
<div class="text-white font-bold ml-auto">
<%= tag.p format_money(balance, precision: 0) %>
</div>
</div>
</div>
</div>

View file

@ -4,24 +4,20 @@
<%= tag.div class: "space-y-4" do %>
<%= render "accounts/show/header", account: @account %>
<% if @account.plaid_account_id.present? %>
<%= render "investments/chart", account: @account %>
<% else %>
<%= render "accounts/show/chart",
<%= render "accounts/show/chart",
account: @account,
title: t(".chart_title"),
tooltip: render(
"investments/value_tooltip",
value: @account.value,
cash: @account.balance_money
balance: @account.balance_money,
holdings: @account.balance - @account.cash_balance,
cash: @account.cash_balance
) %>
<% end %>
<div class="min-h-[800px]">
<%= render "accounts/show/tabs", account: @account, tabs: [
{ key: "activity", contents: render("accounts/show/activity", account: @account) },
{ key: "holdings", contents: render("investments/holdings_tab", account: @account) },
{ key: "cash", contents: render("investments/cash_tab", account: @account) }
{ key: "activity", contents: render("accounts/show/activity", account: @account) },
] %>
</div>
<% end %>