"""Shared fixtures for tests.""" import os import pytest from ledger.api import create_app, db from ledger.config import Config from tests.utils.factories import ReferenceAdjustmentTypeFactory class TestConfig(Config): """Test configuration.""" MYSQL_DB_NAME = os.environ.get('MYSQL_TEST_DB_NAME', Config.MYSQL_DB_NAME + '_test') AUDIT_LOG_ES_ENDPOINT = None @pytest.fixture(scope='session', autouse=True) def test_app(): """Create a test application.""" return create_app(TestConfig) @pytest.fixture(autouse=True) def test_app_in_context(test_app): """Push the test app onto the context.""" with test_app.app_context(): yield test_app @pytest.fixture(autouse=True) def test_app_request(test_app_in_context): """Push the test app onto the context and trigger preprocessing.""" with test_app_in_context.test_request_context(): test_app_in_context.preprocess_request() yield test_app_in_context @pytest.fixture def fixture_client(test_app_in_context): """Create a client fixture.""" with test_app_in_context.test_client() as test_client: yield test_client @pytest.fixture def fresh_db(): """Refresh the test database.""" table_names = [ 'abacus_event', 'account', 'account_tax_info', 'accounting_period', 'accounting_run', 'account_contract', 'account_payment_term', 'contract', 'contract_advance', 'contract_reserve', 'ledger_account', 'ledger_account_contract', 'ledger_account_contract_current_balance', 'ledger_account_current_balance', 'ledger_accounting_run_balance', 'ledger_accounting_run_vat', 'ledger_correction', 'ledger_contract_advance_applied', 'ledger_adjustment', 'ledger_adjustment_applied', 'ledger_adjustment_detail', 'ledger_adjustment_detail_applied', 'ledger_adjustment_adjustment_detail', 'ledger_adjustment_adjustment_detail_applied', 'ledger_contract_flowthrough', 'ledger_contract_flowthrough_current_balance', 'ledger_deposit', 'ledger_reserve_release', 'ledger_reserve_taken', 'ledger_reserve_release_schedule', 'ledger_vat_summary', 'payment_group', 'payment_group_payment', 'payment_group_payment_account', 'payment_hold', 'payment_hold_history', 'reference_adjustment_type', 'reference_payment_entity', 'reference_payoneer_program', 'reference_payment_type', 'reference_sap_profit_center', 'reference_signing_entity', 'reference_vat_rate', 'run_controller', 'statement_period', 'worksheet_correction', 'worksheet_adjustment_detail', 'worksheet_adjustment', 'worksheet_payment_contract_advance', 'statement_period_adjustment_file', 'worksheet_payment_custom', ] con = db.engine.connect() con.execute('SET FOREIGN_KEY_CHECKS = 0;') trans = con.begin() for table_name in table_names: con.execute(f'TRUNCATE TABLE `{table_name}`') trans.commit() con.execute('SET FOREIGN_KEY_CHECKS = 1;') def mock_account(account_id=1): """Insert account data.""" SQL_QUERY = """ INSERT INTO account ( `account_id`, `account_name`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES ( {account_id}, 'Test {account_id}', 1, '2021-01-01 00:00:00', 1, '2021-01-01 00:00:00' ); """ db.engine.execute(SQL_QUERY.format(account_id=account_id)) def mock_accounting_period(): """Insert accounting period data.""" STATEMENT_PERIOD_INSERT = """ INSERT INTO statement_period( statement_period_id, statement_period_name, statement_period_status ) VALUES(1, 'Jan 20', 'current'), (2, 'Feb 20', 'open'); """ ACCOUNTING_PERIOD_INSERT = """ INSERT INTO accounting_period ( `accounting_period_id`, `statement_period_id`, `accounting_period_name`, `accounting_period_status`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES (1, 1, 'Jan 20', 'closed', 1, NOW(), 1, NOW()), (2, 1, 'Mar 20', 'closed', 1, NOW(), 1, NOW()) """ db.engine.execute(STATEMENT_PERIOD_INSERT) db.engine.execute(ACCOUNTING_PERIOD_INSERT) def mock_accounting_run(): """Insert accounting run data.""" SQL_QUERY = """ INSERT INTO accounting_run ( `accounting_run_id`, `accounting_period_id`, `run_controller_id`, `run_status`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES (1, 1, 1, 'Committed', 1, '2019-01-01 00:00:00', 1, '2019-01-01 00:00:00'), (2, 1, 2, 'Committed', 1, '2019-03-01 00:00:00', 1, '2019-03-01 00:00:00'), (3, 1, 3, 'Invalid', 1, '2019-03-01 00:00:00', 1, '2019-03-01 00:00:00'), (4, 1, 3, 'Skipped', 1, '2019-03-01 00:00:00', 1, '2019-03-01 00:00:00'); """ db.engine.execute(SQL_QUERY) def mock_run_controller(): """Mock run controller insert.""" SQL_QUERY = """ INSERT INTO run_controller ( `run_controller_id`, `run_controller_name`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES (1, 'foo', 'dana', NOW(), 'dana', NOW()), (2, 'bar', 'dana', NOW(), 'dana', NOW()), (3, 'baz', 'dana', NOW(), 'dana', NOW()); """ db.engine.execute(SQL_QUERY) def mock_contract(contract_id=1, account_id=1): """Mock contract insert.""" SQL_QUERY = """ INSERT INTO contract ( `contract_id`, `reference_signing_entity_id`, `reference_sap_profit_center_id`, `contract_name`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES ( {contract_id}, 1, 1, 'foo-{contract_id}-{account_id}', '', NOW(), '', NOW() ); """ db.engine.execute('SET FOREIGN_KEY_CHECKS=0') db.engine.execute(SQL_QUERY.format(contract_id=contract_id, account_id=account_id)) db.engine.execute('SET FOREIGN_KEY_CHECKS=1') def mock_reference_signing_entities(): """Create reference_signing_entities in the database.""" SQL_INSERT = """ INSERT INTO `reference_sap_profit_center` (`profit_center`, `company_code`, `business_group`) VALUES ('US123','1234','ORC'); """ db.engine.execute(SQL_INSERT) SQL_INSERT = """ INSERT INTO reference_payment_entity( reference_payment_entity_id, payment_entity_name, country_of_tax_reporting, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 'AWAL-UK', 'GBR', 'test', NOW(), 'test', NOW()), (2, 'AWAL-US', 'USA', 'test', NOW(), 'test', NOW()); """ db.engine.execute(SQL_INSERT) SQL_INSERT = """ INSERT INTO reference_signing_entity( reference_signing_entity_id, reference_payment_entity_id, company_code, legal_name, vat_number, company_registration_number, address, reference_sap_profit_center_id ) VALUES ( 1, 1, 4914, 'AWAL Digital Limited', 'GB 423 4787 86', '04430703', '2 Canal Reach, London, N1C 4DB', 1 ); """ db.engine.execute(SQL_INSERT) def mock_account_payment_term(): """Mock account_payment_term insert.""" SQL_QUERY = """ INSERT INTO account_payment_term( `account_payment_term_id`, `account_id`, `currency_code`, `payment_minimum`, `payment_entity_id`, `payment_schedule`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES (1, 1, 'USD', 42.00, 1, null, 'Test', NOW(), 'Test', NOW()), (2, 50, 'USD', 43.00, 1, null, 'Test', NOW(), 'Test', NOW()); """ db.engine.execute(SQL_QUERY) def mock_account_contract(): """Mock account_contract insert.""" SQL_QUERY = """ INSERT INTO account_contract(account_contract_id, account_id, contract_id) VALUES (1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 50, 4), (5, 50, 5); """ db.engine.execute(SQL_QUERY) def mock_contract_reserve(): """Mock contract_reserve insert.""" SQL_QUERY = """ INSERT INTO contract_reserve( contract_reserve_id, contract_id, reserve_rate, reserve_release_offset_in_months, installments_in_months, release_schedule, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 1.90, 1, 2, '["0.50", "0.50"]', 'Test', NOW(), 'Test', NOW()), (2, 2, 23.89, 2, 3, '["0.333", "0.667"]', 'Test', NOW(), 'Test', NOW()); """ db.engine.execute(SQL_QUERY) def mock_account_tax_info(): """Mock account_tax_info insert.""" SQL_QUERY = """ INSERT INTO account_tax_info( `account_tax_info_id`, `account_id`, `country_of_tax_residence`, `is_sba_signed`, `is_vat_exempt`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES (1, 1,'USA', 0, 1, 'test','2021-10-29 13:22:52','test','2021-10-29 13:22:58'), (2, 50,'GBR', 0, 0, 'test','2021-10-29 13:25:36','test','2021-10-29 13:25:43'); """ db.engine.execute(SQL_QUERY) def mock_reference_payment_type(): """Mock reference_payment_type insert.""" SQL_QUERY = """ INSERT INTO reference_payment_type( reference_payment_type_id, payment_type, payment_service, is_internal, notes ) VALUES (1, 'advance', 'payoneer', 1, NULL); """ db.engine.execute(SQL_QUERY) def mock_payment_group_payment_account(): """Mock payment_group, payment_group_payment, payment_group_payment_account.""" REFERENCE_PAYONEER_PROGRAM_INSERT = """ INSERT INTO reference_payoneer_program( `payoneer_program_id`, `payoneer_program_name`, `funding_currency`, `reference_payment_type_id` ) VALUES(1234567890, 'AWAL US USD', 'USD', 1); """ PAYMENT_GROUP_INSERT = """ INSERT INTO payment_group( payment_group_id, group_name, created_at, created_by, last_modified, last_modified_by ) VALUES (1, 'Test Group', NOW(), 'dana', NOW(), 'dana'); """ PAYMENT_GROUP_PAYMENT_INSERT = """ INSERT INTO payment_group_payment( payment_group_payment_id, payment_group_id, statement_period_id, payment_name, created_at, created_by, last_modified, last_modified_by ) VALUES (1, 1, 1, 'Test Payment', NOW(), 'dana', NOW(), 'dana'); """ PAYMENT_GROUP_PAYMENT_ACCOUNT_INSERT = """ INSERT INTO payment_group_payment_account( payment_group_payment_account_id, payment_group_payment_id, account_id, payoneer_program_id, current_statement_period_id, currency_code, last_payment, current_balance, tax_withholding, balance_after_tax, created_at, created_by, last_modified, last_modified_by ) VALUES ( 1, 1, 1, 1234567890, 1, 'USD', 0.00, 10000.00, -100.00, 9900.00, NOW(), 'dana', NOW(), 'dana' ) """ db.engine.execute(REFERENCE_PAYONEER_PROGRAM_INSERT) db.engine.execute(PAYMENT_GROUP_INSERT) db.engine.execute(PAYMENT_GROUP_PAYMENT_INSERT) db.engine.execute(PAYMENT_GROUP_PAYMENT_ACCOUNT_INSERT) def mock_contract_advance(): """Mock contract_advance insert.""" SQL_QUERY = """ INSERT INTO contract_advance( `contract_advance_id`, `contract_id`, `advance_description`, `amount`, `currency_code`, `milestone`, `milestone_description`, `milestone_date`, `advance_status`, `note`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES (1, 1, 'Advance description', '150', 'USD', 'recoupment', 'Milestone description', '2022-09-15', 'paid', 'paid via check', 'test', '2021-10-29 13:22:52','test', '2021-10-29 13:22:58'); """ db.engine.execute(SQL_QUERY) def mock_worksheet_payment_contract_advance(): """Mock worksheet_payment_contract_advance.""" SQL_INSERT = """ INSERT INTO worksheet_payment_contract_advance ( worksheet_payment_contract_advance_id, contract_advance_id, statement_period_id, exchange_rate_statement_period_id, payment_name, amount, currency_code, amount_payee_currency, payee_currency_code, exchange_rate, withholding_tax_amount, vat_amount, amount_after_withholding_and_vat, withholding_tax_amount_payee_currency, vat_amount_payee_currency, amount_after_withholding_and_vat_payee_currency, is_internal, created_at, created_by, last_modified, last_modified_by ) VALUES ( 1, 1, 1, 1, 'Test contract advance payment', 12.00, 'USD', 12.00, 'USD', 1, 5.00, -5.00, 12.00, 5.00, -5.00, 12.00, 0, '2024-04-11', 'test', '2024-04-11', 'test' ); """ db.engine.execute(SQL_INSERT) def mock_worksheet_payment_custom(): """Mock worksheet_payment_custom.""" SQL_INSERT = """ INSERT INTO worksheet_payment_custom ( worksheet_payment_custom_id, account_id, contract_id, currency_code, amount, withholding_tax_amount, withholding_tax_rate, vat_amount, vat_rate, amount_after_withholding_and_vat, activity_statement_period_id, statement_period_id, payment_name, created_at, created_by, last_modified, last_modified_by ) VALUES ( 1, 1, 1, 'USD', 1000.00, -100.00, 10.00, 200.00, 20.00, 1100.00, 1, 1, 'Test custom payment', '2025-12-01', 'test', '2025-12-01', 'test' ); """ db.engine.execute(SQL_INSERT) @pytest.fixture def mock_worksheet_correction(): """Mock worksheet_correction insert.""" SQL_QUERY = """ INSERT INTO worksheet_correction( `worksheet_correction_id`, `account_id`, `contract_id`, `statement_period_id`, `correction_statement_period_id`, `correction_type`, `currency_code`, `gross_revenue`, `distribution_fee`, `net_revenue`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES( 1, 1, 1, 1, 2, 'royalty_reversal', 'USD', -150.00, 30.00, -120.00, 'test', '2021-10-29 13:22:52', 'test', '2021-10-29 13:22:58' ), ( 2, 50, 2, 1, 2, 'royalty_reversal', 'USD', -2500.00, 100.00, -2400.00, 'test', '2021-10-29 13:22:52', 'test', '2021-10-29 13:22:58' ); """ db.engine.execute(SQL_QUERY) @pytest.fixture def mock_event_fixtures(): """Create the records required to add ledger entries.""" mock_reference_signing_entities() mock_account() mock_account(50) mock_accounting_period() mock_run_controller() mock_accounting_run() mock_contract() mock_contract(2, 1) mock_contract(3, 1) mock_contract(4, 50) mock_contract(5, 50) mock_account_tax_info() mock_account_payment_term() mock_account_contract() mock_contract_reserve() ReferenceAdjustmentTypeFactory.create(reference_adjustment_type_id=1) mock_reference_payment_type() mock_payment_group_payment_account() mock_contract_advance() mock_worksheet_payment_contract_advance() mock_worksheet_payment_custom() mock_statement_period_adjustment_file() SQL_QUERY = """ INSERT INTO abacus_event ( `abacus_event_id`, `statement_period_id`, `event_date`, `event_name`, `target_type`, `target_id`, `created_by` ) VALUES ( 1, 1, '2020-01-01', 'take_reserves', 'accounting_run', 1, 'Test' ), ( 2, 1, '2020-01-02', 'commit_royalties', 'accounting_period', 1, 'Test' ), ( 3, 1, '2020-01-03', 'release_reserves', 'statement_period', 1, 'Test' ), ( 4, 1, '2020-01-03', 'tax_withholding', 'payment_group_payment', 1, 'Test' ), ( 5, 1, '2020-01-04', 'apply_pending_adjustments', 'statement_period', 1, 'Test' ), ( 6, 1, '2020-01-04', 'send_payments', 'payment_group_payment', 1, 'Test' ), ( 7, 1, '2020-01-04', 'confirm_advance_payment', 'contract_advance', 1, 'Test' ), ( 8, 1, '2020-01-05', 'payment_returned', 'payment_group_payment_account', 1, 'Test' ), ( 9, 1, '2020-01-02', 'commit_royalties', 'accounting_run', 1, 'Test' ), ( 10, 1, '2020-01-02', 'apply_royalty_reversal', 'statement_period', 1, 'Test' ), ( 11, 1, '2020-01-02', 'release_reserves', 'statement_period', 1, 'Test' ), ( 12, 1, '2020-01-02', 'apply_royalty_correction', 'statement_period', 1, 'Test' ),( 13, 1, '2023-12-11', 'commit_vat', 'statement_period', 1, 'Test' ), ( 14, 1, '2020-01-04', 'apply_pending_adjustments', 'statement_period_adjustment_file', 1, 'Test' ), ( 15, 1, '2024-03-13', 'commit_to_subledger', 'worksheet_payment_contract_advance', 1, 'Test' ), ( 16, 1, '2024-03-13', 'commit_vat_summary', 'vat_summary_file', 1, 'Test' ), ( 17, 1, '2024-04-11', 'return_advance_payment', 'worksheet_payment_contract_advance', 1, 'Test' ), ( 18, 1, '2024-11-26', 'commit_batch_payment', 'payment_group_payment_batch', 1, 'Test' ), ( 19, 1, '2024-11-26', 'commit_vat_summary', 'payment_group_payment_batch', 1, 'Test' ), ( 20, 1, '2024-11-26', 'commit_withholding_tax', 'payment_group_payment_batch', 1, 'Test' ), ( 21, 1, '2024-11-26', 'return_batch_payment', 'payment_group_payment_account', 1, 'Test' ), ( 22, 1, '2024-11-26', 'return_vat_summary', 'payment_group_payment_account', 1, 'Test' ), ( 23, 1, '2024-11-26', 'return_withholding_tax', 'payment_group_payment_account', 1, 'Test' ), ( 24, 1, '2024-11-26', 'commit_mechanicals', 'accounting_run', 1, 'Test' ), ( 25, 1, '2025-12-01', 'commit_custom_payment', 'worksheet_payment_custom', 1, 'Test' ), ( 26, 1, '2025-12-01', 'commit_vat_summary', 'worksheet_payment_custom', 1, 'Test' ), ( 27, 1, '2025-12-01', 'commit_withholding_tax', 'worksheet_payment_custom', 1, 'Test' ), ( 28, 1, '2025-12-02', 'return_custom_payment', 'worksheet_payment_custom', 1, 'Test' ), ( 29, 1, '2025-12-02', 'return_vat_summary', 'worksheet_payment_custom', 1, 'Test' ), ( 30, 1, '2025-12-02', 'return_withholding_tax', 'worksheet_payment_custom', 1, 'Test' ); """ db.engine.execute(SQL_QUERY) mock_worksheet_adjustment() mock_worksheet_adjustment_detail() mock_worksheet_adjustment_detail(worksheet_adjustment_detail_id=2) def mock_statement_period_adjustment_file(): """Mock statement_period_adjustment_file insert.""" SQL_QUERY = """ INSERT INTO statement_period_adjustment_file( `statement_period_adjustment_file_id`, `statement_period_id`, `file_name`, `valid_file_location`, `invalid_file_location`, `valid_row_count`, `invalid_row_count`, `total_file_amount_multicurrency`, `total_rounded_amount_multicurrency`, `md5sum`, `error_type`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES( 1, 1, 'Test Adjustment File', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'test', '2021-10-29 13:22:52', 'test', '2021-10-29 13:22:58' ); """ db.engine.execute(SQL_QUERY) def mock_worksheet_adjustment(worksheet_adjustment_id=1): """Mock worksheet_adjustment insert.""" SQL_QUERY = """ INSERT INTO worksheet_adjustment( `worksheet_adjustment_id`, `statement_period_adjustment_file_id`, `abacus_event_id`, `account_id`, `contract_id`, `activity_statement_period_id`, `apply_to_statement_period_id`, `reference_adjustment_type_id`, `adjustment_amount`, `adjustment_currency_code`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES( {worksheet_adjustment_id}, 1, 14, 1, 1, 1, 2, 1, '150', 'USD', 'test', '2021-10-29 13:22:52', 'test', '2021-10-29 13:22:58' ); """ db.engine.execute(SQL_QUERY.format(worksheet_adjustment_id=worksheet_adjustment_id)) def mock_worksheet_adjustment_detail( worksheet_adjustment_id=1, worksheet_adjustment_detail_id=1 ): """Mock worksheet_adjustment_detail insert.""" SQL_QUERY = """ INSERT INTO worksheet_adjustment_detail( `worksheet_adjustment_detail_id`, `statement_period_adjustment_file_id`, `worksheet_adjustment_id`, `account_id`, `contract_id`, `activity_statement_period_id`, `apply_to_statement_period_id`, `reference_adjustment_type_id`, `currency_code`, `amount`, `upc`, `distribution_type`, `created_by`, `created_at`, `last_modified_by`, `last_modified` ) VALUES( {worksheet_adjustment_detail_id}, 1, {worksheet_adjustment_id}, 1, 1, 1, 2, 1, 'USD', '70', '123456789111', 'digital', 'test', '2021-10-29 13:22:52', 'test', '2021-10-29 13:22:58' ); """ db.engine.execute( SQL_QUERY.format( worksheet_adjustment_id=worksheet_adjustment_id, worksheet_adjustment_detail_id=worksheet_adjustment_detail_id, ) ) @pytest.fixture def mock_bulk_ledger_accounting_run_balances_body(): """Mock bulk ledger accounting run balances POST body.""" return [ { 'abacus_event_id': 1, 'adjusted_net_revenue': '-430.69', 'contract_id': 1, 'currency_code': 'EUR', 'distribution_fee': '95.00', 'mechanical_deduction_admin_fee_total': '534.00', 'mechanical_deduction_total': '333.00', 'total_gross_revenue_amount': '531.31', 'total_net_revenue_amount': '436.31', }, { 'abacus_event_id': 1, 'adjusted_net_revenue': '418.31', 'contract_id': 1, 'currency_code': 'GBP', 'distribution_fee': '200.00', 'mechanical_deduction_admin_fee_total': '50.00', 'mechanical_deduction_total': '33.00', 'total_gross_revenue_amount': '701.31', 'total_net_revenue_amount': '501.31', }, { 'abacus_event_id': 1, 'adjusted_net_revenue': '609.09', 'contract_id': 1, 'currency_code': 'USD', 'distribution_fee': '50.72', 'mechanical_deduction_admin_fee_total': '27.22', 'mechanical_deduction_total': '23.00', 'total_gross_revenue_amount': '710.03', 'total_net_revenue_amount': '659.31', }, ] @pytest.fixture def mock_bulk_ledger_reserve_taken_body(): """Mock POST request body for bulk ledger_reserve_taken entries.""" return [ { 'abacus_event_id': 1, 'accounting_run_id': 1, 'contract_reserve_id': 1, 'currency_code': 'USD', 'gross_returns': '-50.00', 'gross_sales': '200.00', 'net_revenue': '150.00', 'net_revenue_after_reserve': '100.00', 'reserve_amount': '50.00', 'statement_period_id': 1, }, { 'abacus_event_id': 1, 'accounting_run_id': 1, 'contract_reserve_id': 2, 'currency_code': 'AUD', 'gross_returns': '-30.00', 'gross_sales': '80.00', 'net_revenue': '65.10', 'net_revenue_after_reserve': '53.10', 'reserve_amount': '118.20', 'statement_period_id': 1, }, ] @pytest.fixture def mock_bulk_ledger_reserve_release_schedule_body(): """Mock body for POST ledger_reserve_release_schedule.""" return [ { 'abacus_event_id': 1, 'account_id': 1, 'taken_statement_period_id': 1, 'release_statement_period_id': 2, 'ledger_reserve_taken_id': 1, 'currency_code': 'USD', 'installment_amount': '-1500.11', 'outstanding_amount_after_installment': '-2100.01', 'early_release_date': None, }, { 'abacus_event_id': 2, 'account_id': 1, 'taken_statement_period_id': 1, 'release_statement_period_id': 2, 'ledger_reserve_taken_id': 1, 'currency_code': 'USD', 'installment_amount': '-1111.22', 'outstanding_amount_after_installment': '-3333.44', 'early_release_date': None, }, ] @pytest.fixture def mock_bulk_ledger_reserve_release_body(): """Mock POST request body for bulk ledger_reserve_release entries.""" return [ { 'abacus_event_id': 1, 'statement_period_id': 1, 'ledger_reserve_release_schedule_id': 1, 'installment_amount': '1500.00', }, { 'abacus_event_id': 1, 'statement_period_id': 1, 'ledger_reserve_release_schedule_id': 2, 'installment_amount': '179.23', }, ] @pytest.fixture def mock_bulk_ledger_adjustment_applied_request_body(): """Mock body for POST ledger_adjustment_applied.""" return [ { 'abacus_event_id': 1, 'account_id': 1, 'contract_id': 1, 'statement_period_id': 1, 'ledger_adjustment_id': 1, 'worksheet_adjustment_id': 1, 'adjustment_currency_code': 'USD', 'adjustment_amount': '1500.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '1395.20', }, { 'abacus_event_id': 1, 'account_id': 50, 'contract_id': 2, 'statement_period_id': 1, 'ledger_adjustment_id': 2, 'worksheet_adjustment_id': 2, 'adjustment_currency_code': 'GBP', 'adjustment_amount': '1500.00', 'adjustment_payee_currency_code': 'USD', 'adjustment_amount_payee_currency': '1631.35', }, ] @pytest.fixture def mock_ledger_adjustment_detail_applied_post_data(): """Mock ledger_adjustment_detail_applied data.""" return [ { 'ledger_adjustment_detail_id': 1, 'worksheet_adjustment_id': 1, 'worksheet_adjustment_detail_id': 1, 'adjustment_currency_code': 'USD', 'adjustment_amount': '1500.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '1395.20', }, { 'ledger_adjustment_detail_id': 2, 'worksheet_adjustment_id': 1, 'worksheet_adjustment_detail_id': 2, 'adjustment_currency_code': 'GBP', 'adjustment_amount': '1500.00', 'adjustment_payee_currency_code': 'USD', 'adjustment_amount_payee_currency': '1631.35', }, ] @pytest.fixture def mock_bulk_ledger_adjustment_with_details_applied_request_body(): """Mock body for POST ledger_adjustment_with_details_applied.""" return [ { 'abacus_event_id': 1, 'account_id': 1, 'contract_id': 1, 'statement_period_id': 1, 'ledger_adjustment_id': 1, 'worksheet_adjustment_id': 1, 'adjustment_currency_code': 'USD', 'adjustment_amount': '3000.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '3026.55', 'details': [ { 'ledger_adjustment_detail_id': 1, 'worksheet_adjustment_id': 1, 'worksheet_adjustment_detail_id': 1, 'adjustment_currency_code': 'USD', 'adjustment_amount': '1500.00', 'adjustment_payee_currency_code': 'GBP', 'adjustment_amount_payee_currency': '1395.20', }, { 'ledger_adjustment_detail_id': 2, 'worksheet_adjustment_id': 1, 'worksheet_adjustment_detail_id': 2, 'adjustment_currency_code': 'GBP', 'adjustment_amount': '1500.00', 'adjustment_payee_currency_code': 'USD', 'adjustment_amount_payee_currency': '1631.35', }, ], }, ] @pytest.fixture def mock_bulk_ledger_correction_request_body(): """Mock body for POST ledger_correction.""" return [ { 'abacus_event_id': 10, 'worksheet_correction_id': 1, 'account_id': 1, 'contract_id': 1, 'statement_period_id': 1, 'correction_statement_period_id': 2, 'correction_type': 'royalty_reversal', 'currency_code': 'USD', 'gross_revenue': -900.00, 'distribution_fee': 10.00, 'net_revenue': -890.00, }, { 'abacus_event_id': 10, 'worksheet_correction_id': 2, 'account_id': 50, 'contract_id': 2, 'statement_period_id': 1, 'correction_statement_period_id': 2, 'correction_type': 'royalty_reversal', 'currency_code': 'USD', 'gross_revenue': -671.10, 'mechanical_deduction_total': -56.11, 'mechanical_deduction_admin_fee_total': -10.09, 'distribution_fee': 0.00, 'net_revenue': -671.10, }, ] @pytest.fixture def mock_bulk_ledger_vat_summary_request_body(): """Mock body for POST ledger_vat_summary.""" return [ { 'account_id': 1, 'contract_id': 1, 'vat_category': 'closing_balance', 'payee_currency_code': 'USD', 'vat_currency_code': 'GBP', 'base_amount_payee_currency': '100.00', 'vat_rate': '20.00', 'vat_amount_payee_currency': '80.00', 'vat_amount_vat_currency': '63.71', 'wht_rate': '10.00', 'wht_amount_payee_currency': '70.00', 'wht_amount_vat_currency': '53.71', 'net_amount_payee_currency': '180.00', 'abacus_exempt_reason': None, 'description': 'Test VAT Summary 1', }, { 'activity_statement_period_id': 2, 'account_id': 2, 'contract_id': 2, 'vat_category': 'closing_balance', 'payee_currency_code': 'USD', 'vat_currency_code': 'GBP', 'base_amount_payee_currency': '1000.00', 'vat_rate': '50.00', 'vat_amount_payee_currency': '180.00', 'vat_amount_vat_currency': '133.71', 'net_amount_payee_currency': '280.00', 'abacus_exempt_reason': None, }, ]