diff --git a/apps/fyle/migrations/0041_auto_20241226_1155.py b/apps/fyle/migrations/0041_auto_20241226_1155.py new file mode 100644 index 000000000..e7bc3b2ef --- /dev/null +++ b/apps/fyle/migrations/0041_auto_20241226_1155.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2024-12-26 11:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fyle', '0040_expense_masked_corporate_card_number'), + ] + + operations = [ + migrations.AddField( + model_name='expensegroupsettings', + name='created_by', + field=models.CharField(blank=True, help_text='Email of the user who created this record', max_length=255, null=True), + ), + migrations.AddField( + model_name='expensegroupsettings', + name='updated_by', + field=models.CharField(blank=True, help_text='Email of the user who last updated this record', max_length=255, null=True), + ), + ] diff --git a/apps/fyle/models.py b/apps/fyle/models.py index be895b820..d9f15c705 100644 --- a/apps/fyle/models.py +++ b/apps/fyle/models.py @@ -13,6 +13,7 @@ from django.db import models from django.db.models import Count, JSONField from fyle_accounting_mappings.models import ExpenseAttribute +from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin from apps.workspaces.models import Workspace, WorkspaceGeneralSettings from apps.workspaces.utils import round_amount @@ -202,7 +203,7 @@ def get_default_expense_state(): return 'PAYMENT_PROCESSING' -class ExpenseGroupSettings(models.Model): +class ExpenseGroupSettings(AutoAddCreateUpdateInfoMixin, models.Model): """ ExpenseGroupCustomizationSettings """ @@ -226,7 +227,7 @@ class Meta: db_table = 'expense_group_settings' @staticmethod - def update_expense_group_settings(expense_group_settings: Dict, workspace_id: int): + def update_expense_group_settings(expense_group_settings: Dict, workspace_id: int, user): settings = ExpenseGroupSettings.objects.get(workspace_id=workspace_id) current_reimbursable_settings = list(settings.reimbursable_expense_group_fields) current_ccc_settings = list(settings.corporate_credit_card_expense_group_fields) @@ -302,6 +303,7 @@ def update_expense_group_settings(expense_group_settings: Dict, workspace_id: in 'import_card_credits': import_card_credits, 'split_expense_grouping': expense_group_settings['split_expense_grouping'] }, + user=user ) diff --git a/apps/fyle/views.py b/apps/fyle/views.py index eff524e5e..73e02b71f 100644 --- a/apps/fyle/views.py +++ b/apps/fyle/views.py @@ -83,7 +83,7 @@ def get(self, request, *args, **kwargs): return Response(data=self.serializer_class(expense_group_settings).data, status=status.HTTP_200_OK) def post(self, request, *args, **kwargs): - expense_group_settings, _ = ExpenseGroupSettings.update_expense_group_settings(request.data, self.kwargs['workspace_id']) + expense_group_settings, _ = ExpenseGroupSettings.update_expense_group_settings(request.data, self.kwargs['workspace_id'], request.user) return Response(data=self.serializer_class(expense_group_settings).data, status=status.HTTP_200_OK) diff --git a/apps/mappings/migrations/0011_auto_20241226_1155.py b/apps/mappings/migrations/0011_auto_20241226_1155.py new file mode 100644 index 000000000..d2f55456d --- /dev/null +++ b/apps/mappings/migrations/0011_auto_20241226_1155.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2024-12-26 11:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mappings', '0010_auto_20220323_0914'), + ] + + operations = [ + migrations.AddField( + model_name='generalmapping', + name='created_by', + field=models.CharField(blank=True, help_text='Email of the user who created this record', max_length=255, null=True), + ), + migrations.AddField( + model_name='generalmapping', + name='updated_by', + field=models.CharField(blank=True, help_text='Email of the user who last updated this record', max_length=255, null=True), + ), + ] diff --git a/apps/mappings/models.py b/apps/mappings/models.py index fceaae162..eb7f08110 100644 --- a/apps/mappings/models.py +++ b/apps/mappings/models.py @@ -4,9 +4,10 @@ from django.db import models from apps.workspaces.models import Workspace +from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin -class GeneralMapping(models.Model): +class GeneralMapping(AutoAddCreateUpdateInfoMixin, models.Model): """ General Mappings """ diff --git a/apps/workspaces/apis/advanced_configurations/serializers.py b/apps/workspaces/apis/advanced_configurations/serializers.py index 37db3cce0..114a34035 100644 --- a/apps/workspaces/apis/advanced_configurations/serializers.py +++ b/apps/workspaces/apis/advanced_configurations/serializers.py @@ -66,6 +66,9 @@ def get_workspace_id(self, instance): return instance.id def update(self, instance, validated): + request = self.context.get('request') + user = request.user if request and hasattr(request, 'user') else None + workspace_general_settings = validated.pop('workspace_general_settings') general_mappings = validated.pop('general_mappings') workspace_schedules = validated.pop('workspace_schedules') @@ -81,9 +84,10 @@ def update(self, instance, validated): 'change_accounting_period': workspace_general_settings.get('change_accounting_period'), 'memo_structure': workspace_general_settings.get('memo_structure'), }, + user=user ) - GeneralMapping.objects.update_or_create(workspace=instance, defaults={'bill_payment_account_name': general_mappings.get('bill_payment_account').get('name'), 'bill_payment_account_id': general_mappings.get('bill_payment_account').get('id')}) + GeneralMapping.objects.update_or_create(workspace=instance, defaults={'bill_payment_account_name': general_mappings.get('bill_payment_account').get('name'), 'bill_payment_account_id': general_mappings.get('bill_payment_account').get('id')}, user=user) schedule_sync( workspace_id=instance.id, diff --git a/apps/workspaces/apis/advanced_configurations/views.py b/apps/workspaces/apis/advanced_configurations/views.py index 856eb0172..1f99ad8ba 100644 --- a/apps/workspaces/apis/advanced_configurations/views.py +++ b/apps/workspaces/apis/advanced_configurations/views.py @@ -9,3 +9,12 @@ class AdvancedConfigurationsView(generics.RetrieveUpdateAPIView): def get_object(self): return Workspace.objects.filter(id=self.kwargs['workspace_id']).first() + + def get_serializer_context(self): + """ + Override to include the request in the serializer context. + This allows serializers to access the current user. + """ + context = super().get_serializer_context() + context['request'] = self.request + return context diff --git a/apps/workspaces/apis/export_settings/serializers.py b/apps/workspaces/apis/export_settings/serializers.py index 362ff8071..206fdc312 100644 --- a/apps/workspaces/apis/export_settings/serializers.py +++ b/apps/workspaces/apis/export_settings/serializers.py @@ -93,6 +93,9 @@ def get_workspace_id(self, instance): return instance.id def update(self, instance, validated): + request = self.context.get('request') + user = request.user if request and hasattr(request, 'user') else None + workspace_general_settings = validated.pop('workspace_general_settings') expense_group_settings = validated.pop('expense_group_settings') general_mappings = validated.pop('general_mappings') @@ -121,6 +124,7 @@ def update(self, instance, validated): 'map_fyle_cards_qbo_account': enable_cards_mapping, 'name_in_journal_entry': workspace_general_settings.get('name_in_journal_entry'), }, + user=user ) export_trigger = ExportSettingsTrigger(workspace_general_settings, instance.id) @@ -128,7 +132,7 @@ def update(self, instance, validated): export_trigger.post_save_workspace_general_settings() if enable_cards_mapping: - MappingSetting.objects.update_or_create(destination_field='CREDIT_CARD_ACCOUNT', workspace_id=instance.id, defaults={'source_field': 'CORPORATE_CARD', 'import_to_fyle': False, 'is_custom': False}) + MappingSetting.objects.update_or_create(destination_field='CREDIT_CARD_ACCOUNT', workspace_id=instance.id, defaults={'source_field': 'CORPORATE_CARD', 'import_to_fyle': False, 'is_custom': False}, user=user) if not expense_group_settings['reimbursable_expense_group_fields']: expense_group_settings['reimbursable_expense_group_fields'] = ['employee_email', 'report_id', 'fund_source'] @@ -151,7 +155,7 @@ def update(self, instance, validated): ): expense_group_settings['import_card_credits'] = True - ExpenseGroupSettings.update_expense_group_settings(expense_group_settings, instance.id) + ExpenseGroupSettings.update_expense_group_settings(expense_group_settings, instance.id, user) GeneralMapping.objects.update_or_create( workspace=instance, @@ -169,6 +173,7 @@ def update(self, instance, validated): 'default_ccc_vendor_name': general_mappings.get('default_ccc_vendor').get('name'), 'default_ccc_vendor_id': general_mappings.get('default_ccc_vendor').get('id'), }, + user=user ) if instance.onboarding_state == 'EXPORT_SETTINGS': diff --git a/apps/workspaces/apis/export_settings/views.py b/apps/workspaces/apis/export_settings/views.py index 9e70e1609..7ece094a6 100644 --- a/apps/workspaces/apis/export_settings/views.py +++ b/apps/workspaces/apis/export_settings/views.py @@ -9,3 +9,12 @@ class ExportSettingsView(generics.RetrieveUpdateAPIView): def get_object(self): return Workspace.objects.filter(id=self.kwargs['workspace_id']).first() + + def get_serializer_context(self): + """ + Override to include the request in the serializer context. + This allows serializers to access the current user. + """ + context = super().get_serializer_context() + context['request'] = self.request + return context diff --git a/apps/workspaces/apis/import_settings/serializers.py b/apps/workspaces/apis/import_settings/serializers.py index 2e4bea528..33d742ae0 100644 --- a/apps/workspaces/apis/import_settings/serializers.py +++ b/apps/workspaces/apis/import_settings/serializers.py @@ -78,6 +78,9 @@ def get_workspace_id(self, instance): return instance.id def update(self, instance, validated): + request = self.context.get('request') + user = request.user if request and hasattr(request, 'user') else None + workspace_general_settings = validated.pop('workspace_general_settings') general_mappings = validated.pop('general_mappings') mapping_settings = validated.pop('mapping_settings') @@ -104,9 +107,10 @@ def update(self, instance, validated): 'import_vendors_as_merchants': workspace_general_settings.get('import_vendors_as_merchants'), 'import_code_fields': workspace_general_settings.get('import_code_fields'), }, + user=user ) - GeneralMapping.objects.update_or_create(workspace=instance, defaults={'default_tax_code_name': general_mappings.get('default_tax_code').get('name'), 'default_tax_code_id': general_mappings.get('default_tax_code').get('id')}) + GeneralMapping.objects.update_or_create(workspace=instance, defaults={'default_tax_code_name': general_mappings.get('default_tax_code').get('name'), 'default_tax_code_id': general_mappings.get('default_tax_code').get('id')}, user=user) trigger: ImportSettingsTrigger = ImportSettingsTrigger(workspace_general_settings=workspace_general_settings, mapping_settings=mapping_settings, workspace_id=instance.id) @@ -129,6 +133,7 @@ def update(self, instance, validated): 'is_custom': setting['is_custom'] if 'is_custom' in setting else False, 'source_placeholder': setting['source_placeholder'] if 'source_placeholder' in setting else None, }, + user=user ) trigger.post_save_mapping_settings(workspace_general_settings_instance) diff --git a/apps/workspaces/apis/import_settings/views.py b/apps/workspaces/apis/import_settings/views.py index 2843eeb33..8175a7644 100644 --- a/apps/workspaces/apis/import_settings/views.py +++ b/apps/workspaces/apis/import_settings/views.py @@ -11,6 +11,15 @@ class ImportSettingsView(generics.RetrieveUpdateAPIView): def get_object(self): return Workspace.objects.filter(id=self.kwargs['workspace_id']).first() + def get_serializer_context(self): + """ + Override to include the request in the serializer context. + This allows serializers to access the current user. + """ + context = super().get_serializer_context() + context['request'] = self.request + return context + class ImportCodeFieldView(generics.GenericAPIView): """ diff --git a/apps/workspaces/apis/map_employees/serializers.py b/apps/workspaces/apis/map_employees/serializers.py index b06c607c2..69bf4135d 100644 --- a/apps/workspaces/apis/map_employees/serializers.py +++ b/apps/workspaces/apis/map_employees/serializers.py @@ -23,6 +23,9 @@ def get_workspace_id(self, instance): return instance.id def update(self, instance, validated_data): + request = self.context.get('request') + user = request.user if request and hasattr(request, 'user') else None + workspace_id = instance.id workspace_general_settings = validated_data.pop('workspace_general_settings') @@ -33,7 +36,8 @@ def update(self, instance, validated_data): defaults={ 'employee_field_mapping': workspace_general_settings['employee_field_mapping'], 'auto_map_employees': workspace_general_settings['auto_map_employees'] - } + }, + user=user ) MapEmployeesTriggers.run_workspace_general_settings_triggers(workspace_general_settings_instance) diff --git a/apps/workspaces/apis/map_employees/views.py b/apps/workspaces/apis/map_employees/views.py index b340448a8..40ab8de5b 100644 --- a/apps/workspaces/apis/map_employees/views.py +++ b/apps/workspaces/apis/map_employees/views.py @@ -9,3 +9,12 @@ class MapEmployeesView(generics.RetrieveUpdateAPIView): def get_object(self): return Workspace.objects.filter(id=self.kwargs['workspace_id']).first() + + def get_serializer_context(self): + """ + Override to include the request in the serializer context. + This allows serializers to access the current user. + """ + context = super().get_serializer_context() + context['request'] = self.request + return context diff --git a/apps/workspaces/migrations/0050_auto_20241226_1155.py b/apps/workspaces/migrations/0050_auto_20241226_1155.py new file mode 100644 index 000000000..cd4f0eaf6 --- /dev/null +++ b/apps/workspaces/migrations/0050_auto_20241226_1155.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2024-12-26 11:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('workspaces', '0049_auto_20241223_1039'), + ] + + operations = [ + migrations.AddField( + model_name='workspacegeneralsettings', + name='created_by', + field=models.CharField(blank=True, help_text='Email of the user who created this record', max_length=255, null=True), + ), + migrations.AddField( + model_name='workspacegeneralsettings', + name='updated_by', + field=models.CharField(blank=True, help_text='Email of the user who last updated this record', max_length=255, null=True), + ), + ] diff --git a/apps/workspaces/models.py b/apps/workspaces/models.py index ba11051ba..b9e3f5dfb 100644 --- a/apps/workspaces/models.py +++ b/apps/workspaces/models.py @@ -7,6 +7,8 @@ from django.db.models import JSONField from django_q.models import Schedule +from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin + User = get_user_model() @@ -90,7 +92,7 @@ def get_default_memo_fields(): return ['employee_email', 'category', 'spent_on', 'report_number', 'purpose', 'expense_link'] -class WorkspaceGeneralSettings(models.Model): +class WorkspaceGeneralSettings(AutoAddCreateUpdateInfoMixin, models.Model): """ Workspace General Settings """ diff --git a/requirements.txt b/requirements.txt index 039255567..042b2ca2f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,7 @@ django-sendgrid-v5==1.2.0 enum34==1.1.10 future==0.18.2 fyle==0.37.2 -fyle-accounting-mappings==1.35.0 +fyle-accounting-mappings==1.36.2 fyle-integrations-platform-connector==1.39.3 fyle-rest-auth==1.7.4 flake8==4.0.1 diff --git a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql index 02ec4662a..e68e839d5 100644 --- a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql +++ b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql @@ -910,7 +910,9 @@ CREATE TABLE public.expense_group_settings ( import_card_credits boolean NOT NULL, ccc_export_date_type character varying(100) NOT NULL, ccc_expense_state character varying(100), - split_expense_grouping character varying(100) NOT NULL + split_expense_grouping character varying(100) NOT NULL, + created_by character varying(255), + updated_by character varying(255) ); @@ -1105,7 +1107,9 @@ CREATE TABLE public.mapping_settings ( import_to_fyle boolean NOT NULL, is_custom boolean NOT NULL, source_placeholder text, - expense_field_id integer + expense_field_id integer, + created_by character varying(255), + updated_by character varying(255) ); @@ -1283,7 +1287,9 @@ CREATE TABLE public.general_mappings ( default_tax_code_id character varying(255), default_tax_code_name character varying(255), default_debit_card_account_id character varying(40), - default_debit_card_account_name character varying(255) + default_debit_card_account_name character varying(255), + created_by character varying(255), + updated_by character varying(255) ); @@ -1887,7 +1893,9 @@ CREATE TABLE public.workspace_general_settings ( import_items boolean NOT NULL, name_in_journal_entry character varying(100) NOT NULL, is_tax_override_enabled boolean NOT NULL, - import_code_fields character varying(255)[] NOT NULL + import_code_fields character varying(255)[] NOT NULL, + created_by character varying(255), + updated_by character varying(255) ); @@ -4088,6 +4096,10 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; 199 fyle_accounting_mappings 0027_alter_employeemapping_source_employee 2024-12-23 10:37:03.397276+00 200 workspaces 0048_alter_workspace_onboarding_state 2024-12-23 10:37:03.418502+00 201 workspaces 0049_auto_20241223_1039 2024-12-23 10:41:16.03056+00 +202 fyle 0041_auto_20241226_1155 2024-12-26 12:21:39.958813+00 +203 fyle_accounting_mappings 0028_auto_20241226_1030 2024-12-26 12:21:40.030608+00 +204 mappings 0011_auto_20241226_1155 2024-12-26 12:21:40.068569+00 +205 workspaces 0050_auto_20241226_1155 2024-12-26 12:21:40.166719+00 \. @@ -33257,12 +33269,12 @@ COPY public.expense_filters (id, condition, operator, "values", rank, join_by, i -- Data for Name: expense_group_settings; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.expense_group_settings (id, reimbursable_expense_group_fields, corporate_credit_card_expense_group_fields, created_at, updated_at, workspace_id, reimbursable_export_date_type, expense_state, import_card_credits, ccc_export_date_type, ccc_expense_state, split_expense_grouping) FROM stdin; -1 {fund_source,employee_email,claim_number,report_id} {fund_source,employee_email,claim_number,report_id} 2022-05-23 04:06:18.112658+00 2022-05-23 04:10:22.281466+00 1 current_date PAYMENT_PROCESSING f current_date PAID MULTIPLE_LINE_ITEM -2 {report_id,project,claim_number,fund_source,employee_email} {spent_at,expense_id,project,fund_source,employee_email} 2022-05-23 04:13:29.316011+00 2022-05-23 04:16:19.703826+00 2 current_date PAYMENT_PROCESSING f spent_at PAID MULTIPLE_LINE_ITEM -3 {employee_email,report_id,project,fund_source,claim_number} {expense_id,employee_email,project,fund_source,spent_at} 2022-05-23 11:09:25.696485+00 2022-05-23 11:11:15.094788+00 3 current_date PAYMENT_PROCESSING f spent_at PAID MULTIPLE_LINE_ITEM -4 {claim_number,fund_source,project,employee_email,report_id} {claim_number,fund_source,project,employee_email,report_id} 2022-05-23 11:33:11.631266+00 2022-05-23 12:58:43.222723+00 4 current_date PAYMENT_PROCESSING f current_date PAID MULTIPLE_LINE_ITEM -5 {fund_source,claim_number,employee_email,report_id} {fund_source,claim_number,employee_email,report_id} 2022-05-25 14:38:52.508165+00 2022-05-25 14:40:39.655381+00 5 current_date PAYMENT_PROCESSING f current_date PAID MULTIPLE_LINE_ITEM +COPY public.expense_group_settings (id, reimbursable_expense_group_fields, corporate_credit_card_expense_group_fields, created_at, updated_at, workspace_id, reimbursable_export_date_type, expense_state, import_card_credits, ccc_export_date_type, ccc_expense_state, split_expense_grouping, created_by, updated_by) FROM stdin; +1 {fund_source,employee_email,claim_number,report_id} {fund_source,employee_email,claim_number,report_id} 2022-05-23 04:06:18.112658+00 2022-05-23 04:10:22.281466+00 1 current_date PAYMENT_PROCESSING f current_date PAID MULTIPLE_LINE_ITEM \N \N +2 {report_id,project,claim_number,fund_source,employee_email} {spent_at,expense_id,project,fund_source,employee_email} 2022-05-23 04:13:29.316011+00 2022-05-23 04:16:19.703826+00 2 current_date PAYMENT_PROCESSING f spent_at PAID MULTIPLE_LINE_ITEM \N \N +3 {employee_email,report_id,project,fund_source,claim_number} {expense_id,employee_email,project,fund_source,spent_at} 2022-05-23 11:09:25.696485+00 2022-05-23 11:11:15.094788+00 3 current_date PAYMENT_PROCESSING f spent_at PAID MULTIPLE_LINE_ITEM \N \N +4 {claim_number,fund_source,project,employee_email,report_id} {claim_number,fund_source,project,employee_email,report_id} 2022-05-23 11:33:11.631266+00 2022-05-23 12:58:43.222723+00 4 current_date PAYMENT_PROCESSING f current_date PAID MULTIPLE_LINE_ITEM \N \N +5 {fund_source,claim_number,employee_email,report_id} {fund_source,claim_number,employee_email,report_id} 2022-05-25 14:38:52.508165+00 2022-05-25 14:40:39.655381+00 5 current_date PAYMENT_PROCESSING f current_date PAID MULTIPLE_LINE_ITEM \N \N \. @@ -33480,12 +33492,12 @@ COPY public.fyle_credentials (id, refresh_token, created_at, updated_at, workspa -- Data for Name: general_mappings; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.general_mappings (id, bank_account_name, bank_account_id, default_ccc_account_name, default_ccc_account_id, created_at, updated_at, workspace_id, accounts_payable_id, accounts_payable_name, default_ccc_vendor_id, default_ccc_vendor_name, bill_payment_account_id, bill_payment_account_name, qbo_expense_account_id, qbo_expense_account_name, default_tax_code_id, default_tax_code_name, default_debit_card_account_id, default_debit_card_account_name) FROM stdin; -1 \N \N \N \N 2022-05-23 04:10:22.298731+00 2022-05-23 04:11:44.954732+00 1 33 Accounts Payable (A/P) 56 Bob's Burger Joint \N \N 35 Checking \N \N \N \N -2 \N \N Mastercard 41 2022-05-23 04:16:00.01127+00 2022-05-23 04:16:30.781055+00 2 33 Accounts Payable (A/P) \N \N \N \N \N \N \N \N \N \N -3 \N 95 Mastercard 41 2022-05-23 11:10:54.880804+00 2022-05-23 11:11:24.779971+00 3 33 Accounts Payable (A/P) \N \N 35 Checking 35 Checking \N \N 94 \N -4 \N \N \N \N 2022-05-23 11:34:35.749088+00 2022-05-23 12:58:43.247755+00 4 33 Accounts Payable (A/P) 84 again new vendor \N \N 36 Savings \N \N \N \N -5 \N 95 3420 Fyle Credit Card 107 2022-05-25 14:40:39.669004+00 2022-06-13 15:42:48.594623+00 5 \N \N \N \N \N \N 81 Current 5 0.0% ECG @0% \N \N +COPY public.general_mappings (id, bank_account_name, bank_account_id, default_ccc_account_name, default_ccc_account_id, created_at, updated_at, workspace_id, accounts_payable_id, accounts_payable_name, default_ccc_vendor_id, default_ccc_vendor_name, bill_payment_account_id, bill_payment_account_name, qbo_expense_account_id, qbo_expense_account_name, default_tax_code_id, default_tax_code_name, default_debit_card_account_id, default_debit_card_account_name, created_by, updated_by) FROM stdin; +1 \N \N \N \N 2022-05-23 04:10:22.298731+00 2022-05-23 04:11:44.954732+00 1 33 Accounts Payable (A/P) 56 Bob's Burger Joint \N \N 35 Checking \N \N \N \N \N \N +2 \N \N Mastercard 41 2022-05-23 04:16:00.01127+00 2022-05-23 04:16:30.781055+00 2 33 Accounts Payable (A/P) \N \N \N \N \N \N \N \N \N \N \N \N +3 \N 95 Mastercard 41 2022-05-23 11:10:54.880804+00 2022-05-23 11:11:24.779971+00 3 33 Accounts Payable (A/P) \N \N 35 Checking 35 Checking \N \N 94 \N \N \N +4 \N \N \N \N 2022-05-23 11:34:35.749088+00 2022-05-23 12:58:43.247755+00 4 33 Accounts Payable (A/P) 84 again new vendor \N \N 36 Savings \N \N \N \N \N \N +5 \N 95 3420 Fyle Credit Card 107 2022-05-25 14:40:39.669004+00 2022-06-13 15:42:48.594623+00 5 \N \N \N \N \N \N 81 Current 5 0.0% ECG @0% \N \N \N \N \. @@ -33528,23 +33540,23 @@ COPY public.last_export_details (id, last_exported_at, export_mode, total_expens -- Data for Name: mapping_settings; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.mapping_settings (id, source_field, destination_field, created_at, updated_at, workspace_id, import_to_fyle, is_custom, source_placeholder, expense_field_id) FROM stdin; -5 COST_CENTER CLASS 2022-05-23 04:16:18.306273+00 2022-05-23 04:16:18.306311+00 2 t f \N \N -6 PROJECT DEPARTMENT 2022-05-23 04:16:18.342552+00 2022-05-23 04:16:18.342635+00 2 t f \N \N -7 NETSUITE_SAGE_INTACCT_CUSTOMER_QBO_DEPARTMENT_HEY CUSTOMER 2022-05-23 04:16:19.65211+00 2022-05-23 04:16:19.652148+00 2 t t \N \N -8 CATEGORY ACCOUNT 2022-05-23 04:16:19.674894+00 2022-05-23 04:16:19.674932+00 2 f f \N \N -9 CORPORATE_CARD CREDIT_CARD_ACCOUNT 2022-05-23 11:10:54.842379+00 2022-05-23 11:10:54.842418+00 3 f f \N \N -10 COST_CENTER CLASS 2022-05-23 11:11:13.965014+00 2022-05-23 11:11:13.965052+00 3 t f \N \N -11 PROJECT DEPARTMENT 2022-05-23 11:11:14.008838+00 2022-05-23 11:11:14.008881+00 3 t f \N \N -12 KLASS CUSTOMER 2022-05-23 11:11:15.025025+00 2022-05-23 11:11:15.025067+00 3 t t \N \N -13 CATEGORY ACCOUNT 2022-05-23 11:11:15.060901+00 2022-05-23 11:11:15.060975+00 3 f f \N \N -14 COST_CENTER CLASS 2022-05-23 11:34:58.498423+00 2022-05-23 11:34:58.498466+00 4 t f \N \N -15 PROJECT DEPARTMENT 2022-05-23 11:34:58.532986+00 2022-05-23 11:34:58.533026+00 4 t f \N \N -16 TESTING_THIS CUSTOMER 2022-05-23 11:34:59.509529+00 2022-05-23 11:34:59.509567+00 4 t t \N \N -17 CATEGORY ACCOUNT 2022-05-23 11:34:59.540883+00 2022-05-23 11:34:59.540959+00 4 f f \N \N -18 CORPORATE_CARD CREDIT_CARD_ACCOUNT 2022-05-25 14:40:39.632972+00 2022-05-25 14:40:39.633082+00 5 f f \N \N -19 TAX_GROUP TAX_CODE 2022-05-25 14:40:59.508873+00 2022-05-25 14:57:28.861255+00 5 t f \N \N -20 CATEGORY ACCOUNT 2022-05-25 14:40:59.533893+00 2022-05-25 14:57:28.874778+00 5 f f \N \N +COPY public.mapping_settings (id, source_field, destination_field, created_at, updated_at, workspace_id, import_to_fyle, is_custom, source_placeholder, expense_field_id, created_by, updated_by) FROM stdin; +5 COST_CENTER CLASS 2022-05-23 04:16:18.306273+00 2022-05-23 04:16:18.306311+00 2 t f \N \N \N \N +6 PROJECT DEPARTMENT 2022-05-23 04:16:18.342552+00 2022-05-23 04:16:18.342635+00 2 t f \N \N \N \N +7 NETSUITE_SAGE_INTACCT_CUSTOMER_QBO_DEPARTMENT_HEY CUSTOMER 2022-05-23 04:16:19.65211+00 2022-05-23 04:16:19.652148+00 2 t t \N \N \N \N +8 CATEGORY ACCOUNT 2022-05-23 04:16:19.674894+00 2022-05-23 04:16:19.674932+00 2 f f \N \N \N \N +9 CORPORATE_CARD CREDIT_CARD_ACCOUNT 2022-05-23 11:10:54.842379+00 2022-05-23 11:10:54.842418+00 3 f f \N \N \N \N +10 COST_CENTER CLASS 2022-05-23 11:11:13.965014+00 2022-05-23 11:11:13.965052+00 3 t f \N \N \N \N +11 PROJECT DEPARTMENT 2022-05-23 11:11:14.008838+00 2022-05-23 11:11:14.008881+00 3 t f \N \N \N \N +12 KLASS CUSTOMER 2022-05-23 11:11:15.025025+00 2022-05-23 11:11:15.025067+00 3 t t \N \N \N \N +13 CATEGORY ACCOUNT 2022-05-23 11:11:15.060901+00 2022-05-23 11:11:15.060975+00 3 f f \N \N \N \N +14 COST_CENTER CLASS 2022-05-23 11:34:58.498423+00 2022-05-23 11:34:58.498466+00 4 t f \N \N \N \N +15 PROJECT DEPARTMENT 2022-05-23 11:34:58.532986+00 2022-05-23 11:34:58.533026+00 4 t f \N \N \N \N +16 TESTING_THIS CUSTOMER 2022-05-23 11:34:59.509529+00 2022-05-23 11:34:59.509567+00 4 t t \N \N \N \N +17 CATEGORY ACCOUNT 2022-05-23 11:34:59.540883+00 2022-05-23 11:34:59.540959+00 4 f f \N \N \N \N +18 CORPORATE_CARD CREDIT_CARD_ACCOUNT 2022-05-25 14:40:39.632972+00 2022-05-25 14:40:39.633082+00 5 f f \N \N \N \N +19 TAX_GROUP TAX_CODE 2022-05-25 14:40:59.508873+00 2022-05-25 14:57:28.861255+00 5 t f \N \N \N \N +20 CATEGORY ACCOUNT 2022-05-25 14:40:59.533893+00 2022-05-25 14:57:28.874778+00 5 f f \N \N \N \N \. @@ -33909,12 +33921,12 @@ COPY public.users (password, last_login, id, email, user_id, full_name, active, -- Data for Name: workspace_general_settings; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.workspace_general_settings (id, reimbursable_expenses_object, corporate_credit_card_expenses_object, employee_field_mapping, created_at, updated_at, workspace_id, import_projects, import_categories, sync_fyle_to_qbo_payments, sync_qbo_to_fyle_payments, auto_map_employees, category_sync_version, auto_create_destination_entity, map_merchant_to_vendor, je_single_credit_line, change_accounting_period, import_tax_codes, charts_of_accounts, memo_structure, map_fyle_cards_qbo_account, skip_cards_mapping, import_vendors_as_merchants, auto_create_merchants_as_vendors, is_simplify_report_closure_enabled, is_multi_currency_allowed, import_items, name_in_journal_entry, is_tax_override_enabled, import_code_fields) FROM stdin; -1 EXPENSE BILL EMPLOYEE 2022-05-23 04:09:38.662707+00 2022-05-23 04:11:44.940009+00 1 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f f t f f f ['MERCHANT', 'EMPLOYEE'] f {} -3 EXPENSE CREDIT CARD PURCHASE EMPLOYEE 2022-05-23 11:10:34.720211+00 2022-05-23 11:11:24.764146+00 3 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f t f f f f ['MERCHANT', 'EMPLOYEE'] f {} -4 EXPENSE BILL EMPLOYEE 2022-05-23 11:34:12.831875+00 2022-05-23 12:58:43.146006+00 4 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} f f t f f f f ['MERCHANT', 'EMPLOYEE'] f {} -5 EXPENSE JOURNAL ENTRY EMPLOYEE 2022-05-25 14:40:19.853971+00 2022-05-25 14:57:28.75674+00 5 f t f f EMAIL v1 f t f f t {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f t f f f f ['MERCHANT', 'EMPLOYEE'] f {} -2 BILL CREDIT CARD PURCHASE EMPLOYEE 2022-05-23 04:15:31.145853+00 2022-05-23 04:23:23.784482+00 2 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f f t f f f ['MERCHANT', 'EMPLOYEE'] f {} +COPY public.workspace_general_settings (id, reimbursable_expenses_object, corporate_credit_card_expenses_object, employee_field_mapping, created_at, updated_at, workspace_id, import_projects, import_categories, sync_fyle_to_qbo_payments, sync_qbo_to_fyle_payments, auto_map_employees, category_sync_version, auto_create_destination_entity, map_merchant_to_vendor, je_single_credit_line, change_accounting_period, import_tax_codes, charts_of_accounts, memo_structure, map_fyle_cards_qbo_account, skip_cards_mapping, import_vendors_as_merchants, auto_create_merchants_as_vendors, is_simplify_report_closure_enabled, is_multi_currency_allowed, import_items, name_in_journal_entry, is_tax_override_enabled, import_code_fields, created_by, updated_by) FROM stdin; +1 EXPENSE BILL EMPLOYEE 2022-05-23 04:09:38.662707+00 2022-05-23 04:11:44.940009+00 1 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f f t f f f ['MERCHANT', 'EMPLOYEE'] f {} \N \N +3 EXPENSE CREDIT CARD PURCHASE EMPLOYEE 2022-05-23 11:10:34.720211+00 2022-05-23 11:11:24.764146+00 3 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f t f f f f ['MERCHANT', 'EMPLOYEE'] f {} \N \N +4 EXPENSE BILL EMPLOYEE 2022-05-23 11:34:12.831875+00 2022-05-23 12:58:43.146006+00 4 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} f f t f f f f ['MERCHANT', 'EMPLOYEE'] f {} \N \N +5 EXPENSE JOURNAL ENTRY EMPLOYEE 2022-05-25 14:40:19.853971+00 2022-05-25 14:57:28.75674+00 5 f t f f EMAIL v1 f t f f t {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f t f f f f ['MERCHANT', 'EMPLOYEE'] f {} \N \N +2 BILL CREDIT CARD PURCHASE EMPLOYEE 2022-05-23 04:15:31.145853+00 2022-05-23 04:23:23.784482+00 2 f t f f EMAIL v1 f t f f f {Expense} {employee_email,category,spent_on,report_number,purpose,expense_link} t f f t f f f ['MERCHANT', 'EMPLOYEE'] f {} \N \N \. @@ -34016,7 +34028,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 47, true); -- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres -- -SELECT pg_catalog.setval('public.django_migrations_id_seq', 201, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 205, true); -- diff --git a/tests/test_fyle/fixtures.py b/tests/test_fyle/fixtures.py index c7726119a..7312bf4da 100644 --- a/tests/test_fyle/fixtures.py +++ b/tests/test_fyle/fixtures.py @@ -3160,6 +3160,8 @@ 'created_at': '2022-01-27T15:19:21.542785Z', 'updated_at': '2022-02-02T06:51:21.715325Z', 'workspace': 8, + 'created_by': 'asbdsuai@basjd.com', + 'updated_by': 'asbdhjas@gnjksnd.com' }, 'expense_group_id_response': { 'id': 4, diff --git a/tests/test_fyle/test_models.py b/tests/test_fyle/test_models.py index 617f8d9f8..71f8ec49b 100644 --- a/tests/test_fyle/test_models.py +++ b/tests/test_fyle/test_models.py @@ -38,8 +38,9 @@ def test_create_expense_objects(db): def test_expense_group_settings(create_temp_workspace, db): payload = data['expense_group_settings_payload'] + user = Workspace.objects.get(id=1).user - ExpenseGroupSettings.update_expense_group_settings(payload, 98) + ExpenseGroupSettings.update_expense_group_settings(payload, 98, user) settings = ExpenseGroupSettings.objects.last() diff --git a/tests/test_workspaces/fixtures.py b/tests/test_workspaces/fixtures.py index 2bef885a7..d64c000e9 100644 --- a/tests/test_workspaces/fixtures.py +++ b/tests/test_workspaces/fixtures.py @@ -74,6 +74,8 @@ 'is_tax_override_enabled': False, 'import_code_fields': [], 'workspace': 4, + 'created_by': 'asbauirb@gpasd.com', + 'updated_by': 'asdasb@asjd.com' }, 'expenses': [ {