model spec

This commit is contained in:
despiegk 2025-05-09 12:42:42 +03:00
parent d8b40b6995
commit 99bc97b104
16 changed files with 500 additions and 0 deletions

12
specs/models/base/base.v Normal file
View File

@ -0,0 +1,12 @@
module base
import freeflowuniverse.herolib.data.ourtime
// our attempt to make a message object which can be used for email as well as chat
pub struct Base {
pub mut:
id u32
creation_time ourtime.OurTime
mod_time ourtime.OurTime // Last modified time
comments []u32
}

View File

@ -0,0 +1,43 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// CompanyStatus represents the status of a company
pub enum CompanyStatus {
active
inactive
suspended
}
// BusinessType represents the type of a business
pub enum BusinessType {
coop
single
twin
starter
global
}
// Company represents a company registered in the Freezone
pub struct Company {
base.Base // Base struct for common fields
pub mut:
id u32
name string
registration_number string
incorporation_date ourtime.OurTime
fiscal_year_end string
email string
phone string
website string
address string
business_type BusinessType
industry string
description string
status CompanyStatus
created_at ourtime.OurTime
updated_at ourtime.OurTime
shareholders []Shareholder
}

View File

@ -0,0 +1,58 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// MeetingStatus represents the status of a meeting
pub enum MeetingStatus {
scheduled
completed
cancelled
}
// AttendeeRole represents the role of an attendee in a meeting
pub enum AttendeeRole {
coordinator
member
secretary
participant
advisor
admin
}
// AttendeeStatus represents the status of an attendee's participation
pub enum AttendeeStatus {
confirmed
pending
declined
}
// Meeting represents a board meeting of a company or other meeting
pub struct Meeting {
base.Base // Base struct for common fields
pub mut:
id u32
company_id u32
title string
date ourtime.OurTime
location string
description string
status MeetingStatus
minutes string
created_at ourtime.OurTime
updated_at ourtime.OurTime
attendees []Attendee
}
// Attendee represents an attendee of a board meeting
pub struct Attendee {
pub mut:
id u32
meeting_id u32
user_id u32
name string
role AttendeeRole
status AttendeeStatus
created_at ourtime.OurTime
}

View File

@ -0,0 +1,49 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
import freeflowuniverse.herolib.data.currency
// import freeflowuniverse.herolib.core.texttools { name_fix }
// ProductType represents the type of a product
pub enum ProductType {
product
service
}
// ProductStatus represents the status of a product
pub enum ProductStatus {
available
unavailable
}
// ProductComponent represents a component of a product
pub struct ProductComponent {
pub mut:
id u32
name string
description string
quantity int
created_at ourtime.OurTime
updated_at ourtime.OurTime
}
// Product represents a product or service offered by the Freezone
pub struct Product {
base.Base // Base struct for common fields
pub mut:
id u32
name string
description string
price currency.Currency
type_ ProductType
category string
status ProductStatus
created_at ourtime.OurTime
updated_at ourtime.OurTime
max_amount u16 // means allows us to define how many max of this there are
purchase_till ourtime.OurTime
active_till ourtime.OurTime // after this product no longer active if e.g. a service
components []ProductComponent
}

41
specs/models/biz/sale.v Normal file
View File

@ -0,0 +1,41 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
import freeflowuniverse.herolib.data.currency
// SaleStatus represents the status of a sale
pub enum SaleStatus {
pending
completed
cancelled
}
// Sale represents a sale of products or services
pub struct Sale {
base.Base // Base struct for common fields
pub mut:
id u32
company_id u32
buyer_name string
buyer_email string
total_amount currency.Currency
status SaleStatus
sale_date ourtime.OurTime
created_at ourtime.OurTime
updated_at ourtime.OurTime
items []SaleItem
}
pub struct SaleItem {
pub mut:
id u32
sale_id u32
product_id u32
name string
quantity int
unit_price currency.Currency
subtotal currency.Currency
active_till ourtime.OurTime // after this product no longer active if e.g. a service
}

View File

@ -0,0 +1,27 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// ShareholderType represents the type of shareholder
pub enum ShareholderType {
individual
corporate
}
// Shareholder represents a shareholder of a company
pub struct Shareholder {
base.Base // Base struct for common fields
pub mut:
id u32
company_id u32
user_id u32
name string
shares f64
percentage f64
type_ ShareholderType
since ourtime.OurTime
created_at ourtime.OurTime
updated_at ourtime.OurTime
}

19
specs/models/biz/user.v Normal file
View File

@ -0,0 +1,19 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// User represents a user in the Freezone Manager system
pub struct User {
base.Base // Base struct for common fields
pub mut:
id u32
name string
email string
password string
company string // here its just a best effort
role string
created_at ourtime.OurTime
updated_at ourtime.OurTime
}

51
specs/models/biz/vote.v Normal file
View File

