"""Test Setup.""" import pytest @pytest.fixture def mock_event(): """Mock abacus_event.""" return { 'abacus_event_id': 1, 'target_type': 'statement_period_adjustment_file', 'target_id': '1', 'event_name': 'apply_pending_adjustment', 'timestamp': '2020-01-10T01:12:25.15+01:00', 'user_type': 'royalties', 'user_id': '1', } @pytest.fixture def mock_exchange_rates(): """Mock exchange rates.""" return [ { 'exchange_rate_id': 1, 'from_currency_code': 'USD', 'to_currency_code': 'GBP', 'rate': 0.89052, }, { 'exchange_rate_id': 2, 'from_currency_code': 'JPY', 'to_currency_code': 'GBP', 'rate': 0.2083, }, ] @pytest.fixture def mock_payment_entity_close_balance_statuses(): """Mock closing balance statuses for payment entities in statement period.""" return [ { 'statement_period_payment_entity_id': 1, 'reference_payment_entity_id': 1, 'statement_period_id': 1, 'abacus_state_id': 1000, 'action_name': 'close_balance', 'action_status': 'complete', }, { 'statement_period_payment_entity_id': 1, 'reference_payment_entity_id': 2, 'statement_period_id': 1, 'abacus_state_id': 1001, 'action_name': 'close_balance', 'action_status': 'init', }, ] @pytest.fixture def mock_pending_adjustments(): """Mock pending adjustments.""" return [ { 'worksheet_adjustment_id': 1, 'statement_period_adjustment_file_id': 1, 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 222, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 1337, 'apply_to_flowthrough_payment': None, 'adjustment_amount': '2000.05', 'adjustment_currency_code': 'USD', 'note': 'this is a note', 'account_currency_code': 'GBP', 'account_payment_entity_id': 1, 'details': [ { 'worksheet_adjustment_id': '1', 'worksheet_adjustment_detail_id': '1', 'statement_period_adjustment_file_id': '1', 'account_id': 111, 'contract_id': 222, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 1337, 'currency_code': 'USD', 'amount': '1201.08', 'upc': '555444333222111', 'distribution_type': 'digital', 'note': 'info message', }, { 'worksheet_adjustment_id': '1', 'worksheet_adjustment_detail_id': '2', 'statement_period_adjustment_file_id': '1', 'account_id': 111, 'contract_id': 222, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 1337, 'apply_to_flowthrough_payment': None, 'currency_code': 'USD', 'amount': '798.97', 'upc': '555444333222111', 'distribution_type': 'digital', 'note': 'info message', }, ], }, { 'worksheet_adjustment_id': 2, 'statement_period_adjustment_file_id': 1, 'abacus_event_id': 11, 'account_id': 112, 'contract_id': 223, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 105, 'apply_to_flowthrough_payment': False, 'adjustment_amount': '2001.00', 'adjustment_currency_code': 'USD', 'note': 'this is a note', 'account_currency_code': 'GBP', 'account_payment_entity_id': 2, 'details': [], }, { 'worksheet_adjustment_id': 3, 'statement_period_adjustment_file_id': 1, 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 224, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 105, 'apply_to_flowthrough_payment': True, 'adjustment_amount': '2003.00', 'adjustment_currency_code': 'USD', 'note': 'this is a note', 'account_currency_code': 'GBP', 'account_payment_entity_id': 1, 'details': [], }, { 'worksheet_adjustment_id': 4, 'statement_period_adjustment_file_id': 1, 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 224, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 105, 'apply_to_flowthrough_payment': True, 'adjustment_amount': '2003.00', 'adjustment_currency_code': 'USD', 'note': 'this is a note', 'account_currency_code': 'USD', 'account_payment_entity_id': 1, 'details': [], }, ] @pytest.fixture def mock_ledger_adjustment_applied(): """Mock ledger_adjustment_applied records.""" return [ { 'abacus_event_id': 11, 'statement_period_id': 2, 'account_id': 111, 'contract_id': 222, 'worksheet_adjustment_id': 1, 'adjustment_currency_code': 'USD', 'adjustment_amount': '2000.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '1781.09', 'details': [ { 'worksheet_adjustment_id': '1', 'worksheet_adjustment_detail_id': '1', 'account_id': 111, 'contract_id': 222, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 1337, 'currency_code': 'USD', 'amount': '1201.08', 'upc': '555444333222111', 'distribution_type': 'digital', 'note': 'info message', }, { 'worksheet_adjustment_id': '1', 'worksheet_adjustment_detail_id': '2', 'account_id': 111, 'contract_id': 222, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 1337, 'currency_code': 'USD', 'amount': '798.97', 'upc': '555444333222111', 'distribution_type': 'digital', 'note': 'info message', }, ], }, { 'abacus_event_id': 11, 'statement_period_id': 2, 'account_id': 112, 'contract_id': 223, 'worksheet_adjustment_id': 2, 'adjustment_currency_code': 'USD', 'adjustment_amount': '2001.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '1781.94', 'details': [], }, { 'abacus_event_id': 11, 'statement_period_id': 2, 'account_id': 111, 'contract_id': 224, 'worksheet_adjustment_id': 3, 'adjustment_currency_code': 'USD', 'adjustment_amount': '2003.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '1783.72', 'details': [], }, { 'abacus_event_id': 11, 'statement_period_id': 2, 'account_id': 111, 'contract_id': 224, 'worksheet_adjustment_id': 4, 'adjustment_currency_code': 'USD', 'adjustment_amount': '2003.00', 'adjustment_payee_currency_code': 'USD', 'adjustment_amount_payee_currency': '2003.00', 'details': [], }, ] @pytest.fixture def mock_ledger_accounts(): """Mock ledger_account records.""" return [ { 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 222, 'currency_amount': '1781.09', 'currency_code': 'GBP', 'model_type': 'account', }, { 'abacus_event_id': 11, 'account_id': 112, 'contract_id': 223, 'currency_amount': '1781.94', 'currency_code': 'GBP', 'model_type': 'account', }, { 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 224, 'currency_amount': '3786.72', 'currency_code': 'GBP', 'model_type': 'account', }, ] @pytest.fixture def mock_ledger_deposits(): """Mock ledger_deposit records.""" return [ { 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 222, 'currency_code': 'GBP', 'model_type': 'deposit', 'rounded_amount': '1781.09', 'remaining_amount': '-0.0054740', }, { 'abacus_event_id': 11, 'account_id': 111, 'contract_id': 224, 'currency_code': 'GBP', 'model_type': 'deposit', 'rounded_amount': '3786.72', 'remaining_amount': '-0.0084400', }, ] @pytest.fixture def mock_current_statement_period(): """Mock current statement period record.""" return { 'statement_period_id': 2, 'statement_period_name': 'January 2024', 'statement_period_status': 'current', 'closed_date': None, 'exchange_rates_delivered': True, } @pytest.fixture def mock_worksheet_adjustments_and_details(): """Mock worksheet adjustments and details record.""" return { 'items': [ { 'worksheet_adjustment_id': 1, 'statement_period_adjustment_file_id': 1, 'abacus_event_id': 1, 'account_id': 35972, 'contract_id': 500004, 'activity_statement_period_id': 1, 'apply_to_statement_period_id': 2, 'reference_adjustment_type_id': 5, 'adjustment_amount': '34.89', 'adjustment_currency_code': 'DKK', 'note': None, 'internal_note': None, 'account_currency_code': 'USD', 'account_payment_entity_id': 1, 'details': [], } ], 'total_count': 1, }