





















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






const Organizations = db.organizations;

const Stores = db.stores;

const Products = db.products;

const Brands = db.brands;

const Categories = db.categories;

const Customers = db.customers;

const PriceLists = db.price_lists;

const PriceListItems = db.price_list_items;

const Discounts = db.discounts;

const Registers = db.registers;

const CashDrawerSessions = db.cash_drawer_sessions;

const Sales = db.sales;

const SaleItems = db.sale_items;

const Payments = db.payments;

const Returns = db.returns;

const ReturnItems = db.return_items;

const Suppliers = db.suppliers;

const PurchaseOrders = db.purchase_orders;

const PurchaseOrderItems = db.purchase_order_items;

const InventoryItems = db.inventory_items;

const StockMovements = db.stock_movements;

const StockTransfers = db.stock_transfers;

const StockTransferItems = db.stock_transfer_items;







const OrganizationsData = [
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
    },
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
    },
    
];



const StoresData = [
    
    {
    
        
        
            
                "name": "Dubai Marina Branch",
            
        
    
        
        
            
                "code": "DXB-MAR",
            
        
    
        
        
            
                "phone": "+97144223311",
            
        
    
        
        
            
                "email": "marina.store@example.ae",
            
        
    
        
        
            
                "address_line1": "Marina Walk",
            
        
    
        
        
            
                "address_line2": "Shop 12",
            
        
    
        
        
            
                "city": "Dubai",
            
        
    
        
        
            
                "emirate": "Dubai",
            
        
    
        
        
            
                "postal_code": "00000",
            
        
    
        
        
            
                "country": "UAE",
            
        
    
        
        
            
                "vat_trn": "100123456700003",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "opened_at": new Date('2025-09-01T08:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Deira City Centre Branch",
            
        
    
        
        
            
                "code": "DXB-DEI",
            
        
    
        
        
            
                "phone": "+97142661122",
            
        
    
        
        
            
                "email": "deira.store@example.ae",
            
        
    
        
        
            
                "address_line1": "Deira City Centre",
            
        
    
        
        
            
                "address_line2": "Level 1, Unit 104",
            
        
    
        
        
            
                "city": "Dubai",
            
        
    
        
        
            
                "emirate": "Dubai",
            
        
    
        
        
            
                "postal_code": "00000",
            
        
    
        
        
            
                "country": "UAE",
            
        
    
        
        
            
                "vat_trn": "100123456700003",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "opened_at": new Date('2025-10-10T08:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Abu Dhabi Mall Branch",
            
        
    
        
        
            
                "code": "AUH-MAL",
            
        
    
        
        
            
                "phone": "+97126445566",
            
        
    
        
        
            
                "email": "abudhabi.store@example.ae",
            
        
    
        
        
            
                "address_line1": "Abu Dhabi Mall",
            
        
    
        
        
            
                "address_line2": "Ground Floor, Kiosk 7",
            
        
    
        
        
            
                "city": "Abu Dhabi",
            
        
    
        
        
            
                "emirate": "Abu Dhabi",
            
        
    
        
        
            
                "postal_code": "00000",
            
        
    
        
        
            
                "country": "UAE",
            
        
    
        
        
            
                "vat_trn": "100123456700003",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "opened_at": new Date('2025-11-15T08:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ProductsData = [
    
    {
    
        
        
            
                "name": "OasisFresh Hand Sanitizer 250ml",
            
        
    
        
        
            
                "sku": "OF-HS-250",
            
        
    
        
        
            
                "barcode": "6291234500012",
            
        
    
        
        
            
                "short_description": "Alcohol-based hand sanitizer for daily use.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "product_type": "service",
            
        
    
        
        
            
                "is_taxable": true,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "cost_price": 6.5,
            
        
    
        
        
            
                "selling_price": 12.0,
            
        
    
        
        
            
                "reorder_level": 20,
            
        
    
        
        
            
                "track_inventory": true,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "DesertGlow Bottled Water 500ml",
            
        
    
        
        
            
                "sku": "DG-WAT-500",
            
        
    
        
        
            
                "barcode": "6291234500029",
            
        
    
        
        
            
                "short_description": "Drinking water bottle 500ml.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "product_type": "variant_child",
            
        
    
        
        
            
                "is_taxable": true,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "cost_price": 0.6,
            
        
    
        
        
            
                "selling_price": 1.5,
            
        
    
        
        
            
                "reorder_level": 100,
            
        
    
        
        
            
                "track_inventory": true,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "MarinaBasics USB-C Cable 1m",
            
        
    
        
        
            
                "sku": "MB-USBC-1M",
            
        
    
        
        
            
                "barcode": "6291234500036",
            
        
    
        
        
            
                "short_description": "Durable USB-C charging cable 1 meter.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "product_type": "variant_parent",
            
        
    
        
        
            
                "is_taxable": true,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "cost_price": 7.0,
            
        
    
        
        
            
                "selling_price": 19.0,
            
        
    
        
        
            
                "reorder_level": 15,
            
        
    
        
        
            
                "track_inventory": true,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const BrandsData = [
    
    {
    
        
        
            
                "name": "DesertGlow",
            
        
    
        
        
            
                "description": "Everyday essentials designed for Gulf climate.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "MarinaBasics",
            
        
    
        
        
            
                "description": "Affordable basics for daily use.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "OasisFresh",
            
        
    
        
        
            
                "description": "Personal care and hygiene products.",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const CategoriesData = [
    
    {
    
        
        
            
                "name": "Beverages",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Water, soft drinks, and juices.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Snacks",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Chips, nuts, and confectionery.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Personal Care",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Toiletries and grooming items.",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const CustomersData = [
    
    {
    
        
        
            
                "full_name": "Sarah Johnson",
            
        
    
        
        
            
                "phone": "+971589990001",
            
        
    
        
        
            
                "email": "sarah.johnson@example.com",
            
        
    
        
        
            
                "address": "Dubai, UAE",
            
        
    
        
        
            
                "vat_trn": "",
            
        
    
        
        
            
                "customer_type": "business",
            
        
    
        
        
            
                "loyalty_points": 120,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "full_name": "Ahmed Al Qasimi",
            
        
    
        
        
            
                "phone": "+971501110009",
            
        
    
        
        
            
                "email": "ahmed.qasimi@example.ae",
            
        
    
        
        
            
                "address": "Sharjah, UAE",
            
        
    
        
        
            
                "vat_trn": "",
            
        
    
        
        
            
                "customer_type": "consumer",
            
        
    
        
        
            
                "loyalty_points": 45,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "full_name": "Blue Wave Trading LLC",
            
        
    
        
        
            
                "phone": "+97144220088",
            
        
    
        
        
            
                "email": "accounts@bluewavetrading.ae",
            
        
    
        
        
            
                "address": "Al Quoz, Dubai, UAE",
            
        
    
        
        
            
                "vat_trn": "100987654300003",
            
        
    
        
        
            
                "customer_type": "business",
            
        
    
        
        
            
                "loyalty_points": 0,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PriceListsData = [
    
    {
    
        
        
            
                "name": "Dubai Standard Prices",
            
        
    
        
        
            
                "code": "DXB-STD",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "valid_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "valid_to": new Date('2026-12-31T23:59:59Z'),
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Abu Dhabi Standard Prices",
            
        
    
        
        
            
                "code": "AUH-STD",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "valid_from": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "valid_to": new Date('2026-12-31T23:59:59Z'),
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Weekend Promo Prices",
            
        
    
        
        
            
                "code": "WKND-PROMO",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "valid_from": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "valid_to": new Date('2026-06-30T23:59:59Z'),
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PriceListItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "price": 11.5,
            
        
    
        
        
            
                "vat_rate_override": 0.05,
            
        
    
        
        
            
                "effective_from": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-06-30T23:59:59Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "price": 1.4,
            
        
    
        
        
            
                "vat_rate_override": 0.05,
            
        
    
        
        
            
                "effective_from": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-06-30T23:59:59Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "price": 17.0,
            
        
    
        
        
            
                "vat_rate_override": 0.05,
            
        
    
        
        
            
                "effective_from": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "effective_to": new Date('2026-06-30T23:59:59Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const DiscountsData = [
    
    {
    
        
        
            
                "name": "Welcome 10 Percent",
            
        
    
        
        
            
                "discount_type": "amount",
            
        
    
        
        
            
                "value": 10,
            
        
    
        
        
            
                "coupon_code": "WELCOME10",
            
        
    
        
        
            
                "starts_at": new Date('2026-01-01T00:00:00Z'),
            
        
    
        
        
            
                "ends_at": new Date('2026-12-31T23:59:59Z'),
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Weekend AED 5 Off",
            
        
    
        
        
            
                "discount_type": "amount",
            
        
    
        
        
            
                "value": 5,
            
        
    
        
        
            
                "coupon_code": "WKND5",
            
        
    
        
        
            
                "starts_at": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "ends_at": new Date('2026-06-30T23:59:59Z'),
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Tour Group 15 Percent",
            
        
    
        
        
            
                "discount_type": "amount",
            
        
    
        
        
            
                "value": 15,
            
        
    
        
        
            
                "coupon_code": "TOUR15",
            
        
    
        
        
            
                "starts_at": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                "ends_at": new Date('2026-09-30T23:59:59Z'),
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const RegistersData = [
    
    {
    
        
        
            
                "name": "Marina Register 1",
            
        
    
        
        
            
                "code": "MAR-REG-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "receipt_footer_note": "Thank you for shopping with us",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Marina Register 2",
            
        
    
        
        
            
                "code": "MAR-REG-02",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "receipt_footer_note": "Exchange within 7 days with receipt",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Deira Register 1",
            
        
    
        
        
            
                "code": "DEI-REG-01",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "receipt_footer_note": "Prices include VAT where applicable",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const CashDrawerSessionsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "opened_at": new Date('2026-06-06T06:55:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-06T15:10:00Z'),
            
        
    
        
        
            
                "opening_float": 200,
            
        
    
        
        
            
                "closing_cash_counted": 865.5,
            
        
    
        
        
            
                "expected_cash": 862.0,
            
        
    
        
        
            
                "cash_difference": 3.5,
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "notes": "End of morning shift closeout",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "opened_at": new Date('2026-06-06T15:30:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "opening_float": 200,
            
        
    
        
        
            
                "closing_cash_counted": 0,
            
        
    
        
        
            
                "expected_cash": 0,
            
        
    
        
        
            
                "cash_difference": 0,
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "notes": "Evening shift started",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "opened_at": new Date('2026-06-05T07:05:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-05T15:00:00Z'),
            
        
    
        
        
            
                "opening_float": 150,
            
        
    
        
        
            
                "closing_cash_counted": 620,
            
        
    
        
        
            
                "expected_cash": 620,
            
        
    
        
        
            
                "cash_difference": 0,
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "notes": "No variance",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SalesData = [
    
    {
    
        
        
            
                "receipt_number": "DXB-MAR-00010234",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sold_at": new Date('2026-06-06T09:20:00Z'),
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "subtotal": 30.0,
            
        
    
        
        
            
                "discount_total": 0.0,
            
        
    
        
        
            
                "vat_total": 1.5,
            
        
    
        
        
            
                "grand_total": 31.5,
            
        
    
        
        
            
                "amount_paid": 31.5,
            
        
    
        
        
            
                "change_given": 0.0,
            
        
    
        
        
            
                "receipt_delivery": "email",
            
        
    
        
        
            
                "customer_email": "",
            
        
    
        
        
            
                "notes": "Walk-in customer",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "receipt_number": "DXB-DEI-00004510",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sold_at": new Date('2026-06-06T11:05:00Z'),
            
        
    
        
        
            
                "status": "refunded",
            
        
    
        
        
            
                "subtotal": 19.0,
            
        
    
        
        
            
                "discount_total": 5.0,
            
        
    
        
        
            
                "vat_total": 0.7,
            
        
    
        
        
            
                "grand_total": 14.7,
            
        
    
        
        
            
                "amount_paid": 20.0,
            
        
    
        
        
            
                "change_given": 5.3,
            
        
    
        
        
            
                "receipt_delivery": "email",
            
        
    
        
        
            
                "customer_email": "",
            
        
    
        
        
            
                "notes": "Applied weekend coupon",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "receipt_number": "AUH-MAL-00001288",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "sold_at": new Date('2026-06-05T13:40:00Z'),
            
        
    
        
        
            
                "status": "voided",
            
        
    
        
        
            
                "subtotal": 15.0,
            
        
    
        
        
            
                "discount_total": 0.0,
            
        
    
        
        
            
                "vat_total": 0.75,
            
        
    
        
        
            
                "grand_total": 15.75,
            
        
    
        
        
            
                "amount_paid": 15.75,
            
        
    
        
        
            
                "change_given": 0.0,
            
        
    
        
        
            
                "receipt_delivery": "email",
            
        
    
        
        
            
                "customer_email": "sarah.johnson@example.com",
            
        
    
        
        
            
                "notes": "E-receipt requested",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SaleItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "product_name_snapshot": "OasisFresh Hand Sanitizer 250ml",
            
        
    
        
        
            
                "sku_snapshot": "OF-HS-250",
            
        
    
        
        
            
                "barcode_snapshot": "6291234500012",
            
        
    
        
        
            
                "quantity": 1,
            
        
    
        
        
            
                "unit_price": 12.0,
            
        
    
        
        
            
                "line_discount": 0.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 0.6,
            
        
    
        
        
            
                "line_total": 12.6,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "product_name_snapshot": "MarinaBasics USB-C Cable 1m",
            
        
    
        
        
            
                "sku_snapshot": "MB-USBC-1M",
            
        
    
        
        
            
                "barcode_snapshot": "6291234500036",
            
        
    
        
        
            
                "quantity": 1,
            
        
    
        
        
            
                "unit_price": 19.0,
            
        
    
        
        
            
                "line_discount": 0.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 0.95,
            
        
    
        
        
            
                "line_total": 19.95,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "product_name_snapshot": "DesertGlow Bottled Water 500ml",
            
        
    
        
        
            
                "sku_snapshot": "DG-WAT-500",
            
        
    
        
        
            
                "barcode_snapshot": "6291234500029",
            
        
    
        
        
            
                "quantity": 4,
            
        
    
        
        
            
                "unit_price": 1.5,
            
        
    
        
        
            
                "line_discount": 0.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 0.3,
            
        
    
        
        
            
                "line_total": 6.3,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PaymentsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "paid_at": new Date('2026-06-06T09:21:00Z'),
            
        
    
        
        
            
                "method": "gift_card",
            
        
    
        
        
            
                "amount": 31.5,
            
        
    
        
        
            
                "currency": "AED",
            
        
    
        
        
            
                "reference": "POS-TRX-892341",
            
        
    
        
        
            
                "status": "authorized",
            
        
    
        
        
            
                "gateway": "network_international",
            
        
    
        
        
            
                "gateway_response": "approved",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "paid_at": new Date('2026-06-06T11:06:00Z'),
            
        
    
        
        
            
                "method": "cash",
            
        
    
        
        
            
                "amount": 20.0,
            
        
    
        
        
            
                "currency": "AED",
            
        
    
        
        
            
                "reference": "CASH-TILL-01",
            
        
    
        
        
            
                "status": "authorized",
            
        
    
        
        
            
                "gateway": "cash",
            
        
    
        
        
            
                "gateway_response": "received",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "paid_at": new Date('2026-06-05T13:41:00Z'),
            
        
    
        
        
            
                "method": "apple_pay",
            
        
    
        
        
            
                "amount": 15.75,
            
        
    
        
        
            
                "currency": "AED",
            
        
    
        
        
            
                "reference": "AP-558812",
            
        
    
        
        
            
                "status": "authorized",
            
        
    
        
        
            
                "gateway": "network_international",
            
        
    
        
        
            
                "gateway_response": "approved",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ReturnsData = [
    
    {
    
        
        
            
                "return_number": "RET-DXB-MAR-000021",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "returned_at": new Date('2026-06-06T14:10:00Z'),
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "reason": "wrong_item",
            
        
    
        
        
            
                "refund_total": 19.95,
            
        
    
        
        
            
                "notes": "Cable replaced and refunded",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "return_number": "RET-AUH-MAL-000008",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "returned_at": new Date('2026-06-05T16:45:00Z'),
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "reason": "wrong_item",
            
        
    
        
        
            
                "refund_total": 10.5,
            
        
    
        
        
            
                "notes": "Awaiting customer revisit for refund method confirmation",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "return_number": "RET-SHJ-CTY-000002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "returned_at": new Date('2026-06-04T12:20:00Z'),
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "reason": "defective",
            
        
    
        
        
            
                "refund_total": 0.0,
            
        
    
        
        
            
                "notes": "Outside return window",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ReturnItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 1,
            
        
    
        
        
            
                "unit_price": 19.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 0.95,
            
        
    
        
        
            
                "refund_amount": 19.95,
            
        
    
        
        
            
                "condition_notes": "Packaging opened, item faulty",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 1,
            
        
    
        
        
            
                "unit_price": 15.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 0.5,
            
        
    
        
        
            
                "refund_amount": 10.5,
            
        
    
        
        
            
                "condition_notes": "Unopened, wrong variant chosen",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity": 1,
            
        
    
        
        
            
                "unit_price": 12.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 0.6,
            
        
    
        
        
            
                "refund_amount": 0.0,
            
        
    
        
        
            
                "condition_notes": "Return rejected due to policy",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SuppliersData = [
    
    {
    
        
        
            
                "name": "Gulf Wholesale Supplies",
            
        
    
        
        
            
                "contact_name": "Hassan Ali",
            
        
    
        
        
            
                "phone": "+97143335522",
            
        
    
        
        
            
                "email": "sales@gulfwholesale.ae",
            
        
    
        
        
            
                "address": "Ras Al Khor, Dubai, UAE",
            
        
    
        
        
            
                "vat_trn": "100222333400003",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Oasis Distribution FZE",
            
        
    
        
        
            
                "contact_name": "Meera Nair",
            
        
    
        
        
            
                "phone": "+97165220011",
            
        
    
        
        
            
                "email": "orders@oasisdist.ae",
            
        
    
        
        
            
                "address": "SAIF Zone, Sharjah, UAE",
            
        
    
        
        
            
                "vat_trn": "100333444500003",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "PalmTech Trading",
            
        
    
        
        
            
                "contact_name": "Wei Chen",
            
        
    
        
        
            
                "phone": "+97142667788",
            
        
    
        
        
            
                "email": "b2b@palmtech.ae",
            
        
    
        
        
            
                "address": "Deira, Dubai, UAE",
            
        
    
        
        
            
                "vat_trn": "100444555600003",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PurchaseOrdersData = [
    
    {
    
        
        
            
                "po_number": "PO-2026-000120",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "ordered_at": new Date('2026-06-01T09:00:00Z'),
            
        
    
        
        
            
                "expected_at": new Date('2026-06-05T09:00:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-06-05T11:30:00Z'),
            
        
    
        
        
            
                "status": "sent",
            
        
    
        
        
            
                "subtotal": 650.0,
            
        
    
        
        
            
                "vat_total": 32.5,
            
        
    
        
        
            
                "grand_total": 682.5,
            
        
    
        
        
            
                "notes": "Monthly replenishment for Marina",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-000121",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "ordered_at": new Date('2026-06-02T10:15:00Z'),
            
        
    
        
        
            
                "expected_at": new Date('2026-06-06T10:15:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "status": "received",
            
        
    
        
        
            
                "subtotal": 420.0,
            
        
    
        
        
            
                "vat_total": 21.0,
            
        
    
        
        
            
                "grand_total": 441.0,
            
        
    
        
        
            
                "notes": "Awaiting remaining accessories",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "po_number": "PO-2026-000122",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "ordered_at": new Date('2026-06-03T08:40:00Z'),
            
        
    
        
        
            
                "expected_at": new Date('2026-06-07T08:40:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "subtotal": 300.0,
            
        
    
        
        
            
                "vat_total": 15.0,
            
        
    
        
        
            
                "grand_total": 315.0,
            
        
    
        
        
            
                "notes": "Souvenir stock top-up",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PurchaseOrderItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 50,
            
        
    
        
        
            
                "quantity_received": 50,
            
        
    
        
        
            
                "unit_cost": 6.5,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 16.25,
            
        
    
        
        
            
                "line_total": 341.25,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 200,
            
        
    
        
        
            
                "quantity_received": 180,
            
        
    
        
        
            
                "unit_cost": 0.6,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 5.4,
            
        
    
        
        
            
                "line_total": 113.4,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_ordered": 30,
            
        
    
        
        
            
                "quantity_received": 10,
            
        
    
        
        
            
                "unit_cost": 7.0,
            
        
    
        
        
            
                "vat_rate": 0.05,
            
        
    
        
        
            
                "vat_amount": 3.5,
            
        
    
        
        
            
                "line_total": 73.5,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const InventoryItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand": 120,
            
        
    
        
        
            
                "reserved": 5,
            
        
    
        
        
            
                "available": 115,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-06-01T08:00:00Z'),
            
        
    
        
        
            
                "last_movement_at": new Date('2026-06-06T11:05:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand": 500,
            
        
    
        
        
            
                "reserved": 0,
            
        
    
        
        
            
                "available": 500,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-05-25T08:00:00Z'),
            
        
    
        
        
            
                "last_movement_at": new Date('2026-06-06T09:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "on_hand": 40,
            
        
    
        
        
            
                "reserved": 2,
            
        
    
        
        
            
                "available": 38,
            
        
    
        
        
            
                "last_counted_at": new Date('2026-06-02T08:00:00Z'),
            
        
    
        
        
            
                "last_movement_at": new Date('2026-06-06T14:10:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const StockMovementsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "moved_at": new Date('2026-06-06T09:20:00Z'),
            
        
    
        
        
            
                "movement_type": "return",
            
        
    
        
        
            
                "quantity": -4,
            
        
    
        
        
            
                "reference_code": "DXB-MAR-00010234",
            
        
    
        
        
            
                "notes": "Water sold on receipt",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "moved_at": new Date('2026-06-06T14:10:00Z'),
            
        
    
        
        
            
                "movement_type": "return",
            
        
    
        
        
            
                "quantity": 1,
            
        
    
        
        
            
                "reference_code": "RET-DXB-MAR-000021",
            
        
    
        
        
            
                "notes": "Returned cable added back",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "moved_at": new Date('2026-06-05T11:30:00Z'),
            
        
    
        
        
            
                "movement_type": "adjustment_out",
            
        
    
        
        
            
                "quantity": 50,
            
        
    
        
        
            
                "reference_code": "PO-2026-000120",
            
        
    
        
        
            
                "notes": "Sanitizer received",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const StockTransfersData = [
    
    {
    
        
        
            
                "transfer_number": "TR-2026-00033",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "requested_at": new Date('2026-06-03T14:00:00Z'),
            
        
    
        
        
            
                "shipped_at": new Date('2026-06-03T18:00:00Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-06-04T10:30:00Z'),
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "notes": "Keychains moved for weekend traffic",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transfer_number": "TR-2026-00034",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "requested_at": new Date('2026-06-04T09:15:00Z'),
            
        
    
        
        
            
                "shipped_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "status": "shipped",
            
        
    
        
        
            
                "notes": "Water replenishment to Sharjah",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "transfer_number": "TR-2026-00035",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "requested_at": new Date('2026-06-05T11:00:00Z'),
            
        
    
        
        
            
                "shipped_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "received_at": new Date('2026-06-08T09:04:48Z'),
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                "notes": "Accessories requested by Abu Dhabi",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const StockTransferItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_requested": 10,
            
        
    
        
        
            
                "quantity_shipped": 10,
            
        
    
        
        
            
                "quantity_received": 10,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_requested": 50,
            
        
    
        
        
            
                "quantity_shipped": 0,
            
        
    
        
        
            
                "quantity_received": 0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "quantity_requested": 15,
            
        
    
        
        
            
                "quantity_shipped": 0,
            
        
    
        
        
            
                "quantity_received": 0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
            
            async function associateUserWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const User0 = await Users.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (User0?.setOrganization)
                {
                    await
                    User0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const User1 = await Users.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (User1?.setOrganization)
                {
                    await
                    User1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const User2 = await Users.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (User2?.setOrganization)
                {
                    await
                    User2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
    
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateStoreWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Store0 = await Stores.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Store0?.setOrganization)
                {
                    await
                    Store0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Store1 = await Stores.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Store1?.setOrganization)
                {
                    await
                    Store1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Store2 = await Stores.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Store2?.setOrganization)
                {
                    await
                    Store2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductWithBrand() {
            
                const relatedBrand0 = await Brands.findOne({
                    offset: Math.floor(Math.random() * (await Brands.count())),
                });
                const Product0 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Product0?.setBrand)
                {
                    await
                    Product0.
                    setBrand(relatedBrand0);
                }
            
                const relatedBrand1 = await Brands.findOne({
                    offset: Math.floor(Math.random() * (await Brands.count())),
                });
                const Product1 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Product1?.setBrand)
                {
                    await
                    Product1.
                    setBrand(relatedBrand1);
                }
            
                const relatedBrand2 = await Brands.findOne({
                    offset: Math.floor(Math.random() * (await Brands.count())),
                });
                const Product2 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Product2?.setBrand)
                {
                    await
                    Product2.
                    setBrand(relatedBrand2);
                }
            
        }
        
    
        
            
            async function associateProductWithCategory() {
            
                const relatedCategory0 = await Categories.findOne({
                    offset: Math.floor(Math.random() * (await Categories.count())),
                });
                const Product0 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Product0?.setCategory)
                {
                    await
                    Product0.
                    setCategory(relatedCategory0);
                }
            
                const relatedCategory1 = await Categories.findOne({
                    offset: Math.floor(Math.random() * (await Categories.count())),
                });
                const Product1 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Product1?.setCategory)
                {
                    await
                    Product1.
                    setCategory(relatedCategory1);
                }
            
                const relatedCategory2 = await Categories.findOne({
                    offset: Math.floor(Math.random() * (await Categories.count())),
                });
                const Product2 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Product2?.setCategory)
                {
                    await
                    Product2.
                    setCategory(relatedCategory2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateProductWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Product0 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Product0?.setOrganization)
                {
                    await
                    Product0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Product1 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Product1?.setOrganization)
                {
                    await
                    Product1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Product2 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Product2?.setOrganization)
                {
                    await
                    Product2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
            
            async function associateBrandWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Brand0 = await Brands.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Brand0?.setOrganization)
                {
                    await
                    Brand0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Brand1 = await Brands.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Brand1?.setOrganization)
                {
                    await
                    Brand1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Brand2 = await Brands.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Brand2?.setOrganization)
                {
                    await
                    Brand2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associateCategoryWithParent_category() {
            
                const relatedParent_category0 = await Categories.findOne({
                    offset: Math.floor(Math.random() * (await Categories.count())),
                });
                const Category0 = await Categories.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Category0?.setParent_category)
                {
                    await
                    Category0.
                    setParent_category(relatedParent_category0);
                }
            
                const relatedParent_category1 = await Categories.findOne({
                    offset: Math.floor(Math.random() * (await Categories.count())),
                });
                const Category1 = await Categories.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Category1?.setParent_category)
                {
                    await
                    Category1.
                    setParent_category(relatedParent_category1);
                }
            
                const relatedParent_category2 = await Categories.findOne({
                    offset: Math.floor(Math.random() * (await Categories.count())),
                });
                const Category2 = await Categories.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Category2?.setParent_category)
                {
                    await
                    Category2.
                    setParent_category(relatedParent_category2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateCategoryWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Category0 = await Categories.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Category0?.setOrganization)
                {
                    await
                    Category0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Category1 = await Categories.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Category1?.setOrganization)
                {
                    await
                    Category1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Category2 = await Categories.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Category2?.setOrganization)
                {
                    await
                    Category2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateCustomerWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Customer0 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Customer0?.setOrganization)
                {
                    await
                    Customer0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Customer1 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Customer1?.setOrganization)
                {
                    await
                    Customer1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Customer2 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Customer2?.setOrganization)
                {
                    await
                    Customer2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
            
            async function associatePriceListWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const PriceList0 = await PriceLists.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PriceList0?.setStore)
                {
                    await
                    PriceList0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const PriceList1 = await PriceLists.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PriceList1?.setStore)
                {
                    await
                    PriceList1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const PriceList2 = await PriceLists.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PriceList2?.setStore)
                {
                    await
                    PriceList2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associatePriceListWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PriceList0 = await PriceLists.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PriceList0?.setOrganization)
                {
                    await
                    PriceList0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PriceList1 = await PriceLists.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PriceList1?.setOrganization)
                {
                    await
                    PriceList1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PriceList2 = await PriceLists.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PriceList2?.setOrganization)
                {
                    await
                    PriceList2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePriceListItemWithPrice_list() {
            
                const relatedPrice_list0 = await PriceLists.findOne({
                    offset: Math.floor(Math.random() * (await PriceLists.count())),
                });
                const PriceListItem0 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PriceListItem0?.setPrice_list)
                {
                    await
                    PriceListItem0.
                    setPrice_list(relatedPrice_list0);
                }
            
                const relatedPrice_list1 = await PriceLists.findOne({
                    offset: Math.floor(Math.random() * (await PriceLists.count())),
                });
                const PriceListItem1 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PriceListItem1?.setPrice_list)
                {
                    await
                    PriceListItem1.
                    setPrice_list(relatedPrice_list1);
                }
            
                const relatedPrice_list2 = await PriceLists.findOne({
                    offset: Math.floor(Math.random() * (await PriceLists.count())),
                });
                const PriceListItem2 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PriceListItem2?.setPrice_list)
                {
                    await
                    PriceListItem2.
                    setPrice_list(relatedPrice_list2);
                }
            
        }
        
    
        
            
            async function associatePriceListItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PriceListItem0 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PriceListItem0?.setProduct)
                {
                    await
                    PriceListItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PriceListItem1 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PriceListItem1?.setProduct)
                {
                    await
                    PriceListItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PriceListItem2 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PriceListItem2?.setProduct)
                {
                    await
                    PriceListItem2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePriceListItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PriceListItem0 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PriceListItem0?.setOrganization)
                {
                    await
                    PriceListItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PriceListItem1 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PriceListItem1?.setOrganization)
                {
                    await
                    PriceListItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PriceListItem2 = await PriceListItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PriceListItem2?.setOrganization)
                {
                    await
                    PriceListItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateDiscountWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Discount0 = await Discounts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Discount0?.setStore)
                {
                    await
                    Discount0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Discount1 = await Discounts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Discount1?.setStore)
                {
                    await
                    Discount1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Discount2 = await Discounts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Discount2?.setStore)
                {
                    await
                    Discount2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
            
            async function associateDiscountWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Discount0 = await Discounts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Discount0?.setOrganization)
                {
                    await
                    Discount0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Discount1 = await Discounts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Discount1?.setOrganization)
                {
                    await
                    Discount1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Discount2 = await Discounts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Discount2?.setOrganization)
                {
                    await
                    Discount2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
            
            async function associateRegisterWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Register0 = await Registers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Register0?.setStore)
                {
                    await
                    Register0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Register1 = await Registers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Register1?.setStore)
                {
                    await
                    Register1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Register2 = await Registers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Register2?.setStore)
                {
                    await
                    Register2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateRegisterWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Register0 = await Registers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Register0?.setOrganization)
                {
                    await
                    Register0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Register1 = await Registers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Register1?.setOrganization)
                {
                    await
                    Register1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Register2 = await Registers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Register2?.setOrganization)
                {
                    await
                    Register2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateCashDrawerSessionWithRegister() {
            
                const relatedRegister0 = await Registers.findOne({
                    offset: Math.floor(Math.random() * (await Registers.count())),
                });
                const CashDrawerSession0 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CashDrawerSession0?.setRegister)
                {
                    await
                    CashDrawerSession0.
                    setRegister(relatedRegister0);
                }
            
                const relatedRegister1 = await Registers.findOne({
                    offset: Math.floor(Math.random() * (await Registers.count())),
                });
                const CashDrawerSession1 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CashDrawerSession1?.setRegister)
                {
                    await
                    CashDrawerSession1.
                    setRegister(relatedRegister1);
                }
            
                const relatedRegister2 = await Registers.findOne({
                    offset: Math.floor(Math.random() * (await Registers.count())),
                });
                const CashDrawerSession2 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CashDrawerSession2?.setRegister)
                {
                    await
                    CashDrawerSession2.
                    setRegister(relatedRegister2);
                }
            
        }
        
    
        
            
            async function associateCashDrawerSessionWithOpened_by_user() {
            
                const relatedOpened_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CashDrawerSession0 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CashDrawerSession0?.setOpened_by_user)
                {
                    await
                    CashDrawerSession0.
                    setOpened_by_user(relatedOpened_by_user0);
                }
            
                const relatedOpened_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CashDrawerSession1 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CashDrawerSession1?.setOpened_by_user)
                {
                    await
                    CashDrawerSession1.
                    setOpened_by_user(relatedOpened_by_user1);
                }
            
                const relatedOpened_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CashDrawerSession2 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CashDrawerSession2?.setOpened_by_user)
                {
                    await
                    CashDrawerSession2.
                    setOpened_by_user(relatedOpened_by_user2);
                }
            
        }
        
    
        
            
            async function associateCashDrawerSessionWithClosed_by_user() {
            
                const relatedClosed_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CashDrawerSession0 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CashDrawerSession0?.setClosed_by_user)
                {
                    await
                    CashDrawerSession0.
                    setClosed_by_user(relatedClosed_by_user0);
                }
            
                const relatedClosed_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CashDrawerSession1 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CashDrawerSession1?.setClosed_by_user)
                {
                    await
                    CashDrawerSession1.
                    setClosed_by_user(relatedClosed_by_user1);
                }
            
                const relatedClosed_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CashDrawerSession2 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CashDrawerSession2?.setClosed_by_user)
                {
                    await
                    CashDrawerSession2.
                    setClosed_by_user(relatedClosed_by_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateCashDrawerSessionWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const CashDrawerSession0 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CashDrawerSession0?.setOrganization)
                {
                    await
                    CashDrawerSession0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const CashDrawerSession1 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CashDrawerSession1?.setOrganization)
                {
                    await
                    CashDrawerSession1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const CashDrawerSession2 = await CashDrawerSessions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CashDrawerSession2?.setOrganization)
                {
                    await
                    CashDrawerSession2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associateSaleWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Sale0 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Sale0?.setStore)
                {
                    await
                    Sale0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Sale1 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Sale1?.setStore)
                {
                    await
                    Sale1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Sale2 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Sale2?.setStore)
                {
                    await
                    Sale2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
            
            async function associateSaleWithRegister() {
            
                const relatedRegister0 = await Registers.findOne({
                    offset: Math.floor(Math.random() * (await Registers.count())),
                });
                const Sale0 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Sale0?.setRegister)
                {
                    await
                    Sale0.
                    setRegister(relatedRegister0);
                }
            
                const relatedRegister1 = await Registers.findOne({
                    offset: Math.floor(Math.random() * (await Registers.count())),
                });
                const Sale1 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Sale1?.setRegister)
                {
                    await
                    Sale1.
                    setRegister(relatedRegister1);
                }
            
                const relatedRegister2 = await Registers.findOne({
                    offset: Math.floor(Math.random() * (await Registers.count())),
                });
                const Sale2 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Sale2?.setRegister)
                {
                    await
                    Sale2.
                    setRegister(relatedRegister2);
                }
            
        }
        
    
        
            
            async function associateSaleWithCashier() {
            
                const relatedCashier0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Sale0 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Sale0?.setCashier)
                {
                    await
                    Sale0.
                    setCashier(relatedCashier0);
                }
            
                const relatedCashier1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Sale1 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Sale1?.setCashier)
                {
                    await
                    Sale1.
                    setCashier(relatedCashier1);
                }
            
                const relatedCashier2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Sale2 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Sale2?.setCashier)
                {
                    await
                    Sale2.
                    setCashier(relatedCashier2);
                }
            
        }
        
    
        
            
            async function associateSaleWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Sale0 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Sale0?.setCustomer)
                {
                    await
                    Sale0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Sale1 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Sale1?.setCustomer)
                {
                    await
                    Sale1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Sale2 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Sale2?.setCustomer)
                {
                    await
                    Sale2.
                    setCustomer(relatedCustomer2);
                }
            
        }
        
    
        
            
            async function associateSaleWithCash_drawer_session() {
            
                const relatedCash_drawer_session0 = await CashDrawerSessions.findOne({
                    offset: Math.floor(Math.random() * (await CashDrawerSessions.count())),
                });
                const Sale0 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Sale0?.setCash_drawer_session)
                {
                    await
                    Sale0.
                    setCash_drawer_session(relatedCash_drawer_session0);
                }
            
                const relatedCash_drawer_session1 = await CashDrawerSessions.findOne({
                    offset: Math.floor(Math.random() * (await CashDrawerSessions.count())),
                });
                const Sale1 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Sale1?.setCash_drawer_session)
                {
                    await
                    Sale1.
                    setCash_drawer_session(relatedCash_drawer_session1);
                }
            
                const relatedCash_drawer_session2 = await CashDrawerSessions.findOne({
                    offset: Math.floor(Math.random() * (await CashDrawerSessions.count())),
                });
                const Sale2 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Sale2?.setCash_drawer_session)
                {
                    await
                    Sale2.
                    setCash_drawer_session(relatedCash_drawer_session2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateSaleWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Sale0 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Sale0?.setOrganization)
                {
                    await
                    Sale0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Sale1 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Sale1?.setOrganization)
                {
                    await
                    Sale1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Sale2 = await Sales.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Sale2?.setOrganization)
                {
                    await
                    Sale2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateSaleItemWithSale() {
            
                const relatedSale0 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const SaleItem0 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SaleItem0?.setSale)
                {
                    await
                    SaleItem0.
                    setSale(relatedSale0);
                }
            
                const relatedSale1 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const SaleItem1 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SaleItem1?.setSale)
                {
                    await
                    SaleItem1.
                    setSale(relatedSale1);
                }
            
                const relatedSale2 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const SaleItem2 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SaleItem2?.setSale)
                {
                    await
                    SaleItem2.
                    setSale(relatedSale2);
                }
            
        }
        
    
        
            
            async function associateSaleItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const SaleItem0 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SaleItem0?.setProduct)
                {
                    await
                    SaleItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const SaleItem1 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SaleItem1?.setProduct)
                {
                    await
                    SaleItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const SaleItem2 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SaleItem2?.setProduct)
                {
                    await
                    SaleItem2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateSaleItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SaleItem0 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SaleItem0?.setOrganization)
                {
                    await
                    SaleItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SaleItem1 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SaleItem1?.setOrganization)
                {
                    await
                    SaleItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SaleItem2 = await SaleItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SaleItem2?.setOrganization)
                {
                    await
                    SaleItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePaymentWithSale() {
            
                const relatedSale0 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setSale)
                {
                    await
                    Payment0.
                    setSale(relatedSale0);
                }
            
                const relatedSale1 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setSale)
                {
                    await
                    Payment1.
                    setSale(relatedSale1);
                }
            
                const relatedSale2 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setSale)
                {
                    await
                    Payment2.
                    setSale(relatedSale2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePaymentWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Payment0 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Payment0?.setOrganization)
                {
                    await
                    Payment0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Payment1 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Payment1?.setOrganization)
                {
                    await
                    Payment1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Payment2 = await Payments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Payment2?.setOrganization)
                {
                    await
                    Payment2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associateReturnWithOriginal_sale() {
            
                const relatedOriginal_sale0 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const Return0 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Return0?.setOriginal_sale)
                {
                    await
                    Return0.
                    setOriginal_sale(relatedOriginal_sale0);
                }
            
                const relatedOriginal_sale1 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const Return1 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Return1?.setOriginal_sale)
                {
                    await
                    Return1.
                    setOriginal_sale(relatedOriginal_sale1);
                }
            
                const relatedOriginal_sale2 = await Sales.findOne({
                    offset: Math.floor(Math.random() * (await Sales.count())),
                });
                const Return2 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Return2?.setOriginal_sale)
                {
                    await
                    Return2.
                    setOriginal_sale(relatedOriginal_sale2);
                }
            
        }
        
    
        
            
            async function associateReturnWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Return0 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Return0?.setStore)
                {
                    await
                    Return0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Return1 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Return1?.setStore)
                {
                    await
                    Return1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const Return2 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Return2?.setStore)
                {
                    await
                    Return2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
            
            async function associateReturnWithProcessed_by_user() {
            
                const relatedProcessed_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Return0 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Return0?.setProcessed_by_user)
                {
                    await
                    Return0.
                    setProcessed_by_user(relatedProcessed_by_user0);
                }
            
                const relatedProcessed_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Return1 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Return1?.setProcessed_by_user)
                {
                    await
                    Return1.
                    setProcessed_by_user(relatedProcessed_by_user1);
                }
            
                const relatedProcessed_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Return2 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Return2?.setProcessed_by_user)
                {
                    await
                    Return2.
                    setProcessed_by_user(relatedProcessed_by_user2);
                }
            
        }
        
    
        
            
            async function associateReturnWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Return0 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Return0?.setCustomer)
                {
                    await
                    Return0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Return1 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Return1?.setCustomer)
                {
                    await
                    Return1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const Return2 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Return2?.setCustomer)
                {
                    await
                    Return2.
                    setCustomer(relatedCustomer2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateReturnWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Return0 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Return0?.setOrganization)
                {
                    await
                    Return0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Return1 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Return1?.setOrganization)
                {
                    await
                    Return1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Return2 = await Returns.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Return2?.setOrganization)
                {
                    await
                    Return2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateReturnItemWithReturn() {
            
                const relatedReturn0 = await Returns.findOne({
                    offset: Math.floor(Math.random() * (await Returns.count())),
                });
                const ReturnItem0 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReturnItem0?.setReturn)
                {
                    await
                    ReturnItem0.
                    setReturn(relatedReturn0);
                }
            
                const relatedReturn1 = await Returns.findOne({
                    offset: Math.floor(Math.random() * (await Returns.count())),
                });
                const ReturnItem1 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReturnItem1?.setReturn)
                {
                    await
                    ReturnItem1.
                    setReturn(relatedReturn1);
                }
            
                const relatedReturn2 = await Returns.findOne({
                    offset: Math.floor(Math.random() * (await Returns.count())),
                });
                const ReturnItem2 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReturnItem2?.setReturn)
                {
                    await
                    ReturnItem2.
                    setReturn(relatedReturn2);
                }
            
        }
        
    
        
            
            async function associateReturnItemWithSale_item() {
            
                const relatedSale_item0 = await SaleItems.findOne({
                    offset: Math.floor(Math.random() * (await SaleItems.count())),
                });
                const ReturnItem0 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReturnItem0?.setSale_item)
                {
                    await
                    ReturnItem0.
                    setSale_item(relatedSale_item0);
                }
            
                const relatedSale_item1 = await SaleItems.findOne({
                    offset: Math.floor(Math.random() * (await SaleItems.count())),
                });
                const ReturnItem1 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReturnItem1?.setSale_item)
                {
                    await
                    ReturnItem1.
                    setSale_item(relatedSale_item1);
                }
            
                const relatedSale_item2 = await SaleItems.findOne({
                    offset: Math.floor(Math.random() * (await SaleItems.count())),
                });
                const ReturnItem2 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReturnItem2?.setSale_item)
                {
                    await
                    ReturnItem2.
                    setSale_item(relatedSale_item2);
                }
            
        }
        
    
        
            
            async function associateReturnItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const ReturnItem0 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReturnItem0?.setProduct)
                {
                    await
                    ReturnItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const ReturnItem1 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReturnItem1?.setProduct)
                {
                    await
                    ReturnItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const ReturnItem2 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReturnItem2?.setProduct)
                {
                    await
                    ReturnItem2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateReturnItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReturnItem0 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ReturnItem0?.setOrganization)
                {
                    await
                    ReturnItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReturnItem1 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ReturnItem1?.setOrganization)
                {
                    await
                    ReturnItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const ReturnItem2 = await ReturnItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ReturnItem2?.setOrganization)
                {
                    await
                    ReturnItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateSupplierWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Supplier0 = await Suppliers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Supplier0?.setOrganization)
                {
                    await
                    Supplier0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Supplier1 = await Suppliers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Supplier1?.setOrganization)
                {
                    await
                    Supplier1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Supplier2 = await Suppliers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Supplier2?.setOrganization)
                {
                    await
                    Supplier2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associatePurchaseOrderWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setStore)
                {
                    await
                    PurchaseOrder0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setStore)
                {
                    await
                    PurchaseOrder1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setStore)
                {
                    await
                    PurchaseOrder2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
            
            async function associatePurchaseOrderWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setSupplier)
                {
                    await
                    PurchaseOrder0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setSupplier)
                {
                    await
                    PurchaseOrder1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setSupplier)
                {
                    await
                    PurchaseOrder2.
                    setSupplier(relatedSupplier2);
                }
            
        }
        
    
        
            
            async function associatePurchaseOrderWithCreated_by_user() {
            
                const relatedCreated_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setCreated_by_user)
                {
                    await
                    PurchaseOrder0.
                    setCreated_by_user(relatedCreated_by_user0);
                }
            
                const relatedCreated_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setCreated_by_user)
                {
                    await
                    PurchaseOrder1.
                    setCreated_by_user(relatedCreated_by_user1);
                }
            
                const relatedCreated_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setCreated_by_user)
                {
                    await
                    PurchaseOrder2.
                    setCreated_by_user(relatedCreated_by_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePurchaseOrderWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseOrder0 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrder0?.setOrganization)
                {
                    await
                    PurchaseOrder0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseOrder1 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrder1?.setOrganization)
                {
                    await
                    PurchaseOrder1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseOrder2 = await PurchaseOrders.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrder2?.setOrganization)
                {
                    await
                    PurchaseOrder2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePurchaseOrderItemWithPurchase_order() {
            
                const relatedPurchase_order0 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderItem0 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderItem0?.setPurchase_order)
                {
                    await
                    PurchaseOrderItem0.
                    setPurchase_order(relatedPurchase_order0);
                }
            
                const relatedPurchase_order1 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderItem1 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderItem1?.setPurchase_order)
                {
                    await
                    PurchaseOrderItem1.
                    setPurchase_order(relatedPurchase_order1);
                }
            
                const relatedPurchase_order2 = await PurchaseOrders.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseOrders.count())),
                });
                const PurchaseOrderItem2 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderItem2?.setPurchase_order)
                {
                    await
                    PurchaseOrderItem2.
                    setPurchase_order(relatedPurchase_order2);
                }
            
        }
        
    
        
            
            async function associatePurchaseOrderItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PurchaseOrderItem0 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderItem0?.setProduct)
                {
                    await
                    PurchaseOrderItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PurchaseOrderItem1 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderItem1?.setProduct)
                {
                    await
                    PurchaseOrderItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PurchaseOrderItem2 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderItem2?.setProduct)
                {
                    await
                    PurchaseOrderItem2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePurchaseOrderItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseOrderItem0 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseOrderItem0?.setOrganization)
                {
                    await
                    PurchaseOrderItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseOrderItem1 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseOrderItem1?.setOrganization)
                {
                    await
                    PurchaseOrderItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseOrderItem2 = await PurchaseOrderItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseOrderItem2?.setOrganization)
                {
                    await
                    PurchaseOrderItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateInventoryItemWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setStore)
                {
                    await
                    InventoryItem0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setStore)
                {
                    await
                    InventoryItem1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setStore)
                {
                    await
                    InventoryItem2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
            
            async function associateInventoryItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setProduct)
                {
                    await
                    InventoryItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setProduct)
                {
                    await
                    InventoryItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setProduct)
                {
                    await
                    InventoryItem2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateInventoryItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const InventoryItem0 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (InventoryItem0?.setOrganization)
                {
                    await
                    InventoryItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const InventoryItem1 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (InventoryItem1?.setOrganization)
                {
                    await
                    InventoryItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const InventoryItem2 = await InventoryItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (InventoryItem2?.setOrganization)
                {
                    await
                    InventoryItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateStockMovementWithStore() {
            
                const relatedStore0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockMovement0 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockMovement0?.setStore)
                {
                    await
                    StockMovement0.
                    setStore(relatedStore0);
                }
            
                const relatedStore1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockMovement1 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockMovement1?.setStore)
                {
                    await
                    StockMovement1.
                    setStore(relatedStore1);
                }
            
                const relatedStore2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockMovement2 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockMovement2?.setStore)
                {
                    await
                    StockMovement2.
                    setStore(relatedStore2);
                }
            
        }
        
    
        
            
            async function associateStockMovementWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const StockMovement0 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockMovement0?.setProduct)
                {
                    await
                    StockMovement0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const StockMovement1 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockMovement1?.setProduct)
                {
                    await
                    StockMovement1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const StockMovement2 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockMovement2?.setProduct)
                {
                    await
                    StockMovement2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateStockMovementWithPerformed_by_user() {
            
                const relatedPerformed_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockMovement0 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockMovement0?.setPerformed_by_user)
                {
                    await
                    StockMovement0.
                    setPerformed_by_user(relatedPerformed_by_user0);
                }
            
                const relatedPerformed_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockMovement1 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockMovement1?.setPerformed_by_user)
                {
                    await
                    StockMovement1.
                    setPerformed_by_user(relatedPerformed_by_user1);
                }
            
                const relatedPerformed_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockMovement2 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockMovement2?.setPerformed_by_user)
                {
                    await
                    StockMovement2.
                    setPerformed_by_user(relatedPerformed_by_user2);
                }
            
        }
        
    
        
            
            async function associateStockMovementWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockMovement0 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockMovement0?.setOrganization)
                {
                    await
                    StockMovement0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockMovement1 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockMovement1?.setOrganization)
                {
                    await
                    StockMovement1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockMovement2 = await StockMovements.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockMovement2?.setOrganization)
                {
                    await
                    StockMovement2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
    
        
            
            async function associateStockTransferWithFrom_store() {
            
                const relatedFrom_store0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockTransfer0 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransfer0?.setFrom_store)
                {
                    await
                    StockTransfer0.
                    setFrom_store(relatedFrom_store0);
                }
            
                const relatedFrom_store1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockTransfer1 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransfer1?.setFrom_store)
                {
                    await
                    StockTransfer1.
                    setFrom_store(relatedFrom_store1);
                }
            
                const relatedFrom_store2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockTransfer2 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransfer2?.setFrom_store)
                {
                    await
                    StockTransfer2.
                    setFrom_store(relatedFrom_store2);
                }
            
        }
        
    
        
            
            async function associateStockTransferWithTo_store() {
            
                const relatedTo_store0 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockTransfer0 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransfer0?.setTo_store)
                {
                    await
                    StockTransfer0.
                    setTo_store(relatedTo_store0);
                }
            
                const relatedTo_store1 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockTransfer1 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransfer1?.setTo_store)
                {
                    await
                    StockTransfer1.
                    setTo_store(relatedTo_store1);
                }
            
                const relatedTo_store2 = await Stores.findOne({
                    offset: Math.floor(Math.random() * (await Stores.count())),
                });
                const StockTransfer2 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransfer2?.setTo_store)
                {
                    await
                    StockTransfer2.
                    setTo_store(relatedTo_store2);
                }
            
        }
        
    
        
            
            async function associateStockTransferWithRequested_by_user() {
            
                const relatedRequested_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockTransfer0 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransfer0?.setRequested_by_user)
                {
                    await
                    StockTransfer0.
                    setRequested_by_user(relatedRequested_by_user0);
                }
            
                const relatedRequested_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockTransfer1 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransfer1?.setRequested_by_user)
                {
                    await
                    StockTransfer1.
                    setRequested_by_user(relatedRequested_by_user1);
                }
            
                const relatedRequested_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockTransfer2 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransfer2?.setRequested_by_user)
                {
                    await
                    StockTransfer2.
                    setRequested_by_user(relatedRequested_by_user2);
                }
            
        }
        
    
        
            
            async function associateStockTransferWithApproved_by_user() {
            
                const relatedApproved_by_user0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockTransfer0 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransfer0?.setApproved_by_user)
                {
                    await
                    StockTransfer0.
                    setApproved_by_user(relatedApproved_by_user0);
                }
            
                const relatedApproved_by_user1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockTransfer1 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransfer1?.setApproved_by_user)
                {
                    await
                    StockTransfer1.
                    setApproved_by_user(relatedApproved_by_user1);
                }
            
                const relatedApproved_by_user2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const StockTransfer2 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransfer2?.setApproved_by_user)
                {
                    await
                    StockTransfer2.
                    setApproved_by_user(relatedApproved_by_user2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateStockTransferWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockTransfer0 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransfer0?.setOrganization)
                {
                    await
                    StockTransfer0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockTransfer1 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransfer1?.setOrganization)
                {
                    await
                    StockTransfer1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockTransfer2 = await StockTransfers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransfer2?.setOrganization)
                {
                    await
                    StockTransfer2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateStockTransferItemWithStock_transfer() {
            
                const relatedStock_transfer0 = await StockTransfers.findOne({
                    offset: Math.floor(Math.random() * (await StockTransfers.count())),
                });
                const StockTransferItem0 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransferItem0?.setStock_transfer)
                {
                    await
                    StockTransferItem0.
                    setStock_transfer(relatedStock_transfer0);
                }
            
                const relatedStock_transfer1 = await StockTransfers.findOne({
                    offset: Math.floor(Math.random() * (await StockTransfers.count())),
                });
                const StockTransferItem1 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransferItem1?.setStock_transfer)
                {
                    await
                    StockTransferItem1.
                    setStock_transfer(relatedStock_transfer1);
                }
            
                const relatedStock_transfer2 = await StockTransfers.findOne({
                    offset: Math.floor(Math.random() * (await StockTransfers.count())),
                });
                const StockTransferItem2 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransferItem2?.setStock_transfer)
                {
                    await
                    StockTransferItem2.
                    setStock_transfer(relatedStock_transfer2);
                }
            
        }
        
    
        
            
            async function associateStockTransferItemWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const StockTransferItem0 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransferItem0?.setProduct)
                {
                    await
                    StockTransferItem0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const StockTransferItem1 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransferItem1?.setProduct)
                {
                    await
                    StockTransferItem1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const StockTransferItem2 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransferItem2?.setProduct)
                {
                    await
                    StockTransferItem2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateStockTransferItemWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockTransferItem0 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (StockTransferItem0?.setOrganization)
                {
                    await
                    StockTransferItem0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockTransferItem1 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (StockTransferItem1?.setOrganization)
                {
                    await
                    StockTransferItem1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const StockTransferItem2 = await StockTransferItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (StockTransferItem2?.setOrganization)
                {
                    await
                    StockTransferItem2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Organizations.bulkCreate(OrganizationsData);
                
            
            
                
                await Stores.bulkCreate(StoresData);
                
            
            
                
                await Products.bulkCreate(ProductsData);
                
            
            
                
                await Brands.bulkCreate(BrandsData);
                
            
            
                
                await Categories.bulkCreate(CategoriesData);
                
            
            
                
                await Customers.bulkCreate(CustomersData);
                
            
            
                
                await PriceLists.bulkCreate(PriceListsData);
                
            
            
                
                await PriceListItems.bulkCreate(PriceListItemsData);
                
            
            
                
                await Discounts.bulkCreate(DiscountsData);
                
            
            
                
                await Registers.bulkCreate(RegistersData);
                
            
            
                
                await CashDrawerSessions.bulkCreate(CashDrawerSessionsData);
                
            
            
                
                await Sales.bulkCreate(SalesData);
                
            
            
                
                await SaleItems.bulkCreate(SaleItemsData);
                
            
            
                
                await Payments.bulkCreate(PaymentsData);
                
            
            
                
                await Returns.bulkCreate(ReturnsData);
                
            
            
                
                await ReturnItems.bulkCreate(ReturnItemsData);
                
            
            
                
                await Suppliers.bulkCreate(SuppliersData);
                
            
            
                
                await PurchaseOrders.bulkCreate(PurchaseOrdersData);
                
            
            
                
                await PurchaseOrderItems.bulkCreate(PurchaseOrderItemsData);
                
            
            
                
                await InventoryItems.bulkCreate(InventoryItemsData);
                
            
            
                
                await StockMovements.bulkCreate(StockMovementsData);
                
            
            
                
                await StockTransfers.bulkCreate(StockTransfersData);
                
            
            
                
                await StockTransferItems.bulkCreate(StockTransferItemsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateUserWithOrganization(),
                    
                
            
                
                
                
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateStoreWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductWithBrand(),
                    
                
                    
                        
                        await associateProductWithCategory(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateBrandWithOrganization(),
                    
                
            
                
                
                    
                
                    
                        
                        await associateCategoryWithParent_category(),
                    
                
                    
                
                    
                
                    
                        
                        await associateCategoryWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateCustomerWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associatePriceListWithStore(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePriceListWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePriceListItemWithPrice_list(),
                    
                
                    
                        
                        await associatePriceListItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePriceListItemWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDiscountWithStore(),
                    
                
                    
                        
                        await associateDiscountWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateRegisterWithStore(),
                    
                
                    
                
                    
                
                    
                        
                        await associateRegisterWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateCashDrawerSessionWithRegister(),
                    
                
                    
                        
                        await associateCashDrawerSessionWithOpened_by_user(),
                    
                
                    
                        
                        await associateCashDrawerSessionWithClosed_by_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateCashDrawerSessionWithOrganization(),
                    
                
            
                
                
                    
                
                    
                        
                        await associateSaleWithStore(),
                    
                
                    
                        
                        await associateSaleWithRegister(),
                    
                
                    
                        
                        await associateSaleWithCashier(),
                    
                
                    
                        
                        await associateSaleWithCustomer(),
                    
                
                    
                        
                        await associateSaleWithCash_drawer_session(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSaleWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateSaleItemWithSale(),
                    
                
                    
                        
                        await associateSaleItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSaleItemWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePaymentWithSale(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePaymentWithOrganization(),
                    
                
            
                
                
                    
                
                    
                        
                        await associateReturnWithOriginal_sale(),
                    
                
                    
                        
                        await associateReturnWithStore(),
                    
                
                    
                        
                        await associateReturnWithProcessed_by_user(),
                    
                
                    
                        
                        await associateReturnWithCustomer(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateReturnWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateReturnItemWithReturn(),
                    
                
                    
                        
                        await associateReturnItemWithSale_item(),
                    
                
                    
                        
                        await associateReturnItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateReturnItemWithOrganization(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSupplierWithOrganization(),
                    
                
            
                
                
                    
                
                    
                        
                        await associatePurchaseOrderWithStore(),
                    
                
                    
                        
                        await associatePurchaseOrderWithSupplier(),
                    
                
                    
                        
                        await associatePurchaseOrderWithCreated_by_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePurchaseOrderWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePurchaseOrderItemWithPurchase_order(),
                    
                
                    
                        
                        await associatePurchaseOrderItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePurchaseOrderItemWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateInventoryItemWithStore(),
                    
                
                    
                        
                        await associateInventoryItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateInventoryItemWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateStockMovementWithStore(),
                    
                
                    
                        
                        await associateStockMovementWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateStockMovementWithPerformed_by_user(),
                    
                
                    
                        
                        await associateStockMovementWithOrganization(),
                    
                
            
                
                
                    
                
                    
                        
                        await associateStockTransferWithFrom_store(),
                    
                
                    
                        
                        await associateStockTransferWithTo_store(),
                    
                
                    
                        
                        await associateStockTransferWithRequested_by_user(),
                    
                
                    
                        
                        await associateStockTransferWithApproved_by_user(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateStockTransferWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateStockTransferItemWithStock_transfer(),
                    
                
                    
                        
                        await associateStockTransferItemWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateStockTransferItemWithOrganization(),
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('organizations', null, {});
            
            
            await queryInterface.bulkDelete('stores', null, {});
            
            
            await queryInterface.bulkDelete('products', null, {});
            
            
            await queryInterface.bulkDelete('brands', null, {});
            
            
            await queryInterface.bulkDelete('categories', null, {});
            
            
            await queryInterface.bulkDelete('customers', null, {});
            
            
            await queryInterface.bulkDelete('price_lists', null, {});
            
            
            await queryInterface.bulkDelete('price_list_items', null, {});
            
            
            await queryInterface.bulkDelete('discounts', null, {});
            
            
            await queryInterface.bulkDelete('registers', null, {});
            
            
            await queryInterface.bulkDelete('cash_drawer_sessions', null, {});
            
            
            await queryInterface.bulkDelete('sales', null, {});
            
            
            await queryInterface.bulkDelete('sale_items', null, {});
            
            
            await queryInterface.bulkDelete('payments', null, {});
            
            
            await queryInterface.bulkDelete('returns', null, {});
            
            
            await queryInterface.bulkDelete('return_items', null, {});
            
            
            await queryInterface.bulkDelete('suppliers', null, {});
            
            
            await queryInterface.bulkDelete('purchase_orders', null, {});
            
            
            await queryInterface.bulkDelete('purchase_order_items', null, {});
            
            
            await queryInterface.bulkDelete('inventory_items', null, {});
            
            
            await queryInterface.bulkDelete('stock_movements', null, {});
            
            
            await queryInterface.bulkDelete('stock_transfers', null, {});
            
            
            await queryInterface.bulkDelete('stock_transfer_items', null, {});
            
        
    },
};