fix b4w real-world import

This commit is contained in:
2026-09-12 21:00:26 +02:00
parent e9dcb88da5
commit 500b76b8a8
4 changed files with 40 additions and 6 deletions
+9 -2
View File
@@ -27,7 +27,7 @@ class B4wExport(ExportBaseModel):
sign: Sign = Field(alias="CdtDbtInd")
reference: str = Field(alias="RmtInf")
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(
alias="Category",
examples=[
@@ -51,7 +51,7 @@ class B4wExport(ExportBaseModel):
"CdtDbtInd": f"{self.sign!s}",
"RmtInf": f"{self.reference}",
"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 ''}",
"Notes": f"{self.notes}",
}
@@ -77,6 +77,13 @@ class B4wExport(ExportBaseModel):
def amount_signed(self) -> Decimal:
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")
@classmethod
def category_str_is_parsable(