"""Reference Adjustment Type model tests.""" from datetime import datetime from moneyhub.models.reference_adjustment_type import ReferenceAdjustmentType from tests.unit.conftest import insert_mock_data def _insert_mock_data(): """Insert mock data for the tests.""" insert_mock_data({ 'account': [ {'account_id': 1235}, {'account_id': 4444} ], 'reference_payment_entity': {'reference_payment_entity_id': 1}, 'reference_sap_profit_center': { 'reference_sap_profit_center_id': 1, 'profit_center': 'UK1234', 'company_code': '1234', 'business_group': 'ORC' }, 'reference_signing_entity': { 'reference_signing_entity_id': 1, 'reference_payment_entity_id': 1, 'reference_sap_profit_center_id': 1, 'company_code': '1234', 'tax_entity_company_code': '1234', 'legal_name': 'Company', 'vat_number': '12341234', 'company_registration_number': '12341234', 'address': None, }, 'contract': [ { 'contract_id': 4343, 'reference_signing_entity_id': 1, }, { 'contract_id': 999, 'reference_signing_entity_id': 1, }, { 'contract_id': 123, 'reference_signing_entity_id': 1, }, ], 'statement_period': [ {'statement_period_id': 12, 'statement_period_status': 'closed'}, {'statement_period_id': 14, 'statement_period_status': 'current'}, ], 'abacus_event': [ {'abacus_event_id': 1, 'statement_period_id': 12}, {'abacus_event_id': 2, 'statement_period_id': 14}, {'abacus_event_id': 3, 'statement_period_id': 14}, ], 'reference_adjustment_type': [ { 'reference_adjustment_type_id': 1, 'type_name': 'Label Earnings' }, { 'reference_adjustment_type_id': 2, 'type_name': 'Publisher Earnings' }, { 'reference_adjustment_type_id': 65, 'type_name': 'Expense' }, ], 'statement_period_adjustment_file': { 'statement_period_adjustment_file_id': 1, 'statement_period_id': 12, }, 'worksheet_adjustment': [ { 'account_id': 1235, 'contract_id': 4343, 'abacus_event_id': 1, 'statement_period_adjustment_file_id': 1, 'worksheet_adjustment_id': 1, 'activity_statement_period_id': 12, 'adjustment_amount': 1010.00, 'adjustment_currency_code': 'USD', 'apply_to_statement_period_id': 14, 'reference_adjustment_type_id': 1, 'note': 'mock adjustment' }, { 'account_id': 1235, 'contract_id': 4343, 'abacus_event_id': 1, 'statement_period_adjustment_file_id': 1, 'worksheet_adjustment_id': 2, 'activity_statement_period_id': 12, 'adjustment_amount': 1010.00, 'adjustment_currency_code': 'USD', 'apply_to_statement_period_id': 14, 'reference_adjustment_type_id': 2, 'note': 'mock adjustment' }, { 'account_id': 1235, 'contract_id': 4343, 'abacus_event_id': 3, 'statement_period_adjustment_file_id': 1, 'worksheet_adjustment_id': 5, 'activity_statement_period_id': 12, 'adjustment_amount': 252.00, 'adjustment_currency_code': 'USD', 'apply_to_statement_period_id': 14, 'reference_adjustment_type_id': 2, 'note': 'mock adjustment applied' }, ], 'worksheet_adjustment_detail': [ { 'worksheet_adjustment_id': 1, 'worksheet_adjustment_detail_id': 1, 'statement_period_adjustment_file_id': 1, 'account_id': 1235, 'contract_id': 999, 'activity_statement_period_id': 12, 'amount': '1000.00', 'apply_to_statement_period_id': 14, 'currency_code': 'USD', 'created_at': datetime(2022, 1, 1), 'created_by': 'someone', 'distribution_type': 'digital', 'last_modified': datetime(2022, 5, 1), 'last_modified_by': 'someone', 'reference_adjustment_type_id': 1, 'note': 'mock adjustment', 'upc': '12345678' }, { 'worksheet_adjustment_id': 5, 'worksheet_adjustment_detail_id': 5, 'statement_period_adjustment_file_id': 1, 'account_id': 1235, 'contract_id': 999, 'activity_statement_period_id': 12, 'amount': '1000.00', 'apply_to_statement_period_id': 14, 'currency_code': 'USD', 'created_at': datetime(2022, 1, 1), 'created_by': 'someone', 'distribution_type': 'digital', 'last_modified': datetime(2022, 5, 1), 'last_modified_by': 'someone', 'reference_adjustment_type_id': 2, 'note': 'mock adjustment', 'upc': '87654321' } ], }) def test_get_reference_adjustments_types_by_account_id(): """Test getting adjustment types based on an account.""" account_id = 1235 _insert_mock_data() res = ReferenceAdjustmentType.get_by_account_id(account_id) assert len(res) == 2 def test_get_for_expenses_by_account_id(): """Test getting expenses types based on an account.""" account_id = 1235 _insert_mock_data() res = ReferenceAdjustmentType.get_for_expenses_by_account_id(account_id) assert len(res) == 2 def test_get_reference_adjustments_types_exclude_expenses(): """Test getting adjustment types excluding expenses id.""" account_id = 4444 _insert_mock_data() res = ReferenceAdjustmentType.get_by_account_id(account_id) assert len(res) == 0