"""Factories for organization app.""" import factory from apps.organization.models import IndustryCluster, Organization, OrganizationType from faker import Faker fake = Faker("ru_RU") class OrganizationFactory(factory.django.DjangoModelFactory): """Factory for Organization model.""" class Meta: model = Organization name = factory.LazyAttribute(lambda _: fake.company()) short_name = factory.LazyAttribute(lambda _: f"АО «{fake.company()}»") organization_type = factory.LazyAttribute( lambda _: fake.random_element( [OrganizationType.AO, OrganizationType.PAO, OrganizationType.FGUP] ) ) cluster = factory.LazyAttribute( lambda _: fake.random_element( [ IndustryCluster.RADIOELECTRONICS, IndustryCluster.NUCLEAR, IndustryCluster.SPACE, ] ) ) inn = factory.LazyAttribute(lambda _: fake.numerify("##########")) ogrn = factory.LazyAttribute(lambda _: fake.numerify("#############")) kpp = factory.LazyAttribute(lambda _: fake.numerify("#########")) okpo = factory.LazyAttribute(lambda _: fake.numerify("########")) registration_date = factory.LazyAttribute(lambda _: fake.date_this_century()) legal_address = factory.LazyAttribute(lambda _: fake.address().replace("\n", ", ")) activity_type = factory.LazyAttribute(lambda _: fake.job()) founder_name = factory.LazyAttribute(lambda _: fake.company()) ownership_type = "Собственность государственных корпораций" legal_form = "Акционерное общество" charter_capital_amount = factory.LazyAttribute( lambda _: fake.pydecimal(left_digits=9, right_digits=2, positive=True) ) general_director_name = factory.LazyAttribute(lambda _: fake.name()) general_director_inn = factory.LazyAttribute( lambda _: fake.numerify("############") ) general_director_appointment_date = factory.LazyAttribute( lambda _: fake.date_this_decade() ) executors_count = factory.LazyAttribute(lambda _: fake.random_int(min=20, max=500)) financial_reports_available = True tax_reports_available = True in_defense_unreliable_suppliers_registry = False in_275_fz_registry = False bankruptcy_messages_found = False @classmethod def create_organization(cls, **kwargs): """Create organization with defaults.""" return cls.create(**kwargs)