Private
Public Access
bueno es parte del plan de implementacion para el caso de uso de gestion
de stock
This commit is contained in:
1 parent
24e746b1b7
commit
6ed8805e21
40 files changed
+2748
-31
No files matched your search
+14
-4
@@ -4,24 +4,34 @@ import (
|
||||
"time"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Stock struct {
|
||||
ID uint64 `gorm:"primaryKey" json:"id"`
|
||||
EmpresaID uint64 `gorm:"not null;default:1;index;uniqueIndex:uq_stock_empresa_repuesto_almacen,priority:1" json:"empresaId"`
|
||||
|
||||
Cantidad uint `gorm:"not null;default:0" json:"cantidad"`
|
||||
CantidadReservada uint `gorm:"not null;default:0" json:"cantidadReservada"`
|
||||
Cantidad float64 `gorm:"type:decimal(15,3);not null;default:0;check:cantidad >= 0" json:"cantidad"`
|
||||
CantidadReservada float64 `gorm:"type:decimal(15,3);not null;default:0;check:cantidad_reservada >= 0" json:"cantidadReservada"`
|
||||
RepuestoID uint64 `gorm:"not null;uniqueIndex:uq_stock_empresa_repuesto_almacen,priority:2" json:"repuestoId"`
|
||||
Repuesto Repuesto `gorm:"foreignKey:RepuestoID" json:"repuesto"`
|
||||
AlmacenID uint `gorm:"not null;uniqueIndex:uq_stock_empresa_repuesto_almacen,priority:3" json:"almacenId"`
|
||||
Almacen Almacen `gorm:"foreignKey:AlmacenID" json:"almacen,omitempty"`
|
||||
Observacion string `gorm:"type:varchar(60)" json:"observacion"`
|
||||
|
||||
Movmientos datatypes.JSONSlice[MovimientoStock] `gorm:"type:json" json:"movimientos,omitempty"`
|
||||
// MovimientosLegacy conserva el JSON histórico de la versión anterior.
|
||||
// La fuente de verdad pasa a ser la tabla movimiento_stock.
|
||||
MovimientosLegacy datatypes.JSONSlice[MovimientoStockLegacy] `gorm:"column:movimientos;type:json" json:"movimientosLegacy,omitempty"`
|
||||
Movimientos []MovimientoStock `gorm:"foreignKey:StockID" json:"-"`
|
||||
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
|
||||
}
|
||||
|
||||
type MovimientoStock struct {
|
||||
// MovimientoStockLegacy es el formato anterior embebido en stock.movimientos.
|
||||
// Solo se usa para migrar datos existentes.
|
||||
type MovimientoStockLegacy struct {
|
||||
Fecha time.Time `json:"fecha"`
|
||||
Tipo string `json:"tipo"`
|
||||
Cantidad float64 `json:"cantidad"`
|
||||
|
||||
Reference in new issue
Block a user