fix(inbox): carry the matched transaction amount into manual booking (#1546)
PR #1524 swapped the matched-state "Bokfor manuellt" path from BookDirectlyDialog to EditKonteringDialog, which is seeded only from the booking proposal. An unknown supplier has no proposal, so the dialog opened with two blank rows and no amount at all: on a foreign-currency invoice the SEK figure then existed nowhere on screen (user-reported regression, 2026-08-12). suggest-booking now returns, on every empty-proposal branch (no_mapping, currency_unsupported, engine failure), the matched bank row's SEK amount and date plus a balanced two-row skeleton: the settlement account on one side, a blank cost row on the other, mirroring what buildPrefillLines seeded before the swap. The SEK amount goes through resolveSekAmountOrNull, so a foreign row with no honest kronor figure still opens blank rather than relabeling EUR as SEK. The dialog also shows the matched transaction's amount and date beside the title, and empty proposals now carry the bank date so the entry no longer falls back to the document date. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
a97b0023d4
commit
402bf02b1b
@@ -23,6 +23,7 @@
|
||||
* room for line text, dimensions or tax codes.
|
||||
*/
|
||||
import { useTranslations } from 'next-intl'
|
||||
import { formatCurrency, formatDate } from '@/lib/utils'
|
||||
import JournalEntryForm from '@/components/bookkeeping/JournalEntryForm'
|
||||
import DocumentViewerPane from '@/components/bookkeeping/DocumentViewerPane'
|
||||
import {
|
||||
@@ -51,6 +52,7 @@ export default function EditKonteringDialog({
|
||||
entryDate,
|
||||
description,
|
||||
lines,
|
||||
matchedTransaction = null,
|
||||
onBooked,
|
||||
}: {
|
||||
open: boolean
|
||||
@@ -64,6 +66,11 @@ export default function EditKonteringDialog({
|
||||
entryDate: string
|
||||
description: string
|
||||
lines: ProposedLine[]
|
||||
/** SEK amount and date of the matched bank row, when there is one. Shown
|
||||
beside the title so the kronor figure stays visible even if the user
|
||||
clears the rows: on a foreign-currency invoice this is the only place
|
||||
the SEK amount exists at all. */
|
||||
matchedTransaction?: { amount_sek: number; date: string } | null
|
||||
onBooked: (entryId: string) => void
|
||||
}) {
|
||||
const t = useTranslations('inbox_workspace')
|
||||
@@ -73,6 +80,12 @@ export default function EditKonteringDialog({
|
||||
<DialogContent className="max-w-6xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Ändra kontering</DialogTitle>
|
||||
{matchedTransaction && (
|
||||
<p className="text-xs text-muted-foreground tabular-nums">
|
||||
{t('dialog_matched_transaction')}: {formatCurrency(matchedTransaction.amount_sek)} ·{' '}
|
||||
{formatDate(matchedTransaction.date)}
|
||||
</p>
|
||||
)}
|
||||
</DialogHeader>
|
||||
|
||||
<div className="grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,480px)]">
|
||||
|
||||
@@ -2523,6 +2523,13 @@ type SuggestedBooking = {
|
||||
description?: string
|
||||
rule_name?: string | null
|
||||
entry_date?: string
|
||||
/** Skeleton rows seeded from the matched bank transaction when `lines` is
|
||||
empty: the amount in SEK against the settlement account, cost side left
|
||||
blank. Editor prefill only; never rendered as a proposal. */
|
||||
fallback_lines?: { account_number: string; debit_amount: number; credit_amount: number; description: string }[]
|
||||
/** The matched bank row's SEK amount and date, present on empty proposals
|
||||
so the dialog can still show the kronor figure. */
|
||||
transaction?: { amount_sek: number; date: string } | null
|
||||
}
|
||||
|
||||
const SUGGESTION_SOURCE_LABEL: Record<string, string> = {
|
||||
@@ -3231,7 +3238,12 @@ function FieldsRail({
|
||||
new Date().toISOString().slice(0, 10)
|
||||
}
|
||||
description={data?.supplier?.name ?? item.email_subject ?? 'Underlag'}
|
||||
lines={proposal?.lines ?? []}
|
||||
// No proposal is not the same as no amount: the matched bank row still
|
||||
// knows what left the account and where. The fallback skeleton keeps
|
||||
// the kronor figure in the form (regression report 2026-08-12: match,
|
||||
// "Bokför manuellt", and the amount no longer followed along).
|
||||
lines={proposal?.lines.length ? proposal.lines : (proposal?.fallback_lines ?? [])}
|
||||
matchedTransaction={proposal?.transaction ?? null}
|
||||
onBooked={() => {
|
||||
setEditOpen(false)
|
||||
// Realtime refreshes the list, but this rail renders from the
|
||||
|
||||
Reference in New Issue
Block a user