Пример #1
0
    def get_expense_history(self, resp):
        """This method parses the json object and returns expense history list.

        Args:
            resp(dict): Response containing json object for expense history.

        Returns:
            instance: Expenses list object.

        """
        expenses_list = ExpenseList()
        for value in resp['expensehistory']:
            expense = Expense()
            expense.set_expense_id(value['expense_id'])
            expense.set_date(value['date'])
            expense.set_account_name(value['account_name'])
            expense.set_vendor_name(value['vendor_name'])
            expense.set_paid_through_account_name(\
            value['paid_through_account_name'])
            expense.set_customer_name(value['customer_name'])
            expense.set_total(value['total'])
            expense.set_status(value['status'])
            expenses_list.set_expenses(expense)
        page_context_obj = PageContext()
        page_context = resp['page_context']
        page_context_obj.set_page(page_context['page'])
        page_context_obj.set_per_page(page_context['per_page'])
        page_context_obj.set_has_more_page(page_context['has_more_page'])
        page_context_obj.set_report_name(page_context['report_name'])
        page_context_obj.set_sort_column(page_context['sort_column'])
        page_context_obj.set_sort_order(page_context['sort_order'])
        expenses_list.set_page_context(page_context_obj)
        return expenses_list
    def get_expense(self, resp):  
        """This method parses the given response and returns expense object.

        Args:
            resp(dict): Response containing json object for expense.

        Returns:
            instance: Expense object.

        """
        expense = resp['expense']
        expense_obj = Expense()
        expense_obj.set_expense_id(expense['expense_id'])
        expense_obj.set_expense_item_id(expense['expense_item_id'])
        expense_obj.set_account_id(expense['account_id'])
        expense_obj.set_account_name(expense['account_name'])
        expense_obj.set_paid_through_account_id(expense[\
        'paid_through_account_id'])
        expense_obj.set_paid_through_account_name(expense[\
        'paid_through_account_name'])
        expense_obj.set_vendor_id(expense['vendor_id'])
        expense_obj.set_vendor_name(expense['vendor_name'])
        expense_obj.set_date(expense['date'])
        expense_obj.set_tax_id(expense['tax_id'])
        expense_obj.set_tax_name(expense['tax_name'])
        expense_obj.set_tax_percentage(expense['tax_percentage'])
        expense_obj.set_currency_id(expense['currency_id'])
        expense_obj.set_currency_code(expense['currency_code'])
        expense_obj.set_exchange_rate(expense['exchange_rate'])
        expense_obj.set_tax_amount(expense['tax_amount'])
        expense_obj.set_sub_total(expense['sub_total'])
        expense_obj.set_total(expense['total'])
        expense_obj.set_bcy_total(expense['bcy_total'])
        expense_obj.set_amount(expense['amount'])
        expense_obj.set_is_inclusive_tax(expense['is_inclusive_tax'])
        expense_obj.set_reference_number(expense['reference_number'])
        expense_obj.set_description(expense['description'])
        expense_obj.set_is_billable(expense['is_billable'])
        expense_obj.set_customer_id(expense['customer_id'])
        expense_obj.set_customer_name(expense['customer_name'])
        expense_obj.set_expense_receipt_name(expense['expense_receipt_name'])
        expense_obj.set_created_time(expense['created_time'])
        expense_obj.set_last_modified_time(expense['last_modified_time'])
        expense_obj.set_status(expense['status'])
        expense_obj.set_invoice_id(expense['invoice_id'])
        expense_obj.set_invoice_number(expense['invoice_number'])
        expense_obj.set_project_id(expense['project_id'])
        expense_obj.set_project_name(expense['project_name'])
        return expense_obj
Пример #3
0
customer_payments.set_date('2014-04-28')
customer_payments.set_reference_number('')
customer_payments.set_exchange_rate(1.0)
customer_payments.set_amount(10.0)
customer_payments.set_bank_charges(0.0)
customer_payments.set_tax_account_id('')
customer_payments.set_account_id(account_id)

contact_ids = contact_api.get_contacts().get_contacts()[1].get_contact_id()

print bank_transaction_api.categorize_as_customer_payment(transaction_id,customer_payments)
print bank_transaction_api.categorize_as_customer_payment(transaction_id,customer_payments,contact_ids)

# Categorize as expense

