示例#1
0
def load_attachments(qbo_connection: QBOConnector, ref_id: str, ref_type: str,
                     expense_group: ExpenseGroup):
    """
    Get attachments from fyle
    :param qbo_connection: QBO Connection
    :param ref_id: object id
    :param ref_type: type of object
    :param expense_group: Expense group
    """
    try:
        fyle_credentials = FyleCredential.objects.get(
            workspace_id=expense_group.workspace_id)
        expense_ids = expense_group.expenses.values_list('expense_id',
                                                         flat=True)
        fyle_connector = FyleConnector(fyle_credentials.refresh_token,
                                       expense_group.workspace_id)
        attachments = fyle_connector.get_attachments(expense_ids)
        qbo_connection.post_attachments(ref_id, ref_type, attachments)
    except Exception:
        error = traceback.format_exc()
        logger.error(
            'Attachment failed for expense group id %s / workspace id %s \n Error: %s',
            expense_group.id, expense_group.workspace_id, {'error': error})
示例#2
0
def load_attachments(sage_intacct_connection: SageIntacctConnector, key: str,
                     expense_group: ExpenseGroup):
    """
    Get attachments from fyle
    :param sage_intacct_connection: Sage Intacct Connection
    :param key: expense report / bills key
    :param expense_group: Expense group
    """
    try:
        fyle_credentials = FyleCredential.objects.get(
            workspace_id=expense_group.workspace_id)
        expense_ids = expense_group.expenses.values_list('expense_id',
                                                         flat=True)
        fyle_connector = FyleConnector(fyle_credentials.refresh_token,
                                       expense_group.workspace_id)
        claim_number = expense_group.description.get('claim_number')
        attachments = fyle_connector.get_attachments(expense_ids)
        return sage_intacct_connection.post_attachments(
            attachments, claim_number)
    except Exception:
        error = traceback.format_exc()
        logger.error(
            'Attachment failed for expense group id %s / workspace id %s \n Error: %s',
            expense_group.id, expense_group.workspace_id, error)