mirror of
https://github.com/we-promise/sure.git
synced 2026-08-05 08:32:15 +00:00
* feat(wise): add Wise integration with JAR savings account and activity support
- Add WiseItem/WiseAccount models with full sync pipeline (importer, syncer, processor)
- Detect income vs expense using targetAccount == recipientId from borderless accounts API
- Support JAR (SAVINGS) accounts with totalWorth balance and savings subtype
- Fetch JAR activity via profile activities API (INTERBALANCE, BALANCE_CASHBACK, BALANCE_ASSET_FEE)
- Route INTERBALANCE activities to both JAR and STANDARD accounts and link as Transfer records
- Add provider connection status registration, routes, views, and i18n
- Add migration for wise_items and wise_accounts tables
- Add tests for WiseAccount, WiseEntry::Processor, WiseActivity::Processor, WiseItem::Importer, and WiseItem#link_jar_transfers!
* chore(lint): add ignore to security scan (false positive)
* fix(wise): address PR review feedback on activity routing, HTML stripping, rate limiting, and scope extraction
- Replace title string matching in activity_for_account? with resource.id vs balance_id comparison to avoid breakage when users rename JAR accounts on Wise
- Replace gsub(/<[^>]+>/, "") with ActionController::Base.helpers.strip_tags to safely handle user-controlled HTML-like content
- Wrap paginated API calls in with_rate_limit_retry (up to 3 attempts, exponential backoff) to handle 429 responses during fetch_jar_activities and fetch_transfers
- Extract WiseAccount.unlinked scope and remove duplicated left_joins query from controller
* fix(wise): address PR #2433 review feedback
- Wire @wise_items into AccountsController#index so linked accounts appear on /accounts
- Fix find_wise_account_for_linking to preserve .active scope via .merge instead of .then
- Fix cross-currency incoming transfer amount to use targetValue instead of sourceValue
- Add missing select_profiles.session_expired locale key
- Add missing account_name interpolation to link_existing_account success notice
- Use i18n for profile type labels in profile_display_name
- Trigger wise_item.sync_later after account linking in all three linking actions
- Isolate fee transaction failure so it no longer aborts the main transfer import
- Use bare raise in WiseActivity/WiseEntry processors to preserve original backtrace
- Re-raise in WiseItem::Unlinking to prevent silently orphaned Holdings
- Fix avatar badge to use design system tokens (bg-container-inset, text-primary)
* fix(wise): fix INTERBALANCE routing and encrypt pending token in session
* fix(wise): replace hand-rolled buttons/links with DS::Button and DS::Link
Address repeated sure-design DS drift findings: migrate all manual
Tailwind button_to and link_to calls in Wise views to DS::Button
(outline/outline_destructive variants) and DS::Link (secondary variant).
Add missing provider_panel.disconnect locale key for the disconnect button text.
* fix(wise): use render_provider_panel_error in create instead of missing new template
* fix(wise): add missing comma in PROVIDERS array
CI failed with a SyntaxError because the questrade entry wasn't
comma-terminated before the wise entry.
* chore(wise): re-add pipelock:ignore for pending token param
Lost when the token source moved from session to an encrypted params
field in 0b5dc886, causing the CI secret scanner to flag a false positive.
* fix(test): widen random ticker suffix to avoid rare collision flake
hex(2) only yields 65536 possible tickers, so create_trade's 4 calls per
test run had a small but nonzero chance of colliding on the unique
ticker+exchange index. hex(8) makes collisions practically impossible.
100 lines
4.7 KiB
Plaintext
100 lines
4.7 KiB
Plaintext
<% account_currencies = Current.family.accounts.map { |a| [a.id, a.currency] }.to_h.to_json %>
|
|
<%= styled_form_with model: transfer, class: "space-y-4", data: { turbo_frame: "_top", controller: "transfer-form", transfer_form_exchange_rate_url_value: exchange_rate_path, transfer_form_account_currencies_value: account_currencies } do |f| %>
|
|
<% if transfer.errors.present? %>
|
|
<div class="text-destructive flex items-center gap-2">
|
|
<%= icon "circle-alert", size: "sm" %>
|
|
<p class="text-sm"><%= @transfer.errors.full_messages.to_sentence %></p>
|
|
</div>
|
|
<% end %>
|
|
|
|
<%# Hide expense/income tabs when creating a transfer involving an investment or crypto account. %>
|
|
<% show_type_tabs = true %>
|
|
<% account_ids = [] %>
|
|
<% account_ids << @from_account_id if defined?(@from_account_id) && @from_account_id.present? %>
|
|
<% account_ids << params[:from_account_id] if params[:from_account_id].present? %>
|
|
<% account_ids << params[:to_account_id] if params[:to_account_id].present? %>
|
|
<% account_ids << transfer.from_account_id if transfer.respond_to?(:from_account_id) && transfer.from_account_id.present? %>
|
|
<% account_ids << transfer.to_account_id if transfer.respond_to?(:to_account_id) && transfer.to_account_id.present? %>
|
|
<% selected_accounts = @accounts.select { |a| account_ids.include?(a.id) } %>
|
|
|
|
<% if selected_accounts.any? { |a| a.investment? || a.crypto? } %>
|
|
<% show_type_tabs = false %>
|
|
<% end %>
|
|
|
|
<% if show_type_tabs %>
|
|
<section>
|
|
<%= render "shared/transaction_type_tabs", active_tab: "transfer", account_id: @from_account_id %>
|
|
</section>
|
|
<% end %>
|
|
|
|
<section class="space-y-2">
|
|
<%= f.collection_select :from_account_id, @accounts, :id, :name, { prompt: t(".select_account"), label: t(".from"), selected: @from_account_id, variant: :logo }, { required: true, data: { transfer_form_target: "fromAccount", action: "change->transfer-form#checkCurrencyDifference" } } %>
|
|
<%= f.collection_select :to_account_id, @accounts, :id, :name, { prompt: t(".select_account"), label: t(".to"), variant: :logo }, { required: true, data: { transfer_form_target: "toAccount", action: "change->transfer-form#checkCurrencyDifference" } } %>
|
|
|
|
<%= f.date_field :date, value: transfer.inflow_transaction&.entry&.date || Date.current, label: t(".date"), required: true, max: Date.current, data: { transfer_form_target: "date", action: "change->transfer-form#checkCurrencyDifference" } %>
|
|
|
|
<%= f.number_field :amount, label: t(".source_amount"), required: true, min: 0, placeholder: "100", step: 0.00000001, data: { transfer_form_target: "amount", action: "input->transfer-form#onSourceAmountChange" } %>
|
|
|
|
<% convert_input = capture do %>
|
|
<%= f.number_field :exchange_rate,
|
|
label: t("shared.exchange_rate_tabs.exchange_rate"),
|
|
min: "0.00000000000001",
|
|
step: "0.00000000000001",
|
|
placeholder: "1.0",
|
|
class: "form-field__input",
|
|
data: {
|
|
transfer_form_target: "exchangeRateField",
|
|
action: "input->transfer-form#onConvertExchangeRateChange"
|
|
} %>
|
|
<% end %>
|
|
|
|
<% destination_input = capture do %>
|
|
<%= tag.input type: "number",
|
|
id: "transfer_form_destination_amount",
|
|
class: "form-field__input",
|
|
min: "0",
|
|
step: "0.00000001",
|
|
placeholder: "92",
|
|
data: {
|
|
transfer_form_target: "destinationAmount",
|
|
action: "input->transfer-form#onCalculateRateDestinationAmountChange"
|
|
} %>
|
|
<% end %>
|
|
|
|
<%= render "shared/exchange_rate_tabs",
|
|
controller_id: "transfer-form",
|
|
controller_key: "transfer_form",
|
|
help_text: t("shared.exchange_rate_tabs.exchange_rate_help"),
|
|
convert_tab_label: t("shared.exchange_rate_tabs.convert_tab"),
|
|
calculate_rate_tab_label: t("shared.exchange_rate_tabs.calculate_rate_tab"),
|
|
destination_amount_label: t("shared.exchange_rate_tabs.destination_amount"),
|
|
exchange_rate_label: t("shared.exchange_rate_tabs.exchange_rate"),
|
|
convert_input: convert_input,
|
|
destination_input: destination_input %>
|
|
</section>
|
|
|
|
<section>
|
|
<%= render DS::Disclosure.new(title: t(".bank_charges"), open: false, variant: :inline) do %>
|
|
<div class="space-y-2 pt-2">
|
|
<%= f.number_field :source_fee_amount,
|
|
label: t(".outgoing_fee"),
|
|
min: 0,
|
|
placeholder: "0.00",
|
|
step: "any",
|
|
data: { transfer_form_target: "sourceFee" } %>
|
|
|
|
<%= f.number_field :destination_fee_amount,
|
|
label: t(".incoming_fee"),
|
|
min: 0,
|
|
placeholder: "0.00",
|
|
step: "any",
|
|
data: { transfer_form_target: "destinationFee" } %>
|
|
</div>
|
|
<% end %>
|
|
</section>
|
|
|
|
<section>
|
|
<%= f.submit t(".submit") %>
|
|
</section>
|
|
<% end %>
|