Skip to content

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.

889 B
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

import type { IssueData } from "./types";

/** Merge-field variable map for an Issue. */
export function buildIssueVars(
  data: Pick<IssueData, "nonConformance" | "company">
): Record<string, string> {
  const nc = data.nonConformance;
  const str = (v: unknown): string => (v == null ? "" : String(v));

  return {
    "issue.number": str(nc?.nonConformanceId),
    "issue.name": str(nc?.name),
    "issue.status": str(nc?.status),
    "issue.openDate": str(nc?.openDate),
    "issue.closeDate": str(nc?.closeDate),
    "company.name": str(data.company?.name),
    "company.city": str(data.company?.city),
    "company.country": str(data.company?.countryCode)
  };
}