Add/stripe connect transactions (#1139)

* fix(mcp-oauth): allow ChatGPT connector callbacks and resume OAuth after login

Add chatgpt.com/connector/oauth/* (per-instance) and the legacy
chatgpt.com/connector_platform_oauth_redirect to the built-in OAuth
redirect allowlist so ChatGPT MCP connectors can register and authorize.

Fix the login page dropping the ?next= destination: an OAuth-initiated
visit that required login previously ended on the dashboard and the
connection flow silently died. Login now resumes to the sanitized next
path (hard navigation, since the consent page is route-handler HTML),
carries it through the MFA step-up as returnTo, and /mfa/verify
hard-navigates for /api/ destinations.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(transactions): dedup incoming feed rows against booked hand-entered twins

Users who bookkeep via MCP/chat first and connect their bank afterwards got
the same movement twice: the synced row's external_id lives in a different
namespace, the free-form manual title never text-bridges the bank's raw
string, and the cross-channel mirror deliberately excluded manual/mcp rows.

Extend the mirror with a booked-hand-entered track: an incoming feed row is
skipped when a BOOKED manual/mcp row shares its (date, ore) bucket count-
symmetrically. Gates beyond the feed-vs-feed mirror: stored row must be
booked (staged rows never consume an import), currencies must not contradict
(bucket key is date+ore only), the cash-account guard applies to the count
exactly as to consumption, and symmetry uses the Layer-1-unmatched incoming
count so an already-stored row cannot inflate it. Consumption stamps the
batch cash_account_id onto an account-unbound hand row, so one hand row can
never consume feed rows on other accounts in later syncs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(bookkeeping): inline verifikat rattelse (strike lines + text/date edit)

Second sanctioned correction track under BFL 5 kap 5/9 pp, Fortnox-style:
strike lines inside a posted verifikat with replacements in the same
voucher, and correct description/entry_date without an andringsverifikat.
Envelope: posted entries, open unlocked periods, company lock date,
same-period date moves, structural/FX/doc-linked lines excluded, and a
reconciliation guard preserving per-account net on bank/reskontra sides of
externally linked entries. Every rattelse writes an immutable who/when row
(journal_entry_rattelse_log, WORM, archived as rakenskapsinformation) and
struck originals render struck-through in the verifikat; list rows and the
detail header carry a Rattad marker. CLAUDE.md hard rule 1 and the
swedish-accounting-compliance skill are amended to state the two-track
rule. Staging carries the DDL; prod gets it on merge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat: live saldo in booking form, prior-year window comparison, hideable assistant FAB

- Manual journal entry: saldo column now shows before -> after computed
  from the typed debit/credit amounts (direction feedback while booking)
- Resultatrapport: a narrowed date range now compares against the same
  window shifted one year back (#862), merged across fiscal periods for
  brutet rakenskapsar; P&L rows report window activity instead of
  rolled-forward YTD closing
- Assistant FAB: per-user hide toggle (user_preferences.hide_assistant_fab,
  settings > assistant), sidebar entry unaffected; collapsed sessions keep
  their reopen handle

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(stripe): sync balance transactions as a bank feed on 1686

Import the connected Stripe balance into the transactions inbox, opt-in
per connection (transaction_sync_enabled on stripe_connections):

- Balance transactions map to feed rows with the two-row gross+fee split
  and frozen external_id formats (stripe_{acct}_{txn} / _fee), dated on
  created, bound to a provisioned "Stripe-saldo" cash account on 1686 so
  booking settles against the clearing account by construction.
- Double-booking protection: settled payment-link charges import
  pre-linked to their settlement entry; payout rows import pre-linked to
  the payout entry; processPayoutPaidEvent claims the payout's fee rows
  at booking time (linkPayoutFeedRows, idempotent from both directions).
- Cursor last_balance_txn_synced_at with 24h overlap; first run
  backfills 90 days floored at the day after the company lock date.
- Nightly cron /api/extensions/stripe/transactions/cron (03:30),
  transaction-sync toggle route, "Synka nu" covers both feeds, settings
  panel toggle with last-synced/backfill note, sv+en strings.
- Migration 20260723200000 (applied to staging).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(transactions): offer match-to-voucher on unbooked history rows

Unbooked transactions with is_business already set (e.g. left behind when
a voucher was removed without a full uncategorize) land in the history
list instead of the inbox, where the match-against-existing-voucher
action did not exist, leaving them with no path back to voucher
matching. Add the same menu item to the history list for unbooked rows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(transactions): enhance ownership checks and error handling in journal entry routes

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mattsson
2026-07-24 01:16:20 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent be9d630347
commit d840257c0c
55 changed files with 23207 additions and 125 deletions
+26 -4
View File
@@ -364,7 +364,16 @@
"reason_amount_mismatch": "The amount does not match the invoice remaining balance",
"reason_currency_mismatch": "The currency does not match the invoice",
"reason_non_sek_invoice": "Foreign-currency invoice (book manually)",
"reason_unknown": "Unknown reason"
"reason_unknown": "Unknown reason",
"transaction_sync_title": "Transactions from Stripe",
"transaction_sync_description": "Import all Stripe transactions (payments, fees, refunds and payouts) into the transactions inbox every night, like a bank feed for your Stripe balance. Already-booked payments are linked to their vouchers; you book the rest as usual.",
"transaction_sync_backfill_note": "The first sync fetches up to 90 days of history, but never before the bookkeeping lock date.",
"transaction_sync_last_synced": "Last synced {date}",
"transaction_sync_never_synced": "Not synced yet",
"transaction_sync_enabled_toast": "Transaction sync enabled. History is fetched on the next sync.",
"transaction_sync_disabled_toast": "Transaction sync disabled.",
"transaction_sync_toggle_failed": "Could not save the setting. Please try again.",
"sync_done_transactions": "{imported} transaction(s) imported, {linked} linked to vouchers."
},
"settings_modal": {
"title": "Settings",
@@ -1609,6 +1618,10 @@
"connected_description": "You can now file declarations and fetch the tax account balance.",
"connect_failed_title": "Connection failed"
},
"settings_assistant": {
"fab_title": "Floating assistant button",
"fab_description": "Show the assistant button in the bottom-right corner on every page. The assistant is always available in the sidebar."
},
"settings_account_danger": {
"heading": "Delete account",
"blockers_title": "Companies you own",
@@ -2674,6 +2687,7 @@
"create_correction": "Create correction entry",
"not_posted": "Not posted",
"possible_match_invoice": "Possible match: Invoice {number}",
"match_voucher": "Match to existing voucher",
"attach_document": "Match to document",
"book": "Post",
"delete": "Delete",
@@ -3774,6 +3788,8 @@
"scope_label": "Showing:",
"scope_all_years": "All fiscal years",
"out_of_period_label": "Subsequent",
"rattelse_badge": "Corrected",
"rattelse_badge_tooltip": "The voucher was corrected after posting: see the correction history on the voucher page",
"out_of_period_tooltip": "Posted in a later fiscal year, but relates to the selected year (e.g. payment of an invoice issued in the selected year).",
"out_of_period_tooltip_mobile": "Posted in a later fiscal year, but relates to the selected year.",
"attachment_count_tooltip": "{count} documents",
@@ -3965,8 +3981,14 @@
"copy_entry": "Copy journal entry",
"edit_entry": "Edit",
"correct_menu": "Correct",
"correct_lines": "Correct lines",
"correct_lines": "Correct lines (correction entry)",
"correct_date": "Correct date",
"strike_lines": "Strike lines in the voucher",
"correct_metadata": "Change text or date",
"struck_marker": "Struck {date}",
"rattelse_history_title": "Correction history",
"rattelse_kind_metadata": "Text/date corrected",
"rattelse_kind_lines": "Lines struck and replaced",
"correct_opening_balances": "Correct opening balances",
"reverse_action": "Reverse (storno)",
"reverse_confirm_title": "Reverse journal entry",
@@ -4053,8 +4075,8 @@
"col_description": "Description",
"col_debit": "Debit",
"col_credit": "Credit",
"col_saldo": "Balance (before)",
"saldo_label": "Balance (before)",
"col_saldo": "Balance",
"saldo_label": "Balance",
"line_description_placeholder": "Line text...",
"sum": "Total",
"sum_d": "D: {amount}",
+26 -4
View File
@@ -364,7 +364,16 @@
"reason_amount_mismatch": "Beloppet stämmer inte med fakturans restbelopp",
"reason_currency_mismatch": "Valutan stämmer inte med fakturan",
"reason_non_sek_invoice": "Faktura i utländsk valuta (bokförs manuellt)",
"reason_unknown": "Okänd orsak"
"reason_unknown": "Okänd orsak",
"transaction_sync_title": "Transaktioner från Stripe",
"transaction_sync_description": "Hämta alla Stripe-transaktioner (betalningar, avgifter, återbetalningar och utbetalningar) till transaktionsinkorgen varje natt, som ett bankflöde för ditt Stripe-saldo. Redan bokförda betalningar länkas till sina verifikat; övriga bokför du som vanligt.",
"transaction_sync_backfill_note": "Vid första synkningen hämtas upp till 90 dagars historik, dock inte före bokföringslåset.",
"transaction_sync_last_synced": "Senast synkad {date}",
"transaction_sync_never_synced": "Inte synkad ännu",
"transaction_sync_enabled_toast": "Transaktionssynk aktiverad. Historiken hämtas vid nästa synkning.",
"transaction_sync_disabled_toast": "Transaktionssynk avaktiverad.",
"transaction_sync_toggle_failed": "Kunde inte spara inställningen. Försök igen.",
"sync_done_transactions": "{imported} transaktion(er) importerade, {linked} länkade till verifikat."
},
"settings_modal": {
"title": "Inställningar",
@@ -1609,6 +1618,10 @@
"connected_description": "Du kan nu skicka deklarationer och hämta skattekonto-saldot.",
"connect_failed_title": "Anslutning misslyckades"
},
"settings_assistant": {
"fab_title": "Flytande assistentknapp",
"fab_description": "Visa assistentknappen nere till höger på alla sidor. Assistenten finns alltid kvar i sidomenyn."
},
"settings_account_danger": {
"heading": "Radera konto",
"blockers_title": "Företag du äger",
@@ -2674,6 +2687,7 @@
"create_correction": "Skapa ändringsverifikation",
"not_posted": "Ej bokförd",
"possible_match_invoice": "Möjlig match: Faktura {number}",
"match_voucher": "Matcha mot befintlig verifikation",
"attach_document": "Matcha mot underlag",
"book": "Bokför",
"delete": "Ta bort",
@@ -3774,6 +3788,8 @@
"scope_label": "Visar:",
"scope_all_years": "Alla räkenskapsår",
"out_of_period_label": "Efterföljande",
"rattelse_badge": "Rättad",
"rattelse_badge_tooltip": "Verifikatet har rättats i efterhand: se rättelsehistoriken på verifikatsidan",
"out_of_period_tooltip": "Bokförd i ett senare räkenskapsår, men avser det valda året (t.ex. betalning av en faktura utställd i det valda året).",
"out_of_period_tooltip_mobile": "Bokförd i ett senare räkenskapsår, men avser det valda året.",
"attachment_count_tooltip": "{count} underlag",
@@ -3965,8 +3981,14 @@
"copy_entry": "Kopiera verifikat",
"edit_entry": "Redigera",
"correct_menu": "Rätta",
"correct_lines": "Rätta rader",
"correct_lines": "Rätta rader (ändringsverifikat)",
"correct_date": "Rätta datum",
"strike_lines": "Stryk rader i verifikatet",
"correct_metadata": "Ändra text eller datum",
"struck_marker": "Struken {date}",
"rattelse_history_title": "Rättelsehistorik",
"rattelse_kind_metadata": "Text/datum rättat",
"rattelse_kind_lines": "Rader strukna och ersatta",
"correct_opening_balances": "Korrigera ingående balanser",
"reverse_action": "Återför (storno)",
"reverse_confirm_title": "Återför verifikat",
@@ -4053,8 +4075,8 @@
"col_description": "Beskrivning",
"col_debit": "Debet",
"col_credit": "Kredit",
"col_saldo": "Saldo (före)",
"saldo_label": "Saldo (före)",
"col_saldo": "Saldo",
"saldo_label": "Saldo",
"line_description_placeholder": "Radtext...",
"sum": "Summa",
"sum_d": "D: {amount}",