Skip to content

feat: sincronizacion automatica de tasa bcv y ui#27

Merged
josean798 merged 2 commits into
developmentfrom
feat/sincronizacion-tasa-de-cambio-bcv
Jun 4, 2026
Merged

feat: sincronizacion automatica de tasa bcv y ui#27
josean798 merged 2 commits into
developmentfrom
feat/sincronizacion-tasa-de-cambio-bcv

Conversation

@josean798

@josean798 josean798 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

🚀 Pull Request: Sistema de Sincronización de Tasas BCV

Este Pull Request introduce un nuevo sistema para sincronizar automáticamente las tasas de cambio del Banco Central de Venezuela (BCV). Incluye la infraestructura necesaria para el scraping (extracción de datos), persistencia en base de datos y la auto-aplicación de estas tasas a los eventos.


✨ Aspectos Clave

  • 🗄️ Nueva entidad y tabla BcvRate: Creada para almacenar las tasas obtenidas.
  • 🔄 Modelos actualizados: Se modificaron los modelos ExchangeRate y Event para soportar la sincronización automática.
  • 🧠 Integración de un Proveedor: Se añade un servicio que busca, cachea e integra las tasas del BCV, actualizando automáticamente los eventos configurados para esto.
  • 📦 Nuevas dependencias: Se incorporan herramientas para realizar peticiones HTTP y scraping de forma eficiente.

🛠️ Cambios Detallados

🔄 Sistema de Auto-Sincronización de Tasas BCV

  • Persistencia de datos: Se añadió la entidad, tabla y repositorio BcvRate para almacenar las tasas del BCV, junto con el esquema de Prisma y su respectiva migración. [1] [2] [3] [4] [5]
  • ⚙️ Servicio BcvProvider: Se implementó este servicio para consultar, guardar en caché y refrescar las tasas, actualizando automáticamente los eventos que tengan la opción autoSyncBcv activa.
  • 🕷️ Scraper del BCV: Desarrollado utilizando cheerio y undici para extraer los valores actualizados del USD y EUR directamente desde la página oficial del BCV.
  • 🏗️ Inyección de Dependencias: Se integraron el proveedor y el repositorio en el contenedor de DI, asegurando su inicialización al arrancar la aplicación. [1] [2] [3] [4] [5]

📊 Cambios en Esquemas y Entidades

  • 📅 Modelo Event: Se extendió para incluir el campo booleano autoSyncBcv, permitiendo a cada evento decidir si desea activar la sincronización automática. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • 💵 Modelo ExchangeRate: Se actualizó para admitir el campo source (manual o bcv). Además, el campo setBy ahora permite valores nulos (nullable) para diferenciar si la tasa fue fijada de forma manual por un usuario o de forma automática por el sistema. [1] [2] [3] [4]

📦 Nuevas Dependencias

  • 📦 Se agregaron cheerio (para el parsing de HTML) y undici (para realizar peticiones HTTP de manera eficiente). [1] [2]

close #26

Copilot AI review requested due to automatic review settings June 3, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end support for automatically fetching Banco Central de Venezuela (BCV) exchange rates, persisting them server-side, optionally auto-applying them to events, and exposing/consuming the data from the web UI.

Changes:

  • Added a new BCV rate domain (DB model + repository) plus a BCV provider/scraper and API module endpoints to fetch/sync rates.
  • Extended Event and ExchangeRate models/types to support autoSyncBcv and rate source (manual vs bcv), including UI updates to toggle auto-sync and display source.
  • Added scraping dependencies (cheerio, undici) and wired the provider into the API container.

