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 ¶
- Constants
- type Category
- type ComponentConsumeLogs
- type Customer
- type Disposal
- type ItemCost
- type JSONFloat
- type LanguageData
- type LanguageSettings
- type Log
- type LogDisposalMaterialAdd
- type LogDisposalProductAdd
- type LogMaterialAdd
- type LogMaterialConsume
- type LogMaterialInventoryReturn
- type LogOrderFinish
- type LogOrderItemRefund
- type LogOrderStart
- type LogProductIncrease
- type LogProductWaste
- type LogRefundOrder
- type LogSalesPerDayOrder
- type LogSalesPerDayRefund
- type LogWasteMaterial
- type LogWasteOrderItem
- type Material
- type MaterialDisposal
- type MaterialEntry
- type MaterialSettings
- type Order
- type OrderItem
- type OrderItemMaterial
- type OrderItemRefundMaterial
- type OrderItemRefundProductAdd
- type OrderQueueSettings
- type OrderSettings
- type PrinterSettings
- type Product
- type ProductDisposal
- type ProductEntry
- type SalesLogs
- type SalesPerDay
- type SalesPerDayOrder
- type SalesPerDayRefund
- type Settings
- type SubmitOrderMeta
- type Topic
- type WebsocketClientBaseMessage
- type WebsocketOrderFinishClientMessage
- type WebsocketOrderFinishServerMessage
- type WebsocketOrderSubmitServerMessage
- type WebsocketSubscribeClientMessage
- type WebsocketTopicClientMessage
- type WebsocketTopicServerMessage
Constants ¶
const ( TypeDisposalMaterial = "disposal_material" TypeDisposalProduct = "disposal_product" )
const ( LogTypeDisposalAdd = "disposal_add" LogTypeMaterialInventoryReturn = "material_inventory_return" LogTypeOrderItemRefunded = "order_item_refunded" LogTypeOrderStart = "order_Start" LogTypeOrderFinish = "order_finish" LogTypeMaterialConsume = "component_consume" LogTypeMaterialAdd = "component_add" LogTypeMaterialWaste = "material_waste" LogTypeProductIncrease = "product_increase" LogTypeSalesPerDayOrder = "sales_per_day_order" LogTypeSalesPerDayRefund = "sales_per_day_refund" )
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 []Product `json:"products"` // product ids
}
Category represents the category of products.
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"`
OrderItemIndex uint `json:"order_item_index" bson:"order_item_index"`
OrderId string `json:"order_id" bson:"order_id"`
Type string `json:"type" bson:"type"`
}
type Disposal ¶ added in v0.0.14
type Disposal struct {
Id string `json:"id" bson:"id"`
OrderId string `json:"order_id" bson:"order_id"`
Type string `json:"type" bson:"type"` // material or order_item
Quantity float64 `json:"quantity" bson:"quantity"`
Comment string `json:"comment" bson:"comment"`
}
Disposal used to store a returned order item or material which is too unique and modified to return to normal inventory state
type ItemCost ¶
type ItemCost struct {
ProductId string
ItemId string `json:"item_id" bson:"item_id"`
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 LanguageData ¶
type LanguageData struct {
ApiVersion string `json:"api_version" bson:"api_version"`
Code string `json:"code" bson:"code"`
Language string `json:"language" bson:"language"`
Orientation string `json:"orientation" bson:"orientation"`
Pack map[string]interface{} `json:"pack" bson:"pack"`
}
LanguageData is used to store the language mentioned details, stored in the language json file.
type LanguageSettings ¶
type LogDisposalMaterialAdd ¶ added in v0.0.16
type LogDisposalMaterialAdd struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
Disposal MaterialDisposal `json:"disposal" mapstructure:"disposal"`
}
type LogDisposalProductAdd ¶ added in v0.0.16
type LogDisposalProductAdd struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
Disposal ProductDisposal `json:"disposal" mapstructure:"disposal"`
}
type LogMaterialAdd ¶ added in v0.0.16
type LogMaterialAdd struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
MaterialId string `json:"material_id" bson:"material_id" mapstructure:"material_id"`
EntryId string `json:"entry_id" bson:"entry_id" mapstructure:"entry_id"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
}
type LogMaterialConsume ¶ added in v0.0.16
type LogMaterialConsume struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
MaterialId string `json:"material_id" bson:"material_id" mapstructure:"material_id"`
EntryId string `json:"entry_id" bson:"entry_id" mapstructure:"entry_id"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
ProductId string `json:"recipe_id" bson:"recipe_id" mapstructure:"recipe_id"`
OrderItemIndex int `json:"order_item_index" bson:"order_item_index" mapstructure:"order_item_index"`
Reason string `json:"reason" bson:"reason" mapstructure:"reason"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
}
type LogMaterialInventoryReturn ¶ added in v0.0.16
type LogMaterialInventoryReturn struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
Reason string `json:"reason" bson:"reason" mapstructure:"reason"`
}
type LogOrderFinish ¶ added in v0.0.16
type LogOrderFinish struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
Cost float64 `json:"cost" bson:"cost" mapstructure:"cost"`
SalePrice float64 `json:"sale_price" bson:"sale_price" mapstructure:"sale_price"`
Items []ItemCost `json:"items" bson:"items" mapstructure:"items"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
TimeConsumed time.Duration `json:"time_consumed" bson:"time_consumed" mapstructure:"time_consumed"`
}
type LogOrderItemRefund ¶ added in v0.0.16
type LogOrderItemRefund struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
ItemId string `json:"item_id" bson:"item_id" mapstructure:"item_id"`
Reason string `json:"reason" bson:"reason" mapstructure:"reason"`
}
type LogOrderStart ¶ added in v0.0.16
type LogProductIncrease ¶ added in v0.0.16
type LogProductIncrease struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
ProductId string `json:"product_id" bson:"product_id" mapstructure:"product_id"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
Source string `json:"source" bson:"source" mapstructure:"source"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
}
type LogProductWaste ¶ added in v0.0.16
type LogProductWaste struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
ProductId string `json:"product_id" bson:"product_id" mapstructure:"product_id"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
OrderItemId string `json:"order_item_id" bson:"order_item_id" mapstructure:"order_item_id"`
Reason string `json:"reason" bson:"reason" mapstructure:"reason"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
Item OrderItem `json:"item" bson:"item" mapstructure:"item"`
}
type LogRefundOrder ¶ added in v0.0.16
type LogSalesPerDayOrder ¶ added in v0.0.16
type LogSalesPerDayOrder struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
SalesPerDayOrder SalesPerDayOrder `json:"sales_per_day_order" bson:"sales_per_day_order" mapstructure:"sales_per_day_order"`
}
type LogSalesPerDayRefund ¶ added in v0.0.16
type LogSalesPerDayRefund struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
SalesPerDayRefund SalesPerDayRefund `json:"sales_per_day_refund" bson:"sales_per_day_refund" mapstructure:"sales_per_day_refund"`
}
type LogWasteMaterial ¶ added in v0.0.16
type LogWasteMaterial struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
MaterialId string `json:"material_id" bson:"material_id" mapstructure:"material_id"`
EntryId string `json:"entry_id" bson:"entry_id" mapstructure:"entry_id"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
Reason string `json:"reason" bson:"reason" mapstructure:"reason"`
IsConsume bool `json:"is_consume" bson:"is_consume" mapstructure:"is_consume"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
}
type LogWasteOrderItem ¶ added in v0.0.16
type LogWasteOrderItem struct {
Log `json:",inline" bson:",inline" mapstructure:",squash"`
Item OrderItem `json:"item" bson:"item" mapstructure:"item"`
OrderId string `json:"order_id" bson:"order_id" mapstructure:"order_id"`
Quantity float64 `json:"quantity" bson:"quantity" mapstructure:"quantity"`
Reason string `json:"reason" bson:"reason" mapstructure:"reason"`
}
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 MaterialDisposal ¶ added in v0.0.14
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"`
Customer Customer `json:"customer" bson:"customer"`
IsPayLater bool `json:"is_pay_later" bson:"is_pay_later"`
IsPaid bool `json:"is_paid" bson:"is_paid"`
// IsAutoStart determines whether the order is automatically started when it is submitted.
IsAutoStart bool `json:"is_auto_start" bson:"is_auto_start"`
// ServiceStyle dine_in, takeaway or delivery
IsDelivery bool `json:"is_delivery" bson:"is_delivery"`
IsTakeAway bool `json:"is_take_away" bson:"is_take_away"`
IsDineIn bool `json:"is_dine_in" bson:"is_dine_in"`
CustomData map[string]string `json:"custom_data" bson:"custom_data"`
}
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"`
Status string `json:"status" bson:"status"`
}
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"`
IsRefunded bool `json:"is_refunded" bson:"is_refunded"`
RefundReason string `json:"refund_reason" bson:"refund_reason"`
}
OrderItemMaterial represents the material, entry, and quantity associated with an order item.
type OrderItemRefundMaterial ¶ added in v0.0.14
type OrderItemRefundMaterial struct {
MaterialId string `json:"material_id" bson:"material_id"`
EntryId string `json:"entry_id" bson:"entry_id"`
InventoryReturnQty float64 `json:"inventory_return_qty" bson:"inventory_return_qty"`
DisposeQty float64 `json:"dispose_qty" bson:"dispose_qty"`
WasteQty float64 `json:"waste_qty" bson:"waste_qty"`
CostPerUnit float64 `json:"cost_per_unit" bson:"cost_per_unit"`
Comment string `json:"comment" bson:"comment"`
}
type OrderItemRefundProductAdd ¶ added in v0.0.14
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 PrinterSettings ¶
type PrinterSettings struct {
Host string `bson:"host" json:"host"`
}
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:"image_url" 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 ProductDisposal ¶ added in v0.0.14
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"`
Refunds []SalesPerDayRefund `json:"refunds" bson:"refunds"`
Costs float64 `json:"costs" bson:"costs"`
TotalSales float64 `json:"total_sales" bson:"total_sales"`
RefundsValue float64 `json:"refunds_value" bson:"refunds_value"`
}
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 SalesPerDayRefund ¶ added in v0.0.14
type SalesPerDayRefund struct {
OrderId string `json:"order_id" bson:"order_id"`
ItemId string `json:"order_item_id" bson:"order_item_id"`
ProductId string `json:"product_id" bson:"product_id"`
Reason string `json:"reason" bons:"reason"`
Amount float64 `json:"amount" bson:"amount"`
ItemCost float64 `json:"item_cost" bson:"item_cost"`
Destination string `json:"destination" bson:"destination"`
MaterialRerunds []OrderItemRefundMaterial `json:"material_refunds" bson:"material_refunds"`
ProductAdd []OrderItemRefundProductAdd `json:"products_add" bson:"products_add"`
}
type Settings ¶
type Settings struct {
Id string `bson:"id,omitempty" json:"id"`
Inventory MaterialSettings `bson:"inventory" json:"inventory"`
Orders OrderSettings `bson:"orders" json:"orders"`
Language LanguageSettings `bson:"language" json:"language"`
ReceiptPrinter PrinterSettings `bson:"receipt_printer" json:"receipt_printer"`
}
Settings represents the configuration settings structure
type SubmitOrderMeta ¶
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 WebsocketOrderSubmitServerMessage ¶
type WebsocketOrderSubmitServerMessage struct {
WebsocketTopicServerMessage `json:",inline"`
Order Order `json:"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"`
Date time.Time `json:"date"`
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.