def async_auto_map_employees(workspace_id: int): try: employee_mapping_preference = WorkspaceGeneralSettings.objects.get( workspace_id=workspace_id).auto_map_employees fyle_credentials = FyleCredential.objects.get( workspace_id=workspace_id) fyle_connection = FyleConnector( refresh_token=fyle_credentials.refresh_token, workspace_id=workspace_id) xero_credentials = XeroCredentials.objects.get( workspace_id=workspace_id) xero_connection = XeroConnector(xero_credentials, workspace_id=workspace_id) fyle_connection.sync_employees() xero_connection.sync_contacts() Mapping.auto_map_employees('CONTACT', employee_mapping_preference, workspace_id) except XeroCredentials.DoesNotExist: logger.error( 'Xero Credentials not found for workspace_id %s', workspace_id, )
def async_auto_map_employees(workspace_id: int): general_settings = WorkspaceGeneralSettings.objects.get( workspace_id=workspace_id) employee_mapping_preference = general_settings.auto_map_employees mapping_setting = MappingSetting.objects.filter( ~Q(destination_field='CREDIT_CARD_ACCOUNT'), source_field='EMPLOYEE', workspace_id=workspace_id).first() destination_type = mapping_setting.destination_field fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id) fyle_connection = FyleConnector( refresh_token=fyle_credentials.refresh_token, workspace_id=workspace_id) qbo_credentials = QBOCredential.objects.get(workspace_id=workspace_id) qbo_connection = QBOConnector(credentials_object=qbo_credentials, workspace_id=workspace_id) fyle_connection.sync_employees() if destination_type == 'EMPLOYEE': qbo_connection.sync_employees() else: qbo_connection.sync_vendors() Mapping.auto_map_employees(destination_type, employee_mapping_preference, workspace_id)
def async_auto_map_ccc_account(workspace_id: str): general_mappings = GeneralMapping.objects.get(workspace_id=workspace_id) default_ccc_account_id = general_mappings.default_ccc_account_id if default_ccc_account_id: fyle_credentials = FyleCredential.objects.get( workspace_id=workspace_id) fyle_connection = FyleConnector( refresh_token=fyle_credentials.refresh_token, workspace_id=workspace_id) fyle_connection.sync_employees() Mapping.auto_map_ccc_employees('CREDIT_CARD_ACCOUNT', default_ccc_account_id, workspace_id)