How to collect and disburse millions worth of payments securely.

Illustration showing payment collections and disbursements.

What is Disbursement?

  • Employee salaries
  • Payroll expenses
  • Payments to suppliers, contractors, and vendors
  • Reimbursements to workers for out-of-pocket expenses
  • Dividend payments to shareholders
  • Profit distributions to other business owners

Responsibilities and features

  1. Avoid duplicate payments: If beneficiaries get funds at regular frequencies due to dividend or salary. There’s a higher chance of duplicate payments due to the recurring nature of the code.
  2. Avoid over-payments: Disbursing the funds more than the funds collected from the company (including the in-flight amount) is a loss.
  3. Able to consume payment status: It’s not a rare occasion to have payment failure, this module should be able to rollback the calculation if there’s a failure.
  4. Check on the credit-limit: It’s common practice for businesses to allow credit-limit to their clients. At any point in time, the system should able to keep current credit per client.

Data models and Flow

  1. The true amount for payroll, loan, profit: will be stored in trueAmount
  2. Collections: will be stored in amountCollected
  3. Disbursements: will be stored in amountDisbursed

Important metrics to be observed

Overpayment = amountDisbursed - trueAmount
FrontedAmount = amountDisbursed — amountCollected
DeficitAmount = trueAmount - amountCollected

Data Models

  • BalanceAccount
    - trueAmount: Current amount should be for the beneficiary (either for profit/payroll).
    - amountCollected: Amount received from the company.
    - amountDisbursed: Amount paid ahead to the beneficiary.
    - companyId: Primary Id for the company.
    - amountTxn: List of all instances of amount records attributed.
    - collectedTxn: List of transactions collected and are attributed.
    - disbursedTxn: List of transactions disbursement and attributed.
  • Transactions
    - amount: Amount this transaction is carrying.
    source: The entity where the amount will be debited.
    - destination: The entity where the amount will be credited.
    - transactionDate: This date will help to attribute quarter and year.

Data Flow

Data-flow diagram representing connection with relevant entities.

Implementation with MongoDB


def commit(transaction):     


def rollback(transaction): 
assert transaction.canRollback

Sample Code Snippet using Django ORM

Further reading




Code, arts, process and aspirations. co-Founded GreedyGame | IIT Ropar. Found at

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Two Sum Problem Solved Using Ruby

Improve Your Coding Efficiency Immediately

Introducing Jetstack Subscription

Must do Dynamic Programming questions for SDE Interviews

CI with Jenkins and GitHub in K8s

What to expect at FarmHack NG (HACK 101 Part 2)

Scala reminder: Gotta name an argument to use it twice

Hackathons 101: Your Guide to nwHacks

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arink Verma

Arink Verma

Code, arts, process and aspirations. co-Founded GreedyGame | IIT Ropar. Found at

More from Medium

Why We Invested: Qualifi

Why Proptech Startups Fail?

Instant nets $2.2m pre-seed, with an eye towards building a frictionless economy

Startup Grind Global Conference 2022 — my personal take