Saltearse al contenido

Base de datos

Keirost usa PostgreSQL con esquema multi-tenant:

  • public — usuarios, tenants, plugins, geografia
  • tenant_* — un schema por empresa con todo el negocio

Schema public

Tenant

Empresas registradas en el sistema.

CampoTipoDescripcion
idPK textUUID
nametext uniqueNombre visible
schemaNametext uniqueNombre del schema PostgreSQL
configtextJSON de configuracion
createdAttimestamp
updatedAttimestamp

GlobalUser

Usuarios globales del sistema.

CampoTipoDescripcion
idPK textUUID
emailtext uniqueLogin
usernametext uniqueAlias
passwordtextHash bcrypt
roletextUSER / ADMIN / SUPERUSER
signatureNametextFirma para PDFs
signatureRoletextCargo en firma
signatureImageUrltextImagen de firma
createdAttimestamp
updatedAttimestamp

UserTenantMembership

Relacion usuario-empresa con rol.

CampoTipoDescripcion
idPK text
userIdFK → GlobalUser
tenantIdFK → Tenant
roletextUSER / ADMIN
permissionstextJSON de permisos
UNIQUE(userId, tenantId)

PluginField

Campos personalizados declarados por plugins o UI.

CampoTipoDescripcion
idPK text
pluginIdtext__user__ para campos UI
tenantIdtextnull si es plugin global
tableNametextTabla destino
fieldNametextNombre del campo
fieldTypetextTEXT, INTEGER, DECIMAL, BOOLEAN, DATE, JSONB, ENUM
labeltextEtiqueta UI
optionsjsonbOpciones para ENUM
requiredbooleanObligatorio
defaultValuetextValor por defecto
showInListbooleanVisible en listado
refTabletextPara campos REFERENCE
validationjsonb{min, max, pattern}
createdAttimestamp

PluginTable

Tablas personalizadas declaradas por plugins.

CampoTipoDescripcion
idPK text
pluginIdtext__user__ para tablas UI
tenantIdtextnull si es global
tableNametextNombre fisico
definitiontextJSON con columnas
labeltextEtiqueta menu
kindtextmaster / document
iconNametextIcono lucide
menuModuletextModulo del menu

TenantPlugin

Activacion de plugins por empresa.

CampoTipoDescripcion
idPK text
tenantIdFK → Tenant
pluginIdtext
isActiveboolean
configtextJSON de config
UNIQUE(tenantId, pluginId)

DevApiKey

Claves de desarrollo para plugins remotos.

CampoTipoDescripcion
idPK text
clientIdtext unique
clientSecrettext
nametextDescripcion
createdByFK → GlobalUser
tenantIdFK → Tenant
permissionstextScopes del token
isActiveboolean
lastUsedAttimestamp

ApiToken

Tokens server-to-server por tenant.

CampoTipoDescripcion
idPK text
tenantIdtext
nametext
tokenHashtext uniqueSHA-256 del token
prefixtextPrimeros caracteres legibles
scopestextCSV de permisos
createdByUserIdtext
revokedAttimestamp

Country

Paises. PK: code (ISO 3166-1 alpha-2).

CampoTipoDescripcion
codePK textES, PT, etc.
nametext
nameEntextNombre en ingles
phonePrefixtext+34
currencytextEUR
taxIdRegextextRegex validacion NIF
taxIdLabeltextEtiqueta (NIF/CIF)
postalCodeRegextext

Region

Regiones (comunidades autonomas).

CampoTipoDescripcion
idPK text
countryCodeFK → Country
codetext
nametext
UNIQUE(countryCode, code)

SubRegion

Provincias.

CampoTipoDescripcion
idPK text
countryCodeFK → Country
regionIdFK → Regionnullable
codetext
nametext
UNIQUE(countryCode, code)

Locality

Municipios.

CampoTipoDescripcion
idPK text
countryCodeFK → Country
subRegionIdFK → SubRegion
codetext
nametext
UNIQUE(countryCode, code)

Configuracion

SystemConfig

Clave-valor de configuracion por empresa.

CampoTipoDescripcion
idPK text
keytext uniqueEj: company_name
valuetext
descriptiontext

UserModule

Modulos del menu creados desde la UI.

CampoTipoDescripcion
idPK text
tenantIdtext
labeltextNombre visible
iconNametextIcono lucide
moduleOrderintegerOrden en el menu

DocumentSeries

Series documentales por tipo y periodo.

CampoTipoDescripcion
idPK text
nametext unique
docTypetextSINV, PINV, SDN, PDN, SO, PO
periodIdFK → AccountingPeriod
prefixtextEj: FA
firstNumberinteger
nextNumberinteger
lastNumberinteger
isDefaultboolean

