Files
lti-api/internal/entities/product_warehouse.go
T
aguhh18 91b320d489 feat(BE-47,48,49,50): implement inventory adjustment system
- Extend DB schema with product_warehouses and stock_logs tables
- Implement stock adjustment API (increase/decrease operations)
- Add comprehensive validation for all adjustment operations
- Implement audit log system for each adjustment with history tracking
- Include transaction handling, DTOs, seeders, and proper error handling
- Add adjustment history API with pagination and filtering

TODO: Integration testing pending
2025-10-10 09:24:17 +07:00

24 lines
922 B
Go

package entities
import (
"time"
"gorm.io/gorm"
)
type ProductWarehouse struct {
Id uint `json:"id" gorm:"primaryKey;autoIncrement"`
ProductId uint `json:"product_id" gorm:"not null"`
WarehouseId uint `json:"warehouse_id" gorm:"not null"`
Quantity float64 `json:"quantity" gorm:"default:0"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
CreatedBy uint `json:"created_by" gorm:"not null"`
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
// Relations
Product Product `json:"product,omitempty" gorm:"foreignKey:ProductId;references:Id"`
Warehouse Warehouse `json:"warehouse,omitempty" gorm:"foreignKey:WarehouseId;references:Id"`
CreatedUser User `json:"created_user,omitempty" gorm:"foreignKey:CreatedBy;references:Id"`
}