





















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






const Customers = db.customers;

const Devices = db.devices;

const RepairOrders = db.repair_orders;

const RepairServices = db.repair_services;

const OrderItems = db.order_items;

const PaymentMethods = db.payment_methods;

const Payments = db.payments;

const Invoices = db.invoices;

const InvoiceItems = db.invoice_items;

const WhatsappNotifications = db.whatsapp_notifications;

const AiChatSessions = db.ai_chat_sessions;

const AiChatMessages = db.ai_chat_messages;

const QrLinks = db.qr_links;







const CustomersData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_code": "Grace Hopper",
            
        
    
        
        
            
                "preferred_contact_channel": "Alan Turing",
            
        
    
        
        
            
                "accepts_marketing": true,
            
        
    
        
        
            
                "company_name": "Ada Lovelace",
            
        
    
        
        
            
                "tax_identifier": "Grace Hopper",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_code": "Alan Turing",
            
        
    
        
        
            
                "preferred_contact_channel": "Grace Hopper",
            
        
    
        
        
            
                "accepts_marketing": true,
            
        
    
        
        
            
                "company_name": "Grace Hopper",
            
        
    
        
        
            
                "tax_identifier": "Ada Lovelace",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_code": "Ada Lovelace",
            
        
    
        
        
            
                "preferred_contact_channel": "Marie Curie",
            
        
    
        
        
            
                "accepts_marketing": true,
            
        
    
        
        
            
                "company_name": "Ada Lovelace",
            
        
    
        
        
            
                "tax_identifier": "Grace Hopper",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_code": "Grace Hopper",
            
        
    
        
        
            
                "preferred_contact_channel": "Marie Curie",
            
        
    
        
        
            
                "accepts_marketing": true,
            
        
    
        
        
            
                "company_name": "Alan Turing",
            
        
    
        
        
            
                "tax_identifier": "Grace Hopper",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "customer_code": "Grace Hopper",
            
        
    
        
        
            
                "preferred_contact_channel": "Alan Turing",
            
        
    
        
        
            
                "accepts_marketing": false,
            
        
    
        
        
            
                "company_name": "Alan Turing",
            
        
    
        
        
            
                "tax_identifier": "Alan Turing",
            
        
    
    },
    
];



const DevicesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "device_type": "laptop",
            
        
    
        
        
            
                "brand": "Grace Hopper",
            
        
    
        
        
            
                "model": "Marie Curie",
            
        
    
        
        
            
                "color": "Ada Lovelace",
            
        
    
        
        
            
                "serial_number": "Grace Hopper",
            
        
    
        
        
            
                "accessories_received": "Alan Turing",
            
        
    
        
        
            
                "device_condition": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "device_type": "phone",
            
        
    
        
        
            
                "brand": "Ada Lovelace",
            
        
    
        
        
            
                "model": "Marie Curie",
            
        
    
        
        
            
                "color": "Alan Turing",
            
        
    
        
        
            
                "serial_number": "Marie Curie",
            
        
    
        
        
            
                "accessories_received": "Ada Lovelace",
            
        
    
        
        
            
                "device_condition": "Grace Hopper",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "device_type": "laptop",
            
        
    
        
        
            
                "brand": "Marie Curie",
            
        
    
        
        
            
                "model": "Ada Lovelace",
            
        
    
        
        
            
                "color": "Alan Turing",
            
        
    
        
        
            
                "serial_number": "Marie Curie",
            
        
    
        
        
            
                "accessories_received": "Ada Lovelace",
            
        
    
        
        
            
                "device_condition": "Marie Curie",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "device_type": "tablet",
            
        
    
        
        
            
                "brand": "Alan Turing",
            
        
    
        
        
            
                "model": "Alan Turing",
            
        
    
        
        
            
                "color": "Alan Turing",
            
        
    
        
        
            
                "serial_number": "Ada Lovelace",
            
        
    
        
        
            
                "accessories_received": "Ada Lovelace",
            
        
    
        
        
            
                "device_condition": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "device_type": "phone",
            
        
    
        
        
            
                "brand": "Alan Turing",
            
        
    
        
        
            
                "model": "Grace Hopper",
            
        
    
        
        
            
                "color": "Grace Hopper",
            
        
    
        
        
            
                "serial_number": "Alan Turing",
            
        
    
        
        
            
                "accessories_received": "Grace Hopper",
            
        
    
        
        
            
                "device_condition": "Ada Lovelace",
            
        
    
    },
    
];



