package entities

import (
	"time"
)

type MarketingDeliveryProduct struct {
	Id                              uint       `gorm:"primaryKey;autoIncrement"`
	MarketingProductId              uint       `gorm:"uniqueIndex;not null"`
	ProductWarehouseId              uint       `gorm:"not null"`
	AttributedProjectFlockKandangId *uint      `gorm:"->;column:attributed_project_flock_kandang_id"`
	UnitPrice                       float64    `gorm:"type:numeric(15,3)"`
	TotalWeight                     float64    `gorm:"type:numeric(15,3)"`
	AvgWeight                       float64    `gorm:"type:numeric(15,3)"`
	WeightPerConvertion             *float64   `gorm:"type:numeric(15,3)"`
	TotalPrice                      float64    `gorm:"type:numeric(15,3)"`
	DeliveryDate                    *time.Time `gorm:"type:timestamptz"`
	VehicleNumber                   string     `gorm:"type:varchar(50)"`

	// FIFO Fields
	UsageQty   float64    `gorm:"type:numeric(15,3);default:0;not null"`
	PendingQty float64    `gorm:"type:numeric(15,3);default:0;not null"`
	CreatedAt  *time.Time `gorm:"type:timestamptz;not null"`

	MarketingProduct              MarketingProduct     `gorm:"foreignKey:MarketingProductId;references:Id"`
	AttributedProjectFlockKandang *ProjectFlockKandang `gorm:"foreignKey:AttributedProjectFlockKandangId;references:Id"`
}
