Factoring Operations Management System
An internal factoring platform for managing invoice portfolios, calculating discounts, tracking maturities, handling collections, and generating financial reports from a single centralized system.
PostgreSQL
Docker
Ubuntu
Nginx
Next.js
React
HTML5
About This Project
An internal tool for factoring companies to manage invoice portfolios—load operations, track maturities, calculate daily discounts, and collect payments without spreadsheets or manual math.
Key Features:
- Factoring operations CRUD – Register invoices with client, payer, face value, issue date, due date, and monthly rate. Auto-computes days, discount, advance, and expected gain.
- Client & payer directory – Manage cedentes (sellers) and pagadores (debtors) with RUC normalization, fuzzy search, and duplicate detection via PostgreSQL trigram indexes.
- Live dashboard – Stat cards for total portfolio, pending amount, expected profit, and overdue count. Timeline view of the next 7 days of maturities.
- Smart operations listing – Ordered by due date, overdue rows highlighted in red, cursor-based pagination, and filter by status, date range, client, or payer.
- One-click collection – Mark invoices as collected with a single button; idempotent SQL guards prevent double-collection; revert supported for corrections.
- Interest report – Date-range interest earned report with summary stat cards, top-5 client breakdown, and streaming Excel export with styled headers and frozen panes.
- Secure attachments – Upload PDF, JPEG, PNG, or WebP files (magic-byte verified, 10 MiB cap) linked to operations with server-authed download and orphan janitor cleanup.
- Auth with no public signup – Better Auth email+password login; users created exclusively via admin CLI. Cookie-based sessions with Origin-check CSRF.
- Spanish-first UX – All copy in español rioplatense (es-AR), USD currency formatting, and editorial typography with Fraunces serif + Geist sans.
- Responsive & accessible – Mobile-first layout with shadcn/ui primitives, keyboard navigation, loading skeletons, and print-friendly detail pages.
Tech Stack:
- Frontend: Next.js 16 (App Router), React 19, Tailwind CSS 4, shadcn/ui (Radix primitives), Fraunces + Geist fonts
- Backend: Next.js Server Actions, PostgreSQL view for derived fields, decimal.js for exact money math (HALF_UP)
- Database: PostgreSQL 16 (clients, payers, operations, attachments, sessions, accounts)
- Auth: Better Auth, argon2id password hashing, cookie sessions, Origin-check CSRF middleware
- Validation: Zod schemas (zMoney, zPercent, zDate) + React Hook Form
- ORM & Migrations: Drizzle ORM + Drizzle Kit
- Excel Export: ExcelJS streaming WorkbookWriter
- Testing: Playwright e2e (happy-path), unit tests for factoring math and identity normalization
- Infra: Docker Compose (multi-stage Dockerfile), nginx reverse proxy, Cloudflare TLS, nightly pg_dump backups, predeploy grep gate