package entities

import "time"

type AdjustmentStock struct {
	Id                 uint      `gorm:"primaryKey"`
	ProductWarehouseId uint      `gorm:"column:product_warehouse_id;not null"`
	PairedAdjustmentId *uint     `gorm:"column:paired_adjustment_id"`
	TransactionType    string    `gorm:"column:transaction_type;type:varchar(100);not null;default:LEGACY"`
	FunctionCode       string    `gorm:"column:function_code;type:varchar(64)"`
	TotalQty           float64   `gorm:"column:total_qty;default:0"`
	TotalUsed          float64   `gorm:"column:total_used;default:0"`
	UsageQty           float64   `gorm:"column:usage_qty;default:0"`
	PendingQty         float64   `gorm:"column:pending_qty;default:0"`
	Price              float64   `gorm:"column:price;type:numeric(15,3);default:0"`
	GrandTotal         float64   `gorm:"column:grand_total;type:numeric(15,3);default:0"`
	CreatedAt          time.Time `gorm:"column:created_at;autoCreateTime"`
	UpdatedAt          time.Time `gorm:"column:updated_at;autoUpdateTime"`
	AdjNumber          string    `gorm:"column:adj_number;uniqueIndex;not null"`

	ProductWarehouse *ProductWarehouse `gorm:"foreignKey:ProductWarehouseId;references:Id"`
	PairedAdjustment *AdjustmentStock  `gorm:"foreignKey:PairedAdjustmentId;references:Id"`
	StockLog         *StockLog         `gorm:"polymorphic:Loggable;polymorphicType:LoggableType;polymorphicId:LoggableId;polymorphicValue:ADJUSTMENT"`
}
