# Distributor Billing System

> TypeScript REST APIs for invoices, payments, ledgers, bank reconciliation, and scheduled financial workflows.

Author: Nirdesh Pokharel

Canonical URL: https://nirdeshpokhrel.com.np/work/distributor-billing

## Architecture

REST API → Invoices / payments / ledgers; bank transactions → Rule matching → AI-assisted review; Bull → Scheduled workflows

## Business workflow

The backend supports invoices, payments, ledgers, inventory, and reporting. Payment gateways and webhook delivery connect the internal financial workflows to external systems, while Excel/CSV pipelines support moving data into and out of the platform.

## Reconciliation approach

Bank reconciliation combines rule-based matching with an AI-assisted workflow for ambiguous transactions and manual review. The distinction matters: a model suggestion is part of the review workflow, not evidence that a transaction is definitively reconciled or authorized to post to a ledger.

## Asynchronous processing

Bull-based scheduled jobs support daily financial workflows. Moving work into jobs separates it from an interactive request, but introduces questions about retries, duplicate processing, and partial completion. The public summary does not establish the implemented retry or transaction policy.

## Integration boundaries

Payment integration and webhook delivery require mapping external events into internal records. A sound review checks payload validation, repeated notifications, delayed events, and failures after a payment provider has accepted a request. These are validation priorities rather than unsupported claims of a specific implementation.

## Import and export considerations

Spreadsheet and CSV inputs can include malformed values, duplicate rows, and inconsistent date formats. Reporting must retain the appropriate access scope. The known implementation includes import-export pipelines; validation details and production volumes remain unpublished.

## Delivered scope

The work spans the REST API suite, reconciliation workflow, scheduled processing, payment integration, and data exchange. No reconciliation accuracy, financial volume, or processing-speed claim is made without source measurements.