DocumentTemplate

Plantillas PDF (HTML o canvas).

CampoTipoDescripcion
idPK text
docTypetextTipo de documento
nametext
htmltextHTML Handlebars
canvasLayoutjsonbLayout del editor visual
isDefaultboolean
legacyHtmlbooleantrue = HTML clasico

Fiscalidad y pagos

TaxGroup

Tipos de impuesto (IVA, IRPF).

CampoTipoDescripcion
idPK text
codetext uniqueIVA21, IVA10, IRPF19
ratedecimal(5,2)Porcentaje

Currency

Monedas soportadas.

CampoTipoDescripcion
idPK text
codetext uniqueEUR, USD
nametext
symboltext€, $
decimalsintegerDefault 2
exchangeRatedecimal(12,6)vs moneda base
isBasebooleanMoneda base del tenant

DocumentType

Tipos de documento fiscal configurables.

CampoTipoDescripcion
idPK text
codetext
nametext
docCategorytextCategoria
isRectifybooleanEs rectificativa
isActiveboolean

PaymentMethod

Metodos de pago.

CampoTipoDescripcion
idPK text
codetext uniquetransfer, cash, card
nametext

PaymentTerm

Condiciones de pago (30 dias, 60 dias, etc.).

CampoTipoDescripcion
idPK text
nametext
linesjsonbArray de plazos y porcentajes

Payment

Cobros y pagos registrados.

CampoTipoDescripcion
idPK text
salesInvoiceIdFK → SalesInvoiceo purchaseInvoiceId
datedate
amountdecimal(15,4)
currencyIdFK → Currency
paymentMethodIdFK → PaymentMethod
referencetextNumero de transferencia
sourcetextmanual, automation

PriceList

Listas de precios.

CampoTipoDescripcion
idPK text
nametext

ItemPrice

Precio por articulo y lista.

CampoTipoDescripcion
idPK text
priceListIdFK → PriceList
itemIdFK → Item
pricedecimal(12,4)
UNIQUE(priceListId, itemId)

Contabilidad

AccountingPeriod

Periodos fiscales (ejercicios).

CampoTipoDescripcion
idPK text
codetext unique
nametext
startDatetimestamp
endDatetimestamp
statustextO abierto / C cerrado

ChartOfAccount

Plan contable.

CampoTipoDescripcion
idPK text
codetext unique
nametext
typetextasset, liability, equity, income, expense
parentIdtextJerarquia
isAnalyticalbooleanRequiere dimension analitica
isActiveboolean

CostCenter

Centros de coste.

CampoTipoDescripcion
idPK text
codetext unique
nametext
parentIdtextJerarquia
managerEmployeeIdFK → Employee
isActiveboolean

ProfitCenter

Centros de beneficio.

CampoTipoDescripcion
idPK text
codetext unique
nametext
parentIdtextJerarquia
managerEmployeeIdFK → Employee
isActiveboolean

InternalOrder

Proyectos / ordenes internas / WBS.

CampoTipoDescripcion
idPK text
codetext unique
nametext
typetextproject, internal_order, wbs
startDatedate
endDatedate
budgetAmountdecimal(15,2)
statustextopen, closed
costCenterIdFK → CostCenter

JournalEntry

Asientos contables (cabecera).

CampoTipoDescripcion
idPK text
numberintegerNumero de asiento
datetimestamp
periodIdFK → AccountingPeriod
descriptiontext
sourcetextmanual, sales_invoice, payment, payroll
sourceDocumentIdtextID del documento origen
statustextdraft, posted, reversed
reversedByIdtextID del asiento de reversion
postedAttimestamp

JournalEntryLine

Lineas de asiento (debe/haber).

CampoTipoDescripcion
idPK text
entryIdFK → JournalEntry
lineNumberinteger
accountIdFK → ChartOfAccount
debitdecimal(15,4)Default 0
creditdecimal(15,4)Default 0
costCenterIdFK → CostCenter
profitCenterIdFK → ProfitCenter
internalOrderIdFK → InternalOrder
partnerIdtext
currencytextDefault EUR
exchangeRatedecimal(15,6)Default 1

AccountMapping

Mapeo de cuentas para asientos automaticos.

CampoTipoDescripcion
idPK text
kindtextsales_revenue, customer_receivable, payroll_gross, etc.
keytextdefault o override por partner/tax
accountIdFK → ChartOfAccount

DimensionRule

Reglas de dimension por cuenta.

