Ingest comdirect #5
+2
-2
@@ -27,8 +27,8 @@ def main():
|
|||||||
assert isinstance(giro_account, Account)
|
assert isinstance(giro_account, Account)
|
||||||
ingest_comdirect(
|
ingest_comdirect(
|
||||||
Path(args.input_comdirect),
|
Path(args.input_comdirect),
|
||||||
account_iban=giro_account.iban,
|
account_iban=giro_account.iban or "",
|
||||||
account_currency=giro_account.currency,
|
account_currency=giro_account.currency or "",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -27,7 +27,7 @@ class B4wExport(ExportBaseModel):
|
|||||||
sign: Sign = Field(alias="CdtDbtInd")
|
sign: Sign = Field(alias="CdtDbtInd")
|
||||||
reference: str = Field(alias="RmtInf")
|
reference: str = Field(alias="RmtInf")
|
||||||
other_name: str = Field(alias="RmtdNm")
|
other_name: str = Field(alias="RmtdNm")
|
||||||
other_iban: str = Field(alias="RmtdAcctIBAN", pattern=IBAN_PATTERN)
|
other_iban: str | None = Field(alias="RmtdAcctIBAN", pattern=IBAN_PATTERN)
|
||||||
category: Category | None = Field(
|
category: Category | None = Field(
|
||||||
alias="Category",
|
alias="Category",
|
||||||
examples=[
|
examples=[
|
||||||
@@ -51,7 +51,7 @@ class B4wExport(ExportBaseModel):
|
|||||||
"CdtDbtInd": f"{self.sign!s}",
|
"CdtDbtInd": f"{self.sign!s}",
|
||||||
"RmtInf": f"{self.reference}",
|
"RmtInf": f"{self.reference}",
|
||||||
"RmtdNm": f"{self.other_name}",
|
"RmtdNm": f"{self.other_name}",
|
||||||
"RmtdAcctIBAN": f"{self.other_iban}",
|
"RmtdAcctIBAN": f"{self.other_iban or ''}",
|
||||||
"Category": f"{self.category.to_str() if self.category else ''}",
|
"Category": f"{self.category.to_str() if self.category else ''}",
|
||||||
"Notes": f"{self.notes}",
|
"Notes": f"{self.notes}",
|
||||||
}
|
}
|
||||||
@@ -77,6 +77,13 @@ class B4wExport(ExportBaseModel):
|
|||||||
def amount_signed(self) -> Decimal:
|
def amount_signed(self) -> Decimal:
|
||||||
return self.amount * self.sign.to_sign()
|
return self.amount * self.sign.to_sign()
|
||||||
|
|
||||||
|
@field_validator("other_iban", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def other_iban_blank_is_none(cls, iban_in: str | None) -> str | None:
|
||||||
|
if iban_in is None or (isinstance(iban_in, str) and not iban_in.strip()):
|
||||||
|
return None
|
||||||
|
return iban_in
|
||||||
|
|
||||||
@field_validator("category", mode="before")
|
@field_validator("category", mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def category_str_is_parsable(
|
def category_str_is_parsable(
|
||||||
|
|||||||
+8
-2
@@ -34,6 +34,13 @@ def _iban() -> str:
|
|||||||
return B4wExportFactory.__faker__.iban()
|
return B4wExportFactory.__faker__.iban()
|
||||||
|
|
||||||
|
|
||||||
|
def _other_iban() -> str:
|
||||||
|
faker = B4wExportFactory.__faker__
|
||||||
|
if faker.pyint(min_value=0, max_value=100) < 50:
|
||||||
|
return ""
|
||||||
|
return faker.iban()
|
||||||
|
|
||||||
|
|
||||||
class B4wExportFactory(ModelFactory[B4wExport]):
|
class B4wExportFactory(ModelFactory[B4wExport]):
|
||||||
__faker__ = Faker("de_DE")
|
__faker__ = Faker("de_DE")
|
||||||
__use_examples__ = True
|
__use_examples__ = True
|
||||||
@@ -43,7 +50,7 @@ class B4wExportFactory(ModelFactory[B4wExport]):
|
|||||||
Notes = Use(_sentence)
|
Notes = Use(_sentence)
|
||||||
RmtdNm = Use(_names)
|
RmtdNm = Use(_names)
|
||||||
OwnrAcctIBAN = Use(_iban)
|
OwnrAcctIBAN = Use(_iban)
|
||||||
RmtdAcctIBAN = Use(_iban)
|
RmtdAcctIBAN = Use(_other_iban)
|
||||||
|
|
||||||
|
|
||||||
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
||||||
@@ -61,4 +68,3 @@ class ComdirectCreditCardFactory(ModelFactory[ComdirectCreditCard]):
|
|||||||
class ComdirectDepotFactory(ModelFactory[ComdirectDepot]):
|
class ComdirectDepotFactory(ModelFactory[ComdirectDepot]):
|
||||||
__faker__ = Faker("de_DE")
|
__faker__ = Faker("de_DE")
|
||||||
__use_example__ = True
|
__use_example__ = True
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,27 @@ def test_b4w_export_account_iban_to_short():
|
|||||||
_ = B4wExportFactory.build(OwnrAcctIBAN="DE123")
|
_ = B4wExportFactory.build(OwnrAcctIBAN="DE123")
|
||||||
|
|
||||||
|
|
||||||
|
def test_b4w_export_other_iban_empty_is_none():
|
||||||
|
data = B4wExportFactory.build(RmtdAcctIBAN="")
|
||||||
|
assert data.other_iban is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_b4w_export_other_iban_blank_is_none():
|
||||||
|
data = B4wExportFactory.build(RmtdAcctIBAN=" ")
|
||||||
|
assert data.other_iban is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_b4w_export_other_iban_invalid():
|
||||||
|
with pytest.raises(ValidationError):
|
||||||
|
_ = B4wExportFactory.build(RmtdAcctIBAN="not an IBAN")
|
||||||
|
|
||||||
|
|
||||||
|
def test_b4w_export_other_iban_repr_round_trip_empty():
|
||||||
|
data = B4wExportFactory.build(RmtdAcctIBAN="")
|
||||||
|
data2 = eval(str(data))
|
||||||
|
assert data == data2
|
||||||
|
|
||||||
|
|
||||||
def test_b4w_export_parameters_to_dict():
|
def test_b4w_export_parameters_to_dict():
|
||||||
data = B4wExportFactory.build()
|
data = B4wExportFactory.build()
|
||||||
params = data.parameters_to_dict()
|
params = data.parameters_to_dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user