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

Commit

def commit(transaction):     
BalanceAccount.objects(
company=transaction.company,
transactions__ne=transaction
).modify(
inc__amount=transaction.amount,
push__transactions=transaction
)

Rollback

def rollback(transaction): 
assert transaction.canRollback
BalanceAccount.objects(
company=transaction.company,
transactions=transaction
).modify(
dec__amount=transaction.amount,
pull__transactions=transaction
)

Sample Code Snippet using Django ORM

Further reading

--

--

--

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

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

Recommended from Medium

Strong VS Weak/Unowned References & ARC in Swift

Should all ML Frameworks be Standardized?

Regular Expression Made Easy Part- 1

Deploy Custom Domains And SSL using App Service Managed Certificate through ARM Template

Can’t see the Xcode’s Canvas, if put “import SwiftUI” on over 500 lines of code.

Character Cell to Tiles and Back Again Algorithm

Screen Shot 2022-01-27 at 7.25.14 PM.png

FFmpeg — Your powerful video/audio helper in your application

Runkeeper versus Workout activities on Apple Watch

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 www.arinkverma.in

More from Medium

KA-CHING: Building Our Monetization Machine

Apollo.io x Nexus Venture Partners | A Conversation about Scaling Product-Led Growth

How We Use Internal Hackathons to Create New Product Features | Courier

List of Financial MVP Development Companies