money-tracker 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. money_tracker-0.3.0/PKG-INFO +373 -0
  2. money_tracker-0.3.0/README.md +354 -0
  3. money_tracker-0.3.0/pyproject.toml +44 -0
  4. money_tracker-0.3.0/pyproject.toml.orig +42 -0
  5. money_tracker-0.3.0/src/money_tracker/__init__.py +3 -0
  6. money_tracker-0.3.0/src/money_tracker/cli.py +60 -0
  7. money_tracker-0.3.0/src/money_tracker/commands/__init__.py +62 -0
  8. money_tracker-0.3.0/src/money_tracker/commands/accounts.py +217 -0
  9. money_tracker-0.3.0/src/money_tracker/commands/budgets.py +272 -0
  10. money_tracker-0.3.0/src/money_tracker/commands/categories.py +222 -0
  11. money_tracker-0.3.0/src/money_tracker/commands/context.py +231 -0
  12. money_tracker-0.3.0/src/money_tracker/commands/db.py +93 -0
  13. money_tracker-0.3.0/src/money_tracker/commands/doctor.py +40 -0
  14. money_tracker-0.3.0/src/money_tracker/commands/payees.py +134 -0
  15. money_tracker-0.3.0/src/money_tracker/commands/reference.py +7 -0
  16. money_tracker-0.3.0/src/money_tracker/commands/reports.py +114 -0
  17. money_tracker-0.3.0/src/money_tracker/commands/transactions.py +420 -0
  18. money_tracker-0.3.0/src/money_tracker/commands/users.py +192 -0
  19. money_tracker-0.3.0/src/money_tracker/config.py +59 -0
  20. money_tracker-0.3.0/src/money_tracker/constants.py +20 -0
  21. money_tracker-0.3.0/src/money_tracker/db.py +110 -0
  22. money_tracker-0.3.0/src/money_tracker/errors.py +21 -0
  23. money_tracker-0.3.0/src/money_tracker/migrations/__init__.py +1 -0
  24. money_tracker-0.3.0/src/money_tracker/migrations/env.py +39 -0
  25. money_tracker-0.3.0/src/money_tracker/migrations/versions/0001_initial_schema.py +165 -0
  26. money_tracker-0.3.0/src/money_tracker/migrations/versions/__init__.py +1 -0
  27. money_tracker-0.3.0/src/money_tracker/models.py +222 -0
  28. money_tracker-0.3.0/src/money_tracker/money.py +57 -0
  29. money_tracker-0.3.0/src/money_tracker/output.py +59 -0
  30. money_tracker-0.3.0/src/money_tracker/presentation.py +199 -0
  31. money_tracker-0.3.0/src/money_tracker/services/__init__.py +1 -0
  32. money_tracker-0.3.0/src/money_tracker/services/accounts.py +108 -0
  33. money_tracker-0.3.0/src/money_tracker/services/budgets.py +175 -0
  34. money_tracker-0.3.0/src/money_tracker/services/categories.py +143 -0
  35. money_tracker-0.3.0/src/money_tracker/services/doctor.py +410 -0
  36. money_tracker-0.3.0/src/money_tracker/services/payees.py +67 -0
  37. money_tracker-0.3.0/src/money_tracker/services/reports.py +734 -0
  38. money_tracker-0.3.0/src/money_tracker/services/resolution.py +42 -0
  39. money_tracker-0.3.0/src/money_tracker/services/transactions.py +337 -0
  40. money_tracker-0.3.0/src/money_tracker/services/users.py +123 -0
  41. money_tracker-0.3.0/src/money_tracker/static/css/app.css +1 -0
  42. money_tracker-0.3.0/src/money_tracker/static/css/input.css +16 -0
  43. money_tracker-0.3.0/src/money_tracker/static/js/cashflow.js +232 -0
  44. money_tracker-0.3.0/src/money_tracker/static/js/filters.js +83 -0
  45. money_tracker-0.3.0/src/money_tracker/static/vendor/echarts.LICENSE +222 -0
  46. money_tracker-0.3.0/src/money_tracker/static/vendor/echarts.min.js +45 -0
  47. money_tracker-0.3.0/src/money_tracker/templates/web/auth/login.html +30 -0
  48. money_tracker-0.3.0/src/money_tracker/templates/web/base.html +75 -0
  49. money_tracker-0.3.0/src/money_tracker/templates/web/components/account_rows.html +62 -0
  50. money_tracker-0.3.0/src/money_tracker/templates/web/components/cashflow_graph.html +18 -0
  51. money_tracker-0.3.0/src/money_tracker/templates/web/components/category_rows.html +24 -0
  52. money_tracker-0.3.0/src/money_tracker/templates/web/dashboard.html +196 -0
  53. money_tracker-0.3.0/src/money_tracker/templates/web/references/form.html +82 -0
  54. money_tracker-0.3.0/src/money_tracker/templates/web/references/list.html +81 -0
  55. money_tracker-0.3.0/src/money_tracker/templates/web/transactions/detail.html +42 -0
  56. money_tracker-0.3.0/src/money_tracker/templates/web/transactions/form.html +139 -0
  57. money_tracker-0.3.0/src/money_tracker/templates/web/transactions/list.html +165 -0
  58. money_tracker-0.3.0/src/money_tracker/templates/web/transactions/reverse.html +38 -0
  59. money_tracker-0.3.0/src/money_tracker/web/__init__.py +68 -0
  60. money_tracker-0.3.0/src/money_tracker/web/auth.py +33 -0
  61. money_tracker-0.3.0/src/money_tracker/web/dashboard.py +302 -0
  62. money_tracker-0.3.0/src/money_tracker/web/database.py +19 -0
  63. money_tracker-0.3.0/src/money_tracker/web/periods.py +172 -0
  64. money_tracker-0.3.0/src/money_tracker/web/references.py +362 -0
  65. money_tracker-0.3.0/src/money_tracker/web/transactions.py +608 -0
