Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: masked card num employee name description #578

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/fyle/migrations/0035_expense_masked_corporate_card_number.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
anishfyle marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
anishfyle marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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'],
Expand Down
2 changes: 2 additions & 0 deletions apps/sage_intacct/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '',
Expand Down
14 changes: 8 additions & 6 deletions tests/sql_fixtures/reset_db_fixtures/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);


Expand Down Expand Up @@ -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
\.


Expand Down Expand Up @@ -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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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
anishfyle marked this conversation as resolved.
Show resolved Hide resolved
\.


Expand Down Expand Up @@ -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);


--
Expand Down
42 changes: 28 additions & 14 deletions tests/test_fyle/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down Expand Up @@ -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': [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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': [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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': [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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': [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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': [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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': {
Expand Down
3 changes: 2 additions & 1 deletion tests/test_workspaces/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': ['[email protected]'], 'workspace': 1, 'schedule': 9}
Expand Down
Loading