Skip to content

[Model] Create Pydantic model for normalized transaction schema #95

@williaby

Description

@williaby

Summary

Create a strongly typed TransactionModel using Pydantic to validate and standardize normalized transaction records after ETL processing. This model will serve as the single source of truth for downstream logic, including validation, serialization, and optional export.


Design Requirements

  • Field validation: Ensure type enforcement and domain-level constraints (e.g. non-negative amounts, ISO8601 timestamps).
  • Field coverage:
    • date: datetime.date or ISO 8601 string
    • amount: Decimal
    • vendor: str
    • category: str
    • subcategory: Optional[str]
    • account_name: str
    • account_id: UUID | str
    • person_tag: Optional[str]
    • budget_category: Optional[str]
    • comment: Optional[str]

Implementation Tasks

  • Define model in ledgerbase/models/transaction.py
  • Add unit tests for boundary and format validation
  • Integrate into the ETL process post-normalization
  • Document model fields and validation logic

Acceptance Criteria

  • The model validates all normalized transaction records against the schema
  • Invalid fields raise detailed Pydantic ValidationError exceptions
  • Model is unit tested for correct parsing, coercion, and failure cases
  • Field types align with pyproject.toml-defined linters and type checkers

Dependencies


Milestone

Milestone: v0.3.0 – ETL Enhancements and Data Integrity

This model is foundational for enforcing transaction schema consistency as the system scales to multi-institution support and category tagging logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions