/** * TypeScript types for the expenses module. */ export interface ExpenseCategory { id: string; organisation_id: string; name: string; color: string; created_at: string; } export type ExpenseStatus = "draft" | "submitted" | "approved" | "rejected" | "reimbursed"; export interface Expense { id: string; organisation_id: string; category_id: string | null; employee_id: string | null; amount: number; currency: string; vendor: string | null; description: string | null; expense_date: string; status: ExpenseStatus; receipt_url: string | null; created_by: string | null; created_at: string; updated_at: string; } export interface ExpenseWithCategory extends Expense { category: { name: string; color: string } | null; employee: { first_name: string; last_name: string } | null; } export const STATUS_LABELS: Record = { draft: "Draft", submitted: "Submitted", approved: "Approved", rejected: "Rejected", reimbursed: "Reimbursed", }; export const STATUS_COLORS: Record = { draft: "bg-gray-100 text-gray-600 border-gray-200", submitted: "bg-amber-100 text-amber-700 border-amber-200", approved: "bg-blue-100 text-blue-700 border-blue-200", rejected: "bg-red-100 text-red-700 border-red-200", reimbursed: "bg-emerald-100 text-emerald-700 border-emerald-200", }; export function formatCurrency(amount: number, currency = "AUD"): string { const symbols: Record = { USD: "$", AUD: "A$", GBP: "£", CAD: "C$", NZD: "NZ$", EUR: "€", INR: "₹", SGD: "S$", JPY: "¥", }; const sym = symbols[currency] || "$"; return `${sym}${amount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; } export function formatDateShort(dateStr: string): string { const d = new Date(dateStr + "T00:00:00"); return d.toLocaleDateString("en-AU", { day: "numeric", month: "short", year: "numeric" }); }