Skip to content

application.dtos.sync_dtos

src.application.dtos.sync_dtos

Data Sync DTOs (Data Transfer Objects).

Response/result dataclasses for sync command handlers. These carry sync operation results from handlers back to the presentation layer.

DTOs
  • SyncAccountsResult: Result from SyncAccounts command
  • SyncTransactionsResult: Result from SyncTransactions command
  • SyncHoldingsResult: Result from SyncHoldings command
  • BalanceChange: Tracks balance changes for portfolio events
Reference
  • docs/architecture/cqrs.md (DTOs section)

Classes

BalanceChange dataclass

Tracks balance change for a single account during sync.

Used to emit AccountBalanceUpdated events after sync completes.

Attributes:

Name Type Description
account_id UUID

Account whose balance changed.

previous Decimal

Balance before sync.

current Decimal

Balance after sync.

currency str

Currency code.

Source code in src/application/dtos/sync_dtos.py
@dataclass
class BalanceChange:
    """Tracks balance change for a single account during sync.

    Used to emit AccountBalanceUpdated events after sync completes.

    Attributes:
        account_id: Account whose balance changed.
        previous: Balance before sync.
        current: Balance after sync.
        currency: Currency code.
    """

    account_id: UUID
    previous: Decimal
    current: Decimal
    currency: str

SyncAccountsResult dataclass

Result of account sync operation.

Attributes:

Name Type Description
created int

Number of new accounts created.

updated int

Number of existing accounts updated.

unchanged int

Number of accounts unchanged.

errors int

Number of accounts that failed to sync.

message str

Human-readable summary.

balance_changes list[BalanceChange]

List of balance changes for portfolio events.

Source code in src/application/dtos/sync_dtos.py
@dataclass
class SyncAccountsResult:
    """Result of account sync operation.

    Attributes:
        created: Number of new accounts created.
        updated: Number of existing accounts updated.
        unchanged: Number of accounts unchanged.
        errors: Number of accounts that failed to sync.
        message: Human-readable summary.
        balance_changes: List of balance changes for portfolio events.
    """

    created: int
    updated: int
    unchanged: int
    errors: int
    message: str
    balance_changes: list[BalanceChange] = field(default_factory=list)

SyncTransactionsResult dataclass

Result of transaction sync operation.

Attributes:

Name Type Description
created int

Number of new transactions created.

updated int

Number of existing transactions updated.

unchanged int

Number of transactions unchanged.

errors int

Number of transactions that failed to sync.

accounts_synced int

Number of accounts processed.

message str

Human-readable summary.

Source code in src/application/dtos/sync_dtos.py
@dataclass
class SyncTransactionsResult:
    """Result of transaction sync operation.

    Attributes:
        created: Number of new transactions created.
        updated: Number of existing transactions updated.
        unchanged: Number of transactions unchanged.
        errors: Number of transactions that failed to sync.
        accounts_synced: Number of accounts processed.
        message: Human-readable summary.
    """

    created: int
    updated: int
    unchanged: int
    errors: int
    accounts_synced: int
    message: str

SyncHoldingsResult dataclass

Result of holdings sync operation.

Attributes:

Name Type Description
created int

Number of new holdings created.

updated int

Number of existing holdings updated.

unchanged int

Number of holdings unchanged.

deactivated int

Number of holdings deactivated (no longer in provider).

errors int

Number of holdings that failed to sync.

message str

Human-readable summary.

Source code in src/application/dtos/sync_dtos.py
@dataclass
class SyncHoldingsResult:
    """Result of holdings sync operation.

    Attributes:
        created: Number of new holdings created.
        updated: Number of existing holdings updated.
        unchanged: Number of holdings unchanged.
        deactivated: Number of holdings deactivated (no longer in provider).
        errors: Number of holdings that failed to sync.
        message: Human-readable summary.
    """

    created: int
    updated: int
    unchanged: int
    deactivated: int
    errors: int
    message: str