Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: label template in print job
Sidwebworks7af45b515917
diff --git a/apps/erp/app/components/DocumentTemplateEditor/index.tsx b/apps/erp/app/components/DocumentTemplateEditor/index.tsxindex b2baa19eca..f97f2711ad 100644--- a/apps/erp/app/components/DocumentTemplateEditor/index.tsx+++ b/apps/erp/app/components/DocumentTemplateEditor/index.tsx@@ -160,10 +160,9 @@ const PICKER_LABEL =*/function ControlRail() {const [tab, setTab] = useState<"style">("style");- // Labels render on monochrome thermal stock — theme colors don't apply.- const showThemeColors = useEditorStore(- (s) => s.documentType !== "trackingLabel"- );+ // Labels render on thermal stock with fixed printer fonts and no color —+ // typography and theme don't apply, so the whole Style tab is hidden.+ const isLabel = useEditorStore((s) => s.documentType === "trackingLabel");return (<ScrollArea className="h-full bg-card">@@ -173,27 +172,27 @@ function ControlRail() {<BlockList /></section>- <Tabs- value={tab}- onValueChange={(v) => setTab(v as "style")}- className="border-t pt-1"- >- <TabsList className="h-auto w-full justify-start gap-1 rounded-none border-b bg-transparent p-0 shadow-none">- <UnderlineTab value="style" icon={<LuPalette />} label="Style" />- </TabsList>- <TabsContent value="style" className="flex flex-col gap-5 pt-4">- <section className="flex flex-col gap-3">- <h3 className={RAIL_HEADING}>Typography</h3>- <FontConfig />- </section>- {showThemeColors && (+ {!isLabel && (+ <Tabs+ value={tab}+ onValueChange={(v) => setTab(v as "style")}+ className="border-t pt-1"+ >+ <TabsList className="h-auto w-full justify-start gap-1 rounded-none border-b bg-transparent p-0 shadow-none">+ <UnderlineTab value="style" icon={<LuPalette />} label="Style" />+ </TabsList>+ <TabsContent value="style" className="flex flex-col gap-5 pt-4">+ <section className="flex flex-col gap-3">+ <h3 className={RAIL_HEADING}>Typography</h3>+ <FontConfig />+ </section><section className="flex flex-col gap-2"><h3 className={RAIL_HEADING}>Theme colors</h3><ThemeConfig /></section>- )}- </TabsContent>- </Tabs>+ </TabsContent>+ </Tabs>+ )}</div></ScrollArea>);@@ -285,7 +284,7 @@ function EditorToolbar({</div></div>{previewEntities.length > 0 && (- <div className="flex min-w-0 max-w-[280px] flex-1 flex-col items-center gap-0.5">+ <div className="flex min-w-0 max-w-[280px] flex-1 flex-col items-center gap-0.5 self-end"><span className={PICKER_LABEL}>Preview data</span><Selectvalue={previewId ?? SAMPLE_DATA_VALUE}@@ -307,7 +306,7 @@ function EditorToolbar({</Select></div>)}- <div className="flex items-center gap-2">+ <div className="flex items-end gap-2"><LabelSizePicker />{canEdit && (<>@@ -347,7 +346,7 @@ function LabelSizePicker() {return (<div className="flex flex-col items-start gap-0.5">- <span className={PICKER_LABEL}>Label stock</span>+ <span className={PICKER_LABEL}>Preview size</span><Select value={labelSizeId} onValueChange={setLabelSizeId}><SelectTrigger size="sm" className="w-[160px]"><SelectValue placeholder="Label size" />diff --git a/packages/jobs/src/inngest/functions/tasks/print-job/index.tsx b/packages/jobs/src/inngest/functions/tasks/print-job/index.tsxindex c804391c25..23ad35f009 100644--- a/packages/jobs/src/inngest/functions/tasks/print-job/index.tsx+++ b/packages/jobs/src/inngest/functions/tasks/print-job/index.tsx@@ -270,7 +270,13 @@ async function processDocumentType(format);} else if (hasBuiltInRenderer) {- content = await renderItemBuiltIn(client, doc, format, mediaSizeId);+ content = await renderItemBuiltIn(+ client,+ companyId,+ doc,+ format,+ mediaSizeId+ );} else {await updatePrintJobStatus(client, jobId, companyId, "failed", {error: `Document type "${documentTypeId}" requires a BinderyPress template.`diff --git a/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx b/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsxindex 94b101158b..9e849c4fef 100644--- a/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx+++ b/packages/jobs/src/inngest/functions/tasks/print-job/renderers.tsx@@ -3,16 +3,18 @@// renderToStream.import type { Database } from "@carbon/database";+import { resolveLabelLogo } from "@carbon/documents/labels";import {KanbanLabelPDF,ProductLabelPDF,StorageUnitLabelPDF} from "@carbon/documents/pdf";+import { toDocumentTemplate } from "@carbon/documents/template";import {generateProductLabelZPL,generateStorageUnitLabelZPL} from "@carbon/documents/zpl";-import { ERP_URL } from "@carbon/env";+import { ERP_URL, SUPABASE_URL } from "@carbon/env";import { renderWithBinderyPress } from "@carbon/printing/printing.server";import type { LabelSize, ProductLabelItem } from "@carbon/utils";import { labelSizes } from "@carbon/utils";@@ -53,6 +55,7 @@ export async function renderItemWithTemplate(export async function renderItemBuiltIn(client: SupabaseClient<Database>,+ companyId: string,doc: PrintableDocumentItem,format: "zpl" | "pdf",mediaSizeId: string@@ -60,14 +63,27 @@ export async function renderItemBuiltIn(switch (doc.type) {case "productLabel": {const mediaSize = requireMediaSize(mediaSizeId);+ // Apply the company's tracking-label template + logo, same as the+ // interactive download routes — otherwise queued jobs print a layout+ // that doesn't match what the customizer shows.+ const { template, logo } = await loadProductLabelContext(+ client,+ companyId,+ mediaSize+ );if (format === "pdf") {return renderPdfContent(- <ProductLabelPDF items={[doc.item]} labelSize={mediaSize} />+ <ProductLabelPDF+ items={[doc.item]}+ labelSize={mediaSize}+ template={template}+ logo={logo}+ />);}requireZplCapable(mediaSize);return {- content: generateProductLabelZPL(doc.item, mediaSize),+ content: generateProductLabelZPL(doc.item, mediaSize, template, logo),contentType: "zpl"};}@@ -97,6 +113,51 @@ function requireMediaSize(mediaSizeId: string): LabelSize {return mediaSize;}+const PUBLIC_STORAGE_URL_PREFIX = `${SUPABASE_URL}/storage/v1/object/public/public/`;++/**+ * Resolve the company's tracking-label template + logo for a built-in render.+ * Mirrors the interactive label routes (which use `getDocumentTemplateConfig`+ * + `resolveLabelLogo`) so queued print jobs honor the customizer layout. The+ * jobs package can't import app modules, so it reads the row directly here.+ */+async function loadProductLabelContext(+ client: SupabaseClient<Database>,+ companyId: string,+ labelSize: LabelSize+) {+ const [templateRow, companyRow] = await Promise.all([+ client+ .from("documentTemplate")+ .select("*")+ .eq("companyId", companyId)+ .eq("documentType", "trackingLabel")+ .maybeSingle(),+ client+ .from("company")+ .select("logoLight, logoLightIcon")+ .eq("id", companyId)+ .maybeSingle()+ ]);++ const template = toDocumentTemplate(templateRow.data, "trackingLabel");++ const expand = (path: string | null | undefined) =>+ path ? `${PUBLIC_STORAGE_URL_PREFIX}${path}` : null;+ const company = companyRow.data+ ? {+ logoLight: expand(companyRow.data.logoLight),+ logoLightIcon: expand(companyRow.data.logoLightIcon)+ }+ : null;++ const logo = await resolveLabelLogo(company, template, labelSize, {+ supabaseUrl: SUPABASE_URL ?? ""+ });++ return { template, logo };+}+function requireZplCapable(mediaSize: LabelSize): void {if (!mediaSize.zpl) {throw new Error(`Media size ${mediaSize.id} does not support ZPL`);