[
{"name": "three journals: a sale, a receipt and an expense", "args": [[{"account": "1200", "debit": {"minor": 12000, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 10000, "currency": "GBP"}}, {"account": "2200", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 2000, "currency": "GBP"}}, {"account": "0100", "debit": {"minor": 5000, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "1200", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 5000, "currency": "GBP"}}, {"account": "5000", "debit": {"minor": 3000, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "0100", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 3000, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "0100", "debits": {"minor": 5000, "currency": "GBP"}, "credits": {"minor": 3000, "currency": "GBP"}, "debitBalance": {"minor": 2000, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "1200", "debits": {"minor": 12000, "currency": "GBP"}, "credits": {"minor": 5000, "currency": "GBP"}, "debitBalance": {"minor": 7000, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "2200", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 2000, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 2000, "currency": "GBP"}}, {"account": "4000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 10000, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 10000, "currency": "GBP"}}, {"account": "5000", "debits": {"minor": 3000, "currency": "GBP"}, "credits": {"minor": 0, "currency": "GBP"}, "debitBalance": {"minor": 3000, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}], "totalDebit": {"minor": 12000, "currency": "GBP"}, "totalCredit": {"minor": 12000, "currency": "GBP"}, "balanced": true}},
{"name": "accounts sort as text, so 1000 comes before 900", "args": [[{"account": "900", "debit": {"minor": 100, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "1000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 100, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "1000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 100, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 100, "currency": "GBP"}}, {"account": "900", "debits": {"minor": 100, "currency": "GBP"}, "credits": {"minor": 0, "currency": "GBP"}, "debitBalance": {"minor": 100, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}], "totalDebit": {"minor": 100, "currency": "GBP"}, "totalCredit": {"minor": 100, "currency": "GBP"}, "balanced": true}},
{"name": "an account that nets to zero keeps its row", "args": [[{"account": "1200", "debit": {"minor": 500, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 500, "currency": "GBP"}}, {"account": "0100", "debit": {"minor": 500, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "1200", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 500, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "0100", "debits": {"minor": 500, "currency": "GBP"}, "credits": {"minor": 0, "currency": "GBP"}, "debitBalance": {"minor": 500, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "1200", "debits": {"minor": 500, "currency": "GBP"}, "credits": {"minor": 500, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 500, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 500, "currency": "GBP"}}], "totalDebit": {"minor": 500, "currency": "GBP"}, "totalCredit": {"minor": 500, "currency": "GBP"}, "balanced": true}},
{"name": "an unbalanced ledger is an answer, not an error", "args": [[{"account": "1200", "debit": {"minor": 10000, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 9999, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "1200", "debits": {"minor": 10000, "currency": "GBP"}, "credits": {"minor": 0, "currency": "GBP"}, "debitBalance": {"minor": 10000, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 9999, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 9999, "currency": "GBP"}}], "totalDebit": {"minor": 10000, "currency": "GBP"}, "totalCredit": {"minor": 9999, "currency": "GBP"}, "balanced": false}},
{"name": "no lines: an empty trial balance that balances", "args": [[], "GBP"], "expect": {"rows": [], "totalDebit": {"minor": 0, "currency": "GBP"}, "totalCredit": {"minor": 0, "currency": "GBP"}, "balanced": true}},
{"name": "zero lines are skipped and make no row", "args": [[{"account": "1200", "debit": {"minor": 100, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 100, "currency": "GBP"}}, {"account": "9999", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "1200", "debits": {"minor": 100, "currency": "GBP"}, "credits": {"minor": 0, "currency": "GBP"}, "debitBalance": {"minor": 100, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 100, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 100, "currency": "GBP"}}], "totalDebit": {"minor": 100, "currency": "GBP"}, "totalCredit": {"minor": 100, "currency": "GBP"}, "balanced": true}},
{"name": "a line with both sides is totalled on both", "args": [[{"account": "1200", "debit": {"minor": 500, "currency": "GBP"}, "credit": {"minor": 200, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 300, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "1200", "debits": {"minor": 500, "currency": "GBP"}, "credits": {"minor": 200, "currency": "GBP"}, "debitBalance": {"minor": 300, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 300, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 300, "currency": "GBP"}}], "totalDebit": {"minor": 300, "currency": "GBP"}, "totalCredit": {"minor": 300, "currency": "GBP"}, "balanced": true}},
{"name": "many postings to one account", "args": [[{"account": "1200", "debit": {"minor": 1, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "1200", "debit": {"minor": 2, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "1200", "debit": {"minor": 3, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 6, "currency": "GBP"}}], "GBP"], "expect": {"rows": [{"account": "1200", "debits": {"minor": 6, "currency": "GBP"}, "credits": {"minor": 0, "currency": "GBP"}, "debitBalance": {"minor": 6, "currency": "GBP"}, "creditBalance": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debits": {"minor": 0, "currency": "GBP"}, "credits": {"minor": 6, "currency": "GBP"}, "debitBalance": {"minor": 0, "currency": "GBP"}, "creditBalance": {"minor": 6, "currency": "GBP"}}], "totalDebit": {"minor": 6, "currency": "GBP"}, "totalCredit": {"minor": 6, "currency": "GBP"}, "balanced": true}},
{"name": "a euro ledger", "args": [[{"account": "1200", "debit": {"minor": 100, "currency": "EUR"}, "credit": {"minor": 0, "currency": "EUR"}}, {"account": "4000", "debit": {"minor": 0, "currency": "EUR"}, "credit": {"minor": 100, "currency": "EUR"}}], "EUR"], "expect": {"rows": [{"account": "1200", "debits": {"minor": 100, "currency": "EUR"}, "credits": {"minor": 0, "currency": "EUR"}, "debitBalance": {"minor": 100, "currency": "EUR"}, "creditBalance": {"minor": 0, "currency": "EUR"}}, {"account": "4000", "debits": {"minor": 0, "currency": "EUR"}, "credits": {"minor": 100, "currency": "EUR"}, "debitBalance": {"minor": 0, "currency": "EUR"}, "creditBalance": {"minor": 100, "currency": "EUR"}}], "totalDebit": {"minor": 100, "currency": "EUR"}, "totalCredit": {"minor": 100, "currency": "EUR"}, "balanced": true}},
{"name": "a line in another currency is refused", "args": [[{"account": "1200", "debit": {"minor": 100, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "EUR"}, "credit": {"minor": 100, "currency": "EUR"}}], "GBP"], "expectError": "line 2: amount is in EUR, not the journal currency GBP"},
{"name": "a negative amount is refused", "args": [[{"account": "1200", "debit": {"minor": -100, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 100, "currency": "GBP"}}], "GBP"], "expectError": "line 1: debit and credit must not be negative"},
{"name": "a malformed account code is refused", "args": [[{"account": "12 00", "debit": {"minor": 100, "currency": "GBP"}, "credit": {"minor": 0, "currency": "GBP"}}, {"account": "4000", "debit": {"minor": 0, "currency": "GBP"}, "credit": {"minor": 100, "currency": "GBP"}}], "GBP"], "expectError": "line 1: account \"12 00\" is not a valid account code"},
{"name": "the ledger currency must be an ISO code", "args": [[], "pounds"], "expectError": "ISO 4217"}
]