5698 lines
119 KiB
JavaScript
5698 lines
119 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const RolePermissions = db.role_permissions;
|
|
|
|
const Farms = db.farms;
|
|
|
|
const Houses = db.houses;
|
|
|
|
const Flocks = db.flocks;
|
|
|
|
const FeedCategories = db.feed_categories;
|
|
|
|
const FeedTypes = db.feed_types;
|
|
|
|
const FeedInventoryPeriods = db.feed_inventory_periods;
|
|
|
|
const FeedReceipts = db.feed_receipts;
|
|
|
|
const FeedConsumptions = db.feed_consumptions;
|
|
|
|
const MortalityRecords = db.mortality_records;
|
|
|
|
const EggProductionRecords = db.egg_production_records;
|
|
|
|
const Employees = db.employees;
|
|
|
|
const AppSettings = db.app_settings;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const RolePermissionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"allowed": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"allowed": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"allowed": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"allowed": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FarmsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "GreenPasture Poultry Farm",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "Brgy San Isidro, San Jose, Nueva Ecija, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "Riverbend Layers Cooperative",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "Barangay Maligaya, Tarlac City, Tarlac, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "Sunfield Hatchery and Farm",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "San Rafael, Bulacan, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "Highland Brood Farms",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "Lipa City, Batangas, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const HousesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "House 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Main laying house, 3-tier cages",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "House 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Laying house near feed storage",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "House 3",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Grower house, controlled ventilation",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "House 4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Breeder house, restricted access",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FlocksData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "GPF-LAY-2025-09-A",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population": 8200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-09-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sex": "male",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "ISA Brown",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"age_weeks": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population": 8085,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 98.6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 1.4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "GPF-LAY-2025-08-B",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population": 7900,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-08-20T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sex": "female",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "Hy-Line Brown",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"age_weeks": 24,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population": 7755,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 98.2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 1.8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "RB-LAY-2025-10-A",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population": 9000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-10-05T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sex": "female",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "Lohmann Brown",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"age_weeks": 17,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population": 8940,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 99.3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 0.7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "SF-BRD-2025-07-A",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population": 4200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-07-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sex": "female",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "Cobb 500 Breeder",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"age_weeks": 31,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population": 4072,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 97.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 3.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedCategoriesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Starter",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Feed for chicks and early growth stage",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Grower",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Feed for pullets during growth stage",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Layer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Feed formulated for egg-laying hens",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Breeder",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Feed formulated for breeder flocks",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedTypesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_name": "Layer Crumble 16 Percent",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_name": "Layer Mash Premium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_name": "Grower Pellet",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_name": "Breeder Pellet 18 Percent",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedInventoryPeriodsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_start": new Date('2026-02-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_end": new Date('2026-02-07T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 12500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"incoming_total_kg": 5000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_total_kg": 6200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 11300,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_start": new Date('2026-01-25T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_end": new Date('2026-01-31T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 13800,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"incoming_total_kg": 2500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_total_kg": 3800,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 12500,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_start": new Date('2026-02-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_end": new Date('2026-02-07T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 8200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"incoming_total_kg": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_total_kg": 2100,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 6100,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_start": new Date('2026-02-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"period_end": new Date('2026-02-07T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 5600,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"incoming_total_kg": 2500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_total_kg": 1900,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 6200,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedReceiptsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-02-02T03:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_received": 80,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 4000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_number": "DR-2026-0202-001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Layer feed delivery from supplier",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-02-03T01:40:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_received": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 1000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_number": "DR-2026-0203-004",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Grower pellet replenishment",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-01-28T06:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_received": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 2500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_number": "DR-2026-0128-002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Layer mash premium delivery",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-02-05T02:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_received": 30,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 1500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_number": "DR-2026-0205-003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Breeder pellet delivery",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedConsumptionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumption_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 920,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Morning and afternoon feeding",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumption_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 880,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Standard ration per flock plan",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumption_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 310,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Grower ration adjusted for temperature",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumption_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 270,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Breeder feed issued, restricted allotment",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const MortalityRecordsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Two birds culled due to leg issues",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "One spent hen removed; routine cleanup",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Observed mild respiratory signs; monitored",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Two spent hens removed after inspection",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EggProductionRecordsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 120,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 35,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 18,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 9,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 22,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 5240,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"exported_to_excel": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Peak production; thin shells slightly elevated",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 98,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 28,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 14,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 19,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 4980,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"exported_to_excel": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Normal trend; monitor broken eggs during collection",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 860,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 22,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 8,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 1120,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"exported_to_excel": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Breeder eggs packed for hatchery transfer",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"record_date": new Date('2026-02-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 140,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 40,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 11,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 26,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 4725,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"exported_to_excel": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Slight dip due to heat; ventilation adjusted",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EmployeesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_number": "EMP-2024-0107",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Janelle Aquino",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1994-05-18T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "San Jose, Nueva Ecija, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "09171234567",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "janelle.aquino@greenpasture.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2024-01-07T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_months": 25,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position": "Farm Supervisor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('1970-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "active",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_number": "EMP-2023-0901",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Ronald Villanueva",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1988-11-02T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Tarlac City, Tarlac, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "09182345678",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "ronald.villanueva@riverbend.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2023-09-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_months": 29,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position": "Inventory Clerk",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('1970-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "active",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_number": "EMP-2022-0606",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Marites Bautista",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1990-02-14T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Bulacan, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "09201234567",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "marites.bautista@sunfield.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2022-06-06T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_months": 44,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position": "HR and Admin Staff",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('1970-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "active",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_number": "EMP-2021-0315",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Dennis Cruz",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1985-07-09T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Lipa City, Batangas, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "09214567890",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "dennis.cruz@highland.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2021-03-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_months": 59,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position": "Operations Manager",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('1970-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "active",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AppSettingsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_key": "brand_primary_color",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_value": "pastel green",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Primary brand color used across the application",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_key": "feed_default_bag_weight_kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_value": "50",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Default bag weight for feed receipts when not specified",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_key": "timezone",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_value": "Asia Manila",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Default timezone for date and time entries",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_key": "egg_export_format",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"setting_value": "xlsx",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Default export format for egg production records",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateRolePermissionWithPermission() {
|
|
|
|
const relatedPermission0 = await Permissions.findOne({
|
|
offset: Math.floor(Math.random() * (await Permissions.count())),
|
|
});
|
|
const RolePermission0 = await RolePermissions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (RolePermission0?.setPermission)
|
|
{
|
|
await
|
|
RolePermission0.
|
|
setPermission(relatedPermission0);
|
|
}
|
|
|
|
const relatedPermission1 = await Permissions.findOne({
|
|
offset: Math.floor(Math.random() * (await Permissions.count())),
|
|
});
|
|
const RolePermission1 = await RolePermissions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (RolePermission1?.setPermission)
|
|
{
|
|
await
|
|
RolePermission1.
|
|
setPermission(relatedPermission1);
|
|
}
|
|
|
|
const relatedPermission2 = await Permissions.findOne({
|
|
offset: Math.floor(Math.random() * (await Permissions.count())),
|
|
});
|
|
const RolePermission2 = await RolePermissions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (RolePermission2?.setPermission)
|
|
{
|
|
await
|
|
RolePermission2.
|
|
setPermission(relatedPermission2);
|
|
}
|
|
|
|
const relatedPermission3 = await Permissions.findOne({
|
|
offset: Math.floor(Math.random() * (await Permissions.count())),
|
|
});
|
|
const RolePermission3 = await RolePermissions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (RolePermission3?.setPermission)
|
|
{
|
|
await
|
|
RolePermission3.
|
|
setPermission(relatedPermission3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateHousWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Hous0 = await Houses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Hous0?.setFarm)
|
|
{
|
|
await
|
|
Hous0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Hous1 = await Houses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Hous1?.setFarm)
|
|
{
|
|
await
|
|
Hous1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Hous2 = await Houses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Hous2?.setFarm)
|
|
{
|
|
await
|
|
Hous2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Hous3 = await Houses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Hous3?.setFarm)
|
|
{
|
|
await
|
|
Hous3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFlockWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Flock0 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Flock0?.setFarm)
|
|
{
|
|
await
|
|
Flock0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Flock1 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Flock1?.setFarm)
|
|
{
|
|
await
|
|
Flock1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Flock2 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Flock2?.setFarm)
|
|
{
|
|
await
|
|
Flock2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Flock3 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Flock3?.setFarm)
|
|
{
|
|
await
|
|
Flock3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFlockWithHouse() {
|
|
|
|
const relatedHouse0 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const Flock0 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Flock0?.setHouse)
|
|
{
|
|
await
|
|
Flock0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const Flock1 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Flock1?.setHouse)
|
|
{
|
|
await
|
|
Flock1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const Flock2 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Flock2?.setHouse)
|
|
{
|
|
await
|
|
Flock2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
const relatedHouse3 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const Flock3 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Flock3?.setHouse)
|
|
{
|
|
await
|
|
Flock3.
|
|
setHouse(relatedHouse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedCategoryWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedCategory0 = await FeedCategories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedCategory0?.setFarm)
|
|
{
|
|
await
|
|
FeedCategory0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedCategory1 = await FeedCategories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedCategory1?.setFarm)
|
|
{
|
|
await
|
|
FeedCategory1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedCategory2 = await FeedCategories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedCategory2?.setFarm)
|
|
{
|
|
await
|
|
FeedCategory2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedCategory3 = await FeedCategories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedCategory3?.setFarm)
|
|
{
|
|
await
|
|
FeedCategory3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedTypeWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedType0 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedType0?.setFarm)
|
|
{
|
|
await
|
|
FeedType0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedType1 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedType1?.setFarm)
|
|
{
|
|
await
|
|
FeedType1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedType2 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedType2?.setFarm)
|
|
{
|
|
await
|
|
FeedType2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedType3 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedType3?.setFarm)
|
|
{
|
|
await
|
|
FeedType3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedTypeWithCategory() {
|
|
|
|
const relatedCategory0 = await FeedCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedCategories.count())),
|
|
});
|
|
const FeedType0 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedType0?.setCategory)
|
|
{
|
|
await
|
|
FeedType0.
|
|
setCategory(relatedCategory0);
|
|
}
|
|
|
|
const relatedCategory1 = await FeedCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedCategories.count())),
|
|
});
|
|
const FeedType1 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedType1?.setCategory)
|
|
{
|
|
await
|
|
FeedType1.
|
|
setCategory(relatedCategory1);
|
|
}
|
|
|
|
const relatedCategory2 = await FeedCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedCategories.count())),
|
|
});
|
|
const FeedType2 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedType2?.setCategory)
|
|
{
|
|
await
|
|
FeedType2.
|
|
setCategory(relatedCategory2);
|
|
}
|
|
|
|
const relatedCategory3 = await FeedCategories.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedCategories.count())),
|
|
});
|
|
const FeedType3 = await FeedTypes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedType3?.setCategory)
|
|
{
|
|
await
|
|
FeedType3.
|
|
setCategory(relatedCategory3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedInventoryPeriodWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedInventoryPeriod0 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedInventoryPeriod0?.setFarm)
|
|
{
|
|
await
|
|
FeedInventoryPeriod0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedInventoryPeriod1 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedInventoryPeriod1?.setFarm)
|
|
{
|
|
await
|
|
FeedInventoryPeriod1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedInventoryPeriod2 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedInventoryPeriod2?.setFarm)
|
|
{
|
|
await
|
|
FeedInventoryPeriod2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedInventoryPeriod3 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedInventoryPeriod3?.setFarm)
|
|
{
|
|
await
|
|
FeedInventoryPeriod3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedInventoryPeriodWithFeed_type() {
|
|
|
|
const relatedFeed_type0 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedInventoryPeriod0 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedInventoryPeriod0?.setFeed_type)
|
|
{
|
|
await
|
|
FeedInventoryPeriod0.
|
|
setFeed_type(relatedFeed_type0);
|
|
}
|
|
|
|
const relatedFeed_type1 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedInventoryPeriod1 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedInventoryPeriod1?.setFeed_type)
|
|
{
|
|
await
|
|
FeedInventoryPeriod1.
|
|
setFeed_type(relatedFeed_type1);
|
|
}
|
|
|
|
const relatedFeed_type2 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedInventoryPeriod2 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedInventoryPeriod2?.setFeed_type)
|
|
{
|
|
await
|
|
FeedInventoryPeriod2.
|
|
setFeed_type(relatedFeed_type2);
|
|
}
|
|
|
|
const relatedFeed_type3 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedInventoryPeriod3 = await FeedInventoryPeriods.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedInventoryPeriod3?.setFeed_type)
|
|
{
|
|
await
|
|
FeedInventoryPeriod3.
|
|
setFeed_type(relatedFeed_type3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedReceiptWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedReceipt0 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedReceipt0?.setFarm)
|
|
{
|
|
await
|
|
FeedReceipt0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedReceipt1 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedReceipt1?.setFarm)
|
|
{
|
|
await
|
|
FeedReceipt1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedReceipt2 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedReceipt2?.setFarm)
|
|
{
|
|
await
|
|
FeedReceipt2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedReceipt3 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedReceipt3?.setFarm)
|
|
{
|
|
await
|
|
FeedReceipt3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedReceiptWithFeed_type() {
|
|
|
|
const relatedFeed_type0 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedReceipt0 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedReceipt0?.setFeed_type)
|
|
{
|
|
await
|
|
FeedReceipt0.
|
|
setFeed_type(relatedFeed_type0);
|
|
}
|
|
|
|
const relatedFeed_type1 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedReceipt1 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedReceipt1?.setFeed_type)
|
|
{
|
|
await
|
|
FeedReceipt1.
|
|
setFeed_type(relatedFeed_type1);
|
|
}
|
|
|
|
const relatedFeed_type2 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedReceipt2 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedReceipt2?.setFeed_type)
|
|
{
|
|
await
|
|
FeedReceipt2.
|
|
setFeed_type(relatedFeed_type2);
|
|
}
|
|
|
|
const relatedFeed_type3 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedReceipt3 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedReceipt3?.setFeed_type)
|
|
{
|
|
await
|
|
FeedReceipt3.
|
|
setFeed_type(relatedFeed_type3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedReceiptWithReceived_by() {
|
|
|
|
const relatedReceived_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedReceipt0 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedReceipt0?.setReceived_by)
|
|
{
|
|
await
|
|
FeedReceipt0.
|
|
setReceived_by(relatedReceived_by0);
|
|
}
|
|
|
|
const relatedReceived_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedReceipt1 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedReceipt1?.setReceived_by)
|
|
{
|
|
await
|
|
FeedReceipt1.
|
|
setReceived_by(relatedReceived_by1);
|
|
}
|
|
|
|
const relatedReceived_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedReceipt2 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedReceipt2?.setReceived_by)
|
|
{
|
|
await
|
|
FeedReceipt2.
|
|
setReceived_by(relatedReceived_by2);
|
|
}
|
|
|
|
const relatedReceived_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedReceipt3 = await FeedReceipts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedReceipt3?.setReceived_by)
|
|
{
|
|
await
|
|
FeedReceipt3.
|
|
setReceived_by(relatedReceived_by3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setFarm)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setFarm)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setFarm)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedConsumption3 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedConsumption3?.setFarm)
|
|
{
|
|
await
|
|
FeedConsumption3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithHouse() {
|
|
|
|
const relatedHouse0 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
const relatedHouse3 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const FeedConsumption3 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedConsumption3?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption3.
|
|
setHouse(relatedHouse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithFlock() {
|
|
|
|
const relatedFlock0 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setFlock)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setFlock(relatedFlock0);
|
|
}
|
|
|
|
const relatedFlock1 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setFlock)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setFlock(relatedFlock1);
|
|
}
|
|
|
|
const relatedFlock2 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setFlock)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setFlock(relatedFlock2);
|
|
}
|
|
|
|
const relatedFlock3 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const FeedConsumption3 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedConsumption3?.setFlock)
|
|
{
|
|
await
|
|
FeedConsumption3.
|
|
setFlock(relatedFlock3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithFeed_type() {
|
|
|
|
const relatedFeed_type0 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setFeed_type)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setFeed_type(relatedFeed_type0);
|
|
}
|
|
|
|
const relatedFeed_type1 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setFeed_type)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setFeed_type(relatedFeed_type1);
|
|
}
|
|
|
|
const relatedFeed_type2 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setFeed_type)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setFeed_type(relatedFeed_type2);
|
|
}
|
|
|
|
const relatedFeed_type3 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedConsumption3 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedConsumption3?.setFeed_type)
|
|
{
|
|
await
|
|
FeedConsumption3.
|
|
setFeed_type(relatedFeed_type3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithRecorded_by() {
|
|
|
|
const relatedRecorded_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setRecorded_by)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setRecorded_by(relatedRecorded_by0);
|
|
}
|
|
|
|
const relatedRecorded_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setRecorded_by)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setRecorded_by(relatedRecorded_by1);
|
|
}
|
|
|
|
const relatedRecorded_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setRecorded_by)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setRecorded_by(relatedRecorded_by2);
|
|
}
|
|
|
|
const relatedRecorded_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption3 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeedConsumption3?.setRecorded_by)
|
|
{
|
|
await
|
|
FeedConsumption3.
|
|
setRecorded_by(relatedRecorded_by3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMortalityRecordWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const MortalityRecord0 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (MortalityRecord0?.setFarm)
|
|
{
|
|
await
|
|
MortalityRecord0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const MortalityRecord1 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (MortalityRecord1?.setFarm)
|
|
{
|
|
await
|
|
MortalityRecord1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const MortalityRecord2 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (MortalityRecord2?.setFarm)
|
|
{
|
|
await
|
|
MortalityRecord2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const MortalityRecord3 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (MortalityRecord3?.setFarm)
|
|
{
|
|
await
|
|
MortalityRecord3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateMortalityRecordWithHouse() {
|
|
|
|
const relatedHouse0 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const MortalityRecord0 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (MortalityRecord0?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const MortalityRecord1 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (MortalityRecord1?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const MortalityRecord2 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (MortalityRecord2?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
const relatedHouse3 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const MortalityRecord3 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (MortalityRecord3?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord3.
|
|
setHouse(relatedHouse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateMortalityRecordWithFlock() {
|
|
|
|
const relatedFlock0 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const MortalityRecord0 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (MortalityRecord0?.setFlock)
|
|
{
|
|
await
|
|
MortalityRecord0.
|
|
setFlock(relatedFlock0);
|
|
}
|
|
|
|
const relatedFlock1 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const MortalityRecord1 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (MortalityRecord1?.setFlock)
|
|
{
|
|
await
|
|
MortalityRecord1.
|
|
setFlock(relatedFlock1);
|
|
}
|
|
|
|
const relatedFlock2 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const MortalityRecord2 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (MortalityRecord2?.setFlock)
|
|
{
|
|
await
|
|
MortalityRecord2.
|
|
setFlock(relatedFlock2);
|
|
}
|
|
|
|
const relatedFlock3 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const MortalityRecord3 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (MortalityRecord3?.setFlock)
|
|
{
|
|
await
|
|
MortalityRecord3.
|
|
setFlock(relatedFlock3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMortalityRecordWithReported_by() {
|
|
|
|
const relatedReported_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const MortalityRecord0 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (MortalityRecord0?.setReported_by)
|
|
{
|
|
await
|
|
MortalityRecord0.
|
|
setReported_by(relatedReported_by0);
|
|
}
|
|
|
|
const relatedReported_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const MortalityRecord1 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (MortalityRecord1?.setReported_by)
|
|
{
|
|
await
|
|
MortalityRecord1.
|
|
setReported_by(relatedReported_by1);
|
|
}
|
|
|
|
const relatedReported_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const MortalityRecord2 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (MortalityRecord2?.setReported_by)
|
|
{
|
|
await
|
|
MortalityRecord2.
|
|
setReported_by(relatedReported_by2);
|
|
}
|
|
|
|
const relatedReported_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const MortalityRecord3 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (MortalityRecord3?.setReported_by)
|
|
{
|
|
await
|
|
MortalityRecord3.
|
|
setReported_by(relatedReported_by3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEggProductionRecordWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const EggProductionRecord0 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EggProductionRecord0?.setFarm)
|
|
{
|
|
await
|
|
EggProductionRecord0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const EggProductionRecord1 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EggProductionRecord1?.setFarm)
|
|
{
|
|
await
|
|
EggProductionRecord1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const EggProductionRecord2 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EggProductionRecord2?.setFarm)
|
|
{
|
|
await
|
|
EggProductionRecord2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const EggProductionRecord3 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EggProductionRecord3?.setFarm)
|
|
{
|
|
await
|
|
EggProductionRecord3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateEggProductionRecordWithHouse() {
|
|
|
|
const relatedHouse0 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const EggProductionRecord0 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EggProductionRecord0?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const EggProductionRecord1 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EggProductionRecord1?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const EggProductionRecord2 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EggProductionRecord2?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
const relatedHouse3 = await Houses.findOne({
|
|
offset: Math.floor(Math.random() * (await Houses.count())),
|
|
});
|
|
const EggProductionRecord3 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EggProductionRecord3?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord3.
|
|
setHouse(relatedHouse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateEggProductionRecordWithFlock() {
|
|
|
|
const relatedFlock0 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const EggProductionRecord0 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EggProductionRecord0?.setFlock)
|
|
{
|
|
await
|
|
EggProductionRecord0.
|
|
setFlock(relatedFlock0);
|
|
}
|
|
|
|
const relatedFlock1 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const EggProductionRecord1 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EggProductionRecord1?.setFlock)
|
|
{
|
|
await
|
|
EggProductionRecord1.
|
|
setFlock(relatedFlock1);
|
|
}
|
|
|
|
const relatedFlock2 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const EggProductionRecord2 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EggProductionRecord2?.setFlock)
|
|
{
|
|
await
|
|
EggProductionRecord2.
|
|
setFlock(relatedFlock2);
|
|
}
|
|
|
|
const relatedFlock3 = await Flocks.findOne({
|
|
offset: Math.floor(Math.random() * (await Flocks.count())),
|
|
});
|
|
const EggProductionRecord3 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EggProductionRecord3?.setFlock)
|
|
{
|
|
await
|
|
EggProductionRecord3.
|
|
setFlock(relatedFlock3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEggProductionRecordWithReported_by() {
|
|
|
|
const relatedReported_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EggProductionRecord0 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EggProductionRecord0?.setReported_by)
|
|
{
|
|
await
|
|
EggProductionRecord0.
|
|
setReported_by(relatedReported_by0);
|
|
}
|
|
|
|
const relatedReported_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EggProductionRecord1 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EggProductionRecord1?.setReported_by)
|
|
{
|
|
await
|
|
EggProductionRecord1.
|
|
setReported_by(relatedReported_by1);
|
|
}
|
|
|
|
const relatedReported_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EggProductionRecord2 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EggProductionRecord2?.setReported_by)
|
|
{
|
|
await
|
|
EggProductionRecord2.
|
|
setReported_by(relatedReported_by2);
|
|
}
|
|
|
|
const relatedReported_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EggProductionRecord3 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EggProductionRecord3?.setReported_by)
|
|
{
|
|
await
|
|
EggProductionRecord3.
|
|
setReported_by(relatedReported_by3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEmployeeWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Employee0?.setFarm)
|
|
{
|
|
await
|
|
Employee0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Employee1?.setFarm)
|
|
{
|
|
await
|
|
Employee1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Employee2?.setFarm)
|
|
{
|
|
await
|
|
Employee2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Employee3?.setFarm)
|
|
{
|
|
await
|
|
Employee3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAppSettingWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const AppSetting0 = await AppSettings.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (AppSetting0?.setFarm)
|
|
{
|
|
await
|
|
AppSetting0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const AppSetting1 = await AppSettings.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (AppSetting1?.setFarm)
|
|
{
|
|
await
|
|
AppSetting1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const AppSetting2 = await AppSettings.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (AppSetting2?.setFarm)
|
|
{
|
|
await
|
|
AppSetting2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
const relatedFarm3 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const AppSetting3 = await AppSettings.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (AppSetting3?.setFarm)
|
|
{
|
|
await
|
|
AppSetting3.
|
|
setFarm(relatedFarm3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await RolePermissions.bulkCreate(RolePermissionsData);
|
|
|
|
|
|
|
|
|
|
await Farms.bulkCreate(FarmsData);
|
|
|
|
|
|
|
|
|
|
await Houses.bulkCreate(HousesData);
|
|
|
|
|
|
|
|
|
|
await Flocks.bulkCreate(FlocksData);
|
|
|
|
|
|
|
|
|
|
await FeedCategories.bulkCreate(FeedCategoriesData);
|
|
|
|
|
|
|
|
|
|
await FeedTypes.bulkCreate(FeedTypesData);
|
|
|
|
|
|
|
|
|
|
await FeedInventoryPeriods.bulkCreate(FeedInventoryPeriodsData);
|
|
|
|
|
|
|
|
|
|
await FeedReceipts.bulkCreate(FeedReceiptsData);
|
|
|
|
|
|
|
|
|
|
await FeedConsumptions.bulkCreate(FeedConsumptionsData);
|
|
|
|
|
|
|
|
|
|
await MortalityRecords.bulkCreate(MortalityRecordsData);
|
|
|
|
|
|
|
|
|
|
await EggProductionRecords.bulkCreate(EggProductionRecordsData);
|
|
|
|
|
|
|
|
|
|
await Employees.bulkCreate(EmployeesData);
|
|
|
|
|
|
|
|
|
|
await AppSettings.bulkCreate(AppSettingsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateRolePermissionWithPermission(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateHousWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFlockWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFlockWithHouse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedCategoryWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedTypeWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedTypeWithCategory(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedInventoryPeriodWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedInventoryPeriodWithFeed_type(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedReceiptWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedReceiptWithFeed_type(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedReceiptWithReceived_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithHouse(),
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithFlock(),
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithFeed_type(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithRecorded_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithHouse(),
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithFlock(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithReported_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithHouse(),
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithFlock(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithReported_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEmployeeWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAppSettingWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('role_permissions', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('farms', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('houses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('flocks', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_categories', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_types', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_inventory_periods', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_receipts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_consumptions', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('mortality_records', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('egg_production_records', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('employees', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('app_settings', null, {});
|
|
|
|
|
|
},
|
|
}; |