black
This commit is contained in:
+7
-2
@@ -95,12 +95,15 @@ def _parse_date_german(date_str: str) -> date | None:
|
||||
day, month, year = list(map(int, date_str.split(".")))
|
||||
return date(day=day, month=month, year=year)
|
||||
|
||||
|
||||
def _parse_decimal_german(decimal_str: str) -> Decimal:
|
||||
return Decimal(decimal_str.replace(".", "").replace(",", "."))
|
||||
|
||||
|
||||
class ComdirectBase(BaseModel):
|
||||
date_val: date | None = Field(alias="Wertstellung (Valuta)", examples=["07.09.2026"])
|
||||
date_val: date | None = Field(
|
||||
alias="Wertstellung (Valuta)", examples=["07.09.2026"]
|
||||
)
|
||||
amount_eur: Decimal = Field(alias="Umsatz in EUR", examples=["32,43"])
|
||||
|
||||
@field_validator("date_val", mode="before")
|
||||
@@ -138,7 +141,9 @@ class ComdirectCreditCard(ComdirectGiro):
|
||||
)
|
||||
reference: str = Field(alias="Referenz", default="")
|
||||
text: str = Field(alias="Buchungstext", default="")
|
||||
amount_eur: Decimal | None = Field(alias="Umsatz in EUR", examples=["32,43"], default=None)
|
||||
amount_eur: Decimal | None = Field(
|
||||
alias="Umsatz in EUR", examples=["32,43"], default=None
|
||||
)
|
||||
|
||||
|
||||
class ComdirectDepot(ComdirectBase):
|
||||
|
||||
+3
-1
@@ -18,11 +18,11 @@ def reader_b4w(path: Path):
|
||||
return list(map(B4wExport.model_validate, raw))
|
||||
|
||||
|
||||
|
||||
PATTERN_ACCOUNT_NAME = r'^"Umsätze ([^"]+)";"Zeitraum: .*$'
|
||||
PATTERN_HEADER = r'"([^"]+)"'
|
||||
PATTERN_DATA = r'"([^"]+)"'
|
||||
|
||||
|
||||
class EXPECT_LINE(Enum):
|
||||
ACCOUNT_NAME = auto()
|
||||
BLANK = auto()
|
||||
@@ -33,6 +33,7 @@ class EXPECT_LINE(Enum):
|
||||
COMDIRECT_ACCOUNTS = BANK_ACCOUNTS.get("comdirect", {})
|
||||
assert isinstance(COMDIRECT_ACCOUNTS, dict)
|
||||
|
||||
|
||||
def reader_comdirect(path: Path):
|
||||
result = {}
|
||||
raw = _reader_raw_comdirect(path)
|
||||
@@ -42,6 +43,7 @@ def reader_comdirect(path: Path):
|
||||
result[account_name] = list(map(account.ingestion_function, account_data))
|
||||
return result
|
||||
|
||||
|
||||
def _reader_raw_comdirect(path: Path):
|
||||
|
||||
with path.open(encoding="latin1") as fid:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
from enum import Enum
|
||||
|
||||
IBAN_PATTERN = r"^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$"
|
||||
|
||||
|
||||
class Currency(str, Enum):
|
||||
EUR = "EUR"
|
||||
USD = "USD"
|
||||
@@ -14,5 +14,3 @@ class Currency(str, Enum):
|
||||
|
||||
def __repr__(self):
|
||||
return f"Currency.{self.name}"
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,3 @@ class AccountInfo(BaseModel):
|
||||
iban: str = Field(pattern=IBAN_PATTERN)
|
||||
ingestion_function: Callable
|
||||
currency: Currency
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user