Private
Public Access
feat: adapatadas entidades para que coinsidan con el modelo
This commit is contained in:
1 parent
de33352618
commit
152a40ca19
16 files changed
+105
-68
No files matched your search
@@ -2,9 +2,8 @@ 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"`
|
||||
Ubicacion string `gorm:"type:varchar(40)" json:"ubicacion"`
|
||||
Stocks []Stock `gorm:"foreignKey:RepuestoID" json:"stocks,omitempty"`
|
||||
}
|
||||
|
||||
func (Almacen) TableName() string {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
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"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Cliente struct {
|
||||
gorm.Model
|
||||
Nombre string `gorm:"type:varchar(40)" json:"nombre"`
|
||||
Facturas []Factura `gorm:"foreignKey:facturaID" json:"facturas,omitempty"`
|
||||
Recibos []Recibo `gorm:"foreignKey:reciboID"`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
models_seguridad "repuestera_back/models/seguridad"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// este lo uso de base para los distintos tipos de comprobantes
|
||||
type Comprobante struct {
|
||||
gorm.Model
|
||||
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"`
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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"
|
||||
}
|
||||
+4
-13
@@ -1,20 +1,11 @@
|
||||
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"`
|
||||
Usuario models_seguridad.Usuario `gorm:"foreignKey:UsuarioID" json:"usuario,omitempty"`
|
||||
Comprobante
|
||||
Cliente Cliente `gorm:"foreignKey:ClienteID" json:"cliente"`
|
||||
Total float64 `gorm:"not null;default:0" json:"total"`
|
||||
Detalles []FacturaDetalle `gorm:"type:json" json:"detalles,omitempty"`
|
||||
}
|
||||
|
||||
func (Factura) TableName() string {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FormaDePago struct {
|
||||
gorm.Model
|
||||
Descripcion string `gorm:"type:varchar(20),not null" json:"desripcion" `
|
||||
}
|
||||
func (FormaDePago) TableName() string {
|
||||
return "forma_de_pago"
|
||||
}
|
||||
@@ -1,18 +1,13 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Marca struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(3)" json:"id"`
|
||||
Nombre string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"nombre"`
|
||||
Repuestos []Repuesto `gorm:"foreignKey:MarcaID"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
gorm.Model
|
||||
Nombre string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"nombre"`
|
||||
Repuestos []Repuesto `gorm:"foreignKey:MarcaID" json:"repuestos"`
|
||||
}
|
||||
|
||||
func (Marca) TableName() string {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type NotaCredito struct {
|
||||
Comprobante
|
||||
Motivo string `gorm:"type:varchar(40),not null"`
|
||||
FacturaOrigen Factura `gorm:"foreignKey:FacturaID" json:"factura"`
|
||||
}
|
||||
func (NotaCredito) TableName() string {
|
||||
return "nota_credito"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type NotaDebito struct {
|
||||
Comprobante
|
||||
Motivo string `gorm:"type:varchar(40),not null"`
|
||||
FacturaOrigen Factura `gorm:"foreignKey:FacturaID" json:"factura"`
|
||||
}
|
||||
func (NotaDebito) TableName() string {
|
||||
return "nota_debito"
|
||||
}
|
||||
@@ -1,20 +1,9 @@
|
||||
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"`
|
||||
Usuario models_seguridad.Usuario `gorm:"foreignKey:UsuarioID" json:"usuario,omitempty"`
|
||||
Comprobante
|
||||
Proveedor Proveedor `gorm:"foreignKey:ProveedorID" json:"Proveedor"`
|
||||
Detalles []OrdenCompraDetalle `gorm:"type:json" json:"detalles,omitempty"`
|
||||
}
|
||||
|
||||
func (OrdenCompra) TableName() string {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Pago struct {
|
||||
gorm.Model
|
||||
FormaDePago FormaDePago `gorm:"foreignKey:FormaDePagoID"`
|
||||
Importe float64 `gorm:"type:decimal(10,2)"`
|
||||
}
|
||||
|
||||
func (Pago) TableName() string {
|
||||
return "pago"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Proveedor struct {
|
||||
gorm.Model
|
||||
Nombre string `gorm:"type:varchar(40)" json:"nombre"`
|
||||
Facturas []Factura `gorm:"foreignKey:FacturaID" json:"facturas,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type Recibo struct {
|
||||
Comprobante
|
||||
Pagos []Pago `gorm:"foreignKey:pagoId" json:"pagos"`
|
||||
}
|
||||
|
||||
func (Recibo) TableName() string {
|
||||
return "recibo"
|
||||
}
|
||||
@@ -13,7 +13,7 @@ type Repuesto struct {
|
||||
Precio float64 `gorm:"not null;type:decimal(10,2)" json:"precio" binding:"required"`
|
||||
StockMinimo int64 `gorm:"not null;type:bigint" json:"stockMinimo" binding:"required"`
|
||||
Descripcion string `gorm:"uniqueIndex;not null;type:varchar(70)" json:"descripcion" binding:"required"`
|
||||
MarcaID string `gorm:"type:varchar(3);index" json:"marcaId" binding:"required"`
|
||||
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"`
|
||||
|
||||
@@ -5,9 +5,7 @@ type Stock struct {
|
||||
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"`
|
||||
|
||||
Repuesto Repuesto `gorm:"foreignKey:RepuestoID" json:"repuesto,omitempty"`
|
||||
Cajon Cajon `gorm:"foreignKey:CajonID" json:"cajon,omitempty"`
|
||||
Repuesto Repuesto `gorm:"foreignKey:RepuestoID" json:"repuesto"`
|
||||
}
|
||||
|
||||
func (Stock) TableName() string {
|
||||
|
||||
Reference in new issue
Block a user