feat(transactions): move an unbooked transaction to another cash account (#1570)
A bank transaction that ingested under the wrong cash account (or with no
account at all: legacy connections, own-account transfers the backfills
deliberately skipped) surfaces under the primary account's reconciliation
and can never be matched on the account it belongs to, because
cross-account matching is deliberately blocked. There was no first-party
way to fix the binding.
New PATCH /api/transactions/[id]/cash-account moves a movable staging row
(not booked, not invoice/supplier-invoice matched, not anchored via
transaction_voucher_links) to another of the company's cash accounts,
addressed by its BAS 19xx ledger account. Cross-currency moves are
hard-rejected (the row would vanish from every report's currency scope),
and the movable gate is re-asserted atomically in the UPDATE filter
against a concurrent book/auto-match, mirroring the title route. The tvl
check runs as a pre-check query since PostgREST cannot express NOT EXISTS
in an update filter; a tvl row appearing concurrently implies the booking
flow, which sets its own transaction state.
UI: 'Flytta till annat konto' in the transaction inbox row menu (opens a
radio-list dialog of the enabled cash accounts, current one preselected
and disabled) and direct 'Flytta till {name}' items in the bank
reconciliation unmatched-row menu that PATCH and refetch the view.
New structured error codes: TRANSACTION_MOVE_BOOKED,
TRANSACTION_MOVE_UNKNOWN_ACCOUNT, TRANSACTION_MOVE_CURRENCY_MISMATCH.
Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Jakob Wennberg
Claude Fable 5
parent
c420fd2aa1
commit
1eebb75269
@@ -392,6 +392,25 @@ const TRANSACTIONS: Record<string, StructuredErrorEntry> = {
|
||||
message_en:
|
||||
'Cannot edit the title of a booked or matched transaction. Posted vouchers are corrected with storno.',
|
||||
},
|
||||
TRANSACTION_MOVE_BOOKED: {
|
||||
httpStatus: 409,
|
||||
message_sv:
|
||||
'Transaktionen är bokförd eller kopplad till en verifikation och kan inte flyttas till ett annat konto. Koppla bort den under Rapporter → Bankavstämning, eller storna verifikationen först.',
|
||||
message_en:
|
||||
'The transaction is booked or linked to a voucher and cannot be moved to another account. Unlink it under Reports → Bank reconciliation, or reverse (storno) the voucher first.',
|
||||
},
|
||||
TRANSACTION_MOVE_UNKNOWN_ACCOUNT: {
|
||||
httpStatus: 404,
|
||||
message_sv: 'Kontot finns inte bland företagets registrerade bankkonton.',
|
||||
message_en: "The account is not one of the company's registered cash accounts.",
|
||||
},
|
||||
TRANSACTION_MOVE_CURRENCY_MISMATCH: {
|
||||
httpStatus: 400,
|
||||
message_sv:
|
||||
'Transaktionens valuta stämmer inte med kontots valuta. En transaktion kan bara flyttas till ett konto i samma valuta.',
|
||||
message_en:
|
||||
'The transaction currency does not match the target account currency. A transaction can only be moved to an account in the same currency.',
|
||||
},
|
||||
TX_CATEGORIZE_INVALID_ACCOUNT: {
|
||||
httpStatus: 400,
|
||||
message_sv: 'Det valda kontot finns inte i kontoplanen.',
|
||||
|
||||
Reference in New Issue
Block a user