termine de crear los modelos por una segunda vez

This commit is contained in:
fede committed 2026-08-06 19:09:08 -03:00
1 parent 152a40ca19
commit 8a1ea71805
12 files changed
+45 -13

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ package models
type Almacen struct { type Almacen struct {
ID string `gorm:"primaryKey;type:varchar(5)" json:"id"` ID string `gorm:"primaryKey;type:varchar(5)" json:"id"`
Ubicacion string `gorm:"type:varchar(40)" json:"ubicacion"` Ubicacion string `gorm:"type:varchar(40)" json:"ubicacion"`
Stocks []Stock `gorm:"foreignKey:RepuestoID" json:"stocks,omitempty"` Stocks []Stock `gorm:"foreignKey:repuestoID" json:"stocks,omitempty"`
} }
func (Almacen) TableName() string { func (Almacen) TableName() string {
+2 -1
View File
@@ -12,5 +12,6 @@ type Comprobante struct {
Numero string `gorm:"size:50;not null" json:"numero"` Numero string `gorm:"size:50;not null" json:"numero"`
Estado string `gorm:"type:varchar(20);not null" json:"estado"` Estado string `gorm:"type:varchar(20);not null" json:"estado"`
Total float64 `gorm:"type:decimal(15,2);not null" json:"total"` Total float64 `gorm:"type:decimal(15,2);not null" json:"total"`
Responsable models_seguridad.Usuario `gorm:"foreignKey:UsuarioID" json:"usuario"` ResponsableID uint `gorm:"column:usuarioID"`
Responsable models_seguridad.Usuario `gorm:"foreignKey:usuarioID" json:"usuario"`
} }
@@ -0,0 +1,8 @@
package contabilidad
import "gorm.io/gorm"
type AsientoContable struct {
gorm.Model
Movimientos []MovimientoContable `gorm:"foreignKey:movimientoID"`
}
@@ -0,0 +1,10 @@
package contabilidad
import "gorm.io/gorm"
type CuentaContable struct {
gorm.Model
Nombre string `gorm:"type:varchar(30),not null"`
Tipo string `gorm:"type:varchar(12),not null"`
Movimientos []MovimientoContable `gorm:"foreignKey:movimientoID"`
}
@@ -0,0 +1,14 @@
package contabilidad
import "gorm.io/gorm"
type MovimientoContable struct {
gorm.Model
AsientoID uint `gorm:"column:asientoID"`
Asiento AsientoContable `gorm:"foreignKey:asientoID"`
CuentaID uint `gorm:"column:cuentaID"`
Cuenta CuentaContable `gorm:"foreignKey:cuentaID"`
Debe float64 `gorm:"type:decimal(10,2)"`
Haber float64 `gorm:"type:decimal(10,2)"`
Descripcion string `gorm:"type:varchar(50)"`
}
+1
View File
@@ -3,6 +3,7 @@ package models
type Factura struct { type Factura struct {
Comprobante Comprobante
ClienteID uint `gorm:"column:ClienteID"`
Cliente Cliente `gorm:"foreignKey:ClienteID" json:"cliente"` Cliente Cliente `gorm:"foreignKey:ClienteID" json:"cliente"`
Total float64 `gorm:"not null;default:0" json:"total"` Total float64 `gorm:"not null;default:0" json:"total"`
Detalles []FacturaDetalle `gorm:"type:json" json:"detalles,omitempty"` Detalles []FacturaDetalle `gorm:"type:json" json:"detalles,omitempty"`
+2 -1
View File
@@ -3,7 +3,8 @@ package models
type NotaCredito struct { type NotaCredito struct {
Comprobante Comprobante
Motivo string `gorm:"type:varchar(40),not null"` Motivo string `gorm:"type:varchar(40),not null"`
FacturaOrigen Factura `gorm:"foreignKey:FacturaID" json:"factura"` FacturaOrigen Factura `gorm:"foreignKey:facturaID" json:"factura"`
FacturaOrigenID uint `gorm:"column:facturaID"`
} }
func (NotaCredito) TableName() string { func (NotaCredito) TableName() string {
return "nota_credito" return "nota_credito"
+2 -1
View File
@@ -3,7 +3,8 @@ package models
type NotaDebito struct { type NotaDebito struct {
Comprobante Comprobante
Motivo string `gorm:"type:varchar(40),not null"` Motivo string `gorm:"type:varchar(40),not null"`
FacturaOrigen Factura `gorm:"foreignKey:FacturaID" json:"factura"` FacturaOrigen Factura `gorm:"foreignKey:facturaID" json:"factura"`
FacturaOrigenID uint `gorm:"column:facturaID"`
} }
func (NotaDebito) TableName() string { func (NotaDebito) TableName() string {
return "nota_debito" return "nota_debito"
+2 -1
View File
@@ -2,7 +2,8 @@ package models
type OrdenCompra struct { type OrdenCompra struct {
Comprobante Comprobante
Proveedor Proveedor `gorm:"foreignKey:ProveedorID" json:"Proveedor"` Proveedor Proveedor `gorm:"foreignKey:proveedorID" json:"Proveedor"`
ProveedorID uint `gorm:"column:proveedorID"`
Detalles []OrdenCompraDetalle `gorm:"type:json" json:"detalles,omitempty"` Detalles []OrdenCompraDetalle `gorm:"type:json" json:"detalles,omitempty"`
} }
+1
View File
@@ -4,6 +4,7 @@ import "gorm.io/gorm"
type Pago struct { type Pago struct {
gorm.Model gorm.Model
FormaDePagoID uint `gorm:"column:formaDePagoID"`
FormaDePago FormaDePago `gorm:"foreignKey:FormaDePagoID"` FormaDePago FormaDePago `gorm:"foreignKey:FormaDePagoID"`
Importe float64 `gorm:"type:decimal(10,2)"` Importe float64 `gorm:"type:decimal(10,2)"`
} }
+1 -6
View File
@@ -1,14 +1,12 @@
package models package models
import ( import (
"time"
"gorm.io/datatypes" "gorm.io/datatypes"
"gorm.io/gorm" "gorm.io/gorm"
) )
type Repuesto struct { type Repuesto struct {
ID uint64 `gorm:"primaryKey" json:"id"` gorm.Model
Nombre string `gorm:"type:varchar(50);not null" json:"nombre" binding:"required"` Nombre string `gorm:"type:varchar(50);not null" json:"nombre" binding:"required"`
Precio float64 `gorm:"not null;type:decimal(10,2)" json:"precio" binding:"required"` Precio float64 `gorm:"not null;type:decimal(10,2)" json:"precio" binding:"required"`
StockMinimo int64 `gorm:"not null;type:bigint" json:"stockMinimo" binding:"required"` StockMinimo int64 `gorm:"not null;type:bigint" json:"stockMinimo" binding:"required"`
@@ -16,9 +14,6 @@ type Repuesto struct {
Marca Marca `gorm:"foreignKey:marcaId"` Marca Marca `gorm:"foreignKey:marcaId"`
Aliases datatypes.JSONSlice[string] `gorm:"type:json" json:"aliases,omitempty"` Aliases datatypes.JSONSlice[string] `gorm:"type:json" json:"aliases,omitempty"`
Stocks []Stock `gorm:"foreignKey:RepuestoID" json:"stocks,omitempty"` Stocks []Stock `gorm:"foreignKey:RepuestoID" json:"stocks,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
} }
func (Repuesto) TableName() string { func (Repuesto) TableName() string {
+1 -2
View File
@@ -2,9 +2,8 @@ package models
type Stock struct { type Stock struct {
ID uint64 `gorm:"primaryKey" json:"id"` ID uint64 `gorm:"primaryKey" json:"id"`
RepuestoID uint64 `gorm:"index;not null" json:"repuestoId"`
CajonID string `gorm:"type:varchar(30);index;not null" json:"cajonId"`
Cantidad uint `gorm:"not null;default:0" json:"cantidad"` Cantidad uint `gorm:"not null;default:0" json:"cantidad"`
RepuestoID uint64 `gorm:"index;not null" json:"repuestoId"`
Repuesto Repuesto `gorm:"foreignKey:RepuestoID" json:"repuesto"` Repuesto Repuesto `gorm:"foreignKey:RepuestoID" json:"repuesto"`
} }