-- Monedas base y menú de configuración
-- Módulo Configuración: 3d9e6a32-afc0-4eb8-da97-f4f26f4d5e4f
-- Rol Administrador: 8a9b3a32-dfc7-4eb5-aa94-c1f93f1d2e1c

INSERT INTO currencies (id, code, name, symbol, decimal_places, is_active)
VALUES
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b5c', 'USD', 'Dólar estadounidense', '$', 2, TRUE),
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b5d', 'COP', 'Peso colombiano', '$', 2, TRUE),
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b5e', 'EUR', 'Euro', '€', 2, TRUE),
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b5f', 'DOP', 'Peso dominicano', 'RD$', 2, TRUE),
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b60', 'MXN', 'Peso mexicano', '$', 2, TRUE),
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b61', 'CAD', 'Dólar canadiense', 'C$', 2, TRUE),
  ('f0a1b2c3-d4e5-4f6a-8b9c-0d1e2f3a4b62', 'GBP', 'Libra esterlina', '£', 2, TRUE)
ON CONFLICT (code) DO UPDATE
SET name = EXCLUDED.name,
    symbol = EXCLUDED.symbol,
    decimal_places = EXCLUDED.decimal_places,
    is_active = EXCLUDED.is_active,
    updated_at = CURRENT_TIMESTAMP;

INSERT INTO auth.page (id, module_id, name_es, name_en, path, icon, order_index, is_active)
VALUES
  ('d7e8f9a0-b1c2-4d3e-4f5a-6b7c8d9e0f1a', '3d9e6a32-afc0-4eb8-da97-f4f26f4d5e4f', 'Monedas', 'Currencies', '/security/currencies', 'payments', 8, TRUE)
ON CONFLICT (id) DO UPDATE
SET module_id = EXCLUDED.module_id,
    name_es = EXCLUDED.name_es,
    name_en = EXCLUDED.name_en,
    path = EXCLUDED.path,
    icon = EXCLUDED.icon,
    order_index = EXCLUDED.order_index,
    is_active = EXCLUDED.is_active,
    updated_at = CURRENT_TIMESTAMP;

INSERT INTO auth.profile (role_id, page_id, can_view, can_create, can_edit, can_delete)
VALUES
  ('8a9b3a32-dfc7-4eb5-aa94-c1f93f1d2e1c', 'd7e8f9a0-b1c2-4d3e-4f5a-6b7c8d9e0f1a', TRUE, TRUE, TRUE, TRUE)
ON CONFLICT (role_id, page_id) DO UPDATE
SET can_view = EXCLUDED.can_view,
    can_create = EXCLUDED.can_create,
    can_edit = EXCLUDED.can_edit,
    can_delete = EXCLUDED.can_delete;
