schemas.transaction_schemas¶
src.schemas.transaction_schemas
¶
Transaction request and response schemas.
Pydantic schemas for transaction API endpoints. Includes: - Request schemas (client → API) - Response schemas (API → client) - DTO-to-schema conversion methods
Reference
- docs/architecture/api-design-patterns.md
Classes¶
TransactionResponse
¶
Bases: BaseModel
Single transaction response.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
UUID
|
Transaction unique identifier. |
account_id |
UUID
|
Account FK. |
provider_transaction_id |
str
|
Provider's unique ID. |
transaction_type |
str
|
Type (e.g., "trade", "transfer"). |
subtype |
str
|
Subtype (e.g., "buy", "deposit"). |
status |
str
|
Status (e.g., "settled", "pending"). |
amount_value |
Decimal
|
Transaction amount. |
amount_currency |
str
|
Amount currency code. |
description |
str
|
Human-readable description. |
asset_type |
str | None
|
Asset type or None. |
symbol |
str | None
|
Security ticker or None. |
security_name |
str | None
|
Full security name or None. |
quantity |
Decimal | None
|
Share/unit quantity or None. |
unit_price_amount |
Decimal | None
|
Price per share/unit or None. |
unit_price_currency |
str | None
|
Unit price currency or None. |
commission_amount |
Decimal | None
|
Trading commission or None. |
commission_currency |
str | None
|
Commission currency or None. |
transaction_date |
date
|
Date transaction occurred. |
settlement_date |
date | None
|
Date settled or None. |
is_trade |
bool
|
Whether transaction is a trade. |
is_transfer |
bool
|
Whether transaction is a transfer. |
is_income |
bool
|
Whether transaction is income. |
is_fee |
bool
|
Whether transaction is a fee. |
is_debit |
bool
|
Whether debits account. |
is_credit |
bool
|
Whether credits account. |
is_settled |
bool
|
Whether settled. |
created_at |
datetime
|
First sync timestamp. |
updated_at |
datetime
|
Last sync timestamp. |
Source code in src/schemas/transaction_schemas.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
Functions¶
from_dto
classmethod
¶
Convert application DTO to response schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
TransactionResult
|
TransactionResult from handler. |
required |
Returns:
| Type | Description |
|---|---|
TransactionResponse
|
TransactionResponse for API response. |
Source code in src/schemas/transaction_schemas.py
TransactionListResponse
¶
Bases: BaseModel
Transaction list response with pagination.
Attributes:
| Name | Type | Description |
|---|---|---|
transactions |
list[TransactionResponse]
|
List of transactions. |
total_count |
int
|
Total count of transactions. |
has_more |
bool
|
Whether more results are available. |
Source code in src/schemas/transaction_schemas.py
Functions¶
from_dto
classmethod
¶
Convert application DTO to response schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
TransactionListResult
|
TransactionListResult from handler. |
required |
Returns:
| Type | Description |
|---|---|
TransactionListResponse
|
TransactionListResponse for API response. |
Source code in src/schemas/transaction_schemas.py
SyncTransactionsResponse
¶
Bases: SyncResponse
Response for transaction sync operation.
Extends SyncResponse with transaction-specific fields.
Attributes:
| Name | Type | Description |
|---|---|---|
transactions_created |
int
|
Number of new transactions created. |
transactions_updated |
int
|
Number of existing transactions updated. |
Source code in src/schemas/transaction_schemas.py
SyncTransactionsRequest
¶
Bases: BaseModel
Request to sync transactions from provider.
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection to sync from. |
account_id |
UUID | None
|
Optional specific account to sync (all if None). |
start_date |
date | None
|
Optional start date for sync range. |
end_date |
date | None
|
Optional end date for sync range. |
force |
bool
|
Force sync even if recently synced. |