db/specs/modelsold/biz/sale.v

44 lines
1.3 KiB
V

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 // Provides id u32, creation_time, mod_time, comments []u32
pub mut:
// id u32 is provided by base.Base
company_id u32 // Reference to Company.id that made the sale
buyer_name string
buyer_email string
total_amount currency.Currency
status SaleStatus
sale_date ourtime.OurTime
// created_at is provided by base.Base.creation_time
// updated_at is provided by base.Base.mod_time
items []SaleItem
}
// SaleItem represents an individual item within a Sale.
// Its lifecycle is tied to the parent Sale.
pub struct SaleItem {
pub mut:
// id u32 - Removed, component of Sale
// sale_id u32 - Removed, implicit link to parent Sale
product_id u32 // Reference to Product.id
name string // Denormalized product name at time of sale
quantity int
unit_price currency.Currency // Price per unit at time of sale
subtotal currency.Currency
service_active_until ourtime.OurTime? // Optional: For services, date until this specific purchased instance is active
}