package models

import (
	"time"

	"github.com/google/uuid"
)

type ProductIngredient struct {
	ID               uuid.UUID  `json:"id"`
	OrganizationID   uuid.UUID  `json:"organization_id"`
	OutletID         *uuid.UUID `json:"outlet_id"`
	ProductID        uuid.UUID  `json:"product_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"`
	Ingredient *Ingredient `json:"ingredient,omitempty"`
}

type CreateProductIngredientRequest struct {
	OutletID        *uuid.UUID `json:"outlet_id"`
	ProductID       uuid.UUID  `json:"product_id" validate:"required"`
	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 UpdateProductIngredientRequest struct {
	OutletID        *uuid.UUID `json:"outlet_id"`
	Quantity        float64    `json:"quantity" validate:"required,gt=0"`
	WastePercentage float64    `json:"waste_percentage" validate:"min=0,max=100"`
}

type ProductIngredientResponse struct {
	ID               uuid.UUID  `json:"id"`
	OrganizationID   uuid.UUID  `json:"organization_id"`
	OutletID         *uuid.UUID `json:"outlet_id"`
	ProductID        uuid.UUID  `json:"product_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"`
	Ingredient *Ingredient `json:"ingredient,omitempty"`
}
