* feat(api): implement commit functionality for journal entries * fix(extensions): make ExtensionSettings.clear() a real delete so disconnect flows work The 2026-03-30 multi-tenant refactor dropped all RLS policies on extension_data and recreated only SELECT/INSERT/UPDATE. Combined with `value jsonb NOT NULL`, every extension that called `settings.set(key, null)` to clear stored state (cloud-backup disconnect, skatteverket OAuth/AGI cleanup, arcim-migration consent reset) silently failed — the upsert hit the NOT NULL constraint and the error was swallowed, leaving users stuck with stale connection rows. Adds an `extension_data_delete` RLS policy, a `clear(key)` method backed by a real DELETE, switches the four affected handlers, and makes `set()` throw on Supabase error so this class of silent failure can't recur. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(journal-entries): add draft saving functionality to journal entry form * feat: add periodisk sammanställning report generation and CSV export - Implemented period date helpers in `period-dates.ts` for calculating start and end dates based on period type (monthly, quarterly, yearly). - Created `periodisk-sammanstallning.ts` to generate the periodisk sammanställning report, including data fetching, validation, and warning handling. - Developed CSV serializer in `periodisk-sammanstallning-csv.ts` for exporting the report in SKV574008 format. - Added new columns to `company_settings` for storing periodisk sammanställning settings and tax contact information via migration. - Introduced a new migration to add a `paid_with_private_funds` flag to `supplier_invoices` for tracking out-of-pocket expenses. - Updated journal entries to include the new source type for privately paid supplier invoices. * feat(migrations): add paid_with_private_funds flag to supplier_invoices and expand journal_entries.source_type CHECK * fix(ai_requests): drop existing policies and trigger before creating new ones * fix(migrations): ensure extension_data has a proper DELETE policy for ExtensionSettings.clear() * fix(supplier-invoices): update error handling for invalid input in POST request * fix: correct capitalization in project title * fix(migrations): resolve duplicate version 20260513120000 Two migrations shared the same timestamp prefix, causing schema_migrations_pkey collision on Supabase preview branches. Bump extension_data_delete_policy to 20260513120001. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
145 lines
4.0 KiB
TypeScript
145 lines
4.0 KiB
TypeScript
'use client'
|
|
|
|
import { cn } from '@/lib/utils'
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectGroup,
|
|
SelectItem,
|
|
SelectLabel,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from '@/components/ui/select'
|
|
import type { EntityType } from '@/types'
|
|
|
|
interface ReportItem {
|
|
value: string
|
|
label: string
|
|
entityType?: EntityType
|
|
}
|
|
|
|
interface ReportCategory {
|
|
label: string
|
|
items: ReportItem[]
|
|
}
|
|
|
|
const CATEGORIES: ReportCategory[] = [
|
|
{
|
|
label: 'Löpande',
|
|
items: [
|
|
{ value: 'resultatrapport', label: 'Resultatrapport' },
|
|
{ value: 'balansrapport', label: 'Balansrapport' },
|
|
{ value: 'trial-balance', label: 'Saldobalans' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Bokslut',
|
|
items: [
|
|
{ value: 'income-statement', label: 'Resultaträkning' },
|
|
{ value: 'balance-sheet', label: 'Balansräkning' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Skatt & moms',
|
|
items: [
|
|
{ value: 'vat-declaration', label: 'Momsdeklaration' },
|
|
{ value: 'periodisk-sammanstallning', label: 'Periodisk sammanställning' },
|
|
{ value: 'ne-declaration', label: 'NE-bilaga', entityType: 'enskild_firma' },
|
|
{ value: 'ink2-declaration', label: 'INK2', entityType: 'aktiebolag' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Huvudböcker',
|
|
items: [
|
|
{ value: 'huvudbok', label: 'Huvudbok' },
|
|
{ value: 'grundbok', label: 'Grundbok' },
|
|
{ value: 'kundreskontra', label: 'Kundreskontra' },
|
|
{ value: 'supplier-ledger', label: 'Leverantörsreskontra' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Avstämning',
|
|
items: [
|
|
{ value: 'bank-reconciliation', label: 'Bankavstämning' },
|
|
],
|
|
},
|
|
]
|
|
|
|
interface ReportsNavProps {
|
|
active: string
|
|
onChange: (value: string) => void
|
|
entityType?: EntityType
|
|
}
|
|
|
|
export function ReportsNav({ active, onChange, entityType }: ReportsNavProps) {
|
|
const filtered = CATEGORIES
|
|
.map(cat => ({
|
|
...cat,
|
|
items: cat.items.filter(item => !item.entityType || item.entityType === entityType),
|
|
}))
|
|
.filter(cat => cat.items.length > 0)
|
|
|
|
return (
|
|
<>
|
|
{/* Mobile: grouped select */}
|
|
<div className="sm:hidden">
|
|
<Select value={active} onValueChange={onChange}>
|
|
<SelectTrigger>
|
|
<SelectValue />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{filtered.map(cat => (
|
|
<SelectGroup key={cat.label}>
|
|
<SelectLabel>{cat.label}</SelectLabel>
|
|
{cat.items.map(item => (
|
|
<SelectItem key={item.value} value={item.value}>
|
|
{item.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectGroup>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
|
|
{/* Desktop: vertical left rail */}
|
|
<nav
|
|
className="hidden sm:block w-56 flex-shrink-0 sticky top-8 self-start"
|
|
aria-label="Rapportkategorier"
|
|
>
|
|
<ul className="space-y-6">
|
|
{filtered.map(cat => (
|
|
<li key={cat.label}>
|
|
<p className="text-[11px] font-semibold text-muted-foreground/80 uppercase tracking-[0.08em] mb-2 px-3">
|
|
{cat.label}
|
|
</p>
|
|
<ul className="space-y-px">
|
|
{cat.items.map(item => {
|
|
const isActive = active === item.value
|
|
return (
|
|
<li key={item.value}>
|
|
<button
|
|
type="button"
|
|
onClick={() => onChange(item.value)}
|
|
aria-current={isActive ? 'page' : undefined}
|
|
className={cn(
|
|
'w-full text-left px-3 py-1.5 rounded-md text-[13px] transition-colors',
|
|
isActive
|
|
? 'bg-primary/10 text-foreground font-medium'
|
|
: 'text-muted-foreground hover:text-foreground hover:bg-muted/40'
|
|
)}
|
|
>
|
|
{item.label}
|
|
</button>
|
|
</li>
|
|
)
|
|
})}
|
|
</ul>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</nav>
|
|
</>
|
|
)
|
|
}
|