Money in your database
Money looks like just another number until a cent goes missing. This series starts with how to store an amount, builds a ledger on top of it, and ends with checking that ledger against what the bank says.
Read in order
Part 1
How to Store Money in a Database Without Losing Cents
Most advice stops at 'use integer cents'. That breaks on yen, dinars, wei and a bill split three ways.
Part 2
Double-Entry Ledger in Postgres: Enforce the Rules in the Database
A balance column tells you where you ended up. A ledger tells you how you got there, and the database can check the sums.
Part 3
Payment Reconciliation in SQL: Match Your Ledger to the Bank
Your ledger says one thing and the bank says another. Find out which lines differ, and why.