diff --git a/apps/fyle/migrations/0035_expense_masked_corporate_card_number.py b/apps/fyle/migrations/0035_expense_masked_corporate_card_number.py new file mode 100644 index 00000000..201ba802 --- /dev/null +++ b/apps/fyle/migrations/0035_expense_masked_corporate_card_number.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.14 on 2024-11-20 02:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fyle', '0034_expense_is_posted_at_null'), + ] + + operations = [ + migrations.AddField( + model_name='expense', + name='masked_corporate_card_number', + field=models.CharField(help_text='Masked Corporate Card Number', max_length=255, null=True), + ), + ] diff --git a/apps/fyle/models.py b/apps/fyle/models.py index 7bfabdc9..d388fc8e 100644 --- a/apps/fyle/models.py +++ b/apps/fyle/models.py @@ -144,6 +144,7 @@ class Expense(models.Model): is_skipped = models.BooleanField(null=True, default=False, help_text='Expense is skipped or not') report_title = models.TextField(null=True, blank=True, help_text='Report title') accounting_export_summary = JSONField(default=dict) + masked_corporate_card_number = models.CharField(max_length=255, help_text='Masked Corporate Card Number', null=True) previous_export_state = models.CharField(max_length=255, help_text='Previous export state', null=True) workspace = models.ForeignKey( Workspace, on_delete=models.PROTECT, help_text='To which workspace this expense belongs to', null=True @@ -200,6 +201,7 @@ def create_expense_objects(expenses: List[Dict], workspace_id: int, skip_update: 'spent_at': expense['spent_at'], 'posted_at': expense['posted_at'], 'is_posted_at_null': expense['is_posted_at_null'], + 'masked_corporate_card_number': expense['masked_corporate_card_number'], 'fund_source': SOURCE_ACCOUNT_MAP[expense['source_account_type']], 'verified_at': expense['verified_at'], 'custom_properties': expense['custom_properties'], diff --git a/apps/sage_intacct/models.py b/apps/sage_intacct/models.py index 75d9a188..bf5e1b2a 100644 --- a/apps/sage_intacct/models.py +++ b/apps/sage_intacct/models.py @@ -450,6 +450,8 @@ def get_expense_purpose(workspace_id, lineitem: Expense, category: str, configur details = { 'employee_email': lineitem.employee_email, + 'employee_name': lineitem.employee_name, + 'card_number': '{0}'.format(lineitem.masked_corporate_card_number) if lineitem.masked_corporate_card_number else '', 'merchant': '{0}'.format(lineitem.vendor) if lineitem.vendor else '', 'category': '{0}'.format(category) if lineitem.category else '', 'purpose': '{0}'.format(lineitem.purpose) if lineitem.purpose else '', diff --git a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql index 4d7a7bbb..c10ccb50 100644 --- a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql +++ b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql @@ -1165,7 +1165,8 @@ CREATE TABLE public.expenses ( workspace_id integer, paid_on_fyle boolean NOT NULL, bank_transaction_id character varying(255), - is_posted_at_null boolean NOT NULL + is_posted_at_null boolean NOT NULL, + masked_corporate_card_number character varying(255) ); @@ -4135,6 +4136,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; 197 sage_intacct 0030_auto_20241112_0425 2024-11-18 04:59:52.138056+00 198 tasks 0010_alter_tasklog_expense_group 2024-11-18 04:59:52.206781+00 199 workspaces 0039_alter_configuration_change_accounting_period 2024-11-18 05:05:10.975057+00 +200 fyle 0035_expense_masked_corporate_card_number 2024-11-20 02:49:32.481921+00 \. @@ -7571,10 +7573,10 @@ COPY public.expense_reports (id, employee_id, description, supdoc_id, created_at -- Data for Name: expenses; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.expenses (id, employee_email, category, sub_category, project, expense_id, expense_number, claim_number, amount, currency, foreign_amount, foreign_currency, settlement_id, reimbursable, state, vendor, cost_center, purpose, report_id, spent_at, approved_at, expense_created_at, expense_updated_at, created_at, updated_at, fund_source, custom_properties, verified_at, billable, paid_on_sage_intacct, org_id, tax_amount, tax_group_id, file_ids, payment_number, corporate_card_id, is_skipped, report_title, posted_at, employee_name, accounting_export_summary, previous_export_state, workspace_id, paid_on_fyle, bank_transaction_id, is_posted_at_null) FROM stdin; -1 ashwin.t@fyle.in Food \N Aaron Abbott txR9dyrqr1Jn E/2022/09/T/21 C/2022/09/R/21 21 USD \N \N setqwcKcC9q1k t PAYMENT_PROCESSING Ashwin Marketing \N rpEZGqVCyWxQ 2022-09-20 17:00:00+00 2022-09-19 19:54:36.96+00 2022-09-19 19:54:15.870239+00 2022-09-19 19:55:58.641995+00 2022-09-20 08:48:21.737374+00 2022-09-20 08:48:21.737392+00 PERSONAL {"Team": "", "Class": "", "Klass": "", "Location": "", "Team Copy": "", "Tax Groups": "", "Departments": "", "Team 2 Postman": "", "User Dimension": "", "Location Entity": "", "Operating System": "", "System Operating": "", "User Dimension Copy": "", "Custom Expense Field": null} \N \N f or79Cob97KSh \N \N {} P/2022/09/R/18 \N f \N \N \N {} \N \N f \N f -2 ashwin.t@fyle.in Food \N Aaron Abbott txCqLqsEnAjf E/2022/09/T/22 C/2022/09/R/22 11 USD \N \N setzhjuqQ6Pl5 f PAYMENT_PROCESSING Ashwin Marketing \N rpSTYO8AfUVA 2022-09-20 17:00:00+00 2022-09-20 08:50:48.428+00 2022-09-20 08:50:27.570399+00 2022-09-20 08:51:13.891379+00 2022-09-20 08:51:27.566571+00 2022-09-20 08:51:27.566598+00 CCC {"Team": "", "Class": "", "Klass": "", "Location": "", "Team Copy": "", "Tax Groups": "", "Departments": "", "Team 2 Postman": "", "User Dimension": "", "Location Entity": "", "Operating System": "", "System Operating": "", "User Dimension Copy": "", "Custom Expense Field": null} \N t f or79Cob97KSh 2.41 tggu76WXIdjY {} P/2022/09/R/19 \N f \N \N \N {} \N \N f \N f -3 ashwin.t@fyle.in Taxi \N Aaron Abbott txTHfEPWOEOp E/2022/09/T/23 C/2022/09/R/23 22 USD \N \N set0SnAq66Zbq f PAYMENT_PROCESSING Ashwin Marketing \N rpBf5ibqUT6B 2022-09-20 17:00:00+00 2022-09-20 08:56:09.337+00 2022-09-20 08:55:53.246893+00 2022-09-20 08:56:40.795304+00 2022-09-20 08:56:50.117313+00 2022-09-20 08:56:50.117349+00 CCC {"Team": "", "Class": "", "Klass": "", "Location": "", "Team Copy": "", "Tax Groups": "", "Departments": "", "Team 2 Postman": "", "User Dimension": "", "Location Entity": "", "Operating System": "", "System Operating": "", "User Dimension Copy": "", "Custom Expense Field": null} \N \N f or79Cob97KSh 4.81 tggu76WXIdjY {} P/2022/09/R/20 \N f \N \N \N {} \N \N f \N f +COPY public.expenses (id, employee_email, category, sub_category, project, expense_id, expense_number, claim_number, amount, currency, foreign_amount, foreign_currency, settlement_id, reimbursable, state, vendor, cost_center, purpose, report_id, spent_at, approved_at, expense_created_at, expense_updated_at, created_at, updated_at, fund_source, custom_properties, verified_at, billable, paid_on_sage_intacct, org_id, tax_amount, tax_group_id, file_ids, payment_number, corporate_card_id, is_skipped, report_title, posted_at, employee_name, accounting_export_summary, previous_export_state, workspace_id, paid_on_fyle, bank_transaction_id, is_posted_at_null, masked_corporate_card_number) FROM stdin; +1 ashwin.t@fyle.in Food \N Aaron Abbott txR9dyrqr1Jn E/2022/09/T/21 C/2022/09/R/21 21 USD \N \N setqwcKcC9q1k t PAYMENT_PROCESSING Ashwin Marketing \N rpEZGqVCyWxQ 2022-09-20 17:00:00+00 2022-09-19 19:54:36.96+00 2022-09-19 19:54:15.870239+00 2022-09-19 19:55:58.641995+00 2022-09-20 08:48:21.737374+00 2022-09-20 08:48:21.737392+00 PERSONAL {"Team": "", "Class": "", "Klass": "", "Location": "", "Team Copy": "", "Tax Groups": "", "Departments": "", "Team 2 Postman": "", "User Dimension": "", "Location Entity": "", "Operating System": "", "System Operating": "", "User Dimension Copy": "", "Custom Expense Field": null} \N \N f or79Cob97KSh \N \N {} P/2022/09/R/18 \N f \N \N \N {} \N \N f \N f \N +2 ashwin.t@fyle.in Food \N Aaron Abbott txCqLqsEnAjf E/2022/09/T/22 C/2022/09/R/22 11 USD \N \N setzhjuqQ6Pl5 f PAYMENT_PROCESSING Ashwin Marketing \N rpSTYO8AfUVA 2022-09-20 17:00:00+00 2022-09-20 08:50:48.428+00 2022-09-20 08:50:27.570399+00 2022-09-20 08:51:13.891379+00 2022-09-20 08:51:27.566571+00 2022-09-20 08:51:27.566598+00 CCC {"Team": "", "Class": "", "Klass": "", "Location": "", "Team Copy": "", "Tax Groups": "", "Departments": "", "Team 2 Postman": "", "User Dimension": "", "Location Entity": "", "Operating System": "", "System Operating": "", "User Dimension Copy": "", "Custom Expense Field": null} \N t f or79Cob97KSh 2.41 tggu76WXIdjY {} P/2022/09/R/19 \N f \N \N \N {} \N \N f \N f \N +3 ashwin.t@fyle.in Taxi \N Aaron Abbott txTHfEPWOEOp E/2022/09/T/23 C/2022/09/R/23 22 USD \N \N set0SnAq66Zbq f PAYMENT_PROCESSING Ashwin Marketing \N rpBf5ibqUT6B 2022-09-20 17:00:00+00 2022-09-20 08:56:09.337+00 2022-09-20 08:55:53.246893+00 2022-09-20 08:56:40.795304+00 2022-09-20 08:56:50.117313+00 2022-09-20 08:56:50.117349+00 CCC {"Team": "", "Class": "", "Klass": "", "Location": "", "Team Copy": "", "Tax Groups": "", "Departments": "", "Team 2 Postman": "", "User Dimension": "", "Location Entity": "", "Operating System": "", "System Operating": "", "User Dimension Copy": "", "Custom Expense Field": null} \N \N f or79Cob97KSh 4.81 tggu76WXIdjY {} P/2022/09/R/20 \N f \N \N \N {} \N \N f \N f \N \. @@ -8142,7 +8144,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 50, true); -- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres -- -SELECT pg_catalog.setval('public.django_migrations_id_seq', 199, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 200, true); -- diff --git a/tests/test_fyle/fixtures.py b/tests/test_fyle/fixtures.py index 532b207c..6b578c32 100644 --- a/tests/test_fyle/fixtures.py +++ b/tests/test_fyle/fixtures.py @@ -290,7 +290,8 @@ 'Vehicle Type': '', 'Fyle Categories': '', }, - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, ], 'eliminated_expenses': [ @@ -336,7 +337,8 @@ 'Vehicle Type': '', 'Fyle Categories': '', }, - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' } ], 'positive_expenses': [ @@ -382,7 +384,8 @@ 'Vehicle Type': '', 'Fyle Categories': '', }, - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': 'tx4ziVSAyIsy', @@ -426,7 +429,8 @@ 'Vehicle Type': '', 'Fyle Categories': '', }, - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, ], 'negative_expenses': [ @@ -472,7 +476,8 @@ 'Vehicle Type': '', 'Fyle Categories': '', }, - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': 'tx4ziVSAyIsy', @@ -516,7 +521,8 @@ 'Vehicle Type': '', 'Fyle Categories': '', }, - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, ], 'ccc_expenses_split_no_bank_transaction_id': [ @@ -567,7 +573,8 @@ 'paid_on_qbo': False, 'created_at': '2024-06-18T19:12:17.003409+00:00', 'updated_at': '2024-06-18T19:12:17.003421+00:00', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': '24009', @@ -619,7 +626,8 @@ 'paid_on_qbo': False, 'created_at': '2024-06-18T19:12:17.020617+00:00', 'updated_at': '2024-06-18T19:12:17.020627+00:00', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' } ], 'ccc_expenses_split_same_bank_transaction_id': [ @@ -670,7 +678,8 @@ 'created_at': '2024-06-18T19:12:17.003409+00:00', 'updated_at': '2024-06-18T19:12:17.003421+00:00', 'bank_transaction_id': 'anish', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': '24009', @@ -722,7 +731,8 @@ 'created_at': '2024-06-18T19:12:17.020617+00:00', 'updated_at': '2024-06-18T19:12:17.020627+00:00', 'bank_transaction_id': 'anish', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' } ], 'ccc_expenses_split_diff_bank_transaction_id': [ @@ -774,7 +784,8 @@ 'updated_at': '2024-06-18T19:12:17.003421+00:00', 'bank_transaction_id': 'Arkham', 'fund_source': 'CCC', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': '24004', @@ -827,7 +838,8 @@ 'updated_at': '2024-06-18T19:12:17.003421+00:00', 'bank_transaction_id': 'Arkham', 'fund_source': 'CCC', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': '24008', @@ -877,7 +889,8 @@ 'updated_at': '2024-06-18T19:12:17.003421+00:00', 'bank_transaction_id': 'Anish', 'fund_source': 'CCC', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' }, { 'id': '24009', @@ -930,7 +943,8 @@ 'updated_at': '2024-06-18T19:12:17.003421+00:00', 'bank_transaction_id': 'Anish', 'fund_source': 'CCC', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' } ], 'expense_group_id': { diff --git a/tests/test_workspaces/fixtures.py b/tests/test_workspaces/fixtures.py index 82ef2129..544292bb 100644 --- a/tests/test_workspaces/fixtures.py +++ b/tests/test_workspaces/fixtures.py @@ -62,7 +62,8 @@ }, 'paid_on_qbo':False, 'payment_number':'P/2022/05/R/7', - 'is_posted_at_null': True + 'is_posted_at_null': True, + 'masked_corporate_card_number': '**** 4567' } ], 'workspace_schedule': {'id': 1, 'enabled': True, 'start_datetime': '2022-09-26T13:08:16.281604Z', 'interval_hours': 1, 'error_count': None, 'additional_email_options': [], 'emails_selected': ['ashwin.t@fyle.in'], 'workspace': 1, 'schedule': 9}