From 5c31b3f4b93e219b4b76ac5fe62e3b8cd9560391 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Wed, 11 Oct 2023 13:26:46 +0530 Subject: [PATCH 1/8] onboarding state implementation --- .../0033_workspace_onboarding_state.py | 19 +++ apps/workspaces/models.py | 14 +++ .../sql/scripts/019-add-onboarding-state.sql | 115 ++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 apps/workspaces/migrations/0033_workspace_onboarding_state.py create mode 100644 scripts/sql/scripts/019-add-onboarding-state.sql diff --git a/apps/workspaces/migrations/0033_workspace_onboarding_state.py b/apps/workspaces/migrations/0033_workspace_onboarding_state.py new file mode 100644 index 00000000..e4fdbf14 --- /dev/null +++ b/apps/workspaces/migrations/0033_workspace_onboarding_state.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.14 on 2023-10-10 11:39 + +import apps.workspaces.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('workspaces', '0032_configuration_name_in_journal_entry'), + ] + + operations = [ + migrations.AddField( + model_name='workspace', + name='onboarding_state', + field=models.CharField(choices=[('CONNECTION', 'CONNECTION'), ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), ('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 eb7a503c..c501b73f 100644 --- a/apps/workspaces/models.py +++ b/apps/workspaces/models.py @@ -12,6 +12,19 @@ User = get_user_model() +ONBOARDING_STATE_CHOICES = ( + ('CONNECTION', 'CONNECTION'), + ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), + ('EXPORT_SETTINGS', 'EXPORT_SETTINGS'), + ('IMPORT_SETTINGS', 'IMPORT_SETTINGS'), + ('ADVANCED_CONFIGURATION', 'ADVANCED_CONFIGURATION'), + ('COMPLETE', 'COMPLETE'), +) + + +def get_default_onboarding_state(): + return 'CONNECTION' + class Workspace(models.Model): """ Workspace model @@ -29,6 +42,7 @@ class Workspace(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') employee_exported_at = models.DateTimeField(auto_now_add=True, help_text='Employee exported to Fyle at datetime') + onboarding_state = models.CharField(max_length=50, choices=ONBOARDING_STATE_CHOICES, default=get_default_onboarding_state, help_text='Onboarding status of the workspace', null=True) class Meta: db_table = 'workspaces' diff --git a/scripts/sql/scripts/019-add-onboarding-state.sql b/scripts/sql/scripts/019-add-onboarding-state.sql new file mode 100644 index 00000000..c70bdd6f --- /dev/null +++ b/scripts/sql/scripts/019-add-onboarding-state.sql @@ -0,0 +1,115 @@ +-- Create a view for joined on all settings tables to figure out onboarding progress +create or replace view all_settings_view as +select + w.id as workspace_id, + wgs.id as configuration_id, + gm.id as general_mappings_id, + qc.id as netsuite_creds_id +from workspaces w +left join + configurations wgs on w.id = wgs.workspace_id +left join + netsuite_credentials qc on qc.workspace_id = w.id +left join + general_mappings gm on gm.workspace_id = w.id +where w.onboarding_state = 'CONNECTION'; + +begin; -- Start Transaction Block + +-- Count of all workspaces where qbo creds are present, configuration is present and general mappings are present +select + 'QC=TRUE, C=TRUE, GM=TRUE' as setting, count(*) +from all_settings_view +where + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null; + +--- Update all of the above to have onboarding state set to 'COMPLETE' +update workspaces +set + onboarding_state = 'COMPLETE' +where id in ( + select + workspace_id + from all_settings_view + where + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null +); + +-- Count of all workspaces where qbo creds are present, configuration is present and general mappings are not present +select + 'QC=TRUE, C=TRUE, GM=FALSE' as settings, count(*) +from all_settings_view +where + configuration_id is not null and general_mappings_id is null and netsuite_creds_id is not null; + +--- Update all of the above to have onboarding state set to 'EXPORT_SETTINGS' +update workspaces +set + onboarding_state = 'EXPORT_SETTINGS' +where id in ( + select + workspace_id + from all_settings_view + where + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null +); + + +-- Count of all workspaces where qbo creds are present, configuration is not present and general mappings are not present +select + 'QC=TRUE, C=FALSE, GM=FALSE' as settings, count(*) +from all_settings_view +where + configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null; + +--- Update all of the above to have onboarding state set to 'MAP_EMPLOYEES' +update workspaces +set + onboarding_state = 'MAP_EMPLOYEES' +where id in ( + select + workspace_id + from all_settings_view + where + configuration_id is null and general_mappings_id is not null and netsuite_creds_id is not null +); + + +-- Count of all workspaces where qbo creds is not present, configuration is present and general mappings is present +select + 'QC=FALSE, C=TRUE, GM=TRUE' as settings, count(*) +from all_settings_view +where + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is null; + +--- Update all of the above to have onboarding state set to 'COMPLETE' +update workspaces +set + onboarding_state = 'COMPLETE' +where id in ( + select + workspace_id + from all_settings_view + where + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is null +); + + +-- Count of all workspaces where qbo creds are not present, configuration is present and general mappings are not present +select + 'QC=FALSE, C=TRUE, GM=FALSE' as settings, count(*) +from all_settings_view +where + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is null; + +--- Update all of the above to have onboarding state set to 'EXPORT_SETTINGS' +update workspaces +set + onboarding_state = 'EXPORT_SETTINGS' +where id in ( + select + workspace_id + from all_settings_view + where + configuration_id is not null and general_mappings_id is null and netsuite_creds_id is null +); From 798e2bc15a8a6f84bd648717317aedc1e3e46bd2 Mon Sep 17 00:00:00 2001 From: Nilesh Pant Date: Wed, 11 Oct 2023 15:32:19 +0530 Subject: [PATCH 2/8] tests migrations --- .../reset_db_fixtures/reset_db.sql | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql index 102f9570..9cdb94e4 100644 --- a/tests/sql_fixtures/reset_db_fixtures/reset_db.sql +++ b/tests/sql_fixtures/reset_db_fixtures/reset_db.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 15.4 (Debian 15.4-1.pgdg120+1) --- Dumped by pg_dump version 15.4 (Debian 15.4-1.pgdg100+1) +-- Dumped from database version 15.2 (Debian 15.2-1.pgdg110+1) +-- Dumped by pg_dump version 15.4 (Debian 15.4-2.pgdg100+1) SET statement_timeout = 0; SET lock_timeout = 0; @@ -1753,7 +1753,8 @@ CREATE TABLE public.workspaces ( source_synced_at timestamp with time zone, cluster_domain character varying(255), employee_exported_at timestamp with time zone NOT NULL, - ccc_last_synced_at timestamp with time zone + ccc_last_synced_at timestamp with time zone, + onboarding_state character varying(50) ); @@ -7706,6 +7707,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; 162 fyle 0025_auto_20230622_0516 2023-06-22 10:17:05.677561+00 163 django_q 0014_schedule_cluster 2023-07-17 14:43:54.845689+00 164 netsuite 0022_creditcardcharge_department_id 2023-07-26 10:31:38.187076+00 +165 workspaces 0033_workspace_onboarding_state 2023-10-11 09:59:47.359324+00 \. @@ -11486,10 +11488,10 @@ COPY public.workspace_schedules (id, enabled, start_datetime, interval_hours, wo -- Data for Name: workspaces; Type: TABLE DATA; Schema: public; Owner: postgres -- -COPY public.workspaces (id, name, fyle_org_id, ns_account_id, last_synced_at, created_at, updated_at, destination_synced_at, source_synced_at, cluster_domain, employee_exported_at, ccc_last_synced_at) FROM stdin; -1 Fyle For Arkham Asylum or79Cob97KSh TSTDRV2089588 2021-11-15 13:12:12.210053+00 2021-11-15 08:46:16.062858+00 2021-11-15 13:12:12.210769+00 2021-11-15 08:56:43.737724+00 2021-11-15 08:55:57.620811+00 https://staging.fyle.tech 2021-09-17 14:32:05.585557+00 \N -2 Fyle For IntacctNew Technologies oraWFQlEpjbb TSTDRV2089588 2021-11-16 04:25:49.067507+00 2021-11-16 04:16:57.840307+00 2021-11-16 04:25:49.067805+00 2021-11-16 04:18:28.233322+00 2021-11-16 04:17:43.950915+00 https://staging.fyle.tech 2021-11-17 14:32:05.585557+00 \N -49 Fyle For intacct-test orHe8CpW2hyN TSTDRV2089588 2021-12-03 11:26:58.663241+00 2021-12-03 11:00:33.634494+00 2021-12-03 11:26:58.664557+00 2021-12-03 11:04:27.847159+00 2021-12-03 11:03:52.560696+00 https://staging.fyle.tech 2021-11-17 14:32:05.585557+00 \N +COPY public.workspaces (id, name, fyle_org_id, ns_account_id, last_synced_at, created_at, updated_at, destination_synced_at, source_synced_at, cluster_domain, employee_exported_at, ccc_last_synced_at, onboarding_state) FROM stdin; +1 Fyle For Arkham Asylum or79Cob97KSh TSTDRV2089588 2021-11-15 13:12:12.210053+00 2021-11-15 08:46:16.062858+00 2021-11-15 13:12:12.210769+00 2021-11-15 08:56:43.737724+00 2021-11-15 08:55:57.620811+00 https://staging.fyle.tech 2021-09-17 14:32:05.585557+00 \N CONNECTION +2 Fyle For IntacctNew Technologies oraWFQlEpjbb TSTDRV2089588 2021-11-16 04:25:49.067507+00 2021-11-16 04:16:57.840307+00 2021-11-16 04:25:49.067805+00 2021-11-16 04:18:28.233322+00 2021-11-16 04:17:43.950915+00 https://staging.fyle.tech 2021-11-17 14:32:05.585557+00 \N CONNECTION +49 Fyle For intacct-test orHe8CpW2hyN TSTDRV2089588 2021-12-03 11:26:58.663241+00 2021-12-03 11:00:33.634494+00 2021-12-03 11:26:58.664557+00 2021-12-03 11:04:27.847159+00 2021-12-03 11:03:52.560696+00 https://staging.fyle.tech 2021-11-17 14:32:05.585557+00 \N CONNECTION \. @@ -11585,7 +11587,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 43, true); -- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres -- -SELECT pg_catalog.setval('public.django_migrations_id_seq', 164, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 165, true); -- From fdd7a9e20d2e7dfe79bc897b6585e5474b9feac3 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Wed, 11 Oct 2023 15:52:55 +0530 Subject: [PATCH 3/8] added onboarding state --- tests/test_workspaces/data.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_workspaces/data.json b/tests/test_workspaces/data.json index 367c79c8..27a52c14 100644 --- a/tests/test_workspaces/data.json +++ b/tests/test_workspaces/data.json @@ -38,6 +38,7 @@ "updated_at":"2021-11-10T20:41:37.151696Z", "employee_exported_at":"2021-11-10T20:41:37.151696Z", "ccc_last_synced_at": "2021-11-10T20:41:37.151680Z", + "onboarding_state": "COMPLETE", "user":[ 1 ] From 609594dd577750302534d29cd613fb26d504b466 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Thu, 12 Oct 2023 12:49:48 +0530 Subject: [PATCH 4/8] changed comment --- scripts/sql/scripts/019-add-onboarding-state.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/sql/scripts/019-add-onboarding-state.sql b/scripts/sql/scripts/019-add-onboarding-state.sql index c70bdd6f..5047856c 100644 --- a/scripts/sql/scripts/019-add-onboarding-state.sql +++ b/scripts/sql/scripts/019-add-onboarding-state.sql @@ -16,7 +16,7 @@ where w.onboarding_state = 'CONNECTION'; begin; -- Start Transaction Block --- Count of all workspaces where qbo creds are present, configuration is present and general mappings are present +-- Count of all workspaces where netsuite are present, configuration is present and general mappings are present select 'QC=TRUE, C=TRUE, GM=TRUE' as setting, count(*) from all_settings_view @@ -35,7 +35,7 @@ where id in ( configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null ); --- Count of all workspaces where qbo creds are present, configuration is present and general mappings are not present +-- Count of all workspaces where netsuite are present, configuration is present and general mappings are not present select 'QC=TRUE, C=TRUE, GM=FALSE' as settings, count(*) from all_settings_view @@ -55,7 +55,7 @@ where id in ( ); --- Count of all workspaces where qbo creds are present, configuration is not present and general mappings are not present +-- Count of all workspaces where netsuite are present, configuration is not present and general mappings are not present select 'QC=TRUE, C=FALSE, GM=FALSE' as settings, count(*) from all_settings_view @@ -75,7 +75,7 @@ where id in ( ); --- Count of all workspaces where qbo creds is not present, configuration is present and general mappings is present +-- Count of all workspaces where netsuite is not present, configuration is present and general mappings is present select 'QC=FALSE, C=TRUE, GM=TRUE' as settings, count(*) from all_settings_view @@ -95,7 +95,7 @@ where id in ( ); --- Count of all workspaces where qbo creds are not present, configuration is present and general mappings are not present +-- Count of all workspaces where netsuite are not present, configuration is present and general mappings are not present select 'QC=FALSE, C=TRUE, GM=FALSE' as settings, count(*) from all_settings_view From d15a8f5ae54d8d9d2ed724db70bd75fe50ddd63f Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Thu, 12 Oct 2023 13:23:16 +0530 Subject: [PATCH 5/8] added subsidiary state to onboarding state --- .../migrations/0034_auto_20231012_0750.py | 19 +++++++++++++++++++ apps/workspaces/models.py | 1 + 2 files changed, 20 insertions(+) create mode 100644 apps/workspaces/migrations/0034_auto_20231012_0750.py diff --git a/apps/workspaces/migrations/0034_auto_20231012_0750.py b/apps/workspaces/migrations/0034_auto_20231012_0750.py new file mode 100644 index 00000000..226e7c23 --- /dev/null +++ b/apps/workspaces/migrations/0034_auto_20231012_0750.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.14 on 2023-10-12 07:50 + +import apps.workspaces.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('workspaces', '0033_workspace_onboarding_state'), + ] + + operations = [ + migrations.AlterField( + model_name='workspace', + name='onboarding_state', + field=models.CharField(choices=[('CONNECTION', 'CONNECTION'), ('SUBSIDIARY', 'SUBSIDIARY'), ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), ('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 c501b73f..92e71072 100644 --- a/apps/workspaces/models.py +++ b/apps/workspaces/models.py @@ -14,6 +14,7 @@ ONBOARDING_STATE_CHOICES = ( ('CONNECTION', 'CONNECTION'), + ('SUBSIDIARY', 'SUBSIDIARY'), ('MAP_EMPLOYEES', 'MAP_EMPLOYEES'), ('EXPORT_SETTINGS', 'EXPORT_SETTINGS'), ('IMPORT_SETTINGS', 'IMPORT_SETTINGS'), From ec4f4d16de5aaad2bad4e14ae5986313b1453325 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Fri, 13 Oct 2023 13:19:19 +0530 Subject: [PATCH 6/8] changed script to add subsidiary state and fixed some bug --- .../sql/scripts/019-add-onboarding-state.sql | 78 ++++++++----------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/scripts/sql/scripts/019-add-onboarding-state.sql b/scripts/sql/scripts/019-add-onboarding-state.sql index 5047856c..6f485fa7 100644 --- a/scripts/sql/scripts/019-add-onboarding-state.sql +++ b/scripts/sql/scripts/019-add-onboarding-state.sql @@ -4,24 +4,27 @@ select w.id as workspace_id, wgs.id as configuration_id, gm.id as general_mappings_id, - qc.id as netsuite_creds_id + qc.id as netsuite_creds_id, + sm.id as subsidiary_id from workspaces w left join configurations wgs on w.id = wgs.workspace_id left join - netsuite_credentials qc on qc.workspace_id = w.id + netsuite_credentials nc on qc.workspace_id = w.id left join general_mappings gm on gm.workspace_id = w.id +left join + subsidiary_mappings sm on sm.workspace_id = w.id where w.onboarding_state = 'CONNECTION'; begin; -- Start Transaction Block -- Count of all workspaces where netsuite are present, configuration is present and general mappings are present select - 'QC=TRUE, C=TRUE, GM=TRUE' as setting, count(*) + 'NC=TRUE, C=TRUE, GM=TRUE, SM=True' as setting, count(*) from all_settings_view where - configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null; + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null and subsidiary_id is not null; --- Update all of the above to have onboarding state set to 'COMPLETE' update workspaces @@ -32,35 +35,34 @@ where id in ( workspace_id from all_settings_view where - configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null + configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null and subsidiary_id is not null ); --- Count of all workspaces where netsuite are present, configuration is present and general mappings are not present +-- Count of all workspaces where netsuite cred is present and general mapping and credentials and subsidiary are not present. select - 'QC=TRUE, C=TRUE, GM=FALSE' as settings, count(*) -from all_settings_view -where - configuration_id is not null and general_mappings_id is null and netsuite_creds_id is not null; + 'NC=TRUE, C=FALSE, GM=FALSE, SM=FALSE' as setting, count(*) +from all_settings_view +where + configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is null; ---- Update all of the above to have onboarding state set to 'EXPORT_SETTINGS' -update workspaces -set - onboarding_state = 'EXPORT_SETTINGS' +-- Update all of the above to have onboarding state set to 'SUBSIDIARY' +update workspaces +set + onboarding_state = 'SUBSIDIARY' where id in ( - select - workspace_id - from all_settings_view + select + workspace_id + from all_settings_view where - configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is not null + configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is null ); - --- Count of all workspaces where netsuite are present, configuration is not present and general mappings are not present +-- Count of all workspaces where netsuite cred and subsidiary are present, configuration is not present and general mappings are not present select - 'QC=TRUE, C=FALSE, GM=FALSE' as settings, count(*) + 'NC=TRUE, C=FALSE, GM=FALSE, SM=TRUE' as settings, count(*) from all_settings_view where - configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null; + configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null; --- Update all of the above to have onboarding state set to 'MAP_EMPLOYEES' update workspaces @@ -71,36 +73,16 @@ where id in ( workspace_id from all_settings_view where - configuration_id is null and general_mappings_id is not null and netsuite_creds_id is not null + configuration_id is null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null ); --- Count of all workspaces where netsuite is not present, configuration is present and general mappings is present +-- Count of all workspaces where netsuite are present, configuration is present, subsidiary is present and general mappings are not present select - 'QC=FALSE, C=TRUE, GM=TRUE' as settings, count(*) + 'NC=TRUE, C=TRUE, GM=FALSE, SM=TRUE' as settings, count(*) from all_settings_view where - configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is null; - ---- Update all of the above to have onboarding state set to 'COMPLETE' -update workspaces -set - onboarding_state = 'COMPLETE' -where id in ( - select - workspace_id - from all_settings_view - where - configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is null -); - - --- Count of all workspaces where netsuite are not present, configuration is present and general mappings are not present -select - 'QC=FALSE, C=TRUE, GM=FALSE' as settings, count(*) -from all_settings_view -where - configuration_id is not null and general_mappings_id is not null and netsuite_creds_id is null; + configuration_id is not null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null; --- Update all of the above to have onboarding state set to 'EXPORT_SETTINGS' update workspaces @@ -111,5 +93,7 @@ where id in ( workspace_id from all_settings_view where - configuration_id is not null and general_mappings_id is null and netsuite_creds_id is null + configuration_id is not null and general_mappings_id is null and netsuite_creds_id is not null and subsidiary_id is not null ); + + From 67ddf5997d4064591f4b69e325c7ebffcee5b253 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Fri, 13 Oct 2023 17:15:42 +0530 Subject: [PATCH 7/8] bug fix --- scripts/sql/scripts/019-add-onboarding-state.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sql/scripts/019-add-onboarding-state.sql b/scripts/sql/scripts/019-add-onboarding-state.sql index 6f485fa7..a57f04e6 100644 --- a/scripts/sql/scripts/019-add-onboarding-state.sql +++ b/scripts/sql/scripts/019-add-onboarding-state.sql @@ -4,13 +4,13 @@ select w.id as workspace_id, wgs.id as configuration_id, gm.id as general_mappings_id, - qc.id as netsuite_creds_id, + nc.id as netsuite_creds_id, sm.id as subsidiary_id from workspaces w left join configurations wgs on w.id = wgs.workspace_id left join - netsuite_credentials nc on qc.workspace_id = w.id + netsuite_credentials nc on nc.workspace_id = w.id left join general_mappings gm on gm.workspace_id = w.id left join From 3bce53863f5f941d1735d4422f4b8c0f1926c5a2 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Mon, 16 Oct 2023 13:13:09 +0530 Subject: [PATCH 8/8] state change on connection and subsidiary change --- apps/mappings/signals.py | 10 +++++++++- apps/workspaces/views.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/mappings/signals.py b/apps/mappings/signals.py index 58b45385..220049f8 100644 --- a/apps/mappings/signals.py +++ b/apps/mappings/signals.py @@ -14,9 +14,17 @@ from apps.workspaces.models import Configuration from apps.workspaces.tasks import delete_cards_mapping_settings -from .models import GeneralMapping +from .models import GeneralMapping, SubsidiaryMapping from .tasks import schedule_auto_map_ccc_employees + +@receiver(post_save, sender=SubsidiaryMapping) +def run_post_subsidiary_mappings(sender, instance: SubsidiaryMapping, **kwargs): + + workspace = instance.workspace + workspace.onboarding_state = 'MAP_EMPLOYEES' + workspace.save() + @receiver(post_save, sender=MappingSetting) def run_post_mapping_settings_triggers(sender, instance: MappingSetting, **kwargs): """ diff --git a/apps/workspaces/views.py b/apps/workspaces/views.py index af40dab8..dc67116b 100644 --- a/apps/workspaces/views.py +++ b/apps/workspaces/views.py @@ -175,6 +175,7 @@ def post(self, request, **kwargs): workspace=workspace ) workspace.ns_account_id = ns_account_id + workspace.onboarding_state = 'SUBSIDIARY' workspace.save() else: