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

@@ -14,28 +14,30 @@ pub enum SaleStatus {
// Sale represents a sale of products or services
pub struct Sale {
base.Base // Base struct for common fields
base.Base // Provides id u32, creation_time, mod_time, comments []u32
pub mut:
id u32
company_id u32
// 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 ourtime.OurTime
updated_at 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
sale_id u32
product_id u32
name string
// 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
unit_price currency.Currency // Price per unit at time of sale
subtotal currency.Currency
active_till ourtime.OurTime // after this product no longer active if e.g. a service
service_active_until ourtime.OurTime? // Optional: For services, date until this specific purchased instance is active
}