71 lines
1.6 KiB
Python
71 lines
1.6 KiB
Python
from decimal import Decimal
|
|
|
|
from faker import Faker
|
|
from polyfactory.factories.pydantic_factory import ModelFactory
|
|
from polyfactory.fields import Use
|
|
|
|
from src.models.b4w import B4wExport
|
|
from src.models.comdirect import ComdirectCreditCard, ComdirectDepot, ComdirectGiro
|
|
|
|
DEFAULT_CATEGORY = "root_category:parent_category:leaf_category"
|
|
|
|
|
|
def _amount() -> Decimal:
|
|
return B4wExportFactory.__faker__.pydecimal(
|
|
left_digits=6,
|
|
right_digits=2,
|
|
positive=True,
|
|
min_value=Decimal("0.01"),
|
|
)
|
|
|
|
|
|
def _sentence() -> str:
|
|
return B4wExportFactory.__faker__.sentence(
|
|
nb_words=8,
|
|
variable_nb_words=False,
|
|
)
|
|
|
|
|
|
def _names() -> str:
|
|
return B4wExportFactory.__faker__.company()
|
|
|
|
|
|
def _iban() -> str:
|
|
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]):
|
|
__faker__ = Faker("de_DE")
|
|
__use_examples__ = True
|
|
|
|
Amt = Use(_amount)
|
|
RmtInf = Use(_sentence)
|
|
Notes = Use(_sentence)
|
|
RmtdNm = Use(_names)
|
|
OwnrAcctIBAN = Use(_iban)
|
|
RmtdAcctIBAN = Use(_other_iban)
|
|
|
|
|
|
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
|
__faker__ = Faker("de_DE")
|
|
__use_example__ = True
|
|
|
|
Buchungstext = Use(_sentence)
|
|
|
|
|
|
class ComdirectCreditCardFactory(ModelFactory[ComdirectCreditCard]):
|
|
__faker__ = Faker("de_DE")
|
|
__use_example__ = True
|
|
|
|
|
|
class ComdirectDepotFactory(ModelFactory[ComdirectDepot]):
|
|
__faker__ = Faker("de_DE")
|
|
__use_example__ = True
|