b4w dummy data

This commit is contained in:
2026-09-12 14:40:55 +02:00
parent a0a4d6e8d9
commit cc7ba35c4d
4 changed files with 102 additions and 14 deletions
+20 -14
View File
@@ -39,22 +39,28 @@ class B4wExport(ExportBaseModel):
)
notes: str = Field(alias="Notes")
def parameters_to_dict(self) -> dict[str, str]:
return {
"Id1": f"{self.id}",
"OwnrAcctIBAN": f"{self.account_iban!s}",
"OwnrAcctCcy": f"{self.account_currency!s}",
"ValDt": date2str(self.date_valid),
"BookgDt": date2str(self.date_book),
"Amt": f"{self.amount!s}",
"AmtCcy": f"{self.amount_currency!s}",
"CdtDbtInd": f"{self.sign!s}",
"RmtInf": f"{self.reference}",
"RmtdNm": f"{self.other_name}",
"RmtdAcctIBAN": f"{self.other_iban}",
"Category": f"{self.category.to_str() if self.category else ''}",
"Notes": f"{self.notes}",
}
def parameters_to_str(self):
return (
f"Id1='{self.id}', "
f"OwnrAcctIBAN='{self.account_iban!s}', "
f"AmtCcy='{self.amount_currency!s}', "
f"ValDt='{date2str(self.date_valid)}', "
f"BookgDt='{date2str( self.date_book )}', "
f"Amt='{self.amount!s}', "
f"OwnrAcctCcy='{self.account_currency!s}', "
f"CdtDbtInd='{self.sign!s}', "
f"RmtInf='{self.reference}', "
f"RmtdNm='{self.other_name}', "
f"RmtdAcctIBAN='{self.other_iban}', "
f"Category='{self.category.to_str() if self.category else ''}', "
f"Notes='{self.notes}'"
parameters = ", ".join(
f"{key}='{value}'" for key, value in self.parameters_to_dict().items()
)
return parameters
def __repr__(self):
return f"B4wExport({self.parameters_to_str()})"
@@ -0,0 +1,22 @@
import csv
from pathlib import Path
from tests.factories import B4wExportFactory
NUMBER_OF_ROWS = 50
PATH_DEFAULT = Path("tests/test_data/b4w_export_dummy_01.csv")
def save_csv(path: Path = PATH_DEFAULT):
data = B4wExportFactory.batch(NUMBER_OF_ROWS)
row_fields = list(data[0].parameters_to_dict())
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", newline="") as fid:
writer = csv.DictWriter(fid, fieldnames=row_fields)
writer.writeheader()
for export in data:
writer.writerow(export.parameters_to_dict())
if __name__ == "__main__":
save_csv()