2025-08-10 21:46:44 +07:00
|
|
|
package contract
|
|
|
|
|
|
|
|
|
|
import (
|
2025-09-13 02:17:51 +07:00
|
|
|
"time"
|
2025-08-10 21:46:44 +07:00
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-13 02:17:51 +07:00
|
|
|
// Request structures
|
|
|
|
|
type CreateProductRecipeRequest struct {
|
|
|
|
|
OutletID *uuid.UUID `json:"outlet_id"`
|
|
|
|
|
ProductID uuid.UUID `json:"product_id" validate:"required"`
|
|
|
|
|
VariantID *uuid.UUID `json:"variant_id"`
|
|
|
|
|
IngredientID uuid.UUID `json:"ingredient_id" validate:"required"`
|
|
|
|
|
Quantity float64 `json:"quantity" validate:"required,gt=0"`
|
|
|
|
|
WastePercentage float64 `json:"waste_percentage" validate:"min=0,max=100"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UpdateProductRecipeRequest struct {
|
|
|
|
|
OutletID *uuid.UUID `json:"outlet_id"`
|
|
|
|
|
VariantID *uuid.UUID `json:"variant_id"`
|
|
|
|
|
Quantity float64 `json:"quantity" validate:"required,gt=0"`
|
|
|
|
|
WastePercentage float64 `json:"waste_percentage" validate:"min=0,max=100"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GetProductRecipeByProductIDRequest struct {
|
|
|
|
|
ProductID uuid.UUID `json:"-"`
|
|
|
|
|
VariantID *uuid.UUID `json:"-"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BulkCreateProductRecipeRequest struct {
|
|
|
|
|
Recipes []CreateProductRecipeRequest `json:"recipes" validate:"required,min=1"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Response structures
|
|
|
|
|
type ProductRecipeResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
|
|
|
OutletID *uuid.UUID `json:"outlet_id"`
|
|
|
|
|
ProductID uuid.UUID `json:"product_id"`
|
|
|
|
|
VariantID *uuid.UUID `json:"variant_id"`
|
|
|
|
|
IngredientID uuid.UUID `json:"ingredient_id"`
|
|
|
|
|
Quantity float64 `json:"quantity"`
|
|
|
|
|
WastePercentage float64 `json:"waste_percentage"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
Product *ProductResponse `json:"product,omitempty"`
|
|
|
|
|
ProductVariant *ProductVariantResponse `json:"product_variant,omitempty"`
|
|
|
|
|
Ingredient *ProductRecipeIngredientResponse `json:"ingredient,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ProductRecipeIngredientResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
|
|
|
OutletID *uuid.UUID `json:"outlet_id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
UnitID uuid.UUID `json:"unit_id"`
|
|
|
|
|
Cost float64 `json:"cost"`
|
|
|
|
|
Stock float64 `json:"stock"`
|
|
|
|
|
IsSemiFinished bool `json:"is_semi_finished"`
|
|
|
|
|
IsActive bool `json:"is_active"`
|
|
|
|
|
Metadata map[string]interface{} `json:"metadata"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
Unit *ProductRecipeUnitResponse `json:"unit,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ProductRecipeUnitResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Symbol string `json:"symbol"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
2025-08-10 21:46:44 +07:00
|
|
|
}
|