W116: Generate PO PDF
Renders a printable PO document and returns the PDF bytes. Triggered from Purchase Order Detail, "Export PDF". Composes header, items, vendor and billing contact, ship-to location, and the org's branding (logo, address) into a generic CPG template; no per-template Anthem code lives here.
Steps
-
Hydrate everything Get Detail returns. Run W113 to load PO header, items, vendor, location, and referenced catalog rows.
-
Load the vendor billing contact. Call
Vendors.getByIdandContacts.listByEntity('vendor', vendorId)to pull the primary billing contact. -
Load the org branding bundle. Call
OrganizationSettings.getfor the logo reference (resolves to aDocumentsrow), billing address, and any per-org branding values. -
Render the PDF. Feed the generic CPG template with the data above. The template is shape-only; org settings provide every value.
-
Return the PDF bytes. The L4 layer streams them to the client.
Returns
The PDF bytes for the rendered PO.
Business rules
- No Anthem-specific values in code. The template is generic; everything that differs between orgs lives in
organization_settings. - Logo is optional. If the org has not set a logo, the template renders without one rather than failing.
Errors
NotFoundError. The PO was not found.