The Settings module is the central control panel for every tenant in B2B Import ERP. All configuration lives in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ency07/B2B-import/llms.txt
Use this file to discover all available pages before exploring further.
tenant_settings table as typed JSONB key-value pairs, organized by module category, and protected by Row Level Security so that one tenant can never read or modify another’s settings. Changes take effect immediately without requiring a deployment or server restart.
Settings Categories
Settings are grouped into seven modules. Each module corresponds to amodule value in the tenant_settings table:
EMPRESA — Company Identity
Core legal and operational identity:
nombre_comercial, razon_social, nit, regimen, direccion, ciudad, departamento, pais, codigo_postal, web, email_corporativo, telefono_principal, telefono_secundario, whatsapp_principal, whatsapp_soporte, whatsapp_ventas, telegram_chat_id, horario_laboral_inicio, horario_laboral_fin.LOCALIZACION — Regional Settings
Regional preferences:
zona_horaria, idioma, moneda, formato_fecha, formato_hora, separador_decimal, separador_miles.IDENTIDAD — Branding and Visual
Logo URLs (
logo_claro_url, logo_oscuro_url, logo_login_url, logo_pdf_url, favicon_url, splash_url, loader_url, icono_movil_url), color tokens (color_primario, color_secundario, color_exito, color_warning, color_danger, color_info), and typography settings (tipografia_principal, border_radius, sombras, animaciones). These values are loaded by the White Label system at runtime.DOCUMENTOS — Document Templates
PDF and print configuration:
pie_pagina, encabezado, firma_url, sello_url, qr_habilitado, margin settings (margen_superior, margen_inferior, margen_izquierdo, margen_derecho), numeracion_formato, formato_pdf, formato_impresion.ERP — System Preferences
ERP-level metadata and support links:
nombre_sistema, version_visible, url_soporte, email_soporte, url_centro_ayuda, url_manual_usuario, url_politica_privacidad, url_terminos, url_cookies.INTEGRACIONES — External Services
API keys and configuration for email providers, WhatsApp, Telegram, SMS gateways, AI inference services, payment processors, storage buckets, maps, calendar integrations, and webhooks. See the Integrations module for full details.
TELEFONIA — Contact Numbers
All company phone numbers stored individually: sales, support, emergencies, billing, guarantees, admin, manager, technician, WhatsApp, and SMS lines. The database enforces E.164 international format (
+573001112233) for every value.Configuration Storage Model
Settings are persisted as JSONB rows intenant_settings. Each row has a module, config_key, and config_value:
validate_tenant_settings_white_label) enforces format rules on write:
- Color values (
color_primario, etc.) must be valid hex (#RRGGBB), RGB/RGBA, HSL/HSLA, or a named CSS color. - URL values (all
*_urlkeys) must be absolute URLs, relative paths, or base64 data URIs. - TELEFONIA values must match E.164 international phone format.
notification_routes(inINTEGRACIONES) must be a valid JSON object.
pgp_sym_encrypt using the handle_tenant_settings_encryption trigger when is_encrypted = true. Decryption occurs transparently inside the get_tenant_setting() database function at read time.
Physical deletion of any settings row is blocked by the trg_block_physical_settings_delete trigger. All deactivations must use soft delete (deleted_at).
Branding Server Actions
Thesrc/app/actions/branding.ts file exports five Next.js Server Actions that manage tenant branding end-to-end:
| Action | Description |
|---|---|
getTenantBranding(tenantCode?) | Reads all settings from EMPRESA, LOCALIZACION, IDENTIDAD, and DOCUMENTOS modules and merges them with compile-time defaults from getBrandingDefaults(). Returns a complete BrandingConfig object. |
saveTenantBranding(tenantCode, data, description?) | Bulk-upserts the provided BrandingConfig fields to tenant_settings, then immediately takes a full snapshot of the resulting active configuration and stores it in tenant_branding_version. |
getBrandingHistory(tenantCode?) | Returns the list of BrandingVersion snapshots ordered by version_number descending. |
restoreBrandingVersion(tenantCode, versionId) | Reads the config_values snapshot from tenant_branding_version, upserts all keys back to tenant_settings, then records a new snapshot documenting the restoration. |
uploadBrandingLogo(tenantCode, fileType, base64Data, fileName, mimeType) | Uploads a logo or image asset to the tenant-logos Supabase Storage bucket and returns the resulting public URL. Accepted types: PNG, JPEG, SVG, GIF, ICO. Max size: 2 MB. |
Branding Versioning Flow
Every call tosaveTenantBranding() appends a new immutable row to tenant_branding_version. Calling restoreBrandingVersion() creates a new version rather than mutating history:
Branding settings changes take effect immediately for server-rendered pages. Any values cached in the browser’s
localStorage are refreshed on the next full page load, so users may see the previous branding for up to one navigation cycle after a change.Advanced Admin (Phase 34)
Phase 34 extends the Settings module with two new capabilities backed by dedicated tables:Custom Field Definitions
Administrators can define dynamic extra fields (
custom_field_definitions) for any of seven entity types: CLIENT, REQUIREMENT, QUOTE, JOB, INVOICE, WARRANTY, USER. Each field has a field_type (TEXT, NUMBER, DATE, LIST, FILE, BOOLEAN, JSON), an optional is_required flag, and — for LIST fields — a validated options array. The validate_entity_custom_fields trigger enforces schema compliance on every write to the target entity tables.Automation Rules
The
automation_rules table stores event-driven rules in the form IF event_type → DO action_type. Supported actions are DISPATCH_NOTIFICATION, CREATE_TASK, and WRITE_LOG. The execute_automation_rules() database function evaluates all active rules for a tenant when a business event fires.users table: avatar_url, preferred_language, preferred_theme, signature_url, timezone, and home_page.
Access Control
Only users with theADMINISTRADOR_TENANT, GERENTE, or GERENTE_GENERAL role can write to tenant_settings. All other authenticated users can read public settings (is_public = true) scoped to their own tenant. Platform super-admins have full cross-tenant access.