workspace/projects/erp-suite/apps/verticales/vidrio-templado/database/init/02-rls-functions.sql
rckrdmrd 789d1ab46b
Some checks failed
CI Pipeline / changes (push) Has been cancelled
CI Pipeline / core (push) Has been cancelled
CI Pipeline / trading-backend (push) Has been cancelled
CI Pipeline / trading-data-service (push) Has been cancelled
CI Pipeline / trading-frontend (push) Has been cancelled
CI Pipeline / erp-core (push) Has been cancelled
CI Pipeline / erp-mecanicas (push) Has been cancelled
CI Pipeline / gamilit-backend (push) Has been cancelled
CI Pipeline / gamilit-frontend (push) Has been cancelled
changes on workspace
2025-12-09 14:46:20 -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
-- ============================================================================