package entities

import "time"

// DETAIL PRODUK
type StockTransferDetail struct {
	Id              uint64 `gorm:"primaryKey;autoIncrement"`
	StockTransferId uint64
	ProductId       uint64

	SourceProductWarehouseID *uint64 `gorm:"column:source_product_warehouse_id"`
	UsageQty                 float64 `gorm:"column:usage_qty;default:0"`   // Actual yang berhasil diambil
	PendingQty               float64 `gorm:"column:pending_qty;default:0"` // Yang pending (nunggu stock)
	DestProductWarehouseID   *uint64 `gorm:"column:dest_product_warehouse_id"`
	TotalQty                 float64 `gorm:"column:total_qty;default:0"`  // Total lot yang tersedia
	TotalUsed                float64 `gorm:"column:total_used;default:0"` // Yang sudah dipakai dari lot ini
	ExpenseNonstockId        *uint64 `gorm:"column:expense_nonstock_id"`
	CreatedAt                time.Time
	UpdatedAt                time.Time
	DeletedAt                *time.Time `gorm:"index"`

	// === RELATIONS ===
	StockTransfer          *StockTransfer              `gorm:"foreignKey:StockTransferId"`
	Product                *Product                    `gorm:"foreignKey:ProductId"`
	SourceProductWarehouse *ProductWarehouse           `gorm:"foreignKey:SourceProductWarehouseID"`
	DestProductWarehouse   *ProductWarehouse           `gorm:"foreignKey:DestProductWarehouseID"`
	ExpenseNonstock        *ExpenseNonstock            `gorm:"foreignKey:ExpenseNonstockId;references:Id"`
	DeliveryItems          []StockTransferDeliveryItem `gorm:"foreignKey:StockTransferDetailId"`
}
