Files
sure/app/views/accounts/index.html.erb
Oscar c6a240a183 feat(redbark): add australian bank sync (redbark) (#2794)
* add redbark provider integration

- per family api key provider, built like the lunchflow integration
- syncs accounts, balances and transactions from api.redbark.com
- account setup flow, settings panel, locales and routes
- tests and fixtures

* harden redbark integration based on prior provider pr feedback

- use DebugLogEntry.capture for sync/import/unlink failures
- retry 429s and 5xxs with backoff, raise on page cap instead of truncating
- keep raw response bodies out of logs and errors
- not null constraints on account columns, migration base 7.2
- persist ignored flag for skipped accounts so they stop nagging setup
- validate api key on every save, re-arm status on key rotation
- destroy aborts if unlink fails, atomic account create and link
- require_admin on mutating actions, see_other on error redirects
- single grouped query for item account counts
- i18n default connection name, blank password field value
- controller and provider tests

* fix issues found in second review sweep

- add missing syncable scope, without it every family sync raises
- kick off a sync on connection create and on key rotation
- setup dialog fetches accounts inline for fresh connections and shows api errors
- skip balance write when no balance has been fetched yet, never anchor a false zero
- exclude stale and non banking accounts from the batched balances call, per account fallback if the batch is rejected
- detect the server row ceiling and empty pages instead of silently truncating history
- user sync start date only governs the initial backfill, incremental after that
- fetch connections before the per account loop so auth errors propagate once
- drop untemplated index/show/new/edit routes and dead preload/link_accounts actions
- stable dom id on the settings panel so repeat turbo replaces keep working

* skip brokerage connections, found in live testing

- the transactions endpoint 400s for brokerage connections, they belong to /v1/trades
- only import accounts from banking and documents connections
- guard transaction fetches for any legacy linked non banking account

* address review feedback

- treat the truncation header as a pagination signal: split the date window and refetch instead of failing the account
- prune stale pending rows from the snapshot so settled pendings cant come back as duplicates
- block linking a sure account that already has another provider feed
- count setup failures separately from skips and surface an error instead of "all skipped"
- add not nulls on redbark_items name and api key
- enqueue the destroy job after the flag commits, not inside the transaction
- swap bg-gray-400 for bg-surface-inset, drop amounts from info logs, remove i18n default fallbacks
- tests for window splitting, pending pruning and encrypted payload round trip

* fix issues from convention review

- benign skips (unlinked account, blank id, unparseable rows) no longer count as failures, tracked separately so a clean batch reports success
- currency parsing goes through extract_currency so hash shaped payloads resolve instead of falling to the default
- merchant ids use truncated sha256 instead of md5
- debug log entries for import failures and account sync scheduling failures

* bound the raw transactions snapshot to the fetch window

- trim raw_transactions_payload to the current fetch window on merge, same as brex
- keep rows without a parseable date, drop settled pendings as before
- surface skipped rows in the aggregate debug log entry with imported/skipped counts
2026-07-26 07:40:25 +02:00

115 lines
3.5 KiB
Plaintext

<%= content_for :page_title, t(".accounts") %>
<%= content_for :page_actions do %>
<%= icon(
"refresh-cw",
as_button: true,
size: "sm",
href: sync_all_accounts_path,
disabled: Current.family.syncing?,
frame: :_top
) %>
<% if (family_sync = Current.family.syncs.visible.first) %>
<%= button_to cancel_sync_path(family_sync),
method: :post,
class: "flex items-center gap-1 text-sm text-secondary hover:text-primary",
aria: { label: t(".cancel_sync") },
data: { turbo_frame: :_top } do %>
<%= icon "circle-x", class: "w-4 h-4" %>
<span><%= t(".cancel_sync") %></span>
<% end %>
<% end %>
<%= render DS::Link.new(
text: t(".new_account"),
href: new_account_path(return_to: accounts_path),
variant: "primary",
icon: "plus",
frame: :modal
) %>
<% end %>
<% if @manual_accounts.empty? && @plaid_items.empty? && @simplefin_items.empty? && @lunchflow_items.empty? && @redbark_items.empty? && @akahu_items.empty? && @up_items.empty? && @enable_banking_items.empty? && @coinstats_items.empty? && @coinbase_items.empty? && @mercury_items.empty? && @brex_items.empty? && @ibkr_items.empty? && @snaptrade_items.empty? && @indexa_capital_items.empty? && @sophtron_items.empty? && @binance_items.empty? && @questrade_items.empty? && @wise_items.empty? %>
<%= render "empty" %>
<% else %>
<div class="space-y-2">
<% if @plaid_items.any? %>
<%= render @plaid_items.sort_by(&:created_at) %>
<% end %>
<% if @simplefin_items.any? %>
<%= render @simplefin_items.sort_by(&:created_at) %>
<% end %>
<% if @lunchflow_items.any? %>
<%= render @lunchflow_items.sort_by(&:created_at) %>
<% end %>
<% if @redbark_items.any? %>
<%= render @redbark_items.sort_by(&:created_at) %>
<% end %>
<% if @akahu_items.any? %>
<%= render @akahu_items.sort_by(&:created_at) %>
<% end %>
<% if @up_items.any? %>
<%= render @up_items.sort_by(&:created_at) %>
<% end %>
<% if @enable_banking_items.any? %>
<%= render @enable_banking_items.sort_by(&:created_at) %>
<% end %>
<% if @coinstats_items.any? %>
<%= render @coinstats_items.sort_by(&:created_at) %>
<% end %>
<% if @sophtron_items.any? %>
<%= render @sophtron_items.sort_by(&:created_at) %>
<% end %>
<% if @mercury_items.any? %>
<%= render @mercury_items.sort_by(&:created_at) %>
<% end %>
<% if @brex_items.any? %>
<%= render @brex_items.sort_by(&:created_at) %>
<% end %>
<% if @coinbase_items.any? %>
<%= render @coinbase_items.sort_by(&:created_at) %>
<% end %>
<% if @binance_items.any? %>
<%= render @binance_items.sort_by(&:created_at) %>
<% end %>
<% if @wise_items.any? %>
<%= render @wise_items.sort_by(&:created_at) %>
<% end %>
<% if @snaptrade_items.any? %>
<%= render @snaptrade_items.sort_by(&:created_at) %>
<% end %>
<% if @ibkr_items.any? %>
<%= render @ibkr_items.sort_by(&:created_at) %>
<% end %>
<% if @indexa_capital_items.any? %>
<%= render @indexa_capital_items.sort_by(&:created_at) %>
<% end %>
<% if @questrade_items.any? %>
<%= render @questrade_items.sort_by(&:created_at) %>
<% end %>
<% if @manual_accounts.any? %>
<div id="manual-accounts">
<%= render "accounts/index/manual_accounts", accounts: @manual_accounts %>
</div>
<% else %>
<div id="manual-accounts"></div>
<% end %>
</div>
<% end %>