feat: financial data integrity & reconciliation (#96)#481
Closed
sinatragianpaolo-oc wants to merge 2 commits intorohitdash08:mainfrom
Closed
feat: financial data integrity & reconciliation (#96)#481sinatragianpaolo-oc wants to merge 2 commits intorohitdash08:mainfrom
sinatragianpaolo-oc wants to merge 2 commits intorohitdash08:mainfrom
Conversation
added 2 commits
March 17, 2026 02:59
…ohitdash08#96) 8 integrity checks: - balance mismatch (monthly net flow < 0) - orphaned expenses (missing category_id) - orphaned recurring expenses (missing category_id) - future-dated expenses (spent_at > today) - duplicate expenses (same day/amount/type) - negative amounts - stale active recurring (end_date passed) - bills missing reminders (due within 7 days) Endpoints: GET /integrity/check?months=3 — full report, all check arrays GET /integrity/check/summary — overall_status + per-check counts only All checks are read-only. Graceful degradation: duplicate check uses array_agg (PostgreSQL-only); falls back silently on SQLite.
Unit tests: empty DB → ok, balance mismatch, orphaned expense, future-dated, negative amount, stale recurring, bill missing reminder, user isolation. HTTP tests: auth, structure, clean user → ok, months param/validation, future expense via HTTP, balance via HTTP. Summary endpoint: auth, keys, no detail arrays.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements financial data integrity & reconciliation to fix #96.
Detects missing or inconsistent financial records across 8 check categories. All checks are read-only — nothing is mutated.
Endpoints
GET /integrity/check?months=3— full report with all detail arraysGET /integrity/check/summary— lightweight status + per-check counts (for dashboard badges)Both JWT-protected.
Checks performed
balance_mismatchesorphaned_expensesorphaned_recurringfuture_dated_expensesspent_at> today (likely data entry error)duplicate_expensesnegative_amountsamount <= 0stale_recurringend_datebills_missing_remindersoverall_status:"ok"/"warnings"/"errors"Example response
{ "overall_status": "warnings", "total_issues": 3, "balance_mismatches": [{"month": "2026-02", "income": 1000, "expenses": 2500, "net_flow": -1500}], "future_dated_expenses": [{"expense_id": 42, "days_ahead": 5}], "bills_missing_reminders": [{"bill_name": "Rent", "days_until_due": 2}], ... }Files
app/services/integrity.py— 8 check functions +run_integrity_check(uid, months)app/routes/integrity.py— Flask blueprintapp/routes/__init__.py— blueprint registrationtests/test_integrity.py— 35 tests (service unit + HTTP integration)/claim #96
Closes #96