package models

import (
	"apskel-pos-be/internal/entities"
	"time"

	"github.com/google/uuid"
)

type Ingredient 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       entities.Metadata `json:"metadata"`
	CreatedAt      time.Time         `json:"created_at"`
	UpdatedAt      time.Time         `json:"updated_at"`

	// Relations
	Unit *Unit `json:"unit,omitempty"`
}

type CreateIngredientRequest struct {
	OrganizationID uuid.UUID         `json:"organization_id"`
	OutletID       *uuid.UUID        `json:"outlet_id"`
	Name           string            `json:"name" validate:"required,min=1,max=255"`
	UnitID         uuid.UUID         `json:"unit_id" validate:"required"`
	Cost           float64           `json:"cost" validate:"min=0"`
	Stock          float64           `json:"stock" validate:"min=0"`
	IsSemiFinished bool              `json:"is_semi_finished"`
	IsActive       bool              `json:"is_active"`
	Metadata       entities.Metadata `json:"metadata"`
}

type UpdateIngredientRequest struct {
	OutletID       *uuid.UUID        `json:"outlet_id"`
	Name           string            `json:"name" validate:"required,min=1,max=255"`
	UnitID         uuid.UUID         `json:"unit_id" validate:"required"`
	Cost           float64           `json:"cost" validate:"min=0"`
	Stock          float64           `json:"stock" validate:"min=0"`
	IsSemiFinished bool              `json:"is_semi_finished"`
	IsActive       bool              `json:"is_active"`
	Metadata       entities.Metadata `json:"metadata"`
}

type IngredientResponse 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       entities.Metadata `json:"metadata"`
	CreatedAt      time.Time         `json:"created_at"`
	UpdatedAt      time.Time         `json:"updated_at"`

	// Relations
	Unit *Unit `json:"unit,omitempty"`
}
