Skip to content

AMI-9: Add a category to expenses - #5

Merged
aminbaa merged 1 commit into
factory_pre_mergefrom
factory/AMI-9
Nov 28, 2026
Merged

aminbaa merged 1 commit into
factory_pre_mergefrom
factory/AMI-9

Conversation

@aminbaa

@aminbaa aminbaa commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Linear: https://linear.app/aminbaa/issue/AMI-9/add-a-category-to-expenses

Factory decision: build

Add an optional category field (travel, meals, software, office, other; default other) to expenses, set on create, returned everywhere, with existing rows backfilled to other.

Plan: Add category: Literal[...] = "other" to ExpenseIn and include it in the INSERT in app/expenses.py.
In app/db.py, add the column to SCHEMA with NOT NULL DEFAULT 'other' and a CHECK constraint. Add an idempotent ALTER TABLE in init_db for existing databases, and add categories to the seed data if wanted.
Add tests in tests/test_expenses.py: default is other, a valid category is accepted, an invalid one gives 422, and category appears in the get and list responses.

Why:

  • The acceptance criteria are concrete: a category enum (travel, meals, software, office, other), optional on create with default other, returned wherever expenses are returned, and existing rows backfilled to other. That is specific enough to implement without clarification.
  • Category is not personal data. personal_phone and work_phone are not involved, so the data rules in docs/data.md do not require escalation.
  • The change does not touch money handling. Amounts stay as integer cents, and no currency conversion is added.
  • The change is expected to fall under the default CODEOWNERS owner (@sagard-example/expenses). It needs review from @sagard-example/platform only if the implementation touches app/auth.py or .github/, which this ticket does not require. If that changes, escalate that part.
  • Repository rules still apply: work on a branch, open a PR, pass CI, and add tests for the new behaviour, including the default on create, the backfill of existing rows, and rejection of values outside the enum.
  • The spec is unambiguous: the allowed values, the default and the backfill value are all given.
  • The change stays in app/expenses.py and app/db.py, owned by the default expenses team. It doesn't touch app/auth.py or .github/.
  • Expenses are returned via SELECT * and dict(row), so a new column appears in every response without extra work.
  • No personal data or money rules are involved. docs/data.md covers amounts and phone numbers only, and this field changes neither.
  • The only wrinkle is that the schema uses CREATE TABLE IF NOT EXISTS, so existing databases need an ALTER TABLE ADD COLUMN ... DEFAULT 'other' migration. That is straightforward.

Opened by ticket-factory. CI and review run on this PR; the factory lands it into factory_pre_merge when they pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@aminbaa
aminbaa merged commit bb8c092 into factory_pre_merge Nov 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant