from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Any, Mapping


@dataclass(frozen=True)
class SourceRequest:
    source: str
    source_account_key: str
    service_source_id: int | None
    credential_id: int | None
    account_label: str | None
    credentials: Mapping[str, Any]
    provider_options: Mapping[str, Any]


@dataclass(frozen=True)
class ExtractionContext:
    job_id: str
    audit_run_id: str | None
    period_from: datetime
    period_to: datetime
    source: SourceRequest
    source_directory: Path
    checkpoint_path: Path


@dataclass(frozen=True)
class ProviderRecord:
    provider_record_key: str
    occurred_at: datetime
    record_type: str
    provider_status: str
    provider_transaction_id: str | None = None
    provider_reference: str | None = None
    subscriber_identifier: str | None = None
    amount: Any = None
    cost_amount: Any = None
    commission_amount: Any = None
    currency: str | None = None
    balance_before: Any = None
    balance_after: Any = None
    description: str | None = None
    raw_payload: Mapping[str, Any] = field(default_factory=dict)
