Documentation ¶
Overview ¶
Package models contains the data models for the application.
The models are used to store data in the database and to marshal/unmarshal data to/from JSON.
The models are divided into the following categories:
- Sales: Models related to sales, such as SalesPerDay and SalesPerDayOrder.
- Items: Models related to items, such as ItemCost and OrderItem.
- Orders: Models related to orders, such as Order and OrderItem.
- Materials: Models related to materials, such as Material and MaterialEntry.
- Products: Models related to products, such as Product and ProductEntry.
- SalesLogs: Models related to sales logs, such as SalesLogs.
Package models contains the data models for the application.
The models are used to store data in the database and to marshal/unmarshal data to/from JSON.
Index ¶
- type Category
- type CategoryProduct
- type ComponentConsumeLogs
- type ItemCost
- type JSONFloat
- type Material
- type MaterialEntry
- type MaterialSettings
- type Order
- type OrderItem
- type OrderItemMaterial
- type OrderQueueSettings
- type OrderSettings
- type Product
- type ProductEntry
- type SalesLogs
- type SalesPerDay
- type SalesPerDayOrder
- type Settings
- type Topic
- type WebsocketClientBaseMessage
- type WebsocketOrderFinishClientMessage
- type WebsocketOrderFinishServerMessage
- type WebsocketSubscribeClientMessage
- type WebsocketTopicClientMessage
- type WebsocketTopicServerMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct { Id string `json:"id" bson:"id"` Name string `json:"name"` Products []CategoryProduct `json:"products"` // product ids }
Category represents the category of products.
type CategoryProduct ¶
type CategoryProduct struct { Id string `json:"id" bson:"id"` Name string `json:"name" bson:"name"` }
CategoryProduct represents the product in a category.
type ComponentConsumeLogs ¶
type ComponentConsumeLogs struct { Id string `json:"id,omitempty" bson:"id,omitempty"` Date time.Time `json:"date" bson:"date"` Name string `json:"component_name" bson:"name"` Quantity float32 `json:"quantity" bson:"quantity"` Company string `json:"company" bson:"company"` ItemName string `json:"item_name" bson:"item_name"` ItemOrderIndex uint `json:"item_order_index" bson:"item_order_index"` OrderId string `json:"order_id" bson:"order_id"` }
type ItemCost ¶
type ItemCost struct { RecipeId string ItemName string Cost float64 SalePrice float64 Quantity float64 Components []struct { ComponentName string ComponentId string EntryId string Quantity float64 Cost float64 } DownstreamCost []ItemCost }
ItemCost represents the cost of an item, including the recipe cost, sale price, quantity, and the costs of the components.
type JSONFloat ¶
type JSONFloat float64
JSONFloat is a float64 that is marshaled to JSON as a string to avoid the JSON number type limitations.
func (JSONFloat) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Material ¶
type Material struct { Id string `json:"id,omitempty" bson:"id,omitempty"` Name string `json:"name"` Entries []MaterialEntry `json:"entries" bson:"entries"` Quantity float64 `json:"quantity"` Settings MaterialSettings `json:"settings" bson:"settings"` Unit string `json:"unit" bson:"unit"` }
Material represents a material with its details, including entries and settings.
type MaterialEntry ¶
type MaterialEntry struct { Id string `json:"id,omitempty" bson:"id,omitempty"` PurchaseQuantity float32 `json:"purchase_quantity" bson:"purchase_quantity"` PurchasePrice float64 `json:"purchase_price" bson:"price"` Quantity float32 `json:"quantity"` Company string `json:"company"` SKU string `json:"sku"` ExpirationDate time.Time `json:"expiration_date" bson:"expiration_date"` }
MaterialEntry represents an entry of material, detailing purchase and quantity information.
type MaterialSettings ¶
type MaterialSettings struct {
StockAlertTreshold float64 `json:"stock_alert_treshold" bson:"stock_alert_treshold"`
}
MaterialSettings represents settings associated with a material, such as stock alert threshold.
type Order ¶
type Order struct { SubmittedAt time.Time `json:"submitted_at" bson:"submitted_at"` Id string `json:"id" bson:"id,omitempty"` DisplayId string `json:"display_id" bson:"display_id"` Items []OrderItem `json:"items" bson:"items"` Discount float64 `json:"discount" bson:"discount"` State string `json:"state" bson:"state"` StartedAt time.Time `json:"started_at" bson:"started_at"` Comment string `json:"comment" bson:"comment"` Cost float64 `json:"cost" bson:"cost"` SalePrice float64 `json:"sale_price" bson:"sale_price"` IsPayLater bool `json:"is_pay_later" bson:"is_pay_later"` IsPaid bool `json:"is_paid" bson:"is_paid"` }
Order represents a customer order, containing order details, items, and financial information.
type OrderItem ¶
type OrderItem struct { Id string `json:"id" bson:"id"` Product Product `json:"product"` Price float64 `json:"price" bson:"price"` Materials []OrderItemMaterial `json:"materials" bson:"materials"` IsConsumeFromReady bool `json:"is_consume_from_ready"` SubItems []OrderItem `json:"sub_items" bson:"sub_items"` Quantity float64 `json:"quantity" bson:"quantity"` Comment string `json:"comment" bson:"comment"` SalePrice float64 `json:"sale_price" bson:"sale_price"` Cost float64 `json:"cost" bson:"cost"` }
OrderItem represents an item in an order, including product details, materials, and pricing.
type OrderItemMaterial ¶
type OrderItemMaterial struct { Material Material `json:"material"` Entry MaterialEntry `json:"entry"` Quantity float64 `json:"quantity" bson:"quantity"` }
OrderItemMaterial represents the material, entry, and quantity associated with an order item.
type OrderQueueSettings ¶
type OrderQueueSettings struct { Prefix string `json:"prefix" bson:"prefix"` Next uint32 `json:"next" bson:"next"` }
OrderQueueSettings represents the configuration settings for an order queue
type OrderSettings ¶
type OrderSettings struct {
Queues []OrderQueueSettings `json:"queues" bson:"queues"`
}
OrderSettings represents the configuration settings for orders
type Product ¶
type Product struct { Id string `bson:"id,omitempty" json:"id"` Name string `bson:"name" json:"name"` Materials []Material `bson:"materials" json:"materials"` SubProducts []Product `bson:"sub_products" json:"sub_products"` Entries []ProductEntry `bson:"entries" json:"entries"` Price float64 `bson:"price" json:"price"` ImageURL string `bson:"imageurl" json:"image_url"` Unit string `bson:"unit" json:"unit"` Quantity float64 `bson:"quantity" json:"quantity"` Ready float64 `bson:"ready" json:"ready"` }
Product represents a product with its details, including materials, entries, and pricing.
type ProductEntry ¶
type ProductEntry struct { Id string `json:"id,omitempty" bson:"id,omitempty"` PurchaseQuantity float32 `json:"purchase_quantity" bson:"purchase_quantity"` PurchasePrice float64 `json:"purchase_price"` Quantity float32 `json:"quantity"` Company string `json:"company"` Unit string `json:"unit"` SKU string `json:"sku"` }
ProductEntry represents an entry of a product, detailing purchase and quantity information.
type SalesLogs ¶
type SalesLogs struct { Id string `json:"id" bson:"id,omitempty"` SalePrice JSONFloat `json:"sale_price" bson:"sale_price"` Items []ItemCost OrderId string `json:"order_id"` TimeConsumed time.Time `json:"time_consumed"` Type string `json:"type"` Date time.Time `json:"date"` Cost JSONFloat `json:"cost"` }
SalesLogs represents logs of sales, capturing sale price, items, and consumption details.
type SalesPerDay ¶
type SalesPerDay struct { Id string `json:"id" bson:"id,omitempty"` Date string `json:"date" bson:"date"` Orders []SalesPerDayOrder `json:"orders" bson:"orders"` Costs float64 `json:"costs" bson:"costs"` TotalSales float64 `json:"total_sales" bson:"total_sales"` }
SalesPerDay aggregates sales data for a specific day, including total costs and sales.
type SalesPerDayOrder ¶
type SalesPerDayOrder struct { Order Order `json:"order" bson:"order,inline"` Costs []ItemCost `json:"costs" bson:"costs"` }
SalesPerDayOrder represents an order and its associated costs for a specific day.
type Settings ¶
type Settings struct { Id string `bson:"id,omitempty" json:"id"` Inventory struct { DefaultInventoryQuantityWarn float64 `json:"default_inventory_quantity_warn" bson:"default_inventory_quantity_warn"` } `bson:"inventory" json:"inventory"` Orders OrderSettings `bson:"orders" json:"orders"` }
Settings represents the configuration settings structure
type WebsocketClientBaseMessage ¶
type WebsocketClientBaseMessage struct {
Type string `json:"type"`
}
WebsocketClientBaseMessage is a base message for all client messages.
type WebsocketOrderFinishClientMessage ¶
type WebsocketOrderFinishClientMessage struct {
OrderId string `json:"order_id"`
}
WebsocketOrderFinishClientMessage is a message sent by the client to finish an order.
type WebsocketOrderFinishServerMessage ¶
type WebsocketOrderFinishServerMessage struct { WebsocketTopicServerMessage `json:",inline"` OrderId string `json:"order_id"` }
WebsocketOrderFinishServerMessage is a message sent by the server to finish an order.
type WebsocketSubscribeClientMessage ¶
type WebsocketSubscribeClientMessage struct { WebsocketClientBaseMessage `json:",inline"` TopicName string `json:"topic_name"` }
WebsocketSubscribeClientMessage is a message sent by the client to subscribe to a specific topic.
type WebsocketTopicClientMessage ¶
type WebsocketTopicClientMessage struct {
TopicName string `json:"topic_name"`
}
WebsocketTopicClientMessage is a message sent by the client to send a message to a specific topic.
type WebsocketTopicServerMessage ¶
type WebsocketTopicServerMessage struct { Type string `json:"type"` TopicName string `json:"topic_name"` Severity string `json:"severity"` Message string `json:"message"` Key string `json:"key"` // unqique label to prevent message duplications }
WebsocketTopicServerMessage is a message sent by the server to a specific topic.