const RepairOrdersData = [
    
    {
    
        
        
            
                "order_number": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "chatbot",
            
        
    
        
        
            
                "status": "new",
            
        
    
        
        
            
                "problem_description": "Ada Lovelace",
            
        
    
        
        
            
                "diagnosis_notes": "Alan Turing",
            
        
    
        
        
            
                "internal_notes": "Ada Lovelace",
            
        
    
        
        
            
                "estimated_cost": 8.3,
            
        
    
        
        
            
                "final_cost": 7.07,
            
        
    
        
        
            
                "requires_deposit": false,
            
        
    
        
        
            
                "deposit_amount": 0.39,
            
        
    
        
        
            
                "requested_at": new Date(Date.now()),
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "estimated_ready_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                "delivered_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "whatsapp_notified": false,
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "admin_panel",
            
        
    
        
        
            
                "status": "new",
            
        
    
        
        
            
                "problem_description": "Grace Hopper",
            
        
    
        
        
            
                "diagnosis_notes": "Ada Lovelace",
            
        
    
        
        
            
                "internal_notes": "Grace Hopper",
            
        
    
        
        
            
                "estimated_cost": 2.8,
            
        
    
        
        
            
                "final_cost": 4.25,
            
        
    
        
        
            
                "requires_deposit": true,
            
        
    
        
        
            
                "deposit_amount": 0.57,
            
        
    
        
        
            
                "requested_at": new Date(Date.now()),
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "estimated_ready_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                "delivered_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "whatsapp_notified": false,
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "qr",
            
        
    
        
        
            
                "status": "delivered",
            
        
    
        
        
            
                "problem_description": "Grace Hopper",
            
        
    
        
        
            
                "diagnosis_notes": "Grace Hopper",
            
        
    
        
        
            
                "internal_notes": "Alan Turing",
            
        
    
        
        
            
                "estimated_cost": 0.36,
            
        
    
        
        
            
                "final_cost": 0.49,
            
        
    
        
        
            
                "requires_deposit": false,
            
        
    
        
        
            
                "deposit_amount": 0.03,
            
        
    
        
        
            
                "requested_at": new Date(Date.now()),
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "estimated_ready_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                "delivered_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "whatsapp_notified": false,
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "qr",
            
        
    
        
        
            
                "status": "diagnosing",
            
        
    
        
        
            
                "problem_description": "Grace Hopper",
            
        
    
        
        
            
                "diagnosis_notes": "Ada Lovelace",
            
        
    
        
        
            
                "internal_notes": "Alan Turing",
            
        
    
        
        
            
                "estimated_cost": 8.17,
            
        
    
        
        
            
                "final_cost": 4.83,
            
        
    
        
        
            
                "requires_deposit": true,
            
        
    
        
        
            
                "deposit_amount": 6.06,
            
        
    
        
        
            
                "requested_at": new Date(Date.now()),
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "estimated_ready_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                "delivered_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "whatsapp_notified": true,
            
        
    
    },
    
    {
    
        
        
            
                "order_number": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "source": "admin_panel",
            
        
    
        
        
            
                "status": "ready_for_pickup",
            
        
    
        
        
            
                "problem_description": "Marie Curie",
            
        
    
        
        
            
                "diagnosis_notes": "Grace Hopper",
            
        
    
        
        
            
                "internal_notes": "Marie Curie",
            
        
    
        
        
            
                "estimated_cost": 9.97,
            
        
    
        
        
            
                "final_cost": 8.99,
            
        
    
        
        
            
                "requires_deposit": false,
            
        
    
        
        
            
                "deposit_amount": 7.36,
            
        
    
        
        
            
                "requested_at": new Date(Date.now()),
            
        
    
        
        
            
                "received_at": new Date(Date.now()),
            
        
    
        
        
            
                "estimated_ready_at": new Date(Date.now()),
            
        
    
        
        
            
                "completed_at": new Date(Date.now()),
            
        
    
        
        
            
                "delivered_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "whatsapp_notified": false,
            
        
    
    },
    
];



const RepairServicesData = [
    
    {
    
        
        
            
                "service_name": "Marie Curie",
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "base_price": 8.74,
            
        
    
        
        
            
                "estimated_minutes": 3,
            
        
    
        
        
            
                "is_active": false,
            
        
    
    },
    
    {
    
        
        
            
                "service_name": "Marie Curie",
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "base_price": 9.78,
            
        
    
        
        
            
                "estimated_minutes": 3,
            
        
    
        
        
            
                "is_active": false,
            
        
    
    },
    
    {
    
        
        
            
                "service_name": "Grace Hopper",
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "base_price": 4.45,
            
        
    
        
        
            
                "estimated_minutes": 4,
            
        
    
        
        
            
                "is_active": true,
            
        
    
    },
    
    {
    
        
        
            
                "service_name": "Alan Turing",
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "base_price": 4.49,
            
        
    
        
        
            
                "estimated_minutes": 4,
            
        
    
        
        
            
                "is_active": false,
            
        
    
    },
    
    {
    
        
        
            
                "service_name": "Alan Turing",
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "base_price": 9.0,
            
        
    
        
        
            
                "estimated_minutes": 3,
            
        
    
        
        
            
                "is_active": false,
            
        
    
    },
    
];



const OrderItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_description": "Marie Curie",
            
        
    
        
        
            
                "quantity": 6,
            
        
    
        
        
            
                "unit_price": 8.27,
            
        
    
        
        
            
                "line_total": 5.73,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_description": "Grace Hopper",
            
        
    
        
        
            
                "quantity": 8,
            
        
    
        
        
            
                "unit_price": 2.34,
            
        
    
        
        
            
                "line_total": 0.93,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_description": "Grace Hopper",
            
        
    
        
        
            
                "quantity": 5,
            
        
    
        
        
            
                "unit_price": 3.44,
            
        
    
        
        
            
                "line_total": 6.88,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_description": "Ada Lovelace",
            
        
    
        
        
            
                "quantity": 5,
            
        
    
        
        
            
                "unit_price": 7.67,
            
        
    
        
        
            
                "line_total": 6.42,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "item_description": "Marie Curie",
            
        
    
        
        
            
                "quantity": 5,
            
        
    
        
        
            
                "unit_price": 8.13,
            
        
    
        
        
            
                "line_total": 2.21,
            
        
    
    },
    
];



const PaymentMethodsData = [
    
    {
    
        
        
            
                "provider": "transfermovil",
            
        
    
        
        
            
                "display_name": "Marie Curie",
            
        
    
        
        
            
                "is_enabled": false,
            
        
    
        
        
            
                "instructions": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
    },
    
    {
    
        
        
            
                "provider": "enzona",
            
        
    
        
        
            
                "display_name": "Grace Hopper",
            
        
    
        
        
            
                "is_enabled": false,
            
        
    
        
        
            
                "instructions": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
    },
    
    {
    
        
        
            
                "provider": "enzona",
            
        
    
        
        
            
                "display_name": "Marie Curie",
            
        
    
        
        
            
                "is_enabled": true,
            
        
    
        
        
            
                "instructions": "Alan Turing",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
    },
    
    {
    
        
        
            
                "provider": "enzona",
            
        
    
        
        
            
                "display_name": "Alan Turing",
            
        
    
        
        
            
                "is_enabled": false,
            
        
    
        
        
            
                "instructions": "Marie Curie",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
    },
    
    {
    
        
        
            
                "provider": "transfermovil",
            
        
    
        
        
            
                "display_name": "Marie Curie",
            
        
    
        
        
            
                "is_enabled": true,
            
        
    
        
        
            
                "instructions": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
    },
    
];



const PaymentsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "payment_type": "balance",
            
        
    
        
        
            
                "status": "submitted",
            
        
    
        
        
            
                "amount": 4.56,
            
        
    
        
        
            
                "currency": "Grace Hopper",
            
        
    
        
        
            
                "reference_code": "Alan Turing",
            
        
    
        
        
            
                "provider_transaction_code": "Ada Lovelace",
            
        
    
        
        
            
                "initiated_at": new Date(Date.now()),
            
        
    
        
        
            
                "confirmed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "payment_type": "deposit",
            
        
    
        
        
            
                "status": "failed",
            
        
    
        
        
            
                "amount": 9.32,
            
        
    
        
        
            
                "currency": "Alan Turing",
            
        
    
        
        
            
                "reference_code": "Alan Turing",
            
        
    
        
        
            
                "provider_transaction_code": "Alan Turing",
            
        
    
        
        
            
                "initiated_at": new Date(Date.now()),
            
        
    
        
        
            
                "confirmed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "payment_type": "other",
            
        
    
        
        
            
                "status": "failed",
            
        
    
        
        
            
                "amount": 8.73,
            
        
    
        
        
            
                "currency": "Alan Turing",
            
        
    
        
        
            
                "reference_code": "Grace Hopper",
            
        
    
        
        
            
                "provider_transaction_code": "Grace Hopper",
            
        
    
        
        
            
                "initiated_at": new Date(Date.now()),
            
        
    
        
        
            
                "confirmed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "payment_type": "full",
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "amount": 5.62,
            
        
    
        
        
            
                "currency": "Alan Turing",
            
        
    
        
        
            
                "reference_code": "Marie Curie",
            
        
    
        
        
            
                "provider_transaction_code": "Grace Hopper",
            
        
    
        
        
            
                "initiated_at": new Date(Date.now()),
            
        
    
        
        
            
                "confirmed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "payment_type": "full",
            
        
    
        
        
            
                "status": "confirmed",
            
        
    
        
        
            
                "amount": 4.09,
            
        
    
        
        
            
                "currency": "Alan Turing",
            
        
    
        
        
            
                "reference_code": "Grace Hopper",
            
        
    
        
        
            
                "provider_transaction_code": "Marie Curie",
            
        
    
        
        
            
                "initiated_at": new Date(Date.now()),
            
        
    
        
        
            
                "confirmed_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
    },
    
];



