"""Creates required DB fixtures.""" import mysql.connector def mysqlclient_docker(): """Initialize mysql client for docker image.""" return mysql.connector.connect( host='payoneer-payments-payout-mysql', port='3306', database='royalty_accounting', user='db_user', password='db_pass' ) cnx = mysqlclient_docker() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.statement_period ( statement_period_id, statement_period_name, statement_period_status ) VALUE ( 256, 'Test statement period', 'current' ); """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.account ( account_id, account_name, created_by, created_at, last_modified_by, last_modified ) VALUES ( 25153, 'TEST ACCOUNT_1', 1472, '2021-04-12 02:38:45.000000', 1472, '2021-04-12 02:38:45.000000' ), ( 25154, 'TEST ACCOUNT_2', 1472, '2021-04-12 02:38:45.000000', 1472, '2021-04-12 02:38:45.000000' ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.contract ( contract_id, reference_signing_entity_id, contract_name, contract_type, term_start, term_end, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1, 1, 'test_contract_1', 'distribution', '2022-06-06', '2022-06-09', 'vz', '2022-06-06 03:43:02', 'vz', '2022-06-06 03:43:05' ), ( 2, 1, 'test_contract_2', 'distribution', '2022-06-06', '2022-06-09', 'vz', '2022-06-06 03:43:02', 'vz', '2022-06-06 03:43:05' ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """INSERT INTO royalty_accounting.account_contract ( account_contract_id, account_id, contract_id ) VALUES ( 1, 25153, 1 ), ( 2, 25154, 2 ); """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.abacus_event ( abacus_event_id, event_name, target_type, target_id, event_date, previous_abacus_event_id, rolled_back_at ) VALUES ( 1067, 'send_payments', 'payment_group_payment', 1, '2021-04-12 02:38:45.000000', null, null ), ( 1068, 'send_payments', 'payment_group_payment', 2, '2021-04-12 02:38:45.000000', null, null ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.accounting_run ( accounting_run_id, accounting_period_id, run_controller_id, run_status, start_date, summary_export_url, created_by, created_at, last_modified_by, last_modified ) VALUES ( 1472, 21, 2687, 'Committing', NOW(), "s3://test-royalties-sales-files/accounting-period/accounting-run/fake.tsv", '2107', '2021-04-12 02:40:58', '1952', '2021-04-12 02:41:06' ) """ cursor.execute(query) cnx.commit() cursor = cnx.cursor() query = """ INSERT INTO royalty_accounting.accounting_period ( accounting_period_id, statement_period_id, accounting_period_name, accounting_period_status, contract_type, closed_date, created_by, created_at, last_modified_by, last_modified ) VALUES ( 21, 256, 'test', 'open', 'distribution', null, 'vz', '2022-02-16 05:35:39', 'vz', '2022-02-16 05:35:42' )""" cursor.execute(query) cnx.commit() cursor = cnx.cursor() payment_group_query = """ INSERT INTO payment_group ( payment_group_id, group_name, group_criteria, is_reusable, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by ) VALUES ( 1, 'test_payment_group_1', '{"account_id": 25153}', 0, '2020-08-28 07:11:39', 'test', '2020-08-28 07:11:42', 'test', null, null ), ( 2, 'test_payment_group_2', '{"reference_payment_entities": [3]}', 1, '2020-08-28 07:11:39', 'test', '2020-08-28 07:11:42', 'test', null, null )""" cursor.execute(payment_group_query) cnx.commit() cursor = cnx.cursor() payment_group_payment_query = """ INSERT INTO payment_group_payment ( payment_group_payment_id, payment_group_id, payment_name, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by ) VALUES ( 1, 1, 'payment_group_payment_1', '2020-08-28 07:26:44', 'test', '2020-08-28 07:26:49', 'test', null, null ), ( 2, 2, 'payment_group_paymen_2', '2020-08-28 07:26:44', 'test', '2020-08-28 07:26:49', 'test', null, null )""" cursor.execute(payment_group_payment_query) cnx.commit() cursor = cnx.cursor() payment_group_payment_account_query = """ INSERT INTO payment_group_payment_account ( payment_group_payment_account_id, current_statement_period_id, payoneer_program_id, payment_group_payment_id, prior_payment_group_payment_id, account_id, currency_code, last_payment, contracts_payable, current_balance, tax_withholding, balance_after_tax, note, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by ) VALUES ( 1, 256, 100176930, 1, null, 25153, 'USD', 100.00, '[{"contract_id": 1, "currency_code": "USD", "current_balance": "763.31"}]', 200.00, 0.00, 200.00, null, '2020-09-02 04:55:20', 'test', '2020-09-02 04:55:28', 'test', null, null ), ( 2, 256, 100176930, 2, null, 25154, 'USD', 100.00, '[{"contract_id": 2, "currency_code": "USD", "current_balance": "763.31"}]', 200.00, 0.00, 200.00, null, '2020-09-02 04:55:20', 'test', '2020-09-02 04:55:28', 'test', null, null )""" cursor.execute(payment_group_payment_account_query) cnx.commit() cursor = cnx.cursor() payment_group_payment_account_query = """ INSERT INTO royalty_accounting.account_payee ( account_id, payoneer_payee_id, payoneer_payee_name, payoneer_iframe_url, payoneer_iframe_url_date, payoneer_session_id, created_by, created_at, last_modified_by, last_modified ) VALUES ( 25153, 1, 'test', 'test', '2022-03-24', 'test', 'vz', '2022-03-24 07:27:26', 'vz', '2022-03-24 07:27:30' ), ( 25154, 2, 'test', 'test', '2022-03-24', 'test', 'vz', '2022-03-24 07:27:26', 'vz', '2022-03-24 07:27:30' )""" cursor.execute(payment_group_payment_account_query) cnx.commit() cnx.close() print('Fixtures were created.')