package entities

import (
	"time"

	"gorm.io/gorm"
)

type Recording struct {
	Id                    uint           `gorm:"primaryKey"`
	ProjectFlockKandangId uint           `gorm:"column:project_flock_kandangs_id;not null;index"`
	RecordDatetime        time.Time      `gorm:"column:record_datetime;not null"`
	Day                   *int           `gorm:"column:day"`
	TotalDepletionQty     *float64       `gorm:"column:total_depletion_qty"`
	TotalDepletionCumQty  *float64       `gorm:"-"`
	CumDepletionRate      *float64       `gorm:"column:cum_depletion_rate"`
	DepletionRate         *float64       `gorm:"-"`
	CumIntake             *int           `gorm:"column:cum_intake"`
	FcrValue              *float64       `gorm:"column:fcr_value"`
	TotalChickQty         *float64       `gorm:"column:total_chick_qty"`
	HenDay                *float64       `gorm:"column:hen_day"`
	HenHouse              *float64       `gorm:"column:hen_house"`
	FeedIntake            *float64       `gorm:"column:feed_intake"`
	EggMass               *float64       `gorm:"column:egg_mass"`
	EggWeight             *float64       `gorm:"column:egg_weight"`
	CreatedBy             uint           `gorm:"column:created_by"`
	CreatedAt             time.Time      `gorm:"autoCreateTime"`
	UpdatedAt             time.Time      `gorm:"autoUpdateTime"`
	DeletedAt             gorm.DeletedAt `gorm:"index" json:"-"`

	ProjectFlockKandang *ProjectFlockKandang `gorm:"foreignKey:ProjectFlockKandangId;references:Id"`
	CreatedUser         *User                `gorm:"foreignKey:CreatedBy;references:Id"`
	Depletions          []RecordingDepletion `gorm:"foreignKey:RecordingId;references:Id"`
	Stocks              []RecordingStock     `gorm:"foreignKey:RecordingId;references:Id"`
	Eggs                []RecordingEgg       `gorm:"foreignKey:RecordingId;references:Id"`

	LatestApproval *Approval `gorm:"-" json:"-"`

	StandardHenDay       *float64 `gorm:"-"`
	StandardHenHouse     *float64 `gorm:"-"`
	StandardFeedIntake   *float64 `gorm:"-"`
	StandardMaxDepletion *float64 `gorm:"-"`
	StandardEggMass      *float64 `gorm:"-"`
	StandardEggWeight    *float64 `gorm:"-"`
	StandardFcr          *float64 `gorm:"-"`
	PopulationCanChange  *bool    `gorm:"-"`
	TransferExecuted     *bool    `gorm:"-"`
	IsTransition         *bool    `gorm:"-"`
	IsLaying             *bool    `gorm:"-"`
}
