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:
@@ -405,7 +405,8 @@ def finish_all(shop: Shop, itp: dict[str, Any]) -> dict[str, Any]:
|
||||
return sign_all_blocks(shop, approve_all(shop, itp))
|
||||
|
||||
|
||||
def test_signoff_without_pdf(qc_shop: Shop) -> None:
|
||||
def test_signoff_files_pdf(qc_shop: Shop) -> None:
|
||||
"""Phase 7: the sign-off builds the signed ITP PDF and files it in the unit's Q.C. folder."""
|
||||
shop = qc_shop
|
||||
unit_id, itp = new_itp(shop)
|
||||
q = shop("qc.quinn")
|
||||
@@ -425,13 +426,17 @@ def test_signoff_without_pdf(qc_shop: Shop) -> None:
|
||||
itp = ok(sign_off(q, itp))
|
||||
assert itp["status"] == "complete" and itp["can"] == {"edit": False, "sign_off": False, "reopen": False}
|
||||
assert itp["signoff"]["by"]["display_name"] == "Quinn QC" and itp["signoff"]["at"]
|
||||
assert itp["signoff"]["asset_id"] is None
|
||||
assert itp_log(itp)[0] == ("ITP signed off", "PDF filing reserved for phase 7") and itp["log"][0]["signed"]
|
||||
asset_id = itp["signoff"]["asset_id"]
|
||||
assert asset_id is not None
|
||||
assert itp_log(itp)[0] == ("ITP signed off", "PDF filed") and itp["log"][0]["signed"]
|
||||
row = one(
|
||||
shop.settings, "SELECT signoff_asset_id, signoff_signature_id IS NOT NULL FROM itps WHERE id = %s", (itp["id"],)
|
||||
)
|
||||
assert tuple(row) == (None, True)
|
||||
assert all_rows(shop.settings, "SELECT count(*) FROM qc_docs WHERE unit_id = %s", (unit_id,))[0][0] == 0
|
||||
assert (str(row[0]), row[1]) == (asset_id, True)
|
||||
asset = one(shop.settings, "SELECT mime, source, original_name FROM assets WHERE id = %s", (asset_id,))
|
||||
assert tuple(asset) == ("application/pdf", "itp_signoff", f"{itp['no']}_signed.pdf")
|
||||
docs = all_rows(shop.settings, "SELECT type, auto, asset_id FROM qc_docs WHERE unit_id = %s", (unit_id,))
|
||||
assert [(d[0], d[1], str(d[2])) for d in docs] == [("ITP", True, asset_id)]
|
||||
# the admin may reopen; qc.quinn and qc.sue may not
|
||||
assert get_itp(shop("admin.ann"), unit_id)["can"]["reopen"] is True
|
||||
assert get_itp(q, unit_id)["can"]["reopen"] is False
|
||||
@@ -485,7 +490,8 @@ def test_signoff_with_pdf_hook(qc_shop: Shop, monkeypatch: pytest.MonkeyPatch) -
|
||||
calls: list[Any] = []
|
||||
asset_ids = [upload_doc(q, "itp-1.pdf")["id"], upload_doc(q, "itp-2.pdf")["id"]]
|
||||
|
||||
def fake_hook(conn: Any, itp_row: Any, actor: Any) -> uuid.UUID:
|
||||
def fake_hook(conn: Any, itp_row: Any, actor: Any, settings: Any = None) -> uuid.UUID:
|
||||
assert settings is not None
|
||||
calls.append(itp_row)
|
||||
return uuid.UUID(asset_ids[len(calls) - 1])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user