5535 lines
114 KiB
JavaScript
5535 lines
114 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Accounts = db.accounts;
|
|
|
|
const Contacts = db.contacts;
|
|
|
|
const LeadSources = db.lead_sources;
|
|
|
|
const Leads = db.leads;
|
|
|
|
const Pipelines = db.pipelines;
|
|
|
|
const DealStages = db.deal_stages;
|
|
|
|
const Deals = db.deals;
|
|
|
|
const ActivityTypes = db.activity_types;
|
|
|
|
const Activities = db.activities;
|
|
|
|
const Notes = db.notes;
|
|
|
|
const Tags = db.tags;
|
|
|
|
const Tasks = db.tasks;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const AccountsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Northwind Traders",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "company",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://northwindtraders.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Logistics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 212 555 0140",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address": "233 Hudson St, New York, NY",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address": "Warehouse 12, Newark, NJ",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Growing regional distributor seeking CRM modernization.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "BluePeak Software",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "individual",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://bluepeaksoftware.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Software",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 646 555 0198",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address": "45 W 18th St, New York, NY",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address": "45 W 18th St, New York, NY",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Mid-market SaaS evaluating sales enablement tools.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Cedar & Stone Manufacturing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "partner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://cedarstonemfg.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Manufacturing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 312 555 0122",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address": "800 W Fulton Market, Chicago, IL",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address": "Dock 3, Cicero, IL",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Interested in pipeline reporting and forecasting.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Harborview Capital",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "individual",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://harborviewcap.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Financial Services",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 617 555 0166",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"billing_address": "200 State St, Boston, MA",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shipping_address": "200 State St, Boston, MA",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Compliance-focused buyer; prefers secure integrations.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ContactsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"full_name": "Elena Torres",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "elena.torres@northwindtraders.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 212 555 0161",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"job_title": "Operations Director",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lifecycle_stage": "customer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"do_not_contact": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"linkedin_url": "https://www.linkedin.com/in/elena-torres-ops",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Prefers email follow-ups in the morning.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_contacted_at": new Date('2026-07-10T15:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"full_name": "Derek Wu",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "derek.wu@bluepeaksoftware.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 646 555 0120",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"job_title": "VP Sales",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lifecycle_stage": "partner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"do_not_contact": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"linkedin_url": "https://www.linkedin.com/in/derek-wu-vpsales",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Wants demo focused on pipeline and forecasting.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_contacted_at": new Date('2026-07-15T17:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"full_name": "Nina Kapoor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "nina.kapoor@cedarstonemfg.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 312 555 0177",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"job_title": "IT Manager",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lifecycle_stage": "prospect",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"do_not_contact": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"linkedin_url": "https://www.linkedin.com/in/nina-kapoor-it",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Asked about SSO and data migration.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_contacted_at": new Date('2026-07-12T14:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"full_name": "Marcus Reed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "marcus.reed@harborviewcap.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 617 555 0189",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"job_title": "Procurement Lead",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lifecycle_stage": "former_customer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"do_not_contact": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"linkedin_url": "https://www.linkedin.com/in/marcus-reed-procurement",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Will require vendor risk review and references.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_contacted_at": new Date('2026-07-16T13:45:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LeadSourcesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Website Inquiry",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Inbound form submissions from marketing site.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Referral Partner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Leads from channel and referral partners.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Outbound Prospecting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "SDR outreach and cold campaigns.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Event Webinar",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Registrations from webinars and virtual events.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LeadsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Northwind Traders - CRM Upgrade",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "qualified",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": "cold",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_value": 24000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"company_name": "Northwind Traders",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "elena.torres@northwindtraders.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 212 555 0161",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-28T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-20T15:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Interested in better ownership visibility and follow-ups.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "BluePeak Software - Pipeline Reporting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "new",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": "cold",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_value": 48000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"company_name": "BluePeak Software",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "derek.wu@bluepeaksoftware.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 646 555 0120",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-29T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-21T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Asked for forecast accuracy and stage governance.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Cedar & Stone - Sales Activity Tracking",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "qualified",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": "warm",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_value": 36000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"company_name": "Cedar & Stone Manufacturing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "nina.kapoor@cedarstonemfg.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 312 555 0177",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-30T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-22T18:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Wants activity logs connected to deals and contacts.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Harborview Capital - Secure CRM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "converted",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": "warm",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_value": 60000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"company_name": "Harborview Capital",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "marcus.reed@harborviewcap.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1 617 555 0189",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-31T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-23T12:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Security and compliance are key evaluation criteria.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const PipelinesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "New Business",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Standard pipeline for new customer acquisition.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Mid-Market Expansion",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Upsell and cross-sell motions for existing customers.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Enterprise Sales",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Longer sales cycles with procurement and security review.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Partner Deals",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Channel-sourced opportunities with partner involvement.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_default": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const DealStagesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Qualification",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sort_order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 0.1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_won": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_lost": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Discovery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sort_order": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 0.25,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_won": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_lost": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Proposal",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sort_order": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 0.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_won": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_lost": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Negotiation",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sort_order": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 0.75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_won": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_lost": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const DealsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Northwind Traders - Annual CRM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "on_hold",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 24000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expected_close_at": new Date('2026-08-20T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-09-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-28T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-20T15:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loss_reason": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Focus on pipeline visibility, ownership, and follow-up scheduling.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "BluePeak Software - Team Seats",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "lost",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 48000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expected_close_at": new Date('2026-08-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-08-30T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-29T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-21T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loss_reason": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Proposal sent; planning follow-up to review pricing and rollout plan.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Cedar & Stone - Implementation Package",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "lost",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 36000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expected_close_at": new Date('2026-09-05T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-09-20T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-30T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-22T18:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loss_reason": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Early stage; needs technical validation and migration scope.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Harborview Capital - Enterprise Rollout",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "on_hold",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 60000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expected_close_at": new Date('2026-08-30T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"closed_at": new Date('2026-09-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-31T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-07-23T12:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"loss_reason": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Procurement review in progress; security questionnaire pending.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ActivityTypesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Discovery Call",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "task",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Follow-up Email",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "other",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Product Demo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "call",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Proposal Review Meeting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "other",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ActivitiesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "inbound",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start_at": new Date('2026-07-20T15:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end_at": new Date('2026-07-20T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-07-20T15:35:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Discovery call with Elena",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Covered current process and pain points. Agreed to share a short demo next week.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-28T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "internal",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "canceled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start_at": new Date('2026-07-29T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end_at": new Date('2026-07-29T17:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-07-29T17:50:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Pipeline and forecasting demo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Demo to focus on stage governance, ownership, and reporting.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-30T18:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "inbound",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "no_show",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start_at": new Date('2026-07-22T18:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end_at": new Date('2026-07-22T18:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-07-22T18:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "SSO and migration details",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Sent overview of SSO options and migration approach. Asked for timeline and data sources.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-07-30T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "outbound",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "canceled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start_at": new Date('2026-07-31T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end_at": new Date('2026-07-31T14:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-07-31T14:50:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Procurement review and next steps",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Review pricing, contract terms, and procurement checklist items.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_follow_up_at": new Date('2026-08-01T15:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const NotesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Northwind pain points",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body": "Key issues: unclear ownership, missed follow-ups, and limited pipeline reporting. They want a simple workflow and reminders.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "BluePeak success criteria",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body": "Decision based on forecast accuracy, flexible stages, and quick onboarding. Requested a sample dashboard view for managers.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Cedar & Stone technical notes",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body": "They have Azure AD and prefer SSO. Data currently in spreadsheets and a legacy CRM export.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Harborview procurement",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body": "Need vendor risk assessment, SOC2 documentation, and standard MSA review. Timeline depends on compliance sign-off.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TagsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "High Priority",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"color": "#DC2626",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Security Review",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"color": "#2563EB",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Needs Demo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"color": "#16A34A",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Budget Pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"color": "#F59E0B",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TasksData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Send Northwind recap email",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "open",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "high",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_at": new Date('2026-07-28T18:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-07-29T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Summarize discovery call and confirm demo date and attendees.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Prepare BluePeak proposal revisions",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "canceled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_at": new Date('2026-07-30T20:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-08-01T10:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Update pricing for annual commit and include onboarding timeline.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Collect Cedar & Stone requirements",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "canceled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "urgent",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_at": new Date('2026-08-02T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-08-03T16:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Request data export samples and confirm SSO requirements.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Complete Harborview security questionnaire",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "high",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_at": new Date('2026-08-05T18:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-08-06T14:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Coordinate with security team to provide required compliance documentation.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAccountWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account0 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Account0?.setOwner)
|
|
{
|
|
await
|
|
Account0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account1 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Account1?.setOwner)
|
|
{
|
|
await
|
|
Account1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account2 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Account2?.setOwner)
|
|
{
|
|
await
|
|
Account2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Account3 = await Accounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Account3?.setOwner)
|
|
{
|
|
await
|
|
Account3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateContactWithAccount() {
|
|
|
|
const relatedAccount0 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Contact0 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Contact0?.setAccount)
|
|
{
|
|
await
|
|
Contact0.
|
|
setAccount(relatedAccount0);
|
|
}
|
|
|
|
const relatedAccount1 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Contact1 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Contact1?.setAccount)
|
|
{
|
|
await
|
|
Contact1.
|
|
setAccount(relatedAccount1);
|
|
}
|
|
|
|
const relatedAccount2 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Contact2 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Contact2?.setAccount)
|
|
{
|
|
await
|
|
Contact2.
|
|
setAccount(relatedAccount2);
|
|
}
|
|
|
|
const relatedAccount3 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Contact3 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Contact3?.setAccount)
|
|
{
|
|
await
|
|
Contact3.
|
|
setAccount(relatedAccount3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateContactWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact0 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Contact0?.setOwner)
|
|
{
|
|
await
|
|
Contact0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact1 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Contact1?.setOwner)
|
|
{
|
|
await
|
|
Contact1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact2 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Contact2?.setOwner)
|
|
{
|
|
await
|
|
Contact2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact3 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Contact3?.setOwner)
|
|
{
|
|
await
|
|
Contact3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLeadWithPrimary_contact() {
|
|
|
|
const relatedPrimary_contact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lead0?.setPrimary_contact)
|
|
{
|
|
await
|
|
Lead0.
|
|
setPrimary_contact(relatedPrimary_contact0);
|
|
}
|
|
|
|
const relatedPrimary_contact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lead1?.setPrimary_contact)
|
|
{
|
|
await
|
|
Lead1.
|
|
setPrimary_contact(relatedPrimary_contact1);
|
|
}
|
|
|
|
const relatedPrimary_contact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lead2?.setPrimary_contact)
|
|
{
|
|
await
|
|
Lead2.
|
|
setPrimary_contact(relatedPrimary_contact2);
|
|
}
|
|
|
|
const relatedPrimary_contact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead3 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lead3?.setPrimary_contact)
|
|
{
|
|
await
|
|
Lead3.
|
|
setPrimary_contact(relatedPrimary_contact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateLeadWithAccount() {
|
|
|
|
const relatedAccount0 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lead0?.setAccount)
|
|
{
|
|
await
|
|
Lead0.
|
|
setAccount(relatedAccount0);
|
|
}
|
|
|
|
const relatedAccount1 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lead1?.setAccount)
|
|
{
|
|
await
|
|
Lead1.
|
|
setAccount(relatedAccount1);
|
|
}
|
|
|
|
const relatedAccount2 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lead2?.setAccount)
|
|
{
|
|
await
|
|
Lead2.
|
|
setAccount(relatedAccount2);
|
|
}
|
|
|
|
const relatedAccount3 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Lead3 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lead3?.setAccount)
|
|
{
|
|
await
|
|
Lead3.
|
|
setAccount(relatedAccount3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateLeadWithSource() {
|
|
|
|
const relatedSource0 = await LeadSources.findOne({
|
|
offset: Math.floor(Math.random() * (await LeadSources.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lead0?.setSource)
|
|
{
|
|
await
|
|
Lead0.
|
|
setSource(relatedSource0);
|
|
}
|
|
|
|
const relatedSource1 = await LeadSources.findOne({
|
|
offset: Math.floor(Math.random() * (await LeadSources.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lead1?.setSource)
|
|
{
|
|
await
|
|
Lead1.
|
|
setSource(relatedSource1);
|
|
}
|
|
|
|
const relatedSource2 = await LeadSources.findOne({
|
|
offset: Math.floor(Math.random() * (await LeadSources.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lead2?.setSource)
|
|
{
|
|
await
|
|
Lead2.
|
|
setSource(relatedSource2);
|
|
}
|
|
|
|
const relatedSource3 = await LeadSources.findOne({
|
|
offset: Math.floor(Math.random() * (await LeadSources.count())),
|
|
});
|
|
const Lead3 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lead3?.setSource)
|
|
{
|
|
await
|
|
Lead3.
|
|
setSource(relatedSource3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLeadWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lead0?.setOwner)
|
|
{
|
|
await
|
|
Lead0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lead1?.setOwner)
|
|
{
|
|
await
|
|
Lead1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lead2?.setOwner)
|
|
{
|
|
await
|
|
Lead2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead3 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lead3?.setOwner)
|
|
{
|
|
await
|
|
Lead3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateDealStageWithPipeline() {
|
|
|
|
const relatedPipeline0 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const DealStage0 = await DealStages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (DealStage0?.setPipeline)
|
|
{
|
|
await
|
|
DealStage0.
|
|
setPipeline(relatedPipeline0);
|
|
}
|
|
|
|
const relatedPipeline1 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const DealStage1 = await DealStages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (DealStage1?.setPipeline)
|
|
{
|
|
await
|
|
DealStage1.
|
|
setPipeline(relatedPipeline1);
|
|
}
|
|
|
|
const relatedPipeline2 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const DealStage2 = await DealStages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (DealStage2?.setPipeline)
|
|
{
|
|
await
|
|
DealStage2.
|
|
setPipeline(relatedPipeline2);
|
|
}
|
|
|
|
const relatedPipeline3 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const DealStage3 = await DealStages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (DealStage3?.setPipeline)
|
|
{
|
|
await
|
|
DealStage3.
|
|
setPipeline(relatedPipeline3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateDealWithAccount() {
|
|
|
|
const relatedAccount0 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setAccount)
|
|
{
|
|
await
|
|
Deal0.
|
|
setAccount(relatedAccount0);
|
|
}
|
|
|
|
const relatedAccount1 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setAccount)
|
|
{
|
|
await
|
|
Deal1.
|
|
setAccount(relatedAccount1);
|
|
}
|
|
|
|
const relatedAccount2 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setAccount)
|
|
{
|
|
await
|
|
Deal2.
|
|
setAccount(relatedAccount2);
|
|
}
|
|
|
|
const relatedAccount3 = await Accounts.findOne({
|
|
offset: Math.floor(Math.random() * (await Accounts.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setAccount)
|
|
{
|
|
await
|
|
Deal3.
|
|
setAccount(relatedAccount3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateDealWithPrimary_contact() {
|
|
|
|
const relatedPrimary_contact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setPrimary_contact)
|
|
{
|
|
await
|
|
Deal0.
|
|
setPrimary_contact(relatedPrimary_contact0);
|
|
}
|
|
|
|
const relatedPrimary_contact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setPrimary_contact)
|
|
{
|
|
await
|
|
Deal1.
|
|
setPrimary_contact(relatedPrimary_contact1);
|
|
}
|
|
|
|
const relatedPrimary_contact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setPrimary_contact)
|
|
{
|
|
await
|
|
Deal2.
|
|
setPrimary_contact(relatedPrimary_contact2);
|
|
}
|
|
|
|
const relatedPrimary_contact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setPrimary_contact)
|
|
{
|
|
await
|
|
Deal3.
|
|
setPrimary_contact(relatedPrimary_contact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateDealWithPipeline() {
|
|
|
|
const relatedPipeline0 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setPipeline)
|
|
{
|
|
await
|
|
Deal0.
|
|
setPipeline(relatedPipeline0);
|
|
}
|
|
|
|
const relatedPipeline1 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setPipeline)
|
|
{
|
|
await
|
|
Deal1.
|
|
setPipeline(relatedPipeline1);
|
|
}
|
|
|
|
const relatedPipeline2 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setPipeline)
|
|
{
|
|
await
|
|
Deal2.
|
|
setPipeline(relatedPipeline2);
|
|
}
|
|
|
|
const relatedPipeline3 = await Pipelines.findOne({
|
|
offset: Math.floor(Math.random() * (await Pipelines.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setPipeline)
|
|
{
|
|
await
|
|
Deal3.
|
|
setPipeline(relatedPipeline3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateDealWithStage() {
|
|
|
|
const relatedStage0 = await DealStages.findOne({
|
|
offset: Math.floor(Math.random() * (await DealStages.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setStage)
|
|
{
|
|
await
|
|
Deal0.
|
|
setStage(relatedStage0);
|
|
}
|
|
|
|
const relatedStage1 = await DealStages.findOne({
|
|
offset: Math.floor(Math.random() * (await DealStages.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setStage)
|
|
{
|
|
await
|
|
Deal1.
|
|
setStage(relatedStage1);
|
|
}
|
|
|
|
const relatedStage2 = await DealStages.findOne({
|
|
offset: Math.floor(Math.random() * (await DealStages.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setStage)
|
|
{
|
|
await
|
|
Deal2.
|
|
setStage(relatedStage2);
|
|
}
|
|
|
|
const relatedStage3 = await DealStages.findOne({
|
|
offset: Math.floor(Math.random() * (await DealStages.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setStage)
|
|
{
|
|
await
|
|
Deal3.
|
|
setStage(relatedStage3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateDealWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setOwner)
|
|
{
|
|
await
|
|
Deal0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setOwner)
|
|
{
|
|
await
|
|
Deal1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setOwner)
|
|
{
|
|
await
|
|
Deal2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setOwner)
|
|
{
|
|
await
|
|
Deal3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithType() {
|
|
|
|
const relatedType0 = await ActivityTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await ActivityTypes.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setType)
|
|
{
|
|
await
|
|
Activity0.
|
|
setType(relatedType0);
|
|
}
|
|
|
|
const relatedType1 = await ActivityTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await ActivityTypes.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setType)
|
|
{
|
|
await
|
|
Activity1.
|
|
setType(relatedType1);
|
|
}
|
|
|
|
const relatedType2 = await ActivityTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await ActivityTypes.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setType)
|
|
{
|
|
await
|
|
Activity2.
|
|
setType(relatedType2);
|
|
}
|
|
|
|
const relatedType3 = await ActivityTypes.findOne({
|
|
offset: Math.floor(Math.random() * (await ActivityTypes.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setType)
|
|
{
|
|
await
|
|
Activity3.
|
|
setType(relatedType3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithAssigned_to() {
|
|
|
|
const relatedAssigned_to0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setAssigned_to)
|
|
{
|
|
await
|
|
Activity0.
|
|
setAssigned_to(relatedAssigned_to0);
|
|
}
|
|
|
|
const relatedAssigned_to1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setAssigned_to)
|
|
{
|
|
await
|
|
Activity1.
|
|
setAssigned_to(relatedAssigned_to1);
|
|
}
|
|
|
|
const relatedAssigned_to2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setAssigned_to)
|
|
{
|
|
await
|
|
Activity2.
|
|
setAssigned_to(relatedAssigned_to2);
|
|
}
|
|
|
|
const relatedAssigned_to3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setAssigned_to)
|
|
{
|
|
await
|
|
Activity3.
|
|
setAssigned_to(relatedAssigned_to3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithDeal() {
|
|
|
|
const relatedDeal0 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setDeal)
|
|
{
|
|
await
|
|
Activity0.
|
|
setDeal(relatedDeal0);
|
|
}
|
|
|
|
const relatedDeal1 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setDeal)
|
|
{
|
|
await
|
|
Activity1.
|
|
setDeal(relatedDeal1);
|
|
}
|
|
|
|
const relatedDeal2 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setDeal)
|
|
{
|
|
await
|
|
Activity2.
|
|
setDeal(relatedDeal2);
|
|
}
|
|
|
|
const relatedDeal3 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setDeal)
|
|
{
|
|
await
|
|
Activity3.
|
|
setDeal(relatedDeal3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithLead() {
|
|
|
|
const relatedLead0 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setLead)
|
|
{
|
|
await
|
|
Activity0.
|
|
setLead(relatedLead0);
|
|
}
|
|
|
|
const relatedLead1 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setLead)
|
|
{
|
|
await
|
|
Activity1.
|
|
setLead(relatedLead1);
|
|
}
|
|
|
|
const relatedLead2 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setLead)
|
|
{
|
|
await
|
|
Activity2.
|
|
setLead(relatedLead2);
|
|
}
|
|
|
|
const relatedLead3 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setLead)
|
|
{
|
|
await
|
|
Activity3.
|
|
setLead(relatedLead3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithContact() {
|
|
|
|
const relatedContact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setContact)
|
|
{
|
|
await
|
|
Activity0.
|
|
setContact(relatedContact0);
|
|
}
|
|
|
|
const relatedContact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setContact)
|
|
{
|
|
await
|
|
Activity1.
|
|
setContact(relatedContact1);
|
|
}
|
|
|
|
const relatedContact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setContact)
|
|
{
|
|
await
|
|
Activity2.
|
|
setContact(relatedContact2);
|
|
}
|
|
|
|
const relatedContact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setContact)
|
|
{
|
|
await
|
|
Activity3.
|
|
setContact(relatedContact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateNoteWithAuthor() {
|
|
|
|
const relatedAuthor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Note0 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Note0?.setAuthor)
|
|
{
|
|
await
|
|
Note0.
|
|
setAuthor(relatedAuthor0);
|
|
}
|
|
|
|
const relatedAuthor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Note1 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Note1?.setAuthor)
|
|
{
|
|
await
|
|
Note1.
|
|
setAuthor(relatedAuthor1);
|
|
}
|
|
|
|
const relatedAuthor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Note2 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Note2?.setAuthor)
|
|
{
|
|
await
|
|
Note2.
|
|
setAuthor(relatedAuthor2);
|
|
}
|
|
|
|
const relatedAuthor3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Note3 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Note3?.setAuthor)
|
|
{
|
|
await
|
|
Note3.
|
|
setAuthor(relatedAuthor3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateNoteWithDeal() {
|
|
|
|
const relatedDeal0 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Note0 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Note0?.setDeal)
|
|
{
|
|
await
|
|
Note0.
|
|
setDeal(relatedDeal0);
|
|
}
|
|
|
|
const relatedDeal1 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Note1 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Note1?.setDeal)
|
|
{
|
|
await
|
|
Note1.
|
|
setDeal(relatedDeal1);
|
|
}
|
|
|
|
const relatedDeal2 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Note2 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Note2?.setDeal)
|
|
{
|
|
await
|
|
Note2.
|
|
setDeal(relatedDeal2);
|
|
}
|
|
|
|
const relatedDeal3 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Note3 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Note3?.setDeal)
|
|
{
|
|
await
|
|
Note3.
|
|
setDeal(relatedDeal3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateNoteWithLead() {
|
|
|
|
const relatedLead0 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Note0 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Note0?.setLead)
|
|
{
|
|
await
|
|
Note0.
|
|
setLead(relatedLead0);
|
|
}
|
|
|
|
const relatedLead1 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Note1 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Note1?.setLead)
|
|
{
|
|
await
|
|
Note1.
|
|
setLead(relatedLead1);
|
|
}
|
|
|
|
const relatedLead2 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Note2 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Note2?.setLead)
|
|
{
|
|
await
|
|
Note2.
|
|
setLead(relatedLead2);
|
|
}
|
|
|
|
const relatedLead3 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Note3 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Note3?.setLead)
|
|
{
|
|
await
|
|
Note3.
|
|
setLead(relatedLead3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateNoteWithContact() {
|
|
|
|
const relatedContact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Note0 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Note0?.setContact)
|
|
{
|
|
await
|
|
Note0.
|
|
setContact(relatedContact0);
|
|
}
|
|
|
|
const relatedContact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Note1 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Note1?.setContact)
|
|
{
|
|
await
|
|
Note1.
|
|
setContact(relatedContact1);
|
|
}
|
|
|
|
const relatedContact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Note2 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Note2?.setContact)
|
|
{
|
|
await
|
|
Note2.
|
|
setContact(relatedContact2);
|
|
}
|
|
|
|
const relatedContact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Note3 = await Notes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Note3?.setContact)
|
|
{
|
|
await
|
|
Note3.
|
|
setContact(relatedContact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithAssignee() {
|
|
|
|
const relatedAssignee0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setAssignee)
|
|
{
|
|
await
|
|
Task0.
|
|
setAssignee(relatedAssignee0);
|
|
}
|
|
|
|
const relatedAssignee1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setAssignee)
|
|
{
|
|
await
|
|
Task1.
|
|
setAssignee(relatedAssignee1);
|
|
}
|
|
|
|
const relatedAssignee2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setAssignee)
|
|
{
|
|
await
|
|
Task2.
|
|
setAssignee(relatedAssignee2);
|
|
}
|
|
|
|
const relatedAssignee3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task3 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Task3?.setAssignee)
|
|
{
|
|
await
|
|
Task3.
|
|
setAssignee(relatedAssignee3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithDeal() {
|
|
|
|
const relatedDeal0 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setDeal)
|
|
{
|
|
await
|
|
Task0.
|
|
setDeal(relatedDeal0);
|
|
}
|
|
|
|
const relatedDeal1 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setDeal)
|
|
{
|
|
await
|
|
Task1.
|
|
setDeal(relatedDeal1);
|
|
}
|
|
|
|
const relatedDeal2 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setDeal)
|
|
{
|
|
await
|
|
Task2.
|
|
setDeal(relatedDeal2);
|
|
}
|
|
|
|
const relatedDeal3 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Task3 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Task3?.setDeal)
|
|
{
|
|
await
|
|
Task3.
|
|
setDeal(relatedDeal3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithLead() {
|
|
|
|
const relatedLead0 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setLead)
|
|
{
|
|
await
|
|
Task0.
|
|
setLead(relatedLead0);
|
|
}
|
|
|
|
const relatedLead1 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setLead)
|
|
{
|
|
await
|
|
Task1.
|
|
setLead(relatedLead1);
|
|
}
|
|
|
|
const relatedLead2 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setLead)
|
|
{
|
|
await
|
|
Task2.
|
|
setLead(relatedLead2);
|
|
}
|
|
|
|
const relatedLead3 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Task3 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Task3?.setLead)
|
|
{
|
|
await
|
|
Task3.
|
|
setLead(relatedLead3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithContact() {
|
|
|
|
const relatedContact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setContact)
|
|
{
|
|
await
|
|
Task0.
|
|
setContact(relatedContact0);
|
|
}
|
|
|
|
const relatedContact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setContact)
|
|
{
|
|
await
|
|
Task1.
|
|
setContact(relatedContact1);
|
|
}
|
|
|
|
const relatedContact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setContact)
|
|
{
|
|
await
|
|
Task2.
|
|
setContact(relatedContact2);
|
|
}
|
|
|
|
const relatedContact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Task3 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Task3?.setContact)
|
|
{
|
|
await
|
|
Task3.
|
|
setContact(relatedContact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Accounts.bulkCreate(AccountsData);
|
|
|
|
|
|
|
|
|
|
await Contacts.bulkCreate(ContactsData);
|
|
|
|
|
|
|
|
|
|
await LeadSources.bulkCreate(LeadSourcesData);
|
|
|
|
|
|
|
|
|
|
await Leads.bulkCreate(LeadsData);
|
|
|
|
|
|
|
|
|
|
await Pipelines.bulkCreate(PipelinesData);
|
|
|
|
|
|
|
|
|
|
await DealStages.bulkCreate(DealStagesData);
|
|
|
|
|
|
|
|
|
|
await Deals.bulkCreate(DealsData);
|
|
|
|
|
|
|
|
|
|
await ActivityTypes.bulkCreate(ActivityTypesData);
|
|
|
|
|
|
|
|
|
|
await Activities.bulkCreate(ActivitiesData);
|
|
|
|
|
|
|
|
|
|
await Notes.bulkCreate(NotesData);
|
|
|
|
|
|
|
|
|
|
await Tags.bulkCreate(TagsData);
|
|
|
|
|
|
|
|
|
|
await Tasks.bulkCreate(TasksData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAccountWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateContactWithAccount(),
|
|
|
|
|
|
|
|
|
|
await associateContactWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLeadWithPrimary_contact(),
|
|
|
|
|
|
|
|
|
|
await associateLeadWithAccount(),
|
|
|
|
|
|
|
|
|
|
await associateLeadWithSource(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLeadWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateDealStageWithPipeline(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateDealWithAccount(),
|
|
|
|
|
|
|
|
|
|
await associateDealWithPrimary_contact(),
|
|
|
|
|
|
|
|
|
|
await associateDealWithPipeline(),
|
|
|
|
|
|
|
|
|
|
await associateDealWithStage(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateDealWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateActivityWithType(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateActivityWithAssigned_to(),
|
|
|
|
|
|
|
|
|
|
await associateActivityWithDeal(),
|
|
|
|
|
|
|
|
|
|
await associateActivityWithLead(),
|
|
|
|
|
|
|
|
|
|
await associateActivityWithContact(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateNoteWithAuthor(),
|
|
|
|
|
|
|
|
|
|
await associateNoteWithDeal(),
|
|
|
|
|
|
|
|
|
|
await associateNoteWithLead(),
|
|
|
|
|
|
|
|
|
|
await associateNoteWithContact(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateTaskWithAssignee(),
|
|
|
|
|
|
|
|
|
|
await associateTaskWithDeal(),
|
|
|
|
|
|
|
|
|
|
await associateTaskWithLead(),
|
|
|
|
|
|
|
|
|
|
await associateTaskWithContact(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('accounts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('contacts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('lead_sources', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('leads', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('pipelines', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('deal_stages', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('deals', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('activity_types', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('activities', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('notes', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('tags', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('tasks', null, {});
|
|
|
|
|
|
},
|
|
}; |