package models

import (
	"time"

	"github.com/google/uuid"
)

type ProductRecipe 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"`

	// Relations
	Product        *Product        `json:"product,omitempty"`
	ProductVariant *ProductVariant `json:"product_variant,omitempty"`
	Ingredient     *Ingredient     `json:"ingredient,omitempty"`
}

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 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"`

	// Relations
	Product        *Product        `json:"product,omitempty"`
	ProductVariant *ProductVariant `json:"product_variant,omitempty"`
	Ingredient     *Ingredient     `json:"ingredient,omitempty"`
}