"""Schemata für einmalige Buchungen.""" from datetime import date, datetime from pydantic import Field from app.models.enums import EntryKind from app.schemas.common import ApiModel, InputModel, Money, PositiveMoney from app.schemas.merchant import MerchantOut class TransactionCreate(InputModel): kind: EntryKind title: str = Field(min_length=1, max_length=160, examples=["Wocheneinkauf"]) merchant_id: int | None = None category_id: int account_id: int amount: PositiveMoney = Field(description="Immer positiv – die Richtung steckt in `kind`.") booking_date: date note: str | None = None tags: list[str] = Field(default_factory=list) class TransactionUpdate(InputModel): kind: EntryKind | None = None title: str | None = Field(default=None, min_length=1, max_length=160) merchant_id: int | None = None category_id: int | None = None account_id: int | None = None amount: PositiveMoney | None = None booking_date: date | None = None note: str | None = None tags: list[str] | None = None class TransactionOut(ApiModel): id: int kind: EntryKind title: str merchant_id: int | None category_id: int account_id: int amount: Money booking_date: date note: str | None tags: list[str] created_at: datetime merchant: MerchantOut | None = None