const InvoicesData = [
    
    {
    
        
        
            
                "invoice_number": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "paid",
            
        
    
        
        
            
                "issued_at": new Date(Date.now()),
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal": 6.94,
            
        
    
        
        
            
                "tax_total": 4.9,
            
        
    
        
        
            
                "discount_total": 7.6,
            
        
    
        
        
            
                "total": 4.86,
            
        
    
        
        
            
                "billing_name": "Marie Curie",
            
        
    
        
        
            
                "billing_address": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "issued_at": new Date(Date.now()),
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal": 2.8,
            
        
    
        
        
            
                "tax_total": 6.29,
            
        
    
        
        
            
                "discount_total": 8.03,
            
        
    
        
        
            
                "total": 5.82,
            
        
    
        
        
            
                "billing_name": "Alan Turing",
            
        
    
        
        
            
                "billing_address": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "issued_at": new Date(Date.now()),
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal": 6.47,
            
        
    
        
        
            
                "tax_total": 9.64,
            
        
    
        
        
            
                "discount_total": 5.98,
            
        
    
        
        
            
                "total": 0.6,
            
        
    
        
        
            
                "billing_name": "Ada Lovelace",
            
        
    
        
        
            
                "billing_address": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "issued_at": new Date(Date.now()),
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal": 2.33,
            
        
    
        
        
            
                "tax_total": 5.64,
            
        
    
        
        
            
                "discount_total": 5.97,
            
        
    
        
        
            
                "total": 2.63,
            
        
    
        
        
            
                "billing_name": "Marie Curie",
            
        
    
        
        
            
                "billing_address": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "invoice_number": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "issued",
            
        
    
        
        
            
                "issued_at": new Date(Date.now()),
            
        
    
        
        
            
                "due_at": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal": 2.03,
            
        
    
        
        
            
                "tax_total": 4.76,
            
        
    
        
        
            
                "discount_total": 6.47,
            
        
    
        
        
            
                "total": 6.49,
            
        
    
        
        
            
                "billing_name": "Grace Hopper",
            
        
    
        
        
            
                "billing_address": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const InvoiceItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                "quantity": 9,
            
        
    
        
        
            
                "unit_price": 6.78,
            
        
    
        
        
            
                "line_total": 4.35,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Alan Turing",
            
        
    
        
        
            
                "quantity": 5,
            
        
    
        
        
            
                "unit_price": 5.89,
            
        
    
        
        
            
                "line_total": 0.56,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "quantity": 9,
            
        
    
        
        
            
                "unit_price": 3.36,
            
        
    
        
        
            
                "line_total": 5.92,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "quantity": 6,
            
        
    
        
        
            
                "unit_price": 8.96,
            
        
    
        
        
            
                "line_total": 8.44,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Alan Turing",
            
        
    
        
        
            
                "quantity": 8,
            
        
    
        
        
            
                "unit_price": 8.31,
            
        
    
        
        
            
                "line_total": 5.84,
            
        
    
    },
    
];



const WhatsappNotificationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "invoice_issued",
            
        
    
        
        
            
                "to_number": "Alan Turing",
            
        
    
        
        
            
                "message_body": "Alan Turing",
            
        
    
        
        
            
                "status": "failed",
            
        
    
        
        
            
                "queued_at": new Date(Date.now()),
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                "provider_message_id": "Alan Turing",
            
        
    
        
        
            
                "error_details": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "status_changed",
            
        
    
        
        
            
                "to_number": "Ada Lovelace",
            
        
    
        
        
            
                "message_body": "Grace Hopper",
            
        
    
        
        
            
                "status": "queued",
            
        
    
        
        
            
                "queued_at": new Date(Date.now()),
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                "provider_message_id": "Marie Curie",
            
        
    
        
        
            
                "error_details": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "invoice_issued",
            
        
    
        
        
            
                "to_number": "Ada Lovelace",
            
        
    
        
        
            
                "message_body": "Marie Curie",
            
        
    
        
        
            
                "status": "sent",
            
        
    
        
        
            
                "queued_at": new Date(Date.now()),
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                "provider_message_id": "Alan Turing",
            
        
    
        
        
            
                "error_details": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "custom",
            
        
    
        
        
            
                "to_number": "Ada Lovelace",
            
        
    
        
        
            
                "message_body": "Ada Lovelace",
            
        
    
        
        
            
                "status": "sent",
            
        
    
        
        
            
                "queued_at": new Date(Date.now()),
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                "provider_message_id": "Marie Curie",
            
        
    
        
        
            
                "error_details": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "invoice_issued",
            
        
    
        
        
            
                "to_number": "Ada Lovelace",
            
        
    
        
        
            
                "message_body": "Grace Hopper",
            
        
    
        
        
            
                "status": "queued",
            
        
    
        
        
            
                "queued_at": new Date(Date.now()),
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                "provider_message_id": "Grace Hopper",
            
        
    
        
        
            
                "error_details": "Ada Lovelace",
            
        
    
    },
    
];



const AiChatSessionsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "whatsapp",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "summary": "Ada Lovelace",
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "whatsapp",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "summary": "Ada Lovelace",
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "web_chat",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "summary": "Ada Lovelace",
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "web_chat",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "summary": "Marie Curie",
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "whatsapp",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "summary": "Grace Hopper",
            
        
    
        
        
            
                "started_at": new Date(Date.now()),
            
        
    
        
        
            
                "ended_at": new Date(Date.now()),
            
        
    
    },
    
];



const AiChatMessagesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sender": "agent",
            
        
    
        
        
            
                "message_text": "Ada Lovelace",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sender": "customer",
            
        
    
        
        
            
                "message_text": "Ada Lovelace",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sender": "customer",
            
        
    
        
        
            
                "message_text": "Alan Turing",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sender": "bot",
            
        
    
        
        
            
                "message_text": "Alan Turing",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sender": "bot",
            
        
    
        
        
            
                "message_text": "Grace Hopper",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const QrLinksData = [
    
    {
    
        
        
            
                "code_name": "Grace Hopper",
            
        
    
        
        
            
                "target_path": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                "scan_count": 2,
            
        
    
        
        
            
                "last_scanned_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                "code_name": "Marie Curie",
            
        
    
        
        
            
                "target_path": "Marie Curie",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "scan_count": 6,
            
        
    
        
        
            
                "last_scanned_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                "code_name": "Alan Turing",
            
        
    
        
        
            
                "target_path": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                "scan_count": 6,
            
        
    
        
        
            
                "last_scanned_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                "code_name": "Grace Hopper",
            
        
    
        
        
            
                "target_path": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                "scan_count": 5,
            
        
    
        
        
            
                "last_scanned_at": new Date(Date.now()),
            
        
    
    },
    
    {
    
        
        
            
                "code_name": "Grace Hopper",
            
        
    
        
        
            
                "target_path": "Alan Turing",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "scan_count": 3,
            
        
    
        
        
            
                "last_scanned_at": new Date(Date.now()),
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
    
    
        
            
            async function associateCustomerWithUser() {
            
                const relatedUser0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Customer0 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Customer0?.setUser)
                {
                    await
                    Customer0.
                    setUser(relatedUser0);
                }
            
                const relatedUser1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Customer1 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Customer1?.setUser)
                {
                    await
                    Customer1.
                    setUser(relatedUser1);
                }
            
                const relatedUser2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Customer2 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Customer2?.setUser)
                {
                    await
                    Customer2.
                    setUser(relatedUser2);
                }
            
                const relatedUser3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Customer3 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Customer3?.setUser)
                {
                    await
                    Customer3.
                    setUser(relatedUser3);
                }
            
                const relatedUser4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Customer4 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Customer4?.setUser)
                {
                    await
                    Customer4.
                    setUser(relatedUser4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateDeviceWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Device0 = await Devices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Device0?.setCustomer)
                {
                    await
                    Device0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Device1 = await Devices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Device1?.setCustomer)
                {
                    await
                    Device1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Device2 = await Devices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Device2?.setCustomer)
                {
                    await
                    Device2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Device3 = await Devices.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Device3?.setCustomer)
                {
                    await
                    Device3.
                    setCustomer(relatedCustomer3);
                }
            
                const relatedCustomer4 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Device4 = await Devices.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Device4?.setCustomer)
                {
                    await
                    Device4.
                    setCustomer(relatedCustomer4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateRepairOrderWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const RepairOrder0 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RepairOrder0?.setCustomer)
                {
                    await
                    RepairOrder0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const RepairOrder1 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RepairOrder1?.setCustomer)
                {
                    await
                    RepairOrder1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const RepairOrder2 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RepairOrder2?.setCustomer)
                {
                    await
                    RepairOrder2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const RepairOrder3 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RepairOrder3?.setCustomer)
                {
                    await
                    RepairOrder3.
                    setCustomer(relatedCustomer3);
                }
            
                const relatedCustomer4 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const RepairOrder4 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RepairOrder4?.setCustomer)
                {
                    await
                    RepairOrder4.
                    setCustomer(relatedCustomer4);
                }
            
        }
        
    
        
            
            async function associateRepairOrderWithDevice() {
            
                const relatedDevice0 = await Devices.findOne({
                    offset: Math.floor(Math.random() * (await Devices.count())),
                });
                const RepairOrder0 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RepairOrder0?.setDevice)
                {
                    await
                    RepairOrder0.
                    setDevice(relatedDevice0);
                }
            
                const relatedDevice1 = await Devices.findOne({
                    offset: Math.floor(Math.random() * (await Devices.count())),
                });
                const RepairOrder1 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RepairOrder1?.setDevice)
                {
                    await
                    RepairOrder1.
                    setDevice(relatedDevice1);
                }
            
                const relatedDevice2 = await Devices.findOne({
                    offset: Math.floor(Math.random() * (await Devices.count())),
                });
                const RepairOrder2 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RepairOrder2?.setDevice)
                {
                    await
                    RepairOrder2.
                    setDevice(relatedDevice2);
                }
            
                const relatedDevice3 = await Devices.findOne({
                    offset: Math.floor(Math.random() * (await Devices.count())),
                });
                const RepairOrder3 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RepairOrder3?.setDevice)
                {
                    await
                    RepairOrder3.
                    setDevice(relatedDevice3);
                }
            
                const relatedDevice4 = await Devices.findOne({
                    offset: Math.floor(Math.random() * (await Devices.count())),
                });
                const RepairOrder4 = await RepairOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RepairOrder4?.setDevice)
                {
                    await
                    RepairOrder4.
                    setDevice(relatedDevice4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateOrderItemWithRepair_order() {
            
                const relatedRepair_order0 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const OrderItem0 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (OrderItem0?.setRepair_order)
                {
                    await
                    OrderItem0.
                    setRepair_order(relatedRepair_order0);
                }
            
                const relatedRepair_order1 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const OrderItem1 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (OrderItem1?.setRepair_order)
                {
                    await
                    OrderItem1.
                    setRepair_order(relatedRepair_order1);
                }
            
                const relatedRepair_order2 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const OrderItem2 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (OrderItem2?.setRepair_order)
                {
                    await
                    OrderItem2.
                    setRepair_order(relatedRepair_order2);
                }
            
                const relatedRepair_order3 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const OrderItem3 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (OrderItem3?.setRepair_order)
                {
                    await
                    OrderItem3.
                    setRepair_order(relatedRepair_order3);
                }
            
                const relatedRepair_order4 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const OrderItem4 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (OrderItem4?.setRepair_order)
                {
                    await
                    OrderItem4.
                    setRepair_order(relatedRepair_order4);
                }
            
        }
        
    
        
            
            async function associateOrderItemWithRepair_service() {
            
                const relatedRepair_service0 = await RepairServices.findOne({
                    offset: Math.floor(Math.random() * (await RepairServices.count())),
                });
                const OrderItem0 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (OrderItem0?.setRepair_service)
                {
                    await
                    OrderItem0.
                    setRepair_service(relatedRepair_service0);
                }
            
                const relatedRepair_service1 = await RepairServices.findOne({
                    offset: Math.floor(Math.random() * (await RepairServices.count())),
                });
                const OrderItem1 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (OrderItem1?.setRepair_service)
                {
                    await
                    OrderItem1.
                    setRepair_service(relatedRepair_service1);
                }
            
                const relatedRepair_service2 = await RepairServices.findOne({
                    offset: Math.floor(Math.random() * (await RepairServices.count())),
                });
                const OrderItem2 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (OrderItem2?.setRepair_service)
                {
                    await
                    OrderItem2.
                    setRepair_service(relatedRepair_service2);
                }
            
                const relatedRepair_service3 = await RepairServices.findOne({
                    offset: Math.floor(Math.random() * (await RepairServices.count())),
                });
                const OrderItem3 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (OrderItem3?.setRepair_service)
                {
                    await
                    OrderItem3.
                    setRepair_service(relatedRepair_service3);
                }
            
                const relatedRepair_service4 = await RepairServices.findOne({
                    offset: Math.floor(Math.random() * (await RepairServices.count())),
                });
                const OrderItem4 = await OrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (OrderItem4?.setRepair_service)
                {
                    await
                    OrderItem4.
                    setRepair_service(relatedRepair_service4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associatePaymentWithRepair_order() {
            
                const relatedRepair_order0 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setRepair_order)
                {
                    await
                    Payment0.
                    setRepair_order(relatedRepair_order0);
                }
            
                const relatedRepair_order1 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setRepair_order)
                {
                    await
                    Payment1.
                    setRepair_order(relatedRepair_order1);
                }
            
                const relatedRepair_order2 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setRepair_order)
                {
                    await
                    Payment2.
                    setRepair_order(relatedRepair_order2);
                }
            
                const relatedRepair_order3 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Payment3 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Payment3?.setRepair_order)
                {
                    await
                    Payment3.
                    setRepair_order(relatedRepair_order3);
                }
            
                const relatedRepair_order4 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Payment4 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Payment4?.setRepair_order)
                {
                    await
                    Payment4.
                    setRepair_order(relatedRepair_order4);
                }
            
        }
        
    
        
            
            async function associatePaymentWithPayment_method() {
            
                const relatedPayment_method0 = await PaymentMethods.findOne({
                    offset: Math.floor(Math.random() * (await PaymentMethods.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setPayment_method)
                {
                    await
                    Payment0.
                    setPayment_method(relatedPayment_method0);
                }
            
                const relatedPayment_method1 = await PaymentMethods.findOne({
                    offset: Math.floor(Math.random() * (await PaymentMethods.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setPayment_method)
                {
                    await
                    Payment1.
                    setPayment_method(relatedPayment_method1);
                }
            
                const relatedPayment_method2 = await PaymentMethods.findOne({
                    offset: Math.floor(Math.random() * (await PaymentMethods.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setPayment_method)
                {
                    await
                    Payment2.
                    setPayment_method(relatedPayment_method2);
                }
            
                const relatedPayment_method3 = await PaymentMethods.findOne({
                    offset: Math.floor(Math.random() * (await PaymentMethods.count())),
                });
                const Payment3 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Payment3?.setPayment_method)
                {
                    await
                    Payment3.
                    setPayment_method(relatedPayment_method3);
                }
            
                const relatedPayment_method4 = await PaymentMethods.findOne({
                    offset: Math.floor(Math.random() * (await PaymentMethods.count())),
                });
                const Payment4 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Payment4?.setPayment_method)
                {
                    await
                    Payment4.
                    setPayment_method(relatedPayment_method4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            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);
                }
            
                const relatedCustomer4 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Invoice4 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Invoice4?.setCustomer)
                {
                    await
                    Invoice4.
                    setCustomer(relatedCustomer4);
                }
            
        }
        
    
        
            
            async function associateInvoiceWithRepair_order() {
            
                const relatedRepair_order0 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Invoice0 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Invoice0?.setRepair_order)
                {
                    await
                    Invoice0.
                    setRepair_order(relatedRepair_order0);
                }
            
                const relatedRepair_order1 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Invoice1 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Invoice1?.setRepair_order)
                {
                    await
                    Invoice1.
                    setRepair_order(relatedRepair_order1);
                }
            
                const relatedRepair_order2 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Invoice2 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Invoice2?.setRepair_order)
                {
                    await
                    Invoice2.
                    setRepair_order(relatedRepair_order2);
                }
            
                const relatedRepair_order3 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Invoice3 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Invoice3?.setRepair_order)
                {
                    await
                    Invoice3.
                    setRepair_order(relatedRepair_order3);
                }
            
                const relatedRepair_order4 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const Invoice4 = await Invoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Invoice4?.setRepair_order)
                {
                    await
                    Invoice4.
                    setRepair_order(relatedRepair_order4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateInvoiceItemWithInvoice() {
            
                const relatedInvoice0 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceItem0 = await InvoiceItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InvoiceItem0?.setInvoice)
                {
                    await
                    InvoiceItem0.
                    setInvoice(relatedInvoice0);
                }
            
                const relatedInvoice1 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceItem1 = await InvoiceItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InvoiceItem1?.setInvoice)
                {
                    await
                    InvoiceItem1.
                    setInvoice(relatedInvoice1);
                }
            
                const relatedInvoice2 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceItem2 = await InvoiceItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InvoiceItem2?.setInvoice)
                {
                    await
                    InvoiceItem2.
                    setInvoice(relatedInvoice2);
                }
            
                const relatedInvoice3 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceItem3 = await InvoiceItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (InvoiceItem3?.setInvoice)
                {
                    await
                    InvoiceItem3.
                    setInvoice(relatedInvoice3);
                }
            
                const relatedInvoice4 = await Invoices.findOne({
                    offset: Math.floor(Math.random() * (await Invoices.count())),
                });
                const InvoiceItem4 = await InvoiceItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (InvoiceItem4?.setInvoice)
                {
                    await
                    InvoiceItem4.
                    setInvoice(relatedInvoice4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateWhatsappNotificationWithRepair_order() {
            
                const relatedRepair_order0 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const WhatsappNotification0 = await WhatsappNotifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (WhatsappNotification0?.setRepair_order)
                {
                    await
                    WhatsappNotification0.
                    setRepair_order(relatedRepair_order0);
                }
            
                const relatedRepair_order1 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const WhatsappNotification1 = await WhatsappNotifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (WhatsappNotification1?.setRepair_order)
                {
                    await
                    WhatsappNotification1.
                    setRepair_order(relatedRepair_order1);
                }
            
                const relatedRepair_order2 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const WhatsappNotification2 = await WhatsappNotifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (WhatsappNotification2?.setRepair_order)
                {
                    await
                    WhatsappNotification2.
                    setRepair_order(relatedRepair_order2);
                }
            
                const relatedRepair_order3 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const WhatsappNotification3 = await WhatsappNotifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (WhatsappNotification3?.setRepair_order)
                {
                    await
                    WhatsappNotification3.
                    setRepair_order(relatedRepair_order3);
                }
            
                const relatedRepair_order4 = await RepairOrders.findOne({
                    offset: Math.floor(Math.random() * (await RepairOrders.count())),
                });
                const WhatsappNotification4 = await WhatsappNotifications.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (WhatsappNotification4?.setRepair_order)
                {
                    await
                    WhatsappNotification4.
                    setRepair_order(relatedRepair_order4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateAiChatSessionWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const AiChatSession0 = await AiChatSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AiChatSession0?.setCustomer)
                {
                    await
                    AiChatSession0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const AiChatSession1 = await AiChatSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AiChatSession1?.setCustomer)
                {
                    await
                    AiChatSession1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const AiChatSession2 = await AiChatSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AiChatSession2?.setCustomer)
                {
                    await
                    AiChatSession2.
                    setCustomer(relatedCustomer2);
                }
            
                const relatedCustomer3 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const AiChatSession3 = await AiChatSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AiChatSession3?.setCustomer)
                {
                    await
                    AiChatSession3.
                    setCustomer(relatedCustomer3);
                }
            
                const relatedCustomer4 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const AiChatSession4 = await AiChatSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (AiChatSession4?.setCustomer)
                {
                    await
                    AiChatSession4.
                    setCustomer(relatedCustomer4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateAiChatMessageWithAi_chat_session() {
            
                const relatedAi_chat_session0 = await AiChatSessions.findOne({
                    offset: Math.floor(Math.random() * (await AiChatSessions.count())),
                });
                const AiChatMessage0 = await AiChatMessages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AiChatMessage0?.setAi_chat_session)
                {
                    await
                    AiChatMessage0.
                    setAi_chat_session(relatedAi_chat_session0);
                }
            
                const relatedAi_chat_session1 = await AiChatSessions.findOne({
                    offset: Math.floor(Math.random() * (await AiChatSessions.count())),
                });
                const AiChatMessage1 = await AiChatMessages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AiChatMessage1?.setAi_chat_session)
                {
                    await
                    AiChatMessage1.
                    setAi_chat_session(relatedAi_chat_session1);
                }
            
                const relatedAi_chat_session2 = await AiChatSessions.findOne({
                    offset: Math.floor(Math.random() * (await AiChatSessions.count())),
                });
                const AiChatMessage2 = await AiChatMessages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AiChatMessage2?.setAi_chat_session)
                {
                    await
                    AiChatMessage2.
                    setAi_chat_session(relatedAi_chat_session2);
                }
            
                const relatedAi_chat_session3 = await AiChatSessions.findOne({
                    offset: Math.floor(Math.random() * (await AiChatSessions.count())),
                });
                const AiChatMessage3 = await AiChatMessages.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AiChatMessage3?.setAi_chat_session)
                {
                    await
                    AiChatMessage3.
                    setAi_chat_session(relatedAi_chat_session3);
                }
            
                const relatedAi_chat_session4 = await AiChatSessions.findOne({
                    offset: Math.floor(Math.random() * (await AiChatSessions.count())),
                });
                const AiChatMessage4 = await AiChatMessages.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (AiChatMessage4?.setAi_chat_session)
                {
                    await
                    AiChatMessage4.
                    setAi_chat_session(relatedAi_chat_session4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Customers.bulkCreate(CustomersData);
                
            
            
                
                await Devices.bulkCreate(DevicesData);
                
            
            
                
                await RepairOrders.bulkCreate(RepairOrdersData);
                
            
            
                
                await RepairServices.bulkCreate(RepairServicesData);
                
            
            
                
                await OrderItems.bulkCreate(OrderItemsData);
                
            
            
                
                await PaymentMethods.bulkCreate(PaymentMethodsData);
                
            
            
                
                await Payments.bulkCreate(PaymentsData);
                
            
            
                
                await Invoices.bulkCreate(InvoicesData);
                
            
            
                
                await InvoiceItems.bulkCreate(InvoiceItemsData);
                
            
            
                
                await WhatsappNotifications.bulkCreate(WhatsappNotificationsData);
                
            
            
                
                await AiChatSessions.bulkCreate(AiChatSessionsData);
                
            
            
                
                await AiChatMessages.bulkCreate(AiChatMessagesData);
                
            
            
                
                await QrLinks.bulkCreate(QrLinksData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                
                
                    
                        
                        await associateCustomerWithUser(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateDeviceWithCustomer(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateRepairOrderWithCustomer(),
                    
                
                    
                        
                        await associateRepairOrderWithDevice(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateOrderItemWithRepair_order(),
                    
                
                    
                        
                        await associateOrderItemWithRepair_service(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associatePaymentWithRepair_order(),
                    
                
                    
                        
                        await associatePaymentWithPayment_method(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateInvoiceWithCustomer(),
                    
                
                    
                        
                        await associateInvoiceWithRepair_order(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateInvoiceItemWithInvoice(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateWhatsappNotificationWithRepair_order(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateAiChatSessionWithCustomer(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateAiChatMessageWithAi_chat_session(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('customers', null, {});
            
            
            await queryInterface.bulkDelete('devices', null, {});
            
            
            await queryInterface.bulkDelete('repair_orders', null, {});
            
            
            await queryInterface.bulkDelete('repair_services', null, {});
            
            
            await queryInterface.bulkDelete('order_items', null, {});
            
            
            await queryInterface.bulkDelete('payment_methods', null, {});
            
            
            await queryInterface.bulkDelete('payments', null, {});
            
            
            await queryInterface.bulkDelete('invoices', null, {});
            
            
            await queryInterface.bulkDelete('invoice_items', null, {});
            
            
            await queryInterface.bulkDelete('whatsapp_notifications', null, {});
            
            
            await queryInterface.bulkDelete('ai_chat_sessions', null, {});
            
            
            await queryInterface.bulkDelete('ai_chat_messages', null, {});
            
            
            await queryInterface.bulkDelete('qr_links', null, {});
            
        
    },
};