apskel-pos-backend/internal/contract/inventory_contract.go
2025-08-14 00:38:26 +07:00

122 lines
4.5 KiB
Go

package contract
import (
"github.com/google/uuid"
"time"
)
type CreateInventoryRequest struct {
OutletID uuid.UUID `json:"outlet_id" validate:"required"`
ProductID uuid.UUID `json:"product_id" validate:"required"`
Quantity int `json:"quantity" validate:"min=0"`
ReorderLevel int `json:"reorder_level" validate:"min=0"`
}
type UpdateInventoryRequest struct {
Quantity *int `json:"quantity,omitempty" validate:"omitempty,min=0"`
ReorderLevel *int `json:"reorder_level,omitempty" validate:"omitempty,min=0"`
}
type AdjustInventoryRequest struct {
ProductID uuid.UUID `json:"product_id" validate:"required"`
OutletID uuid.UUID `json:"outlet_id" validate:"required"`
Delta int `json:"delta" validate:"required"` // Can be positive or negative
Reason string `json:"reason" validate:"required,min=1,max=255"`
}
type ListInventoryRequest struct {
OutletID *uuid.UUID `json:"outlet_id,omitempty"`
ProductID *uuid.UUID `json:"product_id,omitempty"`
CategoryID *uuid.UUID `json:"category_id,omitempty"`
LowStockOnly *bool `json:"low_stock_only,omitempty"`
ZeroStockOnly *bool `json:"zero_stock_only,omitempty"`
Search string `json:"search,omitempty"`
Page int `json:"page" validate:"required,min=1"`
Limit int `json:"limit" validate:"required,min=1,max=100"`
}
type InventoryResponse struct {
ID uuid.UUID `json:"id"`
OutletID uuid.UUID `json:"outlet_id"`
ProductID uuid.UUID `json:"product_id"`
Quantity int `json:"quantity"`
ReorderLevel int `json:"reorder_level"`
IsLowStock bool `json:"is_low_stock"`
UpdatedAt time.Time `json:"updated_at"`
// Related data (optional)
Product *ProductResponse `json:"product,omitempty"`
Outlet *OutletResponse `json:"outlet,omitempty"`
}
type ListInventoryResponse struct {
Inventory []InventoryResponse `json:"inventory"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Limit int `json:"limit"`
TotalPages int `json:"total_pages"`
}
type InventoryAdjustmentResponse struct {
InventoryID uuid.UUID `json:"inventory_id"`
ProductID uuid.UUID `json:"product_id"`
OutletID uuid.UUID `json:"outlet_id"`
PreviousQty int `json:"previous_quantity"`
NewQty int `json:"new_quantity"`
Delta int `json:"delta"`
Reason string `json:"reason"`
AdjustedAt time.Time `json:"adjusted_at"`
}
// Inventory Report Contracts
type InventoryReportSummaryResponse 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"`
TotalSoldProducts float64 `json:"total_sold_products"`
TotalSoldIngredients float64 `json:"total_sold_ingredients"`
OutletID string `json:"outlet_id"`
OutletName string `json:"outlet_name"`
GeneratedAt string `json:"generated_at"`
}
type InventoryReportDetailResponse struct {
Summary *InventoryReportSummaryResponse `json:"summary"`
Products []*InventoryProductDetailResponse `json:"products"`
Ingredients []*InventoryIngredientDetailResponse `json:"ingredients"`
}
type InventoryProductDetailResponse struct {
ID string `json:"id"`
ProductID string `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"`
TotalSold float64 `json:"total_sold"`
IsLowStock bool `json:"is_low_stock"`
IsZeroStock bool `json:"is_zero_stock"`
UpdatedAt string `json:"updated_at"`
}
type InventoryIngredientDetailResponse struct {
ID string `json:"id"`
IngredientID string `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"`
TotalSold float64 `json:"total_sold"`
IsLowStock bool `json:"is_low_stock"`
IsZeroStock bool `json:"is_zero_stock"`
UpdatedAt string `json:"updated_at"`
}