expense = Expense()
expense.set_account_id(account_id)
expense.set_paid_through_account_id('')
expense.set_amount(200.0)
expense.set_date('2014-04-28')
expense.set_is_inclusive_tax(False)
expense.set_is_billable(True)
expense.set_reference_number('2')
expense.set_description('')
expense.set_customer_id(customer_id)
expense.set_vendor_id(vendor_id)
expense.set_currency_id('currency_id)
expense.set_exchange_rate(20.0)
expense.set_project_id('')
receipt = '/{file_directory}/download.jpg'
print bank_transaction_api.categorize_as_expense(transaction_id,expense)
vendor_id = vendor_api.get_vendor_payments().get_vendor_payments(
)[0].get_vendor_id()

# List Expenses

parameters = {'filter_by': 'Status.Unbilled'}
print expenses_api.get_expenses()
print expenses_api.get_expenses(parameters)

# Get an expense

print expenses_api.get(expense_id)

# Create an expense

expenses = Expense()
expenses.set_account_id(expense_account_id)
expenses.set_paid_through_account_id(account_id)
expenses.set_date("2012-12-30")
expenses.set_amount(100.0)
expenses.set_tax_id("71127000000077019")
expenses.set_is_inclusive_tax(True)
expenses.set_is_billable(True)
expenses.set_customer_id(customer_id)
expenses.set_vendor_id(vendor_id)
expenses.set_currency_id(currency_id)
#expenses.set_exchange_rate()
#expenses.set_project_id()

print expenses_api.create(expenses)
receipt = "/{file_directory}/download.jpg"
    def get_list(self, resp): 
        """This method parses the given response and returns Expense list 
            object.

        Args:
            resp(dict): Response containing json object for Expenses list.
        
        Returns:
            instance: Expenses list object.

        """
        expenses = resp['expenses']
        expense_list = ExpenseList()
        for value in expenses:
            expense = Expense()
            expense.set_expense_id(value['expense_id'])
            expense.set_date(value['date'])
            expense.set_account_name(value['account_name'])
            expense.set_paid_through_account_name(value[\
            'paid_through_account_name'])
            expense.set_description(value['description'])
            expense.set_currency_id(value['currency_id'])
            expense.set_currency_code(value['currency_code'])
            expense.set_bcy_total(value['bcy_total'])
            expense.set_total(value['total'])
            expense.set_is_billable(value['is_billable'])
            expense.set_reference_number(value['reference_number'])
            expense.set_customer_id(value['customer_id'])
            expense.set_customer_name(value['customer_name'])
            expense.set_vendor_id(value['vendor_id'])
            expense.set_vendor_name(value['vendor_name'])
            expense.set_status(value['status'])
            expense.set_created_time(value['created_time'])
            expense.set_expense_receipt_name(value['expense_receipt_name'])
            expense_list.set_expenses(expense)
        page_context_obj = PageContext()
        page_context = resp['page_context']
        page_context_obj.set_page(page_context['page'])
        page_context_obj.set_per_page(page_context['per_page'])
        page_context_obj.set_has_more_page(page_context['has_more_page'])
        page_context_obj.set_report_name(page_context['report_name'])
        page_context_obj.set_applied_filter(page_context['applied_filter'])
        page_context_obj.set_sort_column(page_context['sort_column'])
        page_context_obj.set_sort_order(page_context['sort_order'])
        expense_list.set_page_context(page_context)

        return expense_list
    def get_expense(self, resp):
        """This method parses the given response and returns expense object.

        Args:
            resp(dict): Response containing json object for expense.

        Returns:
            instance: Expense object.

        """
        expense = resp['expense']
        expense_obj = Expense()
        expense_obj.set_expense_id(expense['expense_id'])
        expense_obj.set_expense_item_id(expense['expense_item_id'])
        expense_obj.set_account_id(expense['account_id'])
        expense_obj.set_account_name(expense['account_name'])
        expense_obj.set_paid_through_account_id(expense[\
        'paid_through_account_id'])
        expense_obj.set_paid_through_account_name(expense[\
        'paid_through_account_name'])
        expense_obj.set_vendor_id(expense['vendor_id'])
        expense_obj.set_vendor_name(expense['vendor_name'])
        expense_obj.set_date(expense['date'])
        expense_obj.set_tax_id(expense['tax_id'])
        expense_obj.set_tax_name(expense['tax_name'])
        expense_obj.set_tax_percentage(expense['tax_percentage'])
        expense_obj.set_currency_id(expense['currency_id'])
        expense_obj.set_currency_code(expense['currency_code'])
        expense_obj.set_exchange_rate(expense['exchange_rate'])
        expense_obj.set_tax_amount(expense['tax_amount'])
        expense_obj.set_sub_total(expense['sub_total'])
        expense_obj.set_total(expense['total'])
        expense_obj.set_bcy_total(expense['bcy_total'])
        expense_obj.set_amount(expense['amount'])
        expense_obj.set_is_inclusive_tax(expense['is_inclusive_tax'])
        expense_obj.set_reference_number(expense['reference_number'])
        expense_obj.set_description(expense['description'])
        expense_obj.set_is_billable(expense['is_billable'])
        expense_obj.set_customer_id(expense['customer_id'])
        expense_obj.set_customer_name(expense['customer_name'])
        expense_obj.set_expense_receipt_name(expense['expense_receipt_name'])
        expense_obj.set_created_time(expense['created_time'])
        expense_obj.set_last_modified_time(expense['last_modified_time'])
        expense_obj.set_status(expense['status'])
        expense_obj.set_invoice_id(expense['invoice_id'])
        expense_obj.set_invoice_number(expense['invoice_number'])
        expense_obj.set_project_id(expense['project_id'])
        expense_obj.set_project_name(expense['project_name'])
        return expense_obj
    def get_list(self, resp):
        """This method parses the given response and returns Expense list 
            object.

        Args:
            resp(dict): Response containing json object for Expenses list.
        
        Returns:
            instance: Expenses list object.

        """
        expenses = resp['expenses']
        expense_list = ExpenseList()
        for value in expenses:
            expense = Expense()
            expense.set_expense_id(value['expense_id'])
            expense.set_date(value['date'])
            expense.set_account_name(value['account_name'])
            expense.set_paid_through_account_name(value[\
            'paid_through_account_name'])
            expense.set_description(value['description'])
            expense.set_currency_id(value['currency_id'])
            expense.set_currency_code(value['currency_code'])
            expense.set_bcy_total(value['bcy_total'])
            expense.set_total(value['total'])
            expense.set_is_billable(value['is_billable'])
            expense.set_reference_number(value['reference_number'])
            expense.set_customer_id(value['customer_id'])
            expense.set_customer_name(value['customer_name'])
            expense.set_vendor_id(value['vendor_id'])
            expense.set_vendor_name(value['vendor_name'])
            expense.set_status(value['status'])
            expense.set_created_time(value['created_time'])
            expense.set_expense_receipt_name(value['expense_receipt_name'])
            expense_list.set_expenses(expense)
        page_context_obj = PageContext()
        page_context = resp['page_context']
        page_context_obj.set_page(page_context['page'])
        page_context_obj.set_per_page(page_context['per_page'])
        page_context_obj.set_has_more_page(page_context['has_more_page'])
        page_context_obj.set_report_name(page_context['report_name'])
        page_context_obj.set_applied_filter(page_context['applied_filter'])
        page_context_obj.set_sort_column(page_context['sort_column'])
        page_context_obj.set_sort_order(page_context['sort_order'])
        expense_list.set_page_context(page_context)

        return expense_list
    def get_expense_history(self, resp):
        """This method parses the json object and returns expense history list.

        Args:
            resp(dict): Response containing json object for expense history.

        Returns:
            instance: Expenses list object.

        """
        expenses_list = ExpenseList()
        for value in resp['expensehistory']:
            expense = Expense()
            expense.set_expense_id(value['expense_id'])
            expense.set_date(value['date'])
            expense.set_account_name(value['account_name'])
            expense.set_vendor_name(value['vendor_name'])
            expense.set_paid_through_account_name(\
            value['paid_through_account_name'])
            expense.set_customer_name(value['customer_name'])
            expense.set_total(value['total'])
            expense.set_status(value['status'])
            expenses_list.set_expenses(expense)
        page_context_obj = PageContext()
        page_context = resp['page_context']
        page_context_obj.set_page(page_context['page'])
        page_context_obj.set_per_page(page_context['per_page'])
        page_context_obj.set_has_more_page(page_context['has_more_page'])
        page_context_obj.set_report_name(page_context['report_name'])
        page_context_obj.set_sort_column(page_context['sort_column'])
        page_context_obj.set_sort_order(page_context['sort_order'])
        expenses_list.set_page_context(page_context_obj)
        return expenses_list
customer_payments.set_date('2014-04-28')
customer_payments.set_reference_number('')
customer_payments.set_exchange_rate(1.0)
customer_payments.set_amount(10.0)
customer_payments.set_bank_charges(0.0)
customer_payments.set_tax_account_id('')
customer_payments.set_account_id(account_id)

contact_ids = contact_api.get_contacts().get_contacts()[1].get_contact_id()

print bank_transaction_api.categorize_as_customer_payment(transaction_id,customer_payments)
print bank_transaction_api.categorize_as_customer_payment(transaction_id,customer_payments,contact_ids)

# Categorize as expense

expense = Expense()
expense.set_account_id(account_id)
expense.set_paid_through_account_id('')
expense.set_amount(200.0)
expense.set_date('2014-04-28')
expense.set_is_inclusive_tax(False)
expense.set_is_billable(True)
expense.set_reference_number('2')
expense.set_description('')
expense.set_customer_id(customer_id)
expense.set_vendor_id(vendor_id)
expense.set_currency_id('currency_id)
expense.set_exchange_rate(20.0)
expense.set_project_id('')
receipt = '/{file_directory}/download.jpg'
print bank_transaction_api.categorize_as_expense(transaction_id,expense)
Пример #10
0
vendor_api = zoho_books.get_vendor_payments_api()
vendor_id = vendor_api.get_vendor_payments().get_vendor_payments()[0].get_vendor_id()

# List Expenses 

parameters={'filter_by':'Status.Unbilled'}
print expenses_api.get_expenses()
print expenses_api.get_expenses(parameters)

# Get an expense

print expenses_api.get(expense_id)

# Create an expense

expenses=Expense()
expenses.set_account_id(expense_account_id)
expenses.set_paid_through_account_id(account_id)
expenses.set_date("2012-12-30")
expenses.set_amount(100.0)
expenses.set_tax_id("71127000000077019")
expenses.set_is_inclusive_tax(True)
expenses.set_is_billable(True)
expenses.set_customer_id(customer_id)
expenses.set_vendor_id(vendor_id)
expenses.set_currency_id(currency_id)
#expenses.set_exchange_rate()
#expenses.set_project_id()

print expenses_api.create(expenses)
receipt="/{file_directory}/download.jpg"