From 66bc88cc196f81d4b7696d08b759aef8571d9929 Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari <74908943+Hrishabh17@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:18:54 +0530 Subject: [PATCH 1/3] add migration file (#115) --- .../0026_destinationattribute_code.py | 18 ++++++++++++++++++ setup.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 fyle_accounting_mappings/migrations/0026_destinationattribute_code.py diff --git a/fyle_accounting_mappings/migrations/0026_destinationattribute_code.py b/fyle_accounting_mappings/migrations/0026_destinationattribute_code.py new file mode 100644 index 0000000..fcad129 --- /dev/null +++ b/fyle_accounting_mappings/migrations/0026_destinationattribute_code.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.2 on 2024-08-20 08:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fyle_accounting_mappings', '0025_expenseattributesdeletioncache'), + ] + + operations = [ + migrations.AddField( + model_name='destinationattribute', + name='code', + field=models.CharField(help_text='Code of the attribute', max_length=255, null=True), + ), + ] diff --git a/setup.py b/setup.py index d39f30f..7309456 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='fyle-accounting-mappings', - version='1.34.1', + version='1.34.2', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Django application to store the fyle accounting mappings in a generic manner', From 49354ff85069af138489334ae6ff12c9c251759d Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari <74908943+Hrishabh17@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:08:15 +0530 Subject: [PATCH 2/3] fix: attribute disable only if import to fyle is true (#117) --- fyle_accounting_mappings/models.py | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fyle_accounting_mappings/models.py b/fyle_accounting_mappings/models.py index df8518e..e60afdb 100644 --- a/fyle_accounting_mappings/models.py +++ b/fyle_accounting_mappings/models.py @@ -327,6 +327,7 @@ def bulk_create_or_update_destination_attributes( update: bool = False, display_name: str = None, attribute_disable_callback_path: str = None, + is_import_to_fyle_enabled: bool = False ): """ Create Destination Attributes in bulk @@ -392,7 +393,7 @@ def bulk_create_or_update_destination_attributes( ) ) else: - if attribute_disable_callback_path and ( + if attribute_disable_callback_path and is_import_to_fyle_enabled and ( (attribute['value'] != primary_key_map[attribute['destination_id']]['value']) or ('code' in attribute and attribute['code'] != primary_key_map[attribute['destination_id']]['code']) ): @@ -421,7 +422,7 @@ def bulk_create_or_update_destination_attributes( ) if attribute_disable_callback_path and attributes_to_disable: - import_string(attribute_disable_callback_path)(workspace_id, attributes_to_disable) + import_string(attribute_disable_callback_path)(workspace_id, attributes_to_disable, is_import_to_fyle_enabled) if attributes_to_be_created: DestinationAttribute.objects.bulk_create(attributes_to_be_created, batch_size=50) @@ -448,7 +449,6 @@ class Meta: db_table = 'expense_fields' unique_together = ('attribute_type', 'workspace_id') - @staticmethod def create_or_update_expense_fields(attributes: List[Dict], fields_included: List[str], workspace_id): """ diff --git a/setup.py b/setup.py index 7309456..7f471b9 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='fyle-accounting-mappings', - version='1.34.2', + version='1.34.3', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Django application to store the fyle accounting mappings in a generic manner', From 99160497797b5812fe1590391f1876f1e2e99c1b Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari <74908943+Hrishabh17@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:22:48 +0530 Subject: [PATCH 3/3] Fix attribute disable (#118) * fix: attribute disable only if import to fyle is true * add check for code null * add lower case check --- fyle_accounting_mappings/models.py | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fyle_accounting_mappings/models.py b/fyle_accounting_mappings/models.py index e60afdb..4709ade 100644 --- a/fyle_accounting_mappings/models.py +++ b/fyle_accounting_mappings/models.py @@ -394,8 +394,8 @@ def bulk_create_or_update_destination_attributes( ) else: if attribute_disable_callback_path and is_import_to_fyle_enabled and ( - (attribute['value'] != primary_key_map[attribute['destination_id']]['value']) - or ('code' in attribute and attribute['code'] != primary_key_map[attribute['destination_id']]['code']) + (attribute['value'] and primary_key_map[attribute['destination_id']]['value'] and attribute['value'].lower() != primary_key_map[attribute['destination_id']]['value'].lower()) + or ('code' in attribute and attribute['code'] and attribute['code'] != primary_key_map[attribute['destination_id']]['code']) ): attributes_to_disable[attribute['destination_id']] = { 'value': primary_key_map[attribute['destination_id']]['value'], @@ -408,7 +408,7 @@ def bulk_create_or_update_destination_attributes( (attribute['value'] != primary_key_map[attribute['destination_id']]['value']) or ('detail' in attribute and attribute['detail'] != primary_key_map[attribute['destination_id']]['detail']) or ('active' in attribute and attribute['active'] != primary_key_map[attribute['destination_id']]['active']) - or ('code' in attribute and attribute['code'] != primary_key_map[attribute['destination_id']]['code']) + or ('code' in attribute and attribute['code'] and attribute['code'] != primary_key_map[attribute['destination_id']]['code']) ): attributes_to_be_updated.append( DestinationAttribute( diff --git a/setup.py b/setup.py index 7f471b9..affe963 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='fyle-accounting-mappings', - version='1.34.3', + version='1.34.4', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Django application to store the fyle accounting mappings in a generic manner',