mirror of
https://github.com/Sea-Haven-Industries/seahaven-ap.git
synced 2026-10-04 10:11:58 +00:00
* feat(shared): add payment ladder and CSV domain package Introduce @seahaven-ap/shared via npm workspaces so FE and future API share payments-dashboard-compatible status ladders, pay-date helpers, and CSV headers. * fix(web): build shared package before vite dev Ensure fresh npm ci && npm run dev (and Playwright webServer) can resolve @seahaven-ap/shared dist exports that are gitignored.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* Invoice status helpers for Ready-to-Pay and post pay-run alignment.
|
|
* Thin surface for AP-17; full pay-run logic stays in the API.
|
|
*/
|
|
|
|
export const INVOICE_STATUSES = [
|
|
"pending_approval",
|
|
"approved",
|
|
"scheduled",
|
|
"paid",
|
|
"rejected",
|
|
"void",
|
|
] as const;
|
|
|
|
export type InvoiceStatus = (typeof INVOICE_STATUSES)[number];
|
|
|
|
/** Invoices eligible for Select to Pay / pay-run selection. */
|
|
export const READY_TO_PAY_STATUSES = ["approved"] as const satisfies readonly InvoiceStatus[];
|
|
|
|
export function isInvoiceStatus(value: string): value is InvoiceStatus {
|
|
return (INVOICE_STATUSES as readonly string[]).includes(value);
|
|
}
|
|
|
|
export function isReadyToPay(status: InvoiceStatus | string): boolean {
|
|
return (READY_TO_PAY_STATUSES as readonly string[]).includes(status);
|
|
}
|
|
|
|
/** Status after a successful pay run groups the invoice into the payments queue. */
|
|
export function statusAfterPayRun(): InvoiceStatus {
|
|
return "scheduled";
|
|
}
|
|
|
|
/** Terminal paid status once the payment ladder reaches cleared (AP-17 wiring). */
|
|
export function statusAfterPaymentCleared(): InvoiceStatus {
|
|
return "paid";
|
|
}
|