CampoTipoDescripcion
idPK text
accountIdFK → ChartOfAccountUNIQUE
requiresCostCenterboolean
requiresProfitCenterboolean
requiresInternalOrderboolean

Socios de negocio

PartnerGroup

Grupos de socios (clientes, proveedores).

CampoTipoDescripcion
idPK text
codetext uniqueCLI, PRV, MAY
nametext
codePrefixtextPrefijo de numeracion
isCustomerboolean
isVendorboolean

BusinessPartner

Clientes y proveedores.

CampoTipoDescripcion
idPK text
codetext uniqueAuto-generado
nametextRazon social
niftext unique nullableIndice unico parcial
foreignNametextNombre extranjero
phonetext
emailtext
websitetext
groupIdFK → PartnerGroup
priceListIdFK → PriceList
defaultDocumentTypeIdtext
defaultPaymentMethodIdtext
defaultPaymentTermIdtext
defaultWithholdingRatedecimal(5,2)IRPF por defecto
ibantext
bankNametext
bankSwifttext

PartnerAddress

Direcciones de socios (facturacion/envio).

CampoTipoDescripcion
idPK text
partnerIdFK → BusinessPartner
nametext
streettext
citytext
zipCodetext
countryCodetext
typetextB facturacion / S envio
isDefaultboolean

Contact

Personas de contacto del socio.

CampoTipoDescripcion
idPK text
partnerIdFK → BusinessPartner
nametext
roletextCargo
emailtext
phonetext
mobiletext
isMainbooleanContacto principal

Inventario

Category

Categorias de articulos.

CampoTipoDescripcion
idPK text
nametext
codePrefixtextPrefijo de codigo
parentIdFK → CategoryJerarquia

Item

Articulos / productos / servicios.

CampoTipoDescripcion
idPK text
codetext uniqueReferencia interna
barcodetext unique nullableEAN-13, Code-128
nametext
descriptiontext
uomIdFK → UnitOfMeasureUnidad base
categoryIdFK → Category
taxGroupIdFK → TaxGroup
manageBytextN nada / B lotes / S series
basePricedecimal(12,4)Precio base
stockdoubleStock total
minStockdoubleStock minimo
defaultWarehouseIdtext
defaultZoneIdtext
kindtextproduct (default) / box caja
boxLengthMmintegerPara cajas
boxWidthMminteger
boxHeightMminteger
boxMaxWeightKgdouble
boxTareWeightKgdouble
createdAttimestamp
updatedAttimestamp

ItemBatch

Lotes de articulos.

CampoTipoDescripcion
idPK text
batchNumtextNumero de lote
itemIdFK → Item
quantitydouble
expiryDatetimestamp

ItemSerial

Series de articulos.

CampoTipoDescripcion
idPK text
serialNumtext uniqueNumero de serie
itemIdFK → Item
statustextA activo / I inactivo

UnitOfMeasure

Unidades de medida.

CampoTipoDescripcion
idPK text
codetext uniqueUD, KG, L, M
nametext
baseValuedecimal(12,4)Factor base (default 1)
baseUomIdFK → UnitOfMeasurePara conversiones

ItemAlternativeUom

Conversiones de unidad por articulo.

CampoTipoDescripcion
idPK text
itemIdFK → Item
uomIdFK → UnitOfMeasure
factordecimal(12,4)Ej: 12 (1 caja = 12 uds)

Warehouse

Almacenes.

CampoTipoDescripcion
idPK text
nametext
locationtext
isDefaultboolean
createdAttimestamp
updatedAttimestamp

WarehouseZone

Zonas dentro de un almacen.

CampoTipoDescripcion
idPK text
nametext
descriptiontext
warehouseIdFK → Warehouse

ItemWarehouseStock

Stock por articulo y almacen.

CampoTipoDescripcion
itemIdFK → ItemPK (compuesto)
warehouseIdFK → WarehousePK (compuesto)
stockdouble
updatedAttimestamp

ItemZoneStock

Stock por articulo, almacen y zona.

CampoTipoDescripcion
itemIdFK → ItemPK (compuesto)
warehouseIdFK → WarehousePK (compuesto)
zoneIdFK → WarehouseZonePK (compuesto)
stockdouble
updatedAttimestamp

Documentos de venta

SalesOrder (Pedido de venta)

CampoTipoDescripcion
idPK text
seriesIdFK → DocumentSeries
docNumintegerNumero en la serie
periodIdFK → AccountingPeriod
partnerIdFK → BusinessPartner
datetimestamp
deliveryDatetimestampFecha de entrega
statustextO borrador / P pendiente / C cerrado / X anulado
warehouseIdFK → Warehouse
internalOrderIdFK → InternalOrder
subtotaldecimal(15,4)
taxTotaldecimal(15,4)
totaldecimal(15,4)
taxBreakdowntextJSON desglose IVA
salesAgentIdtextComercial (para comisiones)
createdBytext
createdAttimestamp

