export type MockVendor = { id: string; name: string; }; export type MockInvoiceStatus = "pending_approval" | "approved" | "scheduled" | "paid"; export type MockInvoice = { id: string; invoiceNumber: string; invoiceNumbers: string; vendorId: string; vendorName: string; amountDue: number; amount: number; dueDate: string; payDate: string | null; sendPaymentOn: string | null; status: MockInvoiceStatus; paymentMethod: "check" | "ach"; }; export const mockVendors: MockVendor[] = [ { id: "vendor-1", name: "Acme Supplies Co" }, { id: "vendor-2", name: "Harbor Maintenance LLC" }, { id: "vendor-3", name: "Northwind Utilities" }, { id: "vendor-4", name: "Coastal Office Supply" }, ]; const seedInvoices: MockInvoice[] = [ { id: "inv-1", invoiceNumber: "INV-1001", invoiceNumbers: "INV-1001", vendorId: "vendor-1", vendorName: "Acme Supplies Co", amountDue: 1250.5, amount: 1250.5, dueDate: "2026-08-20", payDate: "2026-08-15", sendPaymentOn: "2026-08-15", status: "approved", paymentMethod: "check", }, { id: "inv-2", invoiceNumber: "INV-1002", invoiceNumbers: "INV-1002", vendorId: "vendor-2", vendorName: "Harbor Maintenance LLC", amountDue: 4800, amount: 4800, dueDate: "2026-08-25", payDate: null, sendPaymentOn: "2026-08-20", status: "pending_approval", paymentMethod: "ach", }, { id: "inv-3", invoiceNumber: "INV-1003", invoiceNumbers: "INV-1003", vendorId: "vendor-3", vendorName: "Northwind Utilities", amountDue: 312.75, amount: 312.75, dueDate: "2026-08-12", payDate: "2026-08-10", sendPaymentOn: "2026-08-10", status: "approved", paymentMethod: "check", }, { id: "inv-4", invoiceNumber: "INV-1004", invoiceNumbers: "INV-1004", vendorId: "vendor-4", vendorName: "Coastal Office Supply", amountDue: 890.25, amount: 900, dueDate: "2026-09-01", payDate: null, sendPaymentOn: "2026-08-27", status: "pending_approval", paymentMethod: "ach", }, { id: "inv-5", invoiceNumber: "INV-1005", invoiceNumbers: "INV-1005", vendorId: "vendor-1", vendorName: "Acme Supplies Co", amountDue: 2100, amount: 2100, dueDate: "2026-07-30", payDate: "2026-07-25", sendPaymentOn: "2026-07-25", status: "scheduled", paymentMethod: "check", }, { id: "inv-6", invoiceNumber: "INV-1006", invoiceNumbers: "INV-1006", vendorId: "vendor-2", vendorName: "Harbor Maintenance LLC", amountDue: 0, amount: 1550, dueDate: "2026-07-15", payDate: "2026-07-10", sendPaymentOn: "2026-07-10", status: "paid", paymentMethod: "ach", }, { id: "inv-7", invoiceNumber: "INV-1007", invoiceNumbers: "INV-1007", vendorId: "vendor-3", vendorName: "Northwind Utilities", amountDue: 645.1, amount: 645.1, dueDate: "2026-08-28", payDate: "2026-08-22", sendPaymentOn: "2026-08-22", status: "approved", paymentMethod: "ach", }, ]; /** Mutable in-memory invoice store for mock POC interactions. */ let invoiceStore: MockInvoice[] = seedInvoices.map((invoice) => ({ ...invoice })); /** Mocks are the default data path until the API is wired. */ export function areMocksEnabled(): boolean { return import.meta.env.VITE_USE_MOCKS !== "false"; } export function getMockInvoices(): MockInvoice[] { if (!areMocksEnabled()) { return []; } return invoiceStore.map((invoice) => ({ ...invoice })); } export function getMockVendors(): MockVendor[] { if (!areMocksEnabled()) { return []; } return mockVendors; } export function updateMockInvoicePayDate(id: string, payDate: string | null): MockInvoice { const index = invoiceStore.findIndex((invoice) => invoice.id === id); if (index === -1) { throw new Error(`Mock invoice not found: ${id}`); } const updated: MockInvoice = { ...invoiceStore[index], payDate }; invoiceStore = [...invoiceStore.slice(0, index), updated, ...invoiceStore.slice(index + 1)]; return { ...updated }; } /** Test helper to restore seed data between unit tests. */ export function resetMockInvoices(): void { invoiceStore = seedInvoices.map((invoice) => ({ ...invoice })); }