From ecb25b82e854e46ec1e8b1c6280b8098623d1cff Mon Sep 17 00:00:00 2001 From: Ashutosh singh <55102089+Ashutosh619-sudo@users.noreply.github.com> Date: Thu, 26 Dec 2024 16:20:22 +0530 Subject: [PATCH] Feat: Adding Created_by and updated_by to conf tables (#689) * Feat: Adding Created_by and updated_by to conf tables * resolve test * fixed test * added fields to mapping settings --- .../migrations/0037_auto_20241226_0929.py | 23 +++++++++++ apps/fyle/models.py | 8 ++-- apps/fyle/views.py | 2 +- .../migrations/0016_auto_20241226_0929.py | 23 +++++++++++ apps/mappings/models.py | 4 +- .../apis/export_settings/serializers.py | 12 ++++-- apps/workspaces/apis/export_settings/views.py | 9 ++++ .../apis/import_settings/serializers.py | 6 ++- apps/workspaces/apis/import_settings/views.py | 9 ++++ .../apis/map_employees/serializers.py | 5 ++- apps/workspaces/apis/map_employees/views.py | 9 ++++ .../migrations/0043_auto_20241224_1102.py | 23 +++++++++++ apps/workspaces/models.py | 4 +- requirements.txt | 2 +- .../reset_db_fixtures/reset_db.sql | 41 +++++++++++-------- tests/test_fyle/fixtures.py | 2 + tests/test_fyle/test_models.py | 3 +- tests/test_workspaces/data.json | 4 +- tests/test_workspaces/test_views.py | 3 ++ 19 files changed, 160 insertions(+), 32 deletions(-) create mode 100644 apps/fyle/migrations/0037_auto_20241226_0929.py create mode 100644 apps/mappings/migrations/0016_auto_20241226_0929.py create mode 100644 apps/workspaces/migrations/0043_auto_20241224_1102.py diff --git a/apps/fyle/migrations/0037_auto_20241226_0929.py b/apps/fyle/migrations/0037_auto_20241226_0929.py new file mode 100644 index 00000000..8d9984e2 --- /dev/null +++ b/apps/fyle/migrations/0037_auto_20241226_0929.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2024-12-26 09:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fyle', '0036_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 0dc7da0a..fad24792 100644 --- a/apps/fyle/models.py +++ b/apps/fyle/models.py @@ -15,6 +15,7 @@ from django.db.models import Count, Q, JSONField from fyle_accounting_mappings.models import ExpenseAttribute +from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin from apps.workspaces.models import Configuration, Workspace @@ -217,7 +218,7 @@ def get_default_split_expense_grouping(): return 'MULTIPLE_LINE_ITEM' -class ExpenseGroupSettings(models.Model): +class ExpenseGroupSettings(AutoAddCreateUpdateInfoMixin, models.Model): """ ExpenseGroupCustomizationSettings """ @@ -257,7 +258,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) @@ -327,7 +328,8 @@ def update_expense_group_settings(expense_group_settings: Dict, workspace_id: in 'reimbursable_export_date_type': expense_group_settings['reimbursable_export_date_type'], 'ccc_export_date_type': expense_group_settings['ccc_export_date_type'], 'split_expense_grouping': expense_group_settings['split_expense_grouping'] - } + }, + user=user ) diff --git a/apps/fyle/views.py b/apps/fyle/views.py index e242f64a..bb115a7c 100644 --- a/apps/fyle/views.py +++ b/apps/fyle/views.py @@ -149,7 +149,7 @@ def get(self, request, *args, **kwargs): def post(self, request, *args, **kwargs): expense_group_settings, _ = ExpenseGroupSettings.update_expense_group_settings( - request.data, self.kwargs['workspace_id']) + request.data, self.kwargs['workspace_id'], user=request.user) return Response( data=self.serializer_class(expense_group_settings).data, status=status.HTTP_200_OK diff --git a/apps/mappings/migrations/0016_auto_20241226_0929.py b/apps/mappings/migrations/0016_auto_20241226_0929.py new file mode 100644 index 00000000..29d5ecf8 --- /dev/null +++ b/apps/mappings/migrations/0016_auto_20241226_0929.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2024-12-26 09:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mappings', '0015_generalmapping_is_tax_balancing_enabled'), + ] + + 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 a8717d79..4cc53775 100644 --- a/apps/mappings/models.py +++ b/apps/mappings/models.py @@ -4,6 +4,7 @@ from django.db import models from apps.workspaces.models import Workspace +from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin class SubsidiaryMapping(models.Model): @@ -22,7 +23,7 @@ class Meta: db_table = 'subsidiary_mappings' -class GeneralMapping(models.Model): +class GeneralMapping(AutoAddCreateUpdateInfoMixin, models.Model): """ General Mapping """ @@ -74,5 +75,6 @@ class GeneralMapping(models.Model): created_at = models.DateTimeField(auto_now_add=True, help_text='Created at datetime') updated_at = models.DateTimeField(auto_now=True, help_text='Updated at datetime') + class Meta: db_table = 'general_mappings' diff --git a/apps/workspaces/apis/export_settings/serializers.py b/apps/workspaces/apis/export_settings/serializers.py index f771876b..d8a0efe2 100644 --- a/apps/workspaces/apis/export_settings/serializers.py +++ b/apps/workspaces/apis/export_settings/serializers.py @@ -32,7 +32,7 @@ class Meta: 'is_simplify_report_closure_enabled', 'name_in_journal_entry', 'employee_field_mapping', - 'auto_map_employees' + 'auto_map_employees', ] read_only_fields = ['is_simplify_report_closure_enabled'] @@ -120,6 +120,8 @@ def get_workspace_id(self, instance): return instance.id def update(self, instance: Workspace, validated_data): + request = self.context.get('request') + user = request.user if request and hasattr(request, 'user') else None configurations = validated_data.pop('configuration') expense_group_settings = validated_data.pop('expense_group_settings') @@ -134,7 +136,8 @@ def update(self, instance: Workspace, validated_data): 'employee_field_mapping': configurations['employee_field_mapping'], 'name_in_journal_entry': configurations['name_in_journal_entry'], 'auto_map_employees': configurations['auto_map_employees'], - } + }, + user=user ) exports_trigger = ExportSettingsTrigger( @@ -156,7 +159,7 @@ def update(self, instance: Workspace, validated_data): if not expense_group_settings['ccc_export_date_type']: expense_group_settings['ccc_export_date_type'] = 'current_date' - ExpenseGroupSettings.update_expense_group_settings(expense_group_settings, workspace_id=workspace_id) + ExpenseGroupSettings.update_expense_group_settings(expense_group_settings, workspace_id=workspace_id, user=user) GeneralMapping.objects.update_or_create( workspace=instance, @@ -169,7 +172,8 @@ def update(self, instance: Workspace, validated_data): 'accounts_payable_name': general_mappings['accounts_payable']['name'], 'default_ccc_vendor_id': general_mappings['default_ccc_vendor']['id'], 'default_ccc_vendor_name': general_mappings['default_ccc_vendor']['name'] - } + }, + 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 43e0ab7e..00a5379a 100644 --- a/apps/workspaces/apis/export_settings/views.py +++ b/apps/workspaces/apis/export_settings/views.py @@ -10,3 +10,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 81fd73b2..878485f5 100644 --- a/apps/workspaces/apis/import_settings/serializers.py +++ b/apps/workspaces/apis/import_settings/serializers.py @@ -109,6 +109,8 @@ 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 configurations = validated_data.pop('configuration') general_mappings = validated_data.pop('general_mappings') @@ -123,9 +125,10 @@ def update(self, instance, validated_data): 'import_vendors_as_merchants': configurations.get('import_vendors_as_merchants'), 'import_netsuite_employees': configurations.get('import_netsuite_employees') }, + 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(configurations=configurations, mapping_settings=mapping_settings, workspace_id=instance.id) @@ -148,6 +151,7 @@ def update(self, instance, validated_data): '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(configurations_instance) diff --git a/apps/workspaces/apis/import_settings/views.py b/apps/workspaces/apis/import_settings/views.py index f80e0641..cb16bd11 100644 --- a/apps/workspaces/apis/import_settings/views.py +++ b/apps/workspaces/apis/import_settings/views.py @@ -9,3 +9,12 @@ 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 diff --git a/apps/workspaces/apis/map_employees/serializers.py b/apps/workspaces/apis/map_employees/serializers.py index 14f36ab6..1f9cc230 100644 --- a/apps/workspaces/apis/map_employees/serializers.py +++ b/apps/workspaces/apis/map_employees/serializers.py @@ -23,6 +23,8 @@ 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 configuration = validated_data.pop('configuration') @@ -34,7 +36,8 @@ def update(self, instance, validated_data): configuration_instance.save() configuration_instance, _ = Configuration.objects.update_or_create( - workspace_id=workspace_id, defaults={'employee_field_mapping': configuration['employee_field_mapping'], 'auto_map_employees': configuration['auto_map_employees']} + workspace_id=workspace_id, defaults={'employee_field_mapping': configuration['employee_field_mapping'], 'auto_map_employees': configuration['auto_map_employees']}, + user=user ) MapEmployeesTriggers.run_configurations_triggers(configuration=configuration_instance) diff --git a/apps/workspaces/apis/map_employees/views.py b/apps/workspaces/apis/map_employees/views.py index d749196e..d2080925 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/0043_auto_20241224_1102.py b/apps/workspaces/migrations/0043_auto_20241224_1102.py new file mode 100644 index 00000000..cc8c55cf --- /dev/null +++ b/apps/workspaces/migrations/0043_auto_20241224_1102.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.14 on 2024-12-24 11:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('workspaces', '0042_auto_20241219_1808'), + ] + + operations = [ + migrations.AddField( + model_name='configuration', + 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='configuration', + 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 517ec0f0..250658ed 100644 --- a/apps/workspaces/models.py +++ b/apps/workspaces/models.py @@ -7,7 +7,7 @@ from django_q.models import Schedule from django.db.models import JSONField - +from fyle_accounting_mappings.mixins import AutoAddCreateUpdateInfoMixin User = get_user_model() @@ -135,7 +135,7 @@ def get_default_memo_fields(): return ['employee_email', 'category', 'merchant', 'spent_on', 'report_number', 'purpose'] -class Configuration(models.Model): +class Configuration(AutoAddCreateUpdateInfoMixin, models.Model): """ Workspace General Settings """ diff --git a/requirements.txt b/requirements.txt index cab2c607..40630a02 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.0 -fyle-accounting-mappings==1.35.0 +fyle-accounting-mappings==1.36.1 fyle-integrations-platform-connector==1.39.3 fyle-rest-auth==1.7.2 gunicorn==20.1.0 diff --git a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql index 4006f520..c17618ba 100644 --- a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql +++ b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql @@ -324,7 +324,9 @@ CREATE TABLE public.configurations ( name_in_journal_entry character varying(100) NOT NULL, allow_intercompany_vendors boolean NOT NULL, je_single_credit_line boolean NOT NULL, - is_attachment_upload_enabled boolean NOT NULL + is_attachment_upload_enabled boolean NOT NULL, + created_by character varying(255), + updated_by character varying(255) ); @@ -961,7 +963,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) ); @@ -1445,7 +1449,9 @@ CREATE TABLE public.general_mappings ( class_name character varying(255), default_tax_code_id character varying(255), default_tax_code_name character varying(255), - is_tax_balancing_enabled boolean NOT NULL + is_tax_balancing_enabled boolean NOT NULL, + created_by character varying(255), + updated_by character varying(255) ); @@ -2701,10 +2707,10 @@ COPY public.category_mappings (id, created_at, updated_at, destination_account_i -- Data for Name: configurations; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.configurations (id, reimbursable_expenses_object, corporate_credit_card_expenses_object, created_at, updated_at, workspace_id, sync_fyle_to_netsuite_payments, sync_netsuite_to_fyle_payments, import_projects, auto_map_employees, import_categories, auto_create_destination_entity, auto_create_merchants, employee_field_mapping, import_tax_items, change_accounting_period, memo_structure, map_fyle_cards_netsuite_account, skip_cards_mapping, import_vendors_as_merchants, import_netsuite_employees, is_simplify_report_closure_enabled, import_items, name_in_journal_entry, allow_intercompany_vendors, je_single_credit_line, is_attachment_upload_enabled) FROM stdin; -1 EXPENSE REPORT BILL 2021-11-15 08:56:07.193743+00 2021-11-15 08:56:07.193795+00 1 f f f \N f f f EMPLOYEE f f {employee_email,category,spent_on,report_number,purpose} t f f f f f MERCHANT f f t -2 JOURNAL ENTRY CREDIT CARD CHARGE 2021-11-16 04:18:15.836271+00 2021-11-16 04:20:09.969589+00 2 f f f \N f f f EMPLOYEE t f {employee_email,category,spent_on,report_number,purpose} t f f f f f MERCHANT f f t -3 JOURNAL ENTRY CREDIT CARD CHARGE 2021-12-03 11:04:00.194287+00 2021-12-03 11:04:00.1943+00 49 f f f \N f f f EMPLOYEE f f {employee_email,category,spent_on,report_number,purpose} t f f f f f MERCHANT f f t +COPY public.configurations (id, reimbursable_expenses_object, corporate_credit_card_expenses_object, created_at, updated_at, workspace_id, sync_fyle_to_netsuite_payments, sync_netsuite_to_fyle_payments, import_projects, auto_map_employees, import_categories, auto_create_destination_entity, auto_create_merchants, employee_field_mapping, import_tax_items, change_accounting_period, memo_structure, map_fyle_cards_netsuite_account, skip_cards_mapping, import_vendors_as_merchants, import_netsuite_employees, is_simplify_report_closure_enabled, import_items, name_in_journal_entry, allow_intercompany_vendors, je_single_credit_line, is_attachment_upload_enabled, created_by, updated_by) FROM stdin; +1 EXPENSE REPORT BILL 2021-11-15 08:56:07.193743+00 2021-11-15 08:56:07.193795+00 1 f f f \N f f f EMPLOYEE f f {employee_email,category,spent_on,report_number,purpose} t f f f f f MERCHANT f f t \N \N +2 JOURNAL ENTRY CREDIT CARD CHARGE 2021-11-16 04:18:15.836271+00 2021-11-16 04:20:09.969589+00 2 f f f \N f f f EMPLOYEE t f {employee_email,category,spent_on,report_number,purpose} t f f f f f MERCHANT f f t \N \N +3 JOURNAL ENTRY CREDIT CARD CHARGE 2021-12-03 11:04:00.194287+00 2021-12-03 11:04:00.1943+00 49 f f f \N f f f EMPLOYEE f f {employee_email,category,spent_on,report_number,purpose} t f f f f f MERCHANT f f t \N \N \. @@ -8004,6 +8010,9 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; 207 fyle_accounting_mappings 0027_alter_employeemapping_source_employee 2024-12-18 05:34:34.929303+00 208 workspaces 0041_configuration_is_attachment_upload_enabled 2024-12-18 05:34:34.968096+00 209 workspaces 0042_auto_20241219_1808 2024-12-23 09:56:48.057086+00 +210 fyle 0037_auto_20241226_0929 2024-12-26 09:48:19.921189+00 +211 mappings 0016_auto_20241226_0929 2024-12-26 09:48:19.963414+00 +212 workspaces 0043_auto_20241224_1102 2024-12-26 09:48:19.987821+00 \. @@ -11590,10 +11599,10 @@ 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, expense_state, reimbursable_export_date_type, created_at, updated_at, workspace_id, import_card_credits, ccc_export_date_type, ccc_expense_state, split_expense_grouping) FROM stdin; -1 {employee_email,report_id,claim_number,fund_source} {employee_email,report_id,claim_number,fund_source} PAYMENT_PROCESSING current_date 2021-11-15 08:46:16.069944+00 2021-11-15 08:46:16.069986+00 1 f current_date PAID MULTIPLE_LINE_ITEM -2 {fund_source,employee_email,settlement_id,spent_at} {expense_id,fund_source,employee_email,settlement_id,spent_at} PAID spent_at 2021-11-16 04:16:57.847694+00 2021-11-16 07:34:26.302812+00 2 f spent_at PAID MULTIPLE_LINE_ITEM -74 {employee_email,report_id,claim_number,fund_source} {claim_number,employee_email,expense_id,report_id,fund_source} PAYMENT_PROCESSING last_spent_at 2021-12-03 11:00:33.637654+00 2021-12-03 11:04:00.206339+00 49 f last_spent_at PAID MULTIPLE_LINE_ITEM +COPY public.expense_group_settings (id, reimbursable_expense_group_fields, corporate_credit_card_expense_group_fields, expense_state, reimbursable_export_date_type, created_at, updated_at, workspace_id, import_card_credits, ccc_export_date_type, ccc_expense_state, split_expense_grouping, created_by, updated_by) FROM stdin; +1 {employee_email,report_id,claim_number,fund_source} {employee_email,report_id,claim_number,fund_source} PAYMENT_PROCESSING current_date 2021-11-15 08:46:16.069944+00 2021-11-15 08:46:16.069986+00 1 f current_date PAID MULTIPLE_LINE_ITEM \N \N +2 {fund_source,employee_email,settlement_id,spent_at} {expense_id,fund_source,employee_email,settlement_id,spent_at} PAID spent_at 2021-11-16 04:16:57.847694+00 2021-11-16 07:34:26.302812+00 2 f spent_at PAID MULTIPLE_LINE_ITEM \N \N +74 {employee_email,report_id,claim_number,fund_source} {claim_number,employee_email,expense_id,report_id,fund_source} PAYMENT_PROCESSING last_spent_at 2021-12-03 11:00:33.637654+00 2021-12-03 11:04:00.206339+00 49 f last_spent_at PAID MULTIPLE_LINE_ITEM \N \N \. @@ -11669,10 +11678,10 @@ 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, location_name, location_id, accounts_payable_name, accounts_payable_id, created_at, updated_at, workspace_id, default_ccc_account_id, default_ccc_account_name, reimbursable_account_id, reimbursable_account_name, default_ccc_vendor_id, default_ccc_vendor_name, vendor_payment_account_id, vendor_payment_account_name, location_level, department_level, use_employee_department, use_employee_class, use_employee_location, department_id, department_name, override_tax_details, class_id, class_level, class_name, default_tax_code_id, default_tax_code_name, is_tax_balancing_enabled) FROM stdin; -1 hubajuba 8 Accounts Payable 25 2021-11-15 08:56:31.432106+00 2021-11-15 13:21:26.113427+00 1 \N \N 118 Unapproved Expense Reports 1674 Ashwin Vendor \N \N TRANSACTION_BODY \N f f f \N \N f \N \N \N \N \N f -2 \N \N Accounts Payable 25 2021-11-16 04:18:39.195287+00 2021-11-16 04:18:39.195312+00 2 228 Aus Account 118 Unapproved Expense Reports 12104 Nilesh Aus Vendor \N \N \N \N f f f \N \N f \N \N \N \N \N f -3 hukiju 10 \N \N 2021-12-03 11:24:17.962764+00 2021-12-03 11:24:17.962809+00 49 228 Aus Account 228 Aus Account 12104 Nilesh Aus Vendor \N \N TRANSACTION_BODY \N f f f \N \N f \N \N \N \N \N f +COPY public.general_mappings (id, location_name, location_id, accounts_payable_name, accounts_payable_id, created_at, updated_at, workspace_id, default_ccc_account_id, default_ccc_account_name, reimbursable_account_id, reimbursable_account_name, default_ccc_vendor_id, default_ccc_vendor_name, vendor_payment_account_id, vendor_payment_account_name, location_level, department_level, use_employee_department, use_employee_class, use_employee_location, department_id, department_name, override_tax_details, class_id, class_level, class_name, default_tax_code_id, default_tax_code_name, is_tax_balancing_enabled, created_by, updated_by) FROM stdin; +1 hubajuba 8 Accounts Payable 25 2021-11-15 08:56:31.432106+00 2021-11-15 13:21:26.113427+00 1 \N \N 118 Unapproved Expense Reports 1674 Ashwin Vendor \N \N TRANSACTION_BODY \N f f f \N \N f \N \N \N \N \N f \N \N +2 \N \N Accounts Payable 25 2021-11-16 04:18:39.195287+00 2021-11-16 04:18:39.195312+00 2 228 Aus Account 118 Unapproved Expense Reports 12104 Nilesh Aus Vendor \N \N \N \N f f f \N \N f \N \N \N \N \N f \N \N +3 hukiju 10 \N \N 2021-12-03 11:24:17.962764+00 2021-12-03 11:24:17.962809+00 49 228 Aus Account 228 Aus Account 12104 Nilesh Aus Vendor \N \N TRANSACTION_BODY \N f f f \N \N f \N \N \N \N \N f \N \N \. @@ -11915,7 +11924,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', 209, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 212, true); -- diff --git a/tests/test_fyle/fixtures.py b/tests/test_fyle/fixtures.py index 0976095c..4f37de15 100644 --- a/tests/test_fyle/fixtures.py +++ b/tests/test_fyle/fixtures.py @@ -1015,6 +1015,8 @@ "updated_at": "2021-11-15T08:46:16.069986Z", "workspace": 1, "split_expense_grouping": "MULTIPLE_LINE_ITEM", + "created_by": "ashu@sadsa.com", + "updated_by": "asdhasj@bjasd.com" }, "fyle_orgs": [ { diff --git a/tests/test_fyle/test_models.py b/tests/test_fyle/test_models.py index da453493..ddd22d6b 100644 --- a/tests/test_fyle/test_models.py +++ b/tests/test_fyle/test_models.py @@ -41,9 +41,10 @@ def test_default_fields(): @pytest.mark.django_db def test_expense_group_settings(create_temp_workspace): payload = data['expense_group_setting_payload'] + user = Workspace.objects.get(id=1).user ExpenseGroupSettings.update_expense_group_settings( - payload, 3 + payload, 3, user ) settings = ExpenseGroupSettings.objects.last() diff --git a/tests/test_workspaces/data.json b/tests/test_workspaces/data.json index f1c30f2c..8382e2a2 100644 --- a/tests/test_workspaces/data.json +++ b/tests/test_workspaces/data.json @@ -26,7 +26,9 @@ "name_in_journal_entry": "MERCHANT", "allow_intercompany_vendors": false, "je_single_credit_line": false, - "is_attachment_upload_enabled": true + "is_attachment_upload_enabled": true, + "created_by": "aksndbkas", + "updated_by": "asvhdvsaj" }, "workspace": { "id":1, diff --git a/tests/test_workspaces/test_views.py b/tests/test_workspaces/test_views.py index f31e1bd2..702d8305 100644 --- a/tests/test_workspaces/test_views.py +++ b/tests/test_workspaces/test_views.py @@ -297,6 +297,9 @@ def test_patch_workspace_configuration(api_client, access_token): api_client.credentials(HTTP_AUTHORIZATION='Bearer {}'.format(access_token)) configuration = Configuration.objects.get(workspace_id=1) + configuration.created_by = 'ashu@gmail.com' + configuration.updated_by = 'ashu@gmail.com' + configuration.save() configuration.auto_create_destination_entity = True configuration.auto_map_employees = ''