Sub topic 2
Double-entry bookkeeping: debits and credits
This chapter assumes you know the accounting equation (assets = liabilities + equity) and the five account types: assets, liabilities, equity, revenue, and expenses. It also assumes you are comfortable with basic currency arithmetic.
The core idea
Double-entry bookkeeping records every transaction in at least two accounts. The amounts recorded on the left side of accounts must equal the amounts recorded on the right side. This keeps the accounting equation in balance after every transaction.
Two terms name the sides:
- A debit is an entry on the left side of an account.
- A credit is an entry on the right side of an account.
Debit and credit do not mean "increase" or "decrease". Whether a debit raises or lowers an account depends on the account's type.
The convention
The equation has assets on the left and liabilities plus equity on the right. The rules follow that layout.
| Account type | Debit | Credit |
|---|---|---|
| Asset | Increases | Decreases |
| Liability | Decreases | Increases |
| Equity (owner's capital) | Decreases | Increases |
| Revenue | Decreases | Increases |
| Expense | Increases | Decreases |
Revenue increases equity, so it follows the equity rule. Expenses decrease equity, so they behave the opposite way: a debit increases them.
Worked example
On January 15 a business pays 1,200 in rent from its bank balance. Two accounts change:
- Rent Expense increases by 1,200. Expenses increase with debits, so debit Rent Expense.
- Cash decreases by 1,200. Assets decrease with credits, so credit Cash.
The journal entry is:
Journal entry (January 15): Debit Rent Expense 1,200; Credit Cash 1,200Total debits (1,200) equal total credits (1,200). Assets fall by 1,200 and equity falls by 1,200 through the expense, so the equation still holds.
Now see the result in T-accounts, assuming Cash already held 10,000 plus a 1,500 receipt:
Cash Rent Expense
------------------------- -------------------------
10,000 | 1,200 | 1,200 |
1,500 | | |
------------------------- -------------------------
Bal 10,300 (debit) Bal 1,200 (debit)Each account's balance is the larger side minus the smaller side. Cash has 11,500 in debits and 1,200 in credits, so its balance is 10,300 on the debit side.
Checking balance in code
This script applies the same rule to four entries. It refuses any entry whose debits and credits differ, then builds a trial balance.
from collections import defaultdict
# Each journal entry: (date, memo, [(account, side, amount_in_whole_dollars), ...])
journal = [
("2026-01-02", "Owner invests cash",
[("Cash", "debit", 10000), ("Owner's Capital", "credit", 10000)]),
("2026-01-05", "Buy supplies on credit",
[("Supplies", "debit", 800), ("Accounts Payable", "credit", 800)]),
("2026-01-09", "Services for cash and on account",
[("Cash", "debit", 1500), ("Accounts Receivable", "debit", 2500),
("Service Revenue", "credit", 4000)]),
("2026-01-15", "Pay rent",
[("Rent Expense", "debit", 1200), ("Cash", "credit", 1200)]),
]
# Post: copy each line to the debit or credit side of its ledger account.
ledger = defaultdict(lambda: {"debit": [], "credit": []})
for date, memo, lines in journal:
total_debits = sum(a for _, side, a in lines if side == "debit")
total_credits = sum(a for _, side, a in lines if side == "credit")
assert total_debits == total_credits, f"Unbalanced entry on {date}: {memo}"
for account, side, amount in lines:
ledger[account][side].append(amount)
# Balance each account and build the trial balance.
debit_column = credit_column = 0
for account, sides in ledger.items():
net = sum(sides["debit"]) - sum(sides["credit"])
if net >= 0:
debit_column += net
print(f"{account:<22}{net:>8}{'':>8}")
else:
credit_column += -net
print(f"{account:<22}{'':>8}{-net:>8}")
print(f"{'Totals':<22}{debit_column:>8}{credit_column:>8}")
assert debit_column == credit_columnThe totals come to 14,800 on each side.
Common errors
- Treating debit as "increase". A debit decreases a liability, so the rule depends on account type.
- Recording only one side of a transaction. The entry no longer balances.
- Debiting an expense when you meant to credit it. The entry can still balance, so the error is easy to miss.
Exercise
A business buys 800 of supplies on credit, meaning it will pay later. Which accounts are debited and credited, and why?
Show answer
Debit Supplies 800, because an asset increases. Credit Accounts Payable 800, because a liability increases. Debits and credits both total 800.
Exercise
A customer pays 500 cash for services already billed and recorded. Which accounts change, and how?
Show answer
Debit Cash 500, because an asset increases. Credit Accounts Receivable 500, because another asset decreases. Total assets are unchanged, and debits equal credits at 500.