diff --git a/apps/hq-web/src/api.ts b/apps/hq-web/src/api.ts index f74a632..7dd9030 100644 --- a/apps/hq-web/src/api.ts +++ b/apps/hq-web/src/api.ts @@ -559,6 +559,25 @@ export async function downloadModuleClientsCsv(moduleId: string, moduleCode: str URL.revokeObjectURL(url) } +// ---------- APEX import (D18 WS-B; owner-only) ---------- +export interface ImportReport { + clients: { staged: number; problems: number } + invoices: { staged: number; problems: number; totalPaise: number } + samples: { firstClients: string[]; lastInvoices: string[] } +} +export interface ImportStatus { + report: ImportReport + problemClients: { row_no: number; code: string | null; name: string | null; problems: string }[] + problemInvoices: { row_no: number; client_code: string | null; doc_no: string | null; problems: string }[] +} +export const getImportStatus = (): Promise => apiFetch('/import/status') +export const stageApexCsv = (body: { clientsCsv?: string; invoicesCsv?: string }): Promise => + apiFetch<{ report: ImportReport }>('/import/stage', { method: 'POST', body: JSON.stringify(body) }).then((r) => r.report) +export const commitApexImport = (): Promise<{ clients: number; invoices: number; seeded: { fy: string; lastSeq: number } | null }> => + apiFetch<{ result: { clients: number; invoices: number; seeded: { fy: string; lastSeq: number } | null } }>( + '/import/commit', { method: 'POST', body: '{}' }, + ).then((r) => r.result) + /** The PDF route needs the bearer header, which an