269 lines
11 KiB
Go
269 lines
11 KiB
Go
package contract
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type PaymentMethodAnalyticsRequest struct {
|
|
OrganizationID uuid.UUID `form:"organization_id"`
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
DateFrom string `form:"date_from" validate:"required"`
|
|
DateTo string `form:"date_to" validate:"required"`
|
|
GroupBy string `form:"group_by,default=day" validate:"omitempty,oneof=day hour week month"`
|
|
}
|
|
|
|
// PaymentMethodAnalyticsResponse represents the response for payment method analytics
|
|
type PaymentMethodAnalyticsResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
DateFrom time.Time `json:"date_from"`
|
|
DateTo time.Time `json:"date_to"`
|
|
GroupBy string `json:"group_by"`
|
|
Summary PaymentMethodSummary `json:"summary"`
|
|
Data []PaymentMethodAnalyticsData `json:"data"`
|
|
}
|
|
|
|
// PaymentMethodSummary represents the summary of payment method analytics
|
|
type PaymentMethodSummary struct {
|
|
TotalAmount float64 `json:"total_amount"`
|
|
TotalOrders int64 `json:"total_orders"`
|
|
TotalPayments int64 `json:"total_payments"`
|
|
AverageOrderValue float64 `json:"average_order_value"`
|
|
}
|
|
|
|
type PaymentMethodAnalyticsData struct {
|
|
PaymentMethodID uuid.UUID `json:"payment_method_id"`
|
|
PaymentMethodName string `json:"payment_method_name"`
|
|
PaymentMethodType string `json:"payment_method_type"`
|
|
TotalAmount float64 `json:"total_amount"`
|
|
OrderCount int64 `json:"order_count"`
|
|
PaymentCount int64 `json:"payment_count"`
|
|
Percentage float64 `json:"percentage"`
|
|
}
|
|
|
|
type SalesAnalyticsRequest struct {
|
|
OrganizationID uuid.UUID
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
DateFrom string `form:"date_from" validate:"required"`
|
|
DateTo string `form:"date_to" validate:"required"`
|
|
GroupBy string `form:"group_by,default=day" validate:"omitempty,oneof=day hour week month"`
|
|
}
|
|
|
|
type SalesAnalyticsResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
DateFrom time.Time `json:"date_from"`
|
|
DateTo time.Time `json:"date_to"`
|
|
GroupBy string `json:"group_by"`
|
|
Summary SalesSummary `json:"summary"`
|
|
Data []SalesAnalyticsData `json:"data"`
|
|
}
|
|
|
|
// SalesSummary represents the summary of sales analytics
|
|
type SalesSummary struct {
|
|
TotalSales float64 `json:"total_sales"`
|
|
TotalOrders int64 `json:"total_orders"`
|
|
TotalItems int64 `json:"total_items"`
|
|
AverageOrderValue float64 `json:"average_order_value"`
|
|
TotalTax float64 `json:"total_tax"`
|
|
TotalDiscount float64 `json:"total_discount"`
|
|
NetSales float64 `json:"net_sales"`
|
|
}
|
|
|
|
// SalesAnalyticsData represents individual sales analytics data point
|
|
type SalesAnalyticsData struct {
|
|
Date time.Time `json:"date"`
|
|
Sales float64 `json:"sales"`
|
|
Orders int64 `json:"orders"`
|
|
Items int64 `json:"items"`
|
|
Tax float64 `json:"tax"`
|
|
Discount float64 `json:"discount"`
|
|
NetSales float64 `json:"net_sales"`
|
|
}
|
|
|
|
type PurchasingAnalyticsRequest struct {
|
|
OrganizationID uuid.UUID
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
DateFrom string `form:"date_from" validate:"required"`
|
|
DateTo string `form:"date_to" validate:"required"`
|
|
GroupBy string `form:"group_by,default=day" validate:"omitempty,oneof=day hour week month"`
|
|
}
|
|
|
|
type PurchasingAnalyticsResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
OutletName *string `json:"outlet_name,omitempty"`
|
|
DateFrom time.Time `json:"date_from"`
|
|
DateTo time.Time `json:"date_to"`
|
|
GroupBy string `json:"group_by"`
|
|
Summary PurchasingSummary `json:"summary"`
|
|
Data []PurchasingAnalyticsData `json:"data"`
|
|
IngredientData []PurchasingIngredientData `json:"ingredient_data"`
|
|
VendorData []PurchasingVendorData `json:"vendor_data"`
|
|
}
|
|
|
|
type PurchasingSummary struct {
|
|
TotalPurchases float64 `json:"total_purchases"`
|
|
TotalPurchaseOrders int64 `json:"total_purchase_orders"`
|
|
TotalQuantity float64 `json:"total_quantity"`
|
|
AveragePurchaseOrderValue float64 `json:"average_purchase_order_value"`
|
|
TotalIngredients int64 `json:"total_ingredients"`
|
|
TotalVendors int64 `json:"total_vendors"`
|
|
}
|
|
|
|
type PurchasingAnalyticsData struct {
|
|
Date time.Time `json:"date"`
|
|
Purchases float64 `json:"purchases"`
|
|
PurchaseOrders int64 `json:"purchase_orders"`
|
|
Quantity float64 `json:"quantity"`
|
|
Ingredients int64 `json:"ingredients"`
|
|
Vendors int64 `json:"vendors"`
|
|
}
|
|
|
|
type PurchasingIngredientData struct {
|
|
IngredientID uuid.UUID `json:"ingredient_id"`
|
|
IngredientName string `json:"ingredient_name"`
|
|
Quantity float64 `json:"quantity"`
|
|
TotalCost float64 `json:"total_cost"`
|
|
AverageUnitCost float64 `json:"average_unit_cost"`
|
|
PurchaseOrderCount int64 `json:"purchase_order_count"`
|
|
}
|
|
|
|
type PurchasingVendorData struct {
|
|
VendorID uuid.UUID `json:"vendor_id"`
|
|
VendorName string `json:"vendor_name"`
|
|
TotalCost float64 `json:"total_cost"`
|
|
PurchaseOrderCount int64 `json:"purchase_order_count"`
|
|
IngredientCount int64 `json:"ingredient_count"`
|
|
Quantity float64 `json:"quantity"`
|
|
}
|
|
|
|
// ProductAnalyticsRequest represents the request for product analytics
|
|
type ProductAnalyticsRequest struct {
|
|
OrganizationID uuid.UUID
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
DateFrom string `form:"date_from" validate:"required"`
|
|
DateTo string `form:"date_to" validate:"required"`
|
|
Limit int `form:"limit,default=1000" validate:"min=1,max=1000"`
|
|
}
|
|
|
|
// ProductAnalyticsResponse represents the response for product analytics
|
|
type ProductAnalyticsResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
DateFrom time.Time `json:"date_from"`
|
|
DateTo time.Time `json:"date_to"`
|
|
Data []ProductAnalyticsData `json:"data"`
|
|
}
|
|
|
|
type ProductAnalyticsData struct {
|
|
ProductID uuid.UUID `json:"product_id"`
|
|
ProductName string `json:"product_name"`
|
|
ProductSku string `json:"product_sku"`
|
|
CategoryID uuid.UUID `json:"category_id"`
|
|
CategoryName string `json:"category_name"`
|
|
CategoryOrder int `json:"category_order"`
|
|
QuantitySold int64 `json:"quantity_sold"`
|
|
Revenue float64 `json:"revenue"`
|
|
AveragePrice float64 `json:"average_price"`
|
|
OrderCount int64 `json:"order_count"`
|
|
StandardHppPerUnit float64 `json:"standard_hpp_per_unit"`
|
|
StandardHppTotal float64 `json:"standard_hpp_total"`
|
|
FifoHppPerUnit float64 `json:"fifo_hpp_per_unit"`
|
|
FifoHppTotal float64 `json:"fifo_hpp_total"`
|
|
MovingAverageHppPerUnit float64 `json:"moving_average_hpp_per_unit"`
|
|
MovingAverageHppTotal float64 `json:"moving_average_hpp_total"`
|
|
}
|
|
|
|
// ProductAnalyticsPerCategoryRequest represents the request for product analytics per category
|
|
type ProductAnalyticsPerCategoryRequest struct {
|
|
OrganizationID uuid.UUID
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
DateFrom string `form:"date_from" validate:"required"`
|
|
DateTo string `form:"date_to" validate:"required"`
|
|
}
|
|
|
|
// ProductAnalyticsPerCategoryResponse represents the response for product analytics per category
|
|
type ProductAnalyticsPerCategoryResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
DateFrom time.Time `json:"date_from"`
|
|
DateTo time.Time `json:"date_to"`
|
|
Data []ProductAnalyticsPerCategoryData `json:"data"`
|
|
}
|
|
|
|
type ProductAnalyticsPerCategoryData struct {
|
|
CategoryID uuid.UUID `json:"category_id"`
|
|
CategoryName string `json:"category_name"`
|
|
TotalRevenue float64 `json:"total_revenue"`
|
|
TotalQuantity int64 `json:"total_quantity"`
|
|
ProductCount int64 `json:"product_count"`
|
|
OrderCount int64 `json:"order_count"`
|
|
TotalStandardHpp float64 `json:"total_standard_hpp"`
|
|
TotalFifoHpp float64 `json:"total_fifo_hpp"`
|
|
TotalMovingAverageHpp float64 `json:"total_moving_average_hpp"`
|
|
}
|
|
|
|
// DashboardAnalyticsRequest represents the request for dashboard analytics
|
|
type DashboardAnalyticsRequest struct {
|
|
OrganizationID uuid.UUID
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
DateFrom string `form:"date_from" validate:"required"`
|
|
DateTo string `form:"date_to" validate:"required"`
|
|
}
|
|
|
|
// DashboardAnalyticsResponse represents the response for dashboard analytics
|
|
type DashboardAnalyticsResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
DateFrom time.Time `json:"date_from"`
|
|
DateTo time.Time `json:"date_to"`
|
|
Overview DashboardOverview `json:"overview"`
|
|
TopProducts []ProductAnalyticsData `json:"top_products"`
|
|
PaymentMethods []PaymentMethodAnalyticsData `json:"payment_methods"`
|
|
RecentSales []SalesAnalyticsData `json:"recent_sales"`
|
|
}
|
|
|
|
// DashboardOverview represents the overview data for dashboard
|
|
type DashboardOverview struct {
|
|
TotalSales float64 `json:"total_sales"`
|
|
TotalOrders int64 `json:"total_orders"`
|
|
AverageOrderValue float64 `json:"average_order_value"`
|
|
TotalCustomers int64 `json:"total_customers"`
|
|
VoidedOrders int64 `json:"voided_orders"`
|
|
RefundedOrders int64 `json:"refunded_orders"`
|
|
}
|
|
|
|
type ProfitLossAnalyticsRequest struct {
|
|
OrganizationID uuid.UUID
|
|
OutletID *string `form:"outlet_id,omitempty"`
|
|
Date string `form:"date" validate:"required"`
|
|
}
|
|
|
|
type ProfitLossAnalyticsResponse struct {
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
|
|
Date time.Time `json:"date"`
|
|
MainSummary []ProfitLossSummaryRow `json:"main_summary"`
|
|
OperationalExpenses []OperationalExpenseItem `json:"operational_expenses"`
|
|
OperationalExpensesTotal float64 `json:"operational_expenses_total"`
|
|
}
|
|
|
|
type ProfitLossSummaryRow struct {
|
|
ID string `json:"id"`
|
|
Label string `json:"label"`
|
|
IsBold bool `json:"is_bold"`
|
|
TodayNominal float64 `json:"today_nominal"`
|
|
TodayPct float64 `json:"today_pct"`
|
|
MtdNominal float64 `json:"mtd_nominal"`
|
|
MtdPct float64 `json:"mtd_pct"`
|
|
SubItems []ProfitLossSummaryRow `json:"sub_items,omitempty"`
|
|
}
|
|
|
|
type OperationalExpenseItem struct {
|
|
Item string `json:"item"`
|
|
Nominal float64 `json:"nominal"`
|
|
}
|