Skip to content

Commit

Permalink
Updating last successful run to null when other types imported (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shwetabhk authored Feb 2, 2024
1 parent 41d9f8d commit fa29e9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions apps/workspaces/apis/import_settings/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import transaction
from fyle_accounting_mappings.models import MappingSetting
from fyle_integrations_imports.models import ImportLog
from rest_framework import serializers

from apps.mappings.models import GeneralMapping
Expand Down Expand Up @@ -81,6 +82,15 @@ def update(self, instance, validated):
general_mappings = validated.pop('general_mappings')
mapping_settings = validated.pop('mapping_settings')

# Check if there is a diff in charts of accounts
# Update the last_successful_run_at to None for Category Import Log
if workspace_general_settings.get('charts_of_accounts') != instance.workspace_general_settings.charts_of_accounts:
category_import_log = ImportLog.objects.filter(workspace_id=instance.id, attribute_type='CATEGORY').first()

if category_import_log:
category_import_log.last_successful_run_at = None
category_import_log.save()

workspace_general_settings_instance, _ = WorkspaceGeneralSettings.objects.update_or_create(
workspace=instance,
defaults={
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
data = {
'import_settings': {
'workspace_general_settings': {'import_categories': True, 'import_items': True, 'charts_of_accounts': ['Expense'], 'import_tax_codes': True, 'import_vendors_as_merchants': True},
'workspace_general_settings': {'import_categories': True, 'import_items': True, 'charts_of_accounts': ['Expense', 'Cost of Goods Sold'], 'import_tax_codes': True, 'import_vendors_as_merchants': True},
'general_mappings': {'default_tax_code': {'name': '12.5% TR @12.5%', 'id': '22'}},
'mapping_settings': [
{'source_field': 'COST_CENTER', 'destination_field': 'DEPARTMENT', 'import_to_fyle': True, 'is_custom': False, 'source_placeholder': 'cost center'},
Expand Down

0 comments on commit fa29e9c

Please sign in to comment.