Reviewed changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pnpm-lock.yaml Locks new dependencies (notably cheerio/undici) required for scraping.
packages/web/src/features/events/services/bcvService.ts Adds web client methods to read/sync BCV rates via API.
packages/web/src/features/events/pages/EventConfigPage.tsx Adds BCV rate card, manual sync button, auto-sync toggle, and source display in UI.
packages/web/src/features/events/hooks/useCurrentExchangeRate.ts Adds refetch-on-custom-event behavior for exchange rate updates.
packages/shared/src/utils/currency.ts Adds getEurUsdRate helper derived from BCV EUR/USD Bs rates.
packages/shared/src/types/index.ts Exports newly added BCV types.
packages/shared/src/types/exchangeRate.types.ts Extends exchange rate type with source and nullable setBy*.
packages/shared/src/types/event.types.ts Extends event type with autoSyncBcv.
packages/shared/src/types/bcv.types.ts Introduces BcvRateType shared contract.
packages/shared/src/schemas/event.schemas.ts Allows autoSyncBcv in event create/update schemas.
packages/api/src/modules/exchange-rates/exchange-rates.service.ts Adds source + optional setBy to exchange rate creation.
packages/api/src/modules/exchange-rates/exchange-rates.mapper.ts Maps new source and optional setBy* fields.
packages/api/src/modules/events/events.service.ts Persists and updates autoSyncBcv on events.
packages/api/src/modules/events/events.mapper.ts Exposes autoSyncBcv in API event payloads.
packages/api/src/modules/bcv/index.ts Registers BCV module composition (service/controller/router).
packages/api/src/modules/bcv/bcv.service.ts Implements BCV rate read/sync service.
packages/api/src/modules/bcv/bcv.routes.ts Defines authenticated BCV endpoints (GET /, POST /sync).
packages/api/src/modules/bcv/bcv.mapper.ts Maps BCV rate entity to shared BcvRateType.
packages/api/src/modules/bcv/bcv.controller.ts Adds controller handlers for read/sync.
packages/api/src/infrastructure/repositories/PrismaExchangeRateRepository.ts Persists and maps new exchange-rate source and nullable setBy.
packages/api/src/infrastructure/repositories/PrismaEventRepository.ts Persists/maps new autoSyncBcv field.
packages/api/src/infrastructure/repositories/PrismaBcvRateRepository.ts Adds Prisma-backed persistence for BCV rates.
packages/api/src/infrastructure/container.ts Wires BCV provider + repository and mounts BCV module routes.
packages/api/src/infrastructure/bcv/scraper.ts Implements BCV HTML scraping using undici + cheerio.
packages/api/src/infrastructure/bcv/provider.ts Implements caching, refresh logic, and auto-sync propagation to events.
packages/api/src/core/interfaces/repositories/IExchangeRateRepository.ts Updates exchange-rate repository contract for source + optional setBy.
packages/api/src/core/interfaces/repositories/IEventRepository.ts Updates event repository contract for autoSyncBcv.
packages/api/src/core/interfaces/repositories/IBcvRateRepository.ts Introduces BCV rate repository contract.
packages/api/src/core/entities/ExchangeRate.ts Extends domain entity with source and nullable setBy*.
packages/api/src/core/entities/Event.ts Extends domain entity with autoSyncBcv.
packages/api/src/core/entities/BcvRate.ts Introduces BCV rate domain entity.
packages/api/prisma/schema.prisma Adds autoSyncBcv, exchange-rate source, nullable setBy, and BcvRate model.
packages/api/prisma/migrations/20260602032103_add_bcv/migration.sql Creates/updates tables & constraints for BCV + new exchange-rate fields.
packages/api/package.json Adds cheerio and undici dependencies to API package.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/api/package.json Outdated
Comment thread packages/api/src/infrastructure/bcv/scraper.ts Outdated
Comment thread packages/api/src/infrastructure/bcv/provider.ts
Comment thread packages/api/src/infrastructure/bcv/provider.ts Outdated
Comment thread packages/api/src/infrastructure/container.ts Outdated
Comment thread packages/web/src/features/events/pages/EventConfigPage.tsx Outdated
Comment thread packages/api/src/modules/bcv/bcv.routes.ts Outdated
Comment thread packages/api/src/infrastructure/bcv/provider.ts Outdated
@josean798 josean798 requested a review from cristian907 June 4, 2026 12:57

@cristian907 cristian907 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed some issues.

@josean798 josean798 merged commit 7c2f365 into development Jun 4, 2026
1 check passed
@josean798 josean798 linked an issue Jun 4, 2026 that may be closed by this pull request
33 tasks
@josean798 josean798 deleted the feat/sincronizacion-tasa-de-cambio-bcv branch June 4, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: Sincronización de la tasa de cambio oficial del BCV

3 participants