Cosmic Module
O
Qubits of DPK
March 20, 2026
Core Open Source
The Analogy
Every night after the bank closes, a cleaning crew comes in and does all the work that can't be done while customers are present:
- Calculate everyone's daily interest
- Check who hasn't paid their EMI
- Apply late fees
- Classify overdue loans
- Prepare tomorrow's reports
This is COB — Close of Business. It's a batch job that runs every night and processes the entire loan and savings portfolio.
Why COB Exists
Real-time processing of millions of loans every time a payment is due is expensive and slow. Instead:
- During the day: human actions (deposits, repayments, approvals)
- At night (COB): automated processing (interest, penalties, delinquency)
Business Date vs System Date
This is critical to understand.
System Date: The actual current date on the server (e.g., 20 March 2026)
Business Date: The "bank's working date" — can be set independently
Why separate?
- If the server goes down on 15 March and comes back on 17 March, COB for 15 and 16 still needs to run
- In tests, you set the business date to simulate different dates without actually waiting
javascript
QUBITS OF DPK
COB always runs for the COB_DATE (business date), not the system date.
How COB Works — Spring Batch
Fineract uses Spring Batch for COB.
Layman: What is Spring Batch?
Spring Batch is a framework for processing large amounts of data in chunks. Instead of loading 10 million loans into memory at once, it processes them in batches of 100.
javascript
QUBITS OF DPK
The COB Steps — What Runs Each Night
For EACH active loan, these steps run in order:
Loan Locking — Critical Concept
Why Locks Exist
During COB, if a teller processes a repayment on a loan at the same time COB is applying interest, data corruption can occur.
Solution: COB locks each loan before processing it. Any API call trying to modify a locked loan gets rejected with an error.
In Code
java
QUBITS OF DPK
Inline COB
If a teller tries to process a repayment on a loan that hasn't had COB run yet today, Fineract runs COB inline (synchronously) before allowing the action:
javascript
QUBITS OF DPK
COB Infrastructure
Partitioning — Parallel Processing
For a bank with 1 million loans, COB can't run on one thread. Fineract partitions loans by ID range:
javascript
QUBITS OF DPK
All partitions run in parallel → 10x faster.
Batch Manager vs Batch Worker Mode
Fineract can run in split mode:
- Batch Manager: Schedules and coordinates the COB job, splits into partitions
- Batch Worker: Runs the actual processing for assigned partitions
This is tested in your PR #5658 (InstanceModeIntegrationTest)!
Scheduler — Triggering COB
COB is triggered by the Quartz Scheduler at a configured time (usually midnight).
java
QUBITS OF DPK
Triggering Manually (for testing)
javascript
QUBITS OF DPK
This is exactly what SchedulerJobHelper.runSchedulerJobByShortName() does in your tests!
Key Jobs in the Scheduler
The Business Date Fast-Forward Pattern
In integration tests, you often need to simulate time passing (e.g., to trigger a missed payment penalty). You use fastForwardTime():
java
QUBITS OF DPK
This loops: set COB date = March 1 → run COB → set COB date = March 2 → run COB → ... → March 31.