diff --git a/apps/workspaces/actions.py b/apps/workspaces/actions.py index 1c71534e8..6561c16a7 100644 --- a/apps/workspaces/actions.py +++ b/apps/workspaces/actions.py @@ -109,10 +109,8 @@ def connect_qbo_oauth(refresh_token, realm_id, workspace_id): workspace.qbo_realm_id = realm_id if workspace.onboarding_state == 'CONNECTION': - if settings.BRAND_ID == 'fyle': - workspace.onboarding_state = 'MAP_EMPLOYEES' - elif settings.BRAND_ID == 'co': - workspace.onboarding_state = 'EXPORT_SETTINGS' + workspace.onboarding_state = 'EXPORT_SETTINGS' + if settings.BRAND_ID == 'co': workspace_general_settings_instance = WorkspaceGeneralSettings.objects.filter(workspace_id=workspace.id).first() if not workspace_general_settings_instance: WorkspaceGeneralSettings.objects.update_or_create( @@ -208,7 +206,7 @@ def setup_e2e_tests(workspace_id: int, connection): platform.import_fyle_dimensions(import_taxes=True) # Reset workspace details - workspace.onboarding_state = 'MAP_EMPLOYEES' + workspace.onboarding_state = 'EXPORT_SETTINGS' workspace.source_synced_at = datetime.now() workspace.destination_synced_at = datetime.now() workspace.qbo_realm_id = healthy_token.realm_id diff --git a/apps/workspaces/apis/map_employees/serializers.py b/apps/workspaces/apis/map_employees/serializers.py index 4be4198df..b06c607c2 100644 --- a/apps/workspaces/apis/map_employees/serializers.py +++ b/apps/workspaces/apis/map_employees/serializers.py @@ -28,20 +28,16 @@ def update(self, instance, validated_data): workspace_general_settings_instance = WorkspaceGeneralSettings.objects.filter(workspace_id=instance.id).first() - if workspace_general_settings_instance and (workspace_general_settings_instance.employee_field_mapping != workspace_general_settings['employee_field_mapping']): - workspace_general_settings_instance.reimbursable_expenses_object = None - workspace_general_settings_instance.save() - workspace_general_settings_instance, _ = WorkspaceGeneralSettings.objects.update_or_create( - workspace_id=workspace_id, defaults={'employee_field_mapping': workspace_general_settings['employee_field_mapping'], 'auto_map_employees': workspace_general_settings['auto_map_employees']} + workspace_id=workspace_id, + defaults={ + 'employee_field_mapping': workspace_general_settings['employee_field_mapping'], + 'auto_map_employees': workspace_general_settings['auto_map_employees'] + } ) MapEmployeesTriggers.run_workspace_general_settings_triggers(workspace_general_settings_instance) - if instance.onboarding_state == 'MAP_EMPLOYEES': - instance.onboarding_state = 'EXPORT_SETTINGS' - instance.save() - return instance def validate(self, data): diff --git a/apps/workspaces/migrations/0048_alter_workspace_onboarding_state.py b/apps/workspaces/migrations/0048_alter_workspace_onboarding_state.py new file mode 100644 index 000000000..46e6108c1 --- /dev/null +++ b/apps/workspaces/migrations/0048_alter_workspace_onboarding_state.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.14 on 2024-12-20 11:27 + +import apps.workspaces.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('workspaces', '0047_alter_workspacegeneralsettings_change_accounting_period'), + ] + + operations = [ + migrations.AlterField( + model_name='workspace', + name='onboarding_state', + field=models.CharField(choices=[('CONNECTION', 'CONNECTION'), ('EXPORT_SETTINGS', 'EXPORT_SETTINGS'), ('IMPORT_SETTINGS', 'IMPORT_SETTINGS'), ('ADVANCED_CONFIGURATION', 'ADVANCED_CONFIGURATION'), ('COMPLETE', 'COMPLETE')], default=apps.workspaces.models.get_default_onboarding_state, help_text='Onboarding status of the workspace', max_length=50, null=True), + ), + ] diff --git a/apps/workspaces/models.py b/apps/workspaces/models.py index 95c4473e5..84a644151 100644 --- a/apps/workspaces/models.py +++ b/apps/workspaces/models.py @@ -12,7 +12,6 @@ ONBOARDING_STATE_CHOICES = ( ('CONNECTION', 'CONNECTION'), - ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), ('EXPORT_SETTINGS', 'EXPORT_SETTINGS'), ('IMPORT_SETTINGS', 'IMPORT_SETTINGS'), ('ADVANCED_CONFIGURATION', 'ADVANCED_CONFIGURATION'), diff --git a/apps/workspaces/signals.py b/apps/workspaces/signals.py index 0272b5137..6e173543b 100644 --- a/apps/workspaces/signals.py +++ b/apps/workspaces/signals.py @@ -29,7 +29,7 @@ def post_delete_qbo_connection(workspace_id): :return: None """ workspace = Workspace.objects.get(id=workspace_id) - if workspace.onboarding_state in ('CONNECTION', 'MAP_EMPLOYEES', 'EXPORT_SETTINGS'): + if workspace.onboarding_state in ('CONNECTION', 'EXPORT_SETTINGS'): EmployeeMapping.objects.filter(workspace_id=workspace_id).delete() DestinationAttribute.objects.filter(workspace_id=workspace_id).delete() workspace.onboarding_state = 'CONNECTION' diff --git a/fyle_integrations_imports b/fyle_integrations_imports index f0c509e8f..83c7eb558 160000 --- a/fyle_integrations_imports +++ b/fyle_integrations_imports @@ -1 +1 @@ -Subproject commit f0c509e8fcfaa2b09ea40473a60bea2383766ee1 +Subproject commit 83c7eb5583447c4202afea6c63b7d45221da55cd diff --git a/sql/functions/e2e-test-setup-workspace-local.sql b/sql/functions/e2e-test-setup-workspace-local.sql index 541f5d127..826863eca 100644 --- a/sql/functions/e2e-test-setup-workspace-local.sql +++ b/sql/functions/e2e-test-setup-workspace-local.sql @@ -271,7 +271,7 @@ BEGIN -- RAISE NOTICE 'Deleted % workspaces', rcount; UPDATE workspaces - SET onboarding_state = 'MAP_EMPLOYEES', last_synced_at = null + SET onboarding_state = 'EXPORT_SETTINGS', last_synced_at = null WHERE id = _workspace_id; UPDATE last_export_details diff --git a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql index b7f6d10df..9ed3be11a 100644 --- a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql +++ b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql @@ -34010,7 +34010,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', 197, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 198, true); -- @@ -35915,3 +35915,4 @@ ALTER TABLE ONLY public.workspaces_user -- -- PostgreSQL database dump complete -- + diff --git a/tests/test_workspaces/test_apis/test_map_employee/test_views.py b/tests/test_workspaces/test_apis/test_map_employee/test_views.py index fcb819794..1cad11c68 100644 --- a/tests/test_workspaces/test_apis/test_map_employee/test_views.py +++ b/tests/test_workspaces/test_apis/test_map_employee/test_views.py @@ -8,7 +8,7 @@ def test_map_employees(api_client, test_connection): workspace = Workspace.objects.get(id=3) - workspace.onboarding_state = 'MAP_EMPLOYEES' + workspace.onboarding_state = 'EXPORT_SETTINGS' workspace.save() workspace_general_settings_instance = WorkspaceGeneralSettings.objects.filter(workspace_id=3).first()