# Categorize as credit note refund refund = CreditNoteRefund() refund.set_creditnote_id(credit_note_id) refund.set_date('2014-01-01') refund.set_refund_mode('cash') refund.set_reference_number('') refund.set_exchange_rate(1.0) refund.set_from_account_id(account_id) refund.set_description('credit not categorize') print bank_transaction_api.categorize_as_credit_note_refunds(transaction_id,refund) # Categorize as vendor payments vendor_payment = VendorPayment() vendor_payment.set_vendor_id(vendor_id) bills=Bill() bills.set_bill_id(bill_id) bills.set_amount_applied(10.0) vendor_payment.set_bills(bills) vendor_payment.set_payment_mode('cash') vendor_payment.set_description('vendor payments') vendor_payment.set_date('2014-04-29') vendor_payment.set_reference_number('2') vendor_payment.set_exchange_rate(1.0) vendor_payment.set_amount(20.0) vendor_payment.set_paid_through_account_id('') print bank_transaction_api.categorize_as_vendor_payment(transaction_id,vendor_payment) # Categorize as customer payment invoice_api = zoho_books.get_invoices_api()
def get_vendor_payment(self, resp): """This method is used to parse the given response and returns vendor payments object. Args: resp(dict): Dictionary containing json object for vendor payments. Returns: instance: Vendor payments object. """ vendor_payment_obj = VendorPayment() vendor_payment = resp['vendorpayment'] vendor_payment_obj.set_payment_id(vendor_payment['payment_id']) vendor_payment_obj.set_vendor_id(vendor_payment['vendor_id']) vendor_payment_obj.set_vendor_name(vendor_payment['vendor_name']) vendor_payment_obj.set_payment_mode(vendor_payment['payment_mode']) vendor_payment_obj.set_description(vendor_payment['description']) vendor_payment_obj.set_date(vendor_payment['date']) vendor_payment_obj.set_reference_number(vendor_payment[\ 'reference_number']) vendor_payment_obj.set_exchange_rate(vendor_payment['exchange_rate']) vendor_payment_obj.set_amount(vendor_payment['amount']) vendor_payment_obj.set_currency_symbol(vendor_payment[\ 'currency_symbol']) vendor_payment_obj.set_paid_through_account_id(vendor_payment[\ 'paid_through_account_id']) vendor_payment_obj.set_paid_through_account_name(vendor_payment[\ 'paid_through_account_name']) for value in vendor_payment['bills']: bill = Bill() bill.set_bill_number(value['bill_number']) bill.set_bill_payment_id(value['bill_payment_id']) bill.set_bill_id(value['bill_id']) bill.set_total(value['total']) bill.set_balance(value['balance']) bill.set_amount_applied(value['amount_applied']) bill.set_date(value['date']) bill.set_due_date(value['due_date']) vendor_payment_obj.set_bills(bill) return vendor_payment_obj
def get_bill(self, resp): """This method parses the given response and returns bills object. Args: resp(dict): Response containing json object for bill object. Returns: instance: Bill object. """ bill = resp['bill'] bill_obj = Bill() bill_obj.set_bill_id(bill['bill_id']) bill_obj.set_vendor_id(bill['vendor_id']) bill_obj.set_vendor_name(bill['vendor_name']) bill_obj.set_unused_credits_payable_amount(bill[\ 'unused_credits_payable_amount']) bill_obj.set_status(bill['status']) bill_obj.set_bill_number(bill['bill_number']) bill_obj.set_date(bill['date']) bill_obj.set_due_date(bill['due_date']) bill_obj.set_reference_number(bill['reference_number']) bill_obj.set_due_by_days(bill['due_by_days']) bill_obj.set_due_in_days(bill['due_in_days']) bill_obj.set_currency_id(bill['currency_id']) bill_obj.set_currency_code(bill['currency_code']) bill_obj.set_currency_symbol(bill['currency_symbol']) bill_obj.set_price_precision(bill['price_precision']) bill_obj.set_exchange_rate(bill['exchange_rate']) for value in bill['line_items']: line_item = LineItem() line_item.set_line_item_id(value['line_item_id']) line_item.set_account_id(value['account_id']) line_item.set_account_name(value['account_name']) line_item.set_description(value['description']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_tax_id(value['tax_id']) line_item.set_tax_name(value['tax_name']) line_item.set_tax_type(value['tax_type']) line_item.set_tax_percentage(value['tax_percentage']) line_item.set_item_total(value['item_total']) line_item.set_item_order(value['item_order']) bill_obj.set_line_items(line_item) bill_obj.set_sub_total(bill['sub_total']) bill_obj.set_tax_total(bill['tax_total']) bill_obj.set_total(bill['total']) for value in bill['taxes']: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) bill_obj.set_taxes(tax) bill_obj.set_payment_made(bill['payment_made']) bill_obj.set_balance(bill['balance']) billing_address = bill['billing_address'] billing_address_obj = Address() billing_address_obj.set_address(billing_address['address']) billing_address_obj.set_city(billing_address['city']) billing_address_obj.set_state(billing_address['state']) billing_address_obj.set_zip(billing_address['zip']) billing_address_obj.set_country(billing_address['country']) billing_address_obj.set_fax(billing_address['fax']) bill_obj.set_billing_address(billing_address_obj) for value in bill['payments']: payments = BillPayment() payments.set_payment_id(value['payment_id']) payments.set_bill_id(value['bill_id']) payments.set_bill_payment_id(value['bill_payment_id']) payments.set_payment_mode(value['payment_mode']) payments.set_description(value['description']) payments.set_date(value['date']) payments.set_reference_number(value['reference_number']) payments.set_exchange_rate(value['exchange_rate']) payments.set_amount(value['amount']) payments.set_paid_through_account_id(value[\ 'paid_through_account_id']) payments.set_paid_through_account_name(value[\ 'paid_through_account_name']) payments.set_is_single_bill_payment(value[\ 'is_single_bill_payment']) billing_address_obj.set_payments(payments) bill_obj.set_created_time(bill['created_time']) bill_obj.set_last_modified_time(bill['last_modified_time']) bill_obj.set_reference_id(bill['reference_id']) bill_obj.set_notes(bill['notes']) bill_obj.set_terms(bill['terms']) bill_obj.set_attachment_name(bill['attachment_name']) return bill_obj
def get_list(self, resp): """This method parses the given response and returns bill list object. Args: resp(dict): Response containing json object for bill list. Returns: instance: Bill list object. """ bill_list = BillList() for value in resp['bills']: bill = Bill() bill.set_bill_id(value['bill_id']) bill.set_vendor_id(value['vendor_id']) bill.set_vendor_name(value['vendor_name']) bill.set_status(value['status']) bill.set_bill_number(value['bill_number']) bill.set_reference_number(value['reference_number']) bill.set_date(value['date']) bill.set_due_date(value['due_date']) bill.set_due_days(value['due_days']) bill.set_currency_id(value['currency_id']) bill.set_currency_code(value['currency_code']) bill.set_total(value['total']) bill.set_balance(value['balance']) bill.set_created_time(value['created_time']) bill_list.set_bills(bill) 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']) bill_list.set_page_context(page_context_obj) return bill_list
account_id = chart_of_accounts_api.get_chart_of_accounts(param).get_chartofaccounts()[1].get_account_id() attachment = '/{file_directory}/emp.pdf' # List bills parameter = {'status':'open'} print bill_api.get_bills() print bill_api.get_bills(parameter) # Get a bill print bill_api.get(bill_id) # Create a bill bill = Bill() bill.set_vendor_id(vendor_id) bill.set_bill_number('38') bill.set_date('2014-05-12') bill.set_due_date('2014-05-13') bill.set_exchange_rate(1) bill.set_reference_number("2") line_items = LineItem() line_items.set_account_id(account_id) line_items.set_description('table') line_items.set_rate("1000.0") line_items.set_quantity("4") line_items.set_item_order("0") bill.set_line_items(line_items) bill.set_notes("before due")