129 lines
3.6 KiB
Go
Raw Normal View History

2025-07-18 20:10:29 +07:00
package models
import (
"time"
"github.com/google/uuid"
)
type Inventory struct {
ID uuid.UUID
OutletID uuid.UUID
ProductID uuid.UUID
Quantity int
ReorderLevel int
UpdatedAt time.Time
}
type CreateInventoryRequest struct {
OutletID uuid.UUID
ProductID uuid.UUID
Quantity int
ReorderLevel int
}
type UpdateInventoryRequest struct {
Quantity *int
ReorderLevel *int
}
type InventoryAdjustmentRequest struct {
2025-08-13 23:36:31 +07:00
ProductID uuid.UUID
OutletID uuid.UUID
Delta int
Reason string
2025-07-18 20:10:29 +07:00
}
type InventoryResponse struct {
ID uuid.UUID
OutletID uuid.UUID
ProductID uuid.UUID
2025-08-13 21:02:26 +07:00
ProductName string
2025-07-18 20:10:29 +07:00
Quantity int
ReorderLevel int
IsLowStock bool
UpdatedAt time.Time
}
func (i *Inventory) IsLowStock() bool {
return i.Quantity <= i.ReorderLevel
}
func (i *Inventory) CanFulfillOrder(requestedQuantity int) bool {
return i.Quantity >= requestedQuantity
}
func (i *Inventory) AdjustQuantity(delta int) int {
newQuantity := i.Quantity + delta
if newQuantity < 0 {
newQuantity = 0
}
return newQuantity
}
2025-08-13 23:36:31 +07:00
// Inventory Report Models
type InventoryReportSummary struct {
TotalProducts int `json:"total_products"`
TotalIngredients int `json:"total_ingredients"`
TotalValue float64 `json:"total_value"`
LowStockProducts int `json:"low_stock_products"`
LowStockIngredients int `json:"low_stock_ingredients"`
ZeroStockProducts int `json:"zero_stock_products"`
ZeroStockIngredients int `json:"zero_stock_ingredients"`
2025-08-14 00:38:26 +07:00
TotalSoldProducts float64 `json:"total_sold_products"`
TotalSoldIngredients float64 `json:"total_sold_ingredients"`
2025-08-13 23:36:31 +07:00
OutletID uuid.UUID `json:"outlet_id"`
OutletName string `json:"outlet_name"`
GeneratedAt time.Time `json:"generated_at"`
}
type InventoryReportDetail struct {
Summary *InventoryReportSummary `json:"summary"`
Products []*InventoryProductDetail `json:"products"`
Ingredients []*InventoryIngredientDetail `json:"ingredients"`
}
type InventoryProductDetail struct {
ID uuid.UUID `json:"id"`
ProductID uuid.UUID `json:"product_id"`
ProductName string `json:"product_name"`
CategoryName string `json:"category_name"`
Quantity int `json:"quantity"`
ReorderLevel int `json:"reorder_level"`
UnitCost float64 `json:"unit_cost"`
TotalValue float64 `json:"total_value"`
2025-08-14 01:00:36 +07:00
TotalIn float64 `json:"total_in"`
TotalOut float64 `json:"total_out"`
2025-08-13 23:36:31 +07:00
IsLowStock bool `json:"is_low_stock"`
IsZeroStock bool `json:"is_zero_stock"`
UpdatedAt time.Time `json:"updated_at"`
}
type InventoryIngredientDetail struct {
ID uuid.UUID `json:"id"`
IngredientID uuid.UUID `json:"ingredient_id"`
IngredientName string `json:"ingredient_name"`
UnitName string `json:"unit_name"`
Quantity int `json:"quantity"`
ReorderLevel int `json:"reorder_level"`
UnitCost float64 `json:"unit_cost"`
TotalValue float64 `json:"total_value"`
2025-08-14 01:00:36 +07:00
TotalIn float64 `json:"total_in"`
TotalOut float64 `json:"total_out"`
2025-08-13 23:36:31 +07:00
IsLowStock bool `json:"is_low_stock"`
IsZeroStock bool `json:"is_zero_stock"`
UpdatedAt time.Time `json:"updated_at"`
}
type InventoryReportFilter struct {
OutletID *uuid.UUID `json:"outlet_id"`
CategoryID *uuid.UUID `json:"category_id"`
ShowLowStock *bool `json:"show_low_stock"`
ShowZeroStock *bool `json:"show_zero_stock"`
Search *string `json:"search"`
Limit *int `json:"limit"`
Offset *int `json:"offset"`
2025-08-14 00:38:26 +07:00
DateFrom *time.Time `json:"date_from"`
DateTo *time.Time `json:"date_to"`
2025-08-13 23:36:31 +07:00
}