Skip to content

fix(backoffice): rechazar importes negativos, facturas duplicadas y fechas de pago imposibles - #23

Merged
bpstack merged 3 commits into
claude/compassionate-planck-gh6aoffrom
opencode/fix-backoffice-invoices
Oct 12, 2026
Merged

bpstack merged 3 commits into
claude/compassionate-planck-gh6aoffrom
opencode/fix-backoffice-invoices

Conversation

@bpstack

@bpstack bpstack commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Cambios

  • Crear y editar una factura rechaza importes negativos, el mismo número del mismo proveedor (409 BACKOFFICE_INVOICE_DUPLICATE) y una fecha de pago imposible.
  • Migración 20261012_unique_invoice_supplier_number.sql (clave única), ya aplicada en Aiven el 2026-10-12; INDEX.md actualizado.

Por qué

La misma factura se podía registrar dos veces y se pagaban las dos en el lote mensual. Decidido el 2026-10-11.

…ssible payment dates

- validations/backoffice/invoice.ts: the rules decided on 2026-10-11. An
  amount is a number or the DECIMAL string the API returns, never negative;
  a payment date is a real day between the invoice date and today.
- Create and edit answer 400 BACKOFFICE_INVALID_AMOUNT for a negative or
  non-numeric amount, and 409 BACKOFFICE_INVOICE_DUPLICATE when the supplier
  already has an invoice with that number.
- Pay answers 400 BACKOFFICE_INVALID_PAYMENT_DATE for a date before the
  invoice, in the future or that does not exist.
- Migration 20261012_unique_invoice_supplier_number.sql adds the unique key
  (applied locally; pending on Aiven) and its row in INDEX.md.
- error-codes.ts, errors.json (es, en), errorCodeMessage.ts: the three codes.
- docs/backoffice: the new rules, and the two decisions to keep deleting
  permanent and validation without a stamped PDF.
- invoice-rules.test.ts: the rules, the controller and the migration.

Why: negative amounts, the same invoice twice (both paid in the monthly
batch) and any payment date were saved. Checked with curl against the
local database: all three were accepted before and are refused now, and an
edit that sends the amounts back as strings still saves.
…Aiven

- INDEX.md: the migration row now reads applied on local and Aiven.

Why: it was applied on Aiven on 2026-10-12 after a dry run and read-only
checks of its preconditions, and verified afterwards.
…of' into opencode/fix-backoffice-invoices

# Conflicts:
#	backend/db-mysql/INDEX.md
@bpstack
bpstack merged commit 05d830f into claude/compassionate-planck-gh6aof Oct 12, 2026
4 checks passed
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
four-points Ready Ready Preview Oct 12, 2026 6:53pm UTC

@bpstack
bpstack deleted the opencode/fix-backoffice-invoices branch October 12, 2026 19:01

This branch was successfully deployed

1 active deployment
Preview — c800dbe3 Deployed Oct 12, 2026 by vercel[bot]
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.

1 participant