added and updated models

This commit is contained in:
timurgordon
2025-05-12 01:54:47 +03:00
parent f388fde388
commit 52528ca99f
25 changed files with 734 additions and 182 deletions

View File

@@ -0,0 +1,31 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// Account represents a business or organization.
// Enums like AccountType and AccountIndustry have been removed for broader applicability.
// Fields previously using these enums now use `string` type.
pub struct Account {
base.Base // Base struct for common fields
pub mut:
name string
typ string // Type of account (e.g., Customer, Partner) - formerly AccountType enum
industry string // Industry of the account (e.g., Technology, Healthcare) - formerly AccountIndustry enum
employees u32
annual_revenue f64
billing_street string
billing_city string
billing_state string
billing_postal_code string
billing_country string
shipping_street string
shipping_city string
shipping_state string
shipping_postal_code string
shipping_country string
description string
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
primary_contact_id u32? // Optional: Reference to Contact
}

39
specs/models/crm/call.v Normal file
View File

@@ -0,0 +1,39 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// CallStatus represents the status of a call
pub enum CallStatus {
planned
held
not_held
canceled
}
// CallDirection represents the direction of a call
pub enum CallDirection {
outbound
inbound
}
// Call represents a phone call in the CRM system
pub struct Call {
base.Base // Base struct for common fields (id u32, creation_time, mod_time)
pub mut:
name string
status CallStatus
direction CallDirection
date_start ourtime.OurTime
duration u32 // Duration in minutes
description string
parent_type string // Can be 'Account', 'Contact', 'Lead', 'Opportunity', 'Case'
parent_id u32 // Reference to the parent entity
account_id u32 // Reference to Account
contact_id u32 // Reference to Contact
lead_id u32 // Reference to Lead
phone_number string
recording_url string // Optional
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
}

View File

@@ -0,0 +1,57 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// CampaignStatus represents the status of a marketing campaign
pub enum CampaignStatus {
planning
active
inactive
complete
canceled
}
// CampaignType represents the type of a marketing campaign
pub enum CampaignType {
email
newsletter
web
television
radio
mail
print
social_media
telemarketing
event
other
}
// Campaign represents a marketing campaign in the CRM system
pub struct Campaign {
base.Base // Base struct for common fields (id u32, creation_time, mod_time)
pub mut:
name string
status CampaignStatus
type CampaignType
start_date ourtime.OurTime
end_date ourtime.OurTime
budget f64
expected_revenue f64
expected_cost f64
actual_cost f64
objective string
description string
target_audience string
sent_count u32
open_count u32
click_count u32
bounce_count u32
opt_out_count u32
lead_count u32
opportunity_count u32
revenue f64
roi f64 // Return on Investment
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
}

53
specs/models/crm/case.v Normal file
View File

@@ -0,0 +1,53 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// CaseStatus represents the status of a support case
pub enum CaseStatus {
new
assigned
pending
closed
rejected
duplicate
}
// CasePriority represents the priority of a support case
pub enum CasePriority {
low
medium
high
urgent
}
// CaseType represents the type of a support case
pub enum CaseType {
question
incident
problem
feature_request
bug
}
// Case represents a customer support case in the CRM system
pub struct Case {
base.Base // Base struct for common fields (id u32, creation_time, mod_time)
pub mut:
// id u32 // Removed, provided by base.Base
number string // Auto-generated case number (e.g., "C-00001")
name string
status CaseStatus
priority CasePriority
type CaseType
account_id u32 // Reference to Account
contact_id u32 // Reference to Contact
description string
resolution string // Optional
solution string // Optional
resolved_at ourtime.OurTime // Optional
// created_at ourtime.OurTime // Removed, provided by base.Base.creation_time
// updated_at ourtime.OurTime // Removed, provided by base.Base.mod_time
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
}

View File

