workspace-v1/projects/erp-suite/apps/verticales/vidrio-templado/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 Vidrio Templado
-- ============================================================================
-- 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 calcular área de vidrio en m2
CREATE OR REPLACE FUNCTION vidrio.calculate_area_m2(
width_mm DECIMAL,
height_mm DECIMAL
)
RETURNS DECIMAL AS $$
BEGIN
RETURN (width_mm / 1000.0) * (height_mm / 1000.0);
END;
$$ LANGUAGE plpgsql IMMUTABLE;
COMMENT ON FUNCTION vidrio.calculate_area_m2 IS
'Calcula el área en metros cuadrados a partir de dimensiones en milímetros';
-- ============================================================================
-- FIN FUNCIONES RLS
-- ============================================================================