RF-SETTINGS-002: Configuraciones por Tenant
Identificacion
| Campo |
Valor |
| ID |
RF-SETTINGS-002 |
| Modulo |
MGN-006 Settings |
| Titulo |
Configuraciones por Tenant |
| Prioridad |
P0 - Critica |
| Estado |
Draft |
| Fecha |
2025-12-05 |
Descripcion
El sistema debe permitir que cada tenant configure parametros especificos de su organizacion, como zona horaria, formato de fecha, moneda por defecto, y otras preferencias de negocio.
Requisitos Funcionales
RF-SETTINGS-002.1: Estructura de Configuracion por Tenant
| Campo |
Tipo |
Descripcion |
| id |
UUID |
Identificador unico |
| tenant_id |
UUID |
FK al tenant |
| key |
VARCHAR(100) |
Clave de configuracion |
| value |
JSONB |
Valor de la configuracion |
| data_type |
ENUM |
Tipo de dato |
| inherited_from |
ENUM |
system, plan, custom |
| is_overridden |
BOOLEAN |
Si sobreescribe valor heredado |
RF-SETTINGS-002.2: Herencia de Configuraciones
Las configuraciones tienen una jerarquia de herencia:
SYSTEM (base)
│
└── PLAN (por plan de suscripcion)
│
└── TENANT (personalizado)
Reglas:
- Si tenant no tiene valor, usa el del plan
- Si plan no tiene valor, usa el del sistema
- Un tenant puede sobreescribir valores del plan
- Algunos valores del sistema no son sobreescribibles
RF-SETTINGS-002.3: Configuraciones de Localizacion
| Key |
Tipo |
Default |
Descripcion |
locale.timezone |
string |
UTC |
Zona horaria |
locale.date_format |
string |
YYYY-MM-DD |
Formato fecha |
locale.time_format |
string |
HH:mm:ss |
Formato hora |
locale.currency_id |
UUID |
null |
Moneda por defecto |
locale.language |
string |
es |
Idioma |
locale.country_id |
UUID |
null |
Pais por defecto |
RF-SETTINGS-002.4: Configuraciones de Negocio
| Key |
Tipo |
Default |
Descripcion |
business.fiscal_year_start |
string |
01-01 |
Inicio año fiscal |
business.week_start |
number |
1 |
Dia inicio semana (1=Lunes) |
business.default_payment_terms |
number |
30 |
Dias de credito |
business.require_vat |
boolean |
false |
VAT obligatorio |
business.tax_inclusive |
boolean |
false |
Precios con impuesto |
RF-SETTINGS-002.5: Configuraciones de Apariencia
| Key |
Tipo |
Default |
Descripcion |
appearance.logo_url |
string |
null |
Logo del tenant |
appearance.primary_color |
string |
#1976d2 |
Color primario |
appearance.favicon_url |
string |
null |
Favicon |
appearance.company_name |
string |
null |
Nombre a mostrar |
RF-SETTINGS-002.6: Configuraciones de Modulos
Cada modulo puede tener configuraciones especificas:
// Ejemplo: Configuraciones de inventario
{
'inventory.default_warehouse_id': UUID,
'inventory.allow_negative_stock': boolean,
'inventory.auto_reorder': boolean
}
// Ejemplo: Configuraciones de ventas
{
'sales.default_tax_id': UUID,
'sales.require_approval': boolean,
'sales.approval_threshold': number
}
Operaciones CRUD
Listar Configuraciones del Tenant
GET /api/v1/settings/tenant?category=locale
Response:
{
"data": [
{
"key": "locale.timezone",
"value": "America/Mexico_City",
"inheritedFrom": "custom",
"isOverridden": true,
"defaultValue": "UTC"
}
]
}
Obtener Configuracion Efectiva
GET /api/v1/settings/tenant/:key
Response:
{
"key": "locale.timezone",
"value": "America/Mexico_City",
"effectiveValue": "America/Mexico_City",
"inheritedFrom": "custom",
"systemDefault": "UTC",
"planDefault": "America/Mexico_City"
}
Actualizar Configuracion
PUT /api/v1/settings/tenant/:key
{
"value": "America/Bogota"
}
Restaurar a Valor Heredado
DELETE /api/v1/settings/tenant/:key
// Elimina la sobreescritura, vuelve al valor del plan/sistema
Obtener Todas las Configuraciones Efectivas
GET /api/v1/settings/tenant/effective
Response:
{
"locale": {
"timezone": "America/Mexico_City",
"dateFormat": "DD/MM/YYYY",
"currency": { "id": "...", "code": "MXN" }
},
"business": {
"fiscalYearStart": "01-01",
"weekStart": 1
}
}
Reglas de Negocio
| ID |
Regla |
Severidad |
| BR-001 |
Admin del tenant puede modificar configuraciones |
Error |
| BR-002 |
Configuraciones bloqueadas por plan no son editables |
Error |
| BR-003 |
Timezone debe ser valida (IANA) |
Error |
| BR-004 |
Currency debe existir en catalogos |
Error |
| BR-005 |
Cambios se replican a cache inmediatamente |
Info |
Criterios de Aceptacion
Historial
| Version |
Fecha |
Autor |
Cambios |
| 1.0 |
2025-12-05 |
Requirements-Analyst |
Creacion inicial |