@ -0,0 +1,51 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// VoteStatus represents the status of a vote
pub enum VoteStatus {
open
closed
cancelled
}
// Vote represents a voting item in the Freezone
pub struct Vote {
base.Base // Base struct for common fields
pub mut:
id u32
company_id u32
title string
description string
start_date ourtime.OurTime
end_date ourtime.OurTime
status VoteStatus
created_at ourtime.OurTime
updated_at ourtime.OurTime
options []VoteOption
ballots []Ballot
private_group []u32 // user id's only people who can vote
}
// VoteOption represents an option in a vote
pub struct VoteOption {
pub mut:
id u8
vote_id u32
text string
count int
min_valid int // min votes we need to make total vote count
}
// the vote as done by the user
pub struct Ballot {
pub mut:
id u32
vote_id u32
user_id u32
vote_option_id u8
shares_count int
created_at ourtime.OurTime
}

View File

@ -0,0 +1,36 @@
module circle
import base
// Define the RecordType enum
pub enum RecordType {
a
aaa
cname
mx
ns
ptr
soa
srv
txt
}
// Define the DomainNamespace struct, represents a full domain with all its records
pub struct DomainNameSpace {
base.Base
pub mut:
id u32
domain string
description string
records []Record
admins []u32 // IDs of the admins they need to exist as user in the circle
}
// Define the Record struct
pub struct Record {
pub mut:
name string
text string
category RecordType
addr []string
}

View File

@ -0,0 +1,12 @@
module circle
import base
// there is one group called "everyone" which is the default group for all members and their roles
pub struct Group {
base.Base
pub mut:
name string // name of the group in a circle, the one "everyone" is the default group
description string // optional description
members []u32 // pointers to the members of this group
}

View File

@ -0,0 +1,27 @@
module circle
// import freeflowuniverse.herolib.data.ourtime
import base
// Role represents the role of a member in a circle
pub enum Role {
admin
stakeholder
member
contributor
guest
external // means no right in this circle appart from we register this user
}
// Member represents a member of a circle
pub struct User {
base.Base
pub mut:
name string // name of the member as used in this circle
description string // optional description which is relevant to this circle
role Role // role of the member in the circle
contact_ids []u32 // IDs of contacts linked to this member
wallet_ids []u32 // IDs of wallets owned by this member which are relevant to this circle
pubkey string // public key of the member as used in this circle
}

View File

@ -0,0 +1,16 @@
module finance
import base
pub struct Account {
base.Base
pub mut:
name string // internal name of the account for the user
user_id u32 // user id of the owner of the account
description string // optional description of the account
ledger string // describes the ledger/blockchain where the account is located e.g. "ethereum", "bitcoin" or other institutions
address string // address of the account on the blockchain
pubkey string
assets []Asset
}

View File

@ -0,0 +1,31 @@
module finance
import base
pub enum AssetType {
erc20
erc721
erc1155
native
}
pub struct Asset {
base.Base
pub mut:
name string
description string
amount f64
address string // address of the asset on the blockchain or bank
asset_type AssetType // type of the asset
decimals u8 // number of decimals of the asset
}
pub fn (self Asset) index_keys() map[string]string {
return {
'name': self.name
}
}
pub fn (self Asset) ftindex_keys() map[string]string {
return map[string]string{}
}

View File

@ -0,0 +1,22 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// CalendarEvent represents a calendar event with all its properties
pub struct CalendarEvent {
base.Base
pub mut:
title string // Event title
description string // Event details
location string // Event location
start_time ourtime.OurTime
end_time ourtime.OurTime // End time
all_day bool // True if it's an all-day event
recurrence string // RFC 5545 Recurrence Rule (e.g., "FREQ=DAILY;COUNT=10")
attendees []u32 // List of contact id's
organizer u32 // The user (see circle) who created the event
status string // "CONFIRMED", "CANCELLED", "TENTATIVE" //TODO: make enum
color string // User-friendly color categorization, e.g., "red", "blue" //TODO: make enum
reminder []ourtime.OurTime // Reminder time before the event
}

View File

@ -0,0 +1,16 @@
module biz
import base
// import freeflowuniverse.herolib.data.ourtime
pub struct Contact {
base.Base
pub mut:
name string // name of the contact as we use in this circle
first_name string
last_name string
email []string
tel []string
}

View File

@ -0,0 +1,40 @@
module biz
import base
import freeflowuniverse.herolib.data.ourtime
// our attempt to make a message object which can be used for email as well as chat
pub struct Message {
base.Base // Base struct for common fields
pub mut:
// Database ID
id u32 // Database ID (assigned by DBHandler)
message_id string // Unique identifier for the email
folder string // The folder this email belongs to (inbox, sent, drafts, etc.)
message string // The email body content
attachments []Attachment // Any file attachments
send_time ourtime.OurTime
date i64 // Unix timestamp when the email was sent/received
size u32 // Size of the message in bytes
read bool // Whether the email has been read
flagged bool // Whether the email has been flagged/starred
// Header information
subject string
from []u32 // List of user IDs (or email addresses) who sent the email user needs to exist in circle where we use this
sender []u32
reply_to []u32
to []u32
cc []u32
bcc []u32
in_reply_to u32
}
// Attachment represents an email attachment
pub struct Attachment {
pub mut:
filename string
content_type string
hash string // Hash of the attachment data
}