





















const db = require('../models');
const Users = db.users;






const Plants = db.plants;

const WorkCenters = db.work_centers;

const Machines = db.machines;

const MaintenanceWorkOrders = db.maintenance_work_orders;

const DowntimeEvents = db.downtime_events;

const Uoms = db.uoms;

const ItemCategories = db.item_categories;

const Items = db.items;

const Warehouses = db.warehouses;

const Locations = db.locations;

const InventoryLots = db.inventory_lots;

const InventoryBalances = db.inventory_balances;

const InventoryTransactions = db.inventory_transactions;

const Suppliers = db.suppliers;

const Customers = db.customers;

const PurchaseOrders = db.purchase_orders;

const PurchaseOrderLines = db.purchase_order_lines;

const Receipts = db.receipts;

const ReceiptLines = db.receipt_lines;

const Boms = db.boms;

const BomLines = db.bom_lines;

const Routings = db.routings;

const RoutingOperations = db.routing_operations;

const ProductionOrders = db.production_orders;

const ProductionOperations = db.production_operations;

const ProductionMaterials = db.production_materials;

const ProductionOutputs = db.production_outputs;

const QaPlans = db.qa_plans;

const QaCharacteristics = db.qa_characteristics;

const QaInspections = db.qa_inspections;

const QaResults = db.qa_results;

const Nonconformances = db.nonconformances;

const Documents = db.documents;

const AuditLogs = db.audit_logs;

const GlAccounts = db.gl_accounts;

const JournalEntries = db.journal_entries;

const JournalLines = db.journal_lines;

const CostCenters = db.cost_centers;

const ItemCosts = db.item_costs;







const PlantsData = [
    
    {
    
        
        
            
                "name": "Fremont Plant",
            
        
    
        
        
            
                "code": "FRM",
            
        
    
        
        
            
                "address": "4750 Industrial Way, Fremont, CA",
            
        
    
        
        
            
                "timezone": "America/Los_Angeles",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Reno Plant",
            
        
    
        
        
            
                "code": "RNO",
            
        
    
        
        
            
                "address": "1200 Silver State Blvd, Reno, NV",
            
        
    
        
        
            
                "timezone": "America/Los_Angeles",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Austin Plant",
            
        
    
        
        
            
                "code": "AUS",
            
        
    
        
        
            
                "address": "8800 Tech Ridge Pkwy, Austin, TX",
            
        
    
        
        
            
                "timezone": "America/Chicago",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Columbus Plant",
            
        
    
        
        
            
                "code": "CMH",
            
        
    
        
        
            
                "address": "3100 Logistics Dr, Columbus, OH",
            
        
    
        
        
            
                "timezone": "America/New_York",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
    },
    
];



