From c80aaf565716623eacc54160d86b57163ec0b8a6 Mon Sep 17 00:00:00 2001 From: Anish Kr Singh <116036738+anishfyle@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:19:47 +0530 Subject: [PATCH] add bank_transaction_id in ALLOWED_FIELDS (#654) * add bank_transaction_id in ALLOWED_FIELDS * updated fixtures and test * updated fixtures * updated fixtures --- apps/fyle/models.py | 2 +- tests/test_fyle/fixtures.py | 38 +++++++++++++++++++--------------- tests/test_fyle/test_models.py | 6 +++--- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/apps/fyle/models.py b/apps/fyle/models.py index 5df40b60..818d3533 100644 --- a/apps/fyle/models.py +++ b/apps/fyle/models.py @@ -17,7 +17,7 @@ from apps.workspaces.models import Workspace, WorkspaceGeneralSettings from apps.workspaces.utils import round_amount -ALLOWED_FIELDS = ['employee_email', 'report_id', 'claim_number', 'settlement_id', 'fund_source', 'vendor', 'category', 'project', 'cost_center', 'verified_at', 'approved_at', 'spent_at', 'expense_id', 'posted_at'] +ALLOWED_FIELDS = ['employee_email', 'report_id', 'claim_number', 'settlement_id', 'fund_source', 'vendor', 'category', 'project', 'cost_center', 'verified_at', 'approved_at', 'spent_at', 'expense_id', 'posted_at', 'bank_transaction_id'] ALLOWED_FORM_INPUT = {'group_expenses_by': ['settlement_id', 'claim_number', 'report_id', 'category', 'vendor', 'expense_id'], 'export_date_type': ['current_date', 'approved_at', 'spent_at', 'verified_at', 'last_spent_at', 'posted_at']} diff --git a/tests/test_fyle/fixtures.py b/tests/test_fyle/fixtures.py index dc185d59..6721efaa 100644 --- a/tests/test_fyle/fixtures.py +++ b/tests/test_fyle/fixtures.py @@ -1144,11 +1144,12 @@ 'paid_on_qbo': False, 'created_at': '2024-06-18T19:12:17.003409+00:00', 'updated_at': '2024-06-18T19:12:17.003421+00:00', - 'bank_transaction_id': 'Arkham' + 'bank_transaction_id': 'Arkham', + 'fund_source': 'CCC' }, { 'id': '24004', - 'employee_email': 'admin21@fyleforbamboohr.com', + 'employee_email': 'admin11@fyleforbamboohr.com', 'employee_name': 'Theresa Brown', 'report_title': '#1: Aug 2024', 'category': 'Taxi', @@ -1171,15 +1172,15 @@ 'state': 'APPROVED', 'vendor': None, 'cost_center': 'F & A', - 'corporate_card_id': None, + 'corporate_card_id': 'baccOhXVSIlP7S', 'purpose': None, 'report_id': 'rp6lAwelLh54', 'file_ids': [], 'spent_at': '2024-06-05T00:00:00+00:00', 'posted_at': None, 'approved_at': '2024-06-05T12:35:28.453+00:00', - 'expense_created_at': '2024-06-05T12:34:41.770252+00:00', - 'expense_updated_at': '2024-06-10T11:45:09.305064+00:00', + 'expense_created_at': '2024-06-05T12:34:09.350864+00:00', + 'expense_updated_at': '2024-06-10T11:45:43.338229+00:00', 'source_account_type': 'PERSONAL_CORPORATE_CREDIT_CARD_ACCOUNT', 'verified_at': None, 'custom_properties': { @@ -1193,13 +1194,14 @@ 'previous_export_state': None, 'paid_on_fyle': False, 'paid_on_qbo': False, - 'created_at': '2024-06-18T19:12:17.020617+00:00', - 'updated_at': '2024-06-18T19:12:17.020627+00:00', - 'bank_transaction_id': 'Arkham' + 'created_at': '2024-06-18T19:12:17.003409+00:00', + 'updated_at': '2024-06-18T19:12:17.003421+00:00', + 'bank_transaction_id': 'Arkham', + 'fund_source': 'CCC' }, { 'id': '24008', - 'employee_email': 'admin1@fyleforbamboohr.com', + 'employee_email': 'admin11@fyleforbamboohr.com', 'employee_name': 'Theresa Brown', 'report_title': '#1: Jun 2024', 'category': 'Taxi', @@ -1243,11 +1245,12 @@ 'paid_on_qbo': False, 'created_at': '2024-06-18T19:12:17.003409+00:00', 'updated_at': '2024-06-18T19:12:17.003421+00:00', - 'bank_transaction_id': 'Anish' + 'bank_transaction_id': 'Anish', + 'fund_source': 'CCC' }, { 'id': '24009', - 'employee_email': 'admin1@fyleforbamboohr.com', + 'employee_email': 'admin11@fyleforbamboohr.com', 'employee_name': 'Theresa Brown', 'report_title': '#1: Jun 2024', 'category': 'Taxi', @@ -1270,15 +1273,15 @@ 'state': 'APPROVED', 'vendor': None, 'cost_center': 'F & A', - 'corporate_card_id': None, + 'corporate_card_id': 'baccOhXVSIlP7S', 'purpose': None, 'report_id': 'rp6lAwelLh54', 'file_ids': [], 'spent_at': '2024-06-05T00:00:00+00:00', 'posted_at': None, 'approved_at': '2024-06-05T12:35:28.453+00:00', - 'expense_created_at': '2024-06-05T12:34:41.770252+00:00', - 'expense_updated_at': '2024-06-10T11:45:09.305064+00:00', + 'expense_created_at': '2024-06-05T12:34:09.350864+00:00', + 'expense_updated_at': '2024-06-10T11:45:43.338229+00:00', 'source_account_type': 'PERSONAL_CORPORATE_CREDIT_CARD_ACCOUNT', 'verified_at': None, 'custom_properties': { @@ -1292,9 +1295,10 @@ 'previous_export_state': None, 'paid_on_fyle': False, 'paid_on_qbo': False, - 'created_at': '2024-06-18T19:12:17.020617+00:00', - 'updated_at': '2024-06-18T19:12:17.020627+00:00', - 'bank_transaction_id': 'Anish' + 'created_at': '2024-06-18T19:12:17.003409+00:00', + 'updated_at': '2024-06-18T19:12:17.003421+00:00', + 'bank_transaction_id': 'Anish', + 'fund_source': 'CCC' } ], 'expense_groups_complete_response': { diff --git a/tests/test_fyle/test_models.py b/tests/test_fyle/test_models.py index d5d6e2a4..617f8d9f 100644 --- a/tests/test_fyle/test_models.py +++ b/tests/test_fyle/test_models.py @@ -388,14 +388,14 @@ def test_split_expenses_diff_bank_transaction_id(db): expense_objects = Expense.create_expense_objects(expenses, 1) assert len(expense_objects) == 4 - expense_groups = _group_expenses(expense_objects, ['expense_id', 'fund_source', 'employee_email', 'spent_at'], 4) + expense_groups = _group_expenses(expense_objects, ['expense_id', 'fund_source', 'employee_email', 'spent_at', 'bank_transaction_id'], 4) assert len(expense_groups) == 4 expense_group_settings.split_expense_grouping = 'MULTIPLE_LINE_ITEM' expense_group_settings.save() - expense_groups = _group_expenses(expense_objects, ['expense_id', 'fund_source', 'employee_email', 'spent_at'], 4) - assert len(expense_groups) == 4 + expense_groups = _group_expenses(expense_objects, ['fund_source', 'employee_email', 'spent_at', 'bank_transaction_id'], 4) + assert len(expense_groups) == 2 def test_format_date():