import { jobModel } from './production/job.schema.js';
import { subJobModel } from './production/subjob.schema.js';
import { printerModel } from './production/printer.schema.js';
import { filamentModel } from './management/filament.schema.js';
import { gcodeFileModel } from './production/gcodefile.schema.js';
import { partModel } from './management/part.schema.js';
import { productModel } from './management/product.schema.js';
import { vendorModel } from './management/vendor.schema.js';
import { filamentStockModel } from './inventory/filamentstock.schema.js';
import { purchaseOrderModel } from './inventory/purchaseorder.schema.js';
import { orderItemModel } from './inventory/orderitem.schema.js';
import { stockEventModel } from './inventory/stockevent.schema.js';
import { stockAuditModel } from './inventory/stockaudit.schema.js';
import { partStockModel } from './inventory/partstock.schema.js';
import { auditLogModel } from './management/auditlog.schema.js';
import { userModel } from './management/user.schema.js';
import { noteTypeModel } from './management/notetype.schema.js';
import { noteModel } from './misc/note.schema.js';
import { documentSizeModel } from './management/documentsize.schema.js';
import { documentTemplateModel } from './management/documenttemplate.schema.js';
import { hostModel } from './management/host.schema.js';
import { documentPrinterModel } from './management/documentprinter.schema.js';
import { documentJobModel } from './management/documentjob.schema.js';
import { fileModel } from './management/file.schema.js';
import { courierServiceModel } from './management/courierservice.schema.js';
import { courierModel } from './management/courier.schema.js';
import { taxRateModel } from './management/taxrates.schema.js';
import { taxRecordModel } from './management/taxrecord.schema.js';

// Map prefixes to models and id fields
export const models = {
  PRN: { model: printerModel, idField: '_id', type: 'printer', referenceField: '_reference' },
  FIL: { model: filamentModel, idField: '_id', type: 'filament', referenceField: '_reference' },
  GCF: { model: gcodeFileModel, idField: '_id', type: 'gcodeFile', referenceField: '_reference' },
  JOB: { model: jobModel, idField: '_id', type: 'job', referenceField: '_reference' },
  PRT: { model: partModel, idField: '_id', type: 'part', referenceField: '_reference' },
  PRD: { model: productModel, idField: '_id', type: 'product', referenceField: '_reference' },
  VEN: { model: vendorModel, idField: '_id', type: 'vendor', referenceField: '_reference' },
  SJB: { model: subJobModel, idField: '_id', type: 'subJob', referenceField: '_reference' },
  FLS: {
    model: filamentStockModel,
    idField: '_id',
    type: 'filamentStock',
    referenceField: '_reference',
  },
  SEV: { model: stockEventModel, idField: '_id', type: 'stockEvent', referenceField: '_reference' },
  SAU: { model: stockAuditModel, idField: '_id', type: 'stockAudit', referenceField: '_reference' },
  PTS: { model: partStockModel, idField: '_id', type: 'partStock', referenceField: '_reference' },
  PDS: { model: null, idField: '_id', type: 'productStock', referenceField: '_reference' }, // No productStockModel found
  ADL: { model: auditLogModel, idField: '_id', type: 'auditLog', referenceField: '_reference' },
  USR: { model: userModel, idField: '_id', type: 'user', referenceField: '_reference' },
  NTY: { model: noteTypeModel, idField: '_id', type: 'noteType', referenceField: '_reference' },
  NTE: { model: noteModel, idField: '_id', type: 'note', referenceField: '_reference' },
  DSZ: {
    model: documentSizeModel,
    idField: '_id',
    type: 'documentSize',
    referenceField: '_reference',
  },
  DTP: {
    model: documentTemplateModel,
    idField: '_id',
    type: 'documentTemplate',
    referenceField: '_reference',
  },
  DPR: {
    model: documentPrinterModel,
    idField: '_id',
    type: 'documentPrinter',
    referenceField: '_reference',
  },
  DJB: {
    model: documentJobModel,
    idField: '_id',
    type: 'documentJob',
    referenceField: '_reference',
  },
  HST: { model: hostModel, idField: '_id', type: 'host', referenceField: '_reference' },
  FLE: { model: fileModel, idField: '_id', type: 'file', referenceField: '_reference' },
  POR: {
    model: purchaseOrderModel,
    idField: '_id',
    type: 'purchaseOrder',
    referenceField: '_reference',
  },
  ODI: {
    model: orderItemModel,
    idField: '_id',
    type: 'orderItem',
    referenceField: '_reference',
  },
  COS: {
    model: courierServiceModel,
    idField: '_id',
    type: 'courierService',
    referenceField: '_reference',
  },
  COR: { model: courierModel, idField: '_id', type: 'courier', referenceField: '_reference' },
  TXR: { model: taxRateModel, idField: '_id', type: 'taxRate', referenceField: '_reference' },
  TXD: { model: taxRecordModel, idField: '_id', type: 'taxRecord', referenceField: '_reference' },
};