SalesOrderLine

CampoTipoDescripcion
idPK text
orderIdFK → SalesOrder
lineNuminteger
itemIdFK → Item
orderedQtydecimal(12,4)Cantidad pedida
deliveredQtydecimal(12,4)Cantidad entregada
pricedecimal(15,4)
taxGroupIdFK → TaxGroup
lineTotaldecimal(15,4)
uomIdFK → UOM
uomFactordecimal(12,4)Default 1
discountRatedecimal(5,2)% descuento
discountAmountdecimal(15,4)
withholdingRatedecimal(5,2)% retencion
withholdingAmountdecimal(15,4)
costCenterIdFK → CostCenter
profitCenterIdFK → ProfitCenter
internalOrderIdFK → InternalOrder
pluginDatajsonb

SalesDeliveryNote (Albaran de venta)

Igual estructura que SalesOrder mas: | orderId | FK → SalesOrder | Pedido origen |

SalesDeliveryNoteLine

Igual estructura que SalesOrderLine mas: | baseLine | integer | Linea del documento base |

SalesDeliveryNoteLineBatch

Trazabilidad por lote en linea de albaran.

CampoTipoDescripcion
idPK text
deliveryLineIdFK → SalesDeliveryNoteLine
batchNumtext
quantitydouble

SalesInvoice (Factura de venta)

Extiende SalesOrder con campos fiscales:

CampoTipoDescripcion
isLockedbooleanBloqueada al asentar
lockedAttimestamp
documentTypeIdtextTipo fiscal
dueDatedateVencimiento
supplyDatedateFecha de operacion
paymentMethodIdtext
paymentTermIdtext
paymentStatustextpending / partial / paid
amountPaiddecimal(15,4)
withholdingRatedecimal(5,2)
withholdingAmountdecimal(15,4)
rectifyReftextReferencia rectificada
rectifyReasontextMotivo rectificacion
currencyIdtextMoneda
exchangeRatedecimal(12,6)
totalCurrencydecimal(15,4)Total en moneda extranjera
billingAddressIdtextDireccion de facturacion
shippingAddressIdtextDireccion de envio
notestextNotas del cliente
internalNotestextNotas internas
fiscalHashtextHash de cadena de suministro
fiscalHashPrevtextHash anterior
fiscalStatustextEstado ante Hacienda
fiscalSentAttimestampFecha envio SII
costCenterIdFK → CostCenter
profitCenterIdFK → ProfitCenter
internalOrderIdFK → InternalOrder

SalesInvoiceLine

Igual estructura que SalesOrderLine mas: | baseType | text | Tipo doc base | | baseId | text | ID doc base | | baseLine | integer | Linea doc base |

SalesInvoiceLineBatch

Trazabilidad por lote en linea de factura.

CampoTipoDescripcion
idPK text
invoiceLineIdFK → SalesInvoiceLine
batchNumtext
quantitydouble

Documentos de compra

PurchaseOrder

Estructura identica a SalesOrder.

PurchaseOrderLine

Estructura identica a SalesOrderLine.

PurchaseDeliveryNote

Estructura identica a SalesDeliveryNote.

PurchaseDeliveryNoteLine

Estructura identica a SalesDeliveryNoteLine.

PurchaseDeliveryNoteLineBatch

Estructura identica a SalesDeliveryNoteLineBatch.

PurchaseInvoice

Estructura identica a SalesInvoice.

PurchaseInvoiceLine

Estructura identica a SalesInvoiceLine.

PurchaseInvoiceLineBatch

Estructura identica a SalesInvoiceLineBatch.

Nota: Los documentos de compra suman stock (albaranes) mientras que los de venta restan stock.


Recursos Humanos

Department

Departamentos.

CampoTipoDescripcion
idPK text
codetext unique
nametext
parentIdtextJerarquia
managerEmployeeIdFK → Employee
costCenterIdFK → CostCenter
isActiveboolean
createdAttimestamp
updatedAttimestamp

Position

Puestos de trabajo.

CampoTipoDescripcion
idPK text
codetext unique
nametext
departmentIdFK → Department
descriptiontext
isActiveboolean

Employee

Empleados.

