threefold.models_to_move.business #
fn Company.new #
fn Company.new() Company
new creates a new Company with default values
fn Payment.new #
fn Payment.new(payment_intent_id string, company_id u32, payment_plan string, setup_fee f64, monthly_fee f64, total_amount f64) Payment
new creates a new Payment
fn Product.new #
fn Product.new() Product
new creates a new Product with default values
fn ProductComponent.new #
fn ProductComponent.new() ProductComponent
new creates a new ProductComponent with default values
fn Sale.new #
fn Sale.new() Sale
new creates a new Sale with default values
fn SaleItem.new #
fn SaleItem.new() SaleItem
new creates a new SaleItem with default values
enum BusinessType #
enum BusinessType {
coop // Cooperative
single // Single entity
twin // Twin entity
starter // Starter business
global // Global business
}
BusinessType represents the type of business
enum CompanyStatus #
enum CompanyStatus {
pending_payment // Company created but payment not completed
active // Payment completed, company is active
suspended // Company suspended (e.g., payment issues)
inactive // Company deactivated
}
CompanyStatus represents the lifecycle of a company
enum PaymentStatus #
enum PaymentStatus {
pending // Payment is pending
processing // Payment is being processed
completed // Payment has been completed
failed // Payment has failed
refunded // Payment has been refunded
}
PaymentStatus represents the status of a payment
enum ProductStatus #
enum ProductStatus {
available // Product is available for purchase
unavailable // Product is not available
}
ProductStatus represents the status of a product
enum ProductType #
enum ProductType {
product // Physical or digital product
service // Service offering
}
ProductType represents the type of a product
enum SaleStatus #
enum SaleStatus {
pending // Sale is pending
completed // Sale has been completed
cancelled // Sale was cancelled
}
SaleStatus represents the status of a sale
struct Company #
struct Company {
pub mut:
id u32 // Unique company ID
name string // Company name
registration_number string // Official registration number
incorporation_date i64 // Incorporation date timestamp
fiscal_year_end string // Fiscal year end (e.g., "MM-DD")
email string // Company email
phone string // Company phone
website string // Company website
address string // Company address
business_type BusinessType // Type of business
industry string // Industry sector
description string // Company description
status CompanyStatus // Current status
created_at u64 // Creation timestamp
updated_at u64 // Last update timestamp
}
Company represents a business entity
fn (Company) name #
fn (mut c Company) name(name string) Company
name sets the company name (builder pattern)
fn (Company) registration_number #
fn (mut c Company) registration_number(registration_number string) Company
registration_number sets the registration number (builder pattern)
fn (Company) incorporation_date #
fn (mut c Company) incorporation_date(incorporation_date i64) Company
incorporation_date sets the incorporation date (builder pattern)
fn (Company) fiscal_year_end #
fn (mut c Company) fiscal_year_end(fiscal_year_end string) Company
fiscal_year_end sets the fiscal year end (builder pattern)
fn (Company) email #
fn (mut c Company) email(email string) Company
email sets the company email (builder pattern)
fn (Company) phone #
fn (mut c Company) phone(phone string) Company
phone sets the company phone (builder pattern)
fn (Company) website #
fn (mut c Company) website(website string) Company
website sets the company website (builder pattern)
fn (Company) address #
fn (mut c Company) address(address string) Company
address sets the company address (builder pattern)
fn (Company) business_type #
fn (mut c Company) business_type(business_type BusinessType) Company
business_type sets the business type (builder pattern)
fn (Company) industry #
fn (mut c Company) industry(industry string) Company
industry sets the industry (builder pattern)
fn (Company) description #
fn (mut c Company) description(description string) Company
description sets the description (builder pattern)
fn (Company) status #
fn (mut c Company) status(status CompanyStatus) Company
status sets the status (builder pattern)
fn (Company) is_active #
fn (c Company) is_active() bool
is_active returns true if the company is active
fn (Company) is_pending_payment #
fn (c Company) is_pending_payment() bool
is_pending_payment returns true if the company is pending payment
fn (Company) is_suspended #
fn (c Company) is_suspended() bool
is_suspended returns true if the company is suspended
fn (Company) is_inactive #
fn (c Company) is_inactive() bool
is_inactive returns true if the company is inactive
fn (Company) activate #
fn (mut c Company) activate()
activate activates the company
fn (Company) suspend #
fn (mut c Company) suspend()
suspend suspends the company
fn (Company) deactivate #
fn (mut c Company) deactivate()
deactivate deactivates the company
fn (Company) business_type_string #
fn (c Company) business_type_string() string
business_type_string returns the business type as a string
fn (Company) status_string #
fn (c Company) status_string() string
status_string returns the status as a string
struct Payment #
struct Payment {
pub mut:
id u32 // Unique payment ID
payment_intent_id string // Stripe payment intent ID for tracking
company_id u32 // Reference to the company this payment is for
payment_plan string // Payment plan ("monthly", "yearly", "two_year")
setup_fee f64 // Setup fee amount
monthly_fee f64 // Monthly fee amount
total_amount f64 // Total payment amount
currency string // Currency code (e.g., "usd")
status PaymentStatus // Payment status
stripe_customer_id ?string // Optional Stripe customer ID
created_at i64 // Creation timestamp
completed_at ?i64 // Completion timestamp
updated_at u64 // Last update timestamp
}
Payment represents a financial transaction
fn (Payment) payment_intent_id #
fn (mut p Payment) payment_intent_id(payment_intent_id string) Payment
payment_intent_id sets the payment intent ID (builder pattern)
fn (Payment) company_id #
fn (mut p Payment) company_id(company_id u32) Payment
company_id sets the company ID (builder pattern)
fn (Payment) payment_plan #
fn (mut p Payment) payment_plan(payment_plan string) Payment
payment_plan sets the payment plan (builder pattern)
fn (Payment) setup_fee #
fn (mut p Payment) setup_fee(setup_fee f64) Payment
setup_fee sets the setup fee (builder pattern)
fn (Payment) monthly_fee #
fn (mut p Payment) monthly_fee(monthly_fee f64) Payment
monthly_fee sets the monthly fee (builder pattern)
fn (Payment) total_amount #
fn (mut p Payment) total_amount(total_amount f64) Payment
total_amount sets the total amount (builder pattern)
fn (Payment) status #
fn (mut p Payment) status(status PaymentStatus) Payment
status sets the status (builder pattern)
fn (Payment) stripe_customer_id #
fn (mut p Payment) stripe_customer_id(stripe_customer_id ?string) Payment
stripe_customer_id sets the Stripe customer ID (builder pattern)
fn (Payment) currency #
fn (mut p Payment) currency(currency string) Payment
currency sets the currency (builder pattern)
fn (Payment) created_at #
fn (mut p Payment) created_at(created_at i64) Payment
created_at sets the creation timestamp (builder pattern)
fn (Payment) completed_at #
fn (mut p Payment) completed_at(completed_at ?i64) Payment
completed_at sets the completion timestamp (builder pattern)
fn (Payment) complete_payment #
fn (mut p Payment) complete_payment(stripe_customer_id ?string) Payment
complete_payment completes the payment with optional Stripe customer ID
fn (Payment) process_payment #
fn (mut p Payment) process_payment() Payment
process_payment marks payment as processing
fn (Payment) fail_payment #
fn (mut p Payment) fail_payment() Payment
fail_payment marks payment as failed
fn (Payment) refund_payment #
fn (mut p Payment) refund_payment() Payment
refund_payment refunds the payment
fn (Payment) is_completed #
fn (p Payment) is_completed() bool
is_completed checks if payment is completed
fn (Payment) is_pending #
fn (p Payment) is_pending() bool
is_pending checks if payment is pending
fn (Payment) is_processing #
fn (p Payment) is_processing() bool
is_processing checks if payment is processing
fn (Payment) has_failed #
fn (p Payment) has_failed() bool
has_failed checks if payment has failed
fn (Payment) is_refunded #
fn (p Payment) is_refunded() bool
is_refunded checks if payment is refunded
fn (Payment) status_string #
fn (p Payment) status_string() string
status_string returns the status as a string
fn (Payment) is_monthly_plan #
fn (p Payment) is_monthly_plan() bool
is_monthly_plan checks if this is a monthly payment plan
fn (Payment) is_yearly_plan #
fn (p Payment) is_yearly_plan() bool
is_yearly_plan checks if this is a yearly payment plan
fn (Payment) is_two_year_plan #
fn (p Payment) is_two_year_plan() bool
is_two_year_plan checks if this is a two-year payment plan
struct Product #
struct Product {
pub mut:
id u32 // Unique product ID
name string // Product name
description string // Product description
price f64 // Product price
type_ ProductType // Product type (product or service)
category string // Product category
status ProductStatus // Product status
max_amount u16 // Maximum amount available
purchase_till i64 // Purchase deadline timestamp
active_till i64 // Active until timestamp
components []ProductComponent // Product components
created_at u64 // Creation timestamp
updated_at u64 // Last update timestamp
}
Product represents a product or service offered
fn (Product) name #
fn (mut p Product) name(name string) Product
name sets the product name (builder pattern)
fn (Product) description #
fn (mut p Product) description(description string) Product
description sets the product description (builder pattern)
fn (Product) price #
fn (mut p Product) price(price f64) Product
price sets the product price (builder pattern)
fn (Product) type_ #
fn (mut p Product) type_(type_ ProductType) Product
type_ sets the product type (builder pattern)
fn (Product) category #
fn (mut p Product) category(category string) Product
category sets the product category (builder pattern)
fn (Product) status #
fn (mut p Product) status(status ProductStatus) Product
status sets the product status (builder pattern)
fn (Product) max_amount #
fn (mut p Product) max_amount(max_amount u16) Product
max_amount sets the maximum amount (builder pattern)
fn (Product) purchase_till #
fn (mut p Product) purchase_till(purchase_till i64) Product
purchase_till sets the purchase deadline (builder pattern)
fn (Product) active_till #
fn (mut p Product) active_till(active_till i64) Product
active_till sets the active until timestamp (builder pattern)
fn (Product) add_component #
fn (mut p Product) add_component(component ProductComponent) Product
add_component adds a component to the product (builder pattern)
fn (Product) components #
fn (mut p Product) components(components []ProductComponent) Product
components sets all components (builder pattern)
fn (Product) is_available #
fn (p Product) is_available() bool
is_available returns true if the product is available
fn (Product) is_service #
fn (p Product) is_service() bool
is_service returns true if the product is a service
fn (Product) is_product #
fn (p Product) is_product() bool
is_product returns true if the product is a physical/digital product
fn (Product) make_available #
fn (mut p Product) make_available()
make_available makes the product available
fn (Product) get_component_by_name #
fn (p Product) get_component_by_name(name string) ?ProductComponent
get_component_by_name finds a component by name
fn (Product) total_components #
fn (p Product) total_components() u32
total_components returns the total number of components
fn (Product) type_string #
fn (p Product) type_string() string
type_string returns the product type as a string
fn (Product) status_string #
fn (p Product) status_string() string
status_string returns the product status as a string
struct ProductComponent #
struct ProductComponent {
pub mut:
name string // Component name
description string // Component description
quantity u32 // Quantity of this component
}
ProductComponent represents a component or sub-part of a product
fn (ProductComponent) name #
fn (mut pc ProductComponent) name(name string) ProductComponent
name sets the component name (builder pattern)
fn (ProductComponent) description #
fn (mut pc ProductComponent) description(description string) ProductComponent
description sets the component description (builder pattern)
fn (ProductComponent) quantity #
fn (mut pc ProductComponent) quantity(quantity u32) ProductComponent
quantity sets the component quantity (builder pattern)
struct Sale #
struct Sale {
pub mut:
id u32 // Unique sale ID
company_id u32 // Company ID
buyer_id u32 // Buyer ID
transaction_id u32 // Transaction ID
total_amount f64 // Total amount of the sale
status SaleStatus // Status of the sale
sale_date i64 // Sale date timestamp
items []SaleItem // Items in the sale
notes string // Additional notes
created_at u64 // Creation timestamp
updated_at u64 // Last update timestamp
}
Sale represents a sale of products or services
fn (Sale) company_id #
fn (mut s Sale) company_id(company_id u32) Sale
company_id sets the company ID (builder pattern)
fn (Sale) buyer_id #
fn (mut s Sale) buyer_id(buyer_id u32) Sale
buyer_id sets the buyer ID (builder pattern)
fn (Sale) transaction_id #
fn (mut s Sale) transaction_id(transaction_id u32) Sale
transaction_id sets the transaction ID (builder pattern)
fn (Sale) total_amount #
fn (mut s Sale) total_amount(total_amount f64) Sale
total_amount sets the total amount (builder pattern)
fn (Sale) status #
fn (mut s Sale) status(status SaleStatus) Sale
status sets the status (builder pattern)
fn (Sale) sale_date #
fn (mut s Sale) sale_date(sale_date i64) Sale
sale_date sets the sale date (builder pattern)
fn (Sale) items #
fn (mut s Sale) items(items []SaleItem) Sale
items sets all items (builder pattern)
fn (Sale) add_item #
fn (mut s Sale) add_item(item SaleItem) Sale
add_item adds an item to the sale (builder pattern)
fn (Sale) notes #
fn (mut s Sale) notes(notes string) Sale
notes sets the notes (builder pattern)
fn (Sale) is_pending #
fn (s Sale) is_pending() bool
is_pending returns true if the sale is pending
fn (Sale) is_completed #
fn (s Sale) is_completed() bool
is_completed returns true if the sale is completed
fn (Sale) is_cancelled #
fn (s Sale) is_cancelled() bool
is_cancelled returns true if the sale is cancelled
fn (Sale) complete #
fn (mut s Sale) complete()
complete completes the sale
fn (Sale) cancel #
fn (mut s Sale) cancel()
cancel cancels the sale
fn (Sale) calculate_total #
fn (mut s Sale) calculate_total()
calculate_total calculates the total amount from all items
fn (Sale) get_item_by_product_id #
fn (s Sale) get_item_by_product_id(product_id u32) ?SaleItem
get_item_by_product_id finds an item by product ID
fn (Sale) total_items #
fn (s Sale) total_items() i32
total_items returns the total number of items
fn (Sale) status_string #
fn (s Sale) status_string() string
status_string returns the status as a string
struct SaleItem #
struct SaleItem {
pub mut:
product_id u32 // Product ID
name string // Denormalized product name at time of sale
quantity i32 // Quantity purchased
unit_price f64 // Price per unit at time of sale
subtotal f64 // Subtotal for this item
service_active_until ?i64 // Optional: For services, date until this specific purchased instance is active
}
SaleItem represents an individual item within a Sale
fn (SaleItem) product_id #
fn (mut si SaleItem) product_id(product_id u32) SaleItem
product_id sets the product ID (builder pattern)
fn (SaleItem) name #
fn (mut si SaleItem) name(name string) SaleItem
name sets the product name (builder pattern)
fn (SaleItem) quantity #
fn (mut si SaleItem) quantity(quantity i32) SaleItem
quantity sets the quantity (builder pattern)
fn (SaleItem) unit_price #
fn (mut si SaleItem) unit_price(unit_price f64) SaleItem
unit_price sets the unit price (builder pattern)
fn (SaleItem) subtotal #
fn (mut si SaleItem) subtotal(subtotal f64) SaleItem
subtotal sets the subtotal (builder pattern)
fn (SaleItem) service_active_until #
fn (mut si SaleItem) service_active_until(service_active_until ?i64) SaleItem
service_active_until sets the service active until date (builder pattern)
fn (SaleItem) calculate_subtotal #
fn (mut si SaleItem) calculate_subtotal()
calculate_subtotal calculates and sets the subtotal based on quantity and unit price
- fn Company.new
- fn Payment.new
- fn Product.new
- fn ProductComponent.new
- fn Sale.new
- fn SaleItem.new
- enum BusinessType
- enum CompanyStatus
- enum PaymentStatus
- enum ProductStatus
- enum ProductType
- enum SaleStatus
- struct Company
- fn name
- fn registration_number
- fn incorporation_date
- fn fiscal_year_end
- fn email
- fn phone
- fn website
- fn address
- fn business_type
- fn industry
- fn description
- fn status
- fn is_active
- fn is_pending_payment
- fn is_suspended
- fn is_inactive
- fn activate
- fn suspend
- fn deactivate
- fn business_type_string
- fn status_string
- struct Payment
- fn payment_intent_id
- fn company_id
- fn payment_plan
- fn setup_fee
- fn monthly_fee
- fn total_amount
- fn status
- fn stripe_customer_id
- fn currency
- fn created_at
- fn completed_at
- fn complete_payment
- fn process_payment
- fn fail_payment
- fn refund_payment
- fn is_completed
- fn is_pending
- fn is_processing
- fn has_failed
- fn is_refunded
- fn status_string
- fn is_monthly_plan
- fn is_yearly_plan
- fn is_two_year_plan
- struct Product
- struct ProductComponent
- struct Sale
- struct SaleItem