Per-line VAT rates: - Add generatePerRateLines() to group invoice items by vat_rate with separate revenue + VAT lines per rate group (invoice-entries.ts) - Add getAvailableVatRates() and getVatTreatmentForRate() (vat-rules.ts) - PDF template shows per-line VAT column and per-rate totals for mixed-rate invoices - Invoice create/review UI supports per-line rate selection - Types: add vat_rate/vat_amount to InvoiceItem, vat_rate to CreateInvoiceItemInput Invoice document types (proforma, delivery note): - Add InvoiceDocumentType, document_type and converted_from_id to Invoice type - PDF hides prices for delivery notes, adds proforma notice - Email templates support all document types - mark-paid skips journal entries for non-invoice document types - Migration 031: invoice_document_type Accounting method support: - Add AccountingMethod type (accrual/cash) - Migration 032: add_accounting_method column to company_settings VAT declaration rewrite: - Rewrite to read directly from general ledger (26xx/3xxx account lines) instead of aggregating invoices/transactions/receipts - ACCOUNT_RUTA mapping drives momsdeklaration boxes from GL balances Bank reconciliation: - Transaction ingest now pre-fetches unlinked GL lines and attempts auto-reconciliation during import - Add transaction.reconciled event type - Add ReconciliationMethod type and reconciliation_method on Transaction - Migration 030: bank_reconciliation - New reconciliation engine, API routes, and BankReconciliationView component Pagination (fetchAllRows): - New lib/supabase/fetch-all.ts overcomes PostgREST 1000-row limit - Adopted in all report generators, SIE/SRU export, account list APIs Fiscal period validation: - New validate-period-duration.ts enforces max 18 months per BFL 3 kap. - Applied in period-service.ts and fiscal-periods API Account mapper simplification: - Remove Levenshtein/fuzzy matching, use exact account number match only Swedbank parser improvements: - Support abbreviated headers (Clnr, Bokfdag, Radnr) - Use Referens column as counterparty Chart of accounts management: - Add DELETE endpoint with system account and usage protection - PUT uses partial updates - New AccountCombobox, AddAccountDialog, EditAccountDialog, ChartOfAccountsManager Tax deadline corrections: - Rewrite inkomstdeklaration_ab using Skatteverket lookup table - Rewrite arsredovisning deadline to 7 months after FY end per ÅRL 8:3 Onboarding first fiscal year: - Add first fiscal year toggle with date pickers and 18-month validation UI terminology: - Change "okategoriserad/kategorisera" to "obokförd/bokföra" throughout Report column fix: - Fix start_date/end_date to period_start/period_end in report queries Supplier invoice input: - CreateSupplierInvoiceItemInput uses amount field (legacy quantity/unit_price kept) Misc: - SIE import uses upsert for idempotent account creation - account-descriptions.ts falls back to BAS reference data - Add invoice_default_notes to CompanySettings - Update CLAUDE.md to reflect current project state Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
170 lines
6.1 KiB
TypeScript
170 lines
6.1 KiB
TypeScript
'use client'
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import { Flame, Receipt, CreditCard, Camera, ArrowRight } from 'lucide-react'
|
|
import type { ReceiptQueueSummary } from '@/types'
|
|
|
|
interface ReceiptDashboardProps {
|
|
summary: ReceiptQueueSummary
|
|
onScanReceipt: () => void
|
|
onViewReceiptQueue: () => void
|
|
onViewTransactionQueue: () => void
|
|
}
|
|
|
|
export default function ReceiptDashboard({
|
|
summary,
|
|
onScanReceipt,
|
|
onViewReceiptQueue,
|
|
onViewTransactionQueue,
|
|
}: ReceiptDashboardProps) {
|
|
const hasWork =
|
|
summary.unmatched_receipts_count > 0 ||
|
|
summary.unmatched_transactions_count > 0 ||
|
|
summary.pending_review_count > 0
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
{/* Quick actions */}
|
|
<div className="grid grid-cols-1 gap-3">
|
|
<Button
|
|
variant="default"
|
|
className="h-auto py-4 flex-col gap-2"
|
|
onClick={onScanReceipt}
|
|
>
|
|
<Camera className="h-6 w-6" />
|
|
<span>Skanna kvitto</span>
|
|
</Button>
|
|
</div>
|
|
|
|
{/* Streak counter */}
|
|
{summary.streak_count > 0 && (
|
|
<Card>
|
|
<CardContent className="pt-4">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-3">
|
|
<div className="h-12 w-12 rounded-full bg-muted flex items-center justify-center">
|
|
<Flame className="h-6 w-6 text-muted-foreground" />
|
|
</div>
|
|
<div>
|
|
<p className="text-2xl font-bold">{summary.streak_count}</p>
|
|
<p className="text-sm text-muted-foreground">dagars streak!</p>
|
|
</div>
|
|
</div>
|
|
<p className="text-xs text-muted-foreground max-w-24 text-right">
|
|
Fortsätt bokföra varje dag
|
|
</p>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
{/* Queue cards */}
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
|
{/* Pending review */}
|
|
{summary.pending_review_count > 0 && (
|
|
<Card
|
|
className="cursor-pointer hover:border-primary/50 transition-colors"
|
|
onClick={onViewReceiptQueue}
|
|
>
|
|
<CardContent className="pt-4">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-3">
|
|
<div className="h-10 w-10 rounded-full bg-muted flex items-center justify-center">
|
|
<Receipt className="h-5 w-5 text-muted-foreground" />
|
|
</div>
|
|
<div>
|
|
<p className="font-medium">Att granska</p>
|
|
<p className="text-sm text-muted-foreground">
|
|
{summary.pending_review_count} kvitton
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<Badge variant="secondary">{summary.pending_review_count}</Badge>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
{/* Unmatched receipts */}
|
|
{summary.unmatched_receipts_count > 0 && (
|
|
<Card
|
|
className="cursor-pointer hover:border-primary/50 transition-colors"
|
|
onClick={onViewReceiptQueue}
|
|
>
|
|
<CardContent className="pt-4">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-3">
|
|
<div className="h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center">
|
|
<Receipt className="h-5 w-5 text-primary" />
|
|
</div>
|
|
<div>
|
|
<p className="font-medium">Kvitton utan transaktion</p>
|
|
<p className="text-sm text-muted-foreground">
|
|
{summary.unmatched_receipts_count} st
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<ArrowRight className="h-5 w-5 text-muted-foreground" />
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
{/* Unmatched transactions */}
|
|
{summary.unmatched_transactions_count > 0 && (
|
|
<Card
|
|
className="cursor-pointer hover:border-primary/50 transition-colors"
|
|
onClick={onViewTransactionQueue}
|
|
>
|
|
<CardContent className="pt-4">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-3">
|
|
<div className="h-10 w-10 rounded-full bg-muted flex items-center justify-center">
|
|
<CreditCard className="h-5 w-5 text-muted-foreground" />
|
|
</div>
|
|
<div>
|
|
<p className="font-medium">Transaktioner utan kvitto</p>
|
|
<p className="text-sm text-muted-foreground">
|
|
{summary.unmatched_transactions_count} st
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<ArrowRight className="h-5 w-5 text-muted-foreground" />
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
</div>
|
|
|
|
{/* All done state */}
|
|
{!hasWork && (
|
|
<Card className="bg-success/5 border-success/20">
|
|
<CardContent className="pt-4 text-center py-8">
|
|
<div className="h-16 w-16 rounded-full bg-success/10 flex items-center justify-center mx-auto mb-4">
|
|
<svg
|
|
className="h-8 w-8 text-success"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
strokeWidth={2}
|
|
d="M5 13l4 4L19 7"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
<h3 className="font-semibold text-lg">Allt är uppdaterat!</h3>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
Inga kvitton eller transaktioner att granska
|
|
</p>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|