CampoTipoDescripcion
idPK text
codetext uniqueNumero de empleado
firstNametext
lastNametext
dnitext
emailtext
phonetext
birthDatedate
hireDatedateFecha de contratacion
terminationDatedateFecha de baja
addressjsonb{street, city, zipCode}
ibantextCuenta bancaria
departmentIdFK → Department
costCenterIdFK → CostCenter
profitCenterIdFK → ProfitCenter
statustextactive / inactive / terminated
userIdtextVinculado a GlobalUser
kioskPintextPIN para fichar (4-8 digitos)
notestext
createdAttimestamp
updatedAttimestamp

Contract

Contratos por empleado.

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
positionIdFK → Position
typetextindefinite, temporary, training
startDatedate
endDatedate
grossSalarydecimal(15,2)Salario bruto anual
paymentsPerYearintegerDefault 12
workHoursPerWeekdecimal(5,2)
collectiveAgreementIdtextConvenio colectivo
probationDaysinteger
noticeDaysinteger
isPartTimeboolean
partTimeRatiodecimal(4,3)
documentUrltextPDF del contrato
signedAttimestamp
isActiveboolean

CollectiveAgreement

Convenios colectivos.

CampoTipoDescripcion
idPK text
codetext unique
nametext
sectortext
baseSalarydecimal(15,2)Salario base de convenio
vacationDaysintegerDefault 22
weeklyHoursdecimal(5,2)Default 40
isActiveboolean

Leave

Ausencias (vacaciones, baja medica).

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
typetextTipo de ausencia
startDatedate
endDatedate
daysdecimal(5,2)Dias naturales
statustextpending / approved

Payroll

Nominas.

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
contractIdFK → Contract
periodYearinteger
periodMonthinteger
grossdecimal(15,2)
irpfAmountdecimal(15,2)
ssEmployeedecimal(15,2)Seguridad Social empleado
ssEmployerdecimal(15,2)Seguridad Social empresa
netPaydecimal(15,2)Neto a percibir
statustextdraft / calculated / sent / paid
approvedAttimestamp
approvedBytext
UNIQUE(employeeId, periodYear, periodMonth)

PayrollConcept

Catalogo de conceptos de nomina.

CampoTipoDescripcion
idPK text
codetext unique
nametext
kindtextdevengo, deduccion, aportacion_empresa
taxableIrpfboolean
taxableSsboolean
calculationtextfixed, percent_of_base, per_hour
defaultAmountdecimal(15,2)
defaultPercentdecimal(6,3)
accountIdFK → ChartOfAccount
isActiveboolean

PayrollLine

Lineas de nomina.

CampoTipoDescripcion
idPK text
payrollIdFK → Payroll
conceptIdFK → PayrollConcept
concepttextNombre del concepto
typetext
quantitydecimal(12,4)
ratedecimal(15,4)
baseAmountdecimal(15,2)
amountdecimal(15,2)
accountIdFK → ChartOfAccount

ShiftTemplate

Plantillas de turno.

CampoTipoDescripcion
idPK text
codetext unique
nametext
startTimetextHH:mm
endTimetextHH:mm
breakMinutesinteger
secondStartTimetextTurno partido
secondEndTimetext
colortext
isActiveboolean

ShiftPattern

Patrones de rotacion ciclica.

CampoTipoDescripcion
idPK text
nametext
cycleWeeksintegerDefault 1
slotsjsonbMatriz week x dayOfWeek
isActiveboolean

ShiftPatternAssignment

Asignacion de patron a empleado.

CampoTipoDescripcion
idPK text
patternIdFK → ShiftPattern
employeeIdFK → Employee
weekOffsetintegerSemana de inicio
validFromdate
validTodate

ShiftAssignment

Asignacion materializada (fila por empleado/dia).

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
datedate
startAttimestamp
endAttimestamp
breakMinutesinteger
shiftTemplateIdFK → ShiftTemplate
patternIdFK → ShiftPattern
statustextscheduled / cancelled

TimeclockEntry

Fichajes.

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
kindtextin / out / break_start / break_end
attimestamp
sourcetextweb / kiosk / admin
latitudedecimal(9,6)
longitudedecimal(9,6)
taskIdtextTarea imputada

TimeclockKiosk

Kioskos fisicos compartidos.

CampoTipoDescripcion
idPK text
nametext
locationtext
tokentext unique
isActiveboolean

IncidentType

Tipos de incidencia laboral.

CampoTipoDescripcion
idPK text
codetext unique
nametext
requiresSubstitutionbooleanRequiere sustituto
affectsPayrollbooleanAfecta a nomina
consumesLeaveBalancebooleanConsume saldo vacaciones
paidbooleanPagada
colortext
isActiveboolean

Incident

