Files
sure/app/views/trades/show.html.erb
Zach Gollwitzer 03a146222d 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
2025-05-23 18:58:22 -04:00

99 lines
3.6 KiB
Plaintext

<%= render DialogComponent.new(variant: "drawer") do |dialog| %>
<% dialog.with_header do %>
<%= render "trades/header", entry: @entry %>
<% end %>
<% trade = @entry.trade %>
<% dialog.with_body do %>
<% dialog.with_section(title: t(".details"), open: true) do %>
<div class="pb-4">
<%= styled_form_with model: @entry,
url: trade_path(@entry),
class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %>
<%= 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" }, 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",
disabled: @entry.linked? %>
<% end %>
</div>
<%= f.fields_for :entryable do |ef| %>
<%= ef.money_field :price,
label: t(".cost_per_share_label"),
disable_currency: true,
auto_submit: true,
min: 0,
disabled: @entry.linked? %>
<% end %>
<% end %>
</div>
<% end %>
<% dialog.with_section(title: t(".additional")) do %>
<div class="pb-4">
<%= styled_form_with model: @entry,
url: trade_path(@entry),
class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %>
<%= f.text_area :notes,
label: t(".note_label"),
placeholder: t(".note_placeholder"),
rows: 5,
"data-auto-submit-form-target": "auto" %>
<% end %>
</div>
<% end %>
<% dialog.with_section(title: t(".settings")) do %>
<div class="pb-4">
<!-- Exclude Trade Form -->
<%= styled_form_with model: @entry,
url: trade_path(@entry),
class: "p-3",
data: { controller: "auto-submit-form" } do |f| %>
<div class="flex cursor-pointer items-center gap-2 justify-between">
<div class="text-sm space-y-1">
<h4 class="text-primary"><%= t(".exclude_title") %></h4>
<p class="text-secondary"><%= t(".exclude_subtitle") %></p>
</div>
<%= f.toggle :excluded, { data: { auto_submit_form_target: "auto" } } %>
</div>
<% end %>
<!-- Delete Trade Form -->
<div class="flex items-center justify-between gap-2 p-3">
<div class="text-sm space-y-1">
<h4 class="text-primary"><%= t(".delete_title") %></h4>
<p class="text-secondary"><%= t(".delete_subtitle") %></p>
</div>
<%= button_to t(".delete"),
entry_path(@entry),
method: :delete,
class: "rounded-lg px-3 py-2 text-red-500 text-sm
font-medium border border-secondary",
data: { turbo_confirm: true } %>
</div>
</div>
<% end %>
<% end %>
<% end %>