diff --git a/back/models/almacen.go b/back/models/almacen.go index b348272..b238758 100644 --- a/back/models/almacen.go +++ b/back/models/almacen.go @@ -3,7 +3,7 @@ package models type Almacen struct { ID string `gorm:"primaryKey;type:varchar(5)" json:"id"` 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 { diff --git a/back/models/comprobante.go b/back/models/comprobante.go index bfa26dd..b669d5f 100644 --- a/back/models/comprobante.go +++ b/back/models/comprobante.go @@ -12,5 +12,6 @@ type Comprobante struct { Numero string `gorm:"size:50;not null" json:"numero"` Estado string `gorm:"type:varchar(20);not null" json:"estado"` 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"` } diff --git a/back/models/contabilidad/asientoContable.go b/back/models/contabilidad/asientoContable.go new file mode 100644 index 0000000..df60e61 --- /dev/null +++ b/back/models/contabilidad/asientoContable.go @@ -0,0 +1,8 @@ +package contabilidad + +import "gorm.io/gorm" + +type AsientoContable struct { + gorm.Model + Movimientos []MovimientoContable `gorm:"foreignKey:movimientoID"` +} diff --git a/back/models/contabilidad/cuentaContable.go b/back/models/contabilidad/cuentaContable.go new file mode 100644 index 0000000..b2b12ef --- /dev/null +++ b/back/models/contabilidad/cuentaContable.go @@ -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"` +} diff --git a/back/models/contabilidad/movimientosContable.go b/back/models/contabilidad/movimientosContable.go new file mode 100644 index 0000000..8ea4270 --- /dev/null +++ b/back/models/contabilidad/movimientosContable.go @@ -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)"` +} diff --git a/back/models/factura.go b/back/models/factura.go index c94eab2..52c2eca 100644 --- a/back/models/factura.go +++ b/back/models/factura.go @@ -3,6 +3,7 @@ package models type Factura struct { Comprobante + ClienteID uint `gorm:"column:ClienteID"` Cliente Cliente `gorm:"foreignKey:ClienteID" json:"cliente"` Total float64 `gorm:"not null;default:0" json:"total"` Detalles []FacturaDetalle `gorm:"type:json" json:"detalles,omitempty"` diff --git a/back/models/notaCredito.go b/back/models/notaCredito.go index 5852ddd..2bae681 100644 --- a/back/models/notaCredito.go +++ b/back/models/notaCredito.go @@ -2,8 +2,9 @@ package models type NotaCredito struct { Comprobante - Motivo string `gorm:"type:varchar(40),not null"` - FacturaOrigen Factura `gorm:"foreignKey:FacturaID" json:"factura"` + Motivo string `gorm:"type:varchar(40),not null"` + FacturaOrigen Factura `gorm:"foreignKey:facturaID" json:"factura"` + FacturaOrigenID uint `gorm:"column:facturaID"` } func (NotaCredito) TableName() string { return "nota_credito" diff --git a/back/models/notaDebito.go b/back/models/notaDebito.go index a731b1b..df55aae 100644 --- a/back/models/notaDebito.go +++ b/back/models/notaDebito.go @@ -2,8 +2,9 @@ package models type NotaDebito struct { Comprobante - Motivo string `gorm:"type:varchar(40),not null"` - FacturaOrigen Factura `gorm:"foreignKey:FacturaID" json:"factura"` + Motivo string `gorm:"type:varchar(40),not null"` + FacturaOrigen Factura `gorm:"foreignKey:facturaID" json:"factura"` + FacturaOrigenID uint `gorm:"column:facturaID"` } func (NotaDebito) TableName() string { return "nota_debito" diff --git a/back/models/orden_compra.go b/back/models/orden_compra.go index 6af85cf..97b6a33 100644 --- a/back/models/orden_compra.go +++ b/back/models/orden_compra.go @@ -2,7 +2,8 @@ package models type OrdenCompra struct { 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"` } diff --git a/back/models/pago.go b/back/models/pago.go index 0bb58a3..426ff02 100644 --- a/back/models/pago.go +++ b/back/models/pago.go @@ -4,8 +4,9 @@ import "gorm.io/gorm" type Pago struct { gorm.Model - FormaDePago FormaDePago `gorm:"foreignKey:FormaDePagoID"` - Importe float64 `gorm:"type:decimal(10,2)"` + FormaDePagoID uint `gorm:"column:formaDePagoID"` + FormaDePago FormaDePago `gorm:"foreignKey:FormaDePagoID"` + Importe float64 `gorm:"type:decimal(10,2)"` } func (Pago) TableName() string { diff --git a/back/models/repuesto.go b/back/models/repuesto.go index 5b7ed60..7e041ea 100644 --- a/back/models/repuesto.go +++ b/back/models/repuesto.go @@ -1,14 +1,12 @@ package models import ( - "time" - "gorm.io/datatypes" "gorm.io/gorm" ) type Repuesto struct { - ID uint64 `gorm:"primaryKey" json:"id"` + gorm.Model 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"` StockMinimo int64 `gorm:"not null;type:bigint" json:"stockMinimo" binding:"required"` @@ -16,9 +14,6 @@ type Repuesto struct { Marca Marca `gorm:"foreignKey:marcaId"` Aliases datatypes.JSONSlice[string] `gorm:"type:json" json:"aliases,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 { diff --git a/back/models/stock.go b/back/models/stock.go index 586f6ee..771850b 100644 --- a/back/models/stock.go +++ b/back/models/stock.go @@ -2,9 +2,8 @@ package models type Stock struct { 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"` + RepuestoID uint64 `gorm:"index;not null" json:"repuestoId"` Repuesto Repuesto `gorm:"foreignKey:RepuestoID" json:"repuesto"` }