Incidencia concreta de un empleado.

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
incidentTypeIdFK → IncidentType
startAttimestamp
endAttimestamp
statustextpending / approved / rejected
documentUrltext
notestext
approvedBytext
approvedAttimestamp

Substitution

Sustitucion de turno.

CampoTipoDescripcion
idPK text
incidentIdFK → Incident
originalEmployeeIdFK → Employee
substituteEmployeeIdFK → Employee
statustextproposed / accepted / rejected

EvaluationCycle

Ciclo de evaluacion (ej: Q1 2026).

CampoTipoDescripcion
idPK text
nametext
startDatedate
endDatedate
statustextdraft / active / closed

EvaluationCompetency

Competencia evaluable.

CampoTipoDescripcion
idPK text
codetext unique
nametext
descriptiontext
weightdecimal(5,2)Default 1
scaleMaxintegerDefault 5
isActiveboolean

EmployeeEvaluation

Evaluacion de un empleado en un ciclo.

CampoTipoDescripcion
idPK text
cycleIdFK → EvaluationCycle
employeeIdFK → Employee
managerIdFK → Employee
statustextpending / self_done / manager_done / closed
finalScoredecimal(5,2)

EmployeeEvaluationScore

Puntuacion por competencia.

CampoTipoDescripcion
idPK text
evaluationIdFK → EmployeeEvaluation
competencyIdFK → EvaluationCompetency
scoreSelfdecimal(5,2)
scoreManagerdecimal(5,2)
commentstext

EmployeeObjective

Objetivos SMART.

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
cycleIdFK → EvaluationCycle
titletext
targetValuedecimal(15,2)
achievedValuedecimal(15,2)
weightdecimal(5,2)Default 1
statustextpending / in_progress / achieved / missed
dueDatedate

CommissionRule

Reglas de comision.

CampoTipoDescripcion
idPK text
nametext
scopetextemployee / department / all
employeeIdFK → Employee
departmentIdFK → Department
basistextnet_amount / gross_amount / margin
kindtextflat_pct / tiered
pctdecimal(6,3)
tiersjsonbTramos
isActiveboolean

CommissionAccrual

Acumulado de comision por documento.

CampoTipoDescripcion
idPK text
employeeIdFK → Employee
ruleIdFK → CommissionRule
periodYear / periodMonthinteger
sourceDocTypetextSINV, SO, SDN
sourceDocIdtext
basedecimal(15,2)
amountdecimal(15,2)
statustextpending / paid / cancelled

Task

Tareas y planificacion.

CampoTipoDescripcion
idPK text
codetext unique
titletext
descriptiontext
statustexttodo / in_progress / done / cancelled
prioritytextlow / normal / high / urgent
assigneeIdFK → Employee
startDate / dueDatedate
estimatedHoursdecimal(8,2)
actualHoursdecimal(8,2)
progressinteger0-100
parentTaskIdtext

TaskDependency

Dependencia entre tareas.

CampoTipoDescripcion
idPK text
predecessorIdFK → Task
successorIdFK → Task
kindtextfinish_to_start
lagDaysinteger

TaskComment

Comentario en tarea.

CampoTipoDescripcion
idPK text
taskIdFK → Task
userIdtext
bodytext
attimestamp

Logistica

Carrier

Transportistas.

CampoTipoDescripcion
idPK text
nametext
codetext
logoUrltext
adapterIdtextnull = manual
isActiveboolean

CarrierAccount

Cuentas de integracion con transportistas.

CampoTipoDescripcion
idPK text
carrierIdFK → Carrier
nametext
sandboxboolean
credentialsjsonbConfig del adapter

Vehicle

Vehiculos de la flota.

CampoTipoDescripcion
idPK text
codetext unique
platetext uniqueMatricula
brandtext
modeltext
capacityKgdoubleCarga maxima
capacityM3doubleVolumen
statustextactive / maintenance / retired
defaultDriverEmployeeIdFK → Employee
archivedAttimestampBaja logica

Shipment

Envios.

CampoTipoDescripcion
idPK text
deliveryNoteIdtextAlbaran origen
carriertextseur, correos, propio
carrierAccountIdtext
trackingNumbertext
statustextpending / in_transit / delivered
preparationStatustextdraft / picking / packed / dispatched
reportTokentext uniqueToken publico tracking
destinationAddresstext
destinationLat / destinationLngdouble
recipientName / email / phonetext
lastLat / lastLngdoubleUltima posicion
deliveredAttimestamp
driverNametext
driverPhonetext
vehiclePlatetext

ShipmentEvent

Eventos en el envio.

