





















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






const Organizations = db.organizations;

const Firms = db.firms;

const Merchants = db.merchants;

const Customers = db.customers;

const Suppliers = db.suppliers;

const Products = db.products;

const Receipts = db.receipts;

const OcrExtractions = db.ocr_extractions;

const SalesInvoices = db.sales_invoices;

const SalesInvoiceLines = db.sales_invoice_lines;

const PurchaseInvoices = db.purchase_invoices;

const PurchaseInvoiceLines = db.purchase_invoice_lines;

const Expenses = db.expenses;

const TaxPeriods = db.tax_periods;

const VatDeclarations = db.vat_declarations;

const TotDeclarations = db.tot_declarations;

const DeclarationSubmissions = db.declaration_submissions;

const Messages = db.messages;

const AuditEvents = db.audit_events;







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



const FirmsData = [
    
    {
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "legal_name": "Marie Curie",
            
        
    
        
        
            
                "tax_id_number": "Marie Curie",
            
        
    
        
        
            
                "country": "Ada Lovelace",
            
        
    
        
        
            
                "city": "Marie Curie",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "contact_email": "Ada Lovelace",
            
        
    
        
        
            
                "contact_phone": "Alan Turing",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "trial_ends_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "legal_name": "Grace Hopper",
            
        
    
        
        
            
                "tax_id_number": "Grace Hopper",
            
        
    
        
        
            
                "country": "Marie Curie",
            
        
    
        
        
            
                "city": "Grace Hopper",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "contact_email": "Alan Turing",
            
        
    
        
        
            
                "contact_phone": "Alan Turing",
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                "trial_ends_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "name": "Marie Curie",
            
        
    
        
        
            
                "legal_name": "Ada Lovelace",
            
        
    
        
        
            
                "tax_id_number": "Marie Curie",
            
        
    
        
        
            
                "country": "Grace Hopper",
            
        
    
        
        
            
                "city": "Grace Hopper",
            
        
    
        
        
            
                "address": "Alan Turing",
            
        
    
        
        
            
                "contact_email": "Marie Curie",
            
        
    
        
        
            
                "contact_phone": "Alan Turing",
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "trial_ends_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const MerchantsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "business_name": "Alan Turing",
            
        
    
        
        
            
                "legal_name": "Marie Curie",
            
        
    
        
        
            
                "tin_number": "Marie Curie",
            
        
    
        
        
            
                "vat_registration_number": "Grace Hopper",
            
        
    
        
        
            
                "taxpayer_type": "tot",
            
        
    
        
        
            
                "industry": "other",
            
        
    
        
        
            
                "city": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Marie Curie",
            
        
    
        
        
            
                "contact_name": "Ada Lovelace",
            
        
    
        
        
            
                "contact_phone": "Ada Lovelace",
            
        
    
        
        
            
                "contact_email": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                "onboarded_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "business_name": "Ada Lovelace",
            
        
    
        
        
            
                "legal_name": "Ada Lovelace",
            
        
    
        
        
            
                "tin_number": "Ada Lovelace",
            
        
    
        
        
            
                "vat_registration_number": "Marie Curie",
            
        
    
        
        
            
                "taxpayer_type": "both",
            
        
    
        
        
            
                "industry": "hospitality",
            
        
    
        
        
            
                "city": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Marie Curie",
            
        
    
        
        
            
                "contact_name": "Ada Lovelace",
            
        
    
        
        
            
                "contact_phone": "Grace Hopper",
            
        
    
        
        
            
                "contact_email": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                "onboarded_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "business_name": "Ada Lovelace",
            
        
    
        
        
            
                "legal_name": "Marie Curie",
            
        
    
        
        
            
                "tin_number": "Grace Hopper",
            
        
    
        
        
            
                "vat_registration_number": "Marie Curie",
            
        
    
        
        
            
                "taxpayer_type": "vat",
            
        
    
        
        
            
                "industry": "manufacturing",
            
        
    
        
        
            
                "city": "Alan Turing",
            
        
    
        
        
            
                "address": "Alan Turing",
            
        
    
        
        
            
                "contact_name": "Marie Curie",
            
        
    
        
        
            
                "contact_phone": "Ada Lovelace",
            
        
    
        
        
            
                "contact_email": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                "onboarded_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const CustomersData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "tin_number": "Ada Lovelace",
            
        
    
        
        
            
                "phone": "Alan Turing",
            
        
    
        
        
            
                "email": "Alan Turing",
            
        
    
        
        
            
                "address": "Alan Turing",
            
        
    
        
        
            
                "category": "business",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "tin_number": "Alan Turing",
            
        
    
        
        
            
                "phone": "Grace Hopper",
            
        
    
        
        
            
                "email": "Marie Curie",
            
        
    
        
        
            
                "address": "Alan Turing",
            
        
    
        
        
            
                "category": "other",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "tin_number": "Ada Lovelace",
            
        
    
        
        
            
                "phone": "Alan Turing",
            
        
    
        
        
            
                "email": "Marie Curie",
            
        
    
        
        
            
                "address": "Ada Lovelace",
            
        
    
        
        
            
                "category": "government",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SuppliersData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Grace Hopper",
            
        
    
        
        
            
                "tin_number": "Marie Curie",
            
        
    
        
        
            
                "phone": "Grace Hopper",
            
        
    
        
        
            
                "email": "Alan Turing",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "category": "import",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "tin_number": "Ada Lovelace",
            
        
    
        
        
            
                "phone": "Ada Lovelace",
            
        
    
        
        
            
                "email": "Alan Turing",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "category": "import",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "tin_number": "Grace Hopper",
            
        
    
        
        
            
                "phone": "Marie Curie",
            
        
    
        
        
            
                "email": "Ada Lovelace",
            
        
    
        
        
            
                "address": "Grace Hopper",
            
        
    
        
        
            
                "category": "other",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ProductsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "sku": "Alan Turing",
            
        
    
        
        
            
                "tax_category": "exempt",
            
        
    
        
        
            
                "default_unit_price": 7.73,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Ada Lovelace",
            
        
    
        
        
            
                "sku": "Ada Lovelace",
            
        
    
        
        
            
                "tax_category": "standard_vat",
            
        
    
        
        
            
                "default_unit_price": 4.59,
            
        
    
        
        
            
                "is_active": false,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "name": "Alan Turing",
            
        
    
        
        
            
                "sku": "Alan Turing",
            
        
    
        
        
            
                "tax_category": "tot_applicable",
            
        
    
        
        
            
                "default_unit_price": 1.55,
            
        
    
        
        
            
                "is_active": true,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ReceiptsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "receipt_kind": "purchase",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "source_channel": "Grace Hopper",
            
        
    
        
        
            
                "captured_at": new Date(Date.now()),
            
        
    
        
        
            
                "ocr_status": "processing",
            
        
    
        
        
            
                "ocr_confidence": 1.27,
            
        
    
        
        
            
                "needs_review": true,
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "receipt_kind": "expense",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "source_channel": "Marie Curie",
            
        
    
        
        
            
                "captured_at": new Date(Date.now()),
            
        
    
        
        
            
                "ocr_status": "failed",
            
        
    
        
        
            
                "ocr_confidence": 9.96,
            
        
    
        
        
            
                "needs_review": true,
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "receipt_kind": "purchase",
            
        
    
        
        
            
                // type code here for "images" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "source_channel": "Ada Lovelace",
            
        
    
        
        
            
                "captured_at": new Date(Date.now()),
            
        
    
        
        
            
                "ocr_status": "processing",
            
        
    
        
        
            
                "ocr_confidence": 0.49,
            
        
    
        
        
            
                "needs_review": false,
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const OcrExtractionsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "processed_at": new Date(Date.now()),
            
        
    
        
        
            
                "engine": "google_vision",
            
        
    
        
        
            
                "status": "success",
            
        
    
        
        
            
                "invoice_number_text": "Ada Lovelace",
            
        
    
        
        
            
                "seller_name_text": "Ada Lovelace",
            
        
    
        
        
            
                "buyer_name_text": "Alan Turing",
            
        
    
        
        
            
                "tin_number_text": "Marie Curie",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal_amount": 8.16,
            
        
    
        
        
            
                "vat_amount": 6.93,
            
        
    
        
        
            
                "tot_amount": 3.37,
            
        
    
        
        
            
                "total_amount": 7.89,
            
        
    
        
        
            
                "raw_text": "Marie Curie",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "processed_at": new Date(Date.now()),
            
        
    
        
        
            
                "engine": "other",
            
        
    
        
        
            
                "status": "partial",
            
        
    
        
        
            
                "invoice_number_text": "Ada Lovelace",
            
        
    
        
        
            
                "seller_name_text": "Grace Hopper",
            
        
    
        
        
            
                "buyer_name_text": "Grace Hopper",
            
        
    
        
        
            
                "tin_number_text": "Marie Curie",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal_amount": 8.79,
            
        
    
        
        
            
                "vat_amount": 1.3,
            
        
    
        
        
            
                "tot_amount": 3.87,
            
        
    
        
        
            
                "total_amount": 8.8,
            
        
    
        
        
            
                "raw_text": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "processed_at": new Date(Date.now()),
            
        
    
        
        
            
                "engine": "aws_textract",
            
        
    
        
        
            
                "status": "success",
            
        
    
        
        
            
                "invoice_number_text": "Marie Curie",
            
        
    
        
        
            
                "seller_name_text": "Alan Turing",
            
        
    
        
        
            
                "buyer_name_text": "Grace Hopper",
            
        
    
        
        
            
                "tin_number_text": "Marie Curie",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "subtotal_amount": 8.59,
            
        
    
        
        
            
                "vat_amount": 5.63,
            
        
    
        
        
            
                "tot_amount": 8.98,
            
        
    
        
        
            
                "total_amount": 0.6,
            
        
    
        
        
            
                "raw_text": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SalesInvoicesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invoice_number": "Ada Lovelace",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "vat_treatment": "zero_rated",
            
        
    
        
        
            
                "subtotal_amount": 9.33,
            
        
    
        
        
            
                "vat_amount": 4.48,
            
        
    
        
        
            
                "total_amount": 6.87,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Grace Hopper",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "invoice_number": "Ada Lovelace",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "vat_treatment": "zero_rated",
            
        
    
        
        
            
                "subtotal_amount": 6.21,
            
        
    
        
        
            
                "vat_amount": 6.26,
            
        
    
        
        
            
                "total_amount": 0.94,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Marie Curie",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "invoice_number": "Ada Lovelace",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "submitted",
            
        
    
        
        
            
                "vat_treatment": "not_applicable",
            
        
    
        
        
            
                "subtotal_amount": 9.6,
            
        
    
        
        
            
                "vat_amount": 3.21,
            
        
    
        
        
            
                "total_amount": 7.76,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const SalesInvoiceLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                "quantity": 3.34,
            
        
    
        
        
            
                "unit_price": 2.7,
            
        
    
        
        
            
                "line_subtotal": 9.16,
            
        
    
        
        
            
                "vat_treatment": "standard_15",
            
        
    
        
        
            
                "vat_amount": 7.27,
            
        
    
        
        
            
                "line_total": 5.78,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "quantity": 8.38,
            
        
    
        
        
            
                "unit_price": 7.25,
            
        
    
        
        
            
                "line_subtotal": 7.41,
            
        
    
        
        
            
                "vat_treatment": "not_applicable",
            
        
    
        
        
            
                "vat_amount": 8.68,
            
        
    
        
        
            
                "line_total": 8.37,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "quantity": 8.93,
            
        
    
        
        
            
                "unit_price": 9.45,
            
        
    
        
        
            
                "line_subtotal": 9.79,
            
        
    
        
        
            
                "vat_treatment": "zero_rated",
            
        
    
        
        
            
                "vat_amount": 8.99,
            
        
    
        
        
            
                "line_total": 3.05,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PurchaseInvoicesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "invoice_number": "Grace Hopper",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "submitted",
            
        
    
        
        
            
                "vat_treatment": "standard_15",
            
        
    
        
        
            
                "subtotal_amount": 1.52,
            
        
    
        
        
            
                "vat_amount": 7.7,
            
        
    
        
        
            
                "withholding_tax_amount": 2.84,
            
        
    
        
        
            
                "total_amount": 5.94,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Grace Hopper",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "invoice_number": "Grace Hopper",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "vat_treatment": "exempt",
            
        
    
        
        
            
                "subtotal_amount": 7.21,
            
        
    
        
        
            
                "vat_amount": 9.78,
            
        
    
        
        
            
                "withholding_tax_amount": 2.15,
            
        
    
        
        
            
                "total_amount": 9.07,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Alan Turing",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "invoice_number": "Grace Hopper",
            
        
    
        
        
            
                "invoice_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "vat_treatment": "exempt",
            
        
    
        
        
            
                "subtotal_amount": 1.3,
            
        
    
        
        
            
                "vat_amount": 7.01,
            
        
    
        
        
            
                "withholding_tax_amount": 9.08,
            
        
    
        
        
            
                "total_amount": 1.86,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const PurchaseInvoiceLinesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "quantity": 9.36,
            
        
    
        
        
            
                "unit_price": 1.09,
            
        
    
        
        
            
                "line_subtotal": 1.97,
            
        
    
        
        
            
                "vat_treatment": "not_applicable",
            
        
    
        
        
            
                "vat_amount": 4.99,
            
        
    
        
        
            
                "line_total": 4.73,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "quantity": 9.42,
            
        
    
        
        
            
                "unit_price": 4.9,
            
        
    
        
        
            
                "line_subtotal": 2.26,
            
        
    
        
        
            
                "vat_treatment": "standard_15",
            
        
    
        
        
            
                "vat_amount": 8.94,
            
        
    
        
        
            
                "line_total": 8.53,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Grace Hopper",
            
        
    
        
        
            
                "quantity": 5.32,
            
        
    
        
        
            
                "unit_price": 6.64,
            
        
    
        
        
            
                "line_subtotal": 0.73,
            
        
    
        
        
            
                "vat_treatment": "exempt",
            
        
    
        
        
            
                "vat_amount": 2.12,
            
        
    
        
        
            
                "line_total": 4.91,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ExpensesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "category": "rent",
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "expense_date": new Date(Date.now()),
            
        
    
        
        
            
                "amount": 3.3,
            
        
    
        
        
            
                "tax_treatment": "capitalizable",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "category": "transport",
            
        
    
        
        
            
                "description": "Ada Lovelace",
            
        
    
        
        
            
                "expense_date": new Date(Date.now()),
            
        
    
        
        
            
                "amount": 3.02,
            
        
    
        
        
            
                "tax_treatment": "non_deductible",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "category": "transport",
            
        
    
        
        
            
                "description": "Marie Curie",
            
        
    
        
        
            
                "expense_date": new Date(Date.now()),
            
        
    
        
        
            
                "amount": 4.88,
            
        
    
        
        
            
                "tax_treatment": "unknown",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "review_notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const TaxPeriodsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "period_type": "monthly",
            
        
    
        
        
            
                "year_number": 4,
            
        
    
        
        
            
                "period_number": 8,
            
        
    
        
        
            
                "start_date": new Date(Date.now()),
            
        
    
        
        
            
                "end_date": new Date(Date.now()),
            
        
    
        
        
            
                "due_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "period_type": "monthly",
            
        
    
        
        
            
                "year_number": 7,
            
        
    
        
        
            
                "period_number": 6,
            
        
    
        
        
            
                "start_date": new Date(Date.now()),
            
        
    
        
        
            
                "end_date": new Date(Date.now()),
            
        
    
        
        
            
                "due_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "ready_to_file",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "period_type": "annual",
            
        
    
        
        
            
                "year_number": 8,
            
        
    
        
        
            
                "period_number": 2,
            
        
    
        
        
            
                "start_date": new Date(Date.now()),
            
        
    
        
        
            
                "end_date": new Date(Date.now()),
            
        
    
        
        
            
                "due_date": new Date(Date.now()),
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const VatDeclarationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "reviewed",
            
        
    
        
        
            
                "total_sales_amount": 4.27,
            
        
    
        
        
            
                "taxable_sales_amount": 9.42,
            
        
    
        
        
            
                "output_vat_amount": 5.55,
            
        
    
        
        
            
                "total_purchases_amount": 2.04,
            
        
    
        
        
            
                "input_vat_amount": 0.84,
            
        
    
        
        
            
                "vat_payable_amount": 3.51,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "generated_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "total_sales_amount": 0.85,
            
        
    
        
        
            
                "taxable_sales_amount": 7.46,
            
        
    
        
        
            
                "output_vat_amount": 4.51,
            
        
    
        
        
            
                "total_purchases_amount": 8.7,
            
        
    
        
        
            
                "input_vat_amount": 6.94,
            
        
    
        
        
            
                "vat_payable_amount": 5.36,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "generated_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "reviewed",
            
        
    
        
        
            
                "total_sales_amount": 4.94,
            
        
    
        
        
            
                "taxable_sales_amount": 1.71,
            
        
    
        
        
            
                "output_vat_amount": 6.37,
            
        
    
        
        
            
                "total_purchases_amount": 1.72,
            
        
    
        
        
            
                "input_vat_amount": 7.69,
            
        
    
        
        
            
                "vat_payable_amount": 2.27,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "generated_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const TotDeclarationsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "gross_sales_amount": 0.24,
            
        
    
        
        
            
                "tot_rate_percent": 3.14,
            
        
    
        
        
            
                "tot_payable_amount": 8.23,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "generated_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "generated",
            
        
    
        
        
            
                "gross_sales_amount": 8.92,
            
        
    
        
        
            
                "tot_rate_percent": 5.8,
            
        
    
        
        
            
                "tot_payable_amount": 1.99,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "generated_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Alan Turing",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "generated",
            
        
    
        
        
            
                "gross_sales_amount": 0.49,
            
        
    
        
        
            
                "tot_rate_percent": 0.85,
            
        
    
        
        
            
                "tot_payable_amount": 8.27,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "generated_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reviewed_at": new Date(Date.now()),
            
        
    
        
        
            
                "notes": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const DeclarationSubmissionsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "declaration_type": "income_tax",
            
        
    
        
        
            
                "submission_reference": "Grace Hopper",
            
        
    
        
        
            
                "submitted_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "failed",
            
        
    
        
        
            
                "response_message": "Grace Hopper",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "declaration_type": "vat",
            
        
    
        
        
            
                "submission_reference": "Grace Hopper",
            
        
    
        
        
            
                "submitted_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "failed",
            
        
    
        
        
            
                "response_message": "Marie Curie",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "declaration_type": "vat",
            
        
    
        
        
            
                "submission_reference": "Marie Curie",
            
        
    
        
        
            
                "submitted_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "received",
            
        
    
        
        
            
                "response_message": "Ada Lovelace",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const MessagesData = [
    
    {
    
        
        
            
                // 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
            
        
    
        
        
            
                "channel": "in_app",
            
        
    
        
        
            
                "subject": "Grace Hopper",
            
        
    
        
        
            
                "body": "Grace Hopper",
            
        
    
        
        
            
                "status": "delivered",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "in_app",
            
        
    
        
        
            
                "subject": "Ada Lovelace",
            
        
    
        
        
            
                "body": "Grace Hopper",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "channel": "email",
            
        
    
        
        
            
                "subject": "Grace Hopper",
            
        
    
        
        
            
                "body": "Alan Turing",
            
        
    
        
        
            
                "status": "read",
            
        
    
        
        
            
                "sent_at": new Date(Date.now()),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const AuditEventsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action": "delete",
            
        
    
        
        
            
                "entity_name": "Ada Lovelace",
            
        
    
        
        
            
                "record_key": "Alan Turing",
            
        
    
        
        
            
                "occurred_at": new Date(Date.now()),
            
        
    
        
        
            
                "details": "Alan Turing",
            
        
    
        
        
            
                "ip_address": "Alan Turing",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "action": "update",
            
        
    
        
        
            
                "entity_name": "Marie Curie",
            
        
    
        
        
            
                "record_key": "Alan Turing",
            
        
    
        
        
            
                "occurred_at": new Date(Date.now()),
            
        
    
        
        
            
                "details": "Grace Hopper",
            
        
    
        
        
            
                "ip_address": "Grace Hopper",
            
        
    
        
        
            
                // 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
            
        
    
        
        
            
                "action": "create",
            
        
    
        
        
            
                "entity_name": "Grace Hopper",
            
        
    
        
        
            
                "record_key": "Grace Hopper",
            
        
    
        
        
            
                "occurred_at": new Date(Date.now()),
            
        
    
        
        
            
                "details": "Marie Curie",
            
        
    
        
        
            
                "ip_address": "Grace Hopper",
            
        
    
        
        
            
                // 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 associateFirmWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Firm0 = await Firms.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Firm0?.setOrganization)
                {
                    await
                    Firm0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Firm1 = await Firms.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Firm1?.setOrganization)
                {
                    await
                    Firm1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Firm2 = await Firms.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Firm2?.setOrganization)
                {
                    await
                    Firm2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateMerchantWithFirm() {
            
                const relatedFirm0 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const Merchant0 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Merchant0?.setFirm)
                {
                    await
                    Merchant0.
                    setFirm(relatedFirm0);
                }
            
                const relatedFirm1 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const Merchant1 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Merchant1?.setFirm)
                {
                    await
                    Merchant1.
                    setFirm(relatedFirm1);
                }
            
                const relatedFirm2 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const Merchant2 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Merchant2?.setFirm)
                {
                    await
                    Merchant2.
                    setFirm(relatedFirm2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMerchantWithAssigned_accountant() {
            
                const relatedAssigned_accountant0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Merchant0 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Merchant0?.setAssigned_accountant)
                {
                    await
                    Merchant0.
                    setAssigned_accountant(relatedAssigned_accountant0);
                }
            
                const relatedAssigned_accountant1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Merchant1 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Merchant1?.setAssigned_accountant)
                {
                    await
                    Merchant1.
                    setAssigned_accountant(relatedAssigned_accountant1);
                }
            
                const relatedAssigned_accountant2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Merchant2 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Merchant2?.setAssigned_accountant)
                {
                    await
                    Merchant2.
                    setAssigned_accountant(relatedAssigned_accountant2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateMerchantWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Merchant0 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Merchant0?.setOrganization)
                {
                    await
                    Merchant0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Merchant1 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Merchant1?.setOrganization)
                {
                    await
                    Merchant1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Merchant2 = await Merchants.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Merchant2?.setOrganization)
                {
                    await
                    Merchant2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateCustomerWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Customer0 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Customer0?.setMerchant)
                {
                    await
                    Customer0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Customer1 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Customer1?.setMerchant)
                {
                    await
                    Customer1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Customer2 = await Customers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Customer2?.setMerchant)
                {
                    await
                    Customer2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            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 associateSupplierWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Supplier0 = await Suppliers.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Supplier0?.setMerchant)
                {
                    await
                    Supplier0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Supplier1 = await Suppliers.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Supplier1?.setMerchant)
                {
                    await
                    Supplier1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Supplier2 = await Suppliers.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Supplier2?.setMerchant)
                {
                    await
                    Supplier2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            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 associateProductWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Product0 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Product0?.setMerchant)
                {
                    await
                    Product0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Product1 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Product1?.setMerchant)
                {
                    await
                    Product1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Product2 = await Products.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Product2?.setMerchant)
                {
                    await
                    Product2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            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 associateReceiptWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Receipt0 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Receipt0?.setMerchant)
                {
                    await
                    Receipt0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Receipt1 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Receipt1?.setMerchant)
                {
                    await
                    Receipt1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Receipt2 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Receipt2?.setMerchant)
                {
                    await
                    Receipt2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateReceiptWithUploaded_by() {
            
                const relatedUploaded_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt0 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Receipt0?.setUploaded_by)
                {
                    await
                    Receipt0.
                    setUploaded_by(relatedUploaded_by0);
                }
            
                const relatedUploaded_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt1 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Receipt1?.setUploaded_by)
                {
                    await
                    Receipt1.
                    setUploaded_by(relatedUploaded_by1);
                }
            
                const relatedUploaded_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Receipt2 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Receipt2?.setUploaded_by)
                {
                    await
                    Receipt2.
                    setUploaded_by(relatedUploaded_by2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateReceiptWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Receipt0 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Receipt0?.setOrganization)
                {
                    await
                    Receipt0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Receipt1 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Receipt1?.setOrganization)
                {
                    await
                    Receipt1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Receipt2 = await Receipts.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Receipt2?.setOrganization)
                {
                    await
                    Receipt2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateOcrExtractionWithReceipt() {
            
                const relatedReceipt0 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const OcrExtraction0 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (OcrExtraction0?.setReceipt)
                {
                    await
                    OcrExtraction0.
                    setReceipt(relatedReceipt0);
                }
            
                const relatedReceipt1 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const OcrExtraction1 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (OcrExtraction1?.setReceipt)
                {
                    await
                    OcrExtraction1.
                    setReceipt(relatedReceipt1);
                }
            
                const relatedReceipt2 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const OcrExtraction2 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (OcrExtraction2?.setReceipt)
                {
                    await
                    OcrExtraction2.
                    setReceipt(relatedReceipt2);
                }
            
        }
        
    
        
            
            async function associateOcrExtractionWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const OcrExtraction0 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (OcrExtraction0?.setMerchant)
                {
                    await
                    OcrExtraction0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const OcrExtraction1 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (OcrExtraction1?.setMerchant)
                {
                    await
                    OcrExtraction1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const OcrExtraction2 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (OcrExtraction2?.setMerchant)
                {
                    await
                    OcrExtraction2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateOcrExtractionWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const OcrExtraction0 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (OcrExtraction0?.setOrganization)
                {
                    await
                    OcrExtraction0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const OcrExtraction1 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (OcrExtraction1?.setOrganization)
                {
                    await
                    OcrExtraction1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const OcrExtraction2 = await OcrExtractions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (OcrExtraction2?.setOrganization)
                {
                    await
                    OcrExtraction2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateSalesInvoiceWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const SalesInvoice0 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoice0?.setMerchant)
                {
                    await
                    SalesInvoice0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const SalesInvoice1 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoice1?.setMerchant)
                {
                    await
                    SalesInvoice1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const SalesInvoice2 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoice2?.setMerchant)
                {
                    await
                    SalesInvoice2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateSalesInvoiceWithCustomer() {
            
                const relatedCustomer0 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const SalesInvoice0 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoice0?.setCustomer)
                {
                    await
                    SalesInvoice0.
                    setCustomer(relatedCustomer0);
                }
            
                const relatedCustomer1 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const SalesInvoice1 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoice1?.setCustomer)
                {
                    await
                    SalesInvoice1.
                    setCustomer(relatedCustomer1);
                }
            
                const relatedCustomer2 = await Customers.findOne({
                    offset: Math.floor(Math.random() * (await Customers.count())),
                });
                const SalesInvoice2 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoice2?.setCustomer)
                {
                    await
                    SalesInvoice2.
                    setCustomer(relatedCustomer2);
                }
            
        }
        
    
        
            
            async function associateSalesInvoiceWithReceipt() {
            
                const relatedReceipt0 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const SalesInvoice0 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoice0?.setReceipt)
                {
                    await
                    SalesInvoice0.
                    setReceipt(relatedReceipt0);
                }
            
                const relatedReceipt1 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const SalesInvoice1 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoice1?.setReceipt)
                {
                    await
                    SalesInvoice1.
                    setReceipt(relatedReceipt1);
                }
            
                const relatedReceipt2 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const SalesInvoice2 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoice2?.setReceipt)
                {
                    await
                    SalesInvoice2.
                    setReceipt(relatedReceipt2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateSalesInvoiceWithEntered_by() {
            
                const relatedEntered_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const SalesInvoice0 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoice0?.setEntered_by)
                {
                    await
                    SalesInvoice0.
                    setEntered_by(relatedEntered_by0);
                }
            
                const relatedEntered_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const SalesInvoice1 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoice1?.setEntered_by)
                {
                    await
                    SalesInvoice1.
                    setEntered_by(relatedEntered_by1);
                }
            
                const relatedEntered_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const SalesInvoice2 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoice2?.setEntered_by)
                {
                    await
                    SalesInvoice2.
                    setEntered_by(relatedEntered_by2);
                }
            
        }
        
    
        
            
            async function associateSalesInvoiceWithReviewed_by() {
            
                const relatedReviewed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const SalesInvoice0 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoice0?.setReviewed_by)
                {
                    await
                    SalesInvoice0.
                    setReviewed_by(relatedReviewed_by0);
                }
            
                const relatedReviewed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const SalesInvoice1 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoice1?.setReviewed_by)
                {
                    await
                    SalesInvoice1.
                    setReviewed_by(relatedReviewed_by1);
                }
            
                const relatedReviewed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const SalesInvoice2 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoice2?.setReviewed_by)
                {
                    await
                    SalesInvoice2.
                    setReviewed_by(relatedReviewed_by2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateSalesInvoiceWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SalesInvoice0 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoice0?.setOrganization)
                {
                    await
                    SalesInvoice0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SalesInvoice1 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoice1?.setOrganization)
                {
                    await
                    SalesInvoice1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SalesInvoice2 = await SalesInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoice2?.setOrganization)
                {
                    await
                    SalesInvoice2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateSalesInvoiceLineWithSales_invoice() {
            
                const relatedSales_invoice0 = await SalesInvoices.findOne({
                    offset: Math.floor(Math.random() * (await SalesInvoices.count())),
                });
                const SalesInvoiceLine0 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoiceLine0?.setSales_invoice)
                {
                    await
                    SalesInvoiceLine0.
                    setSales_invoice(relatedSales_invoice0);
                }
            
                const relatedSales_invoice1 = await SalesInvoices.findOne({
                    offset: Math.floor(Math.random() * (await SalesInvoices.count())),
                });
                const SalesInvoiceLine1 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoiceLine1?.setSales_invoice)
                {
                    await
                    SalesInvoiceLine1.
                    setSales_invoice(relatedSales_invoice1);
                }
            
                const relatedSales_invoice2 = await SalesInvoices.findOne({
                    offset: Math.floor(Math.random() * (await SalesInvoices.count())),
                });
                const SalesInvoiceLine2 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoiceLine2?.setSales_invoice)
                {
                    await
                    SalesInvoiceLine2.
                    setSales_invoice(relatedSales_invoice2);
                }
            
        }
        
    
        
            
            async function associateSalesInvoiceLineWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const SalesInvoiceLine0 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoiceLine0?.setProduct)
                {
                    await
                    SalesInvoiceLine0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const SalesInvoiceLine1 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoiceLine1?.setProduct)
                {
                    await
                    SalesInvoiceLine1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const SalesInvoiceLine2 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoiceLine2?.setProduct)
                {
                    await
                    SalesInvoiceLine2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateSalesInvoiceLineWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SalesInvoiceLine0 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (SalesInvoiceLine0?.setOrganization)
                {
                    await
                    SalesInvoiceLine0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SalesInvoiceLine1 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (SalesInvoiceLine1?.setOrganization)
                {
                    await
                    SalesInvoiceLine1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const SalesInvoiceLine2 = await SalesInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (SalesInvoiceLine2?.setOrganization)
                {
                    await
                    SalesInvoiceLine2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePurchaseInvoiceWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const PurchaseInvoice0 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoice0?.setMerchant)
                {
                    await
                    PurchaseInvoice0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const PurchaseInvoice1 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoice1?.setMerchant)
                {
                    await
                    PurchaseInvoice1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const PurchaseInvoice2 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoice2?.setMerchant)
                {
                    await
                    PurchaseInvoice2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associatePurchaseInvoiceWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseInvoice0 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoice0?.setSupplier)
                {
                    await
                    PurchaseInvoice0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseInvoice1 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoice1?.setSupplier)
                {
                    await
                    PurchaseInvoice1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const PurchaseInvoice2 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoice2?.setSupplier)
                {
                    await
                    PurchaseInvoice2.
                    setSupplier(relatedSupplier2);
                }
            
        }
        
    
        
            
            async function associatePurchaseInvoiceWithReceipt() {
            
                const relatedReceipt0 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const PurchaseInvoice0 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoice0?.setReceipt)
                {
                    await
                    PurchaseInvoice0.
                    setReceipt(relatedReceipt0);
                }
            
                const relatedReceipt1 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const PurchaseInvoice1 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoice1?.setReceipt)
                {
                    await
                    PurchaseInvoice1.
                    setReceipt(relatedReceipt1);
                }
            
                const relatedReceipt2 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const PurchaseInvoice2 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoice2?.setReceipt)
                {
                    await
                    PurchaseInvoice2.
                    setReceipt(relatedReceipt2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePurchaseInvoiceWithEntered_by() {
            
                const relatedEntered_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseInvoice0 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoice0?.setEntered_by)
                {
                    await
                    PurchaseInvoice0.
                    setEntered_by(relatedEntered_by0);
                }
            
                const relatedEntered_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseInvoice1 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoice1?.setEntered_by)
                {
                    await
                    PurchaseInvoice1.
                    setEntered_by(relatedEntered_by1);
                }
            
                const relatedEntered_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseInvoice2 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoice2?.setEntered_by)
                {
                    await
                    PurchaseInvoice2.
                    setEntered_by(relatedEntered_by2);
                }
            
        }
        
    
        
            
            async function associatePurchaseInvoiceWithReviewed_by() {
            
                const relatedReviewed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseInvoice0 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoice0?.setReviewed_by)
                {
                    await
                    PurchaseInvoice0.
                    setReviewed_by(relatedReviewed_by0);
                }
            
                const relatedReviewed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseInvoice1 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoice1?.setReviewed_by)
                {
                    await
                    PurchaseInvoice1.
                    setReviewed_by(relatedReviewed_by1);
                }
            
                const relatedReviewed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const PurchaseInvoice2 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoice2?.setReviewed_by)
                {
                    await
                    PurchaseInvoice2.
                    setReviewed_by(relatedReviewed_by2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associatePurchaseInvoiceWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseInvoice0 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoice0?.setOrganization)
                {
                    await
                    PurchaseInvoice0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseInvoice1 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoice1?.setOrganization)
                {
                    await
                    PurchaseInvoice1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseInvoice2 = await PurchaseInvoices.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoice2?.setOrganization)
                {
                    await
                    PurchaseInvoice2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associatePurchaseInvoiceLineWithPurchase_invoice() {
            
                const relatedPurchase_invoice0 = await PurchaseInvoices.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseInvoices.count())),
                });
                const PurchaseInvoiceLine0 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoiceLine0?.setPurchase_invoice)
                {
                    await
                    PurchaseInvoiceLine0.
                    setPurchase_invoice(relatedPurchase_invoice0);
                }
            
                const relatedPurchase_invoice1 = await PurchaseInvoices.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseInvoices.count())),
                });
                const PurchaseInvoiceLine1 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoiceLine1?.setPurchase_invoice)
                {
                    await
                    PurchaseInvoiceLine1.
                    setPurchase_invoice(relatedPurchase_invoice1);
                }
            
                const relatedPurchase_invoice2 = await PurchaseInvoices.findOne({
                    offset: Math.floor(Math.random() * (await PurchaseInvoices.count())),
                });
                const PurchaseInvoiceLine2 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoiceLine2?.setPurchase_invoice)
                {
                    await
                    PurchaseInvoiceLine2.
                    setPurchase_invoice(relatedPurchase_invoice2);
                }
            
        }
        
    
        
            
            async function associatePurchaseInvoiceLineWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PurchaseInvoiceLine0 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoiceLine0?.setProduct)
                {
                    await
                    PurchaseInvoiceLine0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PurchaseInvoiceLine1 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoiceLine1?.setProduct)
                {
                    await
                    PurchaseInvoiceLine1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const PurchaseInvoiceLine2 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoiceLine2?.setProduct)
                {
                    await
                    PurchaseInvoiceLine2.
                    setProduct(relatedProduct2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associatePurchaseInvoiceLineWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseInvoiceLine0 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (PurchaseInvoiceLine0?.setOrganization)
                {
                    await
                    PurchaseInvoiceLine0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseInvoiceLine1 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (PurchaseInvoiceLine1?.setOrganization)
                {
                    await
                    PurchaseInvoiceLine1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const PurchaseInvoiceLine2 = await PurchaseInvoiceLines.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (PurchaseInvoiceLine2?.setOrganization)
                {
                    await
                    PurchaseInvoiceLine2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateExpensWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Expens0 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Expens0?.setMerchant)
                {
                    await
                    Expens0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Expens1 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Expens1?.setMerchant)
                {
                    await
                    Expens1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Expens2 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Expens2?.setMerchant)
                {
                    await
                    Expens2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateExpensWithReceipt() {
            
                const relatedReceipt0 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const Expens0 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Expens0?.setReceipt)
                {
                    await
                    Expens0.
                    setReceipt(relatedReceipt0);
                }
            
                const relatedReceipt1 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const Expens1 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Expens1?.setReceipt)
                {
                    await
                    Expens1.
                    setReceipt(relatedReceipt1);
                }
            
                const relatedReceipt2 = await Receipts.findOne({
                    offset: Math.floor(Math.random() * (await Receipts.count())),
                });
                const Expens2 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Expens2?.setReceipt)
                {
                    await
                    Expens2.
                    setReceipt(relatedReceipt2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateExpensWithEntered_by() {
            
                const relatedEntered_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Expens0 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Expens0?.setEntered_by)
                {
                    await
                    Expens0.
                    setEntered_by(relatedEntered_by0);
                }
            
                const relatedEntered_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Expens1 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Expens1?.setEntered_by)
                {
                    await
                    Expens1.
                    setEntered_by(relatedEntered_by1);
                }
            
                const relatedEntered_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Expens2 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Expens2?.setEntered_by)
                {
                    await
                    Expens2.
                    setEntered_by(relatedEntered_by2);
                }
            
        }
        
    
        
            
            async function associateExpensWithReviewed_by() {
            
                const relatedReviewed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Expens0 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Expens0?.setReviewed_by)
                {
                    await
                    Expens0.
                    setReviewed_by(relatedReviewed_by0);
                }
            
                const relatedReviewed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Expens1 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Expens1?.setReviewed_by)
                {
                    await
                    Expens1.
                    setReviewed_by(relatedReviewed_by1);
                }
            
                const relatedReviewed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Expens2 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Expens2?.setReviewed_by)
                {
                    await
                    Expens2.
                    setReviewed_by(relatedReviewed_by2);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateExpensWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Expens0 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Expens0?.setOrganization)
                {
                    await
                    Expens0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Expens1 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Expens1?.setOrganization)
                {
                    await
                    Expens1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Expens2 = await Expenses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Expens2?.setOrganization)
                {
                    await
                    Expens2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateTaxPeriodWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const TaxPeriod0 = await TaxPeriods.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TaxPeriod0?.setMerchant)
                {
                    await
                    TaxPeriod0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const TaxPeriod1 = await TaxPeriods.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TaxPeriod1?.setMerchant)
                {
                    await
                    TaxPeriod1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const TaxPeriod2 = await TaxPeriods.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TaxPeriod2?.setMerchant)
                {
                    await
                    TaxPeriod2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateTaxPeriodWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TaxPeriod0 = await TaxPeriods.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TaxPeriod0?.setOrganization)
                {
                    await
                    TaxPeriod0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TaxPeriod1 = await TaxPeriods.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TaxPeriod1?.setOrganization)
                {
                    await
                    TaxPeriod1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TaxPeriod2 = await TaxPeriods.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TaxPeriod2?.setOrganization)
                {
                    await
                    TaxPeriod2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateVatDeclarationWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const VatDeclaration0 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (VatDeclaration0?.setMerchant)
                {
                    await
                    VatDeclaration0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const VatDeclaration1 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (VatDeclaration1?.setMerchant)
                {
                    await
                    VatDeclaration1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const VatDeclaration2 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (VatDeclaration2?.setMerchant)
                {
                    await
                    VatDeclaration2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateVatDeclarationWithTax_period() {
            
                const relatedTax_period0 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const VatDeclaration0 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (VatDeclaration0?.setTax_period)
                {
                    await
                    VatDeclaration0.
                    setTax_period(relatedTax_period0);
                }
            
                const relatedTax_period1 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const VatDeclaration1 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (VatDeclaration1?.setTax_period)
                {
                    await
                    VatDeclaration1.
                    setTax_period(relatedTax_period1);
                }
            
                const relatedTax_period2 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const VatDeclaration2 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (VatDeclaration2?.setTax_period)
                {
                    await
                    VatDeclaration2.
                    setTax_period(relatedTax_period2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateVatDeclarationWithGenerated_by() {
            
                const relatedGenerated_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const VatDeclaration0 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (VatDeclaration0?.setGenerated_by)
                {
                    await
                    VatDeclaration0.
                    setGenerated_by(relatedGenerated_by0);
                }
            
                const relatedGenerated_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const VatDeclaration1 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (VatDeclaration1?.setGenerated_by)
                {
                    await
                    VatDeclaration1.
                    setGenerated_by(relatedGenerated_by1);
                }
            
                const relatedGenerated_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const VatDeclaration2 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (VatDeclaration2?.setGenerated_by)
                {
                    await
                    VatDeclaration2.
                    setGenerated_by(relatedGenerated_by2);
                }
            
        }
        
    
        
    
        
            
            async function associateVatDeclarationWithReviewed_by() {
            
                const relatedReviewed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const VatDeclaration0 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (VatDeclaration0?.setReviewed_by)
                {
                    await
                    VatDeclaration0.
                    setReviewed_by(relatedReviewed_by0);
                }
            
                const relatedReviewed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const VatDeclaration1 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (VatDeclaration1?.setReviewed_by)
                {
                    await
                    VatDeclaration1.
                    setReviewed_by(relatedReviewed_by1);
                }
            
                const relatedReviewed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const VatDeclaration2 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (VatDeclaration2?.setReviewed_by)
                {
                    await
                    VatDeclaration2.
                    setReviewed_by(relatedReviewed_by2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateVatDeclarationWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const VatDeclaration0 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (VatDeclaration0?.setOrganization)
                {
                    await
                    VatDeclaration0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const VatDeclaration1 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (VatDeclaration1?.setOrganization)
                {
                    await
                    VatDeclaration1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const VatDeclaration2 = await VatDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (VatDeclaration2?.setOrganization)
                {
                    await
                    VatDeclaration2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateTotDeclarationWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const TotDeclaration0 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TotDeclaration0?.setMerchant)
                {
                    await
                    TotDeclaration0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const TotDeclaration1 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TotDeclaration1?.setMerchant)
                {
                    await
                    TotDeclaration1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const TotDeclaration2 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TotDeclaration2?.setMerchant)
                {
                    await
                    TotDeclaration2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateTotDeclarationWithTax_period() {
            
                const relatedTax_period0 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const TotDeclaration0 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TotDeclaration0?.setTax_period)
                {
                    await
                    TotDeclaration0.
                    setTax_period(relatedTax_period0);
                }
            
                const relatedTax_period1 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const TotDeclaration1 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TotDeclaration1?.setTax_period)
                {
                    await
                    TotDeclaration1.
                    setTax_period(relatedTax_period1);
                }
            
                const relatedTax_period2 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const TotDeclaration2 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TotDeclaration2?.setTax_period)
                {
                    await
                    TotDeclaration2.
                    setTax_period(relatedTax_period2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateTotDeclarationWithGenerated_by() {
            
                const relatedGenerated_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TotDeclaration0 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TotDeclaration0?.setGenerated_by)
                {
                    await
                    TotDeclaration0.
                    setGenerated_by(relatedGenerated_by0);
                }
            
                const relatedGenerated_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TotDeclaration1 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TotDeclaration1?.setGenerated_by)
                {
                    await
                    TotDeclaration1.
                    setGenerated_by(relatedGenerated_by1);
                }
            
                const relatedGenerated_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TotDeclaration2 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TotDeclaration2?.setGenerated_by)
                {
                    await
                    TotDeclaration2.
                    setGenerated_by(relatedGenerated_by2);
                }
            
        }
        
    
        
    
        
            
            async function associateTotDeclarationWithReviewed_by() {
            
                const relatedReviewed_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TotDeclaration0 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TotDeclaration0?.setReviewed_by)
                {
                    await
                    TotDeclaration0.
                    setReviewed_by(relatedReviewed_by0);
                }
            
                const relatedReviewed_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TotDeclaration1 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TotDeclaration1?.setReviewed_by)
                {
                    await
                    TotDeclaration1.
                    setReviewed_by(relatedReviewed_by1);
                }
            
                const relatedReviewed_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TotDeclaration2 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TotDeclaration2?.setReviewed_by)
                {
                    await
                    TotDeclaration2.
                    setReviewed_by(relatedReviewed_by2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateTotDeclarationWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TotDeclaration0 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TotDeclaration0?.setOrganization)
                {
                    await
                    TotDeclaration0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TotDeclaration1 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TotDeclaration1?.setOrganization)
                {
                    await
                    TotDeclaration1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const TotDeclaration2 = await TotDeclarations.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TotDeclaration2?.setOrganization)
                {
                    await
                    TotDeclaration2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateDeclarationSubmissionWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const DeclarationSubmission0 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeclarationSubmission0?.setMerchant)
                {
                    await
                    DeclarationSubmission0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const DeclarationSubmission1 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeclarationSubmission1?.setMerchant)
                {
                    await
                    DeclarationSubmission1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const DeclarationSubmission2 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeclarationSubmission2?.setMerchant)
                {
                    await
                    DeclarationSubmission2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateDeclarationSubmissionWithTax_period() {
            
                const relatedTax_period0 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const DeclarationSubmission0 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeclarationSubmission0?.setTax_period)
                {
                    await
                    DeclarationSubmission0.
                    setTax_period(relatedTax_period0);
                }
            
                const relatedTax_period1 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const DeclarationSubmission1 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeclarationSubmission1?.setTax_period)
                {
                    await
                    DeclarationSubmission1.
                    setTax_period(relatedTax_period1);
                }
            
                const relatedTax_period2 = await TaxPeriods.findOne({
                    offset: Math.floor(Math.random() * (await TaxPeriods.count())),
                });
                const DeclarationSubmission2 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeclarationSubmission2?.setTax_period)
                {
                    await
                    DeclarationSubmission2.
                    setTax_period(relatedTax_period2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateDeclarationSubmissionWithSubmitted_by() {
            
                const relatedSubmitted_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DeclarationSubmission0 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeclarationSubmission0?.setSubmitted_by)
                {
                    await
                    DeclarationSubmission0.
                    setSubmitted_by(relatedSubmitted_by0);
                }
            
                const relatedSubmitted_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DeclarationSubmission1 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeclarationSubmission1?.setSubmitted_by)
                {
                    await
                    DeclarationSubmission1.
                    setSubmitted_by(relatedSubmitted_by1);
                }
            
                const relatedSubmitted_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DeclarationSubmission2 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeclarationSubmission2?.setSubmitted_by)
                {
                    await
                    DeclarationSubmission2.
                    setSubmitted_by(relatedSubmitted_by2);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateDeclarationSubmissionWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const DeclarationSubmission0 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeclarationSubmission0?.setOrganization)
                {
                    await
                    DeclarationSubmission0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const DeclarationSubmission1 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeclarationSubmission1?.setOrganization)
                {
                    await
                    DeclarationSubmission1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const DeclarationSubmission2 = await DeclarationSubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeclarationSubmission2?.setOrganization)
                {
                    await
                    DeclarationSubmission2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateMessageWithFirm() {
            
                const relatedFirm0 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const Message0 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Message0?.setFirm)
                {
                    await
                    Message0.
                    setFirm(relatedFirm0);
                }
            
                const relatedFirm1 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const Message1 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Message1?.setFirm)
                {
                    await
                    Message1.
                    setFirm(relatedFirm1);
                }
            
                const relatedFirm2 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const Message2 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Message2?.setFirm)
                {
                    await
                    Message2.
                    setFirm(relatedFirm2);
                }
            
        }
        
    
        
            
            async function associateMessageWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Message0 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Message0?.setMerchant)
                {
                    await
                    Message0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Message1 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Message1?.setMerchant)
                {
                    await
                    Message1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const Message2 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Message2?.setMerchant)
                {
                    await
                    Message2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateMessageWithSender() {
            
                const relatedSender0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Message0 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Message0?.setSender)
                {
                    await
                    Message0.
                    setSender(relatedSender0);
                }
            
                const relatedSender1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Message1 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Message1?.setSender)
                {
                    await
                    Message1.
                    setSender(relatedSender1);
                }
            
                const relatedSender2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Message2 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Message2?.setSender)
                {
                    await
                    Message2.
                    setSender(relatedSender2);
                }
            
        }
        
    
        
            
            async function associateMessageWithRecipient() {
            
                const relatedRecipient0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Message0 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Message0?.setRecipient)
                {
                    await
                    Message0.
                    setRecipient(relatedRecipient0);
                }
            
                const relatedRecipient1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Message1 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Message1?.setRecipient)
                {
                    await
                    Message1.
                    setRecipient(relatedRecipient1);
                }
            
                const relatedRecipient2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Message2 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Message2?.setRecipient)
                {
                    await
                    Message2.
                    setRecipient(relatedRecipient2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateMessageWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Message0 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Message0?.setOrganization)
                {
                    await
                    Message0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Message1 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Message1?.setOrganization)
                {
                    await
                    Message1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const Message2 = await Messages.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Message2?.setOrganization)
                {
                    await
                    Message2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    

    
    
    
        
            
            async function associateAuditEventWithFirm() {
            
                const relatedFirm0 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const AuditEvent0 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditEvent0?.setFirm)
                {
                    await
                    AuditEvent0.
                    setFirm(relatedFirm0);
                }
            
                const relatedFirm1 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const AuditEvent1 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditEvent1?.setFirm)
                {
                    await
                    AuditEvent1.
                    setFirm(relatedFirm1);
                }
            
                const relatedFirm2 = await Firms.findOne({
                    offset: Math.floor(Math.random() * (await Firms.count())),
                });
                const AuditEvent2 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditEvent2?.setFirm)
                {
                    await
                    AuditEvent2.
                    setFirm(relatedFirm2);
                }
            
        }
        
    
        
            
            async function associateAuditEventWithMerchant() {
            
                const relatedMerchant0 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const AuditEvent0 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditEvent0?.setMerchant)
                {
                    await
                    AuditEvent0.
                    setMerchant(relatedMerchant0);
                }
            
                const relatedMerchant1 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const AuditEvent1 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditEvent1?.setMerchant)
                {
                    await
                    AuditEvent1.
                    setMerchant(relatedMerchant1);
                }
            
                const relatedMerchant2 = await Merchants.findOne({
                    offset: Math.floor(Math.random() * (await Merchants.count())),
                });
                const AuditEvent2 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditEvent2?.setMerchant)
                {
                    await
                    AuditEvent2.
                    setMerchant(relatedMerchant2);
                }
            
        }
        
    
        
            
            async function associateAuditEventWithActor() {
            
                const relatedActor0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditEvent0 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditEvent0?.setActor)
                {
                    await
                    AuditEvent0.
                    setActor(relatedActor0);
                }
            
                const relatedActor1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditEvent1 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditEvent1?.setActor)
                {
                    await
                    AuditEvent1.
                    setActor(relatedActor1);
                }
            
                const relatedActor2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditEvent2 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditEvent2?.setActor)
                {
                    await
                    AuditEvent2.
                    setActor(relatedActor2);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateAuditEventWithOrganization() {
            
                const relatedOrganization0 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AuditEvent0 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditEvent0?.setOrganization)
                {
                    await
                    AuditEvent0.
                    setOrganization(relatedOrganization0);
                }
            
                const relatedOrganization1 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AuditEvent1 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditEvent1?.setOrganization)
                {
                    await
                    AuditEvent1.
                    setOrganization(relatedOrganization1);
                }
            
                const relatedOrganization2 = await Organizations.findOne({
                    offset: Math.floor(Math.random() * (await Organizations.count())),
                });
                const AuditEvent2 = await AuditEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditEvent2?.setOrganization)
                {
                    await
                    AuditEvent2.
                    setOrganization(relatedOrganization2);
                }
            
        }
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await Organizations.bulkCreate(OrganizationsData);
                
            
            
                
                await Firms.bulkCreate(FirmsData);
                
            
            
                
                await Merchants.bulkCreate(MerchantsData);
                
            
            
                
                await Customers.bulkCreate(CustomersData);
                
            
            
                
                await Suppliers.bulkCreate(SuppliersData);
                
            
            
                
                await Products.bulkCreate(ProductsData);
                
            
            
                
                await Receipts.bulkCreate(ReceiptsData);
                
            
            
                
                await OcrExtractions.bulkCreate(OcrExtractionsData);
                
            
            
                
                await SalesInvoices.bulkCreate(SalesInvoicesData);
                
            
            
                
                await SalesInvoiceLines.bulkCreate(SalesInvoiceLinesData);
                
            
            
                
                await PurchaseInvoices.bulkCreate(PurchaseInvoicesData);
                
            
            
                
                await PurchaseInvoiceLines.bulkCreate(PurchaseInvoiceLinesData);
                
            
            
                
                await Expenses.bulkCreate(ExpensesData);
                
            
            
                
                await TaxPeriods.bulkCreate(TaxPeriodsData);
                
            
            
                
                await VatDeclarations.bulkCreate(VatDeclarationsData);
                
            
            
                
                await TotDeclarations.bulkCreate(TotDeclarationsData);
                
            
            
                
                await DeclarationSubmissions.bulkCreate(DeclarationSubmissionsData);
                
            
            
                
                await Messages.bulkCreate(MessagesData);
                
            
            
                
                await AuditEvents.bulkCreate(AuditEventsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                        
                        await associateUserWithOrganization(),
                    
                
            
                
                
                
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateFirmWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateMerchantWithFirm(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMerchantWithAssigned_accountant(),
                    
                
                    
                
                    
                
                    
                        
                        await associateMerchantWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateCustomerWithMerchant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateCustomerWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateSupplierWithMerchant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSupplierWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateProductWithMerchant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateProductWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateReceiptWithMerchant(),
                    
                
                    
                        
                        await associateReceiptWithUploaded_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateReceiptWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateOcrExtractionWithReceipt(),
                    
                
                    
                        
                        await associateOcrExtractionWithMerchant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateOcrExtractionWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateSalesInvoiceWithMerchant(),
                    
                
                    
                        
                        await associateSalesInvoiceWithCustomer(),
                    
                
                    
                        
                        await associateSalesInvoiceWithReceipt(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSalesInvoiceWithEntered_by(),
                    
                
                    
                        
                        await associateSalesInvoiceWithReviewed_by(),
                    
                
                    
                
                    
                
                    
                        
                        await associateSalesInvoiceWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateSalesInvoiceLineWithSales_invoice(),
                    
                
                    
                        
                        await associateSalesInvoiceLineWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateSalesInvoiceLineWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePurchaseInvoiceWithMerchant(),
                    
                
                    
                        
                        await associatePurchaseInvoiceWithSupplier(),
                    
                
                    
                        
                        await associatePurchaseInvoiceWithReceipt(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePurchaseInvoiceWithEntered_by(),
                    
                
                    
                        
                        await associatePurchaseInvoiceWithReviewed_by(),
                    
                
                    
                
                    
                
                    
                        
                        await associatePurchaseInvoiceWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associatePurchaseInvoiceLineWithPurchase_invoice(),
                    
                
                    
                        
                        await associatePurchaseInvoiceLineWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associatePurchaseInvoiceLineWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateExpensWithMerchant(),
                    
                
                    
                        
                        await associateExpensWithReceipt(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateExpensWithEntered_by(),
                    
                
                    
                        
                        await associateExpensWithReviewed_by(),
                    
                
                    
                
                    
                
                    
                        
                        await associateExpensWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateTaxPeriodWithMerchant(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateTaxPeriodWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateVatDeclarationWithMerchant(),
                    
                
                    
                        
                        await associateVatDeclarationWithTax_period(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateVatDeclarationWithGenerated_by(),
                    
                
                    
                
                    
                        
                        await associateVatDeclarationWithReviewed_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateVatDeclarationWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateTotDeclarationWithMerchant(),
                    
                
                    
                        
                        await associateTotDeclarationWithTax_period(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateTotDeclarationWithGenerated_by(),
                    
                
                    
                
                    
                        
                        await associateTotDeclarationWithReviewed_by(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateTotDeclarationWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateDeclarationSubmissionWithMerchant(),
                    
                
                    
                        
                        await associateDeclarationSubmissionWithTax_period(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDeclarationSubmissionWithSubmitted_by(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDeclarationSubmissionWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateMessageWithFirm(),
                    
                
                    
                        
                        await associateMessageWithMerchant(),
                    
                
                    
                        
                        await associateMessageWithSender(),
                    
                
                    
                        
                        await associateMessageWithRecipient(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateMessageWithOrganization(),
                    
                
            
                
                
                    
                        
                        await associateAuditEventWithFirm(),
                    
                
                    
                        
                        await associateAuditEventWithMerchant(),
                    
                
                    
                        
                        await associateAuditEventWithActor(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateAuditEventWithOrganization(),
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('organizations', null, {});
            
            
            await queryInterface.bulkDelete('firms', null, {});
            
            
            await queryInterface.bulkDelete('merchants', null, {});
            
            
            await queryInterface.bulkDelete('customers', null, {});
            
            
            await queryInterface.bulkDelete('suppliers', null, {});
            
            
            await queryInterface.bulkDelete('products', null, {});
            
            
            await queryInterface.bulkDelete('receipts', null, {});
            
            
            await queryInterface.bulkDelete('ocr_extractions', null, {});
            
            
            await queryInterface.bulkDelete('sales_invoices', null, {});
            
            
            await queryInterface.bulkDelete('sales_invoice_lines', null, {});
            
            
            await queryInterface.bulkDelete('purchase_invoices', null, {});
            
            
            await queryInterface.bulkDelete('purchase_invoice_lines', null, {});
            
            
            await queryInterface.bulkDelete('expenses', null, {});
            
            
            await queryInterface.bulkDelete('tax_periods', null, {});
            
            
            await queryInterface.bulkDelete('vat_declarations', null, {});
            
            
            await queryInterface.bulkDelete('tot_declarations', null, {});
            
            
            await queryInterface.bulkDelete('declaration_submissions', null, {});
            
            
            await queryInterface.bulkDelete('messages', null, {});
            
            
            await queryInterface.bulkDelete('audit_events', null, {});
            
        
    },
};