import { ProductCatalog as CwProductCatalog } from "../../generated/prisma/client"; import { CatalogItem as ApiCatalogItem } from "../../../api/generated/prisma/client"; import { Translation } from "./types"; export const catalogItemTranslation: Translation< CwProductCatalog, ApiCatalogItem > = { values: [ { from: "catalogRecId", to: "id" }, { from: "itemId", to: "identifier" }, { from: "description", to: "name", process: (value) => (value ? value : "Unnamed Item"), }, { from: "longDescription", to: "description" }, { from: "longDescription", to: "customerDescription" }, { from: "notes", to: "internalNotes" }, { from: "subcategoryRecId", to: "subcategoryId", process: (value) => { if (value == null) { throw new Error( "CatalogItem subcategoryId is required but subcategoryRecId is null" ); } return value; }, }, { from: "manufacturerRecId", to: "manufacturerId" }, { from: "manufacturerPartNum", to: "partNumber" }, { from: "vendorSku", to: "vendorSku" }, { from: "vendorRecId", to: "vendorCwId" }, { from: "listPrice", to: "price", process: (value) => Number(value), }, { from: "currentCost", to: "cost", process: (value) => (value == null ? 0 : Number(value)), }, { from: "inactiveFlag", to: "inactive" }, { from: "taxableFlag", to: "salesTaxable" }, { from: "minimumStock", to: "onHand", process: (value) => (value == null ? 0 : value), }, { from: "classId", to: "classId" }, { from: "dateEnteredUtc", to: "createdAt" }, { from: "lastUpdatedUtc", to: "cwLastUpdated" }, { from: "lastUpdatedUtc", to: "updatedAt" }, ], };