-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added integrations_imports submodule, made changes in settings (#310) * Refactor imports for Project resource (#311) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Project: added cluster import, fixed minor typo, added new supplier field * Refactor imports for project and cost_center (#314) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Project: added cluster import, fixed minor typo, added new supplier field * Refactor imports costcenter (#312) * Resource Cost_Center: refactored imports * Refactor imports for Project resource (#311) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Project: added cluster import, fixed minor typo, added new supplier field * Refactor imports custom expense (#313) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Cost_Center: refactored imports * Resource Custom Expense Field: refactored imports * Resource Project: added cluster import, fixed minor typo, added new supplier field * Resource Tax Group: refactored imports (#315) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Cost_Center: refactored imports * Resource Custom Expense Field: refactored imports * Resource Project: added cluster import, fixed minor typo, added new supplier field * Resource Tax Group: refactored imports * Resource Tax Group: changed to is_auto_sync to False by default * Resource Category: refactored imports (#316) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Cost_Center: refactored imports * Resource Custom Expense Field: refactored imports * Resource Tax Group: refactored imports * Resource Category: refactored imports * Resource Category: changed is_auto_sync_enabled to True by default * Refactor imports supplier (#318) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Cost_Center: refactored imports * Resource Custom Expense Field: refactored imports * Resource Tax Group: refactored imports * Resource Category: refactored imports * Added RetryException handler and bumped the sdk versions (#306) * Set tasks limit to 1L (#317) * Set tasks limit to 1L * set timeout * Modified the import schedule creation condition --------- Co-authored-by: ruuushhh <[email protected]> * Refactor old flow (#321) * Added integrations_imports submodule, made changes in settings * Resource Project: Added new flow for the Project Import * Typo Fix * Resource Project: removed old import logic for Project * Resource Cost_Center: refactored imports * Resource Custom Expense Field: refactored imports * Resource Tax Group: refactored imports * Resource Category: refactored imports * Added RetryException handler and bumped the sdk versions (#306) * Set tasks limit to 1L (#317) * Set tasks limit to 1L * set timeout * Modified the import schedule creation condition * Removed dead code, add few test cases, added script for adding new schedule for different workspaces * Added post deploy sql script to dump old schedules and delete --------- Co-authored-by: ruuushhh <[email protected]> * Merged changes from master * Update delete workspace func (#319) * Update delete workspace func * Fix comments * upate workspace last synced fix (#320) * Modified the workflow for submodule * Decreased the coverage to 88% --------- Co-authored-by: ruuushhh <[email protected]>
- Loading branch information
1 parent
60ccb7e
commit 7702403
Showing
33 changed files
with
8,435 additions
and
1,419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "fyle_integrations_imports"] | ||
path = fyle_integrations_imports | ||
url = [email protected]:fylein/fyle_integrations_imports.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,14 @@ | ||
from datetime import datetime | ||
|
||
from django_q.models import Schedule | ||
from fyle_accounting_mappings.models import MappingSetting | ||
|
||
from apps.fyle.enums import FyleAttributeEnum | ||
from apps.workspaces.models import WorkspaceGeneralSettings | ||
|
||
|
||
def schedule_or_delete_fyle_import_tasks(configuration: WorkspaceGeneralSettings): | ||
def is_auto_sync_allowed(workspace_general_settings: WorkspaceGeneralSettings, mapping_setting: MappingSetting = None): | ||
""" | ||
:param configuration: WorkspaceGeneralSettings Instance | ||
:return: None | ||
Get the auto sync permission | ||
:return: bool | ||
""" | ||
project_mapping = MappingSetting.objects.filter( | ||
source_field=FyleAttributeEnum.PROJECT, workspace_id=configuration.workspace_id | ||
).first() | ||
if ( | ||
configuration.import_categories | ||
or (project_mapping and project_mapping.import_to_fyle) | ||
or configuration.import_suppliers_as_merchants | ||
): | ||
start_datetime = datetime.now() | ||
Schedule.objects.update_or_create( | ||
func="apps.mappings.tasks.auto_import_and_map_fyle_fields", | ||
cluster='import', | ||
args="{}".format(configuration.workspace_id), | ||
defaults={ | ||
"schedule_type": Schedule.MINUTES, | ||
"minutes": 24 * 60, | ||
"next_run": start_datetime, | ||
}, | ||
) | ||
elif ( | ||
not configuration.import_categories | ||
and not (project_mapping and project_mapping.import_to_fyle) | ||
and not configuration.import_suppliers_as_merchants | ||
): | ||
Schedule.objects.filter( | ||
func="apps.mappings.tasks.auto_import_and_map_fyle_fields", | ||
args="{}".format(configuration.workspace_id), | ||
).delete() | ||
is_auto_sync_status_allowed = False | ||
if (mapping_setting and mapping_setting.destination_field == 'CUSTOMER' and mapping_setting.source_field == 'PROJECT') or workspace_general_settings.import_categories: | ||
is_auto_sync_status_allowed = True | ||
|
||
return is_auto_sync_status_allowed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from datetime import datetime | ||
from typing import List, Dict | ||
from apps.workspaces.models import WorkspaceGeneralSettings | ||
from django_q.models import Schedule | ||
from fyle_accounting_mappings.models import MappingSetting | ||
|
||
|
||
def new_schedule_or_delete_fyle_import_tasks( | ||
workspace_general_settings_instance: WorkspaceGeneralSettings, | ||
mapping_settings: List[Dict] | ||
): | ||
""" | ||
Schedule or delete fyle import tasks based on the | ||
workspace general settings and mapping settings | ||
:param workspace_general_settings_instance: WorkspaceGeneralSettings instance | ||
:param mapping_settings: List of mapping settings | ||
:return: None | ||
""" | ||
# short-hand notation, it returns True as soon as it encounters import_to_fyle as True | ||
task_to_be_scheduled = any(mapping_setting['import_to_fyle'] for mapping_setting in mapping_settings) | ||
|
||
if ( | ||
task_to_be_scheduled | ||
or workspace_general_settings_instance.import_customers | ||
or workspace_general_settings_instance.import_tax_codes | ||
or workspace_general_settings_instance.import_categories | ||
or workspace_general_settings_instance.import_suppliers_as_merchants | ||
): | ||
Schedule.objects.update_or_create( | ||
func='apps.mappings.queue.construct_tasks_and_chain_import_fields_to_fyle', | ||
args='{}'.format(workspace_general_settings_instance.workspace_id), | ||
defaults={ | ||
'schedule_type':Schedule.MINUTES, | ||
'minutes': 24 * 60, | ||
'next_run': datetime.now(), | ||
'cluster': 'import' | ||
} | ||
) | ||
else: | ||
import_fields_count = MappingSetting.objects.filter( | ||
workspace_id=workspace_general_settings_instance.workspace_id, | ||
import_to_fyle=True | ||
).count() | ||
|
||
# if there are no import fields, delete the schedule | ||
if import_fields_count == 0: | ||
Schedule.objects.filter( | ||
func='apps.mappings.queue.construct_tasks_and_chain_import_fields_to_fyle', | ||
args='{}'.format(workspace_general_settings_instance.workspace_id) | ||
).delete() |
Oops, something went wrong.