The personal finance app for everyone (by everyone)
Ruby
<%# locals: (import:) %>
<div class="h-full flex flex-col justify-center items-center">
<div class="space-y-6 max-w-lg w-full">
<% if import.pending? && import.rows_count > 0 %>
<%# Statement with rows ready for review %>
<div class="mx-auto bg-success/10 h-8 w-8 rounded-full flex items-center justify-center">
<%= icon "check", class: "text-success" %>
</div>
<div class="text-center space-y-2">
<h1 class="font-medium text-primary text-center text-3xl"><%= t("imports.pdf_import.ready_for_review_title") %></h1>
<p class="text-sm text-secondary"><%= t("imports.pdf_import.ready_for_review_description", count: import.rows_count) %></p>
</div>
<div class="bg-container border border-primary rounded-xl p-4 space-y-4">
<% if import.account_statement.present? %>
<div class="space-y-2">
<h2 class="font-medium text-primary"><%= t("imports.pdf_import.source_statement") %></h2>
<p class="text-sm text-secondary px-3 py-2 bg-container-inset rounded-lg">
<%= link_to import.account_statement.filename, account_statement_path(import.account_statement), class: "text-primary hover:text-primary-hover" %>
</p>
</div>
<% end %>
<div class="space-y-2">
<h2 class="font-medium text-primary"><%= t("imports.pdf_import.document_type_label") %></h2>
<p class="text-sm text-secondary px-3 py-2 bg-container-inset rounded-lg">
<%# PDF document_type is AI-derived and not constrained to Import::DOCUMENT_TYPES;
unknown values should be shown as the localized fallback rather
than exposing an untranslated/internal enum string. %>
<%= t("imports.document_types.#{import.document_type}", default: t("imports.pdf_import.unknown_document_type")) %>
</p>
</div>
<div class="space-y-2">
<h2 class="font-medium text-primary"><%= t("imports.pdf_import.transactions_extracted") %></h2>
<p class="text-sm text-secondary px-3 py-2 bg-container-inset rounded-lg">
<%# rows_count is what is left to import, not what the statement held:
anything the account already had was matched and withheld. Calling
that number "extracted" under-reports the statement. %>
<%= t("imports.pdf_import.transactions_extracted_count", count: import.extracted_count) %>
<% if import.reconciled_anything? %>
<span class="block mt-1 text-xs text-subdued">
<%= t("imports.pdf_import.already_recorded_note", count: import.already_recorded_count) %>
</span>
<% end %>
</p>
</div>
<div class="space-y-2">
<h2 id="pdf-import-select-account" class="font-medium text-primary"><%= t("imports.pdf_import.select_account") %></h2>
<%= styled_form_with model: import, scope: :import, url: import_path(import), method: :patch, class: "space-y-2" do |f| %>
<%# Provider-backed accounts are offered too: rows are matched against
existing transactions before they are ever shown, so importing a
statement for a synced account can no longer duplicate what sync
already brought in. %>
<% accounts = Current.user.accessible_accounts.alphabetically.pluck(:name, :id) %>
<% if accounts.any? %>
<%= f.select :account_id, accounts,
{ include_blank: t("imports.pdf_import.select_account_placeholder"), selected: import.account_id, label: false },
{ "aria-labelledby": "pdf-import-select-account" } %>
<% if import.account.nil? %>
<p class="text-xs text-secondary"><%= t("imports.pdf_import.select_account_hint") %></p>
<% end %>
<% else %>
<p class="text-sm text-secondary px-3 py-2 bg-warning/10 rounded-lg">
<%= t("imports.pdf_import.no_accounts") %>
</p>
<%= render DS::Link.new(text: t("imports.pdf_import.create_account"), href: new_account_path(return_to: import_path(import)), variant: "primary", full_width: true, frame: :modal) %>
<% end %>
<% if accounts.any? %>
<%= f.submit t("imports.pdf_import.save_account") %>
<% end %>
<% end %>
</div>
</div>
<div class="space-y-2 flex flex-col">
<% if import.publishable? %>
<%= render DS::Button.new(
text: t("imports.pdf_import.publish_transactions", count: import.rows_count),
href: publish_import_path(import),
method: :post,
variant: :primary,
full_width: true
) %>
<%= render DS::Link.new(text: t("imports.pdf_import.review_transactions"), href: import_clean_path(import), variant: "secondary", full_width: true) %>
<% elsif import.account.present? %>
<%= render DS::Link.new(text: t("imports.pdf_import.review_transactions"), href: import_clean_path(import), variant: "primary", full_width: true) %>
<% else %>
<p class="text-center text-sm text-secondary"><%= t("imports.pdf_import.select_account_to_continue") %></p>
<% end %>
<%= render DS::Link.new(text: t("imports.pdf_import.view_summary"), href: summary_import_path(import), variant: "secondary", full_width: true, frame: :modal) %>
<%= render DS::Link.new(text: t("imports.pdf_import.back_to_imports"), href: imports_path, variant: "secondary", full_width: true) %>
</div>
<% elsif import.importing? || import.pending? %>
<div class="mx-auto bg-gray-tint-5 h-8 w-8 rounded-full flex items-center justify-center">
<%= icon "loader", class: "animate-pulse" %>
</div>
<div class="text-center space-y-2">
<h1 class="font-medium text-primary text-center text-3xl"><%= t("imports.pdf_import.processing_title") %></h1>
<p class="text-sm text-secondary"><%= t("imports.pdf_import.processing_description") %></p>
</div>
<div class="space-y-2 flex flex-col">
<%= render DS::Link.new(text: t("imports.pdf_import.check_status"), href: import_path(import), variant: "primary", full_width: true) %>
<%= render DS::Link.new(text: t("imports.pdf_import.back_to_dashboard"), href: root_path, variant: "secondary", full_width: true) %>
</div>
<% elsif import.failed? %>
<div class="mx-auto bg-destructive/10 h-8 w-8 rounded-full flex items-center justify-center">
<%= icon "x", class: "text-destructive" %>
</div>
<div class="text-center space-y-2">
<h1 class="font-medium text-primary text-center text-3xl"><%= t("imports.pdf_import.failed_title") %></h1>
<p class="text-sm text-secondary"><%= t("imports.pdf_import.failed_description") %></p>
<% if import.error.present? %>
<p class="text-sm text-destructive"><%= import.error %></p>
<% end %>
</div>
<div class="space-y-2 flex flex-col">
<%= render DS::Link.new(text: t("imports.pdf_import.try_again"), href: new_import_path, variant: "primary", full_width: true) %>
<%= render DS::Button.new(
text: t("imports.pdf_import.delete_import"),
href: import_path(import),
method: :delete,
variant: :secondary,
full_width: true
) %>
</div>
<% elsif import.complete? && import.ai_processed? %>
<div class="mx-auto bg-success/10 h-8 w-8 rounded-full flex items-center justify-center">
<%= icon "check", class: "text-success" %>
</div>
<div class="text-center space-y-2">
<h1 class="font-medium text-primary text-center text-3xl"><%= t("imports.pdf_import.complete_title") %></h1>
<%# A statement whose every line was already on file creates nothing, and
the generic description reads as though the import did nothing at all. %>
<% if import.imported_count.zero? && import.reconciled_anything? %>
<p class="text-sm text-secondary"><%= t("imports.pdf_import.complete_fully_reconciled", count: import.already_recorded_count) %></p>
<% else %>
<p class="text-sm text-secondary"><%= t("imports.pdf_import.complete_description") %></p>
<% end %>
</div>
<div class="bg-container border border-primary rounded-xl p-4 space-y-4">
<% if import.account_statement.present? %>
<div class="space-y-2">
<h2 class="font-medium text-primary"><%= t("imports.pdf_import.source_statement") %></h2>
<p class="text-sm text-secondary px-3 py-2 bg-container-inset rounded-lg">
<%= link_to import.account_statement.filename, account_statement_path(import.account_statement), class: "text-primary hover:text-primary-hover" %>
</p>
</div>
<% end %>
<div class="space-y-2">
<h2 class="font-medium text-primary"><%= t("imports.pdf_import.document_type_label") %></h2>
<p class="text-sm text-secondary px-3 py-2 bg-container-inset rounded-lg">
<%= t("imports.document_types.#{import.document_type}", default: t("imports.pdf_import.unknown_document_type")) %>
</p>
</div>
<div class="space-y-2">
<h2 class="font-medium text-primary"><%= t("imports.pdf_import.summary_label") %></h2>
<p class="text-sm text-secondary px-3 py-2 bg-container-inset rounded-lg whitespace-pre-wrap">
<%= import.ai_summary %>
</p>
</div>
</div>
<div class="text-center">
<p class="text-sm text-secondary"><%= t("imports.pdf_import.email_sent_notice") %></p>
</div>
<div class="space-y-2 flex flex-col">
<%= render DS::Link.new(text: t("imports.pdf_import.view_summary"), href: summary_import_path(import), variant: "primary", full_width: true, frame: :modal) %>
<%= render DS::Link.new(text: t("imports.pdf_import.back_to_imports"), href: imports_path, variant: "secondary", full_width: true) %>
<%= render DS::Button.new(
text: t("imports.pdf_import.delete_import"),
href: import_path(import),
method: :delete,
variant: :secondary,
full_width: true
) %>
</div>
<% else %>
<div class="text-center space-y-2">
<h1 class="font-medium text-primary text-center text-3xl"><%= t("imports.pdf_import.unknown_state_title") %></h1>
<p class="text-sm text-secondary"><%= t("imports.pdf_import.unknown_state_description") %></p>
</div>
<div class="space-y-2 flex flex-col">
<%= render DS::Link.new(text: t("imports.pdf_import.back_to_imports"), href: imports_path, variant: "primary", full_width: true) %>
</div>
<% end %>
</div>
</div>