CampoTipoDescripcion
idPK text
shipmentIdFK → Shipment
kindtextstatus_change / incident / note
statustext
descriptiontext

ShipmentPosition

Posiciones GPS del envio.

CampoTipoDescripcion
idPK text
shipmentIdFK → Shipment
lat / lngdouble
speedKmhdouble
reportedAttimestamp

Route

Rutas de reparto.

CampoTipoDescripcion
idPK text
codetext unique
nametext
plannedDatedate
statustextplanned / in_progress / completed
vehiclePlatetextSnapshot historico
vehicleIdtext
driverEmployeeIdFK → Employee
startedAt / completedAttimestamp

RouteStop

Paradas de la ruta.

CampoTipoDescripcion
idPK text
routeIdFK → Route
sequenceintegerOrden
shipmentIdFK → Shipment
addresstext
lat / lngdouble
arrivedAt / departedAttimestamp
statustext
signatureImagetextFirma POD
podNotestext

ExternalPlatform

Plataformas logisticas externas.

CampoTipoDescripcion
idPK text
codetext unique
nametext
addresstext
lat / lngdouble
openingHourstextEj: “L-V 8-18”
contactName / phone / emailtext
archivedAttimestamp

StagingArea

Areas de staging/acopio.

CampoTipoDescripcion
idPK text
codetext unique
nametext
warehouseIdtext
partnerIdtextCliente dueño
platformIdtextPlataforma ajena
lat / lngdouble

StagingAreaItem

Articulos en un area de staging.

CampoTipoDescripcion
idPK text
stagingAreaIdFK → StagingArea
itemIdFK → Item
expectedQtydoubleNivel objetivo

Package

Paquetes/cajas preparadas.

CampoTipoDescripcion
idPK text
codetext unique
deliveryNoteIdtextAlbaran origen
shipmentIdtext
boxItemIdFK → ItemTipo de caja
stagingAreaIdFK → StagingArea
statustextopen / sealed / shipped
weightKgdouble
pickedAttimestamp
sealedAttimestamp

PackageLine

Contenido de un paquete.

CampoTipoDescripcion
idPK text
packageIdFK → Package
itemIdFK → Item
quantitydouble
sourceLineIdtextLinea de albaran origen

PickingTask

Tareas de picking.

CampoTipoDescripcion
idPK text
docTypetextSDN / PDN
docIdtextID del albaran
docLineIdtextLinea del albaran
itemIdtext
warehouseId / zoneIdtext
requestedQtydouble
pickedQtydouble
statustextpending / partial / done / missing
shipmentIdtext
assignedUserId / pickedByUserIdtext

Stock avanzado

TransferNote

Traspasos entre almacenes.

CampoTipoDescripcion
idPK text
codetext
fromWarehouseIdtext
toWarehouseIdtext
datetimestamp
statustextdraft / sent / received
sentAt / receivedAttimestamp

TransferNoteLine

CampoTipoDescripcion
idPK text
transferIdFK → TransferNote
lineNuminteger
itemIdtext
quantitydouble
fromZoneId / toZoneIdtext
batchNumtext

GoodsReceipt

Entradas de mercancia.

CampoTipoDescripcion
idPK text
codetext
warehouseIdtext
typetextinternal / return / adjustment
statustextdraft / posted
postedAttimestamp

GoodsReceiptLine

CampoTipoDescripcion
idPK text
receiptIdFK → GoodsReceipt
lineNuminteger
itemIdtext
quantitydouble
zoneIdtext
batchNumtext

GoodsIssue

Salidas de mercancia.

CampoTipoDescripcion
idPK text
codetext
warehouseIdtext
typetextinternal / scrap / adjustment
statustextdraft / posted
postedAttimestamp

GoodsIssueLine

CampoTipoDescripcion
idPK text
issueIdFK → GoodsIssue
lineNuminteger
itemIdtext
quantitydouble
zoneIdtext
batchNumtext

Sistema

AuditLog

Registro inmutable de cambios.

CampoTipoDescripcion
idPK text
tenantIdFK → Tenant
entityTypetextItem, SalesInvoice, etc.
entityIdtext
actiontextCREATE / UPDATE / DELETE
userIdFK → GlobalUser
oldValuejsonbEstado anterior
newValuejsonbEstado nuevo
createdAttimestamp

Attachment

Archivos adjuntos.

CampoTipoDescripcion
idPK text
entityTypetextsales_invoice, item
entityIdtextID del documento
fileNametextNombre original
mimetextapplication/pdf, etc.
sizebigintBytes
providertextlocal, s3
externalIdtextRuta en storage
uploadedBytext
deletedAttimestampSoft delete

