1966 lines
47 KiB
JavaScript
1966 lines
47 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Accounts = db.accounts;
|
|
|
|
const Assets = db.assets;
|
|
|
|
const Attendances = db.attendances;
|
|
|
|
const Employees = db.employees;
|
|
|
|
const Expenses = db.expenses;
|
|
|
|
const Leaves = db.leaves;
|
|
|
|
const Payrolls = db.payrolls;
|
|
|
|
const Performances = db.performances;
|
|
|
|
const Procurements = db.procurements;
|
|
|
|
const Projects = db.projects;
|
|
|
|
const Vendors = db.vendors;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const AccountsData = [
|
|
{
|
|
account_name: 'Main Account',
|
|
|
|
balance: 100000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'Savings Account',
|
|
|
|
balance: 50000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'Expense Account',
|
|
|
|
balance: 20000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'Investment Account',
|
|
|
|
balance: 30000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
account_name: 'Payroll Account',
|
|
|
|
balance: 40000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const AssetsData = [
|
|
{
|
|
name: 'Dell Laptop',
|
|
|
|
type: 'Electronics',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Office Desk',
|
|
|
|
type: 'Furniture',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Projector',
|
|
|
|
type: 'Electronics',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Office Chair',
|
|
|
|
type: 'Furniture',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Monitor',
|
|
|
|
type: 'Electronics',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const AttendancesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-01T08:00:00Z'),
|
|
|
|
present: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-02T08:00:00Z'),
|
|
|
|
present: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-01T08:00:00Z'),
|
|
|
|
present: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-02T08:00:00Z'),
|
|
|
|
present: true,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
date: new Date('2023-10-01T08:00:00Z'),
|
|
|
|
present: false,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const EmployeesData = [
|
|
{
|
|
first_name: 'John',
|
|
|
|
last_name: 'Doe',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Jane',
|
|
|
|
last_name: 'Smith',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Alice',
|
|
|
|
last_name: 'Johnson',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Bob',
|
|
|
|
last_name: 'Brown',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
first_name: 'Charlie',
|
|
|
|
last_name: 'Davis',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ExpensesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
amount: 150.75,
|
|
|
|
description: 'Travel expenses for client meeting',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
amount: 200,
|
|
|
|
description: 'Office supplies purchase',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
amount: 50.5,
|
|
|
|
description: 'Lunch with client',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
amount: 300,
|
|
|
|
description: 'Conference registration fee',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
amount: 120,
|
|
|
|
description: 'Team building activity',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const LeavesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-10-10T00:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-15T00:00:00Z'),
|
|
|
|
status: 'Rejected',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-10-05T00:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-07T00:00:00Z'),
|
|
|
|
status: 'Approved',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-10-12T00:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-14T00:00:00Z'),
|
|
|
|
status: 'Pending',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-10-20T00:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-22T00:00:00Z'),
|
|
|
|
status: 'Pending',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
start_date: new Date('2023-10-25T00:00:00Z'),
|
|
|
|
end_date: new Date('2023-10-28T00:00:00Z'),
|
|
|
|
status: 'Pending',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PayrollsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 75000,
|
|
|
|
pay_date: new Date('2023-10-30T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 65000,
|
|
|
|
pay_date: new Date('2023-10-30T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 70000,
|
|
|
|
pay_date: new Date('2023-10-30T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 80000,
|
|
|
|
pay_date: new Date('2023-10-30T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
salary: 72000,
|
|
|
|
pay_date: new Date('2023-10-30T00:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PerformancesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
review: 'Excellent performance in Q3',
|
|
|
|
rating: 'Poor',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
review: 'Good team player',
|
|
|
|
rating: 'Average',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
review: 'Average performance, needs improvement',
|
|
|
|
rating: 'Poor',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
review: 'Outstanding leadership skills',
|
|
|
|
rating: 'Good',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
review: 'Below expectations, requires training',
|
|
|
|
rating: 'Good',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ProcurementsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
item: 'Laptops',
|
|
|
|
cost: 5000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
item: 'Office Chairs',
|
|
|
|
cost: 1500,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
item: 'Projectors',
|
|
|
|
cost: 2000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
item: 'Desks',
|
|
|
|
cost: 2500,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
item: 'Monitors',
|
|
|
|
cost: 3000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ProjectsData = [
|
|
{
|
|
name: 'Project Alpha',
|
|
|
|
location: 'New York',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Project Beta',
|
|
|
|
location: 'San Francisco',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Project Gamma',
|
|
|
|
location: 'Los Angeles',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Project Delta',
|
|
|
|
location: 'Chicago',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Project Epsilon',
|
|
|
|
location: 'Houston',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const VendorsData = [
|
|
{
|
|
name: 'Tech Supplies Inc.',
|
|
|
|
contact: 'contact@techsupplies.com',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Office Essentials',
|
|
|
|
contact: 'info@officeessentials.com',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Global Vendors',
|
|
|
|
contact: 'support@globalvendors.com',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Procure Plus',
|
|
|
|
contact: 'sales@procureplus.com',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Vendor Solutions',
|
|
|
|
contact: 'service@vendorsolutions.com',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Nicolaus Copernicus',
|
|
},
|
|
|
|
{
|
|
name: 'Charles Sherrington',
|
|
},
|
|
|
|
{
|
|
name: 'Neils Bohr',
|
|
},
|
|
|
|
{
|
|
name: 'James Watson',
|
|
},
|
|
|
|
{
|
|
name: 'Gregor Mendel',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setOrganization) {
|
|
await User0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setOrganization) {
|
|
await User1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setOrganization) {
|
|
await User2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setOrganization) {
|
|
await User3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User4 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (User4?.setOrganization) {
|
|
await User4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateAccountWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Account0 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Account0?.setOrganization) {
|
|
await Account0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Account1 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Account1?.setOrganization) {
|
|
await Account1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Account2 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Account2?.setOrganization) {
|
|
await Account2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Account3 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Account3?.setOrganization) {
|
|
await Account3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Account4 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Account4?.setOrganization) {
|
|
await Account4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateAssetWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset0 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Asset0?.setEmployee) {
|
|
await Asset0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset1 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Asset1?.setEmployee) {
|
|
await Asset1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset2 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Asset2?.setEmployee) {
|
|
await Asset2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset3 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Asset3?.setEmployee) {
|
|
await Asset3.setEmployee(relatedEmployee3);
|
|
}
|
|
|
|
const relatedEmployee4 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Asset4 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Asset4?.setEmployee) {
|
|
await Asset4.setEmployee(relatedEmployee4);
|
|
}
|
|
}
|
|
|
|
async function associateAssetWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset0 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Asset0?.setOrganization) {
|
|
await Asset0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset1 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Asset1?.setOrganization) {
|
|
await Asset1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset2 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Asset2?.setOrganization) {
|
|
await Asset2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset3 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Asset3?.setOrganization) {
|
|
await Asset3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Asset4 = await Assets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Asset4?.setOrganization) {
|
|
await Asset4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateAttendanceWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Attendance0 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Attendance0?.setEmployee) {
|
|
await Attendance0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Attendance1 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Attendance1?.setEmployee) {
|
|
await Attendance1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Attendance2 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Attendance2?.setEmployee) {
|
|
await Attendance2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Attendance3 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Attendance3?.setEmployee) {
|
|
await Attendance3.setEmployee(relatedEmployee3);
|
|
}
|
|
|
|
const relatedEmployee4 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Attendance4 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Attendance4?.setEmployee) {
|
|
await Attendance4.setEmployee(relatedEmployee4);
|
|
}
|
|
}
|
|
|
|
async function associateAttendanceWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Attendance0 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Attendance0?.setOrganization) {
|
|
await Attendance0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Attendance1 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Attendance1?.setOrganization) {
|
|
await Attendance1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Attendance2 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Attendance2?.setOrganization) {
|
|
await Attendance2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Attendance3 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Attendance3?.setOrganization) {
|
|
await Attendance3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Attendance4 = await Attendances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Attendance4?.setOrganization) {
|
|
await Attendance4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateEmployeeWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Employee0?.setUser) {
|
|
await Employee0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Employee1?.setUser) {
|
|
await Employee1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Employee2?.setUser) {
|
|
await Employee2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Employee3?.setUser) {
|
|
await Employee3.setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Employee4 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Employee4?.setUser) {
|
|
await Employee4.setUser(relatedUser4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateEmployeeWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee0 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Employee0?.setOrganization) {
|
|
await Employee0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee1 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Employee1?.setOrganization) {
|
|
await Employee1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee2 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Employee2?.setOrganization) {
|
|
await Employee2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee3 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Employee3?.setOrganization) {
|
|
await Employee3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Employee4 = await Employees.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Employee4?.setOrganization) {
|
|
await Employee4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateExpenseWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Expense0 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Expense0?.setEmployee) {
|
|
await Expense0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Expense1 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Expense1?.setEmployee) {
|
|
await Expense1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Expense2 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Expense2?.setEmployee) {
|
|
await Expense2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Expense3 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Expense3?.setEmployee) {
|
|
await Expense3.setEmployee(relatedEmployee3);
|
|
}
|
|
|
|
const relatedEmployee4 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Expense4 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Expense4?.setEmployee) {
|
|
await Expense4.setEmployee(relatedEmployee4);
|
|
}
|
|
}
|
|
|
|
async function associateExpenseWithProject() {
|
|
const relatedProject0 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Expense0 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Expense0?.setProject) {
|
|
await Expense0.setProject(relatedProject0);
|
|
}
|
|
|
|
const relatedProject1 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Expense1 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Expense1?.setProject) {
|
|
await Expense1.setProject(relatedProject1);
|
|
}
|
|
|
|
const relatedProject2 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Expense2 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Expense2?.setProject) {
|
|
await Expense2.setProject(relatedProject2);
|
|
}
|
|
|
|
const relatedProject3 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Expense3 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Expense3?.setProject) {
|
|
await Expense3.setProject(relatedProject3);
|
|
}
|
|
|
|
const relatedProject4 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Expense4 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Expense4?.setProject) {
|
|
await Expense4.setProject(relatedProject4);
|
|
}
|
|
}
|
|
|
|
async function associateExpenseWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expense0 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Expense0?.setOrganization) {
|
|
await Expense0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expense1 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Expense1?.setOrganization) {
|
|
await Expense1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expense2 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Expense2?.setOrganization) {
|
|
await Expense2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expense3 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Expense3?.setOrganization) {
|
|
await Expense3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expense4 = await Expenses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Expense4?.setOrganization) {
|
|
await Expense4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateLeafeWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Leafe0 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Leafe0?.setEmployee) {
|
|
await Leafe0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Leafe1 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Leafe1?.setEmployee) {
|
|
await Leafe1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Leafe2 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Leafe2?.setEmployee) {
|
|
await Leafe2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Leafe3 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Leafe3?.setEmployee) {
|
|
await Leafe3.setEmployee(relatedEmployee3);
|
|
}
|
|
|
|
const relatedEmployee4 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Leafe4 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Leafe4?.setEmployee) {
|
|
await Leafe4.setEmployee(relatedEmployee4);
|
|
}
|
|
}
|
|
|
|
async function associateLeafeWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Leafe0 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Leafe0?.setOrganization) {
|
|
await Leafe0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Leafe1 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Leafe1?.setOrganization) {
|
|
await Leafe1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Leafe2 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Leafe2?.setOrganization) {
|
|
await Leafe2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Leafe3 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Leafe3?.setOrganization) {
|
|
await Leafe3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Leafe4 = await Leaves.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Leafe4?.setOrganization) {
|
|
await Leafe4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associatePayrollWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Payroll0 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Payroll0?.setEmployee) {
|
|
await Payroll0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Payroll1 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Payroll1?.setEmployee) {
|
|
await Payroll1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Payroll2 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Payroll2?.setEmployee) {
|
|
await Payroll2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Payroll3 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Payroll3?.setEmployee) {
|
|
await Payroll3.setEmployee(relatedEmployee3);
|
|
}
|
|
|
|
const relatedEmployee4 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Payroll4 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Payroll4?.setEmployee) {
|
|
await Payroll4.setEmployee(relatedEmployee4);
|
|
}
|
|
}
|
|
|
|
async function associatePayrollWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Payroll0 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Payroll0?.setOrganization) {
|
|
await Payroll0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Payroll1 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Payroll1?.setOrganization) {
|
|
await Payroll1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Payroll2 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Payroll2?.setOrganization) {
|
|
await Payroll2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Payroll3 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Payroll3?.setOrganization) {
|
|
await Payroll3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Payroll4 = await Payrolls.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Payroll4?.setOrganization) {
|
|
await Payroll4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associatePerformanceWithEmployee() {
|
|
const relatedEmployee0 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Performance0 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Performance0?.setEmployee) {
|
|
await Performance0.setEmployee(relatedEmployee0);
|
|
}
|
|
|
|
const relatedEmployee1 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Performance1 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Performance1?.setEmployee) {
|
|
await Performance1.setEmployee(relatedEmployee1);
|
|
}
|
|
|
|
const relatedEmployee2 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Performance2 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Performance2?.setEmployee) {
|
|
await Performance2.setEmployee(relatedEmployee2);
|
|
}
|
|
|
|
const relatedEmployee3 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Performance3 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Performance3?.setEmployee) {
|
|
await Performance3.setEmployee(relatedEmployee3);
|
|
}
|
|
|
|
const relatedEmployee4 = await Employees.findOne({
|
|
offset: Math.floor(Math.random() * (await Employees.count())),
|
|
});
|
|
const Performance4 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Performance4?.setEmployee) {
|
|
await Performance4.setEmployee(relatedEmployee4);
|
|
}
|
|
}
|
|
|
|
async function associatePerformanceWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Performance0 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Performance0?.setOrganization) {
|
|
await Performance0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Performance1 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Performance1?.setOrganization) {
|
|
await Performance1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Performance2 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Performance2?.setOrganization) {
|
|
await Performance2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Performance3 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Performance3?.setOrganization) {
|
|
await Performance3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Performance4 = await Performances.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Performance4?.setOrganization) {
|
|
await Performance4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateProcurementWithVendor() {
|
|
const relatedVendor0 = await Vendors.findOne({
|
|
offset: Math.floor(Math.random() * (await Vendors.count())),
|
|
});
|
|
const Procurement0 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Procurement0?.setVendor) {
|
|
await Procurement0.setVendor(relatedVendor0);
|
|
}
|
|
|
|
const relatedVendor1 = await Vendors.findOne({
|
|
offset: Math.floor(Math.random() * (await Vendors.count())),
|
|
});
|
|
const Procurement1 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Procurement1?.setVendor) {
|
|
await Procurement1.setVendor(relatedVendor1);
|
|
}
|
|
|
|
const relatedVendor2 = await Vendors.findOne({
|
|
offset: Math.floor(Math.random() * (await Vendors.count())),
|
|
});
|
|
const Procurement2 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Procurement2?.setVendor) {
|
|
await Procurement2.setVendor(relatedVendor2);
|
|
}
|
|
|
|
const relatedVendor3 = await Vendors.findOne({
|
|
offset: Math.floor(Math.random() * (await Vendors.count())),
|
|
});
|
|
const Procurement3 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Procurement3?.setVendor) {
|
|
await Procurement3.setVendor(relatedVendor3);
|
|
}
|
|
|
|
const relatedVendor4 = await Vendors.findOne({
|
|
offset: Math.floor(Math.random() * (await Vendors.count())),
|
|
});
|
|
const Procurement4 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Procurement4?.setVendor) {
|
|
await Procurement4.setVendor(relatedVendor4);
|
|
}
|
|
}
|
|
|
|
async function associateProcurementWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Procurement0 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Procurement0?.setOrganization) {
|
|
await Procurement0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Procurement1 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Procurement1?.setOrganization) {
|
|
await Procurement1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Procurement2 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Procurement2?.setOrganization) {
|
|
await Procurement2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Procurement3 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Procurement3?.setOrganization) {
|
|
await Procurement3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Procurement4 = await Procurements.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Procurement4?.setOrganization) {
|
|
await Procurement4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateProjectWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Project0 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Project0?.setOrganization) {
|
|
await Project0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Project1 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Project1?.setOrganization) {
|
|
await Project1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Project2 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Project2?.setOrganization) {
|
|
await Project2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Project3 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Project3?.setOrganization) {
|
|
await Project3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Project4 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Project4?.setOrganization) {
|
|
await Project4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateVendorWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Vendor0 = await Vendors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Vendor0?.setOrganization) {
|
|
await Vendor0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Vendor1 = await Vendors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Vendor1?.setOrganization) {
|
|
await Vendor1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Vendor2 = await Vendors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Vendor2?.setOrganization) {
|
|
await Vendor2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Vendor3 = await Vendors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Vendor3?.setOrganization) {
|
|
await Vendor3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Vendor4 = await Vendors.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Vendor4?.setOrganization) {
|
|
await Vendor4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Accounts.bulkCreate(AccountsData);
|
|
|
|
await Assets.bulkCreate(AssetsData);
|
|
|
|
await Attendances.bulkCreate(AttendancesData);
|
|
|
|
await Employees.bulkCreate(EmployeesData);
|
|
|
|
await Expenses.bulkCreate(ExpensesData);
|
|
|
|
await Leaves.bulkCreate(LeavesData);
|
|
|
|
await Payrolls.bulkCreate(PayrollsData);
|
|
|
|
await Performances.bulkCreate(PerformancesData);
|
|
|
|
await Procurements.bulkCreate(ProcurementsData);
|
|
|
|
await Projects.bulkCreate(ProjectsData);
|
|
|
|
await Vendors.bulkCreate(VendorsData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateAccountWithOrganization(),
|
|
|
|
await associateAssetWithEmployee(),
|
|
|
|
await associateAssetWithOrganization(),
|
|
|
|
await associateAttendanceWithEmployee(),
|
|
|
|
await associateAttendanceWithOrganization(),
|
|
|
|
await associateEmployeeWithUser(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateEmployeeWithOrganization(),
|
|
|
|
await associateExpenseWithEmployee(),
|
|
|
|
await associateExpenseWithProject(),
|
|
|
|
await associateExpenseWithOrganization(),
|
|
|
|
await associateLeafeWithEmployee(),
|
|
|
|
await associateLeafeWithOrganization(),
|
|
|
|
await associatePayrollWithEmployee(),
|
|
|
|
await associatePayrollWithOrganization(),
|
|
|
|
await associatePerformanceWithEmployee(),
|
|
|
|
await associatePerformanceWithOrganization(),
|
|
|
|
await associateProcurementWithVendor(),
|
|
|
|
await associateProcurementWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateProjectWithOrganization(),
|
|
|
|
await associateVendorWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('accounts', null, {});
|
|
|
|
await queryInterface.bulkDelete('assets', null, {});
|
|
|
|
await queryInterface.bulkDelete('attendances', null, {});
|
|
|
|
await queryInterface.bulkDelete('employees', null, {});
|
|
|
|
await queryInterface.bulkDelete('expenses', null, {});
|
|
|
|
await queryInterface.bulkDelete('leaves', null, {});
|
|
|
|
await queryInterface.bulkDelete('payrolls', null, {});
|
|
|
|
await queryInterface.bulkDelete('performances', null, {});
|
|
|
|
await queryInterface.bulkDelete('procurements', null, {});
|
|
|
|
await queryInterface.bulkDelete('projects', null, {});
|
|
|
|
await queryInterface.bulkDelete('vendors', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|