package entities

import "time"

type StockLog struct {
	Id                 uint `gorm:"primaryKey;column:id"`
	ProductWarehouseId uint `gorm:"column:product_warehouse_id;not null;index"`
	CreatedBy          uint `gorm:"column:created_by;not null;index"`

	Increase float64 `gorm:"column:increase;type:numeric(15,3);default:0"`
	Decrease float64 `gorm:"column:decrease;type:numeric(15,3);default:0"`
	Stock    float64 `gorm:"column:stock;type:numeric(15,3);not null;default:0"`

	LoggableType string `gorm:"column:loggable_type;type:varchar(50);not null"`
	LoggableId   uint   `gorm:"column:loggable_id;not null"`

	Notes     string    `gorm:"column:notes;type:text"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`

	ProductWarehouse *ProductWarehouse `json:"product_warehouse,omitempty" gorm:"foreignKey:ProductWarehouseId;references:Id"`
	CreatedUser      *User             `json:"created_user,omitempty" gorm:"foreignKey:CreatedBy;references:Id"`
}