Notification

Notificaciones in-app por usuario.

CampoTipoDescripcion
idPK text
userIdtextDestinatario
titletext
bodytext
leveltextinfo / warn / error / success
linktextURL de accion
readAttimestampnull = no leida

Automation

Automatizaciones.

CampoTipoDescripcion
idPK text
tenantIdtext
nametext
enabledboolean
triggerTypetextschedule / event / manual
triggerConfigjsonb
actionTypetextemail / webhook / notification
actionConfigjsonb

AutomationRun

Ejecucion de automatizacion.

CampoTipoDescripcion
idPK text
automationIdFK → Automation
tenantIdtext
statustext
startedAt / finishedAttimestamp
durationMsinteger
errorTexttext

WebhookSubscription

Webhooks salientes.

CampoTipoDescripcion
idPK text
nametext
urltextEndpoint destino
eventstext[]Array de eventos
secrettextPara firma HMAC
isActiveboolean

Relaciones entre tablas

Tenant
├── UserTenantMembership → GlobalUser
├── TenantPlugin
│ └── PluginField / PluginTable
├── SystemConfig
├── UserModule
│ └── PluginTable
├── DocumentSeries → AccountingPeriod
├── DocumentTemplate
├── AccountingPeriod
│ └── JournalEntry
│ └── JournalEntryLine → ChartOfAccount, CostCenter, ProfitCenter, InternalOrder
│ └── SalesInvoice, PurchaseInvoice, SalesOrder, PurchaseOrder
│ └── SalesDeliveryNote, PurchaseDeliveryNote
├── ChartOfAccount
│ └── AccountMapping
│ └── DimensionRule
├── CostCenter / ProfitCenter / InternalOrder
│ └── JournalEntryLine
│ └── Employee, Department
├── PartnerGroup
│ └── BusinessPartner
│ └── PartnerAddress
│ └── Contact
│ └── SalesOrder, PurchaseOrder, SalesInvoice, PurchaseInvoice
├── PriceList
│ └── ItemPrice → Item
├── Category
│ └── Item (parentId)
├── Item
│ ├── ItemBatch / ItemSerial
│ ├── ItemAlternativeUom → UnitOfMeasure
│ ├── ItemWarehouseStock → Warehouse
│ ├── ItemZoneStock → WarehouseZone
│ └── SalesOrderLine, PurchaseOrderLine, SalesInvoiceLine, PurchaseInvoiceLine
├── Warehouse
│ └── WarehouseZone
│ └── ItemWarehouseStock, ItemZoneStock
│ └── GoodsReceipt, GoodsIssue, TransferNote
├── TaxGroup
│ └── Item, SalesOrderLine, PurchaseOrderLine, SalesInvoiceLine, PurchaseInvoiceLine
├── PaymentMethod
│ └── Payment → SalesInvoice / PurchaseInvoice
├── PaymentTerm
│ └── SalesInvoice, PurchaseInvoice
├── Currency
│ └── SalesInvoice, PurchaseInvoice, Payment, JournalEntryLine
├── DocumentType
│ └── SalesInvoice, PurchaseInvoice
├── Department
│ ├── Employee
│ └── Position
├── Employee
│ ├── Contract → Position, CollectiveAgreement
│ ├── Payroll → PayrollLine → PayrollConcept
│ ├── ShiftAssignment → ShiftTemplate, ShiftPattern
│ ├── TimeclockEntry
│ ├── Incident → IncidentType
│ ├── Substitution → Incident
│ ├── EmployeeEvaluation → EvaluationCycle, EvaluationCompetency
│ ├── EmployeeObjective → EvaluationCycle
│ ├── CommissionAccrual → CommissionRule
│ └── Task
├── Carrier
│ └── CarrierAccount
├── Vehicle
│ └── Route (vehicleId, defaultDriverEmployeeId)
├── Route
│ └── RouteStop → Shipment
├── Shipment
│ ├── ShipmentEvent
│ ├── ShipmentPosition
│ └── Package
├── StagingArea
│ ├── StagingAreaItem → Item
│ └── ExternalPlatform (platformId)
├── Package
│ └── PackageLine → Item
│ └── PickingTask
├── TransferNote
│ └── TransferNoteLine → Item, WarehouseZone
├── GoodsReceipt / GoodsIssue
│ └── GoodsReceiptLine / GoodsIssueLine → Item, WarehouseZone
├── Automation
│ └── AutomationRun
├── WebhookSubscription
├── AuditLog → GlobalUser, Tenant
├── Notification → GlobalUser
└── Attachment (polimorfico: entityType + entityId)