4605 lines
94 KiB
JavaScript
4605 lines
94 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Farms = db.farms;
|
|
|
|
const FarmHouses = db.farm_houses;
|
|
|
|
const Flocks = db.flocks;
|
|
|
|
const FeedCategories = db.feed_categories;
|
|
|
|
const FeedTypes = db.feed_types;
|
|
|
|
const FeedStocks = db.feed_stocks;
|
|
|
|
const FeedReceipts = db.feed_receipts;
|
|
|
|
const FeedConsumptions = db.feed_consumptions;
|
|
|
|
const MortalityRecords = db.mortality_records;
|
|
|
|
const EggProductionRecords = db.egg_production_records;
|
|
|
|
const Positions = db.positions;
|
|
|
|
const Employees = db.employees;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const FarmsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "Green Acres Broiler Breeders",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "Brgy San Isidro, Tarlac City, Tarlac, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+63 917 555 0110",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "info@greenacresbreeders.com",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "Riverbend Poultry Farm",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "Brgy Mabini, San Fernando, Pampanga, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+63 918 222 0144",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "contact@riverbendpoultry.ph",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"farm_name": "Highland Hatchery Partners Farm",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"farm_address": "Brgy Poblacion, Malaybalay City, Bukidnon, Philippines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+63 905 777 0303",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "hello@highlandhatchery.ph",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FarmHousesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "H1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_name": "House 1 North",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity_male": 1200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity_female": 10800,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "H2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_name": "House 2 East",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity_male": 1200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity_female": 10800,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_number": "A1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"house_name": "Alpha House 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity_male": 1000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity_female": 9000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FlocksData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "GA-2025-01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "Ross 308 Parent Stock",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-10-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population_male": 1050,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population_female": 9800,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population_male": 1018,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population_female": 9635,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 98.4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 1.6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-03-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Active production cycle monitored weekly",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "GA-2025-02",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "Cobb 500 Parent Stock",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-11-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population_male": 1020,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population_female": 9600,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population_male": 995,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population_female": 9442,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 98.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 2.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-03-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Uniformity within target range",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"flock_code": "RB-2025-07",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"breed": "Ross 308 Parent Stock",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loading_date": new Date('2025-09-20T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population_male": 980,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_population_female": 9050,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population_male": 962,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_population_female": 8930,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"livability_percent": 98.6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"depletion_rate_percent": 1.4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_closed": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-03-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Vaccination schedule complete",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedCategoriesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Breeder Mash",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Mash feeds for breeder stages",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Breeder Pellet",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Pellet feeds for breeder stages",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category_name": "Developer Feed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Feeds for growing breeder birds",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedTypesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_type_name": "Breeder Mash 1 Prelay",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_type_name": "Breeder Pellet 2 Peak",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"feed_type_name": "Developer Crumble 16 Protein",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bag_weight_kg": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedStocksData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 25000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"current_stock_kg": 18450,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 18450,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"as_of_date": new Date('2026-02-28T00:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 18000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"current_stock_kg": 12900,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 12900,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"as_of_date": new Date('2026-02-28T00:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"beginning_inventory_kg": 16000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"current_stock_kg": 11250,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ending_inventory_kg": 11250,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"as_of_date": new Date('2026-02-28T00:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeedReceiptsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-02-20T02:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 5000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_count": 100,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"supplier_name": "AgriFeeds Trading",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_no": "GRN-2026-0220-001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Delivered on time, sealed bags",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-02-18T03:35:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 3000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_count": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"supplier_name": "Poultry Supply Co",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_no": "GRN-2026-0218-003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Count verified by warehouse",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-02-15T01:25:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 4000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bags_count": 80,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"supplier_name": "Northern Feeds Inc",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_no": "GRN-2026-0215-009",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Batch code recorded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 980,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Normal allocation per schedule",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 945,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Slight increase due to temperature drop",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"consumed_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity_kg": 820,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "No issues noted",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const MortalityRecordsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"recorded_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Removed one weak hen, disposed properly",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"recorded_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Routine daily check",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"recorded_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_male": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"mortality_female": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spot_cull_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"spent_cull_female": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_male": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"missex_female": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_mortality": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "One spent hen culled after assessment",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EggProductionRecordsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"collected_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 7200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 120,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 45,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 30,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 18,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 55,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 12,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 7500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Collection completed by 10 AM",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"collected_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 6950,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 110,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 40,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 26,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 24,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 7240,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Slight increase in broken eggs, monitored",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"collected_on": new Date('2026-02-27T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hatching_eggs": 6400,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_small": 95,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_thin_shell": 35,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_misshape": 22,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_double_yolk": 14,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_broken": 48,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_spoiled": 9,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"nonhatching_others": 17,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"total_egg_production": 6640,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"remarks": "Normal production rate",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const PositionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position_name": "Farm Veterinarian",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Oversees flock health and biosecurity",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position_name": "Farm Supervisor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Supervises daily operations and staff",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"position_name": "Warehouse Clerk",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Manages feed inventory and receiving",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EmployeesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_no": "GA-EMP-0001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Ramon Villanueva",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1989-06-14T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Tarlac City, Tarlac",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "+63 917 301 2233",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "ramon.villanueva@greenacresbreeders.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2018-04-10T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('2026-12-31T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_years": 7.9,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "terminated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Reliable shift lead and safety oriented",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_no": "GA-EMP-0002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Leah Mendoza",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1994-09-02T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Capas, Tarlac",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "+63 905 440 1102",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "leah.mendoza@greenacresbreeders.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2021-01-18T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('2026-12-31T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_years": 5.1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "terminated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Coordinates health checks and audit logs",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employee_no": "RB-EMP-0104",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"full_name": "Harold Tan",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"birthday": new Date('1990-12-21T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "San Fernando, Pampanga",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_number": "+63 918 600 7744",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "harold.tan@riverbendpoultry.ph",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"date_hired": new Date('2019-08-05T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resignation_date": new Date('2024-11-30T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tenure_years": 5.3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"employment_status": "terminated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Completed proper turnover of warehouse records",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFarmHousWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FarmHous0 = await FarmHouses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FarmHous0?.setFarm)
|
|
{
|
|
await
|
|
FarmHous0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FarmHous1 = await FarmHouses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FarmHous1?.setFarm)
|
|
{
|
|
await
|
|
FarmHous1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FarmHous2 = await FarmHouses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FarmHous2?.setFarm)
|
|
{
|
|
await
|
|
FarmHous2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFlockWithHouse() {
|
|
|
|
const relatedHouse0 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const Flock0 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Flock0?.setHouse)
|
|
{
|
|
await
|
|
Flock0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const Flock1 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Flock1?.setHouse)
|
|
{
|
|
await
|
|
Flock1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const Flock2 = await Flocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Flock2?.setHouse)
|
|
{
|
|
await
|
|
Flock2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedStockWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedStock0 = await FeedStocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedStock0?.setFarm)
|
|
{
|
|
await
|
|
FeedStock0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedStock1 = await FeedStocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedStock1?.setFarm)
|
|
{
|
|
await
|
|
FeedStock1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const FeedStock2 = await FeedStocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedStock2?.setFarm)
|
|
{
|
|
await
|
|
FeedStock2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedStockWithFeed_type() {
|
|
|
|
const relatedFeed_type0 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedStock0 = await FeedStocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedStock0?.setFeed_type)
|
|
{
|
|
await
|
|
FeedStock0.
|
|
setFeed_type(relatedFeed_type0);
|
|
}
|
|
|
|
const relatedFeed_type1 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedStock1 = await FeedStocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedStock1?.setFeed_type)
|
|
{
|
|
await
|
|
FeedStock1.
|
|
setFeed_type(relatedFeed_type1);
|
|
}
|
|
|
|
const relatedFeed_type2 = await FeedTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await FeedTypes.count())),
|
|
});
|
|
const FeedStock2 = await FeedStocks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedStock2?.setFeed_type)
|
|
{
|
|
await
|
|
FeedStock2.
|
|
setFeed_type(relatedFeed_type2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithHouse() {
|
|
|
|
const relatedHouse0 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setHouse)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeedConsumptionWithReported_by() {
|
|
|
|
const relatedReported_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption0 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeedConsumption0?.setReported_by)
|
|
{
|
|
await
|
|
FeedConsumption0.
|
|
setReported_by(relatedReported_by0);
|
|
}
|
|
|
|
const relatedReported_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption1 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeedConsumption1?.setReported_by)
|
|
{
|
|
await
|
|
FeedConsumption1.
|
|
setReported_by(relatedReported_by1);
|
|
}
|
|
|
|
const relatedReported_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeedConsumption2 = await FeedConsumptions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeedConsumption2?.setReported_by)
|
|
{
|
|
await
|
|
FeedConsumption2.
|
|
setReported_by(relatedReported_by2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateMortalityRecordWithHouse() {
|
|
|
|
const relatedHouse0 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const MortalityRecord0 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (MortalityRecord0?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const MortalityRecord1 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (MortalityRecord1?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const MortalityRecord2 = await MortalityRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (MortalityRecord2?.setHouse)
|
|
{
|
|
await
|
|
MortalityRecord2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateEggProductionRecordWithHouse() {
|
|
|
|
const relatedHouse0 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const EggProductionRecord0 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EggProductionRecord0?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord0.
|
|
setHouse(relatedHouse0);
|
|
}
|
|
|
|
const relatedHouse1 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const EggProductionRecord1 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EggProductionRecord1?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord1.
|
|
setHouse(relatedHouse1);
|
|
}
|
|
|
|
const relatedHouse2 = await FarmHouses.findOne({
|
|
offset: Math.floor(Math.random() * (await FarmHouses.count())),
|
|
});
|
|
const EggProductionRecord2 = await EggProductionRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EggProductionRecord2?.setHouse)
|
|
{
|
|
await
|
|
EggProductionRecord2.
|
|
setHouse(relatedHouse2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associatePositionWithFarm() {
|
|
|
|
const relatedFarm0 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Position0 = await Positions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Position0?.setFarm)
|
|
{
|
|
await
|
|
Position0.
|
|
setFarm(relatedFarm0);
|
|
}
|
|
|
|
const relatedFarm1 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Position1 = await Positions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Position1?.setFarm)
|
|
{
|
|
await
|
|
Position1.
|
|
setFarm(relatedFarm1);
|
|
}
|
|
|
|
const relatedFarm2 = await Farms.findOne({
|
|
offset: Math.floor(Math.random() * (await Farms.count())),
|
|
});
|
|
const Position2 = await Positions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Position2?.setFarm)
|
|
{
|
|
await
|
|
Position2.
|
|
setFarm(relatedFarm2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEmployeeWithPosition() {
|
|
|
|
const relatedPosition0 = await Positions.findOne({
|
|
offset: Math.floor(Math.random() * (await Positions.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Employee0?.setPosition)
|
|
{
|
|
await
|
|
Employee0.
|
|
setPosition(relatedPosition0);
|
|
}
|
|
|
|
const relatedPosition1 = await Positions.findOne({
|
|
offset: Math.floor(Math.random() * (await Positions.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Employee1?.setPosition)
|
|
{
|
|
await
|
|
Employee1.
|
|
setPosition(relatedPosition1);
|
|
}
|
|
|
|
const relatedPosition2 = await Positions.findOne({
|
|
offset: Math.floor(Math.random() * (await Positions.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Employee2?.setPosition)
|
|
{
|
|
await
|
|
Employee2.
|
|
setPosition(relatedPosition2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Farms.bulkCreate(FarmsData);
|
|
|
|
|
|
|
|
|
|
await FarmHouses.bulkCreate(FarmHousesData);
|
|
|
|
|
|
|
|
|
|
await Flocks.bulkCreate(FlocksData);
|
|
|
|
|
|
|
|
|
|
await FeedCategories.bulkCreate(FeedCategoriesData);
|
|
|
|
|
|
|
|
|
|
await FeedTypes.bulkCreate(FeedTypesData);
|
|
|
|
|
|
|
|
|
|
await FeedStocks.bulkCreate(FeedStocksData);
|
|
|
|
|
|
|
|
|
|
await FeedReceipts.bulkCreate(FeedReceiptsData);
|
|
|
|
|
|
|
|
|
|
await FeedConsumptions.bulkCreate(FeedConsumptionsData);
|
|
|
|
|
|
|
|
|
|
await MortalityRecords.bulkCreate(MortalityRecordsData);
|
|
|
|
|
|
|
|
|
|
await EggProductionRecords.bulkCreate(EggProductionRecordsData);
|
|
|
|
|
|
|
|
|
|
await Positions.bulkCreate(PositionsData);
|
|
|
|
|
|
|
|
|
|
await Employees.bulkCreate(EmployeesData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFarmHousWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFlockWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFlockWithHouse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedCategoryWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedTypeWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedTypeWithCategory(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedStockWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedStockWithFeed_type(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedReceiptWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedReceiptWithFeed_type(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedReceiptWithReceived_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithHouse(),
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithFlock(),
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithFeed_type(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeedConsumptionWithReported_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithHouse(),
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithFlock(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMortalityRecordWithReported_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithFarm(),
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithHouse(),
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithFlock(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEggProductionRecordWithReported_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associatePositionWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEmployeeWithFarm(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEmployeeWithPosition(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('farms', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('farm_houses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('flocks', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_categories', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_types', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feed_stocks', 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('positions', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('employees', null, {});
|
|
|
|
|
|
},
|
|
}; |