98e1a48c2b
* feat(bokslut): Arsbokslut hub as Stegen with de-boxed linear steps (trio 1/3) Scene 34: the six-step wizard gets the house horizontal stepper (done checks behind the current step, click-back navigation, forward stays with each step's continue action), the period select moves into the header as the context control, and the progress-bar and picker cards die. Preflight, Preview, Execute and Result are de-boxed: sans eyebrow sections with hairlines, quiet action links, attn lines instead of boxed alerts, muted text for normal states. Step content is centered at reading width. Accruals/Dispositions keep their internals for now (interactive panels; follow-up pass). All wizard logic untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(bokslut): INK2 and NE-bilaga views in the flat house language (trio 2/3) Scene 36 direction: the declaration views lose every card. Statutory sections (Tillgangar, Eget kapital och skulder, Resultatrakning, INK2S, Intakter, Kostnader) become sans eyebrow sections with hairlines, the header card becomes a flat block with the SRU download beside it, the filing instructions lose their info box, warnings render as attn lines, and the NE R11 result becomes the emphasized document-foot row. All ruta tables, SRU downloads and warnings logic untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(bokslut): Arsredovisning page, studio and digital filing in the flat house language (trio 3/3) De-boxes the whole scene-35 surface: the page shell (period picker, K3 note, narrativ, flerarsoversikt, underskrifter, PDF section), the AnnualReportStudio (workflow strip, scope form, completeness checks, versions) and DigitalInlamning (iXBRL review, submission form, status history) all move from Card shells to sans-eyebrow sections with hairlines. Inner info boxes flatten to bordered text blocks; the digital-checks warning becomes an attn line. The iframe border and the Kommer snart overlay sign stay: one frames an external document, the other floats above blurred content. Statutory Swedish-only surface: no new i18n keys. * polish(bokslut): align trio controls with the house language Founder feedback: buttons and selects still read old-style next to the bookkeeping page. Sweeps all trio surfaces: - Drop every min-h-11 override on Buttons and Inputs (44px chunky controls) so the compact house pill and h-10 input apply. - Replace all native <select> elements (BooleanQuestion, currency, group size, signing method, signer role, versions, AGM outcome, roll) with the shadcn Select primitive used system-wide. - Step navigation matches the merged Moms Stegen: white outline size-sm pills labelled 'Nästa: <steg> →' and '← Tillbaka'. Booking commits (Verkställ, Bokför valda dispositioner) stay primary. - Year-end period picker becomes the ContextPicker chip (the house context-picker idiom), and the stepper row widens to max-w-4xl so step 6 'Klart' no longer clips. - font-sans on two uppercase h3 eyebrows that rendered serif via the global h1-h3 display rule. * fix(vat): one toolbar row and the FyPicker chip on every fiscal-year surface The prod momsdeklaration (helårsmoms) broke into two sparse rows: Exportera alone, then a labelled 280px FiscalYearSelector below it, plus a serif uppercase worklist heading and internal check codes in the UI. - The VAT toolbar is one flat row: periodicity picker, fiscal-year chip, black Exportera, all h-9 aligned. - FyPicker (the rounded ContextPicker chip from UI-migration PR 3) replaces FiscalYearSelector on every page-level surface it had left: the VAT toolbar, FocusedReport's header (all report detail pages) and Kassaflödesanalys. Dialog/settings forms keep the labelled select, which is a form field, not a context picker. - 'Verifikationer som saknar basbelopp' becomes a sans eyebrow with hairline; internal codes (RC_BASIS_MISSING et al) no longer render in check rows, the Swedish message already cites the SKV felkod. - font-sans on the SkatteverketPanel validation eyebrow. * polish(vat): periodicity, year and quarter/month pickers as ContextPicker chips Founder feedback: the Arsvis dropdown should also be the rounded style. The cadence choice now lives behind a settings-style 'Period' chip (Manadsvis/Kvartalsvis/Arsvis with a check on the active one), and the year and quarter/month selects become chips too, so the whole momsdeklaration toolbar is chip-shaped: Period, 2026, Kvartal 3 (jul-sep) or Rakenskapsar 2026, then the black Exportera pill. The concrete period chip already implies the cadence, so the Period chip can stay label-only. --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
281 lines
11 KiB
TypeScript
281 lines
11 KiB
TypeScript
'use client'
|
|
|
|
import { useMemo, useState } from 'react'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import { Checkbox } from '@/components/ui/checkbox'
|
|
import {
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableHead,
|
|
TableHeader,
|
|
TableRow,
|
|
} from '@/components/ui/table'
|
|
import { CheckCircle2, AlertTriangle } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import type { YearEndResult, ContinuityDiscrepancy } from '@/types'
|
|
import { formatCurrency } from '@/lib/utils'
|
|
import { formatVoucher } from '@/lib/bookkeeping/voucher-series-resolver'
|
|
|
|
interface ResultStepProps {
|
|
result: YearEndResult
|
|
}
|
|
|
|
const ORE_TOLERANCE = 0.005
|
|
|
|
export function ResultStep({ result }: ResultStepProps) {
|
|
const [acknowledged, setAcknowledged] = useState(false)
|
|
|
|
const continuity = result.continuity
|
|
const discrepancies = continuity?.discrepancies ?? []
|
|
|
|
// If the wizard reached ResultStep, executeYearEndClosing already enforced
|
|
// that no per-account diff exceeded ORE_TOLERANCE: but surface a panel
|
|
// grouped by BAS class so the user can confirm visually before leaving.
|
|
return (
|
|
<div className="space-y-6">
|
|
<div className="space-y-4 py-6 text-center">
|
|
<div className="mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-success/10">
|
|
<CheckCircle2 className="h-7 w-7 text-success" />
|
|
</div>
|
|
<h2 className="font-display text-2xl">Bokslutet är klart</h2>
|
|
<p className="text-muted-foreground">
|
|
Perioden är stängd och en ny räkenskapsperiod har skapats.
|
|
</p>
|
|
</div>
|
|
|
|
<section>
|
|
<div className="mb-1 flex items-center gap-2 px-1">
|
|
<h3 className="font-sans text-xs font-medium uppercase tracking-wider text-muted-foreground">Resultat</h3>
|
|
<div className="h-px flex-1 bg-border/60" />
|
|
</div>
|
|
<div className="space-y-3 px-1 pt-2 text-sm">
|
|
<ResultRow
|
|
label="Bokslutsverifikation"
|
|
value={formatVoucher(result.closingEntry)}
|
|
href={`/bookkeeping/${result.closingEntry.id}`}
|
|
/>
|
|
{result.revaluationEntry && (
|
|
<ResultRow
|
|
label="Kursrevaluering"
|
|
value={formatVoucher(result.revaluationEntry)}
|
|
href={`/bookkeeping/${result.revaluationEntry.id}`}
|
|
/>
|
|
)}
|
|
<ResultRow
|
|
label="Ingående balanser i ny period"
|
|
value={formatVoucher(result.openingBalanceEntry)}
|
|
href={`/bookkeeping/${result.openingBalanceEntry.id}`}
|
|
/>
|
|
{result.resultAppropriationEntry && (
|
|
<ResultRow
|
|
label="Omföring av föregående års resultat (2099 → 2098)"
|
|
value={formatVoucher(result.resultAppropriationEntry)}
|
|
href={`/bookkeeping/${result.resultAppropriationEntry.id}`}
|
|
/>
|
|
)}
|
|
<ResultRow label="Ny räkenskapsperiod" value={result.nextPeriod.name} />
|
|
</div>
|
|
</section>
|
|
|
|
{result.resultAppropriationFailed && (
|
|
<div className="flex items-start gap-3 px-1 py-2 text-destructive">
|
|
<AlertTriangle className="h-4 w-4 mt-0.5 text-destructive shrink-0" />
|
|
<p className="text-sm">
|
|
<span className="font-medium">
|
|
Omföringen av föregående års resultat (2099 → 2098) kunde inte bokföras.
|
|
</span>{' '}
|
|
Bokslutet och de ingående balanserna är klara, men konto 2099 “Årets
|
|
resultat” bär fortfarande föregående års resultat in i den nya perioden.
|
|
Det måste flyttas till 2098 innan balansräkningen stämmer. Kör om bokslutet
|
|
eller kontakta support: felet är loggat.
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
{continuity && (
|
|
<ContinuityPanel
|
|
discrepancies={discrepancies}
|
|
checkedAccounts={continuity.checked_accounts}
|
|
/>
|
|
)}
|
|
|
|
<section className="space-y-4 px-1">
|
|
<label className="flex items-start gap-3 cursor-pointer">
|
|
<Checkbox
|
|
checked={acknowledged}
|
|
onCheckedChange={(v) => setAcknowledged(v === true)}
|
|
className="mt-0.5"
|
|
aria-label="Bekräfta bokslut"
|
|
/>
|
|
<span className="text-sm leading-relaxed">
|
|
Jag har granskat bokslutet och IB/UB-kontinuiteten ovan, och
|
|
bekräftar att alla balanskonton stämmer mot föregående periods
|
|
utgående balans.
|
|
</span>
|
|
</label>
|
|
|
|
<div className="flex flex-col sm:flex-row gap-3 sm:justify-end">
|
|
<Button variant="outline" asChild disabled={!acknowledged}>
|
|
<Link
|
|
href="/bookkeeping"
|
|
aria-disabled={!acknowledged}
|
|
tabIndex={acknowledged ? undefined : -1}
|
|
className={!acknowledged ? 'pointer-events-none opacity-50' : ''}
|
|
>
|
|
Till bokföringen
|
|
</Link>
|
|
</Button>
|
|
<Button variant="outline" asChild disabled={!acknowledged}>
|
|
<Link
|
|
href="/reports"
|
|
aria-disabled={!acknowledged}
|
|
tabIndex={acknowledged ? undefined : -1}
|
|
className={!acknowledged ? 'pointer-events-none opacity-50' : ''}
|
|
>
|
|
Generera rapporter
|
|
</Link>
|
|
</Button>
|
|
<Button asChild disabled={!acknowledged}>
|
|
<Link
|
|
href={`/bookkeeping/year-end/arsredovisning?period=${result.closingEntry.fiscal_period_id}`}
|
|
aria-disabled={!acknowledged}
|
|
tabIndex={acknowledged ? undefined : -1}
|
|
className={!acknowledged ? 'pointer-events-none opacity-50' : ''}
|
|
>
|
|
Skapa årsredovisning
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function ResultRow({ label, value, href }: { label: string; value: string; href?: string }) {
|
|
return (
|
|
<div className="flex items-center justify-between border-b border-border last:border-b-0 pb-3 last:pb-0">
|
|
<span className="text-muted-foreground">{label}</span>
|
|
{href ? (
|
|
<Link href={href} className="font-medium tabular-nums text-primary hover:underline">
|
|
{value}
|
|
</Link>
|
|
) : (
|
|
<span className="font-medium tabular-nums">{value}</span>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
interface ContinuityPanelProps {
|
|
discrepancies: ContinuityDiscrepancy[]
|
|
checkedAccounts: number
|
|
}
|
|
|
|
function ContinuityPanel({ discrepancies, checkedAccounts }: ContinuityPanelProps) {
|
|
const grouped = useMemo(() => {
|
|
const byClass = new Map<number, ContinuityDiscrepancy[]>()
|
|
for (const d of discrepancies) {
|
|
const klass = parseInt(d.account_number[0]) || 0
|
|
if (klass !== 1 && klass !== 2) continue
|
|
const list = byClass.get(klass) ?? []
|
|
list.push(d)
|
|
byClass.set(klass, list)
|
|
}
|
|
return byClass
|
|
}, [discrepancies])
|
|
|
|
const hasIssues = discrepancies.some(
|
|
(d) => Math.abs(d.difference) > ORE_TOLERANCE
|
|
)
|
|
|
|
return (
|
|
<section>
|
|
<div className="mb-3 flex items-center justify-between gap-2 px-1">
|
|
<h3 className="font-sans text-xs font-medium uppercase tracking-wider text-muted-foreground">IB/UB-avstämning</h3>
|
|
{hasIssues ? (
|
|
<Badge variant="destructive" className="gap-1">
|
|
<AlertTriangle className="h-3 w-3" />
|
|
Avvikelser
|
|
</Badge>
|
|
) : (
|
|
<Badge variant="success" className="gap-1">
|
|
<CheckCircle2 className="h-3 w-3" />
|
|
Stämmer
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
<div className="space-y-4 px-1">
|
|
<p className="text-sm text-muted-foreground">
|
|
{checkedAccounts} balanskonto(n) jämförda mellan utgående balans i
|
|
stängd period och ingående balans i ny period.
|
|
</p>
|
|
|
|
{discrepancies.length === 0 ? (
|
|
<p className="text-sm">
|
|
Inga avvikelser. Alla balanskonton i klass 1 och 2 matchar inom
|
|
tolerans (±0,005 SEK).
|
|
</p>
|
|
) : (
|
|
<div className="space-y-6">
|
|
{[1, 2].map((klass) => {
|
|
const rows = grouped.get(klass) ?? []
|
|
if (rows.length === 0) return null
|
|
return (
|
|
<div key={klass}>
|
|
<h3 className="font-sans text-xs font-medium uppercase tracking-wider text-muted-foreground mb-2">
|
|
Klass {klass}: {klass === 1 ? 'Tillgångar' : 'Skulder & eget kapital'}
|
|
</h3>
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>Konto</TableHead>
|
|
<TableHead className="text-right">UB (föregående)</TableHead>
|
|
<TableHead className="text-right">IB (ny period)</TableHead>
|
|
<TableHead className="text-right">Diff</TableHead>
|
|
<TableHead className="text-right">Status</TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{rows.map((d) => {
|
|
const overTol = Math.abs(d.difference) > ORE_TOLERANCE
|
|
return (
|
|
<TableRow key={d.account_number}>
|
|
<TableCell className="font-medium tabular-nums">
|
|
{d.account_number}
|
|
<span className="ml-2 font-normal text-muted-foreground">
|
|
{d.account_name}
|
|
</span>
|
|
</TableCell>
|
|
<TableCell className="text-right tabular-nums">
|
|
{formatCurrency(d.previous_ub_net)}
|
|
</TableCell>
|
|
<TableCell className="text-right tabular-nums">
|
|
{formatCurrency(d.current_ib_net)}
|
|
</TableCell>
|
|
<TableCell className="text-right tabular-nums">
|
|
{formatCurrency(d.difference)}
|
|
</TableCell>
|
|
<TableCell className="text-right">
|
|
{overTol ? (
|
|
<Badge variant="destructive">Avviker</Badge>
|
|
) : (
|
|
<Badge variant="success">OK</Badge>
|
|
)}
|
|
</TableCell>
|
|
</TableRow>
|
|
)
|
|
})}
|
|
</TableBody>
|
|
</Table>
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</section>
|
|
)
|
|
}
|