- Add 8 new Zod schemas (UpdateCustomer, UpdateSupplier, UpdateSupplierInvoice, UpdateAccount, BankUnlink, RunReconciliation, CorrectJournalEntry, EvaluateMappingRules) and wire validateBody() into 24 JSON-body API routes - Remove redundant manual validation checks replaced by Zod - Add comprehensive schema tests (222 tests) - Improve type definitions in types/index.ts with expanded interfaces - Refactor extension types (push-notifications, receipt-ocr) for cleaner imports - Update transaction components (BatchCategorySelector, SwipeCategorizationView, QuickReviewDialog, VatTreatmentSelect) and invoice inbox workspace - Add invoice-inbox utilities and type decoupling tests - Fix NE-bilaga, SRU export, and invoice PDF template type usage - Update CLAUDE.md with expanded architecture documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
import type { Transaction, TransactionCategory, Invoice, Customer, VatTreatment } from '@/types'
|
|
|
|
// Shared transaction type with potential invoice data
|
|
export interface TransactionWithInvoice extends Transaction {
|
|
potential_invoice?: Invoice & { customer?: Customer }
|
|
}
|
|
|
|
// Page view modes
|
|
export type ViewMode = 'inbox' | 'history'
|
|
export type HistoryFilter = 'all' | 'business' | 'private'
|
|
|
|
// Handler types
|
|
export type CategorizeHandler = (
|
|
id: string,
|
|
isBusiness: boolean,
|
|
category?: TransactionCategory,
|
|
vatTreatment?: VatTreatment,
|
|
accountOverride?: string
|
|
) => Promise<boolean>
|
|
|
|
export type MatchInvoiceHandler = (
|
|
transactionId: string,
|
|
invoiceId: string
|
|
) => Promise<boolean>
|
|
|
|
// Category option type
|
|
export interface CategoryOption {
|
|
value: TransactionCategory
|
|
label: string
|
|
}
|
|
|
|
// Shared category arrays
|
|
export const EXPENSE_CATEGORIES: CategoryOption[] = [
|
|
{ value: 'expense_equipment', label: 'Utrustning' },
|
|
{ value: 'expense_software', label: 'Programvara' },
|
|
{ value: 'expense_travel', label: 'Resor' },
|
|
{ value: 'expense_office', label: 'Kontor' },
|
|
{ value: 'expense_marketing', label: 'Marknadsföring' },
|
|
{ value: 'expense_professional_services', label: 'Konsulter' },
|
|
{ value: 'expense_education', label: 'Utbildning' },
|
|
{ value: 'expense_bank_fees', label: 'Bankavgift' },
|
|
{ value: 'expense_card_fees', label: 'Kortavgift' },
|
|
{ value: 'expense_currency_exchange', label: 'Valutaväxling' },
|
|
{ value: 'expense_other', label: 'Övrigt' },
|
|
]
|
|
|
|
export const INCOME_CATEGORIES: CategoryOption[] = [
|
|
{ value: 'income_services', label: 'Tjänster' },
|
|
{ value: 'income_products', label: 'Produkter' },
|
|
{ value: 'income_other', label: 'Övrigt' },
|
|
]
|
|
|
|
export interface VatTreatmentOption {
|
|
value: VatTreatment | 'none'
|
|
label: string
|
|
description?: string
|
|
}
|
|
|
|
export const VAT_TREATMENT_OPTIONS: VatTreatmentOption[] = [
|
|
{ value: 'standard_25', label: 'Moms 25%' },
|
|
{ value: 'reduced_12', label: 'Moms 12%', description: 'Livsmedel, hotell, camping' },
|
|
{ value: 'reduced_6', label: 'Moms 6%', description: 'Böcker, tidningar, kollektivtrafik' },
|
|
{ value: 'reverse_charge', label: 'Omvänd skattskyldighet', description: 'Köparen redovisar momsen (EU-tjänster m.m.)' },
|
|
{ value: 'export', label: 'Export', description: 'Försäljning utanför EU (behåller avdragsrätt)' },
|
|
{ value: 'exempt', label: 'Momsfri', description: 'Undantaget enligt ML (vård, utbildning, finans)' },
|
|
{ value: 'none', label: 'Ingen moms', description: 'Ej momspliktigt (t.ex. lön, privata uttag)' },
|
|
]
|