from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

T = TypeVar("T", bound="TransactionSummary")


@_attrs_define
class TransactionSummary:
    """
    Attributes:
        deposits (float | Unset):
        withdrawals (float | Unset):
        income (float | Unset):
        fees (float | Unset):
        transfers (float | Unset):
        purchases (float | Unset):
        sales (float | Unset):
        reinvestments (float | Unset):
        other (float | Unset):
        accrued (float | Unset):
        gain_loss (float | Unset):
        rollovers (float | Unset):
        forfeiture (float | Unset):
        loan_payments (float | Unset):
        new_loans (float | Unset):
        loan_interest (float | Unset):
    """

    deposits: float | Unset = UNSET
    withdrawals: float | Unset = UNSET
    income: float | Unset = UNSET
    fees: float | Unset = UNSET
    transfers: float | Unset = UNSET
    purchases: float | Unset = UNSET
    sales: float | Unset = UNSET
    reinvestments: float | Unset = UNSET
    other: float | Unset = UNSET
    accrued: float | Unset = UNSET
    gain_loss: float | Unset = UNSET
    rollovers: float | Unset = UNSET
    forfeiture: float | Unset = UNSET
    loan_payments: float | Unset = UNSET
    new_loans: float | Unset = UNSET
    loan_interest: float | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        deposits = self.deposits

        withdrawals = self.withdrawals

        income = self.income

        fees = self.fees

        transfers = self.transfers

        purchases = self.purchases

        sales = self.sales

        reinvestments = self.reinvestments

        other = self.other

        accrued = self.accrued

        gain_loss = self.gain_loss

        rollovers = self.rollovers

        forfeiture = self.forfeiture

        loan_payments = self.loan_payments

        new_loans = self.new_loans

        loan_interest = self.loan_interest

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if deposits is not UNSET:
            field_dict["deposits"] = deposits
        if withdrawals is not UNSET:
            field_dict["withdrawals"] = withdrawals
        if income is not UNSET:
            field_dict["income"] = income
        if fees is not UNSET:
            field_dict["fees"] = fees
        if transfers is not UNSET:
            field_dict["transfers"] = transfers
        if purchases is not UNSET:
            field_dict["purchases"] = purchases
        if sales is not UNSET:
            field_dict["sales"] = sales
        if reinvestments is not UNSET:
            field_dict["reinvestments"] = reinvestments
        if other is not UNSET:
            field_dict["other"] = other
        if accrued is not UNSET:
            field_dict["accrued"] = accrued
        if gain_loss is not UNSET:
            field_dict["gain_loss"] = gain_loss
        if rollovers is not UNSET:
            field_dict["rollovers"] = rollovers
        if forfeiture is not UNSET:
            field_dict["forfeiture"] = forfeiture
        if loan_payments is not UNSET:
            field_dict["loanPayments"] = loan_payments
        if new_loans is not UNSET:
            field_dict["newLoans"] = new_loans
        if loan_interest is not UNSET:
            field_dict["loanInterest"] = loan_interest

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        deposits = d.pop("deposits", UNSET)

        withdrawals = d.pop("withdrawals", UNSET)

        income = d.pop("income", UNSET)

        fees = d.pop("fees", UNSET)

        transfers = d.pop("transfers", UNSET)

        purchases = d.pop("purchases", UNSET)

        sales = d.pop("sales", UNSET)

        reinvestments = d.pop("reinvestments", UNSET)

        other = d.pop("other", UNSET)

        accrued = d.pop("accrued", UNSET)

        gain_loss = d.pop("gain_loss", UNSET)

        rollovers = d.pop("rollovers", UNSET)

        forfeiture = d.pop("forfeiture", UNSET)

        loan_payments = d.pop("loanPayments", UNSET)

        new_loans = d.pop("newLoans", UNSET)

        loan_interest = d.pop("loanInterest", UNSET)

        transaction_summary = cls(
            deposits=deposits,
            withdrawals=withdrawals,
            income=income,
            fees=fees,
            transfers=transfers,
            purchases=purchases,
            sales=sales,
            reinvestments=reinvestments,
            other=other,
            accrued=accrued,
            gain_loss=gain_loss,
            rollovers=rollovers,
            forfeiture=forfeiture,
            loan_payments=loan_payments,
            new_loans=new_loans,
            loan_interest=loan_interest,
        )

        transaction_summary.additional_properties = d
        return transaction_summary

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
