38937-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-03-02 18:12:07 +00:00

13319 lines
297 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Organizations = db.organizations;
const Venues = db.venues;
const Sports = db.sports;
const Courts = db.courts;
const Customers = db.customers;
const Bookings = db.bookings;
const PriceRules = db.price_rules;
const PosTabs = db.pos_tabs;
const PosTabItems = db.pos_tab_items;
const Products = db.products;
const ProductCategories = db.product_categories;
const InventoryLocations = db.inventory_locations;
const StockMovements = db.stock_movements;
const CashSessions = db.cash_sessions;
const Payments = db.payments;
const Invoices = db.invoices;
const DiscountCoupons = db.discount_coupons;
const Notifications = db.notifications;
const AuditLogs = db.audit_logs;
const OrganizationsData = [
{
"name": "Alan Turing",
},
{
"name": "Ada Lovelace",
},
{
"name": "Ada Lovelace",
},
{
"name": "Marie Curie",
},
{
"name": "Marie Curie",
},
];
const VenuesData = [
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"phone": "Alan Turing",
"email": "Alan Turing",
"address_line": "Alan Turing",
"city": "Grace Hopper",
"state": "Grace Hopper",
"postal_code": "Marie Curie",
"latitude": 8.35,
"longitude": 1.4,
"timezone": "Alan Turing",
"status": "inactive",
// type code here for "images" field
},
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"phone": "Marie Curie",
"email": "Grace Hopper",
"address_line": "Grace Hopper",
"city": "Alan Turing",
"state": "Marie Curie",
"postal_code": "Ada Lovelace",
"latitude": 2.57,
"longitude": 2.7,
"timezone": "Marie Curie",
"status": "active",
// type code here for "images" field
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"phone": "Ada Lovelace",
"email": "Grace Hopper",
"address_line": "Marie Curie",
"city": "Ada Lovelace",
"state": "Ada Lovelace",
"postal_code": "Grace Hopper",
"latitude": 6.23,
"longitude": 5.89,
"timezone": "Alan Turing",
"status": "active",
// type code here for "images" field
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"phone": "Marie Curie",
"email": "Marie Curie",
"address_line": "Ada Lovelace",
"city": "Marie Curie",
"state": "Grace Hopper",
"postal_code": "Ada Lovelace",
"latitude": 3.21,
"longitude": 5.89,
"timezone": "Alan Turing",
"status": "inactive",
// type code here for "images" field
},
{
// type code here for "relation_one" field
"name": "Alan Turing",
"phone": "Grace Hopper",
"email": "Alan Turing",
"address_line": "Alan Turing",
"city": "Marie Curie",
"state": "Marie Curie",
"postal_code": "Grace Hopper",
"latitude": 2.34,
"longitude": 1.68,
"timezone": "Grace Hopper",
"status": "inactive",
// type code here for "images" field
},
];
const SportsData = [
{
"name": "Grace Hopper",
// type code here for "images" field
"is_active": false,
// type code here for "relation_one" field
},
{
"name": "Alan Turing",
// type code here for "images" field
"is_active": true,
// type code here for "relation_one" field
},
{
"name": "Ada Lovelace",
// type code here for "images" field
"is_active": true,
// type code here for "relation_one" field
},
{
"name": "Ada Lovelace",
// type code here for "images" field
"is_active": false,
// type code here for "relation_one" field
},
{
"name": "Grace Hopper",
// type code here for "images" field
"is_active": true,
// type code here for "relation_one" field
},
];
const CourtsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Marie Curie",
"surface_type": "rubber",
"min_booking_minutes": 6,
"slot_granularity_minutes": 4,
"base_hourly_rate": 1.79,
"status": "maintenance",
"description": "Marie Curie",
// type code here for "images" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Marie Curie",
"surface_type": "clay",
"min_booking_minutes": 5,
"slot_granularity_minutes": 7,
"base_hourly_rate": 8.95,
"status": "inactive",
"description": "Alan Turing",
// type code here for "images" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Marie Curie",
"surface_type": "synthetic_grass",
"min_booking_minutes": 9,
"slot_granularity_minutes": 1,
"base_hourly_rate": 0.46,
"status": "available",
"description": "Alan Turing",
// type code here for "images" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Grace Hopper",
"surface_type": "rubber",
"min_booking_minutes": 1,
"slot_granularity_minutes": 7,
"base_hourly_rate": 7.65,
"status": "available",
"description": "Alan Turing",
// type code here for "images" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Ada Lovelace",
"surface_type": "wood",
"min_booking_minutes": 6,
"slot_granularity_minutes": 2,
"base_hourly_rate": 4.42,
"status": "maintenance",
"description": "Marie Curie",
// type code here for "images" field
// type code here for "relation_one" field
},
];
const CustomersData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Alan Turing",
"email": "Marie Curie",
"phone": "Grace Hopper",
"document": "Alan Turing",
"birth_date": new Date(Date.now()),
"accepts_marketing": true,
"notes": "Ada Lovelace",
"status": "active",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Marie Curie",
"email": "Ada Lovelace",
"phone": "Ada Lovelace",
"document": "Ada Lovelace",
"birth_date": new Date(Date.now()),
"accepts_marketing": false,
"notes": "Marie Curie",
"status": "blocked",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Alan Turing",
"email": "Ada Lovelace",
"phone": "Ada Lovelace",
"document": "Marie Curie",
"birth_date": new Date(Date.now()),
"accepts_marketing": true,
"notes": "Alan Turing",
"status": "active",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Grace Hopper",
"email": "Ada Lovelace",
"phone": "Ada Lovelace",
"document": "Marie Curie",
"birth_date": new Date(Date.now()),
"accepts_marketing": false,
"notes": "Grace Hopper",
"status": "active",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"full_name": "Marie Curie",
"email": "Ada Lovelace",
"phone": "Marie Curie",
"document": "Alan Turing",
"birth_date": new Date(Date.now()),
"accepts_marketing": true,
"notes": "Ada Lovelace",
"status": "blocked",
},
];
const BookingsData = [
{
// 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
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"status": "completed",
"source": "front_desk",
"court_price": 5.47,
"discount_amount": 7.99,
"total_amount": 1.18,
"is_paid": true,
"internal_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
// type code here for "relation_one" field
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"status": "checked_in",
"source": "front_desk",
"court_price": 0.8,
"discount_amount": 1.41,
"total_amount": 7.47,
"is_paid": true,
"internal_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
// type code here for "relation_one" field
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"status": "completed",
"source": "whatsapp",
"court_price": 4.5,
"discount_amount": 4.94,
"total_amount": 4.41,
"is_paid": false,
"internal_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
// type code here for "relation_one" field
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"status": "canceled",
"source": "online",
"court_price": 8.18,
"discount_amount": 5.88,
"total_amount": 1.99,
"is_paid": false,
"internal_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
// type code here for "relation_one" field
"start_at": new Date(Date.now()),
"end_at": new Date(Date.now()),
"status": "tentative",
"source": "phone",
"court_price": 1.23,
"discount_amount": 2.45,
"total_amount": 7.37,
"is_paid": false,
"internal_notes": "Marie Curie",
},
];
const PriceRulesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Alan Turing",
"valid_from": new Date(Date.now()),
"valid_to": new Date(Date.now()),
"day_of_week": 3,
"start_minute_of_day": 6,
"end_minute_of_day": 6,
"pricing_mode": "hourly",
"price_amount": 7.38,
"is_active": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Alan Turing",
"valid_from": new Date(Date.now()),
"valid_to": new Date(Date.now()),
"day_of_week": 9,
"start_minute_of_day": 9,
"end_minute_of_day": 2,
"pricing_mode": "hourly",
"price_amount": 8.2,
"is_active": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Marie Curie",
"valid_from": new Date(Date.now()),
"valid_to": new Date(Date.now()),
"day_of_week": 2,
"start_minute_of_day": 9,
"end_minute_of_day": 4,
"pricing_mode": "fixed",
"price_amount": 1.82,
"is_active": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Grace Hopper",
"valid_from": new Date(Date.now()),
"valid_to": new Date(Date.now()),
"day_of_week": 2,
"start_minute_of_day": 6,
"end_minute_of_day": 9,
"pricing_mode": "fixed",
"price_amount": 2.08,
"is_active": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Ada Lovelace",
"valid_from": new Date(Date.now()),
"valid_to": new Date(Date.now()),
"day_of_week": 7,
"start_minute_of_day": 1,
"end_minute_of_day": 8,
"pricing_mode": "hourly",
"price_amount": 0.95,
"is_active": false,
// type code here for "relation_one" field
},
];
const PosTabsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "canceled",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"subtotal_amount": 2.98,
"service_fee_amount": 4.65,
"discount_amount": 2.46,
"total_amount": 9.11,
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "closed",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"subtotal_amount": 8.4,
"service_fee_amount": 7.39,
"discount_amount": 7.49,
"total_amount": 2.2,
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "open",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"subtotal_amount": 0.71,
"service_fee_amount": 2.72,
"discount_amount": 9.73,
"total_amount": 5.46,
"notes": "Ada Lovelace",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "closed",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"subtotal_amount": 8.18,
"service_fee_amount": 8.78,
"discount_amount": 8.58,
"total_amount": 1.66,
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "closed",
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"subtotal_amount": 3.35,
"service_fee_amount": 2.69,
"discount_amount": 8.63,
"total_amount": 0.73,
"notes": "Grace Hopper",
},
];
const PosTabItemsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"added_at": new Date(Date.now()),
"quantity": 2.29,
"unit_price": 5.19,
"discount_amount": 0.57,
"total_amount": 0.7,
"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
"added_at": new Date(Date.now()),
"quantity": 1.14,
"unit_price": 4.29,
"discount_amount": 4.8,
"total_amount": 4.53,
"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
"added_at": new Date(Date.now()),
"quantity": 8.17,
"unit_price": 7.87,
"discount_amount": 0.13,
"total_amount": 1.38,
"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
"added_at": new Date(Date.now()),
"quantity": 5.05,
"unit_price": 7.12,
"discount_amount": 7.63,
"total_amount": 6.74,
"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
"added_at": new Date(Date.now()),
"quantity": 6.96,
"unit_price": 8.98,
"discount_amount": 9.88,
"total_amount": 8.7,
"notes": "Marie Curie",
// type code here for "relation_one" field
},
];
const ProductsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Alan Turing",
"sku": "Alan Turing",
"barcode": "Alan Turing",
"product_type": "service",
"sale_price": 1.33,
"cost_price": 5.16,
"is_active": true,
// type code here for "images" field
"description": "Alan Turing",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Ada Lovelace",
"sku": "Alan Turing",
"barcode": "Alan Turing",
"product_type": "stocked",
"sale_price": 2.16,
"cost_price": 4.05,
"is_active": true,
// type code here for "images" field
"description": "Alan Turing",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Grace Hopper",
"sku": "Alan Turing",
"barcode": "Grace Hopper",
"product_type": "service",
"sale_price": 5.4,
"cost_price": 0.94,
"is_active": true,
// type code here for "images" field
"description": "Grace Hopper",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Marie Curie",
"sku": "Grace Hopper",
"barcode": "Alan Turing",
"product_type": "stocked",
"sale_price": 9.5,
"cost_price": 2.24,
"is_active": true,
// type code here for "images" field
"description": "Marie Curie",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Marie Curie",
"sku": "Ada Lovelace",
"barcode": "Ada Lovelace",
"product_type": "service",
"sale_price": 0.04,
"cost_price": 5.84,
"is_active": true,
// type code here for "images" field
"description": "Marie Curie",
},
];
const ProductCategoriesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Grace Hopper",
"description": "Ada Lovelace",
"is_active": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Grace Hopper",
"description": "Alan Turing",
"is_active": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Grace Hopper",
"description": "Ada Lovelace",
"is_active": false,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Ada Lovelace",
"description": "Grace Hopper",
"is_active": false,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"name": "Alan Turing",
"description": "Marie Curie",
"is_active": true,
},
];
const InventoryLocationsData = [
{
// type code here for "relation_one" field
"name": "Grace Hopper",
"location_type": "kitchen",
"is_default": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"location_type": "front_desk",
"is_default": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Marie Curie",
"location_type": "bar",
"is_default": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"location_type": "other",
"is_default": false,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"name": "Ada Lovelace",
"location_type": "kitchen",
"is_default": false,
// type code here for "relation_one" field
},
];
const StockMovementsData = [
{
// 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
"movement_type": "out",
"quantity": 7.13,
"unit_cost": 7.92,
"movement_at": new Date(Date.now()),
"reason": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"movement_type": "in",
"quantity": 3.42,
"unit_cost": 4.37,
"movement_at": new Date(Date.now()),
"reason": "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
// type code here for "relation_one" field
// type code here for "relation_one" field
"movement_type": "out",
"quantity": 6.34,
"unit_cost": 8.38,
"movement_at": new Date(Date.now()),
"reason": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"movement_type": "out",
"quantity": 1.5,
"unit_cost": 0.99,
"movement_at": new Date(Date.now()),
"reason": "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
// type code here for "relation_one" field
// type code here for "relation_one" field
"movement_type": "adjustment",
"quantity": 7.88,
"unit_cost": 0.35,
"movement_at": new Date(Date.now()),
"reason": "Marie Curie",
// type code here for "relation_one" field
},
];
const CashSessionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"status": "closed",
"opening_float_amount": 2.49,
"closing_count_amount": 6.83,
"difference_amount": 3.32,
"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
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"status": "open",
"opening_float_amount": 4.54,
"closing_count_amount": 6.85,
"difference_amount": 0.25,
"notes": "Ada Lovelace",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"status": "open",
"opening_float_amount": 6.87,
"closing_count_amount": 7.57,
"difference_amount": 5.89,
"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
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"status": "closed",
"opening_float_amount": 8.13,
"closing_count_amount": 7.12,
"difference_amount": 0.86,
"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
"opened_at": new Date(Date.now()),
"closed_at": new Date(Date.now()),
"status": "closed",
"opening_float_amount": 0.66,
"closing_count_amount": 3.85,
"difference_amount": 5.48,
"notes": "Marie Curie",
// type code here for "relation_one" field
},
];
const PaymentsData = [
{
// 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
"paid_at": new Date(Date.now()),
"method": "pix",
"status": "pending",
"amount": 1.21,
"external_reference": "Alan Turing",
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"paid_at": new Date(Date.now()),
"method": "debit_card",
"status": "pending",
"amount": 0.79,
"external_reference": "Ada Lovelace",
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"paid_at": new Date(Date.now()),
"method": "pix",
"status": "refunded",
"amount": 2.32,
"external_reference": "Alan Turing",
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"paid_at": new Date(Date.now()),
"method": "credit_card",
"status": "pending",
"amount": 0.3,
"external_reference": "Alan Turing",
"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
// type code here for "relation_one" field
// type code here for "relation_one" field
"paid_at": new Date(Date.now()),
"method": "pix",
"status": "paid",
"amount": 0.06,
"external_reference": "Ada Lovelace",
"notes": "Alan Turing",
// type code here for "relation_one" field
},
];
const InvoicesData = [
{
// 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
"number": "Grace Hopper",
"issued_at": new Date(Date.now()),
"due_at": new Date(Date.now()),
"status": "draft",
"subtotal_amount": 6.31,
"tax_amount": 4.06,
"discount_amount": 2.45,
"total_amount": 7.03,
// type code here for "files" field
"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
// type code here for "relation_one" field
"number": "Ada Lovelace",
"issued_at": new Date(Date.now()),
"due_at": new Date(Date.now()),
"status": "draft",
"subtotal_amount": 1.53,
"tax_amount": 4.47,
"discount_amount": 8.77,
"total_amount": 6.22,
// type code here for "files" field
"notes": "Ada Lovelace",
},
{
// 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
"number": "Grace Hopper",
"issued_at": new Date(Date.now()),
"due_at": new Date(Date.now()),
"status": "draft",
"subtotal_amount": 7.05,
"tax_amount": 0.74,
"discount_amount": 5.81,
"total_amount": 8.67,
// type code here for "files" field
"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
// type code here for "relation_one" field
"number": "Marie Curie",
"issued_at": new Date(Date.now()),
"due_at": new Date(Date.now()),
"status": "draft",
"subtotal_amount": 1.94,
"tax_amount": 2.03,
"discount_amount": 8.69,
"total_amount": 2.4,
// type code here for "files" field
"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
// type code here for "relation_one" field
"number": "Grace Hopper",
"issued_at": new Date(Date.now()),
"due_at": new Date(Date.now()),
"status": "canceled",
"subtotal_amount": 6.79,
"tax_amount": 5.49,
"discount_amount": 6.94,
"total_amount": 1.42,
// type code here for "files" field
"notes": "Marie Curie",
},
];
const DiscountCouponsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"code": "Grace Hopper",
"discount_type": "percent",
"discount_value": 3.67,
"starts_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"max_uses_total": 1,
"max_uses_per_customer": 5,
"is_active": true,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"code": "Ada Lovelace",
"discount_type": "fixed",
"discount_value": 9.99,
"starts_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"max_uses_total": 5,
"max_uses_per_customer": 5,
"is_active": false,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"code": "Grace Hopper",
"discount_type": "fixed",
"discount_value": 1.3,
"starts_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"max_uses_total": 5,
"max_uses_per_customer": 6,
"is_active": false,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"code": "Marie Curie",
"discount_type": "fixed",
"discount_value": 8.44,
"starts_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"max_uses_total": 9,
"max_uses_per_customer": 6,
"is_active": false,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"code": "Grace Hopper",
"discount_type": "percent",
"discount_value": 8.68,
"starts_at": new Date(Date.now()),
"ends_at": new Date(Date.now()),
"max_uses_total": 6,
"max_uses_per_customer": 4,
"is_active": true,
},
];
const NotificationsData = [
{
// 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": "sms",
"status": "canceled",
"scheduled_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
"subject": "Alan Turing",
"message": "Ada Lovelace",
"provider_response": "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
"channel": "sms",
"status": "canceled",
"scheduled_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
"subject": "Marie Curie",
"message": "Grace Hopper",
"provider_response": "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
"channel": "email",
"status": "queued",
"scheduled_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
"subject": "Ada Lovelace",
"message": "Grace Hopper",
"provider_response": "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
"channel": "push",
"status": "failed",
"scheduled_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
"subject": "Alan Turing",
"message": "Marie Curie",
"provider_response": "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
"channel": "email",
"status": "sent",
"scheduled_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
"subject": "Marie Curie",
"message": "Marie Curie",
"provider_response": "Marie Curie",
},
];
const AuditLogsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_at": new Date(Date.now()),
"entity_name": "Grace Hopper",
"entity_record_key": "Grace Hopper",
"action": "create",
"ip_address": "Ada Lovelace",
"user_agent": "Alan Turing",
"details": "Alan Turing",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_at": new Date(Date.now()),
"entity_name": "Ada Lovelace",
"entity_record_key": "Grace Hopper",
"action": "delete",
"ip_address": "Grace Hopper",
"user_agent": "Ada Lovelace",
"details": "Grace Hopper",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_at": new Date(Date.now()),
"entity_name": "Alan Turing",
"entity_record_key": "Marie Curie",
"action": "logout",
"ip_address": "Marie Curie",
"user_agent": "Grace Hopper",
"details": "Grace Hopper",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_at": new Date(Date.now()),
"entity_name": "Alan Turing",
"entity_record_key": "Marie Curie",
"action": "create",
"ip_address": "Ada Lovelace",
"user_agent": "Grace Hopper",
"details": "Alan Turing",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_at": new Date(Date.now()),
"entity_name": "Ada Lovelace",
"entity_record_key": "Alan Turing",
"action": "delete",
"ip_address": "Ada Lovelace",
"user_agent": "Grace Hopper",
"details": "Ada Lovelace",
},
];
// 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);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (User3?.setOrganization)
{
await
User3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User4 = await Users.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (User4?.setOrganization)
{
await
User4.
setOrganization(relatedOrganization4);
}
}
async function associateVenueWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue0 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Venue0?.setOrganization)
{
await
Venue0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue1 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Venue1?.setOrganization)
{
await
Venue1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue2 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Venue2?.setOrganization)
{
await
Venue2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue3 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Venue3?.setOrganization)
{
await
Venue3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Venue4 = await Venues.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Venue4?.setOrganization)
{
await
Venue4.
setOrganization(relatedOrganization4);
}
}
async function associateSportWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sport0 = await Sports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Sport0?.setOrganization)
{
await
Sport0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sport1 = await Sports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Sport1?.setOrganization)
{
await
Sport1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sport2 = await Sports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Sport2?.setOrganization)
{
await
Sport2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sport3 = await Sports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Sport3?.setOrganization)
{
await
Sport3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Sport4 = await Sports.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Sport4?.setOrganization)
{
await
Sport4.
setOrganization(relatedOrganization4);
}
}
async function associateCourtWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Court0 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Court0?.setVenue)
{
await
Court0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Court1 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Court1?.setVenue)
{
await
Court1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Court2 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Court2?.setVenue)
{
await
Court2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Court3 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Court3?.setVenue)
{
await
Court3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Court4 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Court4?.setVenue)
{
await
Court4.
setVenue(relatedVenue4);
}
}
async function associateCourtWithSport() {
const relatedSport0 = await Sports.findOne({
offset: Math.floor(Math.random() * (await Sports.count())),
});
const Court0 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Court0?.setSport)
{
await
Court0.
setSport(relatedSport0);
}
const relatedSport1 = await Sports.findOne({
offset: Math.floor(Math.random() * (await Sports.count())),
});
const Court1 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Court1?.setSport)
{
await
Court1.
setSport(relatedSport1);
}
const relatedSport2 = await Sports.findOne({
offset: Math.floor(Math.random() * (await Sports.count())),
});
const Court2 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Court2?.setSport)
{
await
Court2.
setSport(relatedSport2);
}
const relatedSport3 = await Sports.findOne({
offset: Math.floor(Math.random() * (await Sports.count())),
});
const Court3 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Court3?.setSport)
{
await
Court3.
setSport(relatedSport3);
}
const relatedSport4 = await Sports.findOne({
offset: Math.floor(Math.random() * (await Sports.count())),
});
const Court4 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Court4?.setSport)
{
await
Court4.
setSport(relatedSport4);
}
}
async function associateCourtWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Court0 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Court0?.setOrganization)
{
await
Court0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Court1 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Court1?.setOrganization)
{
await
Court1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Court2 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Court2?.setOrganization)
{
await
Court2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Court3 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Court3?.setOrganization)
{
await
Court3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Court4 = await Courts.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Court4?.setOrganization)
{
await
Court4.
setOrganization(relatedOrganization4);
}
}
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);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Customer3 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Customer3?.setOrganization)
{
await
Customer3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Customer4 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Customer4?.setOrganization)
{
await
Customer4.
setOrganization(relatedOrganization4);
}
}
async function associateCustomerWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Customer0 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Customer0?.setVenue)
{
await
Customer0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Customer1 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Customer1?.setVenue)
{
await
Customer1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Customer2 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Customer2?.setVenue)
{
await
Customer2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Customer3 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Customer3?.setVenue)
{
await
Customer3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Customer4 = await Customers.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Customer4?.setVenue)
{
await
Customer4.
setVenue(relatedVenue4);
}
}
async function associateBookingWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Booking0 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Booking0?.setOrganization)
{
await
Booking0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Booking1 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Booking1?.setOrganization)
{
await
Booking1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Booking2 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Booking2?.setOrganization)
{
await
Booking2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Booking3 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Booking3?.setOrganization)
{
await
Booking3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Booking4 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Booking4?.setOrganization)
{
await
Booking4.
setOrganization(relatedOrganization4);
}
}
async function associateBookingWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Booking0 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Booking0?.setVenue)
{
await
Booking0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Booking1 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Booking1?.setVenue)
{
await
Booking1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Booking2 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Booking2?.setVenue)
{
await
Booking2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Booking3 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Booking3?.setVenue)
{
await
Booking3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Booking4 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Booking4?.setVenue)
{
await
Booking4.
setVenue(relatedVenue4);
}
}
async function associateBookingWithCourt() {
const relatedCourt0 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const Booking0 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Booking0?.setCourt)
{
await
Booking0.
setCourt(relatedCourt0);
}
const relatedCourt1 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const Booking1 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Booking1?.setCourt)
{
await
Booking1.
setCourt(relatedCourt1);
}
const relatedCourt2 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const Booking2 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Booking2?.setCourt)
{
await
Booking2.
setCourt(relatedCourt2);
}
const relatedCourt3 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const Booking3 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Booking3?.setCourt)
{
await
Booking3.
setCourt(relatedCourt3);
}
const relatedCourt4 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const Booking4 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Booking4?.setCourt)
{
await
Booking4.
setCourt(relatedCourt4);
}
}
async function associateBookingWithCustomer() {
const relatedCustomer0 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Booking0 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Booking0?.setCustomer)
{
await
Booking0.
setCustomer(relatedCustomer0);
}
const relatedCustomer1 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Booking1 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Booking1?.setCustomer)
{
await
Booking1.
setCustomer(relatedCustomer1);
}
const relatedCustomer2 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Booking2 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Booking2?.setCustomer)
{
await
Booking2.
setCustomer(relatedCustomer2);
}
const relatedCustomer3 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Booking3 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Booking3?.setCustomer)
{
await
Booking3.
setCustomer(relatedCustomer3);
}
const relatedCustomer4 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Booking4 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Booking4?.setCustomer)
{
await
Booking4.
setCustomer(relatedCustomer4);
}
}
async function associateBookingWithCreated_by_user() {
const relatedCreated_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Booking0 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Booking0?.setCreated_by_user)
{
await
Booking0.
setCreated_by_user(relatedCreated_by_user0);
}
const relatedCreated_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Booking1 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Booking1?.setCreated_by_user)
{
await
Booking1.
setCreated_by_user(relatedCreated_by_user1);
}
const relatedCreated_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Booking2 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Booking2?.setCreated_by_user)
{
await
Booking2.
setCreated_by_user(relatedCreated_by_user2);
}
const relatedCreated_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Booking3 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Booking3?.setCreated_by_user)
{
await
Booking3.
setCreated_by_user(relatedCreated_by_user3);
}
const relatedCreated_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Booking4 = await Bookings.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Booking4?.setCreated_by_user)
{
await
Booking4.
setCreated_by_user(relatedCreated_by_user4);
}
}
async function associatePriceRuleWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PriceRule0 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PriceRule0?.setVenue)
{
await
PriceRule0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PriceRule1 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PriceRule1?.setVenue)
{
await
PriceRule1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PriceRule2 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PriceRule2?.setVenue)
{
await
PriceRule2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PriceRule3 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PriceRule3?.setVenue)
{
await
PriceRule3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PriceRule4 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PriceRule4?.setVenue)
{
await
PriceRule4.
setVenue(relatedVenue4);
}
}
async function associatePriceRuleWithCourt() {
const relatedCourt0 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const PriceRule0 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PriceRule0?.setCourt)
{
await
PriceRule0.
setCourt(relatedCourt0);
}
const relatedCourt1 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const PriceRule1 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PriceRule1?.setCourt)
{
await
PriceRule1.
setCourt(relatedCourt1);
}
const relatedCourt2 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const PriceRule2 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PriceRule2?.setCourt)
{
await
PriceRule2.
setCourt(relatedCourt2);
}
const relatedCourt3 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const PriceRule3 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PriceRule3?.setCourt)
{
await
PriceRule3.
setCourt(relatedCourt3);
}
const relatedCourt4 = await Courts.findOne({
offset: Math.floor(Math.random() * (await Courts.count())),
});
const PriceRule4 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PriceRule4?.setCourt)
{
await
PriceRule4.
setCourt(relatedCourt4);
}
}
async function associatePriceRuleWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PriceRule0 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PriceRule0?.setOrganization)
{
await
PriceRule0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PriceRule1 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PriceRule1?.setOrganization)
{
await
PriceRule1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PriceRule2 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PriceRule2?.setOrganization)
{
await
PriceRule2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PriceRule3 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PriceRule3?.setOrganization)
{
await
PriceRule3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PriceRule4 = await PriceRules.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PriceRule4?.setOrganization)
{
await
PriceRule4.
setOrganization(relatedOrganization4);
}
}
async function associatePosTabWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTab0 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTab0?.setOrganization)
{
await
PosTab0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTab1 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTab1?.setOrganization)
{
await
PosTab1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTab2 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTab2?.setOrganization)
{
await
PosTab2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTab3 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTab3?.setOrganization)
{
await
PosTab3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTab4 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTab4?.setOrganization)
{
await
PosTab4.
setOrganization(relatedOrganization4);
}
}
async function associatePosTabWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PosTab0 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTab0?.setVenue)
{
await
PosTab0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PosTab1 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTab1?.setVenue)
{
await
PosTab1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PosTab2 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTab2?.setVenue)
{
await
PosTab2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PosTab3 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTab3?.setVenue)
{
await
PosTab3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const PosTab4 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTab4?.setVenue)
{
await
PosTab4.
setVenue(relatedVenue4);
}
}
async function associatePosTabWithBooking() {
const relatedBooking0 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const PosTab0 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTab0?.setBooking)
{
await
PosTab0.
setBooking(relatedBooking0);
}
const relatedBooking1 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const PosTab1 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTab1?.setBooking)
{
await
PosTab1.
setBooking(relatedBooking1);
}
const relatedBooking2 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const PosTab2 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTab2?.setBooking)
{
await
PosTab2.
setBooking(relatedBooking2);
}
const relatedBooking3 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const PosTab3 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTab3?.setBooking)
{
await
PosTab3.
setBooking(relatedBooking3);
}
const relatedBooking4 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const PosTab4 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTab4?.setBooking)
{
await
PosTab4.
setBooking(relatedBooking4);
}
}
async function associatePosTabWithCustomer() {
const relatedCustomer0 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const PosTab0 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTab0?.setCustomer)
{
await
PosTab0.
setCustomer(relatedCustomer0);
}
const relatedCustomer1 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const PosTab1 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTab1?.setCustomer)
{
await
PosTab1.
setCustomer(relatedCustomer1);
}
const relatedCustomer2 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const PosTab2 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTab2?.setCustomer)
{
await
PosTab2.
setCustomer(relatedCustomer2);
}
const relatedCustomer3 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const PosTab3 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTab3?.setCustomer)
{
await
PosTab3.
setCustomer(relatedCustomer3);
}
const relatedCustomer4 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const PosTab4 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTab4?.setCustomer)
{
await
PosTab4.
setCustomer(relatedCustomer4);
}
}
async function associatePosTabWithOpened_by_user() {
const relatedOpened_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab0 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTab0?.setOpened_by_user)
{
await
PosTab0.
setOpened_by_user(relatedOpened_by_user0);
}
const relatedOpened_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab1 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTab1?.setOpened_by_user)
{
await
PosTab1.
setOpened_by_user(relatedOpened_by_user1);
}
const relatedOpened_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab2 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTab2?.setOpened_by_user)
{
await
PosTab2.
setOpened_by_user(relatedOpened_by_user2);
}
const relatedOpened_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab3 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTab3?.setOpened_by_user)
{
await
PosTab3.
setOpened_by_user(relatedOpened_by_user3);
}
const relatedOpened_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab4 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTab4?.setOpened_by_user)
{
await
PosTab4.
setOpened_by_user(relatedOpened_by_user4);
}
}
async function associatePosTabWithClosed_by_user() {
const relatedClosed_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab0 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTab0?.setClosed_by_user)
{
await
PosTab0.
setClosed_by_user(relatedClosed_by_user0);
}
const relatedClosed_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab1 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTab1?.setClosed_by_user)
{
await
PosTab1.
setClosed_by_user(relatedClosed_by_user1);
}
const relatedClosed_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab2 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTab2?.setClosed_by_user)
{
await
PosTab2.
setClosed_by_user(relatedClosed_by_user2);
}
const relatedClosed_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab3 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTab3?.setClosed_by_user)
{
await
PosTab3.
setClosed_by_user(relatedClosed_by_user3);
}
const relatedClosed_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTab4 = await PosTabs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTab4?.setClosed_by_user)
{
await
PosTab4.
setClosed_by_user(relatedClosed_by_user4);
}
}
async function associatePosTabItemWithPos_tab() {
const relatedPos_tab0 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const PosTabItem0 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTabItem0?.setPos_tab)
{
await
PosTabItem0.
setPos_tab(relatedPos_tab0);
}
const relatedPos_tab1 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const PosTabItem1 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTabItem1?.setPos_tab)
{
await
PosTabItem1.
setPos_tab(relatedPos_tab1);
}
const relatedPos_tab2 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const PosTabItem2 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTabItem2?.setPos_tab)
{
await
PosTabItem2.
setPos_tab(relatedPos_tab2);
}
const relatedPos_tab3 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const PosTabItem3 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTabItem3?.setPos_tab)
{
await
PosTabItem3.
setPos_tab(relatedPos_tab3);
}
const relatedPos_tab4 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const PosTabItem4 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTabItem4?.setPos_tab)
{
await
PosTabItem4.
setPos_tab(relatedPos_tab4);
}
}
async function associatePosTabItemWithProduct() {
const relatedProduct0 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const PosTabItem0 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTabItem0?.setProduct)
{
await
PosTabItem0.
setProduct(relatedProduct0);
}
const relatedProduct1 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const PosTabItem1 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTabItem1?.setProduct)
{
await
PosTabItem1.
setProduct(relatedProduct1);
}
const relatedProduct2 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const PosTabItem2 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTabItem2?.setProduct)
{
await
PosTabItem2.
setProduct(relatedProduct2);
}
const relatedProduct3 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const PosTabItem3 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTabItem3?.setProduct)
{
await
PosTabItem3.
setProduct(relatedProduct3);
}
const relatedProduct4 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const PosTabItem4 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTabItem4?.setProduct)
{
await
PosTabItem4.
setProduct(relatedProduct4);
}
}
async function associatePosTabItemWithAdded_by_user() {
const relatedAdded_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTabItem0 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTabItem0?.setAdded_by_user)
{
await
PosTabItem0.
setAdded_by_user(relatedAdded_by_user0);
}
const relatedAdded_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTabItem1 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTabItem1?.setAdded_by_user)
{
await
PosTabItem1.
setAdded_by_user(relatedAdded_by_user1);
}
const relatedAdded_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTabItem2 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTabItem2?.setAdded_by_user)
{
await
PosTabItem2.
setAdded_by_user(relatedAdded_by_user2);
}
const relatedAdded_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTabItem3 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTabItem3?.setAdded_by_user)
{
await
PosTabItem3.
setAdded_by_user(relatedAdded_by_user3);
}
const relatedAdded_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PosTabItem4 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTabItem4?.setAdded_by_user)
{
await
PosTabItem4.
setAdded_by_user(relatedAdded_by_user4);
}
}
async function associatePosTabItemWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTabItem0 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PosTabItem0?.setOrganization)
{
await
PosTabItem0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTabItem1 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PosTabItem1?.setOrganization)
{
await
PosTabItem1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTabItem2 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PosTabItem2?.setOrganization)
{
await
PosTabItem2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTabItem3 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PosTabItem3?.setOrganization)
{
await
PosTabItem3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const PosTabItem4 = await PosTabItems.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PosTabItem4?.setOrganization)
{
await
PosTabItem4.
setOrganization(relatedOrganization4);
}
}
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);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Product3 = await Products.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Product3?.setOrganization)
{
await
Product3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Product4 = await Products.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Product4?.setOrganization)
{
await
Product4.
setOrganization(relatedOrganization4);
}
}
async function associateProductWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Product0 = await Products.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Product0?.setVenue)
{
await
Product0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Product1 = await Products.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Product1?.setVenue)
{
await
Product1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Product2 = await Products.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Product2?.setVenue)
{
await
Product2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Product3 = await Products.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Product3?.setVenue)
{
await
Product3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Product4 = await Products.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Product4?.setVenue)
{
await
Product4.
setVenue(relatedVenue4);
}
}
async function associateProductWithProduct_category() {
const relatedProduct_category0 = await ProductCategories.findOne({
offset: Math.floor(Math.random() * (await ProductCategories.count())),
});
const Product0 = await Products.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Product0?.setProduct_category)
{
await
Product0.
setProduct_category(relatedProduct_category0);
}
const relatedProduct_category1 = await ProductCategories.findOne({
offset: Math.floor(Math.random() * (await ProductCategories.count())),
});
const Product1 = await Products.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Product1?.setProduct_category)
{
await
Product1.
setProduct_category(relatedProduct_category1);
}
const relatedProduct_category2 = await ProductCategories.findOne({
offset: Math.floor(Math.random() * (await ProductCategories.count())),
});
const Product2 = await Products.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Product2?.setProduct_category)
{
await
Product2.
setProduct_category(relatedProduct_category2);
}
const relatedProduct_category3 = await ProductCategories.findOne({
offset: Math.floor(Math.random() * (await ProductCategories.count())),
});
const Product3 = await Products.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Product3?.setProduct_category)
{
await
Product3.
setProduct_category(relatedProduct_category3);
}
const relatedProduct_category4 = await ProductCategories.findOne({
offset: Math.floor(Math.random() * (await ProductCategories.count())),
});
const Product4 = await Products.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Product4?.setProduct_category)
{
await
Product4.
setProduct_category(relatedProduct_category4);
}
}
async function associateProductCategoryWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ProductCategory0 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ProductCategory0?.setOrganization)
{
await
ProductCategory0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ProductCategory1 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ProductCategory1?.setOrganization)
{
await
ProductCategory1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ProductCategory2 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ProductCategory2?.setOrganization)
{
await
ProductCategory2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ProductCategory3 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ProductCategory3?.setOrganization)
{
await
ProductCategory3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ProductCategory4 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ProductCategory4?.setOrganization)
{
await
ProductCategory4.
setOrganization(relatedOrganization4);
}
}
async function associateProductCategoryWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const ProductCategory0 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ProductCategory0?.setVenue)
{
await
ProductCategory0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const ProductCategory1 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ProductCategory1?.setVenue)
{
await
ProductCategory1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const ProductCategory2 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ProductCategory2?.setVenue)
{
await
ProductCategory2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const ProductCategory3 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ProductCategory3?.setVenue)
{
await
ProductCategory3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const ProductCategory4 = await ProductCategories.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ProductCategory4?.setVenue)
{
await
ProductCategory4.
setVenue(relatedVenue4);
}
}
async function associateInventoryLocationWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const InventoryLocation0 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (InventoryLocation0?.setVenue)
{
await
InventoryLocation0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const InventoryLocation1 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (InventoryLocation1?.setVenue)
{
await
InventoryLocation1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const InventoryLocation2 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (InventoryLocation2?.setVenue)
{
await
InventoryLocation2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const InventoryLocation3 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (InventoryLocation3?.setVenue)
{
await
InventoryLocation3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const InventoryLocation4 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (InventoryLocation4?.setVenue)
{
await
InventoryLocation4.
setVenue(relatedVenue4);
}
}
async function associateInventoryLocationWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const InventoryLocation0 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (InventoryLocation0?.setOrganization)
{
await
InventoryLocation0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const InventoryLocation1 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (InventoryLocation1?.setOrganization)
{
await
InventoryLocation1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const InventoryLocation2 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (InventoryLocation2?.setOrganization)
{
await
InventoryLocation2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const InventoryLocation3 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (InventoryLocation3?.setOrganization)
{
await
InventoryLocation3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const InventoryLocation4 = await InventoryLocations.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (InventoryLocation4?.setOrganization)
{
await
InventoryLocation4.
setOrganization(relatedOrganization4);
}
}
async function associateStockMovementWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const StockMovement0 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StockMovement0?.setVenue)
{
await
StockMovement0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const StockMovement1 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StockMovement1?.setVenue)
{
await
StockMovement1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const StockMovement2 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StockMovement2?.setVenue)
{
await
StockMovement2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const StockMovement3 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StockMovement3?.setVenue)
{
await
StockMovement3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const StockMovement4 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (StockMovement4?.setVenue)
{
await
StockMovement4.
setVenue(relatedVenue4);
}
}
async function associateStockMovementWithInventory_location() {
const relatedInventory_location0 = await InventoryLocations.findOne({
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
});
const StockMovement0 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StockMovement0?.setInventory_location)
{
await
StockMovement0.
setInventory_location(relatedInventory_location0);
}
const relatedInventory_location1 = await InventoryLocations.findOne({
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
});
const StockMovement1 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StockMovement1?.setInventory_location)
{
await
StockMovement1.
setInventory_location(relatedInventory_location1);
}
const relatedInventory_location2 = await InventoryLocations.findOne({
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
});
const StockMovement2 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StockMovement2?.setInventory_location)
{
await
StockMovement2.
setInventory_location(relatedInventory_location2);
}
const relatedInventory_location3 = await InventoryLocations.findOne({
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
});
const StockMovement3 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StockMovement3?.setInventory_location)
{
await
StockMovement3.
setInventory_location(relatedInventory_location3);
}
const relatedInventory_location4 = await InventoryLocations.findOne({
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
});
const StockMovement4 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (StockMovement4?.setInventory_location)
{
await
StockMovement4.
setInventory_location(relatedInventory_location4);
}
}
async function associateStockMovementWithProduct() {
const relatedProduct0 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const StockMovement0 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StockMovement0?.setProduct)
{
await
StockMovement0.
setProduct(relatedProduct0);
}
const relatedProduct1 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const StockMovement1 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StockMovement1?.setProduct)
{
await
StockMovement1.
setProduct(relatedProduct1);
}
const relatedProduct2 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const StockMovement2 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StockMovement2?.setProduct)
{
await
StockMovement2.
setProduct(relatedProduct2);
}
const relatedProduct3 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const StockMovement3 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StockMovement3?.setProduct)
{
await
StockMovement3.
setProduct(relatedProduct3);
}
const relatedProduct4 = await Products.findOne({
offset: Math.floor(Math.random() * (await Products.count())),
});
const StockMovement4 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (StockMovement4?.setProduct)
{
await
StockMovement4.
setProduct(relatedProduct4);
}
}
async function associateStockMovementWithPos_tab_item() {
const relatedPos_tab_item0 = await PosTabItems.findOne({
offset: Math.floor(Math.random() * (await PosTabItems.count())),
});
const StockMovement0 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StockMovement0?.setPos_tab_item)
{
await
StockMovement0.
setPos_tab_item(relatedPos_tab_item0);
}
const relatedPos_tab_item1 = await PosTabItems.findOne({
offset: Math.floor(Math.random() * (await PosTabItems.count())),
});
const StockMovement1 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StockMovement1?.setPos_tab_item)
{
await
StockMovement1.
setPos_tab_item(relatedPos_tab_item1);
}
const relatedPos_tab_item2 = await PosTabItems.findOne({
offset: Math.floor(Math.random() * (await PosTabItems.count())),
});
const StockMovement2 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StockMovement2?.setPos_tab_item)
{
await
StockMovement2.
setPos_tab_item(relatedPos_tab_item2);
}
const relatedPos_tab_item3 = await PosTabItems.findOne({
offset: Math.floor(Math.random() * (await PosTabItems.count())),
});
const StockMovement3 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StockMovement3?.setPos_tab_item)
{
await
StockMovement3.
setPos_tab_item(relatedPos_tab_item3);
}
const relatedPos_tab_item4 = await PosTabItems.findOne({
offset: Math.floor(Math.random() * (await PosTabItems.count())),
});
const StockMovement4 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (StockMovement4?.setPos_tab_item)
{
await
StockMovement4.
setPos_tab_item(relatedPos_tab_item4);
}
}
async function associateStockMovementWithPerformed_by_user() {
const relatedPerformed_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StockMovement0 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StockMovement0?.setPerformed_by_user)
{
await
StockMovement0.
setPerformed_by_user(relatedPerformed_by_user0);
}
const relatedPerformed_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StockMovement1 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StockMovement1?.setPerformed_by_user)
{
await
StockMovement1.
setPerformed_by_user(relatedPerformed_by_user1);
}
const relatedPerformed_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StockMovement2 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StockMovement2?.setPerformed_by_user)
{
await
StockMovement2.
setPerformed_by_user(relatedPerformed_by_user2);
}
const relatedPerformed_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StockMovement3 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StockMovement3?.setPerformed_by_user)
{
await
StockMovement3.
setPerformed_by_user(relatedPerformed_by_user3);
}
const relatedPerformed_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StockMovement4 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (StockMovement4?.setPerformed_by_user)
{
await
StockMovement4.
setPerformed_by_user(relatedPerformed_by_user4);
}
}
async function associateStockMovementWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const StockMovement0 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StockMovement0?.setOrganization)
{
await
StockMovement0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const StockMovement1 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StockMovement1?.setOrganization)
{
await
StockMovement1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const StockMovement2 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StockMovement2?.setOrganization)
{
await
StockMovement2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const StockMovement3 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StockMovement3?.setOrganization)
{
await
StockMovement3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const StockMovement4 = await StockMovements.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (StockMovement4?.setOrganization)
{
await
StockMovement4.
setOrganization(relatedOrganization4);
}
}
async function associateCashSessionWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const CashSession0 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CashSession0?.setVenue)
{
await
CashSession0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const CashSession1 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CashSession1?.setVenue)
{
await
CashSession1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const CashSession2 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CashSession2?.setVenue)
{
await
CashSession2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const CashSession3 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CashSession3?.setVenue)
{
await
CashSession3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const CashSession4 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (CashSession4?.setVenue)
{
await
CashSession4.
setVenue(relatedVenue4);
}
}
async function associateCashSessionWithOpened_by_user() {
const relatedOpened_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession0 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CashSession0?.setOpened_by_user)
{
await
CashSession0.
setOpened_by_user(relatedOpened_by_user0);
}
const relatedOpened_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession1 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CashSession1?.setOpened_by_user)
{
await
CashSession1.
setOpened_by_user(relatedOpened_by_user1);
}
const relatedOpened_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession2 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CashSession2?.setOpened_by_user)
{
await
CashSession2.
setOpened_by_user(relatedOpened_by_user2);
}
const relatedOpened_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession3 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CashSession3?.setOpened_by_user)
{
await
CashSession3.
setOpened_by_user(relatedOpened_by_user3);
}
const relatedOpened_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession4 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (CashSession4?.setOpened_by_user)
{
await
CashSession4.
setOpened_by_user(relatedOpened_by_user4);
}
}
async function associateCashSessionWithClosed_by_user() {
const relatedClosed_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession0 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CashSession0?.setClosed_by_user)
{
await
CashSession0.
setClosed_by_user(relatedClosed_by_user0);
}
const relatedClosed_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession1 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CashSession1?.setClosed_by_user)
{
await
CashSession1.
setClosed_by_user(relatedClosed_by_user1);
}
const relatedClosed_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession2 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CashSession2?.setClosed_by_user)
{
await
CashSession2.
setClosed_by_user(relatedClosed_by_user2);
}
const relatedClosed_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession3 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CashSession3?.setClosed_by_user)
{
await
CashSession3.
setClosed_by_user(relatedClosed_by_user3);
}
const relatedClosed_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CashSession4 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (CashSession4?.setClosed_by_user)
{
await
CashSession4.
setClosed_by_user(relatedClosed_by_user4);
}
}
async function associateCashSessionWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CashSession0 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CashSession0?.setOrganization)
{
await
CashSession0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CashSession1 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CashSession1?.setOrganization)
{
await
CashSession1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CashSession2 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CashSession2?.setOrganization)
{
await
CashSession2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CashSession3 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CashSession3?.setOrganization)
{
await
CashSession3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const CashSession4 = await CashSessions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (CashSession4?.setOrganization)
{
await
CashSession4.
setOrganization(relatedOrganization4);
}
}
async function associatePaymentWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setVenue)
{
await
Payment0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setVenue)
{
await
Payment1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setVenue)
{
await
Payment2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setVenue)
{
await
Payment3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setVenue)
{
await
Payment4.
setVenue(relatedVenue4);
}
}
async function associatePaymentWithCash_session() {
const relatedCash_session0 = await CashSessions.findOne({
offset: Math.floor(Math.random() * (await CashSessions.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setCash_session)
{
await
Payment0.
setCash_session(relatedCash_session0);
}
const relatedCash_session1 = await CashSessions.findOne({
offset: Math.floor(Math.random() * (await CashSessions.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setCash_session)
{
await
Payment1.
setCash_session(relatedCash_session1);
}
const relatedCash_session2 = await CashSessions.findOne({
offset: Math.floor(Math.random() * (await CashSessions.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setCash_session)
{
await
Payment2.
setCash_session(relatedCash_session2);
}
const relatedCash_session3 = await CashSessions.findOne({
offset: Math.floor(Math.random() * (await CashSessions.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setCash_session)
{
await
Payment3.
setCash_session(relatedCash_session3);
}
const relatedCash_session4 = await CashSessions.findOne({
offset: Math.floor(Math.random() * (await CashSessions.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setCash_session)
{
await
Payment4.
setCash_session(relatedCash_session4);
}
}
async function associatePaymentWithBooking() {
const relatedBooking0 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setBooking)
{
await
Payment0.
setBooking(relatedBooking0);
}
const relatedBooking1 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setBooking)
{
await
Payment1.
setBooking(relatedBooking1);
}
const relatedBooking2 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setBooking)
{
await
Payment2.
setBooking(relatedBooking2);
}
const relatedBooking3 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setBooking)
{
await
Payment3.
setBooking(relatedBooking3);
}
const relatedBooking4 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setBooking)
{
await
Payment4.
setBooking(relatedBooking4);
}
}
async function associatePaymentWithPos_tab() {
const relatedPos_tab0 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setPos_tab)
{
await
Payment0.
setPos_tab(relatedPos_tab0);
}
const relatedPos_tab1 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setPos_tab)
{
await
Payment1.
setPos_tab(relatedPos_tab1);
}
const relatedPos_tab2 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setPos_tab)
{
await
Payment2.
setPos_tab(relatedPos_tab2);
}
const relatedPos_tab3 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setPos_tab)
{
await
Payment3.
setPos_tab(relatedPos_tab3);
}
const relatedPos_tab4 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setPos_tab)
{
await
Payment4.
setPos_tab(relatedPos_tab4);
}
}
async function associatePaymentWithReceived_by_user() {
const relatedReceived_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setReceived_by_user)
{
await
Payment0.
setReceived_by_user(relatedReceived_by_user0);
}
const relatedReceived_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setReceived_by_user)
{
await
Payment1.
setReceived_by_user(relatedReceived_by_user1);
}
const relatedReceived_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setReceived_by_user)
{
await
Payment2.
setReceived_by_user(relatedReceived_by_user2);
}
const relatedReceived_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setReceived_by_user)
{
await
Payment3.
setReceived_by_user(relatedReceived_by_user3);
}
const relatedReceived_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setReceived_by_user)
{
await
Payment4.
setReceived_by_user(relatedReceived_by_user4);
}
}
async function associatePaymentWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment0 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Payment0?.setOrganization)
{
await
Payment0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment1 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Payment1?.setOrganization)
{
await
Payment1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment2 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Payment2?.setOrganization)
{
await
Payment2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment3 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Payment3?.setOrganization)
{
await
Payment3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Payment4 = await Payments.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Payment4?.setOrganization)
{
await
Payment4.
setOrganization(relatedOrganization4);
}
}
async function associateInvoiceWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Invoice0 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invoice0?.setOrganization)
{
await
Invoice0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Invoice1 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invoice1?.setOrganization)
{
await
Invoice1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Invoice2 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invoice2?.setOrganization)
{
await
Invoice2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Invoice3 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invoice3?.setOrganization)
{
await
Invoice3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Invoice4 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invoice4?.setOrganization)
{
await
Invoice4.
setOrganization(relatedOrganization4);
}
}
async function associateInvoiceWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Invoice0 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invoice0?.setVenue)
{
await
Invoice0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Invoice1 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invoice1?.setVenue)
{
await
Invoice1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Invoice2 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invoice2?.setVenue)
{
await
Invoice2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Invoice3 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invoice3?.setVenue)
{
await
Invoice3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Invoice4 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invoice4?.setVenue)
{
await
Invoice4.
setVenue(relatedVenue4);
}
}
async function associateInvoiceWithCustomer() {
const relatedCustomer0 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Invoice0 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invoice0?.setCustomer)
{
await
Invoice0.
setCustomer(relatedCustomer0);
}
const relatedCustomer1 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Invoice1 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invoice1?.setCustomer)
{
await
Invoice1.
setCustomer(relatedCustomer1);
}
const relatedCustomer2 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Invoice2 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invoice2?.setCustomer)
{
await
Invoice2.
setCustomer(relatedCustomer2);
}
const relatedCustomer3 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Invoice3 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invoice3?.setCustomer)
{
await
Invoice3.
setCustomer(relatedCustomer3);
}
const relatedCustomer4 = await Customers.findOne({
offset: Math.floor(Math.random() * (await Customers.count())),
});
const Invoice4 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invoice4?.setCustomer)
{
await
Invoice4.
setCustomer(relatedCustomer4);
}
}
async function associateInvoiceWithBooking() {
const relatedBooking0 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Invoice0 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invoice0?.setBooking)
{
await
Invoice0.
setBooking(relatedBooking0);
}
const relatedBooking1 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Invoice1 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invoice1?.setBooking)
{
await
Invoice1.
setBooking(relatedBooking1);
}
const relatedBooking2 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Invoice2 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invoice2?.setBooking)
{
await
Invoice2.
setBooking(relatedBooking2);
}
const relatedBooking3 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Invoice3 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invoice3?.setBooking)
{
await
Invoice3.
setBooking(relatedBooking3);
}
const relatedBooking4 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Invoice4 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invoice4?.setBooking)
{
await
Invoice4.
setBooking(relatedBooking4);
}
}
async function associateInvoiceWithPos_tab() {
const relatedPos_tab0 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Invoice0 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Invoice0?.setPos_tab)
{
await
Invoice0.
setPos_tab(relatedPos_tab0);
}
const relatedPos_tab1 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Invoice1 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Invoice1?.setPos_tab)
{
await
Invoice1.
setPos_tab(relatedPos_tab1);
}
const relatedPos_tab2 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Invoice2 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Invoice2?.setPos_tab)
{
await
Invoice2.
setPos_tab(relatedPos_tab2);
}
const relatedPos_tab3 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Invoice3 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Invoice3?.setPos_tab)
{
await
Invoice3.
setPos_tab(relatedPos_tab3);
}
const relatedPos_tab4 = await PosTabs.findOne({
offset: Math.floor(Math.random() * (await PosTabs.count())),
});
const Invoice4 = await Invoices.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Invoice4?.setPos_tab)
{
await
Invoice4.
setPos_tab(relatedPos_tab4);
}
}
async function associateDiscountCouponWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscountCoupon0 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscountCoupon0?.setOrganization)
{
await
DiscountCoupon0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscountCoupon1 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscountCoupon1?.setOrganization)
{
await
DiscountCoupon1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscountCoupon2 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscountCoupon2?.setOrganization)
{
await
DiscountCoupon2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscountCoupon3 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (DiscountCoupon3?.setOrganization)
{
await
DiscountCoupon3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscountCoupon4 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (DiscountCoupon4?.setOrganization)
{
await
DiscountCoupon4.
setOrganization(relatedOrganization4);
}
}
async function associateDiscountCouponWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const DiscountCoupon0 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscountCoupon0?.setVenue)
{
await
DiscountCoupon0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const DiscountCoupon1 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscountCoupon1?.setVenue)
{
await
DiscountCoupon1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const DiscountCoupon2 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscountCoupon2?.setVenue)
{
await
DiscountCoupon2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const DiscountCoupon3 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (DiscountCoupon3?.setVenue)
{
await
DiscountCoupon3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const DiscountCoupon4 = await DiscountCoupons.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (DiscountCoupon4?.setVenue)
{
await
DiscountCoupon4.
setVenue(relatedVenue4);
}
}
async function associateNotificationWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setOrganization)
{
await
Notification0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setOrganization)
{
await
Notification1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setOrganization)
{
await
Notification2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setOrganization)
{
await
Notification3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Notification4 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Notification4?.setOrganization)
{
await
Notification4.
setOrganization(relatedOrganization4);
}
}
async function associateNotificationWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setVenue)
{
await
Notification0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setVenue)
{
await
Notification1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setVenue)
{
await
Notification2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setVenue)
{
await
Notification3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const Notification4 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Notification4?.setVenue)
{
await
Notification4.
setVenue(relatedVenue4);
}
}
async function associateNotificationWithRecipient_user() {
const relatedRecipient_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setRecipient_user)
{
await
Notification0.
setRecipient_user(relatedRecipient_user0);
}
const relatedRecipient_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setRecipient_user)
{
await
Notification1.
setRecipient_user(relatedRecipient_user1);
}
const relatedRecipient_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setRecipient_user)
{
await
Notification2.
setRecipient_user(relatedRecipient_user2);
}
const relatedRecipient_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setRecipient_user)
{
await
Notification3.
setRecipient_user(relatedRecipient_user3);
}
const relatedRecipient_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification4 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Notification4?.setRecipient_user)
{
await
Notification4.
setRecipient_user(relatedRecipient_user4);
}
}
async function associateNotificationWithBooking() {
const relatedBooking0 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setBooking)
{
await
Notification0.
setBooking(relatedBooking0);
}
const relatedBooking1 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setBooking)
{
await
Notification1.
setBooking(relatedBooking1);
}
const relatedBooking2 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setBooking)
{
await
Notification2.
setBooking(relatedBooking2);
}
const relatedBooking3 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setBooking)
{
await
Notification3.
setBooking(relatedBooking3);
}
const relatedBooking4 = await Bookings.findOne({
offset: Math.floor(Math.random() * (await Bookings.count())),
});
const Notification4 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Notification4?.setBooking)
{
await
Notification4.
setBooking(relatedBooking4);
}
}
async function associateAuditLogWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditLog0 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditLog0?.setOrganization)
{
await
AuditLog0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditLog1 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditLog1?.setOrganization)
{
await
AuditLog1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditLog2 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditLog2?.setOrganization)
{
await
AuditLog2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditLog3 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AuditLog3?.setOrganization)
{
await
AuditLog3.
setOrganization(relatedOrganization3);
}
const relatedOrganization4 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const AuditLog4 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AuditLog4?.setOrganization)
{
await
AuditLog4.
setOrganization(relatedOrganization4);
}
}
async function associateAuditLogWithVenue() {
const relatedVenue0 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const AuditLog0 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditLog0?.setVenue)
{
await
AuditLog0.
setVenue(relatedVenue0);
}
const relatedVenue1 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const AuditLog1 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditLog1?.setVenue)
{
await
AuditLog1.
setVenue(relatedVenue1);
}
const relatedVenue2 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const AuditLog2 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditLog2?.setVenue)
{
await
AuditLog2.
setVenue(relatedVenue2);
}
const relatedVenue3 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const AuditLog3 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AuditLog3?.setVenue)
{
await
AuditLog3.
setVenue(relatedVenue3);
}
const relatedVenue4 = await Venues.findOne({
offset: Math.floor(Math.random() * (await Venues.count())),
});
const AuditLog4 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AuditLog4?.setVenue)
{
await
AuditLog4.
setVenue(relatedVenue4);
}
}
async function associateAuditLogWithActor_user() {
const relatedActor_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog0 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AuditLog0?.setActor_user)
{
await
AuditLog0.
setActor_user(relatedActor_user0);
}
const relatedActor_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog1 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AuditLog1?.setActor_user)
{
await
AuditLog1.
setActor_user(relatedActor_user1);
}
const relatedActor_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog2 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AuditLog2?.setActor_user)
{
await
AuditLog2.
setActor_user(relatedActor_user2);
}
const relatedActor_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog3 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AuditLog3?.setActor_user)
{
await
AuditLog3.
setActor_user(relatedActor_user3);
}
const relatedActor_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AuditLog4 = await AuditLogs.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (AuditLog4?.setActor_user)
{
await
AuditLog4.
setActor_user(relatedActor_user4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Organizations.bulkCreate(OrganizationsData);
await Venues.bulkCreate(VenuesData);
await Sports.bulkCreate(SportsData);
await Courts.bulkCreate(CourtsData);
await Customers.bulkCreate(CustomersData);
await Bookings.bulkCreate(BookingsData);
await PriceRules.bulkCreate(PriceRulesData);
await PosTabs.bulkCreate(PosTabsData);
await PosTabItems.bulkCreate(PosTabItemsData);
await Products.bulkCreate(ProductsData);
await ProductCategories.bulkCreate(ProductCategoriesData);
await InventoryLocations.bulkCreate(InventoryLocationsData);
await StockMovements.bulkCreate(StockMovementsData);
await CashSessions.bulkCreate(CashSessionsData);
await Payments.bulkCreate(PaymentsData);
await Invoices.bulkCreate(InvoicesData);
await DiscountCoupons.bulkCreate(DiscountCouponsData);
await Notifications.bulkCreate(NotificationsData);
await AuditLogs.bulkCreate(AuditLogsData);
await Promise.all([
// Similar logic for "relation_many"
await associateUserWithOrganization(),
await associateVenueWithOrganization(),
await associateSportWithOrganization(),
await associateCourtWithVenue(),
await associateCourtWithSport(),
await associateCourtWithOrganization(),
await associateCustomerWithOrganization(),
await associateCustomerWithVenue(),
await associateBookingWithOrganization(),
await associateBookingWithVenue(),
await associateBookingWithCourt(),
await associateBookingWithCustomer(),
await associateBookingWithCreated_by_user(),
await associatePriceRuleWithVenue(),
await associatePriceRuleWithCourt(),
await associatePriceRuleWithOrganization(),
await associatePosTabWithOrganization(),
await associatePosTabWithVenue(),
await associatePosTabWithBooking(),
await associatePosTabWithCustomer(),
await associatePosTabWithOpened_by_user(),
await associatePosTabWithClosed_by_user(),
await associatePosTabItemWithPos_tab(),
await associatePosTabItemWithProduct(),
await associatePosTabItemWithAdded_by_user(),
await associatePosTabItemWithOrganization(),
await associateProductWithOrganization(),
await associateProductWithVenue(),
await associateProductWithProduct_category(),
await associateProductCategoryWithOrganization(),
await associateProductCategoryWithVenue(),
await associateInventoryLocationWithVenue(),
await associateInventoryLocationWithOrganization(),
await associateStockMovementWithVenue(),
await associateStockMovementWithInventory_location(),
await associateStockMovementWithProduct(),
await associateStockMovementWithPos_tab_item(),
await associateStockMovementWithPerformed_by_user(),
await associateStockMovementWithOrganization(),
await associateCashSessionWithVenue(),
await associateCashSessionWithOpened_by_user(),
await associateCashSessionWithClosed_by_user(),
await associateCashSessionWithOrganization(),
await associatePaymentWithVenue(),
await associatePaymentWithCash_session(),
await associatePaymentWithBooking(),
await associatePaymentWithPos_tab(),
await associatePaymentWithReceived_by_user(),
await associatePaymentWithOrganization(),
await associateInvoiceWithOrganization(),
await associateInvoiceWithVenue(),
await associateInvoiceWithCustomer(),
await associateInvoiceWithBooking(),
await associateInvoiceWithPos_tab(),
await associateDiscountCouponWithOrganization(),
await associateDiscountCouponWithVenue(),
await associateNotificationWithOrganization(),
await associateNotificationWithVenue(),
await associateNotificationWithRecipient_user(),
await associateNotificationWithBooking(),
await associateAuditLogWithOrganization(),
await associateAuditLogWithVenue(),
await associateAuditLogWithActor_user(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('organizations', null, {});
await queryInterface.bulkDelete('venues', null, {});
await queryInterface.bulkDelete('sports', null, {});
await queryInterface.bulkDelete('courts', null, {});
await queryInterface.bulkDelete('customers', null, {});
await queryInterface.bulkDelete('bookings', null, {});
await queryInterface.bulkDelete('price_rules', null, {});
await queryInterface.bulkDelete('pos_tabs', null, {});
await queryInterface.bulkDelete('pos_tab_items', null, {});
await queryInterface.bulkDelete('products', null, {});
await queryInterface.bulkDelete('product_categories', null, {});
await queryInterface.bulkDelete('inventory_locations', null, {});
await queryInterface.bulkDelete('stock_movements', null, {});
await queryInterface.bulkDelete('cash_sessions', null, {});
await queryInterface.bulkDelete('payments', null, {});
await queryInterface.bulkDelete('invoices', null, {});
await queryInterface.bulkDelete('discount_coupons', null, {});
await queryInterface.bulkDelete('notifications', null, {});
await queryInterface.bulkDelete('audit_logs', null, {});
},
};