DEV Community

Coco
Coco

Posted on

I got tired of calculating commercial lease billing by hand, so I built a tool

I worked in commercial real estate. Not as a developer — as an operator.
Every month, someone on the team had to sit down and manually calculate billing schedules. Every contract had a free rent period, a rent escalation clause, a non-standard start date. Usually all three. You’d open Excel, start calculating day counts, apply the escalation rate, handle the stub period at the beginning, handle the one at the end.
It took hours. It was error-prone. And when you got it wrong, the tenant pushed back.
I got tired of it. I knew how to code. So I built something.
What the problem actually looks like
A real contract:
Lease starts March 15
Free rent for the first 2 months
From month 3: base rate kicks in
From month 13: base rate × 1.05 (anniversary escalation)
Billing anchor is the 15th of each month
Now generate a clean monthly billing schedule for 3 years. Every period needs the right dates, the right applied rate, the right amount. The stub periods at the start and end need to be handled correctly. The free rent and escalation can overlap.
This is not a hard algorithm problem. It’s a tedious, high-stakes edge case problem. Get it wrong and you have a legal dispute. Get it right and you’ve spent two hours on something that should be automated.
@cosiu/periodix — an npm package that takes a lease contract and returns a fully split billing schedule.
const ContractPeriodMonthSplitter = require('@cosiu/periodix');

const result = ContractPeriodMonthSplitter.splitContractPeriods({
startDate: '2024-03-15',
endDate: '2027-03-14',
pivotDate: '2024-03-15',
area: 500,
baseTotalRentRate: 10000,
serviceRate: 3,
freePeriods: [
{ startDate: '2024-03-15', endDate: '2024-05-14' }
],
increaseRules: [
{
type: 'ANNIVERSARY',
anchorDate: '2024-03-14',
rate: 0.05
}
]
});

Each period in the output has exact dates, the applied escalation rate, rent and service fee amounts, and a flag for whether it’s a stub period or a full month.

try it:npm install @cosiu/periodix
GitHub: https://github.com/cocosiu/periodix
If you’re building property management software and you’ve been solving this problem yourself, I’d be curious whether your approach is different. And if you find an edge case this doesn’t handle, open an issue.

Top comments (0)