Sub topic 13
Building a balance check
This chapter assumes you can build the three statements for one period. It also assumes you know the indirect-method cash flow layout and the accounting equation. Here you will build the control that tells you whether your links are correct.
What a balance check is
A balance check is a cell, or a function, that computes one number:
difference = total assets - (total liabilities + total equity)If every link in the model is right, the difference is zero in every period. If it is not zero, at least one link is wrong. The check cannot say which link, but its size and sign give you strong hints, covered in the next chapter.
The check only has value if the two sides are computed independently. Assets must come from their own lines: cash from the cash flow statement, receivables and PP&E from their schedules. Liabilities and equity must also come from their own lines. If you ever set one side to "whatever makes it balance", the check always passes and tells you nothing.
The minimal version
The first example is the one-period model from the earlier chapters. The check sits at the end, and the numbers are the ones you have already seen.
opening = {"cash": 100.0, "ar": 50.0, "ppe": 200.0,
"ap": 30.0, "debt": 120.0, "equity": 200.0}
# Assumptions
tax_rate = 0.25
interest_rate = 0.08
revenue = 500.0
operating_costs = 380.0
depreciation = 20.0
capex = 30.0
dividends = 20.0
debt_repayment = 10.0
ar_close = 60.0
ap_close = 35.0
# Income statement
interest = interest_rate * opening["debt"]
pretax = revenue - operating_costs - depreciation - interest
net_income = pretax - tax_rate * pretax
# Cash flow statement (indirect method)
cfo = (net_income + depreciation
- (ar_close - opening["ar"])
+ (ap_close - opening["ap"]))
cfi = -capex
cff = -debt_repayment - dividends
cash_close = opening["cash"] + cfo + cfi + cff
# Balance sheet
assets = cash_close + ar_close + (opening["ppe"] + capex - depreciation)
liabilities = ap_close + (opening["debt"] - debt_repayment)
equity = opening["equity"] + net_income - dividends
print(round(net_income, 2), round(cash_close, 2))
print(round(assets, 2), round(liabilities + equity, 2))
assert abs(assets - (liabilities + equity)) < 1e-6The model prints a net income of 67.8 and closing cash of 122.8. Assets and liabilities plus equity both come to 392.8. The assert is the check in its simplest form. It is too blunt for real work, because it stops the program on the first failure and does not report the size of the gap.
Why use a tolerance, not exact equality
Spreadsheets and Python both use binary floating-point numbers. Sums such as 0.1 + 0.2 do not come out exactly equal to 0.3. An exact comparison with == can fail on a model that is correct.
Compare against a small tolerance instead. A common choice is 0.001 or 0.005 in model units. Choose a value well below the smallest amount you care about. In a model in millions, 0.001 means a thousand dollars. Do not use a loose tolerance such as 1 to make a red flag go away. A tolerance that hides a real error is worse than none.
In a spreadsheet, round the difference rather than comparing it raw, for example =ROUND(Assets-(Liabilities+Equity),3). Then format the cell to turn red when it is not zero.
A reusable check that reports the gap
A function that returns the difference lets you print it, log it, or test it. This version also shows what happens when one link is deliberately broken. Capex is left out of the PP&E roll-forward but is still deducted in the cash flow statement.
TOL = 0.005
def balance_check(assets, liabilities, equity, tol=TOL):
diff = assets - (liabilities + equity)
return {"difference": round(diff, 6), "ok": abs(diff) < tol}
def build_period(opening, link_capex=True):
interest = 0.08 * opening["debt"]
pretax = 500.0 - 380.0 - 20.0 - interest
net_income = pretax * (1 - 0.25)
cfo = net_income + 20.0 - (60.0 - opening["ar"]) + (35.0 - opening["ap"])
cash_close = opening["cash"] + cfo - 30.0 + (-10.0 - 20.0)
ppe_close = opening["ppe"] + (30.0 if link_capex else 0.0) - 20.0
assets = cash_close + 60.0 + ppe_close
liabilities = 35.0 + (opening["debt"] - 10.0)
equity = opening["equity"] + net_income - 20.0
return balance_check(assets, liabilities, equity)
opening = {"cash": 100.0, "ar": 50.0, "ppe": 200.0,
"ap": 30.0, "debt": 120.0, "equity": 200.0}
print(build_period(opening, link_capex=True))
print(build_period(opening, link_capex=False))The first call returns a difference of 0.0 and ok is True. The second returns a difference of -30.0 and ok is False. The missing 30 sits entirely on the asset side, so assets fall short by exactly the capex amount. That exact match is the kind of clue you look for.
Checking every period
A real model has many forecast periods, and each period's closing balance becomes the next period's opening balance. An error in period 1 carries into every later period. The check should therefore run for each period, and you should find the first failure, because later failures are usually inherited.
def first_failure(results, tol=TOL):
for period, diff in enumerate(results, start=1):
if abs(diff) >= tol:
return period, diff
return None
differences = [0.0, 0.0, -30.0, -30.0, -30.0]
print(first_failure(differences))This prints (3, -30.0). The error began in period 3, and periods 4 and 5 only repeat it. If you start debugging from period 5, you will chase a problem that is two periods old.
In a spreadsheet, add one summary cell that tests the whole row, such as =IF(MAX(ABS(row))<0.005,"OK","ERROR"). Put it at the top of the model so it cannot be missed.
Secondary checks worth adding
The main check is necessary but not sufficient. Add a few cheap checks that catch errors it can miss.
- Cash tie. Closing cash on the balance sheet must equal opening cash plus net cash flow. If the balance sheet cash is a direct link to the cash flow statement, this is true by construction. It still catches someone who overwrote the link with a typed number.
- Retained earnings roll. Closing equity must equal opening equity plus net income minus dividends.
- Opening equals prior closing. For each period after the first, every opening balance must equal the previous period's closing balance.
- Non-negative cash. Negative cash is not an accounting error. It signals that the model needs a revolver or lower payouts, and the check makes it visible.
Two errors can offset each other. A +10 mistake in one line and a -10 mistake in another produce a difference of zero while both lines are wrong. A passing check shows the model is consistent, not that it is right. Sanity-check key ratios and growth rates separately.
Reading the difference
| Pattern of the difference | Likely cause |
|---|---|
| Equals one line item exactly | That item is missing or counted once on one side only |
| Equals twice a line item | A sign error, so the item moved the wrong way |
| Same non-zero value in every period | One-time error that carries forward |
| Grows each period | A recurring formula error, such as a missing flow |
| Equals the change in one working capital line | That change was left out of operating cash flow |
The sign of the difference matters too. A positive difference means assets are too high or liabilities and equity are too low.
Exercise
In a one-period model, the analyst forgets to subtract the 10 increase in receivables when computing cash flow from operations. Everything else is correct. What is the balance check difference, and what is its sign?
Show answer
Cash is overstated by 10, because the receivables increase should have reduced operating cash flow. Receivables on the balance sheet still rise by 10 as normal, so assets are 10 too high. The difference is +10, with assets exceeding liabilities plus equity.
Exercise
Why should a balance check use a small tolerance rather than testing for exact equality, and why should the tolerance not be set to something large like 1?
Show answer
Floating-point arithmetic produces tiny rounding differences, so an exact comparison can fail on a correct model. A small tolerance such as 0.005 absorbs that noise. A large tolerance would allow real errors, such as a missed amount of 0.9, to pass unnoticed.