HomeCase studiesAutomated B2B Invoice Financing & Receivables Escrow...

Case study · Zurich, Switzerland

Automated B2B Invoice Financing & Receivables Escrow Platform

Working Capital & Receivables Finance

Small and mid-sized suppliers often wait 60 to 90 days for corporate buyers to settle approved invoices, straining payroll and inventory cash flow while manual factoring desks drown in PDF checks and spreadsheet schedules. We built a B2B invoice financing platform in Python, Django, and PostgreSQL that automates QR-bill and e-invoice ingestion, debtor risk scoring, fractional funder allocation, and ISO 20022 escrow repayment matching. Suppliers access working capital rapidly while institutional funders gain auditable collateral and deterministic yield accounting.

Industry
Working Capital & Receivables Finance
Solution
A Python and Django underwriting and receivables financing platform with Celery risk pipelines, PostgreSQL fractional ledgering, and a React funding portal.
Platforms
Web & API
Stack
Python · Django · PostgreSQL · Celery · Redis · React
Location
Zurich, Switzerland · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Zurich, Switzerland. Names withheld by agreement.

Project Overview

Across Zurich and the wider DACH manufacturing and services economy, creditworthy SMEs frequently deliver goods to large enterprise buyers on 60-to-90-day payment terms. Bridging that liquidity gap through traditional bank factoring involves weeks of manual paperwork, physical contract signing, and opaque fee schedules. Meanwhile, institutional credit funds looking to finance short-duration trade receivables lack standardized collateral verification and real-time repayment tracking.

We engineered an automated B2B invoice financing platform built with Python, Django, and PostgreSQL, paired with Celery asynchronous underwriting pipelines and a React portal. Suppliers submit Swiss QR-bills or structured e-invoices digitally, risk teams verify debtor creditworthiness through automated checks, funders allocate capital across approved tranches, and incoming bank escrow settlements reconcile pro-rata repayments automatically.

Working Capital & Collateral Bottlenecks

Digitizing trade receivables uncovers legal and accounting complexities that generic lending software misses:

  • Double-pledging fraud risk: Without strict structural fingerprinting, dishonest borrowers can submit slightly altered PDFs of the same receivable across separate financing batches.
  • Fractional allocation races: When multiple institutional buyers fund slices of a large receivable simultaneously, naive availability checks allow over-subscription.
  • Unstructured repayment matching: Corporate accounts payable departments frequently bundle multiple invoices into one wire or mistype payment notes, stranding cash inside unallocated suspense accounts.
  • Floating-point yield distortion: Calculating daily discount rates, reserve holdbacks, and overdue penalty interest with binary floats introduces reconciliation penny errors at settlement.

Architectural Strategy

The platform centers on a strict collateral state machine inside Django backed by PostgreSQL transactional locks. Every invoice progresses through audited lifecycle states (Uploaded → AutomatedChecks → UnderwritingReview → ApprovedForFunding → Funded → Settled / Overdue).

Heavy external IO—extracting Swiss QR-bill payloads, querying commercial credit bureaus, verifying VAT registrations, and generating legal assignment notices—runs off the HTTP request cycle in Celery workers. Inside PostgreSQL, all monetary columns use fixed-precision NUMERIC types mapped exclusively to Python Decimal objects, ensuring every reserve release and funder distribution balances to the exact Rappen or Centime.

Core Capabilities

  • Structured QR-Bill & PDF Ingestion: Parses Swiss QR-bill payloads and e-invoice XML alongside OCR fallback, validating IBANs, VAT IDs, and due dates automatically.
  • Automated Risk Scoring & Fraud Fingerprinting: Cross-checks debtor credit limits, historical dilution rates, concentration caps, and active collateral hashes before human underwriters review a file.
  • Atomic Fractional Tranche Allocation: Lets institutional funders fund whole invoices or percentage slices programmatically or via the React marketplace without oversubscription.
  • Escrow & ISO 20022 Settlement Engine: Ingests daily camt.053 and camt.054 bank statements, matches structured payment references, and computes net supplier reserve releases plus funder yields.
  • Credit & Collection Ledger: Tracks grace periods, late-fee accruals, credit notes, and partial buyer payments with full audit history.

Technical Architecture

Suppliers upload receivables through a React portal backed by Django REST Framework. Upon persistence in encrypted object storage, Django dispatches a Celery underwriting chain over Redis to extract structured invoice fields, compute collateral uniqueness hashes, and fetch debtor credit ratings.

Flow: Supplier React Portal → Django REST API & Encrypted Vault → Celery Risk & Verification Workers (Redis) → PostgreSQL Collateral & Tranche Ledger (SELECT FOR UPDATE) → ISO 20022 Escrow Parser → Pro-Rata Funder Settlement

Approved invoices publish to eligible funders, whose allocations acquire SELECT FOR UPDATE locks on the invoice record inside PostgreSQL to guarantee exact capacity accounting. When corporate buyers remit funds to designated escrow virtual IBANs or QR references, scheduled bank-statement consumers reconcile inflows idempotently and generate payout batches.

Technology Stack

