mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Plaid sync domain improvements (#2267)
Breaks our Plaid sync process out into more manageable classes. Notably, this moves the sync process to a distinct, 2-step flow: 1. Import stage - we first make API calls and import Plaid data to "mirror" tables 2. Processing stage - read the raw data, apply business rules, build internal domain models and sync balances This provides several benefits: - Plaid syncs can now be "replayed" without fetching API data again - Mirror tables provide better audit and debugging capabilities - Eliminates the "all or nothing" sync behavior that is currently in place, which is brittle
This commit is contained in:
parent
5c82af0e8c
commit
03a146222d
72 changed files with 3763 additions and 706 deletions
|
@ -34,6 +34,7 @@
|
|||
min: options[:min] || -99999999999999,
|
||||
max: options[:max] || 99999999999999,
|
||||
step: currency.step,
|
||||
disabled: options[:disabled],
|
||||
data: {
|
||||
"money-field-target": "amount",
|
||||
"auto-submit-form-target": ("auto" if options[:auto_submit])
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
<%= entry.currency %>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
<% if entry.linked? %>
|
||||
<span title="Linked with Plaid">
|
||||
<%= icon("refresh-ccw", size: "sm") %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<span class="text-sm text-secondary">
|
||||
|
|
|
@ -15,20 +15,22 @@
|
|||
<%= f.date_field :date,
|
||||
label: t(".date_label"),
|
||||
max: Date.current,
|
||||
disabled: @entry.linked?,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<%= f.select :nature,
|
||||
[["Buy", "outflow"], ["Sell", "inflow"]],
|
||||
{ container_class: "w-1/3", label: "Type", selected: @entry.amount.negative? ? "inflow" : "outflow" },
|
||||
{ data: { "auto-submit-form-target": "auto" } } %>
|
||||
{ data: { "auto-submit-form-target": "auto" }, disabled: @entry.linked? } %>
|
||||
|
||||
<%= f.fields_for :entryable do |ef| %>
|
||||
<%= ef.number_field :qty,
|
||||
label: t(".quantity_label"),
|
||||
step: "any",
|
||||
value: trade.qty.abs,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
"data-auto-submit-form-target": "auto",
|
||||
disabled: @entry.linked? %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
@ -37,7 +39,8 @@
|
|||
label: t(".cost_per_share_label"),
|
||||
disable_currency: true,
|
||||
auto_submit: true,
|
||||
min: 0 %>
|
||||
min: 0,
|
||||
disabled: @entry.linked? %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
<% if entry.transaction.transfer? %>
|
||||
<%= icon "arrow-left-right", class: "mt-1" %>
|
||||
<% end %>
|
||||
|
||||
<% if entry.linked? %>
|
||||
<span title="Linked with Plaid">
|
||||
<%= icon("refresh-ccw", size: "sm") %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<span class="text-sm text-secondary">
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<%= f.date_field :date,
|
||||
label: t(".date_label"),
|
||||
max: Date.current,
|
||||
disabled: @entry.linked?,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
|
||||
<% unless @entry.transaction.transfer? %>
|
||||
|
@ -25,13 +26,15 @@
|
|||
<%= f.select :nature,
|
||||
[["Expense", "outflow"], ["Income", "inflow"]],
|
||||
{ container_class: "w-1/3", label: t(".nature"), selected: @entry.amount.negative? ? "inflow" : "outflow" },
|
||||
{ data: { "auto-submit-form-target": "auto" } } %>
|
||||
{ data: { "auto-submit-form-target": "auto" }, disabled: @entry.linked? } %>
|
||||
|
||||
<%= f.money_field :amount, label: t(".amount"),
|
||||
container_class: "w-2/3",
|
||||
auto_submit: true,
|
||||
min: 0,
|
||||
value: @entry.amount.abs %>
|
||||
value: @entry.amount.abs,
|
||||
disabled: @entry.linked?,
|
||||
disable_currency: @entry.linked? %>
|
||||
</div>
|
||||
|
||||
<%= f.fields_for :entryable do |ef| %>
|
||||
|
@ -66,7 +69,7 @@
|
|||
<%= f.fields_for :entryable do |ef| %>
|
||||
|
||||
<%= ef.collection_select :merchant_id,
|
||||
Current.family.merchants.alphabetically,
|
||||
[@entry.transaction.merchant, *Current.family.merchants.alphabetically].compact,
|
||||
:id, :name,
|
||||
{ include_blank: t(".none"),
|
||||
label: t(".merchant_label"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue