import { prisma } from "@/lib/prisma";

export const lotTransformationDetailInclude = {
  inputs: {
    include: {
      sourceLot: {
        include: {
          unit: { select: { code: true } },
          warehouse: { select: { name: true } },
          warehouseLocation: { select: { name: true } },
          grade: { select: { name: true } }
        }
      }
    }
  },
  outputs: {
    include: {
      resultLot: {
        include: {
          unit: { select: { code: true } },
          warehouse: { select: { name: true } },
          warehouseLocation: { select: { name: true } },
          grade: { select: { name: true } }
        }
      }
    }
  }
} as const;

export async function getLotTransformationById(id: bigint) {
  return prisma.lotTransformation.findUnique({
    where: { id },
    include: lotTransformationDetailInclude
  });
}
