"""Combined adjustments by type tests.""" from decimal import Decimal from moneyhub.constants.constants import FLOWTHROUGH_ADJUSTMENT_TYPE_ID from moneyhub.models import AdjustmentsByType from tests.unit.conftest import using_mock_snowflake_table ACCOUNT_ID = 24601 _MOCK_DATA = { 'combined_adjustments_by_type_dbt': [ { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12345, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 1, 'reference_adjustment_type_id': 87, 'reference_adjustment_type_name': 'VAT Tax', 'ledger_adjustment_applied_id': 1, }, { 'account_id': 99999, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 11111, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 2, 'reference_adjustment_type_id': 87, 'reference_adjustment_type_name': 'VAT Tax', 'ledger_adjustment_applied_id': 2, }, { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('20.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12346, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 3, 'reference_adjustment_type_id': 9, 'reference_adjustment_type_name': 'Monthly Royalty Payment', 'ledger_adjustment_applied_id': 3, }, { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12345, 'statement_period_id': 124, 'ledger_adjustment_applied_id': 4, 'reference_adjustment_type_id': 9, 'reference_adjustment_type_name': 'Monthly Royalty Payment', 'ledger_adjustment_applied_id': 4, }, { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12347, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 5, 'reference_adjustment_type_id': FLOWTHROUGH_ADJUSTMENT_TYPE_ID, 'reference_adjustment_type_name': 'Flowthrough Adjustment', }, { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12345, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 6, 'reference_adjustment_type_id': FLOWTHROUGH_ADJUSTMENT_TYPE_ID, 'reference_adjustment_type_name': 'Flowthrough Adjustment', }, ], 'payment_allocation_ledger_adjustment': [ { 'payment_allocation_id': 1, 'ledger_adjustment_applied_id': 6, }, { 'payment_allocation_id': 1, 'ledger_adjustment_applied_id': 1, }, { 'payment_allocation_id': 1, 'ledger_adjustment_applied_id': 2, }, { 'payment_allocation_id': 1, 'ledger_adjustment_applied_id': 3, }, { 'payment_allocation_id': 1, 'ledger_adjustment_applied_id': 4, }, ], } @using_mock_snowflake_table(AdjustmentsByType, _MOCK_DATA) def test_get_by_account_id(): """Test getting revenue by account.""" results = AdjustmentsByType.get_by_account_id( ACCOUNT_ID, None, [123]) assert [item.to_dict() for item in results] == [ { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12347, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 5, 'reference_adjustment_type_id': FLOWTHROUGH_ADJUSTMENT_TYPE_ID, 'reference_adjustment_type_name': 'Flowthrough Adjustment', }, { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('20.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12346, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 3, 'reference_adjustment_type_id': 9, 'reference_adjustment_type_name': 'Monthly Royalty Payment', 'ledger_adjustment_applied_id': 3, }, { 'account_id': ACCOUNT_ID, 'adjustment_amount_payee_currency': Decimal('10.00'), 'adjustment_payee_currency_code': 'GBP', 'contract_id': 12345, 'statement_period_id': 123, 'ledger_adjustment_applied_id': 1, 'reference_adjustment_type_id': 87, 'reference_adjustment_type_name': 'VAT Tax', 'ledger_adjustment_applied_id': 1, }, ]