From ba44620febfaa104f6693b2b34e8cc0788f3098d Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Wed, 30 Oct 2024 14:02:25 +0530 Subject: [PATCH 1/4] feat: Add objectLabel as attribute type for user defined dimensions --- apps/sage_intacct/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sage_intacct/utils.py b/apps/sage_intacct/utils.py index f58749a8..7c6bc90d 100644 --- a/apps/sage_intacct/utils.py +++ b/apps/sage_intacct/utils.py @@ -630,13 +630,13 @@ def sync_user_defined_dimensions(self): for dimension in dimensions: if dimension['userDefinedDimension'] == 'true': dimension_attributes = [] - dimension_name = dimension['objectName'] + dimension_name = dimension['objectLabel'] dimension_values = self.connection.dimension_values.get_all(dimension_name) for value in dimension_values: dimension_attributes.append({ 'attribute_type': dimension_name, - 'display_name': dimension_name.lower().replace('_', ' '), + 'display_name': dimension_name, 'value': value['name'], 'destination_id': value['id'], 'active': True From ea2a034ce05b92aa3b1a466dbd0c78303e746cab Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Wed, 30 Oct 2024 14:20:21 +0530 Subject: [PATCH 2/4] comment resolved --- apps/sage_intacct/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sage_intacct/utils.py b/apps/sage_intacct/utils.py index 7c6bc90d..9add160a 100644 --- a/apps/sage_intacct/utils.py +++ b/apps/sage_intacct/utils.py @@ -630,13 +630,13 @@ def sync_user_defined_dimensions(self): for dimension in dimensions: if dimension['userDefinedDimension'] == 'true': dimension_attributes = [] - dimension_name = dimension['objectLabel'] + dimension_name = dimension['objectLabel'].upper().replace(" ", "_") dimension_values = self.connection.dimension_values.get_all(dimension_name) for value in dimension_values: dimension_attributes.append({ 'attribute_type': dimension_name, - 'display_name': dimension_name, + 'display_name': dimension['objectLabel'], 'value': value['name'], 'destination_id': value['id'], 'active': True From 1a18e43b80078c380ff8f128d8cc4e39203884c7 Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Wed, 30 Oct 2024 17:06:05 +0530 Subject: [PATCH 3/4] added script for wrong attributes in DB --- ...e-user-defined-dimension-attribute-type.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 scripts/python/update-user-defined-dimension-attribute-type.py diff --git a/scripts/python/update-user-defined-dimension-attribute-type.py b/scripts/python/update-user-defined-dimension-attribute-type.py new file mode 100644 index 00000000..bfff65a6 --- /dev/null +++ b/scripts/python/update-user-defined-dimension-attribute-type.py @@ -0,0 +1,44 @@ +from django.db.models import Q +from apps.workspaces.models import Workspace +from fyle_accounting_mappings.models import DestinationAttribute, MappingSetting + + +wrong_attributes = { + 254: { + "objectName": "WORK_LOCATION_UDD", + "objectLabel": "Work Location", + }, + 255: { + "objectName": "WORK_LOCATION_UDD", + "objectLabel": "Work Location", + }, + 256: { + "objectName": "WORK_LOCATION_UDD", + "objectLabel": "Work Location", + }, + 537: { + "objectName": "UDD_RESTRICTION", + "objectLabel": "Restriction", + }, + 635: { + "objectName": "RESTRICTION_UDD", + "objectLabel": "Restriction", + }, + 640: { + "objectName": "RESTRICTION_UDD", + "objectLabel": "Restriction", + }, +} + +for workspace_id, attributes in wrong_attributes.items(): + formatted_attribute_type = attributes["objectLabel"].upper().replace(" ", "_") + + DestinationAttribute.objects.filter( + workspace_id=workspace_id, attribute_type=attributes["objectName"] + ).update( + attribute_type=formatted_attribute_type, display_name=attributes["objectLabel"] + ) + + MappingSetting.objects.filter( + workspace_id=workspace_id, destination_field=attributes["objectName"] + ).update(destination_field=formatted_attribute_type) From 33e788972c38fa5d3501d07d648b7372996a8def Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Mon, 4 Nov 2024 13:44:28 +0530 Subject: [PATCH 4/4] Fix for user defined dimension issue --- apps/sage_intacct/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sage_intacct/utils.py b/apps/sage_intacct/utils.py index 9add160a..2afb770b 100644 --- a/apps/sage_intacct/utils.py +++ b/apps/sage_intacct/utils.py @@ -631,7 +631,7 @@ def sync_user_defined_dimensions(self): if dimension['userDefinedDimension'] == 'true': dimension_attributes = [] dimension_name = dimension['objectLabel'].upper().replace(" ", "_") - dimension_values = self.connection.dimension_values.get_all(dimension_name) + dimension_values = self.connection.dimension_values.get_all(dimension['objectName']) for value in dimension_values: dimension_attributes.append({