Partner commissions on serverless Node and Postgres, with no server to run
Описание и применение
Tandem CRM позволяет управлять комиссионными партнёров в серверless среде, используя только Postgres и функции Vercel, без выделенного сервера.
Задача
Managing long‑term partner commissions with hold periods, rate changes, refunds, and deactivations is error‑prone on a serverless stack.
Результат
Tandem CRM enables accurate, auditable partner commission management on a serverless stack without a dedicated server, reducing errors and simplifying maintenance.
Рабочий процесс
- Install tandem-crm and run init to apply migrations and seed demo data
- Create a lead via createLead, passing workspace, partner, and config
- Record a payment via recordPayment, which creates a commission line with its own rate and hold period
- Scheduled cron job calls release_due_commissions() to release held commissions
- Handle refunds by reducing or clawing back matching commission lines
- Deactivate partners to move unpaid lines to a house account
Доказательства
Tandem is an npm package plus a set of SQL migrations. You point it at a Postgres database you already have, and it adds a tandem schema with leads, agents, partners, commissions and payouts.
Each call is just a function that opens a database connection, does its work inside one transaction, and returns. Nothing holds state in memory between requests, so it does not care how many function instances you have or how often they start and stop.
The audits found real problems. A scheduled release job that could crash part way through. A case where a payment could silently produce no commission at all. Writes that were not safe if two requests arrived at the same moment.
- Дата записи: 2026-10-21T05:56:02.486Z