"""Factories for testing models.""" import datetime import factory from abacus_common_logic.test_utils.factories import ( BaseModelFactory, BaseModelFactoryWithTimestamps, ) from abacus_account.constants import constants from abacus_account.models.account import Account from abacus_account.models.account_contract_vat_detail import AccountContractVatDetail from abacus_account.models.account_payee import AccountPayee from abacus_account.models.account_payee_history import AccountPayeeHistory from abacus_account.models.account_payment_term import AccountPaymentTerm from abacus_account.models.account_payment_term_template import ( AccountPaymentTermTemplate, ) from abacus_account.models.account_tax_info import AccountTaxInfo from abacus_account.models.account_tax_info_history import AccountTaxInfoHistory from abacus_account.models.payment_entity_payoneer_program import ( PaymentEntityPayoneerProgram, ) from abacus_account.models.payment_hold import PaymentHold from abacus_account.models.payment_hold_history import PaymentHoldHistory from abacus_account.models.reference_agreement_type import ReferenceAgreementType from abacus_account.models.reference_payoneer_program import ReferencePayoneerProgram from abacus_contract.models.reference_payment_type import ReferencePaymentType class AccountFactory(BaseModelFactoryWithTimestamps): """Factory to create account models for testing.""" class Meta: """Meta definition for the factory.""" model = Account account_name = factory.Sequence(lambda n: f'Account {n + 1}') account_id = factory.Sequence(lambda n: n + 1) created_by = 'sax_ingestion' class AccountContractVatDetailFactory(BaseModelFactoryWithTimestamps): """Factory to create AccountContractVatDetail models for testing.""" class Meta: """Meta definition for the factory.""" model = AccountContractVatDetail account_contract_vat_detail_id = factory.Sequence(lambda n: n + 1) contract_id = factory.Sequence(lambda n: n + 1) account_id = factory.Sequence(lambda n: n + 1) company_code = factory.Sequence(lambda n: f'Company code {n + 1}') vat_country = factory.Sequence(lambda n: f'Country {n + 1}') created_by = 'sax_ingestion' class ReferencePayoneerProgramFactory(BaseModelFactory): """Factory to create reference_payoneer_program models for testing.""" class Meta: """Meta definition for the factory.""" model = ReferencePayoneerProgram payoneer_program_id = factory.Sequence(lambda n: n + 1) payoneer_program_name = 'AWAL Core UK - GBP' funding_currency = 'GBP' reference_payment_type_id = 7 class AccountPayeeFactory(BaseModelFactoryWithTimestamps): """Factory to create account_payee models for testing.""" class Meta: """Meta definition for the factory.""" model = AccountPayee account = factory.SubFactory(AccountFactory) account_payee_id = factory.Sequence(lambda n: n + 1) payoneer_payee_id = 100 payoneer_payee_name = 'Payoneer Payee' payoneer_iframe_url = 'payoneer.com/fake_iframe_url' payoneer_iframe_url_date = datetime.date(2022, 2, 1) payoneer_session_id = 'B99' reference_payoneer_program = factory.SubFactory(ReferencePayoneerProgramFactory) sap_vendor_id = 111 reference_payment_type_id = 7 last_modified = datetime.date(2022, 2, 28) class AccountPayeeHistoryFactory(BaseModelFactoryWithTimestamps): """Factory to create account_payee_history records for testing.""" class Meta: """Meta definition for the factory.""" model = AccountPayeeHistory account_payee_history_id = factory.Sequence(lambda n: n + 1) account = factory.SubFactory(AccountFactory) account_payee_id = 1 payoneer_payee_id = 100 payoneer_payee_name = 'Payoneer Payee' payoneer_iframe_url = 'payoneer.com/fake_iframe_url' payoneer_iframe_url_date = datetime.date(2022, 2, 1) payoneer_session_id = 'B99' created_at = '2022-01-27' last_modified = '2022-01-28' class AccountTaxInfoFactory(BaseModelFactoryWithTimestamps): """Factory to create account_tax_info models for testing.""" class Meta: """Meta definition for the factory.""" model = AccountTaxInfo account_tax_info_id = factory.Sequence(lambda n: n + 1) account = factory.SubFactory(AccountFactory) country_of_tax_residence = 'USA' is_sba_signed = False is_vat_exempt = True is_tax_treaty_claimed = False is_wht_applicable = True certificate_of_residence_expiration_date = None class AccountTaxInfoHistoryFactory(BaseModelFactoryWithTimestamps): """Factory to create account_tax_info_history records for testing.""" class Meta: """Meta definition for the factory.""" model = AccountTaxInfoHistory account_tax_info_history_id = factory.Sequence(lambda n: n + 1) account = factory.SubFactory(AccountFactory) account_tax_info = factory.SubFactory(AccountTaxInfoFactory) country_of_tax_residence = 'USA' is_sba_signed = False is_vat_exempt = True created_at = '2022-01-27' last_modified = '2022-01-28' class PaymentHoldFactory(BaseModelFactoryWithTimestamps): """Factory to create payment_hold models for testing.""" class Meta: """Meta definition for the factory.""" model = PaymentHold is_on_hold = True account = factory.SubFactory(AccountFactory) reason = 'Account was rude to me.' start_date = '2020-04-24' class PaymentHoldHistoryFactory(BaseModelFactoryWithTimestamps): """Factory to create payment_hold_history records for testing.""" class Meta: """Meta definition for factory.""" model = PaymentHoldHistory end_date = '2020-04-30' is_on_hold = True account = factory.SubFactory(AccountFactory) payment_hold = factory.SubFactory(PaymentHoldFactory) reason = 'Account was rude to me.' start_date = '2020-04-24' class AccountPaymentTermFactory(BaseModelFactoryWithTimestamps): """Factory to create account_payment_term models for testing.""" class Meta: """Meta definition for the factory.""" model = AccountPaymentTerm account = factory.SubFactory(AccountFactory) currency_code = 'USD' payment_minimum = '35.00' payment_schedule = constants.PAYMENT_SCHEDULE.SCHEDULE_30_DAYS_MONTH agreement_type_id = 1 payment_entity_id = 5 class AccountPaymentTermTemplateFactory(BaseModelFactory): """Factory to create account_payment_term_template models for testing.""" class Meta: """Meta definition for the factory.""" model = AccountPaymentTermTemplate template_name = 'Template 1' currency_code = 'GBP' payment_terms = { 'payment_minimum': '35.00', 'payment_schedule': constants.PAYMENT_SCHEDULE.SCHEDULE_45_DAYS_MONTH, 'agreement_type_id': 1, 'payment_entity_id': 1, } class ReferenceAgreementTypeFactory(BaseModelFactory): """Factory to create reference_agreement_type model for testing.""" class Meta: """Meta definition for the factory.""" model = ReferenceAgreementType reference_agreement_type_id = factory.Sequence(lambda n: n + 1) agreement_type = 'AWAL Core' class PaymentEntityPayoneerProgramFactory(BaseModelFactory): """Factory to create payment_entity_payoneer_program models for testing.""" class Meta: """Meta definition for the factory.""" model = PaymentEntityPayoneerProgram payment_entity_payoneer_program_id = factory.Sequence(lambda n: n + 1) payment_currency = 'USD' payoneer_program_id = 1 agreement_type_id = 1 reference_payment_entity_id = 1 class ReferencePaymentTypeFactory(BaseModelFactory): """Factory to create ReferencePaymentType instances for testing.""" class Meta: """Factory meta definition.""" model = ReferencePaymentType payment_type = 'advance' payment_service = 'service' is_internal = False notes = None