





















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






const Customers = db.customers;

const Contacts = db.contacts;

const Leads = db.leads;

const Quotes = db.quotes;

const QuoteLineItems = db.quote_line_items;

const Projects = db.projects;

const ProjectMilestones = db.project_milestones;

const Products = db.products;

const Materials = db.materials;

const Suppliers = db.suppliers;

const InventoryLocations = db.inventory_locations;

const InventoryItems = db.inventory_items;

const InventoryTransactions = db.inventory_transactions;

const Boms = db.boms;

const BomItems = db.bom_items;

const PurchaseOrders = db.purchase_orders;

const PurchaseOrderLineItems = db.purchase_order_line_items;

const GoodsReceipts = db.goods_receipts;

const WorkOrders = db.work_orders;

const WorkOrderMaterials = db.work_order_materials;

const Deliveries = db.deliveries;

const DeliveryItems = db.delivery_items;

const Invoices = db.invoices;

const InvoiceLineItems = db.invoice_line_items;

const Payments = db.payments;

const Documents = db.documents;







const CustomersData = [
    
    {
    
        
        
            
                "customer_code": "CUST-0001",
            
        
    
        
        
            
                "name": "Riverbend Developments",
            
        
    
        
        
            
                "type": "developer",
            
        
    
        
        
            
                "email": "ap@riverbenddev.com",
            
        
    
        
        
            
                "phone": "+1-541-555-0140",
            
        
    
        
        
            
                "billing_address": "410 Oak Street, Eugene, OR 97401",
            
        
    
        
        
            
                "shipping_address": "Job Site: 88 Pine Loop, Springfield, OR 97477",
            
        
    
        
        
            
                "tax_number": "OR-771204",
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "notes": "Preferred developer client, net 30",
            
        
    
    },
    
    {
    
        
        
            
                "customer_code": "CUST-0002",
            
        
    
        
        
            
                "name": "Cedar Grove Builders",
            
        
    
        
        
            
                "type": "commercial",
            
        
    
        
        
            
                "email": "office@cedargrovebuilders.com",
            
        
    
        
        
            
                "phone": "+1-503-555-0141",
            
        
    
        
        
            
                "billing_address": "1250 Industrial Way, Salem, OR 97301",
            
        
    
        
        
            
                "shipping_address": "Yard Delivery: 1250 Industrial Way, Salem, OR 97301",
            
        
    
        
        
            
                "tax_number": "OR-558913",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "notes": "Bulk orders for wall panels",
            
        
    
    },
    
    {
    
        
        
            
                "customer_code": "CUST-0003",
            
        
    
        
        
            
                "name": "Summit Ridge Homes",
            
        
    
        
        
            
                "type": "commercial",
            
        
    
        
        
            
                "email": "summitridgehomes@gmail.com",
            
        
    
        
        
            
                "phone": "+1-503-555-0142",
            
        
    
        
        
            
                "billing_address": "913 Ridgeview Dr, Portland, OR 97205",
            
        
    
        
        
            
                "shipping_address": "913 Ridgeview Dr, Portland, OR 97205",
            
        
    
        
        
            
                "tax_number": "N/A",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "notes": "Custom small cabin frame",
            
        
    
    },
    
    {
    
        
        
            
                "customer_code": "CUST-0004",
            
        
    
        
        
            
                "name": "Northpoint Commercial LLC",
            
        
    
        
        
            
                "type": "other",
            
        
    
        
        
            
                "email": "billing@northpointcommercial.com",
            
        
    
        
        
            
                "phone": "+1-425-555-0143",
            
        
    
        
        
            
                "billing_address": "77 Market Ave, Vancouver, WA 98660",
            
        
    
        
        
            
                "shipping_address": "Site: 220 Dock Rd, Vancouver, WA 98660",
            
        
    
        
        
            
                "tax_number": "WA-992211",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "notes": "Pending credit approval",
            
        
    
    },
    
];



const ContactsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "full_name": "Liam Parker",
            
        
    
        
        
            
                "title_role": "Project Coordinator",
            
        
    
        
        
            
                "email": "liam.parker@riverbenddev.com",
            
        
    
        
        
            
                "phone": "+1-541-555-0190",
            
        
    
        
        
            
                "is_primary": true,
            
        
    
        
        
            
                "notes": "Main contact for scheduling and site access",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "full_name": "Olivia King",
            
        
    
        
        
            
                "title_role": "Office Manager",
            
        
    
        
        
            
                "email": "olivia.king@cedargrovebuilders.com",
            
        
    
        
        
            
                "phone": "+1-503-555-0191",
            
        
    
        
        
            
                "is_primary": true,
            
        
    
        
        
            
                "notes": "Purchase orders and invoice questions",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "full_name": "Daniel Rivera",
            
        
    
        
        
            
                "title_role": "Homeowner",
            
        
    
        
        
            
                "email": "daniel.rivera@gmail.com",
            
        
    
        
        
            
                "phone": "+1-503-555-0192",
            
        
    
        
        
            
                "is_primary": true,
            
        
    
        
        
            
                "notes": "Prefers email updates",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "full_name": "Grace Patel",
            
        
    
        
        
            
                "title_role": "Accounts Payable",
            
        
    
        
        
            
                "email": "grace.patel@northpointcommercial.com",
            
        
    
        
        
            
                "phone": "+1-425-555-0193",
            
        
    
        
        
            
                "is_primary": true,
            
        
    
        
        
            
                "notes": "Handles payment processing",
            
        
    
    },
    
];



