"""Unit testcases for AdjustmentFileProcessor.""" from decimal import Decimal import numpy as np from adjustment_file_import.expense_details_processor \ import ExpenseDetailsProcessor def test_formatted_worksheet_adjustment( mock_worksheet_adjustment_details ): """Test _formatted_worksheet_adjustment method. when adjustment details are group by column apply_to_flowthrough_payment. """ mock_abacus_event_id = 1 mock_statement_period_adjustment_file_id = 1 mock_expense_details_processor = ExpenseDetailsProcessor( mock_abacus_event_id, mock_statement_period_adjustment_file_id, mock_worksheet_adjustment_details ) result = mock_expense_details_processor._formatted_worksheet_adjustment( mock_worksheet_adjustment_details[0] ) assert result == { 'statement_period_adjustment_file_id': mock_statement_period_adjustment_file_id, # noqa: E501 'abacus_event_id': mock_abacus_event_id, 'account_id': mock_worksheet_adjustment_details[0]['account_id'], 'contract_id': mock_worksheet_adjustment_details[0]['contract_id'], 'activity_statement_period_id': 301, 'apply_to_statement_period_id': 302, 'reference_adjustment_type_id': 65, 'adjustment_amount': mock_worksheet_adjustment_details[0]['amount'], 'adjustment_currency_code': mock_worksheet_adjustment_details[0]['currency_code'], # noqa: E501 'note': None, 'internal_note': None, 'apply_to_flowthrough_payment': 1 } def test_process( mock_worksheet_adjustment_details, mock_expense_details_entries ): """Test process method.""" mock_abacus_event_id = 1 mock_statement_period_adjustment_file_id = 1 mock_expense_details_processor = ExpenseDetailsProcessor( mock_abacus_event_id, mock_statement_period_adjustment_file_id, mock_worksheet_adjustment_details ) mock_expense_details_processor.process() assert mock_expense_details_processor.expense_detail_entries == [{ 'worksheet_adjustment': { 'statement_period_adjustment_file_id': 1, 'abacus_event_id': 1, 'account_id': '1234', 'contract_id': '1234', 'activity_statement_period_id': np.int64(301), 'apply_to_statement_period_id': np.int64(302), 'reference_adjustment_type_id': 65, 'adjustment_amount': Decimal('1807.5560'), 'adjustment_currency_code': 'USD', 'note': None, 'internal_note': None, 'apply_to_flowthrough_payment': 1 }, 'worksheet_adjustment_detail': [{ 'statement_period_adjustment_file_id': 1, 'account_id': '1234', 'contract_id': '1234', 'activity_statement_period_id': 301, 'apply_to_statement_period_id': 302, 'reference_adjustment_type_id': 1, 'amount': Decimal('-90.122'), 'currency_code': 'USD', 'upc': '1234567890', 'distribution_type': 'digital', 'note': None, 'internal_note': None, 'apply_to_flowthrough_payment': True }, { 'statement_period_adjustment_file_id': 1, 'account_id': '1234', 'contract_id': '1234', 'activity_statement_period_id': 301, 'apply_to_statement_period_id': 302, 'reference_adjustment_type_id': 1, 'amount': Decimal('1897.678'), 'currency_code': 'USD', 'upc': '196925277303', 'distribution_type': 'digital', 'note': None, 'internal_note': None, 'apply_to_flowthrough_payment': 1 }] }]