domain.errors.transaction_error¶
src.domain.errors.transaction_error
¶
Transaction domain errors.
Defines error constants for transaction validation and business logic failures.
Architecture
- Domain layer errors (no infrastructure dependencies)
- Used in Result types (railway-oriented programming)
- Never raised as exceptions (return Failure(error) instead)
Usage
from src.domain.errors import TransactionError from src.core.result import Failure
if amount <= 0: return Failure(TransactionError.INVALID_AMOUNT)
Reference
- docs/architecture/transaction-domain-model.md
Classes¶
TransactionError
¶
Transaction error constants.
Used in Result types for transaction operation failures. These are NOT exceptions - they are error value constants used in railway-oriented programming pattern.
Error Categories
- Validation errors: INVALID_AMOUNT, INVALID_PROVIDER_TRANSACTION_ID, INVALID_TRANSACTION_DATE
- Security errors: MISSING_SECURITY_SYMBOL, MISSING_QUANTITY, INVALID_QUANTITY, MISSING_UNIT_PRICE, MISSING_ASSET_TYPE
- Status errors: TRANSACTION_NOT_FOUND, TRANSACTION_ALREADY_SETTLED, DUPLICATE_PROVIDER_TRANSACTION
Source code in src/domain/errors/transaction_error.py
22 23 24 25 26 27 28 29 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 | |
Attributes¶
INVALID_AMOUNT
class-attribute
instance-attribute
¶
Transaction amount is invalid.
Used when: - Amount is zero or negative (except for specific transaction types) - Amount currency doesn't match account currency - Amount precision exceeds acceptable limits
INVALID_PROVIDER_TRANSACTION_ID
class-attribute
instance-attribute
¶
Provider transaction ID is invalid or missing.
Used when: - provider_transaction_id is empty - provider_transaction_id format is invalid for provider - Duplicate provider_transaction_id for same account
INVALID_TRANSACTION_DATE
class-attribute
instance-attribute
¶
Transaction date is invalid.
Used when: - transaction_date is in the future - transaction_date is before account creation - settlement_date is before transaction_date
MISSING_SECURITY_SYMBOL
class-attribute
instance-attribute
¶
Security symbol is missing for trade transaction.
Used when: - TransactionType is TRADE and subtype requires symbol (BUY, SELL, etc.) - symbol field is None or empty
MISSING_QUANTITY
class-attribute
instance-attribute
¶
Quantity is missing for trade transaction.
Used when: - TransactionType is TRADE and subtype requires quantity - quantity field is None
INVALID_QUANTITY
class-attribute
instance-attribute
¶
Quantity value is invalid.
Used when: - quantity is zero or negative - quantity precision exceeds acceptable limits (typically 8 decimals)
MISSING_UNIT_PRICE
class-attribute
instance-attribute
¶
Unit price is missing for trade transaction.
Used when: - TransactionType is TRADE and subtype requires unit_price - unit_price field is None
MISSING_ASSET_TYPE
class-attribute
instance-attribute
¶
Asset type is missing for trade transaction.
Used when: - TransactionType is TRADE - asset_type field is None
TRANSACTION_NOT_FOUND
class-attribute
instance-attribute
¶
Transaction does not exist.
Used when: - Transaction ID not found in repository - Provider transaction ID not found for account
TRANSACTION_ALREADY_SETTLED
class-attribute
instance-attribute
¶
Transaction is already settled and cannot be modified.
Used when: - Attempting to update a transaction with status SETTLED - Attempting to cancel a settled transaction (use reversal instead)
DUPLICATE_PROVIDER_TRANSACTION
class-attribute
instance-attribute
¶
Provider transaction already exists for this account.
Used when: - Attempting to save transaction with duplicate provider_transaction_id - Same provider_transaction_id already exists for the account
This prevents duplicate transaction imports during sync operations.