% content_for :title, "Set Up SimpleFin Accounts" %>
<%= render DS::Dialog.new do |dialog| %>
<% dialog.with_header(title: "Set Up Your SimpleFin Accounts") do %>
<%= icon "building-2", class: "text-primary" %>
Choose the correct account types for your imported accounts
<% end %>
<% dialog.with_body do %>
<%= form_with url: complete_account_setup_simplefin_item_path(@simplefin_item),
method: :post,
local: true,
data: {
controller: "loading-button",
action: "submit->loading-button#showLoading",
loading_button_loading_text_value: "Creating Accounts...",
turbo_frame: "_top"
},
class: "space-y-6" do |form| %>
<%= icon "info", size: "sm", class: "text-primary mt-0.5 flex-shrink-0" %>
Choose the correct account type for each SimpleFin account:
- Checking or Savings - Regular bank accounts
- Credit Card - Credit card accounts
- Investment - Brokerage, 401(k), IRA accounts
- Loan or Mortgage - Debt accounts
- Other Asset - Everything else
<%= icon "calendar", size: "sm", class: "text-primary mt-0.5 flex-shrink-0" %>
Historical Data Range:
<%= form.date_field :sync_start_date,
label: "Start syncing transactions from:",
value: @simplefin_item.sync_start_date || 1.year.ago.to_date,
min: 3.years.ago.to_date,
max: Date.current,
class: "w-full max-w-xs",
help_text: "Select how far back you want to sync transaction history. Maximum 3 years of history available." %>
<% @simplefin_accounts.each do |simplefin_account| %>
<%= simplefin_account.name %>
<% if simplefin_account.org_data.present? && simplefin_account.org_data['name'].present? %>
• <%= simplefin_account.org_data["name"] %>
<% end %>
Balance: <%= number_to_currency(simplefin_account.current_balance || 0, unit: simplefin_account.currency) %>
<%= label_tag "account_types[#{simplefin_account.id}]", "Account Type:",
class: "block text-sm font-medium text-primary mb-2" %>
<% inferred = @inferred_map[simplefin_account.id] || {} %>
<% selected_type = inferred[:confidence] == :high ? inferred[:type] : "skip" %>
<%= select_tag "account_types[#{simplefin_account.id}]",
options_for_select(@account_type_options, selected_type),
{ class: "appearance-none bg-container border border-primary rounded-md px-3 py-2 text-sm leading-6 text-primary focus:border-primary focus:ring-1 focus:ring-primary focus:outline-none w-full",
data: {
action: "change->account-type-selector#updateSubtype"
} } %>
<% @subtype_options.each do |account_type, subtype_config| %>
<%= render "subtype_select", account_type: account_type, subtype_config: subtype_config, simplefin_account: simplefin_account %>
<% end %>
<% end %>
<%= render DS::Button.new(
text: "Create Accounts",
variant: "primary",
icon: "plus",
type: "submit",
class: "flex-1",
data: { loading_button_target: "button" }
) %>
<%= render DS::Link.new(
text: "Cancel",
variant: "secondary",
href: accounts_path
) %>
<% end %>
<% end %>
<% end %>