avance creando entidades

This commit is contained in:
fede committed 2026-05-14 17:21:28 -03:00
1 parent 1d755376f6
commit 7cadb9c84b
25 files changed
+200 -47

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
package models
type Almacen struct {
ID string `gorm:"primaryKey;type:varchar(5)" json:"id"`
Razon string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"razon"`
EmpresaID string `gorm:"type:varchar(3);index;not null" json:"empresaId"`
Estantes []Estante `gorm:"foreignKey:AlmacenID" json:"estantes,omitempty"`
}
func (Almacen) TableName() string {
return "almacen"
}
+13
View File
@@ -0,0 +1,13 @@
package models
type Cajon struct {
ID string `gorm:"primaryKey;type:varchar(30)" json:"id"`
Razon string `gorm:"not null;type:varchar(70)" json:"razon"`
Codigo string `gorm:"not null;type:varchar(5)" json:"codigo"`
EstanteID string `gorm:"type:varchar(30);index;not null" json:"estanteId"`
Stocks []Stock `gorm:"foreignKey:CajonID" json:"stocks,omitempty"`
}
func (Cajon) TableName() string {
return "cajon"
}
+13
View File
@@ -0,0 +1,13 @@
package models
type Estante struct {
ID string `gorm:"primaryKey;type:varchar(30)" json:"id"`
Razon string `gorm:"not null;type:varchar(70)" json:"razon"`
Codigo string `gorm:"not null;type:varchar(5)" json:"codigo"`
AlmacenID string `gorm:"type:varchar(5);index;not null" json:"almacenId"`
Cajones []Cajon `gorm:"foreignKey:EstanteID" json:"cajones,omitempty"`
}
func (Estante) TableName() string {
return "estante"
}
+23
View File
@@ -0,0 +1,23 @@
package models
import (
"time"
models_seguridad "repuestera_back/models/seguridad"
)
type Factura struct {
ID uint64 `gorm:"primaryKey" json:"id"`
EmpresaID string `gorm:"type:varchar(3);index;not null" json:"empresaId"`
UsuarioID uint64 `gorm:"index;not null" json:"usuarioId"`
Fecha time.Time `gorm:"not null" json:"fecha"`
Cliente string `gorm:"type:varchar(100)" json:"cliente"`
Total float64 `gorm:"not null;default:0" json:"total"`
Detalles []FacturaDetalle `gorm:"type:json" json:"detalles,omitempty"`
Empresa models_seguridad.Empresa `gorm:"foreignKey:EmpresaID" json:"empresa,omitempty"`
Usuario models_seguridad.Usuario `gorm:"foreignKey:UsuarioID" json:"usuario,omitempty"`
}
func (Factura) TableName() string {
return "factura"
}
+8
View File
@@ -0,0 +1,8 @@
package models
type FacturaDetalle struct {
ProductoID uint64 `json:"productoId"`
Cantidad uint `json:"cantidad"`
PrecioUnitario float64 `json:"precioUnitario"`
Subtotal float64 `json:"subtotal"`
}
+11
View File
@@ -0,0 +1,11 @@
package models
type Marca struct {
ID string `gorm:"primaryKey;type:varchar(3)" json:"id"`
Razon string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"razon"`
Productos []Producto `gorm:"foreignKey:MarcaID"`
}
func (Marca) TableName() string {
return "marca"
}
+23
View File
@@ -0,0 +1,23 @@
package models
import (
"time"
models_seguridad "repuestera_back/models/seguridad"
)
type OrdenCompra struct {
ID uint64 `gorm:"primaryKey" json:"id"`
EmpresaID string `gorm:"type:varchar(3);index;not null" json:"empresaId"`
UsuarioID uint64 `gorm:"index;not null" json:"usuarioId"`
Fecha time.Time `gorm:"not null" json:"fecha"`
Proveedor string `gorm:"type:varchar(100)" json:"proveedor"`
Total float64 `gorm:"not null;default:0" json:"total"`
Detalles []OrdenCompraDetalle `gorm:"type:json" json:"detalles,omitempty"`
Empresa models_seguridad.Empresa `gorm:"foreignKey:EmpresaID" json:"empresa,omitempty"`
Usuario models_seguridad.Usuario `gorm:"foreignKey:UsuarioID" json:"usuario,omitempty"`
}
func (OrdenCompra) TableName() string {
return "orden_compra"
}
+8
View File
@@ -0,0 +1,8 @@
package models
type OrdenCompraDetalle struct {
ProductoID uint64 `json:"productoId"`
Cantidad uint `json:"cantidad"`
PrecioUnitario float64 `json:"precioUnitario"`
Subtotal float64 `json:"subtotal"`
}
+18
View File
@@ -0,0 +1,18 @@
package models
import (
models_seguridad "repuestera_back/models/seguridad"
)
type Producto struct {
ID uint64 `gorm:"primaryKey" json:"id"`
Descripcion string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"razon"`
MarcaID string `gorm:"type:varchar(3);index" json:"marcaId"`
Aliases []string `gorm:"type:json" json:"aliases,omitempty"`
Empresas []models_seguridad.Empresa`gorm:"many2many:producto_empresa;" json:"empresas,omitempty"`
Stocks []Stock `gorm:"foreignKey:ProductoID" json:"stocks,omitempty"`
}
func (Producto) TableName() string {
return "producto"
}
@@ -1,4 +1,4 @@
package models
package models_seguridad
type Empresa struct {
ID string `gorm:"primaryKey;type:varchar(3)" json:"id"`
@@ -1,4 +1,4 @@
package models
package models_seguridad
import (
"time"
@@ -1,4 +1,4 @@
package models
package models_seguridad
import (
"time"
@@ -1,4 +1,4 @@
package models
package models_seguridad
import (
"time"
+15
View File
@@ -0,0 +1,15 @@
package models
type Stock struct {
ID uint64 `gorm:"primaryKey" json:"id"`
ProductoID uint64 `gorm:"index;not null" json:"productoId"`
CajonID string `gorm:"type:varchar(30);index;not null" json:"cajonId"`
Cantidad uint `gorm:"not null;default:0" json:"cantidad"`
Producto Producto `gorm:"foreignKey:ProductoID" json:"producto,omitempty"`
Cajon Cajon `gorm:"foreignKey:CajonID" json:"cajon,omitempty"`
}
func (Stock) TableName() string {
return "stock"
}