workspace-v1/projects/erp-suite/apps/verticales/retail/database/init/02-rls-functions.sql
Adrian Flores Cortes 967ab360bb Initial commit: Workspace v1 with 3-layer architecture
Structure:
- control-plane/: Registries, SIMCO directives, CI/CD templates
- projects/: Gamilit, ERP-Suite, Trading-Platform, Betting-Analytics
- shared/: Libs catalog, knowledge-base

Key features:
- Centralized port, domain, database, and service registries
- 23 SIMCO directives + 6 fundamental principles
- NEXUS agent profiles with delegation rules
- Validation scripts for workspace integrity
- Dockerfiles for all services
- Path aliases for quick reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:35:19 -06:00

31 lines
1.1 KiB
PL/PgSQL

-- ============================================================================
-- FUNCIONES RLS - ERP Retail/POS
-- ============================================================================
-- Versión: 1.0.0
-- Fecha: 2025-12-09
-- Nota: Usa las funciones de contexto de ERP-Core (auth schema)
-- ============================================================================
-- Las funciones principales están en ERP-Core:
-- auth.get_current_tenant_id()
-- auth.get_current_user_id()
-- auth.get_current_company_id()
-- Función para obtener sucursal actual del usuario (para POS)
CREATE OR REPLACE FUNCTION retail.get_current_branch_id()
RETURNS UUID AS $$
BEGIN
RETURN current_setting('app.current_branch_id', true)::UUID;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;
$$ LANGUAGE plpgsql STABLE;
COMMENT ON FUNCTION retail.get_current_branch_id IS
'Obtiene el ID de la sucursal actual para operaciones POS';
-- ============================================================================
-- FIN FUNCIONES RLS
-- ============================================================================