Account Creation#
Account creation in Sure is a two-step onboarding flow:
- Type selection — the user picks an account type (Depository, Investment, CreditCard, Loan, Crypto, Property, Vehicle, OtherAsset, OtherLiability) from
accounts/new.html.erb. An optional?classification=asset|liabilityparam pre-filters the list. - Method selection — the user chooses between manual entry or linking a banking provider, rendered by the
_method_selectorpartial.
Each type card is a link generated by the _account_type partial, routing to new_polymorphic_path(accountable, step: "method_select"). Step 2 is gated on params[:step] == "method_select" in the type-specific new view (e.g., depositories/new.html.erb); without it, the form renders directly.
Polymorphic Architecture#
All account-type controllers (Depositories, Investments, CreditCards, Loans, etc.) share CRUD actions via the AccountableResource concern. The concern's create action:
- Parses
opening_balance_datefrom the form; defaults to two years ago if absent . - Calls
Account.create_and_sync, which creates an opening-anchorValuation(viaAccount::OpeningBalanceManager) and enqueues a balance sync. - Locks saved attributes on the new account immediately after creation .
- Permitted params:
name,balance,subtype,currency,opening_balance_date,institution_name,institution_domain,notes,exclude_from_reports.
The concern derives the accountable type from the controller name at runtime via controller_name.classify.constantize , so no extra configuration is needed when adding new account types.
Available provider connections for the chosen account type are populated by Provider::Factory.connection_configs_for_account_type in the set_link_options before-action .
Depository Subtypes#
Depository is the most granular account type, with five subtypes :
| Key | Long name |
|---|---|
checking (default) | Checking |
savings | Savings |
hsa | Health Savings Account |
cd | Certificate of Deposit |
money_market | Money Market |
The subtype is selected from a drop-down rendered in depositories/_form.html.erb, which wraps the shared accounts/form partial.
hsa is the only TAX_ADVANTAGED_SUBTYPE . Because Plaid routes depository.hsa to Depository (not Investment), Depository#tax_treatment returns :tax_advantaged for HSA records so they are correctly included in the family's tax_advantaged_account_ids filter . All other subtypes return nil (treated as taxable, no tax badge shown).
Manual vs. Linked Provider#
The method selector always renders a manual entry option. Provider links are dynamically populated from @provider_configs but are admin-only — non-admin users cannot initiate a provider connection from this screen .
Manual accounts have no account_providers record. They use the forward balance strategy: starting from the opening-anchor Valuation, balance history is projected forward day-by-day as transactions are entered. See Manual Account Entry and Import for details on the forward calculator and file-based import alternatives.
Linked accounts connect through a provider-specific Item → provider account → account_providers polymorphic join → Account chain (e.g., Akahu, EnableBanking). They use the reverse balance strategy, working backward from today's provider-reported balance. See Banking Provider Integration for the full sync architecture.
After account creation, the return_to param (carried through both steps) controls where the user lands — falling back to the session-stored location or the new account page .