4290 lines
74 KiB
JavaScript
4290 lines
74 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ProductCategories = db.product_categories;
|
|
|
|
const Products = db.products;
|
|
|
|
const ProductVariants = db.product_variants;
|
|
|
|
const InventoryLocations = db.inventory_locations;
|
|
|
|
const InventoryItems = db.inventory_items;
|
|
|
|
const Customers = db.customers;
|
|
|
|
const CustomerAddresses = db.customer_addresses;
|
|
|
|
const Orders = db.orders;
|
|
|
|
const OrderItems = db.order_items;
|
|
|
|
const Payments = db.payments;
|
|
|
|
const Refunds = db.refunds;
|
|
|
|
const Shipments = db.shipments;
|
|
|
|
const OrderEvents = db.order_events;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ProductCategoriesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"slug": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"slug": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"slug": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProductsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"barcode": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"product_type": "standard",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "archived",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"base_price": 8.46,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 4.05,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_taxable": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"barcode": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"product_type": "standard",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"base_price": 6.34,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 6.6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_taxable": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"barcode": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"product_type": "standard",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"base_price": 0.29,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 8.4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_taxable": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProductVariantsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"variant_name": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"barcode": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 1.02,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 7.57,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"variant_name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"barcode": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 9.46,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 0.57,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"variant_name": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"barcode": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 3.61,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 8.08,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const InventoryLocationsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_line1": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_line2": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"city": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"region": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"postal_code": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"country": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_line1": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_line2": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"city": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"region": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"postal_code": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"country": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_line1": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_line2": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"city": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"region": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"postal_code": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"country": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const InventoryItemsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"on_hand": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reorder_point": 8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"track_inventory": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"on_hand": 9,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reorder_point": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"track_inventory": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"on_hand": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reorder_point": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"track_inventory": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CustomersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"registered_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Alan Turing",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"registered_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Ada Lovelace",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"registered_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Alan Turing",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CustomerAddressesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_type": "billing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"recipient_name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line1": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line2": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"city": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"region": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"postal_code": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"country": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_type": "shipping",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"recipient_name": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line1": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line2": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"city": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"region": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"postal_code": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"country": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address_type": "shipping",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"recipient_name": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line1": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line2": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"city": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"region": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"postal_code": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"country": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const OrdersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"order_number": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "fulfilled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payment_status": "failed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"fulfillment_status": "partially_fulfilled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"placed_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"fulfilled_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"customer_email": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"customer_phone": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subtotal_amount": 0.47,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"discount_amount": 6.98,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_amount": 4.55,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tax_amount": 4.53,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_amount": 4.85,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address_text": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address_text": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"internal_notes": "Grace Hopper",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"order_number": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "fulfilled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payment_status": "paid",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"fulfillment_status": "unfulfilled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"placed_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"fulfilled_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"customer_email": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"customer_phone": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subtotal_amount": 3.82,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"discount_amount": 4.23,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_amount": 3.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tax_amount": 0.86,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_amount": 2.94,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address_text": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address_text": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"internal_notes": "Ada Lovelace",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"order_number": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payment_status": "paid",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"fulfillment_status": "fulfilled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"placed_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"fulfilled_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"customer_email": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"customer_phone": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subtotal_amount": 1.62,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"discount_amount": 8.89,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_amount": 5.58,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tax_amount": 9.39,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_amount": 2.31,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address_text": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address_text": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"internal_notes": "Alan Turing",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const OrderItemsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"product_name": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"variant_name": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_price": 7.44,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tax_amount": 2.76,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line_total": 7.99,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"product_name": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"variant_name": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_price": 0.49,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tax_amount": 5.86,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line_total": 2.58,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"product_name": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"variant_name": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_price": 7.73,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tax_amount": 3.58,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"line_total": 7.18,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const PaymentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payment_reference": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"method": "bank_transfer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 3.05,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"authorized_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"captured_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reconciled_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_reconciled": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processor": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processor_transaction_ref": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Marie Curie",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payment_reference": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"method": "bank_transfer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 2.37,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"authorized_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"captured_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reconciled_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_reconciled": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processor": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processor_transaction_ref": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Alan Turing",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payment_reference": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"method": "cash",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "captured",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 7.83,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"authorized_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"captured_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reconciled_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_reconciled": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processor": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processor_transaction_ref": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Marie Curie",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const RefundsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"refund_reference": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "succeeded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 3.03,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"refunded_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reason": "Marie Curie",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"refund_reference": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 1.69,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"refunded_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reason": "Grace Hopper",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"refund_reference": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "succeeded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 5.05,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"refunded_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reason": "Alan Turing",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ShipmentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "shipped",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"carrier": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"service_level": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tracking_number": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tracking_url": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipped_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"delivered_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_cost": 6.48,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"carrier": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"service_level": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tracking_number": "Alan Turing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tracking_url": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipped_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"delivered_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_cost": 4.24,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "returned",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"carrier": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"service_level": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tracking_number": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tracking_url": "Ada Lovelace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipped_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"delivered_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_cost": 0.49,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const OrderEventsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "created",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "Marie Curie",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "status_changed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "created",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_at": new Date(Date.now()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "Grace Hopper",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProductWithCategory() {
|
|
|
|
const relatedCategory0 = await ProductCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductCategories.count())),
|
|
});
|
|
const Product0 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Product0?.setCategory)
|
|
{
|
|
await
|
|
Product0.
|
|
setCategory(relatedCategory0);
|
|
}
|
|
|
|
const relatedCategory1 = await ProductCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductCategories.count())),
|
|
});
|
|
const Product1 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Product1?.setCategory)
|
|
{
|
|
await
|
|
Product1.
|
|
setCategory(relatedCategory1);
|
|
}
|
|
|
|
const relatedCategory2 = await ProductCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductCategories.count())),
|
|
});
|
|
const Product2 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Product2?.setCategory)
|
|
{
|
|
await
|
|
Product2.
|
|
setCategory(relatedCategory2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProductVariantWithProduct() {
|
|
|
|
const relatedProduct0 = await Products.findOne({
|
|
offset: Math.floor(Math.random() * (await Products.count())),
|
|
});
|
|
const ProductVariant0 = await ProductVariants.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProductVariant0?.setProduct)
|
|
{
|
|
await
|
|
ProductVariant0.
|
|
setProduct(relatedProduct0);
|
|
}
|
|
|
|
const relatedProduct1 = await Products.findOne({
|
|
offset: Math.floor(Math.random() * (await Products.count())),
|
|
});
|
|
const ProductVariant1 = await ProductVariants.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProductVariant1?.setProduct)
|
|
{
|
|
await
|
|
ProductVariant1.
|
|
setProduct(relatedProduct1);
|
|
}
|
|
|
|
const relatedProduct2 = await Products.findOne({
|
|
offset: Math.floor(Math.random() * (await Products.count())),
|
|
});
|
|
const ProductVariant2 = await ProductVariants.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProductVariant2?.setProduct)
|
|
{
|
|
await
|
|
ProductVariant2.
|
|
setProduct(relatedProduct2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateInventoryItemWithVariant() {
|
|
|
|
const relatedVariant0 = await ProductVariants.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductVariants.count())),
|
|
});
|
|
const InventoryItem0 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryItem0?.setVariant)
|
|
{
|
|
await
|
|
InventoryItem0.
|
|
setVariant(relatedVariant0);
|
|
}
|
|
|
|
const relatedVariant1 = await ProductVariants.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductVariants.count())),
|
|
});
|
|
const InventoryItem1 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryItem1?.setVariant)
|
|
{
|
|
await
|
|
InventoryItem1.
|
|
setVariant(relatedVariant1);
|
|
}
|
|
|
|
const relatedVariant2 = await ProductVariants.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductVariants.count())),
|
|
});
|
|
const InventoryItem2 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryItem2?.setVariant)
|
|
{
|
|
await
|
|
InventoryItem2.
|
|
setVariant(relatedVariant2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateInventoryItemWithLocation() {
|
|
|
|
const relatedLocation0 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryItem0 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryItem0?.setLocation)
|
|
{
|
|
await
|
|
InventoryItem0.
|
|
setLocation(relatedLocation0);
|
|
}
|
|
|
|
const relatedLocation1 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryItem1 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryItem1?.setLocation)
|
|
{
|
|
await
|
|
InventoryItem1.
|
|
setLocation(relatedLocation1);
|
|
}
|
|
|
|
const relatedLocation2 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryItem2 = await InventoryItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryItem2?.setLocation)
|
|
{
|
|
await
|
|
InventoryItem2.
|
|
setLocation(relatedLocation2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCustomerAddressWithCustomer() {
|
|
|
|
const relatedCustomer0 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const CustomerAddress0 = await CustomerAddresses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (CustomerAddress0?.setCustomer)
|
|
{
|
|
await
|
|
CustomerAddress0.
|
|
setCustomer(relatedCustomer0);
|
|
}
|
|
|
|
const relatedCustomer1 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const CustomerAddress1 = await CustomerAddresses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (CustomerAddress1?.setCustomer)
|
|
{
|
|
await
|
|
CustomerAddress1.
|
|
setCustomer(relatedCustomer1);
|
|
}
|
|
|
|
const relatedCustomer2 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const CustomerAddress2 = await CustomerAddresses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (CustomerAddress2?.setCustomer)
|
|
{
|
|
await
|
|
CustomerAddress2.
|
|
setCustomer(relatedCustomer2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateOrderWithCustomer() {
|
|
|
|
const relatedCustomer0 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Order0 = await Orders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Order0?.setCustomer)
|
|
{
|
|
await
|
|
Order0.
|
|
setCustomer(relatedCustomer0);
|
|
}
|
|
|
|
const relatedCustomer1 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Order1 = await Orders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Order1?.setCustomer)
|
|
{
|
|
await
|
|
Order1.
|
|
setCustomer(relatedCustomer1);
|
|
}
|
|
|
|
const relatedCustomer2 = await Customers.findOne({
|
|
offset: Math.floor(Math.random() * (await Customers.count())),
|
|
});
|
|
const Order2 = await Orders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Order2?.setCustomer)
|
|
{
|
|
await
|
|
Order2.
|
|
setCustomer(relatedCustomer2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateOrderItemWithOrder() {
|
|
|
|
const relatedOrder0 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const OrderItem0 = await OrderItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (OrderItem0?.setOrder)
|
|
{
|
|
await
|
|
OrderItem0.
|
|
setOrder(relatedOrder0);
|
|
}
|
|
|
|
const relatedOrder1 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const OrderItem1 = await OrderItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (OrderItem1?.setOrder)
|
|
{
|
|
await
|
|
OrderItem1.
|
|
setOrder(relatedOrder1);
|
|
}
|
|
|
|
const relatedOrder2 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const OrderItem2 = await OrderItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (OrderItem2?.setOrder)
|
|
{
|
|
await
|
|
OrderItem2.
|
|
setOrder(relatedOrder2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateOrderItemWithVariant() {
|
|
|
|
const relatedVariant0 = await ProductVariants.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductVariants.count())),
|
|
});
|
|
const OrderItem0 = await OrderItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (OrderItem0?.setVariant)
|
|
{
|
|
await
|
|
OrderItem0.
|
|
setVariant(relatedVariant0);
|
|
}
|
|
|
|
const relatedVariant1 = await ProductVariants.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductVariants.count())),
|
|
});
|
|
const OrderItem1 = await OrderItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (OrderItem1?.setVariant)
|
|
{
|
|
await
|
|
OrderItem1.
|
|
setVariant(relatedVariant1);
|
|
}
|
|
|
|
const relatedVariant2 = await ProductVariants.findOne({
|
|
offset: Math.floor(Math.random() * (await ProductVariants.count())),
|
|
});
|
|
const OrderItem2 = await OrderItems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (OrderItem2?.setVariant)
|
|
{
|
|
await
|
|
OrderItem2.
|
|
setVariant(relatedVariant2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associatePaymentWithOrder() {
|
|
|
|
const relatedOrder0 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Payment0?.setOrder)
|
|
{
|
|
await
|
|
Payment0.
|
|
setOrder(relatedOrder0);
|
|
}
|
|
|
|
const relatedOrder1 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Payment1?.setOrder)
|
|
{
|
|
await
|
|
Payment1.
|
|
setOrder(relatedOrder1);
|
|
}
|
|
|
|
const relatedOrder2 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Payment2?.setOrder)
|
|
{
|
|
await
|
|
Payment2.
|
|
setOrder(relatedOrder2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateRefundWithPayment() {
|
|
|
|
const relatedPayment0 = await Payments.findOne({
|
|
offset: Math.floor(Math.random() * (await Payments.count())),
|
|
});
|
|
const Refund0 = await Refunds.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Refund0?.setPayment)
|
|
{
|
|
await
|
|
Refund0.
|
|
setPayment(relatedPayment0);
|
|
}
|
|
|
|
const relatedPayment1 = await Payments.findOne({
|
|
offset: Math.floor(Math.random() * (await Payments.count())),
|
|
});
|
|
const Refund1 = await Refunds.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Refund1?.setPayment)
|
|
{
|
|
await
|
|
Refund1.
|
|
setPayment(relatedPayment1);
|
|
}
|
|
|
|
const relatedPayment2 = await Payments.findOne({
|
|
offset: Math.floor(Math.random() * (await Payments.count())),
|
|
});
|
|
const Refund2 = await Refunds.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Refund2?.setPayment)
|
|
{
|
|
await
|
|
Refund2.
|
|
setPayment(relatedPayment2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateShipmentWithOrder() {
|
|
|
|
const relatedOrder0 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const Shipment0 = await Shipments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Shipment0?.setOrder)
|
|
{
|
|
await
|
|
Shipment0.
|
|
setOrder(relatedOrder0);
|
|
}
|
|
|
|
const relatedOrder1 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const Shipment1 = await Shipments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Shipment1?.setOrder)
|
|
{
|
|
await
|
|
Shipment1.
|
|
setOrder(relatedOrder1);
|
|
}
|
|
|
|
const relatedOrder2 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const Shipment2 = await Shipments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Shipment2?.setOrder)
|
|
{
|
|
await
|
|
Shipment2.
|
|
setOrder(relatedOrder2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateShipmentWithShip_from_location() {
|
|
|
|
const relatedShip_from_location0 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const Shipment0 = await Shipments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Shipment0?.setShip_from_location)
|
|
{
|
|
await
|
|
Shipment0.
|
|
setShip_from_location(relatedShip_from_location0);
|
|
}
|
|
|
|
const relatedShip_from_location1 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const Shipment1 = await Shipments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Shipment1?.setShip_from_location)
|
|
{
|
|
await
|
|
Shipment1.
|
|
setShip_from_location(relatedShip_from_location1);
|
|
}
|
|
|
|
const relatedShip_from_location2 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const Shipment2 = await Shipments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Shipment2?.setShip_from_location)
|
|
{
|
|
await
|
|
Shipment2.
|
|
setShip_from_location(relatedShip_from_location2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateOrderEventWithOrder() {
|
|
|
|
const relatedOrder0 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const OrderEvent0 = await OrderEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (OrderEvent0?.setOrder)
|
|
{
|
|
await
|
|
OrderEvent0.
|
|
setOrder(relatedOrder0);
|
|
}
|
|
|
|
const relatedOrder1 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const OrderEvent1 = await OrderEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (OrderEvent1?.setOrder)
|
|
{
|
|
await
|
|
OrderEvent1.
|
|
setOrder(relatedOrder1);
|
|
}
|
|
|
|
const relatedOrder2 = await Orders.findOne({
|
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
|
});
|
|
const OrderEvent2 = await OrderEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (OrderEvent2?.setOrder)
|
|
{
|
|
await
|
|
OrderEvent2.
|
|
setOrder(relatedOrder2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateOrderEventWithActor() {
|
|
|
|
const relatedActor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const OrderEvent0 = await OrderEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (OrderEvent0?.setActor)
|
|
{
|
|
await
|
|
OrderEvent0.
|
|
setActor(relatedActor0);
|
|
}
|
|
|
|
const relatedActor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const OrderEvent1 = await OrderEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (OrderEvent1?.setActor)
|
|
{
|
|
await
|
|
OrderEvent1.
|
|
setActor(relatedActor1);
|
|
}
|
|
|
|
const relatedActor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const OrderEvent2 = await OrderEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (OrderEvent2?.setActor)
|
|
{
|
|
await
|
|
OrderEvent2.
|
|
setActor(relatedActor2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ProductCategories.bulkCreate(ProductCategoriesData);
|
|
|
|
|
|
|
|
|
|
await Products.bulkCreate(ProductsData);
|
|
|
|
|
|
|
|
|
|
await ProductVariants.bulkCreate(ProductVariantsData);
|
|
|
|
|
|
|
|
|
|
await InventoryLocations.bulkCreate(InventoryLocationsData);
|
|
|
|
|
|
|
|
|
|
await InventoryItems.bulkCreate(InventoryItemsData);
|
|
|
|
|
|
|
|
|
|
await Customers.bulkCreate(CustomersData);
|
|
|
|
|
|
|
|
|
|
await CustomerAddresses.bulkCreate(CustomerAddressesData);
|
|
|
|
|
|
|
|
|
|
await Orders.bulkCreate(OrdersData);
|
|
|
|
|
|
|
|
|
|
await OrderItems.bulkCreate(OrderItemsData);
|
|
|
|
|
|
|
|
|
|
await Payments.bulkCreate(PaymentsData);
|
|
|
|
|
|
|
|
|
|
await Refunds.bulkCreate(RefundsData);
|
|
|
|
|
|
|
|
|
|
await Shipments.bulkCreate(ShipmentsData);
|
|
|
|
|
|
|
|
|
|
await OrderEvents.bulkCreate(OrderEventsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProductWithCategory(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProductVariantWithProduct(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateInventoryItemWithVariant(),
|
|
|
|
|
|
|
|
|
|
await associateInventoryItemWithLocation(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCustomerAddressWithCustomer(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateOrderWithCustomer(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateOrderItemWithOrder(),
|
|
|
|
|
|
|
|
|
|
await associateOrderItemWithVariant(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associatePaymentWithOrder(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateRefundWithPayment(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateShipmentWithOrder(),
|
|
|
|
|
|
|
|
|
|
await associateShipmentWithShip_from_location(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateOrderEventWithOrder(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateOrderEventWithActor(),
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('product_categories', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('products', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('product_variants', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('inventory_locations', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('inventory_items', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('customers', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('customer_addresses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('orders', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('order_items', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('payments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('refunds', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('shipments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('order_events', null, {});
|
|
|
|
|
|
},
|
|
}; |