-
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.
* Import base files added * Import Categories support added (#40) * Import Categories support added * Import merchants support added (#41) * Import merchants support added * Import cost centers support added (#42) * Import cost centers support added * Import project support added (#43) * Import project support added * Schedule, queues signals configured (#44) * Schedule, queues signals configured * Imports bugs fixed (#45) * Imports bugs fixed * Comments resolved
- Loading branch information
Showing
14 changed files
with
1,103 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import logging | ||
import traceback | ||
|
||
from dynamics.exceptions.dynamics_exceptions import InvalidTokenError | ||
from fyle.platform.exceptions import InternalServerError | ||
from fyle.platform.exceptions import InvalidTokenError as FyleInvalidTokenError | ||
from fyle.platform.exceptions import WrongParamsError | ||
|
||
from apps.mappings.models import ImportLog | ||
from apps.workspaces.models import BusinessCentralCredentials | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.level = logging.INFO | ||
|
||
|
||
def handle_import_exceptions(func): | ||
def new_fn(expense_attribute_instance, *args): | ||
import_log: ImportLog = args[0] | ||
workspace_id = import_log.workspace_id | ||
attribute_type = import_log.attribute_type | ||
error = { | ||
'task': 'Import {0} to Fyle and Auto Create Mappings'.format(attribute_type), | ||
'workspace_id': workspace_id, | ||
'message': None, | ||
'response': None | ||
} | ||
try: | ||
return func(expense_attribute_instance, *args) | ||
except WrongParamsError as exception: | ||
error['message'] = exception.message | ||
error['response'] = exception.response | ||
error['alert'] = True | ||
import_log.status = 'FAILED' | ||
|
||
except (BusinessCentralCredentials.DoesNotExist, InvalidTokenError): | ||
error['message'] = 'Invalid Token or Business central credentials does not exist workspace_id - {0}'.format(workspace_id) | ||
error['alert'] = False | ||
import_log.status = 'FAILED' | ||
|
||
except FyleInvalidTokenError: | ||
error['message'] = 'Invalid Token for fyle' | ||
error['alert'] = False | ||
import_log.status = 'FAILED' | ||
|
||
except InternalServerError: | ||
error['message'] = 'Internal server error while importing to Fyle' | ||
error['alert'] = True | ||
import_log.status = 'FAILED' | ||
|
||
except Exception: | ||
response = traceback.format_exc() | ||
error['message'] = 'Something went wrong' | ||
error['response'] = response | ||
error['alert'] = False | ||
import_log.status = 'FATAL' | ||
|
||
if error['alert']: | ||
logger.error(error) | ||
else: | ||
logger.info(error) | ||
|
||
import_log.error_log = error | ||
import_log.save() | ||
|
||
return new_fn |
Empty file.
Oops, something went wrong.