import { ProductInventory as CwProductInventory } from "../../generated/prisma/client";
import { ProductInventory as ApiProductInventory } from "../../../api/generated/prisma/client";
import { Translation } from "./types";

export const productInventoryTranslation: Translation<
  CwProductInventory,
  ApiProductInventory
> = {
  values: [
    { from: "inventoryRecId", to: "id" },
    {
      from: "qtyOnHand",
      to: "qtyOnHand",
      process: (value) => (value == null ? 0 : Number(value)),
    },
    {
      from: "lastUpdate",
      to: "createdAt",
      process: (value) => (value ? value : new Date(0)),
    },
    { from: "warehouseRecId", to: "warehouseId" },
    { from: "warehouseBinRecId", to: "warehouseBinId" },
    { from: "catalogRecId", to: "itemId" },
    { from: "updatedBy", to: "updatedById" },
    {
      from: "lastUpdate",
      to: "updatedAt",
      process: (value) => (value ? value : new Date(0)),
    },
  ],
};