@@ -0,0 +1,373 @@
1
+ Metadata-Version: 2.3
2
+ Name: money-tracker
3
+ Version: 0.3.0
4
+ Summary: A reliable command-line money tracker
5
+ Author: robeth
6
+ Author-email: robeth <robethrahmatullah@gmail.comm>
7
+ Requires-Dist: alembic>=1.13,<2
8
+ Requires-Dist: click>=8.1,<9
9
+ Requires-Dist: flask>=3.1,<4
10
+ Requires-Dist: flask-wtf>=1.2,<2
11
+ Requires-Dist: gunicorn>=23,<24
12
+ Requires-Dist: platformdirs>=4,<5
13
+ Requires-Dist: rich>=13,<14
14
+ Requires-Dist: sqlalchemy>=2.0,<3
15
+ Requires-Dist: tomli-w>=1,<2
16
+ Requires-Dist: tomli>=2,<3 ; python_full_version < '3.11'
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+
20
+ deferred to Phase 2.
21
+ # Money Tracker
22
+
23
+ Money Tracker is a Python application for tracking household accounts,
24
+ payees, transactions, category budgets, and reports in SQLite. It provides
25
+ both a command-line interface and a password-protected, server-rendered web
26
+ interface for household use.
27
+
28
+ ## Quick start
29
+
30
+ Run the published executable without a global installation:
31
+
32
+ ```bash
33
+ uvx money-tracker db init --user Alice --currency USD
34
+ uvx money-tracker account add --name Wallet --type cash
35
+ uvx money-tracker payee add --name Market --kind merchant
36
+ uvx money-tracker tx expense \
37
+ --account Wallet --amount 24.95 \
38
+ --payee Market --category Groceries --date 2026-09-20
39
+ uvx money-tracker tx list --json
40
+ ```
41
+
42
+ Use `--json` when another program or an AI agent will parse the result.
43
+ Names are case-insensitive and unique within a database, so names are usually
44
+ easier than numeric IDs. Run `context --json` before a complex command to see
45
+ available users, accounts, balances, and categories. Context does not list
46
+ payees; use `payee list` or `payee show` when a payee reference is needed.
47
+
48
+ `db init` seeds these categories:
49
+
50
+ - `Income` (`income`)
51
+ - `Car` (`expense`) with `Fuel`, `Maintenance`, and `Upgrade` children
52
+ - `Groceries`, `Shopping`, and `Dining` (`expense`)
53
+
54
+ ## Common usage
55
+
56
+ ### Inspect the tracker
57
+
58
+ ```bash
59
+ uvx money-tracker context --json
60
+ uvx money-tracker doctor --json
61
+ uvx money-tracker user list
62
+ uvx money-tracker account list
63
+ uvx money-tracker payee list
64
+ uvx money-tracker category list
65
+ ```
66
+
67
+ `context` is the compact helicopter view for reference discovery. Human
68
+ output has separate Users, Accounts, and Categories sections; JSON has
69
+ `users`, `accounts`, and `categories` members. Use `--tree` to render
70
+ categories hierarchically, including nested `children` arrays in JSON.
71
+
72
+ Reference lists show active records by default. Use `--all` to include
73
+ archived/inactive records; human output then adds an `Active` column. JSON
74
+ always includes `is_active`. Audit fields (`created_at`, `created_by`,
75
+ `updated_at`, and `updated_by`) are hidden by default and can be requested
76
+ with `--include-audit`.
77
+
78
+ `doctor` is read-only and reports the selected database path, path source,
79
+ resolved path, parent directory, configuration path, permissions, SQLite
80
+ health, schema tables, Alembic revision, current executor, and package/runtime
81
+ checks. Use it first when a command appears to use the wrong database.
82
+
83
+ ### Users and current executor
84
+
85
+ ```bash
86
+ uvx money-tracker user add --name Bob --email bob@example.com
87
+ uvx money-tracker user edit Bob --email new@example.com
88
+ uvx money-tracker user use Bob
89
+ uvx money-tracker user current
90
+ uvx money-tracker user archive Bob
91
+ ```
92
+
93
+ The current executor is stored in the local configuration file. Transaction
94
+ ownership is inferred from the account owner; transaction commands do not
95
+ take a separate user argument.
96
+
97
+ ### Accounts, payees, and categories
98
+
99
+ ```bash
100
+ uvx money-tracker account add \
101
+ --name Checking --type checking --opening-balance 1000.00
102
+ uvx money-tracker account edit Checking \
103
+ --type savings --owner Bob --opening-balance 1250.00
104
+ uvx money-tracker account archive Checking
105
+
106
+ uvx money-tracker payee add --name Acme --kind utility
107
+ uvx money-tracker payee edit Acme --kind merchant
108
+
109
+ uvx money-tracker category add \
110
+ --name Fuel --type expense --parent Car
111
+ uvx money-tracker category edit Fuel --name Petrol
112
+ uvx money-tracker category archive Petrol
113
+ uvx money-tracker category list --tree
114
+ ```
115
+
116
+ Valid account types are `cash`, `checking`, `savings`, `credit_card`,
117
+ `investment`, `loan`, and `other`. Valid category types are `income` and
118
+ `expense`. Invalid enum values are rejected with the valid values in the
119
+ error message.
120
+
121
+ ### Transactions
122
+
123
+ Income, expense, transfer, account, budget, and report amounts use decimal
124
+ major units at the CLI boundary. For example, `123` is stored as `12300`
125
+ minor units. Human output and JSON use a two-decimal string plus an exact
126
+ minor-unit field:
127
+
128
+ ```json
129
+ {"amount": "123.00", "amount_minor": 12300}
130
+ ```
131
+
132
+ ```bash
133
+ uvx money-tracker tx income \
134
+ --account Checking --amount 2500.00 --date 2026-09-30 \
135
+ --payee Employer --category Income
136
+ uvx money-tracker tx expense \
137
+ --account Wallet --amount 42.50 --date 2026-09-20 \
138
+ --payee Market --category Groceries --note "Weekly shopping"
139
+ uvx money-tracker tx transfer \
140
+ --from Checking --to Wallet --amount 100.00 --date 2026-09-20
141
+ ```
142
+
143
+ Transfers are stored as two legs sharing one event ID. Financial identity
144
+ (type, amount, and account legs) is not editable. Edit metadata when needed:
145
+
146
+ ```bash
147
+ uvx money-tracker tx edit EVENT_ID \
148
+ --date 2026-09-21 --category Dining --note "Corrected note"
149
+ uvx money-tracker tx reverse EVENT_ID \
150
+ --date 2026-09-22 --note "Posted in error"
151
+ ```
152
+
153
+ Transaction listing is paginated by default to keep agent output bounded.
154
+ Pagination counts logical events, not individual transfer legs:
155
+
156
+ ```bash
157
+ uvx money-tracker tx list --json
158
+ uvx money-tracker tx list \
159
+ --page 2 --page-size 25 --sort created_asc \
160
+ --account Wallet --type expense --json
161
+ ```
162
+
163
+ The JSON result has only `items` and `metadata` at the top level:
164
+
165
+ ```json
166
+ {
167
+ "items": [],
168
+ "metadata": {
169
+ "pagination": {
170
+ "page": 2,
171
+ "page_size": 25,
172
+ "offset": 25,
173
+ "total": 123,
174
+ "shown": 25,
175
+ "pages": 5,
176
+ "has_previous": true,
177
+ "has_next": true
178
+ },
179
+ "sort": {"field": "created", "direction": "asc"},
180
+ "filter": {"account": "Wallet", "type": "expense"}
181
+ }
182
+ }
183
+ ```
184
+
185
+ Unset filters are omitted. Read `metadata.pagination` before requesting
186
+ another page. Human output prints the same page, offset, shown/total, sort,
187
+ and active-filter context above the table.
188
+
189
+ Valid transaction types are `income`, `expense`, and `transfer`.
190
+
191
+ ### Budgets and reports
192
+
193
+ ```bash
194
+ uvx money-tracker budget add \
195
+ --name "Grocery budget" --category Groceries --amount 500.00 \
196
+ --period monthly --start 2026-09-01 --recurring
197
+ uvx money-tracker budget edit "Grocery budget" \
198
+ --category Dining --period yearly --start 2026-01-01
199
+ uvx money-tracker budget status "Grocery budget" \
200
+ --from 2026-09-01 --to 2026-10-01 --json
201
+ ```
202
+
203
+ Valid budget periods are `monthly` and `yearly`. Budgets must use an
204
+ `expense` category. Recurring budgets generate periods through the requested
205
+ report range.
206
+
207
+ ```bash
208
+ uvx money-tracker report summary \
209
+ --from 2026-01-01 --to 2027-01-01 \
210
+ --granularity month --breakdown user \
211
+ --breakdown account --breakdown category --json
212
+ ```
213
+
214
+ Report ranges use the half-open interval `[from, to)`. Supported
215
+ granularities are `month`, `quarter`, and `year`; supported breakdowns are
216
+ `user`, `account`, and `category`.
217
+
218
+ ## Command reference
219
+
220
+ | Command | Purpose |
221
+ | --- | --- |
222
+ | `db init` | Create the SQLite database, run Alembic migrations, create the first user, and seed categories |
223
+ | `doctor` | Read-only database, migration, runtime, and package diagnostics |
224
+ | `context` | Show users, accounts, balances, and categories for reference discovery |
225
+ | `user` | Add, list, show, edit, archive, select, and inspect the current executor |
226
+ | `account` | Add, list, show, edit, and archive accounts |
227
+ | `payee` | Add, list, show, edit, and archive payees/merchants |
228
+ | `category` | Add, list, show, edit, and archive categories |
229
+ | `tx` | Record income, expenses, transfers; list/show/edit/reverse events |
230
+ | `budget` | Add, list, show, edit, archive, and evaluate category budgets |
231
+ | `report summary` | Aggregate transactions over dynamic date ranges |
232
+
233
+ Every list/show/edit command accepts `--json` either after the command or as a
234
+ root option. References can be numeric IDs or unique names.
235
+
236
+ ## Database and application configuration
237
+
238
+ Database selection precedence is:
239
+
240
+ 1. `--db PATH`
241
+ 2. `MONEY_TRACKER_DB`
242
+ 3. `~/.money-tracker/data.db`
243
+
244
+ Normal workflows can omit all three. Use an explicit path when operating on
245
+ multiple independent household/tenant databases:
246
+
247
+ ```bash
248
+ uvx money-tracker --db ./travel.db context --json
249
+ MONEY_TRACKER_DB=./home.db uvx money-tracker context --json
250
+ ```
251
+
252
+ Each SQLite file is an independent configuration. Separate files provide
253
+ Phase 1 tenant isolation; this is not an organization, authentication, or
254
+ authorization system. `doctor --json` exposes the selected path, source
255
+ (`flag`, `environment`, or `default`), resolved path, and relevant parent
256
+ directory details to troubleshoot selection.
257
+
258
+ The current executor is stored in:
259
+
260
+ ```text
261
+ ~/.money-tracker/config.toml
262
+ ```
263
+
264
+ The file contains only the selected user name. Use `user use NAME` to update
265
+ it. `MONEY_TRACKER_DB` selects a database file and does not select or
266
+ authenticate a user.
267
+
268
+ ## Development
269
+
270
+ Install dependencies and run tests from the checkout:
271
+
272
+ ```bash
273
+ uv sync --dev
274
+ uv run pytest -q
275
+ uv run money-tracker --help
276
+ ```
277
+
278
+ `uv run` executes the local project in editable mode, so normal Python source
279
+ changes do not require recompilation. `uvx money-tracker` resolves the
280
+ published package and is best for package-install smoke tests.
281
+
282
+ Alembic migrations are used from day one. Database commands apply migrations
283
+ before opening an application session; do not edit the schema manually.
284
+
285
+ ## Releasing
286
+
287
+ GitHub Actions runs the quality gates (`pytest`, chart tests, generated-CSS
288
+ freshness, package build smoke) on every pull request and push to `master`.
289
+ Publishing happens only for version tags:
290
+
291
+ ```bash
292
+ # 1. set the new version in pyproject.toml and commit it to master
293
+ # 2. tag that commit and push the tag
294
+ git tag v0.2.0
295
+ git push origin v0.2.0
296
+ ```
297
+
298
+ The tag must match `pyproject.toml`'s `version` or the publish workflow stops
299
+ before uploading anything. A matching tag publishes the `money-tracker`
300
+ package to PyPI and pushes the `robeth/money-tracker` image to Docker Hub
301
+ (tags `X.Y.Z`, `X.Y`, and `latest`).
302
+
303
+ One-time repository setup (documented in
304
+ `docs/superpowers/specs/2026-10-11-ci-cd-design.md`):
305
+
306
+ - PyPI and TestPyPI Trusted Publishers for `robeth/money-tracker` pointing at
307
+ `publish.yml` / `publish-testpypi.yml` with the `pypi` / `testpypi`
308
+ GitHub Environments (OIDC — no API tokens).
309
+ - Repository secrets `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN`.
310
+ - Manual dry runs go to TestPyPI via the "Publish to TestPyPI" workflow.
311
+
312
+ ## Local Web Demo
313
+
314
+ Install the development environment, then start the loopback-only web demo:
315
+
316
+ ```bash
317
+ uv sync --dev
318
+ ./scripts/run_local_web_demo.sh
319
+ ```
320
+
321
+ Open `http://127.0.0.1:18765` and sign in with `money-tracker-local-test`.
322
+ After sign-in, choose `Calendar month` and `March 2026` in the dashboard
323
+ period controls to see sample activity. The ignored `.local/` directory holds
324
+ `web-demo.db` and its selected-user config. The database uses the deterministic
325
+ Q1 2026 household scenario from `tests/test_household_scenario.py`: three
326
+ users, five accounts, budgets, and 300 income, expense, and transfer events.
327
+ Its dates are fixed to January through March 2026.
328
+
329
+ The launcher binds only to `127.0.0.1`. Its fixed password and secret key are
330
+ for local testing only; do not expose this server to your network or the
331
+ internet. Stop it with `Ctrl+C`.
332
+
333
+ To reset all demo transactions and references, stop the server and remove
334
+ `.local/web-demo.db`, then run the launcher again. Existing demo databases are
335
+ migrated but never reseeded or overwritten automatically.
336
+
337
+ ## Home-Network Web Interface
338
+
339
+ The web interface is intended for a trusted home network. Its sample Compose
340
+ configuration publishes the service on all host interfaces so a phone on the
341
+ same Wi-Fi can connect. The example uses plain HTTP and is not safe for public
342
+ internet exposure; remote access needs TLS and an explicit access-control
343
+ design.
344
+
345
+ Copy the environment template and replace both placeholders with unique,
346
+ strong values before starting the service:
347
+
348
+ ```bash
349
+ cp .env.example .env
350
+ ```
351
+
352
+ Initialize the persistent database and its first user explicitly. Replace
353
+ `NAME` and `USD` with the household's executor name and base currency:
354
+
355
+ ```bash
356
+ docker compose -f compose.example.yaml run --rm web money-tracker db init --user NAME --currency USD
357
+ docker compose -f compose.example.yaml up -d
358
+ ```
359
+
360
+ Schema upgrades are also explicit:
361
+
362
+ ```bash
363
+ docker compose -f compose.example.yaml run --rm web money-tracker db upgrade
364
+ ```
365
+
366
+ Open `http://<computer-lan-address>:8000` from a device on the same trusted
367
+ Wi-Fi. Find the computer's LAN address in its network settings or with the
368
+ operating system's IP address command. The dashboard and all data routes
369
+ require the configured web password. The database and current-user
370
+ configuration persist in the named `money_tracker_data` volume.
371
+
372
+ To bind to a particular host interface or port, set `MONEY_TRACKER_HOST` or
373
+ `MONEY_TRACKER_PORT` in `.env`. Keep `.env` private; it is excluded from git.