@@ -0,0 +1,35 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// Contact represents an individual person in the CRM system.
pub struct Contact {
base.Base // Provides id u32, creation_time, mod_time
pub mut:
first_name string
last_name string
title string // e.g., Mr., Ms., Dr.
email string
phone string
mobile string
job_title string
department string // Optional
// company_id u32 // Optional: If directly linked to a primary company/account
// reports_to_id u32 // Optional: Contact ID of their manager
// Address fields
address_street string
address_city string
address_state string
address_postal_code string
address_country string
description string // General notes about the contact
do_not_call bool
email_opt_out bool
// Social media profiles could be added here too
// linkedin_profile string
// twitter_profile string
}

47
specs/models/crm/lead.v Normal file
View File

@@ -0,0 +1,47 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// LeadStatus represents the status of a lead
pub enum LeadStatus {
new
assigned
in_process
converted
recycled
dead
}
// LeadSource represents the source of a lead
pub enum LeadSource {
website
call
email
existing_customer
partner
public_relations
campaign
conference
trade_show
word_of_mouth
other
}
// Lead represents a potential customer in the CRM system
pub struct Lead {
base.Base // Base struct for common fields (id u32, creation_time, mod_time)
pub mut:
// id u32 // Removed, provided by base.Base
contact_id u32 // Reference to a Contact (holds name, email, phone etc.)
description string
status LeadStatus
source LeadSource
opportunity_amount f64 // Optional: If lead is converted, this could be initial amount
opportunity_name string // Optional: If lead is converted, this could be initial name
converted_at ourtime.OurTime // Optional: Timestamp when lead was converted
// created_at ourtime.OurTime // Removed, provided by base.Base.creation_time
// updated_at ourtime.OurTime // Removed, provided by base.Base.mod_time
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
}

View File

@@ -0,0 +1,57 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// Opportunity represents a potential sale in the CRM system
pub struct Opportunity {
base.Base // Base struct for common fields (id u32, creation_time, mod_time)
pub mut:
// id u32 // Removed, provided by base.Base
name string
account_id u32 // Reference to Account
amount f64
close_date ourtime.OurTime // Expected close date
probability f64 // Percentage (0-100)
stage OpportunityStage
source OpportunitySource
lead_source string // More specific lead source details if needed
campaign_id u32 // Optional: Reference to Campaign
description string
next_step string // Optional
competition string // Optional
// created_at ourtime.OurTime // Removed, provided by base.Base.creation_time
// updated_at ourtime.OurTime // Removed, provided by base.Base.mod_time
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
contacts []u32 // References to Contacts associated with this opportunity
}
// OpportunityStage represents the stage of an opportunity
pub enum OpportunityStage {
prospecting
qualification
needs_analysis
value_proposition
id_decision_makers
perception_analysis
proposal_price_quote
negotiation_review
closed_won
closed_lost
}
// OpportunitySource represents the source of an opportunity
pub enum OpportunitySource {
call
email
existing_customer
partner
public_relations
campaign
web_site
conference
trade_show
word_of_mouth
other
}

43
specs/models/crm/task.v Normal file
View File

@@ -0,0 +1,43 @@
module crm
import base
import freeflowuniverse.herolib.data.ourtime
// TaskStatus represents the status of a task
pub enum TaskStatus {
not_started
in_progress
completed
deferred
canceled
}
// TaskPriority represents the priority of a task
pub enum TaskPriority {
low
medium
high
urgent
}
// Task represents a task or to-do item in the CRM system
pub struct Task {
base.Base // Base struct for common fields (id u32, creation_time, mod_time)
pub mut:
// id u32 // Removed, provided by base.Base
name string
status TaskStatus
priority TaskPriority
due_date ourtime.OurTime // Optional
completed_at ourtime.OurTime // Optional
description string
parent_type string // Optional: Can be 'Account', 'Contact', 'Lead', 'Opportunity', 'Case'
parent_id u32 // Optional: Reference to the parent entity
account_id u32 // Optional: Reference to Account
contact_id u32 // Optional: Reference to Contact
reminder_time ourtime.OurTime // Optional
// created_at ourtime.OurTime // Removed, provided by base.Base.creation_time
// updated_at ourtime.OurTime // Removed, provided by base.Base.mod_time
assigned_user_id u32 // Reference to User
created_by_id u32 // Reference to User
}