2695 lines
48 KiB
JavaScript
2695 lines
48 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const StaffRoles = db.staff_roles;
|
|
|
|
const Customers = db.customers;
|
|
|
|
const Tables = db.tables;
|
|
|
|
const Reservations = db.reservations;
|
|
|
|
const Tabs = db.tabs;
|
|
|
|
const LineItems = db.line_items;
|
|
|
|
const MenuItems = db.menu_items;
|
|
|
|
const InventoryItems = db.inventory_items;
|
|
|
|
const Suppliers = db.suppliers;
|
|
|
|
const Payments = db.payments;
|
|
|
|
const Promotions = db.promotions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const StaffRolesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Owner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Business owner with full operational oversight",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Manager",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Oversees daily operations and staff coordination",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Floor Staff",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Handles floor duties including seating and guest requests",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CustomersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Olivia Bennett",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "olivia.bennett@example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-202-555-0201",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Vegetarian, prefers window seating",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loyalty_points": 120,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Ethan Brooks",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "ethan.brooks@example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-202-555-0202",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Celebrated birthday in March",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loyalty_points": 45,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Chloe Nguyen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "chloe.nguyen@example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-202-555-0203",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Allergic to shellfish",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loyalty_points": 230,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TablesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Table 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Window",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_available": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Table 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Center",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_available": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Bar Counter 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Bar",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_available": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ReservationsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"code": "R-1001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-02-14T19:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-02-14T21:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"party_size": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "seated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Anniversary seating request",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"code": "R-1002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-02-15T18:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-02-15T19:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"party_size": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "seated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"code": "R-1003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-02-16T20:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-02-16T22:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"party_size": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "canceled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Outdoor seating if clear",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TabsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"number": "TAB-101",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"opened_at": new Date('2026-01-10T20:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-01-10T22:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "open",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total": 89.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Paid by card",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"number": "TAB-102",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"opened_at": new Date('2026-01-12T19:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "closed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Open for group of six",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"number": "TAB-103",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"opened_at": new Date('2026-01-13T21:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-01-13T22:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "closed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total": 42.75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Split bill expected",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LineItemsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Margarita",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_price": 12.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_price": 25.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "No salt on rim",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Craft Beer Pint",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_price": 7.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_price": 21.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Margherita Pizza",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_price": 14.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_price": 14.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Add extra basil",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const MenuItemsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Margarita",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "COCK-001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 12.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_alcohol": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "wine",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Craft Beer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "BEER-002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 7.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_alcohol": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "wine",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Old Fashioned",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "COCK-003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 13.25,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_alcohol": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "cocktail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const InventoryItemsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Tequila Blanco 750ml",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "INV-TEQ-750",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 24.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "bottle",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reorder_level": 6.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Local Pale Ale Keg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "INV-BEER-KEG",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 3.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "keg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reorder_level": 1.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Bourbon 700ml",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "INV-BUR-700",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 12.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "bottle",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reorder_level": 4.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const SuppliersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Northern Spirits Co",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "sales@northernspirits.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-303-555-1101",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Primary spirits supplier",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Local Brew Distributors",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "contact@localbrew.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-303-555-1102",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Handles kegs and beer rotation",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Heritage Liquors",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "orders@heritageliquors.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-303-555-1103",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Specialty bourbons and limited bottles",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const PaymentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "PAY-2001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 89.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"method": "online",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-01-10T22:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "PAY-2002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 42.75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"method": "card",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-01-13T22:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "PAY-2003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 15.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"method": "card",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-01-14T19:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const PromotionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"code": "HAPPYHOUR",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Discounted drinks for happy hour",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-01T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-12-31T19:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"discount_percent": 20.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"code": "WEEKENDFOOD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Food discount on weekends",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-03-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-12-31T23:59:59Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"discount_percent": 15.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"code": "NEWCUSTOMER5",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "One time 5 percent for new customers",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-12-31T23:59:59Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"discount_percent": 5.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateReservationWithCustomer() {
|
|
|
|
const relatedCustomer0 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Reservation0 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Reservation0?.setCustomer)
|
|
{
|
|
await
|
|
Reservation0.
|
|
setCustomer(relatedCustomer0);
|
|
}
|
|
|
|
const relatedCustomer1 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Reservation1 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Reservation1?.setCustomer)
|
|
{
|
|
await
|
|
Reservation1.
|
|
setCustomer(relatedCustomer1);
|
|
}
|
|
|
|
const relatedCustomer2 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Reservation2 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Reservation2?.setCustomer)
|
|
{
|
|
await
|
|
Reservation2.
|
|
setCustomer(relatedCustomer2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateReservationWithTable() {
|
|
|
|
const relatedTable0 = await Tables.findOne({
|
|
offset: Math.floor(Math.random() * (await Tables.count())),
|
|
});
|
|
const Reservation0 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Reservation0?.setTable)
|
|
{
|
|
await
|
|
Reservation0.
|
|
setTable(relatedTable0);
|
|
}
|
|
|
|
const relatedTable1 = await Tables.findOne({
|
|
offset: Math.floor(Math.random() * (await Tables.count())),
|
|
});
|
|
const Reservation1 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Reservation1?.setTable)
|
|
{
|
|
await
|
|
Reservation1.
|
|
setTable(relatedTable1);
|
|
}
|
|
|
|
const relatedTable2 = await Tables.findOne({
|
|
offset: Math.floor(Math.random() * (await Tables.count())),
|
|
});
|
|
const Reservation2 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Reservation2?.setTable)
|
|
{
|
|
await
|
|
Reservation2.
|
|
setTable(relatedTable2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateReservationWithAssigned_staff() {
|
|
|
|
const relatedAssigned_staff0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Reservation0 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Reservation0?.setAssigned_staff)
|
|
{
|
|
await
|
|
Reservation0.
|
|
setAssigned_staff(relatedAssigned_staff0);
|
|
}
|
|
|
|
const relatedAssigned_staff1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Reservation1 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Reservation1?.setAssigned_staff)
|
|
{
|
|
await
|
|
Reservation1.
|
|
setAssigned_staff(relatedAssigned_staff1);
|
|
}
|
|
|
|
const relatedAssigned_staff2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Reservation2 = await Reservations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Reservation2?.setAssigned_staff)
|
|
{
|
|
await
|
|
Reservation2.
|
|
setAssigned_staff(relatedAssigned_staff2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateTabWithCustomer() {
|
|
|
|
const relatedCustomer0 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Tab0 = await Tabs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Tab0?.setCustomer)
|
|
{
|
|
await
|
|
Tab0.
|
|
setCustomer(relatedCustomer0);
|
|
}
|
|
|
|
const relatedCustomer1 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Tab1 = await Tabs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Tab1?.setCustomer)
|
|
{
|
|
await
|
|
Tab1.
|
|
setCustomer(relatedCustomer1);
|
|
}
|
|
|
|
const relatedCustomer2 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Tab2 = await Tabs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Tab2?.setCustomer)
|
|
{
|
|
await
|
|
Tab2.
|
|
setCustomer(relatedCustomer2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTabWithOpened_by() {
|
|
|
|
const relatedOpened_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Tab0 = await Tabs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Tab0?.setOpened_by)
|
|
{
|
|
await
|
|
Tab0.
|
|
setOpened_by(relatedOpened_by0);
|
|
}
|
|
|
|
const relatedOpened_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Tab1 = await Tabs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Tab1?.setOpened_by)
|
|
{
|
|
await
|
|
Tab1.
|
|
setOpened_by(relatedOpened_by1);
|
|
}
|
|
|
|
const relatedOpened_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Tab2 = await Tabs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Tab2?.setOpened_by)
|
|
{
|
|
await
|
|
Tab2.
|
|
setOpened_by(relatedOpened_by2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLineItemWithProduct() {
|
|
|
|
const relatedProduct0 = await MenuItems.findOne({
|
|
offset: Math.floor(Math.random() * (await MenuItems.count())),
|
|
});
|
|
const LineItem0 = await LineItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (LineItem0?.setProduct)
|
|
{
|
|
await
|
|
LineItem0.
|
|
setProduct(relatedProduct0);
|
|
}
|
|
|
|
const relatedProduct1 = await MenuItems.findOne({
|
|
offset: Math.floor(Math.random() * (await MenuItems.count())),
|
|
});
|
|
const LineItem1 = await LineItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (LineItem1?.setProduct)
|
|
{
|
|
await
|
|
LineItem1.
|
|
setProduct(relatedProduct1);
|
|
}
|
|
|
|
const relatedProduct2 = await MenuItems.findOne({
|
|
offset: Math.floor(Math.random() * (await MenuItems.count())),
|
|
});
|
|
const LineItem2 = await LineItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (LineItem2?.setProduct)
|
|
{
|
|
await
|
|
LineItem2.
|
|
setProduct(relatedProduct2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateLineItemWithTab() {
|
|
|
|
const relatedTab0 = await Tabs.findOne({
|
|
offset: Math.floor(Math.random() * (await Tabs.count())),
|
|
});
|
|
const LineItem0 = await LineItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (LineItem0?.setTab)
|
|
{
|
|
await
|
|
LineItem0.
|
|
setTab(relatedTab0);
|
|
}
|
|
|
|
const relatedTab1 = await Tabs.findOne({
|
|
offset: Math.floor(Math.random() * (await Tabs.count())),
|
|
});
|
|
const LineItem1 = await LineItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (LineItem1?.setTab)
|
|
{
|
|
await
|
|
LineItem1.
|
|
setTab(relatedTab1);
|
|
}
|
|
|
|
const relatedTab2 = await Tabs.findOne({
|
|
offset: Math.floor(Math.random() * (await Tabs.count())),
|
|
});
|
|
const LineItem2 = await LineItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (LineItem2?.setTab)
|
|
{
|
|
await
|
|
LineItem2.
|
|
setTab(relatedTab2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMenuItemWithInventory() {
|
|
|
|
const relatedInventory0 = await InventoryItems.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryItems.count())),
|
|
});
|
|
const MenuItem0 = await MenuItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (MenuItem0?.setInventory)
|
|
{
|
|
await
|
|
MenuItem0.
|
|
setInventory(relatedInventory0);
|
|
}
|
|
|
|
const relatedInventory1 = await InventoryItems.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryItems.count())),
|
|
});
|
|
const MenuItem1 = await MenuItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (MenuItem1?.setInventory)
|
|
{
|
|
await
|
|
MenuItem1.
|
|
setInventory(relatedInventory1);
|
|
}
|
|
|
|
const relatedInventory2 = await InventoryItems.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryItems.count())),
|
|
});
|
|
const MenuItem2 = await MenuItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (MenuItem2?.setInventory)
|
|
{
|
|
await
|
|
MenuItem2.
|
|
setInventory(relatedInventory2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateInventoryItemWithSupplier() {
|
|
|
|
const relatedSupplier0 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const InventoryItem0 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryItem0?.setSupplier)
|
|
{
|
|
await
|
|
InventoryItem0.
|
|
setSupplier(relatedSupplier0);
|
|
}
|
|
|
|
const relatedSupplier1 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const InventoryItem1 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryItem1?.setSupplier)
|
|
{
|
|
await
|
|
InventoryItem1.
|
|
setSupplier(relatedSupplier1);
|
|
}
|
|
|
|
const relatedSupplier2 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const InventoryItem2 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryItem2?.setSupplier)
|
|
{
|
|
await
|
|
InventoryItem2.
|
|
setSupplier(relatedSupplier2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associatePaymentWithTab() {
|
|
|
|
const relatedTab0 = await Tabs.findOne({
|
|
offset: Math.floor(Math.random() * (await Tabs.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Payment0?.setTab)
|
|
{
|
|
await
|
|
Payment0.
|
|
setTab(relatedTab0);
|
|
}
|
|
|
|
const relatedTab1 = await Tabs.findOne({
|
|
offset: Math.floor(Math.random() * (await Tabs.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Payment1?.setTab)
|
|
{
|
|
await
|
|
Payment1.
|
|
setTab(relatedTab1);
|
|
}
|
|
|
|
const relatedTab2 = await Tabs.findOne({
|
|
offset: Math.floor(Math.random() * (await Tabs.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Payment2?.setTab)
|
|
{
|
|
await
|
|
Payment2.
|
|
setTab(relatedTab2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associatePaymentWithProcessed_by() {
|
|
|
|
const relatedProcessed_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Payment0?.setProcessed_by)
|
|
{
|
|
await
|
|
Payment0.
|
|
setProcessed_by(relatedProcessed_by0);
|
|
}
|
|
|
|
const relatedProcessed_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Payment1?.setProcessed_by)
|
|
{
|
|
await
|
|
Payment1.
|
|
setProcessed_by(relatedProcessed_by1);
|
|
}
|
|
|
|
const relatedProcessed_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Payment2?.setProcessed_by)
|
|
{
|
|
await
|
|
Payment2.
|
|
setProcessed_by(relatedProcessed_by2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await StaffRoles.bulkCreate(StaffRolesData);
|
|
|
|
|
|
|
|
|
|
await Customers.bulkCreate(CustomersData);
|
|
|
|
|
|
|
|
|
|
await Tables.bulkCreate(TablesData);
|
|
|
|
|
|
|
|
|
|
await Reservations.bulkCreate(ReservationsData);
|
|
|
|
|
|
|
|
|
|
await Tabs.bulkCreate(TabsData);
|
|
|
|
|
|
|
|
|
|
await LineItems.bulkCreate(LineItemsData);
|
|
|
|
|
|
|
|
|
|
await MenuItems.bulkCreate(MenuItemsData);
|
|
|
|
|
|
|
|
|
|
await InventoryItems.bulkCreate(InventoryItemsData);
|
|
|
|
|
|
|
|
|
|
await Suppliers.bulkCreate(SuppliersData);
|
|
|
|
|
|
|
|
|
|
await Payments.bulkCreate(PaymentsData);
|
|
|
|
|
|
|
|
|
|
await Promotions.bulkCreate(PromotionsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateReservationWithCustomer(),
|
|
|
|
|
|
|
|
|
|
await associateReservationWithTable(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateReservationWithAssigned_staff(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateTabWithCustomer(),
|
|
|
|
|
|
|
|
|
|
await associateTabWithOpened_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLineItemWithProduct(),
|
|
|
|
|
|
|
|
|
|
await associateLineItemWithTab(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMenuItemWithInventory(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateInventoryItemWithSupplier(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associatePaymentWithTab(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associatePaymentWithProcessed_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('staff_roles', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('customers', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('tables', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('reservations', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('tabs', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('line_items', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('menu_items', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('inventory_items', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('suppliers', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('payments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('promotions', null, {});
|
|
|
|
|
|
},
|
|
}; |