package validation

import "time"

type (
	Stock struct {
		ProductWarehouseId uint    `json:"product_warehouse_id" validate:"required,number,min=1"`
		Qty                float64 `json:"qty" validate:"required,gte=0"`
	}

	Depletion struct {
		ProductWarehouseId       uint    `json:"product_warehouse_id" validate:"required,number,min=1"`
		SourceProductWarehouseId *uint   `json:"source_product_warehouse_id,omitempty" validate:"omitempty,number,min=1"`
		Qty                      float64 `json:"qty" validate:"required,gte=0"`
	}

	Egg struct {
		ProductWarehouseId uint     `json:"product_warehouse_id" validate:"required,number,min=1"`
		Qty                int      `json:"qty" validate:"required,number,min=0"`
		Weight             *float64 `json:"weight,omitempty" validate:"omitempty,gte=0"`
	}
)

type Create struct {
	ProjectFlockKandangId uint        `json:"project_flock_kandang_id" validate:"required,number,min=1"`
	RecordDate            *string     `json:"record_date,omitempty" validate:"omitempty,datetime=2006-01-02"`
	Stocks                []Stock     `json:"stocks" validate:"dive"`
	Depletions            []Depletion `json:"depletions,omitempty" validate:"omitempty,dive"`
	Eggs                  []Egg       `json:"eggs" validate:"omitempty,dive"`
}

type Update struct {
	Stocks     []Stock     `json:"stocks,omitempty" validate:"omitempty,dive"`
	Depletions []Depletion `json:"depletions,omitempty" validate:"omitempty,dive"`
	Eggs       []Egg       `json:"eggs,omitempty" validate:"omitempty,dive"`
}

type Query struct {
	Page                  int    `query:"page" validate:"omitempty,number,min=1"`
	Limit                 int    `query:"limit" validate:"omitempty,number,min=1"`
	Offset                int    `query:"-" validate:"omitempty,number,min=0"`
	ProjectFlockId        uint   `query:"project_flock_id" validate:"omitempty,number,min=1"`
	ProjectFlockKandangId uint   `query:"project_flock_kandang_id" validate:"omitempty,number,min=1"`
	AreaId                uint   `query:"area_id" validate:"omitempty,number,min=1"`
	LocationId            uint   `query:"location_id" validate:"omitempty,number,min=1"`
	KandangId             uint   `query:"kandang_id" validate:"omitempty,number,min=1"`
	ProjectFlockCategory  string `query:"project_flock_category" validate:"omitempty,oneof=GROWING LAYING"`
	ApprovalStatus        string `query:"approval_status" validate:"omitempty,max=50"`
	Search                string `query:"search" validate:"omitempty,max=100"`
}

type Approve struct {
	Action        string  `json:"action" validate:"required_strict"`
	ApprovableIds []uint  `json:"approvable_ids" validate:"required_strict,min=1,dive,gt=0"`
	Notes         *string `json:"notes,omitempty" validate:"omitempty,max=500"`
}

type GetRecordingNextDay struct {
	ProjectFlockKandangId uint       `json:"project_flock_kandang_id" query:"project_flock_kandang_id" validate:"required,number,min=1"`
	RecordTime            *string    `json:"record_date" query:"record_date" validate:"required,datetime=2006-01-02"`
	RecordTimeValue       *time.Time `query:"-" validate:"-"`
}
