feat(po-pdf): add token field to PurchaseOrderDocumentEntry

This commit is contained in:
SJCoetz 2026-07-09 22:17:21 +02:00
parent 169c1d82c5
commit 1e99d23e8b
2 changed files with 15 additions and 0 deletions

View file

@ -215,6 +215,11 @@ export async function POST(
const newHistoryEntry: PurchaseOrderDocumentEntry = {
version: nextVersion,
file: filename,
// Task 2 will swap this for the real PB token returned from
// the upload response. For now we persist an empty string so
// the schema compiles; the GET handler falls back to
// `documents[idx]` when token is empty (legacy rows).
token: "",
generatedAt: generatedAtIso,
generatedBy: body.generatedBy || "",
reason: (body.notes || "").slice(0, 500),

View file

@ -60,6 +60,8 @@ export interface Company extends BaseRecord {
company: string;
address: string;
vendor: string;
company_email: string;
company_tel: string;
/**
* Geographic location for future routing / delivery features.
*
@ -674,6 +676,14 @@ export interface PurchaseOrderDocumentEntry {
version: number;
/** PB-generated filename for the file in `purchase_orders.documents`. */
file: string;
/**
* PB-side file token (the slugged-on-disk name) for the file in
* `purchase_orders.documents`. Distinct from `file` (the
* human-readable name we asked PB to store). New entries always
* populate this; legacy rows may be empty — the GET handler
* falls back to `documents[idx]` for those.
*/
token: string;
/** ISO 8601 timestamp the PDF was generated. */
generatedAt: string;
/** User id of the operator who triggered the regen (empty string if automated). */