Phase 7: close, file, PDFs and prints
Clerical close and file: the VISUAL observed state beside the close confirm, a 409 with a second confirm when the feed still shows work orders open, filing with a signature and the HMAC seal, the data book built on the server and stored on the seal in the filing transaction, admin reopen keeping the broken seal with its data book. Server PDFs with reportlab, pypdf and pypdfium2: the manufacturing data book page for page after the old build (cover, index, drawings with VOID stamps, traceability and heat map rasters, weld maps and welding records, Q.C. inspections, Q.C. and test documents, MTRs, record history), the job traveler with work order QR codes, the ITP PDF filed automatically at sign-off, every print kind with the PRINTED COPY stamp, the controlled-copy stamp signed with the seal key, PDF metadata, the traceability CSV with the formula guard, and the append-only print_log with an audit row for every print and export (migration 0008). Frontend: the close and file panel, the print menu and its entry points, the printed copies list on the History tab, the ITP PDF buttons. Tests: server (close, file, reopen, seal, the builders, prints, CSV, stamps), frontend, and the Playwright close and print scenarios. Docs updated; SECURITY closes M2, S6, S7 and S8. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
@@ -16,8 +16,11 @@ import type {
|
||||
PacketHeader,
|
||||
PacketListQuery,
|
||||
PacketRead,
|
||||
PrintKind,
|
||||
PrintRow,
|
||||
QcFields,
|
||||
ReceiptBody,
|
||||
SealView,
|
||||
ShortBody,
|
||||
StageFields,
|
||||
TransitionBody,
|
||||
@@ -127,6 +130,25 @@ export const packetsApi = {
|
||||
api.put<PacketRead>(`${base(id)}/qc/welds/${no}`, { ...body, ...g }),
|
||||
/** The scalar inspection fields with a field-level base: 409 field_conflict when someone changed one first. */
|
||||
qcPatch: (id: number, body: FieldCas<QcFields>) => api.patch<PacketRead>(`${base(id)}/qc`, body),
|
||||
|
||||
/* Phase 7: close, file, PDFs and prints. */
|
||||
/** ADMIN_REOPEN: filed back to complete. The reason and the signature are required. */
|
||||
reopen: (id: number, body: { reason: string } & Guarded) => api.post<PacketRead>(`${base(id)}/reopen`, body),
|
||||
/** The newest seal, whether it still matches the record (null when the key is not available), and every seal row. */
|
||||
seal: async (id: number, signal?: AbortSignal): Promise<SealView> => {
|
||||
const raw = await api.get<Partial<SealView> | null>(`${base(id)}/seal`, signal);
|
||||
return { seal: raw?.seal ?? null, valid: raw?.valid ?? null, seals: Array.isArray(raw?.seals) ? raw.seals : [] };
|
||||
},
|
||||
/** Printed copies and exports of this packet, newest first. */
|
||||
prints: async (id: number, signal?: AbortSignal): Promise<PrintRow[]> =>
|
||||
asList<PrintRow>(await api.get<unknown>(`${base(id)}/prints`, signal), "prints"),
|
||||
/** The data book or the job traveler as a PDF. `download` asks for an attachment. */
|
||||
pdfUrl: (id: number, kind: "databook" | "traveler", download = false) => `${base(id)}/pdf/${kind}${download ? "?download=1" : ""}`,
|
||||
/** The traceability CSV. */
|
||||
csvUrl: (id: number) => `${base(id)}/export/traceability.csv`,
|
||||
/** A printed copy: the stamped PDF of one print kind. `sheet` limits a map or clean print to one page; `asset` names the document for kind doc. */
|
||||
printUrl: (id: number, kind: PrintKind, opts: { sheet?: number | undefined; asset?: string | undefined } = {}) =>
|
||||
`${base(id)}/print/${kind}${qs({ sheet: opts.sheet, asset: opts.asset })}`,
|
||||
};
|
||||
|
||||
/** GET /api/departments/{code}/people: the welder picker and the weld sheet's stamp. */
|
||||
|
||||
@@ -413,6 +413,12 @@ export const signOff = (id: number, sign: SignBody | undefined, g: Guarded = {})
|
||||
|
||||
export const reopenItp = (id: number, body: { reason: string; it_reason?: string }) => itp(api.post<Itp>(`/api/itps/${id}/reopen`, body));
|
||||
|
||||
/** Phase 7: the ITP as a PDF built now. `download` asks for an attachment. */
|
||||
export const itpPdfUrl = (id: number, download = false) => `/api/itps/${id}/pdf${download ? "?download=1" : ""}`;
|
||||
|
||||
/** Phase 7: the ITP PDF stamped PRINTED COPY. */
|
||||
export const itpPrintUrl = (id: number) => `/api/itps/${id}/print`;
|
||||
|
||||
export const qcApi = {
|
||||
getQcHome,
|
||||
getFolders,
|
||||
@@ -433,4 +439,6 @@ export const qcApi = {
|
||||
unsignBlock,
|
||||
signOff,
|
||||
reopenItp,
|
||||
itpPdfUrl,
|
||||
itpPrintUrl,
|
||||
};
|
||||
|
||||
@@ -384,6 +384,8 @@ export interface QcFolderDoc {
|
||||
url: string;
|
||||
scope: "unit" | "project";
|
||||
added_at: string | null;
|
||||
/** Not sent today; the asset id is read from `url` when it is missing. */
|
||||
asset_id?: string;
|
||||
}
|
||||
|
||||
/** The unit's ITP summary. */
|
||||
@@ -480,7 +482,12 @@ export interface PacketRead {
|
||||
open_cos: number[];
|
||||
open_shorts: number;
|
||||
docs: PacketDoc[];
|
||||
seal: { sealed_at: string; key_id: string; broken_at: string | null } | null;
|
||||
/** Phase 7: the newest seal row, broken or not, with the data book filed on it. */
|
||||
seal: PacketSeal | null;
|
||||
/** Phase 7: how many seal rows the packet has (2 after a reopen and a refile). */
|
||||
seals?: number;
|
||||
/** Phase 7: what the feed saw in VISUAL against the Clerical close. Null for a hand packet. */
|
||||
vclose_check?: VcloseCheck | null;
|
||||
can: string[];
|
||||
blocked: Record<string, string[]>;
|
||||
holder: string;
|
||||
@@ -505,6 +512,65 @@ export interface PacketRead {
|
||||
itp_hold?: ItpHold | null;
|
||||
}
|
||||
|
||||
/* ---------- Phase 7: close, file, PDFs and prints ---------- */
|
||||
|
||||
/** The data book stored on a seal. */
|
||||
export interface SealDatabook {
|
||||
asset_id: string;
|
||||
/** "/_blob/<id>", inline. */
|
||||
url: string;
|
||||
/** "/_blob/<id>?download=1", as an attachment. */
|
||||
download_url: string;
|
||||
pages: number | null;
|
||||
size: number | null;
|
||||
file_name: string | null;
|
||||
}
|
||||
|
||||
/** PacketRead.seal and the rows of GET /api/packets/{id}/seal. */
|
||||
export interface PacketSeal {
|
||||
id: number;
|
||||
sealed_at: string;
|
||||
sealed_by: WhoRef | null;
|
||||
key_id: string;
|
||||
signed: boolean;
|
||||
broken_at: string | null;
|
||||
broken_by: WhoRef | null;
|
||||
broken_reason: string | null;
|
||||
/** Work orders the feed showed open in VISUAL at filing, or null. */
|
||||
open_wos: string[] | null;
|
||||
databook: SealDatabook | null;
|
||||
}
|
||||
|
||||
/** PacketRead.vclose_check. */
|
||||
export interface VcloseCheck {
|
||||
observed_at: string | null;
|
||||
closed_at: string | null;
|
||||
/** "wo_base/lot" of every leg not closed and not cancelled. Text, never numbers. */
|
||||
open_wos: string[];
|
||||
/** True when the Clerical close and the feed's closed_at say the same. */
|
||||
agrees: boolean;
|
||||
}
|
||||
|
||||
/** GET /api/packets/{id}/seal. `valid` is null when the seal key is not available. */
|
||||
export interface SealView {
|
||||
seal: PacketSeal | null;
|
||||
valid: boolean | null;
|
||||
seals: PacketSeal[];
|
||||
}
|
||||
|
||||
/** The print kinds of GET /api/packets/{id}/print/{kind}. */
|
||||
export type PrintKind = "traveler" | "map-h" | "map-w" | "clean" | "void" | "databook" | "doc";
|
||||
|
||||
/** One row of GET /api/packets/{id}/prints. */
|
||||
export interface PrintRow {
|
||||
id: number;
|
||||
at: string;
|
||||
by: WhoRef | null;
|
||||
kind: string;
|
||||
what: string;
|
||||
pages: number | null;
|
||||
}
|
||||
|
||||
/* ---------- Phase 5: the shop on the packet ---------- */
|
||||
|
||||
export interface Weld {
|
||||
@@ -726,6 +792,8 @@ export interface TransitionBody {
|
||||
for_sup_id?: string;
|
||||
/** Phase 6: QC_REJECT. An NCR number like NCR-2026-0021. */
|
||||
ncr?: string;
|
||||
/** Phase 7: FILE. Files although the feed still shows work orders open in VISUAL. */
|
||||
confirm_open_wos?: boolean;
|
||||
sign?: SignBody;
|
||||
it_reason?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user