"""Creates required DB fixtures.""" import mysql.connector cnx = mysql.connector.connect( host='mysql', port='3306', database='royalty_accounting', user='royalties', password='1234', ) cursor = cnx.cursor() insert_accounts = """ INSERT INTO account ( account_id, account_name, created_by, created_at, last_modified_by, last_modified ) VALUES ( 63484, 'Turtle Girl Records LLC - AWAL', 'test', NOW(), 'test', NOW() ); """ cursor.execute(insert_accounts) cnx.commit() insert_contracts = """ INSERT INTO contract ( contract_id, reference_signing_entity_id, reference_sap_profit_center_id, contract_name, term_start, term_end, created_by, created_at, last_modified_by, last_modified ) VALUES ( 531051, 4, 4, 'AGR667890 - AWAL Recordings Agreement - mxmtoon (Life is Strange EP)', '2021-05-06', '2021-05-27', 'test', NOW(), 'test', NOW() ); """ cursor.execute(insert_contracts) cnx.commit() insert_account_contracts = """ INSERT INTO account_contract( account_contract_id, account_id, contract_id ) VALUES ( 1, 63484, 531051 ); """ cursor.execute(insert_account_contracts) cnx.commit() insert_account_payment_terms = """ 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, 63484, 'GBP', 42.00, 1, null, 'test', NOW(), 'test', NOW() ); """ cursor.execute(insert_account_payment_terms) cnx.commit() cursor = cnx.cursor() abacus_event_query = """ INSERT INTO abacus_event ( abacus_event_id, statement_period_id, event_name, target_type, target_id, event_date, previous_abacus_event_id, rolled_back_at ) VALUES ( 1, 282, 'generate_flowthrough_adjustments', 'statement_period_adjustment_file', 1, '2021-04-12 02:38:45.000000', null, null ) """ cursor.execute(abacus_event_query) cnx.commit() cursor = cnx.cursor() statement_period_adjustment_file_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, 282, 'test adjustment', 's3://qa-abacus-adjustments/test_fixtures/test-adjustment.json.gz', null, null, null, null, null, null, null, 'integration_tests', '2023-11-02 10:53:29', 'integration_tests', '2023-11-02 10:53:34' ), ( 2, 282, 'test-adjustment-invalid-validation', 's3://qa-abacus-adjustments/test_fixtures/test-adjustment-invalid-validation.json.gz', null, null, null, null, null, null, null, 'integration_tests', '2023-11-02 10:53:29', 'integration_tests', '2023-11-02 10:53:34' ) """ cursor.execute(statement_period_adjustment_file_query) cnx.commit() insert_statement_period_adjustment_batch_criteria = """ INSERT INTO statement_period_adjustment_batch_criteria ( statement_period_adjustment_batch_criteria_id, batch_criteria, statement_period_adjustment_file_id, created_by, last_modified_by ) VALUES ( 1, '{"payment_schedules": ["45_days_after_month_end"], "reference_payment_entities": [2]}', 1, 'integration_tests', 'integration_tests' ); """ cursor.execute(insert_statement_period_adjustment_batch_criteria) cnx.commit() cursor = cnx.cursor() update_statement_period_to_current_query = """ UPDATE statement_period t SET t.statement_period_status = 'current' WHERE t.statement_period_id = 282 """ cursor.execute(update_statement_period_to_current_query) cnx.commit() cnx.close() print('Fixtures were created.')