Repository navigation
feat(pagos): cablear Config.METODOS_REQUIEREN_CONFIRMACION (pago-confirmado.2b) - #165
Merged
Merged
Conversation
…irmado.2b / ADR §2) Completa el override configurable diferido de pago-confirmado.1. Los 6 sitios de creación de `Pago` resuelven la lista de métodos que nacen REPORTADO: - route handlers (`venta-libre`, `pagar-fiado`) → `getConfig(...)` (cacheado) - domain services (`ProcesarPedidoService`, `CrearVentasLibresService`) + `PrismaPagoRepository.createMany` → `leerMetodosRequierenConfirmacion(tx)` (nuevo helper en `pago-confirmacion.ts` que lee Config vía la tx en mano, sin importar el helper cacheado — mantiene el módulo libre de deps de framework) Sin config → cae al default del ADR §2 (NEQUI,TRANSFERENCIA,DAVIPLATA). Seed: `METODOS_REQUIEREN_CONFIRMACION` en seed.ts + seed-test.ts. Tests: +2 unit (`leerMetodosRequierenConfirmacion`); mocks de config agregados a venta-libre route test, PrismaPagoRepository test, procesar-pedido service test. tsc + 2763 unit + eslint verdes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… del use case 3 hallazgos, mismo tema: la lectura de `Config.METODOS_REQUIEREN_CONFIRMACION` era per-call dentro de transacciones (N+1 en el cierre de embarque, round-trip extra sin caché en la creación de pedidos — path sensible a lock-contention #20). Ahora se lee UNA vez en el boundary del use case y se pasa `string[]` hacia abajo: - `IPagoRepository.createMany` + impl: param opcional `metodosRequieren?` (fallback a la lectura si se omite, para llamadas directas). - `CrearPedidoUseCase` / `EntregarPedidoUseCase`: `leerMetodosRequierenConfirmacion(tx)` una vez, pasado a `createMany`. - `ProcesarPedidoService.execute` + `CrearVentasLibresService.execute`: 8º/5º param `metodosRequieren?`. `CerrarEmbarqueUseCase` lo lee una vez antes del loop y lo pasa a ambos (antes: una lectura por pedido dentro del lock CIERRE+SECUENCIA). Los route handlers siguen usando `getConfig` (cacheado 60s). tsc + 2763 unit + eslint verdes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…r operación
- **METODOS_REQUIEREN_CONFIRMACION / USUARIO_CONFIRMA_PAGOS** ahora tienen
validador en `config-validation.ts`: un typo en el CSV (`NEQUII,...`) antes
pasaba silencioso y dejaba ese método clasificado como CONFIRMADO. Ahora
`POST /api/config` lo rechaza. (CONFIRMED finding)
- Lectura de config: se mantiene vía `leerMetodosRequierenConfirmacion(tx)`
(NO `getConfig`/`unstable_cache` — rompe los unit tests del use case fuera
de un request context, verificado). Pero se lee UNA vez por operación:
- `CerrarEmbarqueUseCase`: una lectura antes del loop, pasada a
`ProcesarPedidoService` y `CrearVentasLibresService` (antes: una por pedido).
- `CrearPedidoUseCase` / `EntregarPedidoUseCase`: una lectura, pasada a
`PrismaPagoRepository.createMany` (param nuevo `metodosRequieren?`).
Tests: +3 config-validation. tsc + 2766 unit + eslint verdes.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qué
ADR-PAGO-REPORTADO-CONFIRMADO-001§2 — completa el override configurable que quedó diferido en pago-confirmado.1 (#156).Hasta ahora los 6 sitios de creación de
Pagoclasificaban por el default del ADR (NEQUI,TRANSFERENCIA,DAVIPLATA→ REPORTADO). Ahora leenConfig.METODOS_REQUIEREN_CONFIRMACION:venta-libre/route.ts,pagar-fiado/route.tsgetConfig(...)(cacheado, 60s TTL)ProcesarPedidoService,CrearVentasLibresService,PrismaPagoRepository.createManyleerMetodosRequierenConfirmacion(tx)— helper nuevo que lee Config vía la tx en mano (no importagetConfig→ mantiene el módulo libre de deps de framework para el dominio)Sin config → default del ADR. Seed añadido a
seed.ts+seed-test.ts.Verificación
npx tsc --noEmitOK ·npx vitest run→ 2763 OK ·npx eslintOKleerMetodosRequierenConfirmacion: sin config → default; con CSV → override)Rollback
git revert. Vuelve al default hard-codeado (idéntico comportamiento si el config no está seteado).🤖 Generated with Claude Code