const LeadsData = [
    
    {
    
        
        
            
                "lead_code": "LEAD-1001",
            
        
    
        
        
            
                "name": "12x24 Backyard Cabin Frame",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "referral",
            
        
    
        
        
            
                "status": "qualified",
            
        
    
        
        
            
                "estimated_value": 18500.0,
            
        
    
        
        
            
                "expected_close_at": new Date('2026-04-15T17:00:00Z'),
            
        
    
        
        
            
                "requirements": "Basic cabin frame kit with floor and roof framing, delivery included",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "lead_code": "LEAD-1002",
            
        
    
        
        
            
                "name": "Duplex Wall Panels Batch A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "walk_in",
            
        
    
        
        
            
                "status": "new",
            
        
    
        
        
            
                "estimated_value": 64200.0,
            
        
    
        
        
            
                "expected_close_at": new Date('2026-04-05T17:00:00Z'),
            
        
    
        
        
            
                "requirements": "Prebuilt wall panels for two duplex units, includes sheathing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "lead_code": "LEAD-1003",
            
        
    
        
        
            
                "name": "Small Commercial Storage Building",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "website",
            
        
    
        
        
            
                "status": "qualified",
            
        
    
        
        
            
                "estimated_value": 91000.0,
            
        
    
        
        
            
                "expected_close_at": new Date('2026-05-01T17:00:00Z'),
            
        
    
        
        
            
                "requirements": "Timber framing and trusses for 40x60 storage building",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "lead_code": "LEAD-1004",
            
        
    
        
        
            
                "name": "Coastal Cottages Phase 1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "partner",
            
        
    
        
        
            
                "status": "contacted",
            
        
    
        
        
            
                "estimated_value": 128000.0,
            
        
    
        
        
            
                "expected_close_at": new Date('2026-04-22T17:00:00Z'),
            
        
    
        
        
            
                "requirements": "Frames for 4 small cottages, staged deliveries",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const QuotesData = [
    
    {
    
        
        
            
                "quote_number": "Q-2026-001",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "issue_date": new Date('2026-03-20T00:00:00Z'),
            
        
    
        
        
            
                "valid_until": new Date('2026-04-20T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 16500.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "discount_amount": 500.0,
            
        
    
        
        
            
                "total": 16000.0,
            
        
    
        
        
            
                "terms": "50 percent deposit, balance due on delivery",
            
        
    
        
        
            
                "notes": "Includes basic connectors and fasteners allowance",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "quote_number": "Q-2026-002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "sent",
            
        
    
        
        
            
                "issue_date": new Date('2026-03-22T00:00:00Z'),
            
        
    
        
        
            
                "valid_until": new Date('2026-04-06T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 60000.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "discount_amount": 0.0,
            
        
    
        
        
            
                "total": 60000.0,
            
        
    
        
        
            
                "terms": "Net 30 from invoice date",
            
        
    
        
        
            
                "notes": "Pricing assumes customer provides site crane",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "quote_number": "Q-2026-003",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "issue_date": new Date('2026-03-18T00:00:00Z'),
            
        
    
        
        
            
                "valid_until": new Date('2026-04-17T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 73500.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "discount_amount": 0.0,
            
        
    
        
        
            
                "total": 73500.0,
            
        
    
        
        
            
                "terms": "Progress billing: 40/40/20",
            
        
    
        
        
            
                "notes": "Delivery staged in two loads",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "quote_number": "Q-2026-004",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "expired",
            
        
    
        
        
            
                "issue_date": new Date('2026-03-26T00:00:00Z'),
            
        
    
        
        
            
                "valid_until": new Date('2026-04-25T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 124000.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "discount_amount": 2000.0,
            
        
    
        
        
            
                "total": 122000.0,
            
        
    
        
        
            
                "terms": "Deposit required to release to production",
            
        
    
        
        
            
                "notes": "Includes hurricane ties and coastal hardware package",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const QuoteLineItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Floor frame, wall frames, and roof framing package",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "unit_price": 16000.0,
            
        
    
        
        
            
                "line_total": 16000.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Prebuilt wall panels including sheathing",
            
        
    
        
        
            
                "quantity": 48.0,
            
        
    
        
        
            
                "unit_price": 1250.0,
            
        
    
        
        
            
                "line_total": 60000.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Complete frame package including trusses",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "unit_price": 73500.0,
            
        
    
        
        
            
                "line_total": 73500.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Frame package with coastal hardware",
            
        
    
        
        
            
                "quantity": 4.0,
            
        
    
        
        
            
                "unit_price": 30500.0,
            
        
    
        
        
            
                "line_total": 122000.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
];



const ProjectsData = [
    
    {
    
        
        
            
                "project_number": "PRJ-2026-007",
            
        
    
        
        
            
                "name": "Riverbend Lot 7",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "start_at": new Date('2026-03-25T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-04-30T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-05-05T00:00:00Z'),
            
        
    
        
        
            
                "site_address": "Lot 7, 88 Pine Loop, Springfield, OR 97477",
            
        
    
        
        
            
                "budget_amount": 61000.0,
            
        
    
        
        
            
                "contract_amount": 73500.0,
            
        
    
        
        
            
                "notes": "Staged delivery and onsite unload required",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "project_number": "PRJ-2026-008",
            
        
    
        
        
            
                "name": "Summit Ridge Cabin",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "installed",
            
        
    
        
        
            
                "start_at": new Date('2026-04-10T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-05-20T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-05-22T00:00:00Z'),
            
        
    
        
        
            
                "site_address": "913 Ridgeview Dr, Portland, OR 97205",
            
        
    
        
        
            
                "budget_amount": 13000.0,
            
        
    
        
        
            
                "contract_amount": 16000.0,
            
        
    
        
        
            
                "notes": "Customer requested delivery on weekday morning",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "project_number": "PRJ-2026-009",
            
        
    
        
        
            
                "name": "Cedar Grove Duplex Panels A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "start_at": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-04-25T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-28T00:00:00Z'),
            
        
    
        
        
            
                "site_address": "1250 Industrial Way, Salem, OR 97301",
            
        
    
        
        
            
                "budget_amount": 52000.0,
            
        
    
        
        
            
                "contract_amount": 60000.0,
            
        
    
        
        
            
                "notes": "Awaiting final window schedule",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "project_number": "PRJ-2026-010",
            
        
    
        
        
            
                "name": "Bluewater Coastal Cottages Phase 1",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "delivered",
            
        
    
        
        
            
                "start_at": new Date('2026-04-05T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-05-30T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-06-03T00:00:00Z'),
            
        
    
        
        
            
                "site_address": "501 Seaside Ct, Warrenton, OR 97146",
            
        
    
        
        
            
                "budget_amount": 98000.0,
            
        
    
        
        
            
                "contract_amount": 122000.0,
            
        
    
        
        
            
                "notes": "Hardware must meet coastal spec",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ProjectMilestonesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Finalize cut list",
            
        
    
        
        
            
                "status": "blocked",
            
        
    
        
        
            
                "planned_at": new Date('2026-03-28T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-03-29T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Cut list approved by PM",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Material delivery to shop",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "planned_at": new Date('2026-04-02T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-03T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Awaiting remaining connectors",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Customer deposit received",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "planned_at": new Date('2026-04-05T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-06T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Deposit required before release",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Coastal hardware verification",
            
        
    
        
        
            
                "status": "not_started",
            
        
    
        
        
            
                "planned_at": new Date('2026-04-10T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-11T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Verify hurricane ties and fasteners",
            
        
    
    },
    
];



const ProductsData = [
    
    {
    
        
        
            
                "sku": "PRD-CAB-1224",
            
        
    
        
        
            
                "name": "Cabin Frame Kit 12x24",
            
        
    
        
        
            
                "type": "frame_panel",
            
        
    
        
        
            
                "description": "Precut and assembled floor, wall, and roof framing components",
            
        
    
        
        
            
                "unit_price": 16000.0,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "sku": "PRD-WP-8FT",
            
        
    
        
        
            
                "name": "Wall Panel Standard 8ft",
            
        
    
        
        
            
                "type": "floor_frame",
            
        
    
        
        
            
                "description": "Standard 8 foot wall panel with optional sheathing",
            
        
    
        
        
            
                "unit_price": 1250.0,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "sku": "PRD-HFP-2BR",
            
        
    
        
        
            
                "name": "House Frame Package 2BR",
            
        
    
        
        
            
                "type": "floor_frame",
            
        
    
        
        
            
                "description": "Complete frame package for typical 2 bedroom layout",
            
        
    
        
        
            
                "unit_price": 73500.0,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "sku": "PRD-COT-1BR",
            
        
    
        
        
            
                "name": "Cottage Frame Package 1BR",
            
        
    
        
        
            
                "type": "truss",
            
        
    
        
        
            
                "description": "Compact cottage frame package with coastal hardware option",
            
        
    
        
        
            
                "unit_price": 30500.0,
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const MaterialsData = [
    
    {
    
        
        
            
                "material_code": "MAT-2X4-SPF",
            
        
    
        
        
            
                "name": "2x4 SPF Stud 8ft",
            
        
    
        
        
            
                "category": "adhesives",
            
        
    
        
        
            
                "uom": "each",
            
        
    
        
        
            
                "standard_cost": 3.25,
            
        
    
        
        
            
                "last_cost": 3.4,
            
        
    
        
        
            
                "sale_price": 4.75,
            
        
    
        
        
            
                "reorder_point": 400.0,
            
        
    
        
        
            
                "stocked": true,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                "notes": "Primary stud stock",
            
        
    
    },
    
    {
    
        
        
            
                "material_code": "MAT-OSB-716",
            
        
    
        
        
            
                "name": "OSB Sheathing 7/16",
            
        
    
        
        
            
                "category": "lumber",
            
        
    
        
        
            
                "uom": "sheet",
            
        
    
        
        
            
                "standard_cost": 11.5,
            
        
    
        
        
            
                "last_cost": 12.1,
            
        
    
        
        
            
                "sale_price": 16.0,
            
        
    
        
        
            
                "reorder_point": 120.0,
            
        
    
        
        
            
                "stocked": true,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                "notes": "4x8 sheets",
            
        
    
    },
    
    {
    
        
        
            
                "material_code": "MAT-NAIL-16D",
            
        
    
        
        
            
                "name": "16D Framing Nails 50lb",
            
        
    
        
        
            
                "category": "adhesives",
            
        
    
        
        
            
                "uom": "box",
            
        
    
        
        
            
                "standard_cost": 62.0,
            
        
    
        
        
            
                "last_cost": 64.5,
            
        
    
        
        
            
                "sale_price": 85.0,
            
        
    
        
        
            
                "reorder_point": 10.0,
            
        
    
        
        
            
                "stocked": true,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                "notes": "Hot dipped galvanized preferred",
            
        
    
    },
    
    {
    
        
        
            
                "material_code": "MAT-TIE-H2A",
            
        
    
        
        
            
                "name": "H2.5A Hurricane Tie",
            
        
    
        
        
            
                "category": "hardware",
            
        
    
        
        
            
                "uom": "each",
            
        
    
        
        
            
                "standard_cost": 1.1,
            
        
    
        
        
            
                "last_cost": 1.18,
            
        
    
        
        
            
                "sale_price": 1.75,
            
        
    
        
        
            
                "reorder_point": 800.0,
            
        
    
        
        
            
                "stocked": true,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                "notes": "Coastal spec hardware",
            
        
    
    },
    
];



const SuppliersData = [
    
    {
    
        
        
            
                "supplier_code": "SUP-001",
            
        
    
        
        
            
                "name": "Cascade Lumber Supply",
            
        
    
        
        
            
                "email": "sales@cascadelumber.com",
            
        
    
        
        
            
                "phone": "+1-503-555-0201",
            
        
    
        
        
            
                "address": "300 Mill Rd, Salem, OR 97301",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "notes": "Primary SPF lumber supplier",
            
        
    
    },
    
    {
    
        
        
            
                "supplier_code": "SUP-002",
            
        
    
        
        
            
                "name": "Northwest Sheet Goods",
            
        
    
        
        
            
                "email": "orders@nwsheetgoods.com",
            
        
    
        
        
            
                "phone": "+1-503-555-0202",
            
        
    
        
        
            
                "address": "910 Warehouse Ave, Portland, OR 97217",
            
        
    
        
        
            
                "status": "on_hold",
            
        
    
        
        
            
                "notes": "OSB and plywood deliveries twice weekly",
            
        
    
    },
    
    {
    
        
        
            
                "supplier_code": "SUP-003",
            
        
    
        
        
            
                "name": "FastenPro Wholesale",
            
        
    
        
        
            
                "email": "support@fastenpro.com",
            
        
    
        
        
            
                "phone": "+1-360-555-0203",
            
        
    
        
        
            
                "address": "55 Industrial Park, Vancouver, WA 98660",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "notes": "Fasteners and adhesives",
            
        
    
    },
    
    {
    
        
        
            
                "supplier_code": "SUP-004",
            
        
    
        
        
            
                "name": "Simpson Connector Depot",
            
        
    
        
        
            
                "email": "orders@connector-depot.com",
            
        
    
        
        
            
                "phone": "+1-425-555-0204",
            
        
    
        
        
            
                "address": "1200 Steel St, Tacoma, WA 98402",
            
        
    
        
        
            
                "status": "inactive",
            
        
    
        
        
            
                "notes": "Metal connectors and ties",
            
        
    
    },
    
];



const InventoryLocationsData = [
    
    {
    
        
        
            
                "code": "LOC-YARD",
            
        
    
        
        
            
                "name": "Main Yard",
            
        
    
        
        
            
                "type": "yard",
            
        
    
        
        
            
                "address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "code": "LOC-WH1",
            
        
    
        
        
            
                "name": "Warehouse 1",
            
        
    
        
        
            
                "type": "vehicle",
            
        
    
        
        
            
                "address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "code": "LOC-SHOP",
            
        
    
        
        
            
                "name": "Production Shop",
            
        
    
        
        
            
                "type": "vehicle",
            
        
    
        
        
            
                "address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "code": "LOC-SITE-RB7",
            
        
    
        
        
            
                "name": "Job Site Riverbend Lot 7",
            
        
    
        
        
            
                "type": "job_site",
            
        
    
        
        
            
                "address": "88 Pine Loop, Springfield, OR 97477",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const InventoryItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand_qty": 2200.0,
            
        
    
        
        
            
                "allocated_qty": 600.0,
            
        
    
        
        
            
                "available_qty": 1600.0,
            
        
    
        
        
            
                "average_cost": 3.32,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-03-15T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand_qty": 480.0,
            
        
    
        
        
            
                "allocated_qty": 160.0,
            
        
    
        
        
            
                "available_qty": 320.0,
            
        
    
        
        
            
                "average_cost": 11.8,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-03-15T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand_qty": 42.0,
            
        
    
        
        
            
                "allocated_qty": 8.0,
            
        
    
        
        
            
                "available_qty": 34.0,
            
        
    
        
        
            
                "average_cost": 63.1,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-03-10T00:00:00Z'),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand_qty": 3100.0,
            
        
    
        
        
            
                "allocated_qty": 1200.0,
            
        
    
        
        
            
                "available_qty": 1900.0,
            
        
    
        
        
            
                "average_cost": 1.14,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-03-15T00:00:00Z'),
            
        
    
    },
    
];



const InventoryTransactionsData = [
    
    {
    
        
        
            
                "transaction_type": "adjustment",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 1200.0,
            
        
    
        
        
            
                "unit_cost": 3.4,
            
        
    
        
        
            
                "transaction_at": new Date('2026-03-18T14:00:00Z'),
            
        
    
        
        
            
                "reference": "PO QTY RECEIPT 0001",
            
        
    
        
        
            
                "notes": "Received full bundle shipment",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transaction_type": "receipt",
            
        
    
        
        
            
                // 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": 12.1,
            
        
    
        
        
            
                "transaction_at": new Date('2026-03-19T15:10:00Z'),
            
        
    
        
        
            
                "reference": "PO QTY RECEIPT 0002",
            
        
    
        
        
            
                "notes": "Partial receipt, remainder due next week",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transaction_type": "transfer",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 800.0,
            
        
    
        
        
            
                "unit_cost": 1.18,
            
        
    
        
        
            
                "transaction_at": new Date('2026-03-23T07:30:00Z'),
            
        
    
        
        
            
                "reference": "WO ISSUE RB7 0001",
            
        
    
        
        
            
                "notes": "Issued to Riverbend work order",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transaction_type": "issue",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 6.0,
            
        
    
        
        
            
                "unit_cost": 64.5,
            
        
    
        
        
            
                "transaction_at": new Date('2026-03-24T08:00:00Z'),
            
        
    
        
        
            
                "reference": "SHOP RESTOCK 0003",
            
        
    
        
        
            
                "notes": "Moved nails to shop cage",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const BomsData = [
    
    {
    
        
        
            
                "bom_code": "BOM-WP-8FT-A",
            
        
    
        
        
            
                "name": "Wall Panel 8ft Standard BOM",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "yield_qty": 1.0,
            
        
    
        
        
            
                "notes": "Stud layout based on 16 inch on center",
            
        
    
    },
    
    {
    
        
        
            
                "bom_code": "BOM-CAB-1224-A",
            
        
    
        
        
            
                "name": "Cabin Kit 12x24 BOM",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "active",
            
        
    
        
        
            
                "yield_qty": 1.0,
            
        
    
        
        
            
                "notes": "Includes connectors allowance",
            
        
    
    },
    
    {
    
        
        
            
                "bom_code": "BOM-H2A-COAST",
            
        
    
        
        
            
                "name": "Coastal Hardware Addon BOM",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "yield_qty": 1.0,
            
        
    
        
        
            
                "notes": "Hurricane ties and coastal fasteners",
            
        
    
    },
    
    {
    
        
        
            
                "bom_code": "BOM-HFP-2BR-A",
            
        
    
        
        
            
                "name": "House Frame 2BR BOM",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "yield_qty": 1.0,
            
        
    
        
        
            
                "notes": "Pending engineering review",
            
        
    
    },
    
];



const BomItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Studs and plates for one 8ft panel",
            
        
    
        
        
            
                "quantity_per": 10.0,
            
        
    
        
        
            
                "scrap_factor": 0.05,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Sheathing for one 8ft panel",
            
        
    
        
        
            
                "quantity_per": 1.0,
            
        
    
        
        
            
                "scrap_factor": 0.03,
            
        
    
        
        
            
                "sort_order": 2,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Studs and framing members for cabin kit",
            
        
    
        
        
            
                "quantity_per": 240.0,
            
        
    
        
        
            
                "scrap_factor": 0.08,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Framing nails allocation for cabin kit",
            
        
    
        
        
            
                "quantity_per": 2.0,
            
        
    
        
        
            
                "scrap_factor": 0.0,
            
        
    
        
        
            
                "sort_order": 2,
            
        
    
    },
    
];



const PurchaseOrdersData = [
    
    {
    
        
        
            
                "po_number": "PO-2026-0301",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "order_date": new Date('2026-03-18T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-03-25T15:00:00Z'),
            
        
    
        
        
            
                "subtotal": 4080.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "shipping_amount": 120.0,
            
        
    
        
        
            
                "total": 4200.0,
            
        
    
        
        
            
                "ship_to_address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "notes": "Call ahead one hour prior to arrival",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-0302",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "order_date": new Date('2026-03-19T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-03-27T15:00:00Z'),
            
        
    
        
        
            
                "subtotal": 2420.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "shipping_amount": 80.0,
            
        
    
        
        
            
                "total": 2500.0,
            
        
    
        
        
            
                "ship_to_address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "notes": "Deliver to dock door 2",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-0303",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "partially_received",
            
        
    
        
        
            
                "order_date": new Date('2026-03-24T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-04-02T15:00:00Z'),
            
        
    
        
        
            
                "subtotal": 680.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "shipping_amount": 40.0,
            
        
    
        
        
            
                "total": 720.0,
            
        
    
        
        
            
                "ship_to_address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "notes": "Include adhesive and nail stock",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-0304",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "received",
            
        
    
        
        
            
                "order_date": new Date('2026-03-25T00:00:00Z'),
            
        
    
        
        
            
                "expected_delivery_at": new Date('2026-04-01T15:00:00Z'),
            
        
    
        
        
            
                "subtotal": 1416.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "shipping_amount": 84.0,
            
        
    
        
        
            
                "total": 1500.0,
            
        
    
        
        
            
                "ship_to_address": "4500 Shop Rd, Portland, OR 97203",
            
        
    
        
        
            
                "notes": "Coastal ties and connectors",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PurchaseOrderLineItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "SPF studs 8ft",
            
        
    
        
        
            
                "quantity_ordered": 1200.0,
            
        
    
        
        
            
                "quantity_received": 1200.0,
            
        
    
        
        
            
                "unit_cost": 3.4,
            
        
    
        
        
            
                "line_total": 4080.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "OSB 7/16 4x8 sheets",
            
        
    
        
        
            
                "quantity_ordered": 200.0,
            
        
    
        
        
            
                "quantity_received": 200.0,
            
        
    
        
        
            
                "unit_cost": 12.1,
            
        
    
        
        
            
                "line_total": 2420.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "16D framing nails 50lb boxes",
            
        
    
        
        
            
                "quantity_ordered": 8.0,
            
        
    
        
        
            
                "quantity_received": 0.0,
            
        
    
        
        
            
                "unit_cost": 64.5,
            
        
    
        
        
            
                "line_total": 516.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "H2.5A hurricane ties",
            
        
    
        
        
            
                "quantity_ordered": 1200.0,
            
        
    
        
        
            
                "quantity_received": 0.0,
            
        
    
        
        
            
                "unit_cost": 1.18,
            
        
    
        
        
            
                "line_total": 1416.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
];



const GoodsReceiptsData = [
    
    {
    
        
        
            
                "grn_number": "GRN-2026-0101",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "received_at": new Date('2026-03-25T14:45:00Z'),
            
        
    
        
        
            
                "carrier": "Cascade Lumber Trucking",
            
        
    
        
        
            
                "tracking_number": "CL-884120",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Bundles inspected, no damage noted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "grn_number": "GRN-2026-0102",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "received_at": new Date('2026-03-27T15:05:00Z'),
            
        
    
        
        
            
                "carrier": "NW Sheet Freight",
            
        
    
        
        
            
                "tracking_number": "NWS-55019",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "All sheets received and stacked",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "grn_number": "GRN-2026-0103",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "received_at": new Date('2026-04-02T15:15:00Z'),
            
        
    
        
        
            
                "carrier": "FastenPro Courier",
            
        
    
        
        
            
                "tracking_number": "FP-10291",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Awaiting packing slip match",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "grn_number": "GRN-2026-0104",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "posted",
            
        
    
        
        
            
                "received_at": new Date('2026-04-01T15:20:00Z'),
            
        
    
        
        
            
                "carrier": "Connector Depot Freight",
            
        
    
        
        
            
                "tracking_number": "CD-77821",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Count ties on arrival",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const WorkOrdersData = [
    
    {
    
        
        
            
                "work_order_number": "WO-2026-0201",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "released",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-04-01T07:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-04-10T17:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-04-01T07:15:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-04-11T16:30:00Z'),
            
        
    
        
        
            
                "planned_qty": 1.0,
            
        
    
        
        
            
                "completed_qty": 1.0,
            
        
    
        
        
            
                "instructions": "Build wall frames first, then truss prep",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "WO-2026-0202",
            
        
    
        
        
            
                // 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_start_at": new Date('2026-04-08T07:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-04-18T17:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-04-08T07:10:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-04-19T16:00:00Z'),
            
        
    
        
        
            
                "planned_qty": 48.0,
            
        
    
        
        
            
                "completed_qty": 0.0,
            
        
    
        
        
            
                "instructions": "Stage panels by unit and label clearly",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "WO-2026-0203",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-04-15T07:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-04-24T17:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-04-15T07:05:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-04-25T15:45:00Z'),
            
        
    
        
        
            
                "planned_qty": 1.0,
            
        
    
        
        
            
                "completed_qty": 0.6,
            
        
    
        
        
            
                "instructions": "Confirm floor joist spacing with customer plan",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "work_order_number": "WO-2026-0204",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "scheduled_start_at": new Date('2026-04-12T07:00:00Z'),
            
        
    
        
        
            
                "scheduled_end_at": new Date('2026-04-30T17:00:00Z'),
            
        
    
        
        
            
                "actual_start_at": new Date('2026-04-12T07:20:00Z'),
            
        
    
        
        
            
                "actual_end_at": new Date('2026-05-01T16:10:00Z'),
            
        
    
        
        
            
                "planned_qty": 4.0,
            
        
    
        
        
            
                "completed_qty": 2.0,
            
        
    
        
        
            
                "instructions": "Verify coastal hardware on each bundle",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const WorkOrderMaterialsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_qty": 480.0,
            
        
    
        
        
            
                "issued_qty": 0.0,
            
        
    
        
        
            
                "scrap_qty": 0.0,
            
        
    
        
        
            
                "notes": "Issue in stages to keep shop clear",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_qty": 48.0,
            
        
    
        
        
            
                "issued_qty": 0.0,
            
        
    
        
        
            
                "scrap_qty": 0.0,
            
        
    
        
        
            
                "notes": "Sheathing only for specified panels",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_qty": 2.0,
            
        
    
        
        
            
                "issued_qty": 1.0,
            
        
    
        
        
            
                "scrap_qty": 0.0,
            
        
    
        
        
            
                "notes": "Keep one box in nail cage",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "required_qty": 880.0,
            
        
    
        
        
            
                "issued_qty": 800.0,
            
        
    
        
        
            
                "scrap_qty": 10.0,
            
        
    
        
        
            
                "notes": "Scrap due to bent ties",
            
        
    
    },
    
];



const DeliveriesData = [
    
    {
    
        
        
            
                "delivery_number": "DEL-2026-0041",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "planned_ship_at": new Date('2026-04-12T15:00:00Z'),
            
        
    
        
        
            
                "planned_delivery_at": new Date('2026-04-13T16:00:00Z'),
            
        
    
        
        
            
                "delivered_at": new Date('2026-04-13T16:20:00Z'),
            
        
    
        
        
            
                "ship_to_address": "Lot 7, 88 Pine Loop, Springfield, OR 97477",
            
        
    
        
        
            
                "carrier": "Westernframers Truck",
            
        
    
        
        
            
                "tracking_number": "WF-TRK1-0413A",
            
        
    
        
        
            
                "shipping_cost": 650.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "First staged load with wall panels",
            
        
    
    },
    
    {
    
        
        
            
                "delivery_number": "DEL-2026-0042",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "shipped",
            
        
    
        
        
            
                "planned_ship_at": new Date('2026-04-18T15:00:00Z'),
            
        
    
        
        
            
                "planned_delivery_at": new Date('2026-04-19T16:00:00Z'),
            
        
    
        
        
            
                "delivered_at": new Date('2026-04-19T16:10:00Z'),
            
        
    
        
        
            
                "ship_to_address": "Lot 7, 88 Pine Loop, Springfield, OR 97477",
            
        
    
        
        
            
                "carrier": "Westernframers Truck",
            
        
    
        
        
            
                "tracking_number": "WF-TRK1-0419B",
            
        
    
        
        
            
                "shipping_cost": 650.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Second load with trusses and hardware",
            
        
    
    },
    
    {
    
        
        
            
                "delivery_number": "DEL-2026-0043",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "planned_ship_at": new Date('2026-05-01T15:00:00Z'),
            
        
    
        
        
            
                "planned_delivery_at": new Date('2026-05-02T16:00:00Z'),
            
        
    
        
        
            
                "delivered_at": new Date('2026-05-02T16:05:00Z'),
            
        
    
        
        
            
                "ship_to_address": "913 Ridgeview Dr, Portland, OR 97205",
            
        
    
        
        
            
                "carrier": "Westernframers Truck",
            
        
    
        
        
            
                "tracking_number": "WF-TRK1-0502A",
            
        
    
        
        
            
                "shipping_cost": 450.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Call customer 30 minutes before arrival",
            
        
    
    },
    
    {
    
        
        
            
                "delivery_number": "DEL-2026-0044",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "shipped",
            
        
    
        
        
            
                "planned_ship_at": new Date('2026-04-22T15:00:00Z'),
            
        
    
        
        
            
                "planned_delivery_at": new Date('2026-04-23T16:00:00Z'),
            
        
    
        
        
            
                "delivered_at": new Date('2026-04-23T16:00:00Z'),
            
        
    
        
        
            
                "ship_to_address": "1250 Industrial Way, Salem, OR 97301",
            
        
    
        
        
            
                "carrier": "Westernframers Truck",
            
        
    
        
        
            
                "tracking_number": "WF-TRK1-0423X",
            
        
    
        
        
            
                "shipping_cost": 500.0,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Cancelled due to drawing revisions",
            
        
    
    },
    
];



const DeliveryItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Wall panels bundle A",
            
        
    
        
        
            
                "quantity": 12.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Sheathing sheets for bundle A",
            
        
    
        
        
            
                "quantity": 24.0,
            
        
    
        
        
            
                "sort_order": 2,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Hardware box and connectors",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Cabin kit bundles and fasteners",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
];



const InvoicesData = [
    
    {
    
        
        
            
                "invoice_number": "INV-2026-0101",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "sent",
            
        
    
        
        
            
                "issue_date": new Date('2026-03-29T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-28T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 29400.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "total": 29400.0,
            
        
    
        
        
            
                "balance_due": 29400.0,
            
        
    
        
        
            
                "notes": "First progress billing 40 percent",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "INV-2026-0102",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "issue_date": new Date('2026-04-12T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-05-12T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 29400.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "total": 29400.0,
            
        
    
        
        
            
                "balance_due": 14400.0,
            
        
    
        
        
            
                "notes": "Second progress billing 40 percent",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "INV-2026-0103",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "sent",
            
        
    
        
        
            
                "issue_date": new Date('2026-04-10T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-04-10T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 8000.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "total": 8000.0,
            
        
    
        
        
            
                "balance_due": 8000.0,
            
        
    
        
        
            
                "notes": "Deposit invoice",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "INV-2026-0104",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "paid",
            
        
    
        
        
            
                "issue_date": new Date('2026-04-06T00:00:00Z'),
            
        
    
        
        
            
                "due_date": new Date('2026-05-06T00:00:00Z'),
            
        
    
        
        
            
                "subtotal": 48800.0,
            
        
    
        
        
            
                "tax_amount": 0.0,
            
        
    
        
        
            
                "total": 48800.0,
            
        
    
        
        
            
                "balance_due": 48800.0,
            
        
    
        
        
            
                "notes": "Deposit to release production",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const InvoiceLineItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Progress billing - materials and production phase 1",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "unit_price": 29400.0,
            
        
    
        
        
            
                "line_total": 29400.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Progress billing - production phase 2",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "unit_price": 29400.0,
            
        
    
        
        
            
                "line_total": 29400.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Deposit for cabin frame kit",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "unit_price": 8000.0,
            
        
    
        
        
            
                "line_total": 8000.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Deposit for coastal cottage frames",
            
        
    
        
        
            
                "quantity": 1.0,
            
        
    
        
        
            
                "unit_price": 48800.0,
            
        
    
        
        
            
                "line_total": 48800.0,
            
        
    
        
        
            
                "sort_order": 1,
            
        
    
    },
    
];



const PaymentsData = [
    
    {
    
        
        
            
                "payment_reference": "PAY-2026-0001",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "amount": 15000.0,
            
        
    
        
        
            
                "paid_at": new Date('2026-04-20T16:00:00Z'),
            
        
    
        
        
            
                "method": "card",
            
        
    
        
        
            
                "transaction_id": "RB-TRX-88411",
            
        
    
        
        
            
                "notes": "Partial payment received",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "payment_reference": "PAY-2026-0002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "amount": 29400.0,
            
        
    
        
        
            
                "paid_at": new Date('2026-04-10T10:30:00Z'),
            
        
    
        
        
            
                "method": "other",
            
        
    
        
        
            
                "transaction_id": "RB-TRX-88201",
            
        
    
        
        
            
                "notes": "Paid in full",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "payment_reference": "PAY-2026-0003",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "amount": 8000.0,
            
        
    
        
        
            
                "paid_at": new Date('2026-04-10T14:15:00Z'),
            
        
    
        
        
            
                "method": "other",
            
        
    
        
        
            
                "transaction_id": "SR-CC-10021",
            
        
    
        
        
            
                "notes": "Deposit paid via card",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "payment_reference": "PAY-2026-0004",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "amount": 48800.0,
            
        
    
        
        
            
                "paid_at": new Date('2026-04-12T12:05:00Z'),
            
        
    
        
        
            
                "method": "check",
            
        
    
        
        
            
                "transaction_id": "BW-TRX-22019",
            
        
    
        
        
            
                "notes": "Deposit received, release to shop",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const DocumentsData = [
    
    {
    
        
        
            
                "entity_type": "customer",
            
        
    
        
        
            
                "entity_reference": "PRJ-2026-007",
            
        
    
        
        
            
                "name": "Riverbend Lot 7 Contract",
            
        
    
        
        
            
                "category": "specification",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "document_date": new Date('2026-03-18T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Signed contract and scope",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "entity_type": "invoice",
            
        
    
        
        
            
                "entity_reference": "Q-2026-001",
            
        
    
        
        
            
                "name": "Summit Ridge Cabin Quote PDF",
            
        
    
        
        
            
                "category": "drawing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "document_date": new Date('2026-03-20T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Sent to customer via email",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "entity_type": "customer",
            
        
    
        
        
            
                "entity_reference": "WO-2026-0203",
            
        
    
        
        
            
                "name": "Cabin Cut List",
            
        
    
        
        
            
                "category": "specification",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "document_date": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Shop cut list for cabin kit",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "entity_type": "work_order",
            
        
    
        
        
            
                "entity_reference": "DEL-2026-0041",
            
        
    
        
        
            
                "name": "Proof of Delivery Riverbend Load 1",
            
        
    
        
        
            
                "category": "contract",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "document_date": new Date('2026-04-13T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Signed by site superintendent",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateContactWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Contact0 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Contact0?.setCustomer)
                {
                    await
                    Contact0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Contact1 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Contact1?.setCustomer)
                {
                    await
                    Contact1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Contact2 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Contact2?.setCustomer)
                {
                    await
                    Contact2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Contact3 = await Contacts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Contact3?.setCustomer)
                {
                    await
                    Contact3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateLeadWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setCustomer)
                {
                    await
                    Lead0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setCustomer)
                {
                    await
                    Lead1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setCustomer)
                {
                    await
                    Lead2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Lead3 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Lead3?.setCustomer)
                {
                    await
                    Lead3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateLeadWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead0 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Lead0?.setOwner)
                {
                    await
                    Lead0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead1 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Lead1?.setOwner)
                {
                    await
                    Lead1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead2 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Lead2?.setOwner)
                {
                    await
                    Lead2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Lead3 = await Leads.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Lead3?.setOwner)
                {
                    await
                    Lead3.
                    setOwner(relatedOwner3);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associateQuoteWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Quote0 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Quote0?.setCustomer)
                {
                    await
                    Quote0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Quote1 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Quote1?.setCustomer)
                {
                    await
                    Quote1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Quote2 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Quote2?.setCustomer)
                {
                    await
                    Quote2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Quote3 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Quote3?.setCustomer)
                {
                    await
                    Quote3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
            
            async function associateQuoteWithLead() {
            
                const relatedLead0 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Quote0 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Quote0?.setLead)
                {
                    await
                    Quote0.
                    setLead(relatedLead0);
                }
            
                const relatedLead1 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Quote1 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Quote1?.setLead)
                {
                    await
                    Quote1.
                    setLead(relatedLead1);
                }
            
                const relatedLead2 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Quote2 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Quote2?.setLead)
                {
                    await
                    Quote2.
                    setLead(relatedLead2);
                }
            
                const relatedLead3 = await Leads.findOne({
                    offset: Math.floor(Math.random() * (await Leads.count())),
                });
                const Quote3 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Quote3?.setLead)
                {
                    await
                    Quote3.
                    setLead(relatedLead3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateQuoteWithPrepared_by() {
            
                const relatedPrepared_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Quote0 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Quote0?.setPrepared_by)
                {
                    await
                    Quote0.
                    setPrepared_by(relatedPrepared_by0);
                }
            
                const relatedPrepared_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Quote1 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Quote1?.setPrepared_by)
                {
                    await
                    Quote1.
                    setPrepared_by(relatedPrepared_by1);
                }
            
                const relatedPrepared_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Quote2 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Quote2?.setPrepared_by)
                {
                    await
                    Quote2.
                    setPrepared_by(relatedPrepared_by2);
                }
            
                const relatedPrepared_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Quote3 = await Quotes.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Quote3?.setPrepared_by)
                {
                    await
                    Quote3.
                    setPrepared_by(relatedPrepared_by3);
                }
            
        }
        
    

    
    
    
        
            
            async function associateQuoteLineItemWithQuote() {
            
                const relatedQuote0 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const QuoteLineItem0 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QuoteLineItem0?.setQuote)
                {
                    await
                    QuoteLineItem0.
                    setQuote(relatedQuote0);
                }
            
                const relatedQuote1 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const QuoteLineItem1 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QuoteLineItem1?.setQuote)
                {
                    await
                    QuoteLineItem1.
                    setQuote(relatedQuote1);
                }
            
                const relatedQuote2 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const QuoteLineItem2 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QuoteLineItem2?.setQuote)
                {
                    await
                    QuoteLineItem2.
                    setQuote(relatedQuote2);
                }
            
                const relatedQuote3 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const QuoteLineItem3 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QuoteLineItem3?.setQuote)
                {
                    await
                    QuoteLineItem3.
                    setQuote(relatedQuote3);
                }
            
        }
        
    
        
            
            async function associateQuoteLineItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const QuoteLineItem0 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (QuoteLineItem0?.setProduct)
                {
                    await
                    QuoteLineItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const QuoteLineItem1 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (QuoteLineItem1?.setProduct)
                {
                    await
                    QuoteLineItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const QuoteLineItem2 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (QuoteLineItem2?.setProduct)
                {
                    await
                    QuoteLineItem2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const QuoteLineItem3 = await QuoteLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (QuoteLineItem3?.setProduct)
                {
                    await
                    QuoteLineItem3.
                    setProduct(relatedProduct3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateProjectWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Project0 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Project0?.setCustomer)
                {
                    await
                    Project0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Project1 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Project1?.setCustomer)
                {
                    await
                    Project1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Project2 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Project2?.setCustomer)
                {
                    await
                    Project2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Project3 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Project3?.setCustomer)
                {
                    await
                    Project3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
            
            async function associateProjectWithQuote() {
            
                const relatedQuote0 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Project0 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Project0?.setQuote)
                {
                    await
                    Project0.
                    setQuote(relatedQuote0);
                }
            
                const relatedQuote1 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Project1 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Project1?.setQuote)
                {
                    await
                    Project1.
                    setQuote(relatedQuote1);
                }
            
                const relatedQuote2 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Project2 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Project2?.setQuote)
                {
                    await
                    Project2.
                    setQuote(relatedQuote2);
                }
            
                const relatedQuote3 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Project3 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Project3?.setQuote)
                {
                    await
                    Project3.
                    setQuote(relatedQuote3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProjectWithProject_manager() {
            
                const relatedProject_manager0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Project0 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Project0?.setProject_manager)
                {
                    await
                    Project0.
                    setProject_manager(relatedProject_manager0);
                }
            
                const relatedProject_manager1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Project1 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Project1?.setProject_manager)
                {
                    await
                    Project1.
                    setProject_manager(relatedProject_manager1);
                }
            
                const relatedProject_manager2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Project2 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Project2?.setProject_manager)
                {
                    await
                    Project2.
                    setProject_manager(relatedProject_manager2);
                }
            
                const relatedProject_manager3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Project3 = await Projects.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Project3?.setProject_manager)
                {
                    await
                    Project3.
                    setProject_manager(relatedProject_manager3);
                }
            
        }
        
    

    
    
    
        
            
            async function associateProjectMilestoneWithProject() {
            
                const relatedProject0 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const ProjectMilestone0 = await ProjectMilestones.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ProjectMilestone0?.setProject)
                {
                    await
                    ProjectMilestone0.
                    setProject(relatedProject0);
                }
            
                const relatedProject1 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const ProjectMilestone1 = await ProjectMilestones.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ProjectMilestone1?.setProject)
                {
                    await
                    ProjectMilestone1.
                    setProject(relatedProject1);
                }
            
                const relatedProject2 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const ProjectMilestone2 = await ProjectMilestones.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ProjectMilestone2?.setProject)
                {
                    await
                    ProjectMilestone2.
                    setProject(relatedProject2);
                }
            
                const relatedProject3 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const ProjectMilestone3 = await ProjectMilestones.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ProjectMilestone3?.setProject)
                {
                    await
                    ProjectMilestone3.
                    setProject(relatedProject3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateInventoryItemWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setMaterial)
                {
                    await
                    InventoryItem0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setMaterial)
                {
                    await
                    InventoryItem1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setMaterial)
                {
                    await
                    InventoryItem2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryItem3 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryItem3?.setMaterial)
                {
                    await
                    InventoryItem3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
            
            async function associateInventoryItemWithLocation() {
            
                const relatedLocation0 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setLocation)
                {
                    await
                    InventoryItem0.
                    setLocation(relatedLocation0);
                }
            
                const relatedLocation1 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setLocation)
                {
                    await
                    InventoryItem1.
                    setLocation(relatedLocation1);
                }
            
                const relatedLocation2 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setLocation)
                {
                    await
                    InventoryItem2.
                    setLocation(relatedLocation2);
                }
            
                const relatedLocation3 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const InventoryItem3 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryItem3?.setLocation)
                {
                    await
                    InventoryItem3.
                    setLocation(relatedLocation3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateInventoryTransactionWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setMaterial)
                {
                    await
                    InventoryTransaction0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setMaterial)
                {
                    await
                    InventoryTransaction1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setMaterial)
                {
                    await
                    InventoryTransaction2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setMaterial)
                {
                    await
                    InventoryTransaction3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
            
            async function associateInventoryTransactionWithFrom_location() {
            
                const relatedFrom_location0 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.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 InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setTo_location)
                {
                    await
                    InventoryTransaction3.
                    setTo_location(relatedTo_location3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateInventoryTransactionWithCreated_by_user() {
            
                const relatedCreated_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction0 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryTransaction0?.setCreated_by_user)
                {
                    await
                    InventoryTransaction0.
                    setCreated_by_user(relatedCreated_by_user0);
                }
            
                const relatedCreated_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction1 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryTransaction1?.setCreated_by_user)
                {
                    await
                    InventoryTransaction1.
                    setCreated_by_user(relatedCreated_by_user1);
                }
            
                const relatedCreated_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction2 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryTransaction2?.setCreated_by_user)
                {
                    await
                    InventoryTransaction2.
                    setCreated_by_user(relatedCreated_by_user2);
                }
            
                const relatedCreated_by_user3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const InventoryTransaction3 = await InventoryTransactions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InventoryTransaction3?.setCreated_by_user)
                {
                    await
                    InventoryTransaction3.
                    setCreated_by_user(relatedCreated_by_user3);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
            
            async function associateBomWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Bom0 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Bom0?.setProduct)
                {
                    await
                    Bom0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Bom1 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Bom1?.setProduct)
                {
                    await
                    Bom1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Bom2 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Bom2?.setProduct)
                {
                    await
                    Bom2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Bom3 = await Boms.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Bom3?.setProduct)
                {
                    await
                    Bom3.
                    setProduct(relatedProduct3);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateBomItemWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomItem0 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomItem0?.setBom)
                {
                    await
                    BomItem0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomItem1 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomItem1?.setBom)
                {
                    await
                    BomItem1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomItem2 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomItem2?.setBom)
                {
                    await
                    BomItem2.
                    setBom(relatedBom2);
                }
            
                const relatedBom3 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const BomItem3 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (BomItem3?.setBom)
                {
                    await
                    BomItem3.
                    setBom(relatedBom3);
                }
            
        }
        
    
        
            
            async function associateBomItemWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const BomItem0 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (BomItem0?.setMaterial)
                {
                    await
                    BomItem0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const BomItem1 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (BomItem1?.setMaterial)
                {
                    await
                    BomItem1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const BomItem2 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (BomItem2?.setMaterial)
                {
                    await
                    BomItem2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const BomItem3 = await BomItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (BomItem3?.setMaterial)
                {
                    await
                    BomItem3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            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 associatePurchaseOrderWithProject() {
            
                const relatedProject0 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setProject)
                {
                    await
                    PurchaseOrder0.
                    setProject(relatedProject0);
                }
            
                const relatedProject1 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setProject)
                {
                    await
                    PurchaseOrder1.
                    setProject(relatedProject1);
                }
            
                const relatedProject2 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setProject)
                {
                    await
                    PurchaseOrder2.
                    setProject(relatedProject2);
                }
            
                const relatedProject3 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const PurchaseOrder3 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrder3?.setProject)
                {
                    await
                    PurchaseOrder3.
                    setProject(relatedProject3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePurchaseOrderWithBuyer() {
            
                const relatedBuyer0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setBuyer)
                {
                    await
                    PurchaseOrder0.
                    setBuyer(relatedBuyer0);
                }
            
                const relatedBuyer1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setBuyer)
                {
                    await
                    PurchaseOrder1.
                    setBuyer(relatedBuyer1);
                }
            
                const relatedBuyer2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setBuyer)
                {
                    await
                    PurchaseOrder2.
                    setBuyer(relatedBuyer2);
                }
            
                const relatedBuyer3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder3 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrder3?.setBuyer)
                {
                    await
                    PurchaseOrder3.
                    setBuyer(relatedBuyer3);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePurchaseOrderLineItemWithPurchase_order() {
            
                const relatedPurchase_order0 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLineItem0 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderLineItem0?.setPurchase_order)
                {
                    await
                    PurchaseOrderLineItem0.
                    setPurchase_order(relatedPurchase_order0);
                }
            
                const relatedPurchase_order1 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLineItem1 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderLineItem1?.setPurchase_order)
                {
                    await
                    PurchaseOrderLineItem1.
                    setPurchase_order(relatedPurchase_order1);
                }
            
                const relatedPurchase_order2 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLineItem2 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderLineItem2?.setPurchase_order)
                {
                    await
                    PurchaseOrderLineItem2.
                    setPurchase_order(relatedPurchase_order2);
                }
            
                const relatedPurchase_order3 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderLineItem3 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrderLineItem3?.setPurchase_order)
                {
                    await
                    PurchaseOrderLineItem3.
                    setPurchase_order(relatedPurchase_order3);
                }
            
        }
        
    
        
            
            async function associatePurchaseOrderLineItemWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const PurchaseOrderLineItem0 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderLineItem0?.setMaterial)
                {
                    await
                    PurchaseOrderLineItem0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const PurchaseOrderLineItem1 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderLineItem1?.setMaterial)
                {
                    await
                    PurchaseOrderLineItem1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const PurchaseOrderLineItem2 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderLineItem2?.setMaterial)
                {
                    await
                    PurchaseOrderLineItem2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const PurchaseOrderLineItem3 = await PurchaseOrderLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (PurchaseOrderLineItem3?.setMaterial)
                {
                    await
                    PurchaseOrderLineItem3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateGoodsReceiptWithPurchase_order() {
            
                const relatedPurchase_order0 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const GoodsReceipt0 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (GoodsReceipt0?.setPurchase_order)
                {
                    await
                    GoodsReceipt0.
                    setPurchase_order(relatedPurchase_order0);
                }
            
                const relatedPurchase_order1 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const GoodsReceipt1 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (GoodsReceipt1?.setPurchase_order)
                {
                    await
                    GoodsReceipt1.
                    setPurchase_order(relatedPurchase_order1);
                }
            
                const relatedPurchase_order2 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const GoodsReceipt2 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (GoodsReceipt2?.setPurchase_order)
                {
                    await
                    GoodsReceipt2.
                    setPurchase_order(relatedPurchase_order2);
                }
            
                const relatedPurchase_order3 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const GoodsReceipt3 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (GoodsReceipt3?.setPurchase_order)
                {
                    await
                    GoodsReceipt3.
                    setPurchase_order(relatedPurchase_order3);
                }
            
        }
        
    
        
            
            async function associateGoodsReceiptWithReceived_to_location() {
            
                const relatedReceived_to_location0 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const GoodsReceipt0 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (GoodsReceipt0?.setReceived_to_location)
                {
                    await
                    GoodsReceipt0.
                    setReceived_to_location(relatedReceived_to_location0);
                }
            
                const relatedReceived_to_location1 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const GoodsReceipt1 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (GoodsReceipt1?.setReceived_to_location)
                {
                    await
                    GoodsReceipt1.
                    setReceived_to_location(relatedReceived_to_location1);
                }
            
                const relatedReceived_to_location2 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const GoodsReceipt2 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (GoodsReceipt2?.setReceived_to_location)
                {
                    await
                    GoodsReceipt2.
                    setReceived_to_location(relatedReceived_to_location2);
                }
            
                const relatedReceived_to_location3 = await InventoryLocations.findOne({
                    offset: Math.floor(Math.random() * (await InventoryLocations.count())),
                });
                const GoodsReceipt3 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (GoodsReceipt3?.setReceived_to_location)
                {
                    await
                    GoodsReceipt3.
                    setReceived_to_location(relatedReceived_to_location3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateGoodsReceiptWithReceived_by() {
            
                const relatedReceived_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const GoodsReceipt0 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (GoodsReceipt0?.setReceived_by)
                {
                    await
                    GoodsReceipt0.
                    setReceived_by(relatedReceived_by0);
                }
            
                const relatedReceived_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const GoodsReceipt1 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (GoodsReceipt1?.setReceived_by)
                {
                    await
                    GoodsReceipt1.
                    setReceived_by(relatedReceived_by1);
                }
            
                const relatedReceived_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const GoodsReceipt2 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (GoodsReceipt2?.setReceived_by)
                {
                    await
                    GoodsReceipt2.
                    setReceived_by(relatedReceived_by2);
                }
            
                const relatedReceived_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const GoodsReceipt3 = await GoodsReceipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (GoodsReceipt3?.setReceived_by)
                {
                    await
                    GoodsReceipt3.
                    setReceived_by(relatedReceived_by3);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associateWorkOrderWithProject() {
            
                const relatedProject0 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const WorkOrder0 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkOrder0?.setProject)
                {
                    await
                    WorkOrder0.
                    setProject(relatedProject0);
                }
            
                const relatedProject1 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const WorkOrder1 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkOrder1?.setProject)
                {
                    await
                    WorkOrder1.
                    setProject(relatedProject1);
                }
            
                const relatedProject2 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const WorkOrder2 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkOrder2?.setProject)
                {
                    await
                    WorkOrder2.
                    setProject(relatedProject2);
                }
            
                const relatedProject3 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const WorkOrder3 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkOrder3?.setProject)
                {
                    await
                    WorkOrder3.
                    setProject(relatedProject3);
                }
            
        }
        
    
        
            
            async function associateWorkOrderWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const WorkOrder0 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkOrder0?.setProduct)
                {
                    await
                    WorkOrder0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const WorkOrder1 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkOrder1?.setProduct)
                {
                    await
                    WorkOrder1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const WorkOrder2 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkOrder2?.setProduct)
                {
                    await
                    WorkOrder2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const WorkOrder3 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkOrder3?.setProduct)
                {
                    await
                    WorkOrder3.
                    setProduct(relatedProduct3);
                }
            
        }
        
    
        
            
            async function associateWorkOrderWithBom() {
            
                const relatedBom0 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const WorkOrder0 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkOrder0?.setBom)
                {
                    await
                    WorkOrder0.
                    setBom(relatedBom0);
                }
            
                const relatedBom1 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const WorkOrder1 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkOrder1?.setBom)
                {
                    await
                    WorkOrder1.
                    setBom(relatedBom1);
                }
            
                const relatedBom2 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const WorkOrder2 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkOrder2?.setBom)
                {
                    await
                    WorkOrder2.
                    setBom(relatedBom2);
                }
            
                const relatedBom3 = await Boms.findOne({
                    offset: Math.floor(Math.random() * (await Boms.count())),
                });
                const WorkOrder3 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkOrder3?.setBom)
                {
                    await
                    WorkOrder3.
                    setBom(relatedBom3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateWorkOrderWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const WorkOrder0 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkOrder0?.setAssigned_to)
                {
                    await
                    WorkOrder0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const WorkOrder1 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkOrder1?.setAssigned_to)
                {
                    await
                    WorkOrder1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const WorkOrder2 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkOrder2?.setAssigned_to)
                {
                    await
                    WorkOrder2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
                const relatedAssigned_to3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const WorkOrder3 = await WorkOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkOrder3?.setAssigned_to)
                {
                    await
                    WorkOrder3.
                    setAssigned_to(relatedAssigned_to3);
                }
            
        }
        
    

    
    
    
        
            
            async function associateWorkOrderMaterialWithWork_order() {
            
                const relatedWork_order0 = await WorkOrders.findOne({
                    offset: Math.floor(Math.random() * (await WorkOrders.count())),
                });
                const WorkOrderMaterial0 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkOrderMaterial0?.setWork_order)
                {
                    await
                    WorkOrderMaterial0.
                    setWork_order(relatedWork_order0);
                }
            
                const relatedWork_order1 = await WorkOrders.findOne({
                    offset: Math.floor(Math.random() * (await WorkOrders.count())),
                });
                const WorkOrderMaterial1 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkOrderMaterial1?.setWork_order)
                {
                    await
                    WorkOrderMaterial1.
                    setWork_order(relatedWork_order1);
                }
            
                const relatedWork_order2 = await WorkOrders.findOne({
                    offset: Math.floor(Math.random() * (await WorkOrders.count())),
                });
                const WorkOrderMaterial2 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkOrderMaterial2?.setWork_order)
                {
                    await
                    WorkOrderMaterial2.
                    setWork_order(relatedWork_order2);
                }
            
                const relatedWork_order3 = await WorkOrders.findOne({
                    offset: Math.floor(Math.random() * (await WorkOrders.count())),
                });
                const WorkOrderMaterial3 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkOrderMaterial3?.setWork_order)
                {
                    await
                    WorkOrderMaterial3.
                    setWork_order(relatedWork_order3);
                }
            
        }
        
    
        
            
            async function associateWorkOrderMaterialWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const WorkOrderMaterial0 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WorkOrderMaterial0?.setMaterial)
                {
                    await
                    WorkOrderMaterial0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const WorkOrderMaterial1 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WorkOrderMaterial1?.setMaterial)
                {
                    await
                    WorkOrderMaterial1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const WorkOrderMaterial2 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WorkOrderMaterial2?.setMaterial)
                {
                    await
                    WorkOrderMaterial2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const WorkOrderMaterial3 = await WorkOrderMaterials.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WorkOrderMaterial3?.setMaterial)
                {
                    await
                    WorkOrderMaterial3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateDeliveryWithProject() {
            
                const relatedProject0 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Delivery0 = await Deliveries.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Delivery0?.setProject)
                {
                    await
                    Delivery0.
                    setProject(relatedProject0);
                }
            
                const relatedProject1 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Delivery1 = await Deliveries.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Delivery1?.setProject)
                {
                    await
                    Delivery1.
                    setProject(relatedProject1);
                }
            
                const relatedProject2 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Delivery2 = await Deliveries.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Delivery2?.setProject)
                {
                    await
                    Delivery2.
                    setProject(relatedProject2);
                }
            
                const relatedProject3 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Delivery3 = await Deliveries.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Delivery3?.setProject)
                {
                    await
                    Delivery3.
                    setProject(relatedProject3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateDeliveryItemWithDelivery() {
            
                const relatedDelivery0 = await Deliveries.findOne({
                    offset: Math.floor(Math.random() * (await Deliveries.count())),
                });
                const DeliveryItem0 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeliveryItem0?.setDelivery)
                {
                    await
                    DeliveryItem0.
                    setDelivery(relatedDelivery0);
                }
            
                const relatedDelivery1 = await Deliveries.findOne({
                    offset: Math.floor(Math.random() * (await Deliveries.count())),
                });
                const DeliveryItem1 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeliveryItem1?.setDelivery)
                {
                    await
                    DeliveryItem1.
                    setDelivery(relatedDelivery1);
                }
            
                const relatedDelivery2 = await Deliveries.findOne({
                    offset: Math.floor(Math.random() * (await Deliveries.count())),
                });
                const DeliveryItem2 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeliveryItem2?.setDelivery)
                {
                    await
                    DeliveryItem2.
                    setDelivery(relatedDelivery2);
                }
            
                const relatedDelivery3 = await Deliveries.findOne({
                    offset: Math.floor(Math.random() * (await Deliveries.count())),
                });
                const DeliveryItem3 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DeliveryItem3?.setDelivery)
                {
                    await
                    DeliveryItem3.
                    setDelivery(relatedDelivery3);
                }
            
        }
        
    
        
            
            async function associateDeliveryItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeliveryItem0 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeliveryItem0?.setProduct)
                {
                    await
                    DeliveryItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeliveryItem1 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeliveryItem1?.setProduct)
                {
                    await
                    DeliveryItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeliveryItem2 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeliveryItem2?.setProduct)
                {
                    await
                    DeliveryItem2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeliveryItem3 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DeliveryItem3?.setProduct)
                {
                    await
                    DeliveryItem3.
                    setProduct(relatedProduct3);
                }
            
        }
        
    
        
            
            async function associateDeliveryItemWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const DeliveryItem0 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeliveryItem0?.setMaterial)
                {
                    await
                    DeliveryItem0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const DeliveryItem1 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeliveryItem1?.setMaterial)
                {
                    await
                    DeliveryItem1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const DeliveryItem2 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeliveryItem2?.setMaterial)
                {
                    await
                    DeliveryItem2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const DeliveryItem3 = await DeliveryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DeliveryItem3?.setMaterial)
                {
                    await
                    DeliveryItem3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateInvoiceWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Invoice0 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Invoice0?.setCustomer)
                {
                    await
                    Invoice0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Invoice1 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Invoice1?.setCustomer)
                {
                    await
                    Invoice1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Invoice2 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Invoice2?.setCustomer)
                {
                    await
                    Invoice2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Invoice3 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Invoice3?.setCustomer)
                {
                    await
                    Invoice3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
            
            async function associateInvoiceWithProject() {
            
                const relatedProject0 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Invoice0 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Invoice0?.setProject)
                {
                    await
                    Invoice0.
                    setProject(relatedProject0);
                }
            
                const relatedProject1 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Invoice1 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Invoice1?.setProject)
                {
                    await
                    Invoice1.
                    setProject(relatedProject1);
                }
            
                const relatedProject2 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Invoice2 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Invoice2?.setProject)
                {
                    await
                    Invoice2.
                    setProject(relatedProject2);
                }
            
                const relatedProject3 = await Projects.findOne({
                    offset: Math.floor(Math.random() * (await Projects.count())),
                });
                const Invoice3 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Invoice3?.setProject)
                {
                    await
                    Invoice3.
                    setProject(relatedProject3);
                }
            
        }
        
    
        
            
            async function associateInvoiceWithQuote() {
            
                const relatedQuote0 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Invoice0 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Invoice0?.setQuote)
                {
                    await
                    Invoice0.
                    setQuote(relatedQuote0);
                }
            
                const relatedQuote1 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Invoice1 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Invoice1?.setQuote)
                {
                    await
                    Invoice1.
                    setQuote(relatedQuote1);
                }
            
                const relatedQuote2 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Invoice2 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Invoice2?.setQuote)
                {
                    await
                    Invoice2.
                    setQuote(relatedQuote2);
                }
            
                const relatedQuote3 = await Quotes.findOne({
                    offset: Math.floor(Math.random() * (await Quotes.count())),
                });
                const Invoice3 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Invoice3?.setQuote)
                {
                    await
                    Invoice3.
                    setQuote(relatedQuote3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateInvoiceWithIssued_by() {
            
                const relatedIssued_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Invoice0 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Invoice0?.setIssued_by)
                {
                    await
                    Invoice0.
                    setIssued_by(relatedIssued_by0);
                }
            
                const relatedIssued_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Invoice1 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Invoice1?.setIssued_by)
                {
                    await
                    Invoice1.
                    setIssued_by(relatedIssued_by1);
                }
            
                const relatedIssued_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Invoice2 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Invoice2?.setIssued_by)
                {
                    await
                    Invoice2.
                    setIssued_by(relatedIssued_by2);
                }
            
                const relatedIssued_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Invoice3 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Invoice3?.setIssued_by)
                {
                    await
                    Invoice3.
                    setIssued_by(relatedIssued_by3);
                }
            
        }
        
    

    
    
    
        
            
            async function associateInvoiceLineItemWithInvoice() {
            
                const relatedInvoice0 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceLineItem0 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InvoiceLineItem0?.setInvoice)
                {
                    await
                    InvoiceLineItem0.
                    setInvoice(relatedInvoice0);
                }
            
                const relatedInvoice1 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceLineItem1 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InvoiceLineItem1?.setInvoice)
                {
                    await
                    InvoiceLineItem1.
                    setInvoice(relatedInvoice1);
                }
            
                const relatedInvoice2 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceLineItem2 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InvoiceLineItem2?.setInvoice)
                {
                    await
                    InvoiceLineItem2.
                    setInvoice(relatedInvoice2);
                }
            
                const relatedInvoice3 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceLineItem3 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InvoiceLineItem3?.setInvoice)
                {
                    await
                    InvoiceLineItem3.
                    setInvoice(relatedInvoice3);
                }
            
        }
        
    
        
            
            async function associateInvoiceLineItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InvoiceLineItem0 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InvoiceLineItem0?.setProduct)
                {
                    await
                    InvoiceLineItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InvoiceLineItem1 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InvoiceLineItem1?.setProduct)
                {
                    await
                    InvoiceLineItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InvoiceLineItem2 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InvoiceLineItem2?.setProduct)
                {
                    await
                    InvoiceLineItem2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InvoiceLineItem3 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InvoiceLineItem3?.setProduct)
                {
                    await
                    InvoiceLineItem3.
                    setProduct(relatedProduct3);
                }
            
        }
        
    
        
            
            async function associateInvoiceLineItemWithMaterial() {
            
                const relatedMaterial0 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InvoiceLineItem0 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InvoiceLineItem0?.setMaterial)
                {
                    await
                    InvoiceLineItem0.
                    setMaterial(relatedMaterial0);
                }
            
                const relatedMaterial1 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InvoiceLineItem1 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InvoiceLineItem1?.setMaterial)
                {
                    await
                    InvoiceLineItem1.
                    setMaterial(relatedMaterial1);
                }
            
                const relatedMaterial2 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InvoiceLineItem2 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InvoiceLineItem2?.setMaterial)
                {
                    await
                    InvoiceLineItem2.
                    setMaterial(relatedMaterial2);
                }
            
                const relatedMaterial3 = await Materials.findOne({
                    offset: Math.floor(Math.random() * (await Materials.count())),
                });
                const InvoiceLineItem3 = await InvoiceLineItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InvoiceLineItem3?.setMaterial)
                {
                    await
                    InvoiceLineItem3.
                    setMaterial(relatedMaterial3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associatePaymentWithInvoice() {
            
                const relatedInvoice0 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setInvoice)
                {
                    await
                    Payment0.
                    setInvoice(relatedInvoice0);
                }
            
                const relatedInvoice1 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setInvoice)
                {
                    await
                    Payment1.
                    setInvoice(relatedInvoice1);
                }
            
                const relatedInvoice2 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setInvoice)
                {
                    await
                    Payment2.
                    setInvoice(relatedInvoice2);
                }
            
                const relatedInvoice3 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const Payment3 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Payment3?.setInvoice)
                {
                    await
                    Payment3.
                    setInvoice(relatedInvoice3);
                }
            
        }
        
    
        
            
            async function associatePaymentWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setCustomer)
                {
                    await
                    Payment0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setCustomer)
                {
                    await
                    Payment1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setCustomer)
                {
                    await
                    Payment2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Payment3 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Payment3?.setCustomer)
                {
                    await
                    Payment3.
                    setCustomer(relatedCustomer3);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePaymentWithReceived_by() {
            
                const relatedReceived_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setReceived_by)
                {
                    await
                    Payment0.
                    setReceived_by(relatedReceived_by0);
                }
            
                const relatedReceived_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setReceived_by)
                {
                    await
                    Payment1.
                    setReceived_by(relatedReceived_by1);
                }
            
                const relatedReceived_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setReceived_by)
                {
                    await
                    Payment2.
                    setReceived_by(relatedReceived_by2);
                }
            
                const relatedReceived_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Payment3 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Payment3?.setReceived_by)
                {
                    await
                    Payment3.
                    setReceived_by(relatedReceived_by3);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateDocumentWithUploaded_by() {
            
                const relatedUploaded_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setUploaded_by)
                {
                    await
                    Document0.
                    setUploaded_by(relatedUploaded_by0);
                }
            
                const relatedUploaded_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setUploaded_by)
                {
                    await
                    Document1.
                    setUploaded_by(relatedUploaded_by1);
                }
            
                const relatedUploaded_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setUploaded_by)
                {
                    await
                    Document2.
                    setUploaded_by(relatedUploaded_by2);
                }
            
                const relatedUploaded_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document3 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Document3?.setUploaded_by)
                {
                    await
                    Document3.
                    setUploaded_by(relatedUploaded_by3);
                }
            
        }
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Customers.bulkCreate(CustomersData);
                
            
            
                
                await Contacts.bulkCreate(ContactsData);
                
            
            
                
                await Leads.bulkCreate(LeadsData);
                
            
            
                
                await Quotes.bulkCreate(QuotesData);
                
            
            
                
                await QuoteLineItems.bulkCreate(QuoteLineItemsData);
                
            
            
                
                await Projects.bulkCreate(ProjectsData);
                
            
            
                
                await ProjectMilestones.bulkCreate(ProjectMilestonesData);
                
            
            
                
                await Products.bulkCreate(ProductsData);
                
            
            
                
                await Materials.bulkCreate(MaterialsData);
                
            
            
                
                await Suppliers.bulkCreate(SuppliersData);
                
            
            
                
                await InventoryLocations.bulkCreate(InventoryLocationsData);
                
            
            
                
                await InventoryItems.bulkCreate(InventoryItemsData);
                
            
            
                
                await InventoryTransactions.bulkCreate(InventoryTransactionsData);
                
            
            
                
                await Boms.bulkCreate(BomsData);
                
            
            
                
                await BomItems.bulkCreate(BomItemsData);
                
            
            
                
                await PurchaseOrders.bulkCreate(PurchaseOrdersData);
                
            
            
                
                await PurchaseOrderLineItems.bulkCreate(PurchaseOrderLineItemsData);
                
            
            
                
                await GoodsReceipts.bulkCreate(GoodsReceiptsData);
                
            
            
                
                await WorkOrders.bulkCreate(WorkOrdersData);
                
            
            
                
                await WorkOrderMaterials.bulkCreate(WorkOrderMaterialsData);
                
            
            
                
                await Deliveries.bulkCreate(DeliveriesData);
                
            
            
                
                await DeliveryItems.bulkCreate(DeliveryItemsData);
                
            
            
                
                await Invoices.bulkCreate(InvoicesData);
                
            
            
                
                await InvoiceLineItems.bulkCreate(InvoiceLineItemsData);
                
            
            
                
                await Payments.bulkCreate(PaymentsData);
                
            
            
                
                await Documents.bulkCreate(DocumentsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateContactWithCustomer(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateLeadWithCustomer(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateLeadWithOwner(),
                    
                
            
                
                
                    
                
                    
                        
                        await associateQuoteWithCustomer(),
                    
                
                    
                        
                        await associateQuoteWithLead(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateQuoteWithPrepared_by(),
                    
                
            
                
                
                    
                        
                        await associateQuoteLineItemWithQuote(),
                    
                
                    
                        
                        await associateQuoteLineItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateProjectWithCustomer(),
                    
                
                    
                        
                        await associateProjectWithQuote(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProjectWithProject_manager(),
                    
                
            
                
                
                    
                        
                        await associateProjectMilestoneWithProject(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateInventoryItemWithMaterial(),
                    
                
                    
                        
                        await associateInventoryItemWithLocation(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateInventoryTransactionWithMaterial(),
                    
                
                    
                        
                        await associateInventoryTransactionWithFrom_location(),
                    
                
                    
                        
                        await associateInventoryTransactionWithTo_location(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateInventoryTransactionWithCreated_by_user(),
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateBomWithProduct(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateBomItemWithBom(),
                    
                
                    
                        
                        await associateBomItemWithMaterial(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associatePurchaseOrderWithSupplier(),
                    
                
                    
                        
                        await associatePurchaseOrderWithProject(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePurchaseOrderWithBuyer(),
                    
                
            
                
                
                    
                        
                        await associatePurchaseOrderLineItemWithPurchase_order(),
                    
                
                    
                        
                        await associatePurchaseOrderLineItemWithMaterial(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateGoodsReceiptWithPurchase_order(),
                    
                
                    
                        
                        await associateGoodsReceiptWithReceived_to_location(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateGoodsReceiptWithReceived_by(),
                    
                
            
                
                
                    
                
                    
                        
                        await associateWorkOrderWithProject(),
                    
                
                    
                        
                        await associateWorkOrderWithProduct(),
                    
                
                    
                        
                        await associateWorkOrderWithBom(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateWorkOrderWithAssigned_to(),
                    
                
            
                
                
                    
                        
                        await associateWorkOrderMaterialWithWork_order(),
                    
                
                    
                        
                        await associateWorkOrderMaterialWithMaterial(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateDeliveryWithProject(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateDeliveryItemWithDelivery(),
                    
                
                    
                        
                        await associateDeliveryItemWithProduct(),
                    
                
                    
                        
                        await associateDeliveryItemWithMaterial(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateInvoiceWithCustomer(),
                    
                
                    
                        
                        await associateInvoiceWithProject(),
                    
                
                    
                        
                        await associateInvoiceWithQuote(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateInvoiceWithIssued_by(),
                    
                
            
                
                
                    
                        
                        await associateInvoiceLineItemWithInvoice(),
                    
                
                    
                        
                        await associateInvoiceLineItemWithProduct(),
                    
                
                    
                        
                        await associateInvoiceLineItemWithMaterial(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associatePaymentWithInvoice(),
                    
                
                    
                        
                        await associatePaymentWithCustomer(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePaymentWithReceived_by(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDocumentWithUploaded_by(),
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('customers', null, {});
            
            
            await queryInterface.bulkDelete('contacts', null, {});
            
            
            await queryInterface.bulkDelete('leads', null, {});
            
            
            await queryInterface.bulkDelete('quotes', null, {});
            
            
            await queryInterface.bulkDelete('quote_line_items', null, {});
            
            
            await queryInterface.bulkDelete('projects', null, {});
            
            
            await queryInterface.bulkDelete('project_milestones', null, {});
            
            
            await queryInterface.bulkDelete('products', null, {});
            
            
            await queryInterface.bulkDelete('materials', null, {});
            
            
            await queryInterface.bulkDelete('suppliers', null, {});
            
            
            await queryInterface.bulkDelete('inventory_locations', null, {});
            
            
            await queryInterface.bulkDelete('inventory_items', null, {});
            
            
            await queryInterface.bulkDelete('inventory_transactions', null, {});
            
            
            await queryInterface.bulkDelete('boms', null, {});
            
            
            await queryInterface.bulkDelete('bom_items', null, {});
            
            
            await queryInterface.bulkDelete('purchase_orders', null, {});
            
            
            await queryInterface.bulkDelete('purchase_order_line_items', null, {});
            
            
            await queryInterface.bulkDelete('goods_receipts', null, {});
            
            
            await queryInterface.bulkDelete('work_orders', null, {});
            
            
            await queryInterface.bulkDelete('work_order_materials', null, {});
            
            
            await queryInterface.bulkDelete('deliveries', null, {});
            
            
            await queryInterface.bulkDelete('delivery_items', null, {});
            
            
            await queryInterface.bulkDelete('invoices', null, {});
            
            
            await queryInterface.bulkDelete('invoice_line_items', null, {});
            
            
            await queryInterface.bulkDelete('payments', null, {});
            
            
            await queryInterface.bulkDelete('documents', null, {});
            
        
    },
};