<requirement name="ledger-executable"> The product is an executable named `ledger` at the application root. </requirement> <requirement name="relational-persistence"> It stores everything in a relational database through the shipped persistence library, and every command either completes in full or changes nothing. </requirement> <requirement name="database-configuration" stories="database-configuration"> `DATABASE_URL` names the database. A value beginning `postgres://` or `postgresql://` is a PostgreSQL DSN. Any other value is a SQLite file path, optionally prefixed `sqlite://`. When `DATABASE_URL` is unset, `DATABASE_PATH` is used, then `data/app.db`. </requirement> <requirement name="ledger-schema" stories="database-schema"> Three tables. Amounts are stored as integer cents and never as floating point. </requirement> <requirement name="command-dispatch-and-output" stories="cli-dispatch"> Every successful command except `init` writes CSV to standard output: one header row, then data rows, comma-separated, no quoting, no trailing spaces, `\n` line endings. `init` writes nothing. A failing command writes nothing to standard output and one diagnostic line to standard error. </requirement> <requirement name="validate-command-usage" stories="cli-validation"> | `2` | Usage error: unknown command, unknown table or report, wrong argument count. | </requirement> <requirement name="atomic-rejected-commands" stories="account-loading,transaction-loading,balance-invariant,transfers"> 1. **A rejected command changes nothing.** A command checks every input and rule before its first write. A load that rejects row 11 stores none of rows 1 to 10. A transfer stores both of its rows or neither. </requirement> <requirement name="load-accounts-and-categories" stories="account-loading"> | `ledger load <table> <csv>` | Loads `accounts`, `categories`, or `transactions` from a file whose header matches the table's columns in the order above. Writes `table,loaded` and `<table>,<rows>`. | </requirement> <requirement name="load-transactions" stories="transaction-loading"> A loaded transaction keeps the `txn_id` from its file. </requirement> <requirement name="account-management" stories="account-management"> | `ledger account add <code> <name>` | The new account row. | | `ledger account get <code>` | The account row. | | `ledger account rename <code> <name>` | The updated account row. | | `ledger account delete <code>` | `deleted` and the code. Refused while the account has transactions. | </requirement> <requirement name="transaction-management" stories="transaction-management"> | `ledger txn post <account> <category> <amount> <date> [<memo>]` | The new transaction row. | | `ledger txn get <id>` | The transaction row. | | `ledger txn amend <id> <amount>` | The updated transaction row. Only the amount changes. | | `ledger txn delete <id>` | `deleted` and the id. | </requirement> <requirement name="non-negative-balances" stories="balance-invariant"> 2. **No command leaves an account balance below zero.** An account's balance is the sum of its transaction amounts. Posting, amending, deleting, transferring, and loading are all subject to this rule, checked before the command writes anything. </requirement> <requirement name="transfers" stories="transfers"> | `ledger transfer <from> <to> <amount> <date>` | Two transaction rows in category `TRANSFER`: `-amount` on `<from>` with memo `transfer to <to>`, then `+amount` on `<to>` with memo `transfer from <from>`. The amount is positive and the accounts differ. | </requirement> <requirement name="balance-report" stories="balance-report"> | `ledger report balances` | `account,name,transactions,balance` per account ordered by code, then `TOTAL,,<count>,<sum>`. | </requirement> <requirement name="category-report" stories="category-report"> | `ledger report categories` | `category,description,transactions,inflow,outflow,net` per category ordered by code, including categories with no transactions, then `TOTAL,,<count>,<inflow>,<outflow>,<net>`. | </requirement> <requirement name="monthly-report" stories="monthly-report"> | `ledger report monthly` | `month,transactions,inflow,outflow,net` per `YYYY-MM` that has transactions, ascending, then `TOTAL,<count>,<inflow>,<outflow>,<net>`. | </requirement> <requirement name="automated-project-tests" stories="project-tests"> The completed application provides a POSIX-compatible `bin/test.sh` that runs its own automated test suite from the application root and exits zero only when every test passes. The suite covers each command, each exit code, and each rule above against a real temporary database. </requirement> <requirement name="conformance-harness" stories="conformance"> `sources/run.sh` is the scoring entry point. It is supplied, not authored, and is staged verbatim into the application root with the seed files. `drydock uat` runs `sh sources/run.sh` from the completed application root and takes its exit code and output as the score. </requirement> <unattached story="architecture"/>
Run artifact