feat(client): V1 fiado / cuenta corriente — cliente side - #273
Open
pabloalvarez99 wants to merge 1 commit into
Open
feat(client): V1 fiado / cuenta corriente — cliente side#273pabloalvarez99 wants to merge 1 commit into
pabloalvarez99 wants to merge 1 commit into
Conversation
The retail-chico essential #1: fiar al cliente habitual y llevarle la cuenta (business-depth-master-plan §V1). Client side; the backend ships par-coordinado to a frozen contract. Degrades gracefully so it is safe to integrate ahead of it. - api.ts (append-only): CuentaCorriente/CuentaMovimiento types, cuentaCorriente / registrarAbono / posSaleCuenta wrappers, PAYMENT_CUENTA + CUENTA_MODULE_MISSING, and cuentaUnavailable(err) — a narrow "backend not ready" detector (sentinel + Tauri "command not found" + 404/no-implementada) that never hides a real error. The exported PaymentMethod union is untouched. - pos.ts: "Cuenta corriente (fiar)" payment rail, gated to a selected customer (fiarEnabled): disabled with a hint until one is picked, falls back to Efectivo if the customer is cleared. No tender panel for fiado; "Cobrar"→"Fiar"; checkout via posSaleCuenta; cuentaUnavailable → "no disponible" without breaking the cart. - clientes.ts: "Cuenta corriente" section in the detail panel — saldo pill (Debe/Al día), cupo+disponible, movimientos table signed by tipo, abono modal (validateAbono), printable estado de cuenta (#cuenta-print), graceful 404. - rutbrand.css (append): cuenta panel, disabled fiar rail, @media print estado. Tests (TDD): cuenta-fiado.test.ts (17, pure) + cuenta-fiado.dom.test.ts (6, happy-dom, api mocked). GATE: npm run build (tsc + vite) + npm test (664 passed). Scope: views/{pos,clientes}.ts + api.ts + rutbrand.css (appends). No backend, no src-tauri, no migrations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
V1 business-depth ⭐ — fiado / cuenta corriente (lado cliente)
El esencial #1 del retail chico chileno: fiar al cliente habitual y llevarle la cuenta (
docs/strategy/business-depth-master-plan.md§V1). Esta PR es el lado cliente (Tauri); el backend lo despacha paxoloop al próximo worker libre (par coordinado) contra el contrato FROZEN que aquí se consume. Degrada graceful → seguro de integrar antes que el backend.Contrato FROZEN consumido
GET /api/v1/clientes/:id/cuenta→{ saldo, limite, movimientos[] }(CLP int).pos_saleconpaymentMethod = pos_cuenta(sin tender; el server abre el cargo). Gated a cliente.POST /api/v1/clientes/:id/cuenta/abono { monto, medio }→ abono (a caja).Cambios
api.ts(append-only): tiposCuentaCorriente/CuentaMovimiento, wrapperscuentaCorriente/registrarAbono/posSaleCuenta, constsPAYMENT_CUENTA/CUENTA_MODULE_MISSING, ycuentaUnavailable(err)— detector angosto de "backend aún no listo" (sentinel +command … not foundde Tauri + 404/no-implementada) que nunca oculta un error real (permiso/negocio). La unión exportadaPaymentMethodqueda intacta.pos.ts: medio "Cuenta corriente (fiar)", gated a cliente seleccionado (fiarEnabled): disabled+hint hasta elegir; si se quita el cliente con fiado activo, cae a Efectivo. Sin panel de tender en fiado; "Cobrar"→"Fiar"; checkout víaposSaleCuenta;cuentaUnavailable→ "no disponible" sin romper el carro.clientes.ts: sección "Cuenta corriente" en el detalle — pill de saldo (Debe/Al día), cupo+disponible, tabla de movimientos firmada por tipo (+/−), modal "registrar abono" (validateAbono), estado de cuenta imprimible (#cuenta-print,window.print), graceful-404.rutbrand.css(append): panel cuenta, rail fiado:disabled,@media printdel estado.Tests (TDD, RED→GREEN)
cuenta-fiado.test.ts— 17, pure: gate,validateAbono, render saldo/movs, print, escaping XSS,cuentaUnavailable.cuenta-fiado.dom.test.ts— 6, happy-dom (api mockeada): render, graceful-404, abono POST+reload, abono cero rechazado, fiar gating ambos sentidos.GATE:
npm run build(tsc--noEmit+ vite, exit 0) +npm test→ 31 files passed · 664 passed / 7 todo, cero regresiones.Scope:
views/{pos,clientes}.ts+api.ts(append) +rutbrand.css(append). Sin backend, sinsrc-tauri, sin migraciones.ui.ts/format.tssólo lectura.🤖 Generated with Claude Code