Category Technology detail
Core Application & API Python 3.12 with Django & Django REST Framework handling domain workflows and RBAC
Relational Ledger & Locks PostgreSQL with row-level SELECT FOR UPDATE locking and exact numeric Decimal columns
Async Underwriting & Jobs Celery workers orchestrated over Redis for credit checks, PDF parsing, and accrual runs
Client & Underwriter UI React SPA serving supplier invoice submission, funder allocation, and risk desks
Banking & ISO 20022 Sync Automated camt.053/camt.054 statement parsers and Swiss QR-bill reference validators
Document Vault Encrypted object storage with SHA-256 content hashing and watermarked contract generation
Auth & Audit Trail Session/JWT authentication, two-factor sign-off, and django-auditlog immutable history
Deployment Packaging Dockerized web, Celery worker, and beat-scheduler containers with automated schema checks

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Corporate buyers ignoring assignment notices and paying suppliers directly or sending short payments Built a suspense-account resolution workflow in Django allowing partial credit-note adjustments and automatic reserve clawbacks from subsequent supplier tranches.
Blocking web workers during slow external credit-bureau and sanctions lookups Offloaded external scoring calls to Celery chains with exponential retries and cached bureau snapshots per debtor for configurable freshness windows.
Concurrent institutional API bids contending over prime corporate receivables Serialized tranche allocations via PostgreSQL SELECT FOR UPDATE locks with short lock timeouts, choosing deterministic consistency over lock-free optimistic retries.
Auditing historical underwriting decisions months after policy rule updates Persisted immutable JSON snapshots of the debtor credit score, concentration exposure, and rule thresholds evaluated at the exact moment of approval.

Security & Reliability

Commercial receivables carry sensitive supplier pricing, customer rosters, and bank account mandates. Django enforces strict tenant isolation so suppliers view only their own receivables, while institutional funders see anonymized or authorized debtor risk dossiers strictly aligned with compliance agreements.

Every uploaded document is hashed and stored encrypted at rest, served to React reviewers only via short-lived pre-signed URLs. Two-factor authentication gates bank-account changes and payout releases, while Celery's idempotent task design—paired with unique accounting-date keys in PostgreSQL—guarantees that worker restarts never double-post daily discount accruals or duplicate escrow payout instructions.

Performance & Scale

Monthly end-of-quarter invoicing waves concentrate upload and bank-statement bursts into narrow daytime windows. Separating Django web containers from dedicated Celery queues for heavy OCR parsing, credit-bureau polling, and ISO 20022 statement ingestion ensures interactive underwriter dashboards stay snappy during peak submission mornings.

Database queries powering funder portfolio dashboards leverage composite PostgreSQL indexes on maturity dates and risk tiers alongside pre-aggregated position views, avoiding expensive runtime joins across historical settled tranches.

Operational Outcomes

Replacing manual spreadsheet factoring schedules with a unified Django and PostgreSQL platform strengthened control across suppliers, underwriters, and capital partners:

  • Faster underwriting turnaround: Automated QR-bill extraction, duplicate hashing, and debtor limit checks eliminate repetitive manual data verification before credit review.
  • Collision-free fractional funding: Database-enforced tranche locks let multiple institutional investors co-fund large receivables cleanly without reconciliation conflicts.
  • Hands-off escrow reconciliation: Automated ISO 20022 matching routes corporate buyer repayments straight through principal, yield, and supplier reserve settlement.
  • Audit-grade financial precision: Exact Decimal ledgering and immutable underwriting snapshots give Swiss and European compliance reviewers complete traceability across every financed franc or euro.

01 — Questions

asked about this kind of project

How does the platform detect a supplier attempting to finance the same invoice twice?

Every uploaded invoice undergoes both binary SHA-256 hashing and structured metadata fingerprinting across supplier tax ID, debtor UID, invoice number, issue date, and gross amount. PostgreSQL enforces uniqueness constraints on active collateral fingerprints, blocking duplicate submissions even if a supplier re-exports the PDF with a different filename.

Why use Python and Django with PostgreSQL for receivables financing workflows?

Factoring relies heavily on rich domain modeling—multi-party legal notices, tiered advance rates, grace-period penalties, and credit-bureau integrations. Django's ORM combined with strict PostgreSQL transactions and Python's native Decimal arithmetic allowed rapid iteration on complex financial rules without sacrificing mathematical accuracy.

How do you prevent race conditions when multiple institutional funders bid on the same invoice tranche?

Funding allocations execute inside atomic Django transactions using PostgreSQL SELECT FOR UPDATE row locks on the target invoice's remaining open capacity. Concurrent bid requests serialize cleanly at the database boundary, guaranteeing total funded capital never exceeds the approved advance ceiling.

How are corporate buyer repayments matched accurately to fractional funder payouts?

Each financed invoice receives a unique virtual IBAN or structured Swiss QR reference number printed onto the assignment notice. When automated ISO 20022 camt.054 credit notifications arrive from the escrow bank, a Celery reconciler matches the reference, allocates principal and accrued discount fees pro-rata across funders, and triggers payout instructions.

How are daily discount fees and late-payment accruals calculated safely?

Nightly Celery Beat schedules run idempotent accrual jobs keyed by invoice ID and accounting date in PostgreSQL. Using exact Python Decimal arithmetic with explicit day-count conventions prevents rounding drift across partial repayments and early settlements.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.