const WorkCentersData = [
    
    {
    
        
        
            
                "name": "Machining Cell A",
            
        
    
        
        
            
                "code": "MC-A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "warehouse",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Assembly Line 1",
            
        
    
        
        
            
                "code": "AL-1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "machining",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Packaging Line 2",
            
        
    
        
        
            
                "code": "PK-2",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "assembly",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Quality Lab",
            
        
    
        
        
            
                "code": "QA-LAB",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "machining",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
];



const MachinesData = [
    
    {
    
        
        
            
                "name": "CNC Mill 01",
            
        
    
        
        
            
                "asset_tag": "CNC-01",
            
        
    
        
        
            
                "serial_number": "FMC-9A21-001",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "running",
            
        
    
        
        
            
                "commissioned_at": new Date('2022-04-15T00:00:00Z'),
            
        
    
        
        
            
                "last_service_at": new Date('2026-01-20T00:00:00Z'),
            
        
    
        
        
            
                "manufacturer": "Fabrikam",
            
        
    
        
        
            
                "model": "MX-500",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "CNC Lathe 02",
            
        
    
        
        
            
                "asset_tag": "LAT-02",
            
        
    
        
        
            
                "serial_number": "FMC-9A21-002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "available",
            
        
    
        
        
            
                "commissioned_at": new Date('2021-09-10T00:00:00Z'),
            
        
    
        
        
            
                "last_service_at": new Date('2026-01-05T00:00:00Z'),
            
        
    
        
        
            
                "manufacturer": "Fabrikam",
            
        
    
        
        
            
                "model": "LT-300",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Torque Station A1",
            
        
    
        
        
            
                "asset_tag": "ASM-A1",
            
        
    
        
        
            
                "serial_number": "NWD-TS-A1-77",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "down",
            
        
    
        
        
            
                "commissioned_at": new Date('2023-02-01T00:00:00Z'),
            
        
    
        
        
            
                "last_service_at": new Date('2025-12-12T00:00:00Z'),
            
        
    
        
        
            
                "manufacturer": "Northwind Tools",
            
        
    
        
        
            
                "model": "TorquePro 2",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Label Printer PK2",
            
        
    
        
        
            
                "asset_tag": "PK2-LP",
            
        
    
        
        
            
                "serial_number": "ZTP-PL-4421",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "maintenance",
            
        
    
        
        
            
                "commissioned_at": new Date('2020-06-05T00:00:00Z'),
            
        
    
        
        
            
                "last_service_at": new Date('2026-02-02T00:00:00Z'),
            
        
    
        
        
            
                "manufacturer": "ZetaPrint",
            
        
    
        
        
            
                "model": "LP-900",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const MaintenanceWorkOrdersData = [
    
    {
    
        
        
            
                "work_order_number": "MWO-2026-00021",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "priority": "critical",
            
        
    
        
        
            
                "status": "requested",
            
        
    
        
        
            
                "requested_at": new Date('2026-02-07T15:00:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-10T16:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-10T20:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-10T20:30:00Z'),
            
        
    
        
        
            
                "issue_description": "Intermittent paper feed jam during label runs.",
            
        
    
        
        
            
                "work_performed": "Cleaned feed rollers, replaced worn pickup wheel, recalibrated sensor.",
            
        
    
        
        
            
                "labor_hours": 3.5,
            
        
    
        
        
            
                "parts_cost": 86.4,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "MWO-2026-00022",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "requested_at": new Date('2026-02-08T10:30:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-12T17:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-12T19:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-12T19:00:00Z'),
            
        
    
        
        
            
                "issue_description": "Preventive maintenance: lubrication and axis inspection.",
            
        
    
        
        
            
                "work_performed": "Planned PM.",
            
        
    
        
        
            
                "labor_hours": 2.0,
            
        
    
        
        
            
                "parts_cost": 15.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "MWO-2026-00023",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "priority": "medium",
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "requested_at": new Date('2026-02-10T09:10:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-13T16:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-13T20:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-13T20:00:00Z'),
            
        
    
        
        
            
                "issue_description": "Coolant leak observed near pump housing.",
            
        
    
        
        
            
                "work_performed": "Planned repair.",
            
        
    
        
        
            
                "labor_hours": 4.0,
            
        
    
        
        
            
                "parts_cost": 120.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "MWO-2026-00024",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "requested_at": new Date('2026-02-01T08:00:00Z'),
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-03T16:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-03T17:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-03T17:05:00Z'),
            
        
    
        
        
            
                "issue_description": "Annual torque calibration.",
            
        
    
        
        
            
                "work_performed": "Calibrated torque to spec; updated certificate file.",
            
        
    
        
        
            
                "labor_hours": 1.0,
            
        
    
        
        
            
                "parts_cost": 0.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const DowntimeEventsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "unplanned_maintenance",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "start_at": new Date('2026-02-10T15:20:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-02-10T16:05:00Z'),
            
        
    
        
        
            
                "notes": "Stopped due to frequent label misfeeds.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "planned_maintenance",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "start_at": new Date('2026-02-10T18:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-02-10T18:35:00Z'),
            
        
    
        
        
            
                "notes": "Tooling changeover for new revision.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "quality_hold",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "start_at": new Date('2026-02-09T17:10:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-02-09T18:00:00Z'),
            
        
    
        
        
            
                "notes": "Waiting on aluminum billet replenishment.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason": "planned_maintenance",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "start_at": new Date('2026-02-08T19:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-02-08T19:25:00Z'),
            
        
    
        
        
            
                "notes": "Paused for in-process torque verification.",
            
        
    
    },
    
];



const UomsData = [
    
    {
    
        
        
            
                "name": "Each",
            
        
    
        
        
            
                "symbol": "ea",
            
        
    
        
        
            
                "type": "volume",
            
        
    
        
        
            
                "base_factor": 1.0,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Kilogram",
            
        
    
        
        
            
                "symbol": "kg",
            
        
    
        
        
            
                "type": "count",
            
        
    
        
        
            
                "base_factor": 1.0,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Gram",
            
        
    
        
        
            
                "symbol": "g",
            
        
    
        
        
            
                "type": "length",
            
        
    
        
        
            
                "base_factor": 0.001,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Liter",
            
        
    
        
        
            
                "symbol": "L",
            
        
    
        
        
            
                "type": "area",
            
        
    
        
        
            
                "base_factor": 1.0,
            
        
    
    },
    
];



const ItemCategoriesData = [
    
    {
    
        
        
            
                "name": "Raw Materials",
            
        
    
        
        
            
                "code": "RM",
            
        
    
        
        
            
                "type": "service",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Work In Process",
            
        
    
        
        
            
                "code": "WIP",
            
        
    
        
        
            
                "type": "service",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Finished Goods",
            
        
    
        
        
            
                "code": "FG",
            
        
    
        
        
            
                "type": "spare_part",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Consumables",
            
        
    
        
        
            
                "code": "CON",
            
        
    
        
        
            
                "type": "raw_material",
            
        
    
    },
    
];



const ItemsData = [
    
    {
    
        
        
            
                "sku": "FG-AXL-100",
            
        
    
        
        
            
                "name": "Actuator Assembly A100",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_type": "spare_part",
            
        
    
        
        
            
                "tracking": "none",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "standard_cost": 48.75,
            
        
    
        
        
            
                "standard_price": 129.0,
            
        
    
        
        
            
                "description": "Finished actuator assembly for industrial valve control.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "sku": "WIP-AXL-HSG",
            
        
    
        
        
            
                "name": "Actuator Housing Machined",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_type": "spare_part",
            
        
    
        
        
            
                "tracking": "serial",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "standard_cost": 18.2,
            
        
    
        
        
            
                "standard_price": 0.0,
            
        
    
        
        
            
                "description": "Machined aluminum housing used in actuator assembly.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "sku": "RM-AL-6061",
            
        
    
        
        
            
                "name": "Aluminum Billet 6061",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_type": "raw_material",
            
        
    
        
        
            
                "tracking": "none",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "standard_cost": 4.1,
            
        
    
        
        
            
                "standard_price": 0.0,
            
        
    
        
        
            
                "description": "6061 aluminum billet stock for machining operations.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "sku": "RM-SEAL-EPDM",
            
        
    
        
        
            
                "name": "EPDM Seal Ring",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_type": "consumable",
            
        
    
        
        
            
                "tracking": "lot",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "standard_cost": 0.32,
            
        
    
        
        
            
                "standard_price": 0.0,
            
        
    
        
        
            
                "description": "EPDM seal ring for actuator assembly.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const WarehousesData = [
    
    {
    
        
        
            
                "name": "Fremont Raw Warehouse",
            
        
    
        
        
            
                "code": "FRM-RW",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "spares",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Fremont WIP Staging",
            
        
    
        
        
            
                "code": "FRM-WIP",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "spares",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Fremont Finished Goods",
            
        
    
        
        
            
                "code": "FRM-FG",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "wip",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Fremont Quarantine",
            
        
    
        
        
            
                "code": "FRM-QUAR",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "type": "quarantine",
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
];



const LocationsData = [
    
    {
    
        
        
            
                "name": "RW-Aisle1-Bin01",
            
        
    
        
        
            
                "code": "RW-A1-B01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "rack",
            
        
    
        
        
            
                "is_pickable": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "RW-Receiving",
            
        
    
        
        
            
                "code": "RW-REC",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "shipping",
            
        
    
        
        
            
                "is_pickable": false,
            
        
    
    },
    
    {
    
        
        
            
                "name": "WIP-Staging-01",
            
        
    
        
        
            
                "code": "WIP-STG-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "quarantine",
            
        
    
        
        
            
                "is_pickable": false,
            
        
    
    },
    
    {
    
        
        
            
                "name": "FG-Rack-01",
            
        
    
        
        
            
                "code": "FG-R01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "location_type": "staging",
            
        
    
        
        
            
                "is_pickable": true,
            
        
    
    },
    
];



const InventoryLotsData = [
    
    {
    
        
        
            
                "lot_number": "LOT-AL-6061-260201",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "manufactured_at": new Date('2026-01-15T00:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-01-15T00:00:00Z'),
            
        
    
        
        
            
                "qa_status": "released",
            
        
    
        
        
            
                "supplier_lot": "AL6061-15JAN26",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "lot_number": "LOT-SEAL-EPDM-260202",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "manufactured_at": new Date('2026-01-28T00:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2027-01-28T00:00:00Z'),
            
        
    
        
        
            
                "qa_status": "rejected",
            
        
    
        
        
            
                "supplier_lot": "EPDM-012826",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "lot_number": "LOT-HSG-260203",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "manufactured_at": new Date('2026-02-03T00:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-02-03T00:00:00Z'),
            
        
    
        
        
            
                "qa_status": "released",
            
        
    
        
        
            
                "supplier_lot": "INHOUSE-020326",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "lot_number": "LOT-AXL-260204",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "manufactured_at": new Date('2026-02-05T00:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-02-05T00:00:00Z'),
            
        
    
        
        
            
                "qa_status": "rejected",
            
        
    
        
        
            
                "supplier_lot": "INHOUSE-020526",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const InventoryBalancesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_on_hand": 850.0,
            
        
    
        
        
            
                "quantity_allocated": 120.0,
            
        
    
        
        
            
                "quantity_available": 730.0,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-02-01T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_on_hand": 4200.0,
            
        
    
        
        
            
                "quantity_allocated": 800.0,
            
        
    
        
        
            
                "quantity_available": 3400.0,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-02-01T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_on_hand": 320.0,
            
        
    
        
        
            
                "quantity_allocated": 200.0,
            
        
    
        
        
            
                "quantity_available": 120.0,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-02-06T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_on_hand": 180.0,
            
        
    
        
        
            
                "quantity_allocated": 40.0,
            
        
    
        
        
            
                "quantity_available": 140.0,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-02-06T00:00:00Z'),
            
        
    
    },
    
];



const InventoryTransactionsData = [
    
    {
    
        
        
            
                "transaction_number": "ITX-2026-01001",
            
        
    
        
        
            
                "transaction_type": "production_consumption",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 500.0,
            
        
    
        
        
            
                "unit_cost": 4.05,
            
        
    
        
        
            
                "transaction_at": new Date('2026-02-01T16:20:00Z'),
            
        
    
        
        
            
                "reference": "RCPT-2026-00031",
            
        
    
        
        
            
                "notes": "Receipt posted to raw stock.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transaction_number": "ITX-2026-01002",
            
        
    
        
        
            
                "transaction_type": "production_output",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 120.0,
            
        
    
        
        
            
                "unit_cost": 4.1,
            
        
    
        
        
            
                "transaction_at": new Date('2026-02-03T18:05:00Z'),
            
        
    
        
        
            
                "reference": "MO-100243",
            
        
    
        
        
            
                "notes": "Issued to machining staging.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transaction_number": "ITX-2026-01003",
            
        
    
        
        
            
                "transaction_type": "transfer",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 200.0,
            
        
    
        
        
            
                "unit_cost": 18.2,
            
        
    
        
        
            
                "transaction_at": new Date('2026-02-03T20:10:00Z'),
            
        
    
        
        
            
                "reference": "MO-100243",
            
        
    
        
        
            
                "notes": "Machining output reported.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transaction_number": "ITX-2026-01004",
            
        
    
        
        
            
                "transaction_type": "production_output",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 400.0,
            
        
    
        
        
            
                "unit_cost": 0.32,
            
        
    
        
        
            
                "transaction_at": new Date('2026-02-05T19:15:00Z'),
            
        
    
        
        
            
                "reference": "MO-100245",
            
        
    
        
        
            
                "notes": "Backflush consumption at assembly.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SuppliersData = [
    
    {
    
        
        
            
                "name": "BlueRock Metals",
            
        
    
        
        
            
                "supplier_code": "SUP-BRM",
            
        
    
        
        
            
                "email": "orders@bluerockmetals.com",
            
        
    
        
        
            
                "phone": "+1 408 555 0100",
            
        
    
        
        
            
                "address": "900 Foundry Ave, San Jose, CA",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "tax_number": "BRM-CA-77821",
            
        
    
    },
    
    {
    
        
        
            
                "name": "SealWorks Inc",
            
        
    
        
        
            
                "supplier_code": "SUP-SWI",
            
        
    
        
        
            
                "email": "sales@sealworks.com",
            
        
    
        
        
            
                "phone": "+1 702 555 0123",
            
        
    
        
        
            
                "address": "44 Industrial Park Rd, Sparks, NV",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "tax_number": "SWI-NV-11402",
            
        
    
    },
    
    {
    
        
        
            
                "name": "ZetaPrint Supplies",
            
        
    
        
        
            
                "supplier_code": "SUP-ZPS",
            
        
    
        
        
            
                "email": "support@zetaprintsupplies.com",
            
        
    
        
        
            
                "phone": "+1 650 555 0155",
            
        
    
        
        
            
                "address": "2100 Bay Blvd, San Mateo, CA",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "tax_number": "ZPS-CA-90812",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Contoso Calibration",
            
        
    
        
        
            
                "supplier_code": "SUP-CCAL",
            
        
    
        
        
            
                "email": "service@contosocal.com",
            
        
    
        
        
            
                "phone": "+1 925 555 0168",
            
        
    
        
        
            
                "address": "17 Metrology Ln, Pleasanton, CA",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "tax_number": "CCAL-CA-33109",
            
        
    
    },
    
];



const CustomersData = [
    
    {
    
        
        
            
                "name": "Cascade Controls",
            
        
    
        
        
            
                "customer_code": "CUST-CC",
            
        
    
        
        
            
                "email": "ap@cascadecontrols.com",
            
        
    
        
        
            
                "phone": "+1 206 555 0140",
            
        
    
        
        
            
                "address": "120 Lake Union Dr, Seattle, WA",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "tax_number": "CC-WA-12009",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Apex Process Systems",
            
        
    
        
        
            
                "customer_code": "CUST-APS",
            
        
    
        
        
            
                "email": "purchasing@apexprocess.com",
            
        
    
        
        
            
                "phone": "+1 303 555 0199",
            
        
    
        
        
            
                "address": "78 Front Range Pkwy, Denver, CO",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "tax_number": "APS-CO-88210",
            
        
    
    },
    
    {
    
        
        
            
                "name": "MetroValve Services",
            
        
    
        
        
            
                "customer_code": "CUST-MVS",
            
        
    
        
        
            
                "email": "orders@metrovalve.com",
            
        
    
        
        
            
                "phone": "+1 312 555 0120",
            
        
    
        
        
            
                "address": "500 Wacker Dr, Chicago, IL",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "tax_number": "MVS-IL-44102",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Orchard Waterworks",
            
        
    
        
        
            
                "customer_code": "CUST-OWW",
            
        
    
        
        
            
                "email": "finance@orchardwaterworks.com",
            
        
    
        
        
            
                "phone": "+1 916 555 0133",
            
        
    
        
        
            
                "address": "19 Riverbend Rd, Sacramento, CA",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "tax_number": "OWW-CA-30991",
            
        
    
    },
    
];



const PurchaseOrdersData = [
    
    {
    
        
        
            
                "po_number": "PO-2026-00311",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "partially_received",
            
        
    
        
        
            
                "order_date": new Date('2026-01-29T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-02-02T00:00:00Z'),
            
        
    
        
        
            
                "total_amount": 5200.0,
            
        
    
        
        
            
                "currency": "USD",
            
        
    
        
        
            
                "notes": "Aluminum billet replenishment for machining cell.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-00312",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "order_date": new Date('2026-02-01T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-02-06T00:00:00Z'),
            
        
    
        
        
            
                "total_amount": 1680.0,
            
        
    
        
        
            
                "currency": "USD",
            
        
    
        
        
            
                "notes": "EPDM seals for February builds.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-00313",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "order_date": new Date('2026-02-04T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-02-10T00:00:00Z'),
            
        
    
        
        
            
                "total_amount": 125.0,
            
        
    
        
        
            
                "currency": "USD",
            
        
    
        
        
            
                "notes": "Spare pickup rollers for label printer.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-00314",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "order_date": new Date('2026-01-20T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-02-03T00:00:00Z'),
            
        
    
        
        
            
                "total_amount": 0.0,
            
        
    
        
        
            
                "currency": "USD",
            
        
    
        
        
            
                "notes": "Calibration service for torque station.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const PurchaseOrderLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 1000.0,
            
        
    
        
        
            
                "unit_price": 4.2,
            
        
    
        
        
            
                "need_by_at": new Date('2026-02-03T00:00:00Z'),
            
        
    
        
        
            
                "description": "6061 billet, mill cert required.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 6000.0,
            
        
    
        
        
            
                "unit_price": 0.28,
            
        
    
        
        
            
                "need_by_at": new Date('2026-02-06T00:00:00Z'),
            
        
    
        
        
            
                "description": "EPDM seals, 70A durometer.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 10.0,
            
        
    
        
        
            
                "unit_price": 12.5,
            
        
    
        
        
            
                "need_by_at": new Date('2026-02-10T00:00:00Z'),
            
        
    
        
        
            
                "description": "Pickup roller compatible with LP-900.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 0.0,
            
        
    
        
        
            
                "unit_price": 0.0,
            
        
    
        
        
            
                "need_by_at": new Date('2026-02-03T00:00:00Z'),
            
        
    
        
        
            
                "description": "Service line item reference only.",
            
        
    
    },
    
];



const ReceiptsData = [
    
    {
    
        
        
            
                "receipt_number": "RCPT-2026-00031",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "received_at": new Date('2026-02-01T16:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "carrier_reference": "BRM-DEL-88219",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "receipt_number": "RCPT-2026-00032",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "received_at": new Date('2026-02-06T15:40:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "carrier_reference": "SWI-DEL-19002",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "receipt_number": "RCPT-2026-00033",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "posted",
            
        
    
        
        
            
                "received_at": new Date('2026-02-10T14:25:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "carrier_reference": "ZPS-DEL-55310",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "receipt_number": "RCPT-2026-00034",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "received_at": new Date('2026-02-02T10:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "carrier_reference": "BRM-DEL-88220",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const ReceiptLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_received": 500.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-AL-6061-260201",
            
        
    
        
        
            
                "inspection_required": "no",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_received": 6000.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-SEAL-EPDM-260202",
            
        
    
        
        
            
                "inspection_required": "yes",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_received": 10.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-ROLLER-260205",
            
        
    
        
        
            
                "inspection_required": "yes",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_received": 200.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-AL-6061-260201",
            
        
    
        
        
            
                "inspection_required": "no",
            
        
    
    },
    
];



const BomsData = [
    
    {
    
        
        
            
                "bom_code": "BOM-A100-R1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "obsolete",
            
        
    
        
        
            
                "effective_from": new Date('2025-11-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-12-31T00:00:00Z'),
            
        
    
        
        
            
                "revision": "R1",
            
        
    
        
        
            
                "notes": "Baseline BOM for A100 actuator.",
            
        
    
    },
    
    {
    
        
        
            
                "bom_code": "BOM-A100-R2",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "effective_from": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2028-12-31T00:00:00Z'),
            
        
    
        
        
            
                "revision": "R2",
            
        
    
        
        
            
                "notes": "Planned revision with updated seal spec.",
            
        
    
    },
    
    {
    
        
        
            
                "bom_code": "BOM-HSG-R1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "effective_from": new Date('2025-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2028-01-01T00:00:00Z'),
            
        
    
        
        
            
                "revision": "R1",
            
        
    
        
        
            
                "notes": "Machined housing internal BOM.",
            
        
    
    },
    
    {
    
        
        
            
                "bom_code": "BOM-SP-PRNTR",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "obsolete",
            
        
    
        
        
            
                "effective_from": new Date('2020-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2024-01-01T00:00:00Z'),
            
        
    
        
        
            
                "revision": "R0",
            
        
    
        
        
            
                "notes": "Reference only; purchased item.",
            
        
    
    },
    
];



const BomLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 1.0,
            
        
    
        
        
            
                "scrap_factor": 0.01,
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "notes": "Housing subassembly input.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 2.0,
            
        
    
        
        
            
                "scrap_factor": 0.02,
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "notes": "Seal rings consumed at assembly.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 2.0,
            
        
    
        
        
            
                "scrap_factor": 0.02,
            
        
    
        
        
            
                "issue_method": "manual",
            
        
    
        
        
            
                "notes": "Same quantity, updated supplier spec planned.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_per": 1.8,
            
        
    
        
        
            
                "scrap_factor": 0.08,
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "notes": "Billet consumption per housing.",
            
        
    
    },
    
];



const RoutingsData = [
    
    {
    
        
        
            
                "routing_code": "RT-A100-R1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "revision": "R1",
            
        
    
        
        
            
                "effective_from": new Date('2025-11-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-12-31T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                "routing_code": "RT-HSG-R1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "obsolete",
            
        
    
        
        
            
                "revision": "R1",
            
        
    
        
        
            
                "effective_from": new Date('2025-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2028-01-01T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                "routing_code": "RT-A100-R2",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "revision": "R2",
            
        
    
        
        
            
                "effective_from": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2028-12-31T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                "routing_code": "RT-A100-PACK",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "revision": "PK1",
            
        
    
        
        
            
                "effective_from": new Date('2025-11-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2027-12-31T00:00:00Z'),
            
        
    
    },
    
];



const RoutingOperationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 10,
            
        
    
        
        
            
                "operation_name": "CNC Rough Mill",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 30.0,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 12.0,
            
        
    
        
        
            
                "queue_time_minutes": 15.0,
            
        
    
        
        
            
                "move_time_minutes": 5.0,
            
        
    
        
        
            
                "instructions": "Load billet, run roughing program MX500-RGH.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 20,
            
        
    
        
        
            
                "operation_name": "CNC Finish Mill",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 15.0,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 10.0,
            
        
    
        
        
            
                "queue_time_minutes": 10.0,
            
        
    
        
        
            
                "move_time_minutes": 5.0,
            
        
    
        
        
            
                "instructions": "Run finish pass program MX500-FIN; deburr edges.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 10,
            
        
    
        
        
            
                "operation_name": "Assembly Build",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 10.0,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 8.0,
            
        
    
        
        
            
                "queue_time_minutes": 20.0,
            
        
    
        
        
            
                "move_time_minutes": 5.0,
            
        
    
        
        
            
                "instructions": "Assemble housing and seals per WI-A100-ASM-01.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 10,
            
        
    
        
        
            
                "operation_name": "Final Inspection",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "setup_time_minutes": 5.0,
            
        
    
        
        
            
                "run_time_minutes_per_unit": 6.0,
            
        
    
        
        
            
                "queue_time_minutes": 15.0,
            
        
    
        
        
            
                "move_time_minutes": 5.0,
            
        
    
        
        
            
                "instructions": "Inspect dimensions and functional checks per QA plan.",
            
        
    
    },
    
];



const ProductionOrdersData = [
    
    {
    
        
        
            
                "order_number": "MO-100243",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "priority": "high",
            
        
    
        
        
            
                "quantity_planned": 200.0,
            
        
    
        
        
            
                "quantity_completed": 200.0,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-02-03T16:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-02-03T23:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-03T16:10:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-03T22:40:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_order_ref": "CC-PO-77102",
            
        
    
        
        
            
                "notes": "Build WIP housings for assembly orders.",
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "MO-100244",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                "quantity_planned": 150.0,
            
        
    
        
        
            
                "quantity_completed": 60.0,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-02-10T16:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-02-11T23:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-10T16:05:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-11T23:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_order_ref": "APS-PO-55019",
            
        
    
        
        
            
                "notes": "Expedite housings due to customer demand.",
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "MO-100245",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "priority": "low",
            
        
    
        
        
            
                "quantity_planned": 120.0,
            
        
    
        
        
            
                "quantity_completed": 80.0,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-02-05T17:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-02-06T23:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-05T17:20:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-06T22:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_order_ref": "MVS-PO-33007",
            
        
    
        
        
            
                "notes": "Assembly with in-process QA checks.",
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "MO-100246",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "priority": "urgent",
            
        
    
        
        
            
                "quantity_planned": 100.0,
            
        
    
        
        
            
                "quantity_completed": 0.0,
            
        
    
        
        
            
                "planned_start_at": new Date('2026-02-12T17:00:00Z'),
            
        
    
        
        
            
                "planned_end_at": new Date('2026-02-13T22:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-12T17:00:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-13T22:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_order_ref": "OWW-PO-88910",
            
        
    
        
        
            
                "notes": "Plan pack and label after QA release.",
            
        
    
    },
    
];



const ProductionOperationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 10,
            
        
    
        
        
            
                "operation_name": "CNC Rough Mill",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "running",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-03T16:10:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-03T19:30:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-03T16:15:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-03T19:20:00Z'),
            
        
    
        
        
            
                "good_quantity": 200.0,
            
        
    
        
        
            
                "scrap_quantity": 5.0,
            
        
    
        
        
            
                "operator_notes": "Tool wear monitored; replaced insert mid-run.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 20,
            
        
    
        
        
            
                "operation_name": "CNC Finish Mill",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-03T19:40:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-03T22:40:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-03T19:45:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-03T22:35:00Z'),
            
        
    
        
        
            
                "good_quantity": 200.0,
            
        
    
        
        
            
                "scrap_quantity": 0.0,
            
        
    
        
        
            
                "operator_notes": "Deburr completed.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 10,
            
        
    
        
        
            
                "operation_name": "Assembly Build",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-05T17:20:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-06T20:30:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-05T17:25:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-06T20:10:00Z'),
            
        
    
        
        
            
                "good_quantity": 80.0,
            
        
    
        
        
            
                "scrap_quantity": 2.0,
            
        
    
        
        
            
                "operator_notes": "In-process torque checks performed every 20 units.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "operation_sequence": 20,
            
        
    
        
        
            
                "operation_name": "Final Inspection",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "paused",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-02-06T20:30:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-02-06T22:30:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-02-06T20:30:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-02-06T22:30:00Z'),
            
        
    
        
        
            
                "good_quantity": 0.0,
            
        
    
        
        
            
                "scrap_quantity": 0.0,
            
        
    
        
        
            
                "operator_notes": "Awaiting QA availability.",
            
        
    
    },
    
];



const ProductionMaterialsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "quantity_required": 360.0,
            
        
    
        
        
            
                "quantity_issued": 120.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issued_at": new Date('2026-02-03T18:05:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Issued partial; remaining to be issued next shift.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "backflush",
            
        
    
        
        
            
                "quantity_required": 120.0,
            
        
    
        
        
            
                "quantity_issued": 120.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issued_at": new Date('2026-02-05T17:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Staged housings for assembly.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "manual",
            
        
    
        
        
            
                "quantity_required": 240.0,
            
        
    
        
        
            
                "quantity_issued": 400.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issued_at": new Date('2026-02-05T19:15:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Backflush quantity includes over-issue buffer.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issue_method": "manual",
            
        
    
        
        
            
                "quantity_required": 270.0,
            
        
    
        
        
            
                "quantity_issued": 0.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "issued_at": new Date('2026-02-10T16:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "notes": "Pending issue due to earlier shortage.",
            
        
    
    },
    
];



const ProductionOutputsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_produced": 200.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-HSG-260203",
            
        
    
        
        
            
                "reported_at": new Date('2026-02-03T22:40:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "qa_status": "released",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_produced": 80.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-AXL-260204",
            
        
    
        
        
            
                "reported_at": new Date('2026-02-06T16:55:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "qa_status": "pending",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_produced": 60.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-HSG-260203",
            
        
    
        
        
            
                "reported_at": new Date('2026-02-10T23:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "qa_status": "on_hold",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_produced": 0.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "lot_number": "LOT-AXL-260204",
            
        
    
        
        
            
                "reported_at": new Date('2026-02-12T20:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "qa_status": "pending",
            
        
    
    },
    
];



const QaPlansData = [
    
    {
    
        
        
            
                "name": "Incoming Inspection - Aluminum 6061",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "in_process",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "instructions": "Verify mill cert, dimensions, and surface condition.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "In-Process Inspection - Housing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "incoming",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "instructions": "Check critical bore and flatness every 20 parts.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Final Inspection - Actuator A100",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "incoming",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "instructions": "Functional test, torque verification, and dimensional spot checks.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Audit - Packaging Labels",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "in_process",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "instructions": "Verify label content, lot trace, and carton integrity.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const QaCharacteristicsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Alloy Certification Present",
            
        
    
        
        
            
                "data_type": "enum",
            
        
    
        
        
            
                "target_value": 0.0,
            
        
    
        
        
            
                "lower_limit": 0.0,
            
        
    
        
        
            
                "upper_limit": 0.0,
            
        
    
        
        
            
                "unit": "",
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "method": "Review supplier certificate for heat and chemistry.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Billet Diameter",
            
        
    
        
        
            
                "data_type": "enum",
            
        
    
        
        
            
                "target_value": 50.0,
            
        
    
        
        
            
                "lower_limit": 49.8,
            
        
    
        
        
            
                "upper_limit": 50.2,
            
        
    
        
        
            
                "unit": "mm",
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "method": "Measure with caliper at three points.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Critical Bore Diameter",
            
        
    
        
        
            
                "data_type": "enum",
            
        
    
        
        
            
                "target_value": 25.0,
            
        
    
        
        
            
                "lower_limit": 24.95,
            
        
    
        
        
            
                "upper_limit": 25.05,
            
        
    
        
        
            
                "unit": "mm",
            
        
    
        
        
            
                "severity": "major",
            
        
    
        
        
            
                "method": "Measure with bore gauge; record per sample.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Functional Cycle Test",
            
        
    
        
        
            
                "data_type": "text",
            
        
    
        
        
            
                "target_value": 0.0,
            
        
    
        
        
            
                "lower_limit": 0.0,
            
        
    
        
        
            
                "upper_limit": 0.0,
            
        
    
        
        
            
                "unit": "",
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "method": "Cycle actuator 10 times; verify no binding.",
            
        
    
    },
    
];



const QaInspectionsData = [
    
    {
    
        
        
            
                "inspection_number": "INSP-2026-00410",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "final",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "scheduled_at": new Date('2026-02-01T16:30:00Z'),
            
        
    
        
        
            
                "started_at": new Date('2026-02-01T16:40:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-01T17:05:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Mill cert verified and dimensions within tolerance.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "INSP-2026-00411",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "audit",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "scheduled_at": new Date('2026-02-06T16:00:00Z'),
            
        
    
        
        
            
                "started_at": new Date('2026-02-06T16:05:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-06T16:25:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Visual and durometer check acceptable.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "INSP-2026-00412",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "in_process",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "failed",
            
        
    
        
        
            
                "scheduled_at": new Date('2026-02-10T18:30:00Z'),
            
        
    
        
        
            
                "started_at": new Date('2026-02-10T18:35:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-10T19:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Sampling in progress for bore measurements.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "inspection_number": "INSP-2026-00413",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "inspection_type": "incoming",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "passed",
            
        
    
        
        
            
                "scheduled_at": new Date('2026-02-06T20:30:00Z'),
            
        
    
        
        
            
                "started_at": new Date('2026-02-06T20:45:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-06T22:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "summary": "Hold pending review of torque trend.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const QaResultsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "numeric_value": 0.0,
            
        
    
        
        
            
                "text_value": "Certificate verified for heat AL6061-15JAN26",
            
        
    
        
        
            
                "boolean_value": true,
            
        
    
        
        
            
                "decision": "pass",
            
        
    
        
        
            
                "notes": "Cert matches PO requirements.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "numeric_value": 50.05,
            
        
    
        
        
            
                "text_value": "Measured 50.05 mm average",
            
        
    
        
        
            
                "boolean_value": false,
            
        
    
        
        
            
                "decision": "na",
            
        
    
        
        
            
                "notes": "Within limits.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "numeric_value": 25.06,
            
        
    
        
        
            
                "text_value": "One sample at upper edge",
            
        
    
        
        
            
                "boolean_value": true,
            
        
    
        
        
            
                "decision": "fail",
            
        
    
        
        
            
                "notes": "One reading slightly above upper limit; recheck required.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "numeric_value": 0.0,
            
        
    
        
        
            
                "text_value": "No defects observed in sample",
            
        
    
        
        
            
                "boolean_value": false,
            
        
    
        
        
            
                "decision": "fail",
            
        
    
        
        
            
                "notes": "Acceptable.",
            
        
    
    },
    
];



const NonconformancesData = [
    
    {
    
        
        
            
                "ncr_number": "NCR-2026-00107",
            
        
    
        
        
            
                "source": "customer",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "status": "under_investigation",
            
        
    
        
        
            
                "detected_at": new Date('2026-02-10T19:05:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Bore diameter trending high; one sample out of tolerance.",
            
        
    
        
        
            
                "containment_action": "Hold WIP lot in staging; stop machine for tool inspection.",
            
        
    
        
        
            
                "root_cause": "Investigation in progress.",
            
        
    
        
        
            
                "corrective_action": "Adjust tool offsets and replace worn insert.",
            
        
    
        
        
            
                "due_at": new Date('2026-02-12T23:59:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "NCR-2026-00108",
            
        
    
        
        
            
                "source": "incoming",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "status": "corrective_action",
            
        
    
        
        
            
                "detected_at": new Date('2026-02-06T22:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Torque variation noted above typical range on station A1.",
            
        
    
        
        
            
                "containment_action": "Place lot on QA hold pending review.",
            
        
    
        
        
            
                "root_cause": "Operator technique variability suspected.",
            
        
    
        
        
            
                "corrective_action": "Retrain operators and verify torque station calibration.",
            
        
    
        
        
            
                "due_at": new Date('2026-02-11T23:59:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "NCR-2026-00109",
            
        
    
        
        
            
                "source": "incoming",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "status": "verified",
            
        
    
        
        
            
                "detected_at": new Date('2026-02-06T16:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Packaging scuffs on outer bags; seals unaffected.",
            
        
    
        
        
            
                "containment_action": "Accepted with note; notify supplier.",
            
        
    
        
        
            
                "root_cause": "Handling during transit.",
            
        
    
        
        
            
                "corrective_action": "Supplier to improve packaging protection.",
            
        
    
        
        
            
                "due_at": new Date('2026-02-20T23:59:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "ncr_number": "NCR-2026-00110",
            
        
    
        
        
            
                "source": "internal_audit",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "detected_at": new Date('2026-02-12T19:40:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Label template missing revision field on first draft printout.",
            
        
    
        
        
            
                "containment_action": "Stop labeling and quarantine printed labels.",
            
        
    
        
        
            
                "root_cause": "Template version not updated after revision change.",
            
        
    
        
        
            
                "corrective_action": "Update label template and reprint.",
            
        
    
        
        
            
                "due_at": new Date('2026-02-13T23:59:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const DocumentsData = [
    
    {
    
        
        
            
                "document_number": "DOC-WI-A100-ASM-01",
            
        
    
        
        
            
                "title": "Work Instruction A100 Assembly",
            
        
    
        
        
            
                "document_type": "work_instruction",
            
        
    
        
        
            
                "status": "in_review",
            
        
    
        
        
            
                "revision": "R3",
            
        
    
        
        
            
                "effective_at": new Date('2025-12-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-12-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "summary": "Assembly steps and torque requirements for A100 actuator.",
            
        
    
    },
    
    {
    
        
        
            
                "document_number": "DOC-QA-PLAN-A100",
            
        
    
        
        
            
                "title": "QA Plan A100 Final",
            
        
    
        
        
            
                "document_type": "specification",
            
        
    
        
        
            
                "status": "in_review",
            
        
    
        
        
            
                "revision": "R2",
            
        
    
        
        
            
                "effective_at": new Date('2025-11-15T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-11-15T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "summary": "Final inspection and functional testing criteria for A100.",
            
        
    
    },
    
    {
    
        
        
            
                "document_number": "DOC-SOP-REC-01",
            
        
    
        
        
            
                "title": "Receiving and Putaway SOP",
            
        
    
        
        
            
                "document_type": "policy",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "revision": "R1",
            
        
    
        
        
            
                "effective_at": new Date('2025-08-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-08-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "summary": "Standard process for receiving, inspection routing, and putaway.",
            
        
    
    },
    
    {
    
        
        
            
                "document_number": "DOC-PROC-NCR-01",
            
        
    
        
        
            
                "title": "Nonconformance Handling Procedure",
            
        
    
        
        
            
                "document_type": "specification",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "revision": "R4",
            
        
    
        
        
            
                "effective_at": new Date('2025-05-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-05-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "summary": "Procedure for containment, root cause, CAPA, and closure.",
            
        
    
    },
    
];



const AuditLogsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entity_name": "production_orders",
            
        
    
        
        
            
                "record_key": "MO-100245",
            
        
    
        
        
            
                "action": "post",
            
        
    
        
        
            
                "occurred_at": new Date('2026-02-05T16:50:00Z'),
            
        
    
        
        
            
                "ip_address": "10.10.0.12",
            
        
    
        
        
            
                "user_agent": "Chrome on Windows",
            
        
    
        
        
            
                "details": "Order released and priority set to urgent.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entity_name": "receipts",
            
        
    
        
        
            
                "record_key": "RCPT-2026-00031",
            
        
    
        
        
            
                "action": "update",
            
        
    
        
        
            
                "occurred_at": new Date('2026-02-01T16:12:00Z'),
            
        
    
        
        
            
                "ip_address": "10.10.2.21",
            
        
    
        
        
            
                "user_agent": "Chrome on Windows",
            
        
    
        
        
            
                "details": "Receipt posted to inventory.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entity_name": "qa_inspections",
            
        
    
        
        
            
                "record_key": "INSP-2026-00413",
            
        
    
        
        
            
                "action": "export",
            
        
    
        
        
            
                "occurred_at": new Date('2026-02-06T22:25:00Z'),
            
        
    
        
        
            
                "ip_address": "10.10.1.45",
            
        
    
        
        
            
                "user_agent": "Edge on Windows",
            
        
    
        
        
            
                "details": "Inspection set to on_hold due to torque review.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entity_name": "maintenance_work_orders",
            
        
    
        
        
            
                "record_key": "MWO-2026-00021",
            
        
    
        
        
            
                "action": "update",
            
        
    
        
        
            
                "occurred_at": new Date('2026-02-10T18:10:00Z'),
            
        
    
        
        
            
                "ip_address": "10.10.3.10",
            
        
    
        
        
            
                "user_agent": "Chrome on Android",
            
        
    
        
        
            
                "details": "WO updated with parts replacement details.",
            
        
    
    },
    
];



const GlAccountsData = [
    
    {
    
        
        
            
                "account_code": "1100",
            
        
    
        
        
            
                "name": "Raw Materials Inventory",
            
        
    
        
        
            
                "account_type": "cogs",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "description": "Inventory value for raw materials.",
            
        
    
    },
    
    {
    
        
        
            
                "account_code": "1200",
            
        
    
        
        
            
                "name": "Work In Process Inventory",
            
        
    
        
        
            
                "account_type": "revenue",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "description": "Inventory value for WIP.",
            
        
    
    },
    
    {
    
        
        
            
                "account_code": "1300",
            
        
    
        
        
            
                "name": "Finished Goods Inventory",
            
        
    
        
        
            
                "account_type": "revenue",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "description": "Inventory value for finished goods.",
            
        
    
    },
    
    {
    
        
        
            
                "account_code": "5100",
            
        
    
        
        
            
                "name": "Cost of Goods Sold",
            
        
    
        
        
            
                "account_type": "expense",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "description": "COGS for shipped products.",
            
        
    
    },
    
];



const JournalEntriesData = [
    
    {
    
        
        
            
                "journal_number": "JE-2026-00152",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_date": new Date('2026-02-01T00:00:00Z'),
            
        
    
        
        
            
                "status": "reversed",
            
        
    
        
        
            
                "memo": "Receipt of aluminum billet PO-2026-00311",
            
        
    
        
        
            
                "total_debit": 2025.0,
            
        
    
        
        
            
                "total_credit": 2025.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "posted_at": new Date('2026-02-01T18:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                "journal_number": "JE-2026-00153",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_date": new Date('2026-02-03T00:00:00Z'),
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "memo": "Issue aluminum to WIP for MO-100243",
            
        
    
        
        
            
                "total_debit": 492.0,
            
        
    
        
        
            
                "total_credit": 492.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "posted_at": new Date('2026-02-03T23:30:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                "journal_number": "JE-2026-00154",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_date": new Date('2026-02-06T00:00:00Z'),
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "memo": "Move completed assemblies to FG pending QA release",
            
        
    
        
        
            
                "total_debit": 3900.0,
            
        
    
        
        
            
                "total_credit": 3900.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "posted_at": new Date('2026-02-06T23:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                "journal_number": "JE-2026-00155",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "entry_date": new Date('2026-02-10T00:00:00Z'),
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "memo": "Maintenance parts for label printer repair",
            
        
    
        
        
            
                "total_debit": 86.4,
            
        
    
        
        
            
                "total_credit": 86.4,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "posted_at": new Date('2026-02-10T21:00:00Z'),
            
        
    
    },
    
];



const JournalLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "debit_amount": 2025.0,
            
        
    
        
        
            
                "credit_amount": 0.0,
            
        
    
        
        
            
                "description": "Increase raw materials for aluminum receipt",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "debit_amount": 0.0,
            
        
    
        
        
            
                "credit_amount": 2025.0,
            
        
    
        
        
            
                "description": "Offset entry for receipt clearing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "debit_amount": 492.0,
            
        
    
        
        
            
                "credit_amount": 0.0,
            
        
    
        
        
            
                "description": "Issue aluminum to WIP",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "debit_amount": 0.0,
            
        
    
        
        
            
                "credit_amount": 492.0,
            
        
    
        
        
            
                "description": "Reduce raw materials for issue",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const CostCentersData = [
    
    {
    
        
        
            
                "name": "Machining",
            
        
    
        
        
            
                "code": "CC-MACH",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Assembly",
            
        
    
        
        
            
                "code": "CC-ASM",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Packaging",
            
        
    
        
        
            
                "code": "CC-PACK",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "inactive",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Quality",
            
        
    
        
        
            
                "code": "CC-QA",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "inactive",
            
        
    
    },
    
];



const ItemCostsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "material_cost": 22.4,
            
        
    
        
        
            
                "labor_cost": 9.8,
            
        
    
        
        
            
                "overhead_cost": 16.55,
            
        
    
        
        
            
                "standard_cost": 48.75,
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-12-31T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "material_cost": 7.6,
            
        
    
        
        
            
                "labor_cost": 5.2,
            
        
    
        
        
            
                "overhead_cost": 5.4,
            
        
    
        
        
            
                "standard_cost": 18.2,
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-12-31T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "material_cost": 4.1,
            
        
    
        
        
            
                "labor_cost": 0.0,
            
        
    
        
        
            
                "overhead_cost": 0.0,
            
        
    
        
        
            
                "standard_cost": 4.1,
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-12-31T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "material_cost": 0.32,
            
        
    
        
        
            
                "labor_cost": 0.0,
            
        
    
        
        
            
                "overhead_cost": 0.0,
            
        
    
        
        
            
                "standard_cost": 0.32,
            
        
    
        
        
            
                "effective_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-12-31T00:00:00Z'),
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateWorkCenterWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter0 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkCenter0?.setPlant)
                {
                    await
                    WorkCenter0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter1 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkCenter1?.setPlant)
                {
                    await
                    WorkCenter1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter2 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkCenter2?.setPlant)
                {
                    await
                    WorkCenter2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const WorkCenter3 = await WorkCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkCenter3?.setPlant)
                {
                    await
                    WorkCenter3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateMachineWithWork_center() {
            
                const relatedWork_center0 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine0 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Machine0?.setWork_center)
                {
                    await
                    Machine0.
                    setWork_center(relatedWork_center0);
                }
            
                const relatedWork_center1 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine1 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Machine1?.setWork_center)
                {
                    await
                    Machine1.
                    setWork_center(relatedWork_center1);
                }
            
                const relatedWork_center2 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine2 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Machine2?.setWork_center)
                {
                    await
                    Machine2.
                    setWork_center(relatedWork_center2);
                }
            
                const relatedWork_center3 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const Machine3 = await Machines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Machine3?.setWork_center)
                {
                    await
                    Machine3.
                    setWork_center(relatedWork_center3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateMaintenanceWorkOrderWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder0 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaintenanceWorkOrder0?.setMachine)
                {
                    await
                    MaintenanceWorkOrder0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder1 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaintenanceWorkOrder1?.setMachine)
                {
                    await
                    MaintenanceWorkOrder1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder2 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaintenanceWorkOrder2?.setMachine)
                {
                    await
                    MaintenanceWorkOrder2.
                    setMachine(relatedMachine2);
                }
            
                const relatedMachine3 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const MaintenanceWorkOrder3 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (MaintenanceWorkOrder3?.setMachine)
                {
                    await
                    MaintenanceWorkOrder3.
                    setMachine(relatedMachine3);
                }
            
        }
        
    
        
            
            async function associateMaintenanceWorkOrderWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder0 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (MaintenanceWorkOrder0?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder1 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (MaintenanceWorkOrder1?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder2 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (MaintenanceWorkOrder2?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
                const relatedAssigned_to3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const MaintenanceWorkOrder3 = await MaintenanceWorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (MaintenanceWorkOrder3?.setAssigned_to)
                {
                    await
                    MaintenanceWorkOrder3.
                    setAssigned_to(relatedAssigned_to3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateDowntimeEventWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const DowntimeEvent0 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DowntimeEvent0?.setMachine)
                {
                    await
                    DowntimeEvent0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const DowntimeEvent1 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DowntimeEvent1?.setMachine)
                {
                    await
                    DowntimeEvent1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const DowntimeEvent2 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DowntimeEvent2?.setMachine)
                {
                    await
                    DowntimeEvent2.
                    setMachine(relatedMachine2);
                }
            
                const relatedMachine3 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const DowntimeEvent3 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DowntimeEvent3?.setMachine)
                {
                    await
                    DowntimeEvent3.
                    setMachine(relatedMachine3);
                }
            
        }
        
    
        
            
            async function associateDowntimeEventWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const DowntimeEvent0 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DowntimeEvent0?.setProduction_order)
                {
                    await
                    DowntimeEvent0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const DowntimeEvent1 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DowntimeEvent1?.setProduction_order)
                {
                    await
                    DowntimeEvent1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const DowntimeEvent2 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DowntimeEvent2?.setProduction_order)
                {
                    await
                    DowntimeEvent2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const DowntimeEvent3 = await DowntimeEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DowntimeEvent3?.setProduction_order)
                {
                    await
                    DowntimeEvent3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateItemWithCategory() {
            
                const relatedCategory0 = await ItemCategories.findOne({
                    offset: Math.floor(Math.random() * (await ItemCategories.count())),
                });
                const Item0 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Item0?.setCategory)
                {
                    await
                    Item0.
                    setCategory(relatedCategory0);
                }
            
                const relatedCategory1 = await ItemCategories.findOne({
                    offset: Math.floor(Math.random() * (await ItemCategories.count())),
                });
                const Item1 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Item1?.setCategory)
                {
                    await
                    Item1.
                    setCategory(relatedCategory1);
                }
            
                const relatedCategory2 = await ItemCategories.findOne({
                    offset: Math.floor(Math.random() * (await ItemCategories.count())),
                });
                const Item2 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Item2?.setCategory)
                {
                    await
                    Item2.
                    setCategory(relatedCategory2);
                }
            
                const relatedCategory3 = await ItemCategories.findOne({
                    offset: Math.floor(Math.random() * (await ItemCategories.count())),
                });
                const Item3 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Item3?.setCategory)
                {
                    await
                    Item3.
                    setCategory(relatedCategory3);
                }
            
        }
        
    
        
            
            async function associateItemWithUom() {
            
                const relatedUom0 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item0 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Item0?.setUom)
                {
                    await
                    Item0.
                    setUom(relatedUom0);
                }
            
                const relatedUom1 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item1 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Item1?.setUom)
                {
                    await
                    Item1.
                    setUom(relatedUom1);
                }
            
                const relatedUom2 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item2 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Item2?.setUom)
                {
                    await
                    Item2.
                    setUom(relatedUom2);
                }
            
                const relatedUom3 = await Uoms.findOne({
                    offset: Math.floor(Math.random() * (await Uoms.count())),
                });
                const Item3 = await Items.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Item3?.setUom)
                {
                    await
                    Item3.
                    setUom(relatedUom3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateWarehousWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous0 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Warehous0?.setPlant)
                {
                    await
                    Warehous0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous1 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Warehous1?.setPlant)
                {
                    await
                    Warehous1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous2 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Warehous2?.setPlant)
                {
                    await
                    Warehous2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const Warehous3 = await Warehouses.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Warehous3?.setPlant)
                {
                    await
                    Warehous3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateLocationWithWarehouse() {
            
                const relatedWarehouse0 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location0 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Location0?.setWarehouse)
                {
                    await
                    Location0.
                    setWarehouse(relatedWarehouse0);
                }
            
                const relatedWarehouse1 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location1 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Location1?.setWarehouse)
                {
                    await
                    Location1.
                    setWarehouse(relatedWarehouse1);
                }
            
                const relatedWarehouse2 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location2 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Location2?.setWarehouse)
                {
                    await
                    Location2.
                    setWarehouse(relatedWarehouse2);
                }
            
                const relatedWarehouse3 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Location3 = await Locations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Location3?.setWarehouse)
                {
                    await
                    Location3.
                    setWarehouse(relatedWarehouse3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateInventoryLotWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryLot0 = await InventoryLots.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryLot0?.setItem)
                {
                    await
                    InventoryLot0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryLot1 = await InventoryLots.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryLot1?.setItem)
                {
                    await
                    InventoryLot1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryLot2 = await InventoryLots.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryLot2?.setItem)
                {
                    await
                    InventoryLot2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryLot3 = await InventoryLots.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryLot3?.setItem)
                {
                    await
                    InventoryLot3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateInventoryBalanceWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryBalance0 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryBalance0?.setItem)
                {
                    await
                    InventoryBalance0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryBalance1 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryBalance1?.setItem)
                {
                    await
                    InventoryBalance1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryBalance2 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryBalance2?.setItem)
                {
                    await
                    InventoryBalance2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryBalance3 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryBalance3?.setItem)
                {
                    await
                    InventoryBalance3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateInventoryBalanceWithLocation() {
            
                const relatedLocation0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryBalance0 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryBalance0?.setLocation)
                {
                    await
                    InventoryBalance0.
                    setLocation(relatedLocation0);
                }
            
                const relatedLocation1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryBalance1 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryBalance1?.setLocation)
                {
                    await
                    InventoryBalance1.
                    setLocation(relatedLocation1);
                }
            
                const relatedLocation2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryBalance2 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryBalance2?.setLocation)
                {
                    await
                    InventoryBalance2.
                    setLocation(relatedLocation2);
                }
            
                const relatedLocation3 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryBalance3 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryBalance3?.setLocation)
                {
                    await
                    InventoryBalance3.
                    setLocation(relatedLocation3);
                }
            
        }
        
    
        
            
            async function associateInventoryBalanceWithLot() {
            
                const relatedLot0 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryBalance0 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryBalance0?.setLot)
                {
                    await
                    InventoryBalance0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryBalance1 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryBalance1?.setLot)
                {
                    await
                    InventoryBalance1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryBalance2 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryBalance2?.setLot)
                {
                    await
                    InventoryBalance2.
                    setLot(relatedLot2);
                }
            
                const relatedLot3 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryBalance3 = await InventoryBalances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryBalance3?.setLot)
                {
                    await
                    InventoryBalance3.
                    setLot(relatedLot3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateInventoryTransactionWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setItem)
                {
                    await
                    InventoryTransaction0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setItem)
                {
                    await
                    InventoryTransaction1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setItem)
                {
                    await
                    InventoryTransaction2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setItem)
                {
                    await
                    InventoryTransaction3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithFrom_location() {
            
                const relatedFrom_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setFrom_location)
                {
                    await
                    InventoryTransaction0.
                    setFrom_location(relatedFrom_location0);
                }
            
                const relatedFrom_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setFrom_location)
                {
                    await
                    InventoryTransaction1.
                    setFrom_location(relatedFrom_location1);
                }
            
                const relatedFrom_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setFrom_location)
                {
                    await
                    InventoryTransaction2.
                    setFrom_location(relatedFrom_location2);
                }
            
                const relatedFrom_location3 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setFrom_location)
                {
                    await
                    InventoryTransaction3.
                    setFrom_location(relatedFrom_location3);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithTo_location() {
            
                const relatedTo_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setTo_location)
                {
                    await
                    InventoryTransaction0.
                    setTo_location(relatedTo_location0);
                }
            
                const relatedTo_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setTo_location)
                {
                    await
                    InventoryTransaction1.
                    setTo_location(relatedTo_location1);
                }
            
                const relatedTo_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setTo_location)
                {
                    await
                    InventoryTransaction2.
                    setTo_location(relatedTo_location2);
                }
            
                const relatedTo_location3 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setTo_location)
                {
                    await
                    InventoryTransaction3.
                    setTo_location(relatedTo_location3);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithLot() {
            
                const relatedLot0 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setLot)
                {
                    await
                    InventoryTransaction0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setLot)
                {
                    await
                    InventoryTransaction1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setLot)
                {
                    await
                    InventoryTransaction2.
                    setLot(relatedLot2);
                }
            
                const relatedLot3 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setLot)
                {
                    await
                    InventoryTransaction3.
                    setLot(relatedLot3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateInventoryTransactionWithPerformed_by() {
            
                const relatedPerformed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setPerformed_by)
                {
                    await
                    InventoryTransaction0.
                    setPerformed_by(relatedPerformed_by0);
                }
            
                const relatedPerformed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setPerformed_by)
                {
                    await
                    InventoryTransaction1.
                    setPerformed_by(relatedPerformed_by1);
                }
            
                const relatedPerformed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setPerformed_by)
                {
                    await
                    InventoryTransaction2.
                    setPerformed_by(relatedPerformed_by2);
                }
            
                const relatedPerformed_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setPerformed_by)
                {
                    await
                    InventoryTransaction3.
                    setPerformed_by(relatedPerformed_by3);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associatePurchaseOrderWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setSupplier)
                {
                    await
                    PurchaseOrder0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setSupplier)
                {
                    await
                    PurchaseOrder1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setSupplier)
                {
                    await
                    PurchaseOrder2.
                    setSupplier(relatedSupplier2);
                }
            
                const relatedSupplier3 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder3 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrder3?.setSupplier)
                {
                    await
                    PurchaseOrder3.
                    setSupplier(relatedSupplier3);
                }
            
        }
        
    
        
            
            async function associatePurchaseOrderWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setPlant)
                {
                    await
                    PurchaseOrder0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setPlant)
                {
                    await
                    PurchaseOrder1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setPlant)
                {
                    await
                    PurchaseOrder2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const PurchaseOrder3 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrder3?.setPlant)
                {
                    await
                    PurchaseOrder3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associatePurchaseOrderLineWithPurchase_order() {
            
                const relatedPurchase_order0 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLine0 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderLine0?.setPurchase_order)
                {
                    await
                    PurchaseOrderLine0.
                    setPurchase_order(relatedPurchase_order0);
                }
            
                const relatedPurchase_order1 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLine1 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderLine1?.setPurchase_order)
                {
                    await
                    PurchaseOrderLine1.
                    setPurchase_order(relatedPurchase_order1);
                }
            
                const relatedPurchase_order2 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLine2 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderLine2?.setPurchase_order)
                {
                    await
                    PurchaseOrderLine2.
                    setPurchase_order(relatedPurchase_order2);
                }
            
                const relatedPurchase_order3 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLine3 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrderLine3?.setPurchase_order)
                {
                    await
                    PurchaseOrderLine3.
                    setPurchase_order(relatedPurchase_order3);
                }
            
        }
        
    
        
            
            async function associatePurchaseOrderLineWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const PurchaseOrderLine0 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderLine0?.setItem)
                {
                    await
                    PurchaseOrderLine0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const PurchaseOrderLine1 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderLine1?.setItem)
                {
                    await
                    PurchaseOrderLine1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const PurchaseOrderLine2 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderLine2?.setItem)
                {
                    await
                    PurchaseOrderLine2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const PurchaseOrderLine3 = await PurchaseOrderLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrderLine3?.setItem)
                {
                    await
                    PurchaseOrderLine3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateReceiptWithPurchase_order() {
            
                const relatedPurchase_order0 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const Receipt0 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Receipt0?.setPurchase_order)
                {
                    await
                    Receipt0.
                    setPurchase_order(relatedPurchase_order0);
                }
            
                const relatedPurchase_order1 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const Receipt1 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Receipt1?.setPurchase_order)
                {
                    await
                    Receipt1.
                    setPurchase_order(relatedPurchase_order1);
                }
            
                const relatedPurchase_order2 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const Receipt2 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Receipt2?.setPurchase_order)
                {
                    await
                    Receipt2.
                    setPurchase_order(relatedPurchase_order2);
                }
            
                const relatedPurchase_order3 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const Receipt3 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Receipt3?.setPurchase_order)
                {
                    await
                    Receipt3.
                    setPurchase_order(relatedPurchase_order3);
                }
            
        }
        
    
        
            
            async function associateReceiptWithWarehouse() {
            
                const relatedWarehouse0 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Receipt0 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Receipt0?.setWarehouse)
                {
                    await
                    Receipt0.
                    setWarehouse(relatedWarehouse0);
                }
            
                const relatedWarehouse1 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Receipt1 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Receipt1?.setWarehouse)
                {
                    await
                    Receipt1.
                    setWarehouse(relatedWarehouse1);
                }
            
                const relatedWarehouse2 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Receipt2 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Receipt2?.setWarehouse)
                {
                    await
                    Receipt2.
                    setWarehouse(relatedWarehouse2);
                }
            
                const relatedWarehouse3 = await Warehouses.findOne({
                    offset: Math.floor(Math.random() * (await Warehouses.count())),
                });
                const Receipt3 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Receipt3?.setWarehouse)
                {
                    await
                    Receipt3.
                    setWarehouse(relatedWarehouse3);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateReceiptWithReceived_by() {
            
                const relatedReceived_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt0 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Receipt0?.setReceived_by)
                {
                    await
                    Receipt0.
                    setReceived_by(relatedReceived_by0);
                }
            
                const relatedReceived_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt1 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Receipt1?.setReceived_by)
                {
                    await
                    Receipt1.
                    setReceived_by(relatedReceived_by1);
                }
            
                const relatedReceived_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt2 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Receipt2?.setReceived_by)
                {
                    await
                    Receipt2.
                    setReceived_by(relatedReceived_by2);
                }
            
                const relatedReceived_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt3 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Receipt3?.setReceived_by)
                {
                    await
                    Receipt3.
                    setReceived_by(relatedReceived_by3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
            
            async function associateReceiptLineWithReceipt() {
            
                const relatedReceipt0 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const ReceiptLine0 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReceiptLine0?.setReceipt)
                {
                    await
                    ReceiptLine0.
                    setReceipt(relatedReceipt0);
                }
            
                const relatedReceipt1 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const ReceiptLine1 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReceiptLine1?.setReceipt)
                {
                    await
                    ReceiptLine1.
                    setReceipt(relatedReceipt1);
                }
            
                const relatedReceipt2 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const ReceiptLine2 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReceiptLine2?.setReceipt)
                {
                    await
                    ReceiptLine2.
                    setReceipt(relatedReceipt2);
                }
            
                const relatedReceipt3 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const ReceiptLine3 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ReceiptLine3?.setReceipt)
                {
                    await
                    ReceiptLine3.
                    setReceipt(relatedReceipt3);
                }
            
        }
        
    
        
            
            async function associateReceiptLineWithPurchase_order_line() {
            
                const relatedPurchase_order_line0 = await PurchaseOrderLines.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrderLines.count())),
                });
                const ReceiptLine0 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReceiptLine0?.setPurchase_order_line)
                {
                    await
                    ReceiptLine0.
                    setPurchase_order_line(relatedPurchase_order_line0);
                }
            
                const relatedPurchase_order_line1 = await PurchaseOrderLines.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrderLines.count())),
                });
                const ReceiptLine1 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReceiptLine1?.setPurchase_order_line)
                {
                    await
                    ReceiptLine1.
                    setPurchase_order_line(relatedPurchase_order_line1);
                }
            
                const relatedPurchase_order_line2 = await PurchaseOrderLines.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrderLines.count())),
                });
                const ReceiptLine2 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReceiptLine2?.setPurchase_order_line)
                {
                    await
                    ReceiptLine2.
                    setPurchase_order_line(relatedPurchase_order_line2);
                }
            
                const relatedPurchase_order_line3 = await PurchaseOrderLines.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrderLines.count())),
                });
                const ReceiptLine3 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ReceiptLine3?.setPurchase_order_line)
                {
                    await
                    ReceiptLine3.
                    setPurchase_order_line(relatedPurchase_order_line3);
                }
            
        }
        
    
        
            
            async function associateReceiptLineWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ReceiptLine0 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReceiptLine0?.setItem)
                {
                    await
                    ReceiptLine0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ReceiptLine1 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReceiptLine1?.setItem)
                {
                    await
                    ReceiptLine1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ReceiptLine2 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReceiptLine2?.setItem)
                {
                    await
                    ReceiptLine2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ReceiptLine3 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ReceiptLine3?.setItem)
                {
                    await
                    ReceiptLine3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
    
        
            
            async function associateReceiptLineWithTo_location() {
            
                const relatedTo_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ReceiptLine0 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReceiptLine0?.setTo_location)
                {
                    await
                    ReceiptLine0.
                    setTo_location(relatedTo_location0);
                }
            
                const relatedTo_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ReceiptLine1 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReceiptLine1?.setTo_location)
                {
                    await
                    ReceiptLine1.
                    setTo_location(relatedTo_location1);
                }
            
                const relatedTo_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ReceiptLine2 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReceiptLine2?.setTo_location)
                {
                    await
                    ReceiptLine2.
                    setTo_location(relatedTo_location2);
                }
            
                const relatedTo_location3 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ReceiptLine3 = await ReceiptLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ReceiptLine3?.setTo_location)
                {
                    await
                    ReceiptLine3.
                    setTo_location(relatedTo_location3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateBomWithParent_item() {
            
                const relatedParent_item0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom0 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Bom0?.setParent_item)
                {
                    await
                    Bom0.
                    setParent_item(relatedParent_item0);
                }
            
                const relatedParent_item1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom1 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Bom1?.setParent_item)
                {
                    await
                    Bom1.
                    setParent_item(relatedParent_item1);
                }
            
                const relatedParent_item2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom2 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Bom2?.setParent_item)
                {
                    await
                    Bom2.
                    setParent_item(relatedParent_item2);
                }
            
                const relatedParent_item3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Bom3 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Bom3?.setParent_item)
                {
                    await
                    Bom3.
                    setParent_item(relatedParent_item3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateBomLineWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine0 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomLine0?.setBom)
                {
                    await
                    BomLine0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine1 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomLine1?.setBom)
                {
                    await
                    BomLine1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine2 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomLine2?.setBom)
                {
                    await
                    BomLine2.
                    setBom(relatedBom2);
                }
            
                const relatedBom3 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomLine3 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (BomLine3?.setBom)
                {
                    await
                    BomLine3.
                    setBom(relatedBom3);
                }
            
        }
        
    
        
            
            async function associateBomLineWithComponent_item() {
            
                const relatedComponent_item0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine0 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomLine0?.setComponent_item)
                {
                    await
                    BomLine0.
                    setComponent_item(relatedComponent_item0);
                }
            
                const relatedComponent_item1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine1 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomLine1?.setComponent_item)
                {
                    await
                    BomLine1.
                    setComponent_item(relatedComponent_item1);
                }
            
                const relatedComponent_item2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine2 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomLine2?.setComponent_item)
                {
                    await
                    BomLine2.
                    setComponent_item(relatedComponent_item2);
                }
            
                const relatedComponent_item3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const BomLine3 = await BomLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (BomLine3?.setComponent_item)
                {
                    await
                    BomLine3.
                    setComponent_item(relatedComponent_item3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateRoutingWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing0 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Routing0?.setItem)
                {
                    await
                    Routing0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing1 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Routing1?.setItem)
                {
                    await
                    Routing1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing2 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Routing2?.setItem)
                {
                    await
                    Routing2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Routing3 = await Routings.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Routing3?.setItem)
                {
                    await
                    Routing3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateRoutingOperationWithRouting() {
            
                const relatedRouting0 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation0 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RoutingOperation0?.setRouting)
                {
                    await
                    RoutingOperation0.
                    setRouting(relatedRouting0);
                }
            
                const relatedRouting1 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation1 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RoutingOperation1?.setRouting)
                {
                    await
                    RoutingOperation1.
                    setRouting(relatedRouting1);
                }
            
                const relatedRouting2 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation2 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RoutingOperation2?.setRouting)
                {
                    await
                    RoutingOperation2.
                    setRouting(relatedRouting2);
                }
            
                const relatedRouting3 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const RoutingOperation3 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RoutingOperation3?.setRouting)
                {
                    await
                    RoutingOperation3.
                    setRouting(relatedRouting3);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateRoutingOperationWithWork_center() {
            
                const relatedWork_center0 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation0 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RoutingOperation0?.setWork_center)
                {
                    await
                    RoutingOperation0.
                    setWork_center(relatedWork_center0);
                }
            
                const relatedWork_center1 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation1 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RoutingOperation1?.setWork_center)
                {
                    await
                    RoutingOperation1.
                    setWork_center(relatedWork_center1);
                }
            
                const relatedWork_center2 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation2 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RoutingOperation2?.setWork_center)
                {
                    await
                    RoutingOperation2.
                    setWork_center(relatedWork_center2);
                }
            
                const relatedWork_center3 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const RoutingOperation3 = await RoutingOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RoutingOperation3?.setWork_center)
                {
                    await
                    RoutingOperation3.
                    setWork_center(relatedWork_center3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateProductionOrderWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setPlant)
                {
                    await
                    ProductionOrder0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setPlant)
                {
                    await
                    ProductionOrder1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setPlant)
                {
                    await
                    ProductionOrder2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ProductionOrder3 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOrder3?.setPlant)
                {
                    await
                    ProductionOrder3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setItem)
                {
                    await
                    ProductionOrder0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setItem)
                {
                    await
                    ProductionOrder1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setItem)
                {
                    await
                    ProductionOrder2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOrder3 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOrder3?.setItem)
                {
                    await
                    ProductionOrder3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setBom)
                {
                    await
                    ProductionOrder0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setBom)
                {
                    await
                    ProductionOrder1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setBom)
                {
                    await
                    ProductionOrder2.
                    setBom(relatedBom2);
                }
            
                const relatedBom3 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const ProductionOrder3 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOrder3?.setBom)
                {
                    await
                    ProductionOrder3.
                    setBom(relatedBom3);
                }
            
        }
        
    
        
            
            async function associateProductionOrderWithRouting() {
            
                const relatedRouting0 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setRouting)
                {
                    await
                    ProductionOrder0.
                    setRouting(relatedRouting0);
                }
            
                const relatedRouting1 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setRouting)
                {
                    await
                    ProductionOrder1.
                    setRouting(relatedRouting1);
                }
            
                const relatedRouting2 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setRouting)
                {
                    await
                    ProductionOrder2.
                    setRouting(relatedRouting2);
                }
            
                const relatedRouting3 = await Routings.findOne({
                    offset: Math.floor(Math.random() * (await Routings.count())),
                });
                const ProductionOrder3 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOrder3?.setRouting)
                {
                    await
                    ProductionOrder3.
                    setRouting(relatedRouting3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductionOrderWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const ProductionOrder0 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOrder0?.setCustomer)
                {
                    await
                    ProductionOrder0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const ProductionOrder1 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOrder1?.setCustomer)
                {
                    await
                    ProductionOrder1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const ProductionOrder2 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOrder2?.setCustomer)
                {
                    await
                    ProductionOrder2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const ProductionOrder3 = await ProductionOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOrder3?.setCustomer)
                {
                    await
                    ProductionOrder3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
            
            async function associateProductionOperationWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setProduction_order)
                {
                    await
                    ProductionOperation0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setProduction_order)
                {
                    await
                    ProductionOperation1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setProduction_order)
                {
                    await
                    ProductionOperation2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOperation3 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOperation3?.setProduction_order)
                {
                    await
                    ProductionOperation3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateProductionOperationWithWork_center() {
            
                const relatedWork_center0 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setWork_center)
                {
                    await
                    ProductionOperation0.
                    setWork_center(relatedWork_center0);
                }
            
                const relatedWork_center1 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setWork_center)
                {
                    await
                    ProductionOperation1.
                    setWork_center(relatedWork_center1);
                }
            
                const relatedWork_center2 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setWork_center)
                {
                    await
                    ProductionOperation2.
                    setWork_center(relatedWork_center2);
                }
            
                const relatedWork_center3 = await WorkCenters.findOne({
                    offset: Math.floor(Math.random() * (await WorkCenters.count())),
                });
                const ProductionOperation3 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOperation3?.setWork_center)
                {
                    await
                    ProductionOperation3.
                    setWork_center(relatedWork_center3);
                }
            
        }
        
    
        
            
            async function associateProductionOperationWithMachine() {
            
                const relatedMachine0 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation0 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOperation0?.setMachine)
                {
                    await
                    ProductionOperation0.
                    setMachine(relatedMachine0);
                }
            
                const relatedMachine1 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation1 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOperation1?.setMachine)
                {
                    await
                    ProductionOperation1.
                    setMachine(relatedMachine1);
                }
            
                const relatedMachine2 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation2 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOperation2?.setMachine)
                {
                    await
                    ProductionOperation2.
                    setMachine(relatedMachine2);
                }
            
                const relatedMachine3 = await Machines.findOne({
                    offset: Math.floor(Math.random() * (await Machines.count())),
                });
                const ProductionOperation3 = await ProductionOperations.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOperation3?.setMachine)
                {
                    await
                    ProductionOperation3.
                    setMachine(relatedMachine3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateProductionMaterialWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionMaterial0 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionMaterial0?.setProduction_order)
                {
                    await
                    ProductionMaterial0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionMaterial1 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionMaterial1?.setProduction_order)
                {
                    await
                    ProductionMaterial1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionMaterial2 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionMaterial2?.setProduction_order)
                {
                    await
                    ProductionMaterial2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionMaterial3 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionMaterial3?.setProduction_order)
                {
                    await
                    ProductionMaterial3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
            
            async function associateProductionMaterialWithComponent_item() {
            
                const relatedComponent_item0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionMaterial0 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionMaterial0?.setComponent_item)
                {
                    await
                    ProductionMaterial0.
                    setComponent_item(relatedComponent_item0);
                }
            
                const relatedComponent_item1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionMaterial1 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionMaterial1?.setComponent_item)
                {
                    await
                    ProductionMaterial1.
                    setComponent_item(relatedComponent_item1);
                }
            
                const relatedComponent_item2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionMaterial2 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionMaterial2?.setComponent_item)
                {
                    await
                    ProductionMaterial2.
                    setComponent_item(relatedComponent_item2);
                }
            
                const relatedComponent_item3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionMaterial3 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionMaterial3?.setComponent_item)
                {
                    await
                    ProductionMaterial3.
                    setComponent_item(relatedComponent_item3);
                }
            
        }
        
    
        
            
            async function associateProductionMaterialWithLot() {
            
                const relatedLot0 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const ProductionMaterial0 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionMaterial0?.setLot)
                {
                    await
                    ProductionMaterial0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const ProductionMaterial1 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionMaterial1?.setLot)
                {
                    await
                    ProductionMaterial1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const ProductionMaterial2 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionMaterial2?.setLot)
                {
                    await
                    ProductionMaterial2.
                    setLot(relatedLot2);
                }
            
                const relatedLot3 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const ProductionMaterial3 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionMaterial3?.setLot)
                {
                    await
                    ProductionMaterial3.
                    setLot(relatedLot3);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateProductionMaterialWithFrom_location() {
            
                const relatedFrom_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionMaterial0 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionMaterial0?.setFrom_location)
                {
                    await
                    ProductionMaterial0.
                    setFrom_location(relatedFrom_location0);
                }
            
                const relatedFrom_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionMaterial1 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionMaterial1?.setFrom_location)
                {
                    await
                    ProductionMaterial1.
                    setFrom_location(relatedFrom_location1);
                }
            
                const relatedFrom_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionMaterial2 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionMaterial2?.setFrom_location)
                {
                    await
                    ProductionMaterial2.
                    setFrom_location(relatedFrom_location2);
                }
            
                const relatedFrom_location3 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionMaterial3 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionMaterial3?.setFrom_location)
                {
                    await
                    ProductionMaterial3.
                    setFrom_location(relatedFrom_location3);
                }
            
        }
        
    
        
    
        
            
            async function associateProductionMaterialWithIssued_by() {
            
                const relatedIssued_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionMaterial0 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionMaterial0?.setIssued_by)
                {
                    await
                    ProductionMaterial0.
                    setIssued_by(relatedIssued_by0);
                }
            
                const relatedIssued_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionMaterial1 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionMaterial1?.setIssued_by)
                {
                    await
                    ProductionMaterial1.
                    setIssued_by(relatedIssued_by1);
                }
            
                const relatedIssued_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionMaterial2 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionMaterial2?.setIssued_by)
                {
                    await
                    ProductionMaterial2.
                    setIssued_by(relatedIssued_by2);
                }
            
                const relatedIssued_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionMaterial3 = await ProductionMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionMaterial3?.setIssued_by)
                {
                    await
                    ProductionMaterial3.
                    setIssued_by(relatedIssued_by3);
                }
            
        }
        
    
        
    

    
    
    
        
            
            async function associateProductionOutputWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOutput0 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOutput0?.setProduction_order)
                {
                    await
                    ProductionOutput0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOutput1 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOutput1?.setProduction_order)
                {
                    await
                    ProductionOutput1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOutput2 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOutput2?.setProduction_order)
                {
                    await
                    ProductionOutput2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const ProductionOutput3 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOutput3?.setProduction_order)
                {
                    await
                    ProductionOutput3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
            
            async function associateProductionOutputWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOutput0 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOutput0?.setItem)
                {
                    await
                    ProductionOutput0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOutput1 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOutput1?.setItem)
                {
                    await
                    ProductionOutput1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOutput2 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOutput2?.setItem)
                {
                    await
                    ProductionOutput2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ProductionOutput3 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOutput3?.setItem)
                {
                    await
                    ProductionOutput3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
    
        
            
            async function associateProductionOutputWithTo_location() {
            
                const relatedTo_location0 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionOutput0 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOutput0?.setTo_location)
                {
                    await
                    ProductionOutput0.
                    setTo_location(relatedTo_location0);
                }
            
                const relatedTo_location1 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionOutput1 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOutput1?.setTo_location)
                {
                    await
                    ProductionOutput1.
                    setTo_location(relatedTo_location1);
                }
            
                const relatedTo_location2 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionOutput2 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOutput2?.setTo_location)
                {
                    await
                    ProductionOutput2.
                    setTo_location(relatedTo_location2);
                }
            
                const relatedTo_location3 = await Locations.findOne({
                    offset: Math.floor(Math.random() * (await Locations.count())),
                });
                const ProductionOutput3 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOutput3?.setTo_location)
                {
                    await
                    ProductionOutput3.
                    setTo_location(relatedTo_location3);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateProductionOutputWithReported_by() {
            
                const relatedReported_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOutput0 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProductionOutput0?.setReported_by)
                {
                    await
                    ProductionOutput0.
                    setReported_by(relatedReported_by0);
                }
            
                const relatedReported_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOutput1 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProductionOutput1?.setReported_by)
                {
                    await
                    ProductionOutput1.
                    setReported_by(relatedReported_by1);
                }
            
                const relatedReported_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOutput2 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProductionOutput2?.setReported_by)
                {
                    await
                    ProductionOutput2.
                    setReported_by(relatedReported_by2);
                }
            
                const relatedReported_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ProductionOutput3 = await ProductionOutputs.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProductionOutput3?.setReported_by)
                {
                    await
                    ProductionOutput3.
                    setReported_by(relatedReported_by3);
                }
            
        }
        
    
        
    

    
    
    
        
    
        
            
            async function associateQaPlanWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaPlan0 = await QaPlans.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaPlan0?.setItem)
                {
                    await
                    QaPlan0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaPlan1 = await QaPlans.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaPlan1?.setItem)
                {
                    await
                    QaPlan1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaPlan2 = await QaPlans.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaPlan2?.setItem)
                {
                    await
                    QaPlan2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaPlan3 = await QaPlans.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaPlan3?.setItem)
                {
                    await
                    QaPlan3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateQaCharacteristicWithQa_plan() {
            
                const relatedQa_plan0 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaCharacteristic0 = await QaCharacteristics.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaCharacteristic0?.setQa_plan)
                {
                    await
                    QaCharacteristic0.
                    setQa_plan(relatedQa_plan0);
                }
            
                const relatedQa_plan1 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaCharacteristic1 = await QaCharacteristics.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaCharacteristic1?.setQa_plan)
                {
                    await
                    QaCharacteristic1.
                    setQa_plan(relatedQa_plan1);
                }
            
                const relatedQa_plan2 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaCharacteristic2 = await QaCharacteristics.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaCharacteristic2?.setQa_plan)
                {
                    await
                    QaCharacteristic2.
                    setQa_plan(relatedQa_plan2);
                }
            
                const relatedQa_plan3 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaCharacteristic3 = await QaCharacteristics.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaCharacteristic3?.setQa_plan)
                {
                    await
                    QaCharacteristic3.
                    setQa_plan(relatedQa_plan3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateQaInspectionWithQa_plan() {
            
                const relatedQa_plan0 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaInspection0 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaInspection0?.setQa_plan)
                {
                    await
                    QaInspection0.
                    setQa_plan(relatedQa_plan0);
                }
            
                const relatedQa_plan1 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaInspection1 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaInspection1?.setQa_plan)
                {
                    await
                    QaInspection1.
                    setQa_plan(relatedQa_plan1);
                }
            
                const relatedQa_plan2 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaInspection2 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaInspection2?.setQa_plan)
                {
                    await
                    QaInspection2.
                    setQa_plan(relatedQa_plan2);
                }
            
                const relatedQa_plan3 = await QaPlans.findOne({
                    offset: Math.floor(Math.random() * (await QaPlans.count())),
                });
                const QaInspection3 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaInspection3?.setQa_plan)
                {
                    await
                    QaInspection3.
                    setQa_plan(relatedQa_plan3);
                }
            
        }
        
    
        
    
        
            
            async function associateQaInspectionWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaInspection0 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaInspection0?.setItem)
                {
                    await
                    QaInspection0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaInspection1 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaInspection1?.setItem)
                {
                    await
                    QaInspection1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaInspection2 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaInspection2?.setItem)
                {
                    await
                    QaInspection2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const QaInspection3 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaInspection3?.setItem)
                {
                    await
                    QaInspection3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateQaInspectionWithLot() {
            
                const relatedLot0 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const QaInspection0 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaInspection0?.setLot)
                {
                    await
                    QaInspection0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const QaInspection1 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaInspection1?.setLot)
                {
                    await
                    QaInspection1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const QaInspection2 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaInspection2?.setLot)
                {
                    await
                    QaInspection2.
                    setLot(relatedLot2);
                }
            
                const relatedLot3 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const QaInspection3 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaInspection3?.setLot)
                {
                    await
                    QaInspection3.
                    setLot(relatedLot3);
                }
            
        }
        
    
        
            
            async function associateQaInspectionWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QaInspection0 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaInspection0?.setProduction_order)
                {
                    await
                    QaInspection0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QaInspection1 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaInspection1?.setProduction_order)
                {
                    await
                    QaInspection1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QaInspection2 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaInspection2?.setProduction_order)
                {
                    await
                    QaInspection2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const QaInspection3 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaInspection3?.setProduction_order)
                {
                    await
                    QaInspection3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateQaInspectionWithInspector() {
            
                const relatedInspector0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QaInspection0 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaInspection0?.setInspector)
                {
                    await
                    QaInspection0.
                    setInspector(relatedInspector0);
                }
            
                const relatedInspector1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QaInspection1 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaInspection1?.setInspector)
                {
                    await
                    QaInspection1.
                    setInspector(relatedInspector1);
                }
            
                const relatedInspector2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QaInspection2 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaInspection2?.setInspector)
                {
                    await
                    QaInspection2.
                    setInspector(relatedInspector2);
                }
            
                const relatedInspector3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const QaInspection3 = await QaInspections.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaInspection3?.setInspector)
                {
                    await
                    QaInspection3.
                    setInspector(relatedInspector3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
            
            async function associateQaResultWithQa_inspection() {
            
                const relatedQa_inspection0 = await QaInspections.findOne({
                    offset: Math.floor(Math.random() * (await QaInspections.count())),
                });
                const QaResult0 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaResult0?.setQa_inspection)
                {
                    await
                    QaResult0.
                    setQa_inspection(relatedQa_inspection0);
                }
            
                const relatedQa_inspection1 = await QaInspections.findOne({
                    offset: Math.floor(Math.random() * (await QaInspections.count())),
                });
                const QaResult1 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaResult1?.setQa_inspection)
                {
                    await
                    QaResult1.
                    setQa_inspection(relatedQa_inspection1);
                }
            
                const relatedQa_inspection2 = await QaInspections.findOne({
                    offset: Math.floor(Math.random() * (await QaInspections.count())),
                });
                const QaResult2 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaResult2?.setQa_inspection)
                {
                    await
                    QaResult2.
                    setQa_inspection(relatedQa_inspection2);
                }
            
                const relatedQa_inspection3 = await QaInspections.findOne({
                    offset: Math.floor(Math.random() * (await QaInspections.count())),
                });
                const QaResult3 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaResult3?.setQa_inspection)
                {
                    await
                    QaResult3.
                    setQa_inspection(relatedQa_inspection3);
                }
            
        }
        
    
        
            
            async function associateQaResultWithQa_characteristic() {
            
                const relatedQa_characteristic0 = await QaCharacteristics.findOne({
                    offset: Math.floor(Math.random() * (await QaCharacteristics.count())),
                });
                const QaResult0 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QaResult0?.setQa_characteristic)
                {
                    await
                    QaResult0.
                    setQa_characteristic(relatedQa_characteristic0);
                }
            
                const relatedQa_characteristic1 = await QaCharacteristics.findOne({
                    offset: Math.floor(Math.random() * (await QaCharacteristics.count())),
                });
                const QaResult1 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QaResult1?.setQa_characteristic)
                {
                    await
                    QaResult1.
                    setQa_characteristic(relatedQa_characteristic1);
                }
            
                const relatedQa_characteristic2 = await QaCharacteristics.findOne({
                    offset: Math.floor(Math.random() * (await QaCharacteristics.count())),
                });
                const QaResult2 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QaResult2?.setQa_characteristic)
                {
                    await
                    QaResult2.
                    setQa_characteristic(relatedQa_characteristic2);
                }
            
                const relatedQa_characteristic3 = await QaCharacteristics.findOne({
                    offset: Math.floor(Math.random() * (await QaCharacteristics.count())),
                });
                const QaResult3 = await QaResults.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QaResult3?.setQa_characteristic)
                {
                    await
                    QaResult3.
                    setQa_characteristic(relatedQa_characteristic3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateNonconformanceWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setItem)
                {
                    await
                    Nonconformance0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setItem)
                {
                    await
                    Nonconformance1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setItem)
                {
                    await
                    Nonconformance2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setItem)
                {
                    await
                    Nonconformance3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithLot() {
            
                const relatedLot0 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setLot)
                {
                    await
                    Nonconformance0.
                    setLot(relatedLot0);
                }
            
                const relatedLot1 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setLot)
                {
                    await
                    Nonconformance1.
                    setLot(relatedLot1);
                }
            
                const relatedLot2 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setLot)
                {
                    await
                    Nonconformance2.
                    setLot(relatedLot2);
                }
            
                const relatedLot3 = await InventoryLots.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLots.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setLot)
                {
                    await
                    Nonconformance3.
                    setLot(relatedLot3);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setProduction_order)
                {
                    await
                    Nonconformance0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setProduction_order)
                {
                    await
                    Nonconformance1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setProduction_order)
                {
                    await
                    Nonconformance2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setProduction_order)
                {
                    await
                    Nonconformance3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateNonconformanceWithReported_by() {
            
                const relatedReported_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setReported_by)
                {
                    await
                    Nonconformance0.
                    setReported_by(relatedReported_by0);
                }
            
                const relatedReported_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setReported_by)
                {
                    await
                    Nonconformance1.
                    setReported_by(relatedReported_by1);
                }
            
                const relatedReported_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setReported_by)
                {
                    await
                    Nonconformance2.
                    setReported_by(relatedReported_by2);
                }
            
                const relatedReported_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setReported_by)
                {
                    await
                    Nonconformance3.
                    setReported_by(relatedReported_by3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateDocumentWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setOwner)
                {
                    await
                    Document0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setOwner)
                {
                    await
                    Document1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setOwner)
                {
                    await
                    Document2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document3 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Document3?.setOwner)
                {
                    await
                    Document3.
                    setOwner(relatedOwner3);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
            
            async function associateAuditLogWithActor() {
            
                const relatedActor0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog0 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditLog0?.setActor)
                {
                    await
                    AuditLog0.
                    setActor(relatedActor0);
                }
            
                const relatedActor1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog1 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditLog1?.setActor)
                {
                    await
                    AuditLog1.
                    setActor(relatedActor1);
                }
            
                const relatedActor2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog2 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditLog2?.setActor)
                {
                    await
                    AuditLog2.
                    setActor(relatedActor2);
                }
            
                const relatedActor3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog3 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AuditLog3?.setActor)
                {
                    await
                    AuditLog3.
                    setActor(relatedActor3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateJournalEntryWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const JournalEntry0 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalEntry0?.setPlant)
                {
                    await
                    JournalEntry0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const JournalEntry1 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalEntry1?.setPlant)
                {
                    await
                    JournalEntry1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const JournalEntry2 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalEntry2?.setPlant)
                {
                    await
                    JournalEntry2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const JournalEntry3 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalEntry3?.setPlant)
                {
                    await
                    JournalEntry3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateJournalEntryWithPosted_by() {
            
                const relatedPosted_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const JournalEntry0 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalEntry0?.setPosted_by)
                {
                    await
                    JournalEntry0.
                    setPosted_by(relatedPosted_by0);
                }
            
                const relatedPosted_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const JournalEntry1 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalEntry1?.setPosted_by)
                {
                    await
                    JournalEntry1.
                    setPosted_by(relatedPosted_by1);
                }
            
                const relatedPosted_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const JournalEntry2 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalEntry2?.setPosted_by)
                {
                    await
                    JournalEntry2.
                    setPosted_by(relatedPosted_by2);
                }
            
                const relatedPosted_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const JournalEntry3 = await JournalEntries.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalEntry3?.setPosted_by)
                {
                    await
                    JournalEntry3.
                    setPosted_by(relatedPosted_by3);
                }
            
        }
        
    
        
    

    
    
    
        
            
            async function associateJournalLineWithJournal_entry() {
            
                const relatedJournal_entry0 = await JournalEntries.findOne({
                    offset: Math.floor(Math.random() * (await JournalEntries.count())),
                });
                const JournalLine0 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalLine0?.setJournal_entry)
                {
                    await
                    JournalLine0.
                    setJournal_entry(relatedJournal_entry0);
                }
            
                const relatedJournal_entry1 = await JournalEntries.findOne({
                    offset: Math.floor(Math.random() * (await JournalEntries.count())),
                });
                const JournalLine1 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalLine1?.setJournal_entry)
                {
                    await
                    JournalLine1.
                    setJournal_entry(relatedJournal_entry1);
                }
            
                const relatedJournal_entry2 = await JournalEntries.findOne({
                    offset: Math.floor(Math.random() * (await JournalEntries.count())),
                });
                const JournalLine2 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalLine2?.setJournal_entry)
                {
                    await
                    JournalLine2.
                    setJournal_entry(relatedJournal_entry2);
                }
            
                const relatedJournal_entry3 = await JournalEntries.findOne({
                    offset: Math.floor(Math.random() * (await JournalEntries.count())),
                });
                const JournalLine3 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalLine3?.setJournal_entry)
                {
                    await
                    JournalLine3.
                    setJournal_entry(relatedJournal_entry3);
                }
            
        }
        
    
        
            
            async function associateJournalLineWithGl_account() {
            
                const relatedGl_account0 = await GlAccounts.findOne({
                    offset: Math.floor(Math.random() * (await GlAccounts.count())),
                });
                const JournalLine0 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalLine0?.setGl_account)
                {
                    await
                    JournalLine0.
                    setGl_account(relatedGl_account0);
                }
            
                const relatedGl_account1 = await GlAccounts.findOne({
                    offset: Math.floor(Math.random() * (await GlAccounts.count())),
                });
                const JournalLine1 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalLine1?.setGl_account)
                {
                    await
                    JournalLine1.
                    setGl_account(relatedGl_account1);
                }
            
                const relatedGl_account2 = await GlAccounts.findOne({
                    offset: Math.floor(Math.random() * (await GlAccounts.count())),
                });
                const JournalLine2 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalLine2?.setGl_account)
                {
                    await
                    JournalLine2.
                    setGl_account(relatedGl_account2);
                }
            
                const relatedGl_account3 = await GlAccounts.findOne({
                    offset: Math.floor(Math.random() * (await GlAccounts.count())),
                });
                const JournalLine3 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalLine3?.setGl_account)
                {
                    await
                    JournalLine3.
                    setGl_account(relatedGl_account3);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateJournalLineWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const JournalLine0 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalLine0?.setItem)
                {
                    await
                    JournalLine0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const JournalLine1 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalLine1?.setItem)
                {
                    await
                    JournalLine1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const JournalLine2 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalLine2?.setItem)
                {
                    await
                    JournalLine2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const JournalLine3 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalLine3?.setItem)
                {
                    await
                    JournalLine3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateJournalLineWithProduction_order() {
            
                const relatedProduction_order0 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const JournalLine0 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalLine0?.setProduction_order)
                {
                    await
                    JournalLine0.
                    setProduction_order(relatedProduction_order0);
                }
            
                const relatedProduction_order1 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const JournalLine1 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalLine1?.setProduction_order)
                {
                    await
                    JournalLine1.
                    setProduction_order(relatedProduction_order1);
                }
            
                const relatedProduction_order2 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const JournalLine2 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalLine2?.setProduction_order)
                {
                    await
                    JournalLine2.
                    setProduction_order(relatedProduction_order2);
                }
            
                const relatedProduction_order3 = await ProductionOrders.findOne({
                    offset: Math.floor(Math.random() * (await ProductionOrders.count())),
                });
                const JournalLine3 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalLine3?.setProduction_order)
                {
                    await
                    JournalLine3.
                    setProduction_order(relatedProduction_order3);
                }
            
        }
        
    
        
            
            async function associateJournalLineWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const JournalLine0 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalLine0?.setSupplier)
                {
                    await
                    JournalLine0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const JournalLine1 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalLine1?.setSupplier)
                {
                    await
                    JournalLine1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const JournalLine2 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalLine2?.setSupplier)
                {
                    await
                    JournalLine2.
                    setSupplier(relatedSupplier2);
                }
            
                const relatedSupplier3 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const JournalLine3 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalLine3?.setSupplier)
                {
                    await
                    JournalLine3.
                    setSupplier(relatedSupplier3);
                }
            
        }
        
    
        
            
            async function associateJournalLineWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const JournalLine0 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (JournalLine0?.setCustomer)
                {
                    await
                    JournalLine0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const JournalLine1 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (JournalLine1?.setCustomer)
                {
                    await
                    JournalLine1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const JournalLine2 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (JournalLine2?.setCustomer)
                {
                    await
                    JournalLine2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const JournalLine3 = await JournalLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (JournalLine3?.setCustomer)
                {
                    await
                    JournalLine3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
            
            async function associateCostCenterWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const CostCenter0 = await CostCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CostCenter0?.setPlant)
                {
                    await
                    CostCenter0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const CostCenter1 = await CostCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CostCenter1?.setPlant)
                {
                    await
                    CostCenter1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const CostCenter2 = await CostCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CostCenter2?.setPlant)
                {
                    await
                    CostCenter2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const CostCenter3 = await CostCenters.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (CostCenter3?.setPlant)
                {
                    await
                    CostCenter3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
    

    
    
    
        
            
            async function associateItemCostWithItem() {
            
                const relatedItem0 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ItemCost0 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ItemCost0?.setItem)
                {
                    await
                    ItemCost0.
                    setItem(relatedItem0);
                }
            
                const relatedItem1 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ItemCost1 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ItemCost1?.setItem)
                {
                    await
                    ItemCost1.
                    setItem(relatedItem1);
                }
            
                const relatedItem2 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ItemCost2 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ItemCost2?.setItem)
                {
                    await
                    ItemCost2.
                    setItem(relatedItem2);
                }
            
                const relatedItem3 = await Items.findOne({
                    offset: Math.floor(Math.random() * (await Items.count())),
                });
                const ItemCost3 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ItemCost3?.setItem)
                {
                    await
                    ItemCost3.
                    setItem(relatedItem3);
                }
            
        }
        
    
        
            
            async function associateItemCostWithPlant() {
            
                const relatedPlant0 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ItemCost0 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ItemCost0?.setPlant)
                {
                    await
                    ItemCost0.
                    setPlant(relatedPlant0);
                }
            
                const relatedPlant1 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ItemCost1 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ItemCost1?.setPlant)
                {
                    await
                    ItemCost1.
                    setPlant(relatedPlant1);
                }
            
                const relatedPlant2 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ItemCost2 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ItemCost2?.setPlant)
                {
                    await
                    ItemCost2.
                    setPlant(relatedPlant2);
                }
            
                const relatedPlant3 = await Plants.findOne({
                    offset: Math.floor(Math.random() * (await Plants.count())),
                });
                const ItemCost3 = await ItemCosts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ItemCost3?.setPlant)
                {
                    await
                    ItemCost3.
                    setPlant(relatedPlant3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Plants.bulkCreate(PlantsData);
                
            
            
                
                await WorkCenters.bulkCreate(WorkCentersData);
                
            
            
                
                await Machines.bulkCreate(MachinesData);
                
            
            
                
                await MaintenanceWorkOrders.bulkCreate(MaintenanceWorkOrdersData);
                
            
            
                
                await DowntimeEvents.bulkCreate(DowntimeEventsData);
                
            
            
                
                await Uoms.bulkCreate(UomsData);
                
            
            
                
                await ItemCategories.bulkCreate(ItemCategoriesData);
                
            
            
                
                await Items.bulkCreate(ItemsData);
                
            
            
                
                await Warehouses.bulkCreate(WarehousesData);
                
            
            
                
                await Locations.bulkCreate(LocationsData);
                
            
            
                
                await InventoryLots.bulkCreate(InventoryLotsData);
                
            
            
                
                await InventoryBalances.bulkCreate(InventoryBalancesData);
                
            
            
                
                await InventoryTransactions.bulkCreate(InventoryTransactionsData);
                
            
            
                
                await Suppliers.bulkCreate(SuppliersData);
                
            
            
                
                await Customers.bulkCreate(CustomersData);
                
            
            
                
                await PurchaseOrders.bulkCreate(PurchaseOrdersData);
                
            
            
                
                await PurchaseOrderLines.bulkCreate(PurchaseOrderLinesData);
                
            
            
                
                await Receipts.bulkCreate(ReceiptsData);
                
            
            
                
                await ReceiptLines.bulkCreate(ReceiptLinesData);
                
            
            
                
                await Boms.bulkCreate(BomsData);
                
            
            
                
                await BomLines.bulkCreate(BomLinesData);
                
            
            
                
                await Routings.bulkCreate(RoutingsData);
                
            
            
                
                await RoutingOperations.bulkCreate(RoutingOperationsData);
                
            
            
                
                await ProductionOrders.bulkCreate(ProductionOrdersData);
                
            
            
                
                await ProductionOperations.bulkCreate(ProductionOperationsData);
                
            
            
                
                await ProductionMaterials.bulkCreate(ProductionMaterialsData);
                
            
            
                
                await ProductionOutputs.bulkCreate(ProductionOutputsData);
                
            
            
                
                await QaPlans.bulkCreate(QaPlansData);
                
            
            
                
                await QaCharacteristics.bulkCreate(QaCharacteristicsData);
                
            
            
                
                await QaInspections.bulkCreate(QaInspectionsData);
                
            
            
                
                await QaResults.bulkCreate(QaResultsData);
                
            
            
                
                await Nonconformances.bulkCreate(NonconformancesData);
                
            
            
                
                await Documents.bulkCreate(DocumentsData);
                
            
            
                
                await AuditLogs.bulkCreate(AuditLogsData);
                
            
            
                
                await GlAccounts.bulkCreate(GlAccountsData);
                
            
            
                
                await JournalEntries.bulkCreate(JournalEntriesData);
                
            
            
                
                await JournalLines.bulkCreate(JournalLinesData);
                
            
            
                
                await CostCenters.bulkCreate(CostCentersData);
                
            
            
                
                await ItemCosts.bulkCreate(ItemCostsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateWorkCenterWithPlant(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMachineWithWork_center(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateMaintenanceWorkOrderWithMachine(),
                    
                
                    
                        
                        await associateMaintenanceWorkOrderWithAssigned_to(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateDowntimeEventWithMachine(),
                    
                
                    
                        
                        await associateDowntimeEventWithProduction_order(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateItemWithCategory(),
                    
                
                    
                        
                        await associateItemWithUom(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateWarehousWithPlant(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateLocationWithWarehouse(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateInventoryLotWithItem(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateInventoryBalanceWithItem(),
                    
                
                    
                        
                        await associateInventoryBalanceWithLocation(),
                    
                
                    
                        
                        await associateInventoryBalanceWithLot(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateInventoryTransactionWithItem(),
                    
                
                    
                        
                        await associateInventoryTransactionWithFrom_location(),
                    
                
                    
                        
                        await associateInventoryTransactionWithTo_location(),
                    
                
                    
                        
                        await associateInventoryTransactionWithLot(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateInventoryTransactionWithPerformed_by(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associatePurchaseOrderWithSupplier(),
                    
                
                    
                        
                        await associatePurchaseOrderWithPlant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associatePurchaseOrderLineWithPurchase_order(),
                    
                
                    
                        
                        await associatePurchaseOrderLineWithItem(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateReceiptWithPurchase_order(),
                    
                
                    
                        
                        await associateReceiptWithWarehouse(),
                    
                
                    
                
                    
                
                    
                        
                        await associateReceiptWithReceived_by(),
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateReceiptLineWithReceipt(),
                    
                
                    
                        
                        await associateReceiptLineWithPurchase_order_line(),
                    
                
                    
                        
                        await associateReceiptLineWithItem(),
                    
                
                    
                
                    
                        
                        await associateReceiptLineWithTo_location(),
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateBomWithParent_item(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateBomLineWithBom(),
                    
                
                    
                        
                        await associateBomLineWithComponent_item(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateRoutingWithItem(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateRoutingOperationWithRouting(),
                    
                
                    
                
                    
                
                    
                        
                        await associateRoutingOperationWithWork_center(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateProductionOrderWithPlant(),
                    
                
                    
                        
                        await associateProductionOrderWithItem(),
                    
                
                    
                        
                        await associateProductionOrderWithBom(),
                    
                
                    
                        
                        await associateProductionOrderWithRouting(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOrderWithCustomer(),
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateProductionOperationWithProduction_order(),
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOperationWithWork_center(),
                    
                
                    
                        
                        await associateProductionOperationWithMachine(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateProductionMaterialWithProduction_order(),
                    
                
                    
                        
                        await associateProductionMaterialWithComponent_item(),
                    
                
                    
                        
                        await associateProductionMaterialWithLot(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionMaterialWithFrom_location(),
                    
                
                    
                
                    
                        
                        await associateProductionMaterialWithIssued_by(),
                    
                
                    
                
            
                
                
                    
                        
                        await associateProductionOutputWithProduction_order(),
                    
                
                    
                        
                        await associateProductionOutputWithItem(),
                    
                
                    
                
                    
                        
                        await associateProductionOutputWithTo_location(),
                    
                
                    
                
                    
                
                    
                        
                        await associateProductionOutputWithReported_by(),
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateQaPlanWithItem(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateQaCharacteristicWithQa_plan(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateQaInspectionWithQa_plan(),
                    
                
                    
                
                    
                        
                        await associateQaInspectionWithItem(),
                    
                
                    
                        
                        await associateQaInspectionWithLot(),
                    
                
                    
                        
                        await associateQaInspectionWithProduction_order(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateQaInspectionWithInspector(),
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateQaResultWithQa_inspection(),
                    
                
                    
                        
                        await associateQaResultWithQa_characteristic(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithItem(),
                    
                
                    
                        
                        await associateNonconformanceWithLot(),
                    
                
                    
                        
                        await associateNonconformanceWithProduction_order(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithReported_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDocumentWithOwner(),
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateAuditLogWithActor(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateJournalEntryWithPlant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateJournalEntryWithPosted_by(),
                    
                
                    
                
            
                
                
                    
                        
                        await associateJournalLineWithJournal_entry(),
                    
                
                    
                        
                        await associateJournalLineWithGl_account(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateJournalLineWithItem(),
                    
                
                    
                        
                        await associateJournalLineWithProduction_order(),
                    
                
                    
                        
                        await associateJournalLineWithSupplier(),
                    
                
                    
                        
                        await associateJournalLineWithCustomer(),
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateCostCenterWithPlant(),
                    
                
                    
                
            
                
                
                    
                        
                        await associateItemCostWithItem(),
                    
                
                    
                        
                        await associateItemCostWithPlant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('plants', null, {});
            
            
            await queryInterface.bulkDelete('work_centers', null, {});
            
            
            await queryInterface.bulkDelete('machines', null, {});
            
            
            await queryInterface.bulkDelete('maintenance_work_orders', null, {});
            
            
            await queryInterface.bulkDelete('downtime_events', null, {});
            
            
            await queryInterface.bulkDelete('uoms', null, {});
            
            
            await queryInterface.bulkDelete('item_categories', null, {});
            
            
            await queryInterface.bulkDelete('items', null, {});
            
            
            await queryInterface.bulkDelete('warehouses', null, {});
            
            
            await queryInterface.bulkDelete('locations', null, {});
            
            
            await queryInterface.bulkDelete('inventory_lots', null, {});
            
            
            await queryInterface.bulkDelete('inventory_balances', null, {});
            
            
            await queryInterface.bulkDelete('inventory_transactions', null, {});
            
            
            await queryInterface.bulkDelete('suppliers', null, {});
            
            
            await queryInterface.bulkDelete('customers', null, {});
            
            
            await queryInterface.bulkDelete('purchase_orders', null, {});
            
            
            await queryInterface.bulkDelete('purchase_order_lines', null, {});
            
            
            await queryInterface.bulkDelete('receipts', null, {});
            
            
            await queryInterface.bulkDelete('receipt_lines', null, {});
            
            
            await queryInterface.bulkDelete('boms', null, {});
            
            
            await queryInterface.bulkDelete('bom_lines', null, {});
            
            
            await queryInterface.bulkDelete('routings', null, {});
            
            
            await queryInterface.bulkDelete('routing_operations', null, {});
            
            
            await queryInterface.bulkDelete('production_orders', null, {});
            
            
            await queryInterface.bulkDelete('production_operations', null, {});
            
            
            await queryInterface.bulkDelete('production_materials', null, {});
            
            
            await queryInterface.bulkDelete('production_outputs', null, {});
            
            
            await queryInterface.bulkDelete('qa_plans', null, {});
            
            
            await queryInterface.bulkDelete('qa_characteristics', null, {});
            
            
            await queryInterface.bulkDelete('qa_inspections', null, {});
            
            
            await queryInterface.bulkDelete('qa_results', null, {});
            
            
            await queryInterface.bulkDelete('nonconformances', null, {});
            
            
            await queryInterface.bulkDelete('documents', null, {});
            
            
            await queryInterface.bulkDelete('audit_logs', null, {});
            
            
            await queryInterface.bulkDelete('gl_accounts', null, {});
            
            
            await queryInterface.bulkDelete('journal_entries', null, {});
            
            
            await queryInterface.bulkDelete('journal_lines', null, {});
            
            
            await queryInterface.bulkDelete('cost_centers', null, {});
            
            
            await queryInterface.bulkDelete('item_costs', null, {});
            
        
    },
};