def credit_to_invoice(self,response): """This method parses the given response and returns invoices object. Args: response(dict): Responses containing json object for credit to invoice. Returns: instance: Invoice List object. """ invoices = InvoiceList() for value in response['apply_to_invoices']['invoices']: invoice=Invoice() invoice.set_invoice_id(value['invoice_id']) invoice.set_amount_applied(value['amount_applied']) invoices.set_invoices(invoice) return invoices
def get_autoreminder(self, resp): """Get auto reminder. Args: resp(dict): Response containing json object for auto reminders object. Returns: instance: Auto reminders object. """ autoreminder = resp['autoreminder'] autoreminder_obj = Autoreminder() autoreminder_obj.set_autoreminder_id(autoreminder['autoreminder_id']) autoreminder_obj.set_is_enabled(autoreminder['is_enabled']) autoreminder_obj.set_notification_type(autoreminder['type']) autoreminder_obj.set_address_type(autoreminder['address_type']) autoreminder_obj.set_number_of_days(autoreminder['number_of_days']) autoreminder_obj.set_subject(autoreminder['subject']) autoreminder_obj.set_body(autoreminder['body']) placeholders_obj = PlaceHolder() placeholders = resp['placeholders'] for value in placeholders['Invoice']: invoice = Invoice() invoice.set_name(value['name']) invoice.set_value(value['value']) placeholders_obj.set_invoice(invoice) for value in placeholders['Customer']: customer = Customer() customer.set_name(value['name']) customer.set_value(value['value']) placeholders_obj.set_customer(customer) for value in placeholders['Organization']: organization = Organization() organization.set_value(value['value']) organization.set_name(value['name']) placeholders_obj.set_organization(organization) autoreminder_obj.set_placeholders(placeholders) return autoreminder_obj
def get_manual_reminder(self, resp): """Get manual reminder. Args: resp(dict): Response containing json object for manual reminder. Returns: instance: Manual reminders object. """ manualreminder = resp['manualreminder'] manualreminder_obj = ManualReminder() manualreminder_obj.set_manualreminder_id(manualreminder[\ 'manualreminder_id']) manualreminder_obj.set_type(manualreminder['type']) manualreminder_obj.set_subject(manualreminder['subject']) manualreminder_obj.set_body(manualreminder['body']) manualreminder_obj.set_cc_me(manualreminder['cc_me']) placeholders = resp['placeholders'] placeholders_obj = PlaceHolder() for value in placeholders['Invoice']: invoice = Invoice() invoice.set_name(value['name']) invoice.set_value(value['value']) placeholders_obj.set_invoice(invoice) for value in placeholders['Customer']: customer = Customer() customer.set_name(value['name']) customer.set_value(value['value']) placeholders_obj.set_customer(customer) for value in placeholders['Organization']: organization = Organization() organization.set_name(value['name']) organization.set_value(value['value']) placeholders_obj.set_organization(organization) manualreminder_obj.set_placeholders(placeholders_obj) return manualreminder_obj
def preference_list(self, resp): """This method parses the given response and returns preferneces object. Args: resp(dict): Response containing json obejct for preferences. Returns: instance: Prefenreces object. Raises: Books Exception: If status is not '200' or '201'. """ preferences = resp['preferences'] preferences_list = PreferenceList() preference_obj = Preference() preference_obj.set_convert_to_invoice(preferences[\ 'convert_to_invoice']) preference_obj.set_attach_pdf_for_email(preferences[\ 'attach_pdf_for_email']) preference_obj.set_estimate_approval_status(preferences[\ 'estimate_approval_status']) preference_obj.set_notify_me_on_online_payment(preferences[\ 'notify_me_on_online_payment']) preference_obj.set_send_payment_receipt_acknowledgement(preferences[\ 'send_payment_receipt_acknowledgement']) preference_obj.set_auto_notify_recurring_invoice(preferences[\ 'auto_notify_recurring_invoice']) preference_obj.set_snail_mail_include_payment_stub(preferences[\ 'snail_mail_include_payment_stub']) preference_obj.set_is_show_powered_by( preferences['is_show_powered_by']) preference_obj.set_attach_expense_receipt_to_invoice(preferences[\ 'attach_expense_receipt_to_invoice']) preference_obj.set_is_estimate_enabled(preferences[\ 'is_estimate_enabled']) preference_obj.set_is_project_enabled( preferences['is_project_enabled']) preference_obj.set_is_purchaseorder_enabled(preferences[\ 'is_purchaseorder_enabled']) preference_obj.set_is_salesorder_enabled(preferences[\ 'is_salesorder_enabled']) preference_obj.set_is_pricebooks_enabled(preferences[\ 'is_pricebooks_enabled']) preference_obj.set_attach_payment_receipt_with_acknowledgement(\ preferences['attach_payment_receipt_with_acknowledgement']) for value in preferences['auto_reminders']: auto_reminder = Autoreminder() auto_reminder.set_payment_reminder_id(value['payment_reminder_id']) auto_reminder.set_is_enabled(value['is_enabled']) auto_reminder.set_notification_type(value['notification_type']) auto_reminder.set_address_type(value['address_type']) auto_reminder.set_number_of_days(value['number_of_days']) auto_reminder.set_subject(value['subject']) auto_reminder.set_body(value['body']) preference_obj.set_auto_reminders(auto_reminder) terms = preferences['terms'] terms_obj = Term() terms_obj.set_invoice_terms(terms['invoice_terms']) terms_obj.set_estimate_terms(terms['estimate_terms']) terms_obj.set_creditnote_terms(terms['creditnote_terms']) preference_obj.set_terms(terms_obj) address_formats_obj = AddressFormat() address_formats = preferences['address_formats'] address_formats_obj.set_organization_address_format(address_formats[\ 'organization_address_format']) address_formats_obj.set_customer_address_format(address_formats[\ 'customer_address_format']) preference_obj.set_address_formats(address_formats_obj) preferences_list.set_preferences(preference_obj) custom_fields = resp['customfields'] custom_fields_obj = CustomField() for value in custom_fields['invoice']: invoice = Invoice() invoice.set_index(value['index']) invoice.set_show_in_all_pdf(value['show_in_all_pdf']) invoice.set_label(value['label']) custom_fields_obj.set_invoice(invoice) for value in custom_fields['contact']: contact = Contact() contact.set_index(value['index']) contact.set_show_in_all_pdf(vlaue['show_in_all_pdf']) contact.set_label(value['label']) custom_fields_obj.set_contact(contact) for value in custom_fields['estimate']: estimate = Estimate() estimate.set_index(value['index']) estimate.set_show_in_all_pdf(value['show_in_all_pdf']) estimate.set_label(value['label']) custom_fields_obj.set_estimate(estimate) preferences_list.set_custom_fields(custom_fields_obj) placeholders_address_format = resp['placeholders_address_format'] placeholders_address_format_obj = PlaceholderAddressFormat() for value in placeholders_address_format['organization']: organization = Organization() organization.set_value(value['value']) organization.set_name(value['name']) placeholders_address_format_obj.set_organization(organization) for value in placeholders_address_format['customer']: customer = Customer() customer.set_name(value['name']) customer.set_value(value['value']) placeholders_address_format_obj.set_customer(customer) preferences_list.set_placeholders_address_format(\ placeholders_address_format_obj) return preferences_list
#---------------------------------------------------------------------------------------- # Apply to invoices invoice_id = credit_notes_api.list_invoices_credited(credit_note_id).get_invoices_credited()[0].get_invoice_id() ''' creditnote_invoice_id = credit_notes_api.list_invoices_credited( credit_note_id)[0].get_creditnotes_invoice_id() # List invoices credited print credit_notes_api.list_invoices_credited(credit_note_id) # Credit to an invoice invoices = [] invoice = Invoice() invoice.set_invoice_id(invoice_id) invoice.set_amount_applied(10.0) invoices.append(invoice) print credit_notes_api.credit_to_invoice(credit_note_id, invoices) # Delete invoice credited print credit_notes_api.delete_invoices_credited(credit_note_id, creditnote_invoice_id) ''' #----------------------------------------------------------------------------------------- ''' # Refund credit_note_id = credit_notes_api.list_credit_note_refunds( ).get_creditnote_refunds()[0].get_creditnote_id()
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() invoice_id = invoice_api.get_invoices().get_invoices()[0].get_invoice_id() customer_payments = CustomerPayment() customer_payments.set_customer_id(customer_id) invoice = Invoice() invoice.set_invoice_id(invoice_id) invoice.set_amount_applied(20.0) invoice.set_tax_amount_withheld(4.0) invoices = [invoice] customer_payments.set_invoices(invoices) customer_payments.set_payment_mode('cash') customer_payments.set_description('') 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)
#create invoice #invoice_num = 'INV-000001' date = '2014-01-27' payment_terms = 15 payment_terms_label = 'Net 15' due_date = '2014-03-27' discount = 1.0 discount_type = 'item_level' exc_rate = 2.0 reccuring_invoice_id = "" invoiced_estimate_id = "" contact_person_id = [] salesperson_name = 'bob' invoice = Invoice() invoice.set_customer_id(customer_id) invoice.set_contact_persons(contact_person_id) invoice.set_reference_number('1354444444445') invoice.set_template_id(template_id) invoice.set_date(date) invoice.set_payment_terms(payment_terms) invoice.set_payment_terms_label(payment_terms_label) invoice.set_due_date(due_date) invoice.set_discount(discount) invoice.set_is_discount_before_tax(True) invoice.set_discount_type(discount_type) invoice.set_exchange_rate(exc_rate) invoice.set_recurring_invoice_id(reccuring_invoice_id) invoice.set_invoiced_estimate_id(invoiced_estimate_id)
def get(self,response): """This method parses the given response and returns Invoice object. Args: response(dict): Request containing json obect for invoices. Returns: instance: Invoice object. """ invoice = response['invoice'] invoice_object = Invoice() invoice_object.set_invoice_id(invoice['invoice_id']) invoice_object.set_invoice_number(invoice['invoice_number']) invoice_object.set_date(invoice['date']) invoice_object.set_status(invoice['status']) invoice_object.set_payment_terms(invoice['payment_terms']) invoice_object.set_payment_terms_label(invoice['payment_terms_label']) invoice_object.set_due_date(invoice['due_date']) invoice_object.set_payment_expected_date(invoice[\ 'payment_expected_date']) invoice_object.set_last_payment_date(invoice['last_payment_date']) invoice_object.set_reference_number(invoice['reference_number']) invoice_object.set_customer_id(invoice['customer_id']) invoice_object.set_customer_name(invoice['customer_name']) invoice_object.set_contact_persons(invoice['contact_persons']) invoice_object.set_currency_id(invoice['currency_id']) invoice_object.set_currency_code(invoice['currency_code']) invoice_object.set_exchange_rate(invoice['exchange_rate']) invoice_object.set_discount(invoice['discount']) invoice_object.set_is_discount_before_tax(invoice[\ 'is_discount_before_tax']) invoice_object.set_discount_type(invoice['discount_type']) invoice_object.set_recurring_invoice_id(invoice[\ 'recurring_invoice_id']) line_items = invoice['line_items'] for value in line_items: line_item = LineItem() line_item.set_line_item_id(value['line_item_id']) line_item.set_item_id(value['item_id']) line_item.set_project_id(value['project_id']) line_item.set_time_entry_ids(value['time_entry_ids']) line_item.set_expense_id(value['expense_id']) line_item.set_expense_receipt_name(value['expense_receipt_name']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_discount(value['discount']) 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']) invoice_object.set_line_items(line_item) invoice_object.set_shipping_charge(invoice['shipping_charge']) invoice_object.set_adjustment(invoice['adjustment']) invoice_object.set_adjustment_description(invoice[\ 'adjustment_description']) invoice_object.set_sub_total(invoice['sub_total']) invoice_object.set_tax_total(invoice['tax_total']) invoice_object.set_total(invoice['total']) taxes = invoice['taxes'] for value in taxes: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) invoice_object.set_taxes(tax) invoice_object.set_payment_reminder_enabled(invoice[\ 'payment_reminder_enabled']) invoice_object.set_payment_made(invoice['payment_made']) invoice_object.set_credits_applied(invoice['credits_applied']) invoice_object.set_tax_amount_withheld(invoice['tax_amount_withheld']) invoice_object.set_balance(invoice['balance']) invoice_object.set_write_off_amount(invoice['write_off_amount']) invoice_object.set_allow_partial_payments(invoice[\ 'allow_partial_payments']) invoice_object.set_price_precision(invoice['price_precision']) payment_gateways = invoice['payment_options']['payment_gateways'] for value in payment_gateways: payment_gateway = PaymentGateway() payment_gateway.set_configured(value['configured']) payment_gateway.set_additional_field1(value['additional_field1']) payment_gateway.set_gateway_name(value['gateway_name']) invoice_object.set_payment_options(payment_gateway) invoice_object.set_is_emailed(invoice['is_emailed']) invoice_object.set_reminders_sent(invoice['reminders_sent']) invoice_object.set_last_reminder_sent_date(invoice[\ 'last_reminder_sent_date']) billing_address = invoice['billing_address'] billing_address_object = Address() billing_address_object.set_address(billing_address['address']) billing_address_object.set_city(billing_address['city']) billing_address_object.set_state(billing_address['state']) billing_address_object.set_zip(billing_address['zip']) billing_address_object.set_country(billing_address['country']) billing_address_object.set_fax(billing_address['fax']) invoice_object.set_billing_address(billing_address_object) shipping_address = invoice['shipping_address'] shipping_address_object = Address() shipping_address_object.set_address(shipping_address['address']) shipping_address_object.set_city(shipping_address['city']) shipping_address_object.set_state(shipping_address['state']) shipping_address_object.set_zip(shipping_address['zip']) shipping_address_object.set_country(shipping_address['country']) shipping_address_object.set_fax(shipping_address['fax']) invoice_object.set_shipping_address(shipping_address_object) invoice_object.set_notes(invoice['notes']) invoice_object.set_terms(invoice['terms']) custom_fields = invoice['custom_fields'] for value in custom_fields: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_show_on_pdf(value['show_on_pdf']) custom_field.set_value(value['value']) custom_field.set_label(value['label']) invoice_object.set_custom_fields(custom_field) invoice_object.set_template_id(invoice['template_id']) invoice_object.set_template_name(invoice['template_name']) invoice_object.set_created_time(invoice['created_time']) invoice_object.set_last_modified_time(invoice['last_modified_time']) invoice_object.set_attachment_name(invoice['attachment_name']) invoice_object.set_can_send_in_mail(invoice['can_send_in_mail']) invoice_object.set_salesperson_id(invoice['salesperson_id']) invoice_object.set_salesperson_name(invoice['salesperson_name']) return invoice_object
''' #---------------------------------------------------------------------------------------- # Apply to invoices invoice_id = credit_notes_api.list_invoices_credited(credit_note_id).get_invoices_credited()[0].get_invoice_id() ''' creditnote_invoice_id = credit_notes_api.list_invoices_credited(credit_note_id)[0].get_creditnotes_invoice_id() # List invoices credited print credit_notes_api.list_invoices_credited(credit_note_id) # Credit to an invoice invoices=[] invoice=Invoice() invoice.set_invoice_id(invoice_id) invoice.set_amount_applied(10.0) invoices.append(invoice) print credit_notes_api.credit_to_invoice(credit_note_id,invoices) # Delete invoice credited print credit_notes_api.delete_invoices_credited(credit_note_id,creditnote_invoice_id) ''' #----------------------------------------------------------------------------------------- ''' # Refund credit_note_id = credit_notes_api.list_credit_note_refunds().get_creditnote_refunds()[0].get_creditnote_id() creditnote_refund_id = credit_notes_api.list_refunds_of_credit_note(credit_note_id).get_creditnote_refunds()[0].get_creditnote_refund_id() # List credit note refunds
def get_invoice_list(self, resp): """This method parses the given response and returns invoice list object. Args: resp(dict): Response containing json object for invoice list object. Returns: instance: Invoice list object. """ invoices = InvoiceList() for value in resp['invoices']: invoice = Invoice() invoice.set_invoice_id(value['invoice_id']) invoice.set_customer_name(value['customer_name']) invoice.set_customer_id(value['customer_id']) invoice.set_status(value['status']) invoice.set_invoice_number(value['invoice_number']) invoice.set_reference_number(value['reference_number']) invoice.set_date(value['date']) invoice.set_due_date(value['due_date']) invoice.set_total(value['total']) invoice.set_balance(value['balance']) invoice.set_created_time(value['created_time']) invoices.set_invoices(invoice) page_context = resp['page_context'] page_context_obj = PageContext() 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']) invoices.set_page_context(page_context) return invoices
def get(self, response): """This method parses the given response and returns Invoice object. Args: response(dict): Request containing json obect for invoices. Returns: instance: Invoice object. """ invoice = response['invoice'] invoice_object = Invoice() invoice_object.set_invoice_id(invoice['invoice_id']) invoice_object.set_invoice_number(invoice['invoice_number']) invoice_object.set_date(invoice['date']) invoice_object.set_status(invoice['status']) invoice_object.set_payment_terms(invoice['payment_terms']) invoice_object.set_payment_terms_label(invoice['payment_terms_label']) invoice_object.set_due_date(invoice['due_date']) invoice_object.set_payment_expected_date(invoice[\ 'payment_expected_date']) invoice_object.set_last_payment_date(invoice['last_payment_date']) invoice_object.set_reference_number(invoice['reference_number']) invoice_object.set_customer_id(invoice['customer_id']) invoice_object.set_customer_name(invoice['customer_name']) invoice_object.set_contact_persons(invoice['contact_persons_details']) invoice_object.set_currency_id(invoice['currency_id']) invoice_object.set_currency_code(invoice['currency_code']) invoice_object.set_exchange_rate(invoice['exchange_rate']) invoice_object.set_discount(invoice['discount']) invoice_object.gst_no = invoice['gst_no'] invoice_object.set_is_discount_before_tax(invoice[\ 'is_discount_before_tax']) invoice_object.set_discount_type(invoice['discount_type']) invoice_object.set_recurring_invoice_id(invoice[\ 'recurring_invoice_id']) line_items = invoice['line_items'] for value in line_items: line_item = LineItem() line_item.set_line_item_id(value['line_item_id']) line_item.set_item_id(value['item_id']) line_item.set_project_id(value['project_id']) line_item.set_time_entry_ids(value['time_entry_ids']) line_item.set_expense_id(value['expense_id']) line_item.set_expense_receipt_name(value['expense_receipt_name']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_discount(value['discount']) 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_hsn_or_sac(value['hsn_or_sac']) line_item.set_item_total(value['item_total']) invoice_object.set_line_items(line_item) invoice_object.set_shipping_charge(invoice['shipping_charge']) invoice_object.set_adjustment(invoice['adjustment']) invoice_object.set_adjustment_description(invoice[\ 'adjustment_description']) invoice_object.set_sub_total(invoice['sub_total']) invoice_object.set_tax_total(invoice['tax_total']) invoice_object.set_total(invoice['total']) taxes = invoice['taxes'] for value in taxes: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) invoice_object.set_taxes(tax) invoice_object.set_payment_reminder_enabled(invoice[\ 'payment_reminder_enabled']) invoice_object.set_payment_made(invoice['payment_made']) invoice_object.set_credits_applied(invoice['credits_applied']) invoice_object.set_tax_amount_withheld(invoice['tax_amount_withheld']) invoice_object.set_balance(invoice['balance']) invoice_object.set_write_off_amount(invoice['write_off_amount']) invoice_object.set_allow_partial_payments(invoice[\ 'allow_partial_payments']) invoice_object.set_price_precision(invoice['price_precision']) payment_gateways = invoice['payment_options']['payment_gateways'] for value in payment_gateways: payment_gateway = PaymentGateway() payment_gateway.set_configured(value['configured']) payment_gateway.set_additional_field1(value['additional_field1']) payment_gateway.set_gateway_name(value['gateway_name']) invoice_object.set_payment_options(payment_gateway) invoice_object.set_is_emailed(invoice['is_emailed']) invoice_object.set_reminders_sent(invoice['reminders_sent']) invoice_object.set_last_reminder_sent_date(invoice[\ 'last_reminder_sent_date']) billing_address = invoice['billing_address'] billing_address_object = Address() billing_address_object.set_address(billing_address['address']) billing_address_object.set_city(billing_address['city']) billing_address_object.set_state(billing_address['state']) billing_address_object.set_zip(billing_address['zip']) billing_address_object.set_country(billing_address['country']) billing_address_object.set_fax(billing_address['fax']) invoice_object.set_billing_address(billing_address_object) shipping_address = invoice['shipping_address'] shipping_address_object = Address() shipping_address_object.set_address(shipping_address['address']) shipping_address_object.set_city(shipping_address['city']) shipping_address_object.set_state(shipping_address['state']) shipping_address_object.set_zip(shipping_address['zip']) shipping_address_object.set_country(shipping_address['country']) shipping_address_object.set_fax(shipping_address['fax']) invoice_object.set_shipping_address(shipping_address_object) invoice_object.set_notes(invoice['notes']) invoice_object.set_terms(invoice['terms']) custom_fields = invoice['custom_fields'] for value in custom_fields: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_show_on_pdf(value['show_on_pdf']) custom_field.set_value(value['value']) custom_field.set_label(value['label']) invoice_object.set_custom_fields(custom_field) invoice_object.set_template_id(invoice['template_id']) invoice_object.set_template_name(invoice['template_name']) invoice_object.set_created_time(invoice['created_time']) invoice_object.set_last_modified_time(invoice['last_modified_time']) invoice_object.set_attachment_name(invoice['attachment_name']) invoice_object.set_can_send_in_mail(invoice['can_send_in_mail']) invoice_object.set_salesperson_id(invoice['salesperson_id']) invoice_object.set_salesperson_name(invoice['salesperson_name']) return invoice_object
def get_list(self, response): """This method parses the given resonse and creates invoice list object. Args: response(dict): Response containing json object for invoice list. Returns: instance: Invoice list object. """ invoice = response['invoices'] invoice_list = InvoiceList() for value in invoice: invoice_object = Invoice() invoice_object.set_invoice_id(value['invoice_id']) invoice_object.set_customer_name(value['customer_name']) invoice_object.set_customer_id(value['customer_id']) invoice_object.set_status(value['status']) invoice_object.set_invoice_number(value['invoice_number']) invoice_object.set_reference_number(value['reference_number']) invoice_object.set_date(value['date']) invoice_object.set_due_date(value['due_date']) invoice_object.set_due_days(value['due_days']) invoice_object.set_currency_id(value['currency_id']) invoice_object.set_currency_code(value['currency_code']) invoice_object.set_total(value['total']) invoice_object.set_balance(value['balance']) invoice_object.set_created_time(value['created_time']) invoice_object.set_is_emailed(value['is_emailed']) invoice_object.set_reminders_sent(value['reminders_sent']) invoice_object.set_payment_expected_date(value[\ 'payment_expected_date']) invoice_object.set_last_payment_date(value['last_payment_date']) invoice_list.set_invoices(invoice_object) page_context_object = PageContext() page_context = response['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_report_name(page_context['report_name']) page_context_object.set_applied_filter(page_context['applied_filter']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) invoice_list.set_page_context(page_context_object) return invoice_list
def get_customer_payment(self,response): """This method parses the given response and returns customer payments object. Args: response(dict): Response containing json object for customer payments. Returns: instance: Customer payments object. """ payment=response['payment'] customer_payment=CustomerPayment() customer_payment.set_payment_id(payment['payment_id']) customer_payment.set_customer_id(payment['customer_id']) customer_payment.set_customer_name(payment['customer_name']) customer_payment.set_payment_mode(payment['payment_mode']) customer_payment.set_date(payment['date']) customer_payment.set_account_id(payment['account_id']) customer_payment.set_account_name(payment['account_name']) customer_payment.set_exchange_rate(payment['exchange_rate']) customer_payment.set_amount(payment['amount']) customer_payment.set_bank_charges(payment['bank_charges']) customer_payment.set_tax_account_id(payment['tax_account_id']) customer_payment.set_tax_account_name(payment['tax_account_name']) customer_payment.set_tax_amount_withheld(\ payment['tax_amount_withheld']) customer_payment.set_description(payment['description']) customer_payment.set_reference_number(payment['reference_number']) invoices=[] for value in payment['invoices']: invoice=Invoice() invoice.set_invoice_number(value['invoice_number']) invoice.set_invoice_payment_id(value['invoice_payment_id']) invoice.set_invoice_id(value['invoice_id']) invoice.set_amount_applied(value['amount_applied']) invoice.set_tax_amount_withheld(value['tax_amount_withheld']) invoice.set_total(value['total']) invoice.set_balance(value['balance']) invoice.set_date(value['date']) invoice.set_due_date(value['due_date']) invoices.append(invoice) customer_payment.set_invoices(invoices) return customer_payment
account_id = accounts_api.get_bank_accounts().get_bank_accounts()[0].get_account_id() # List customer payments print customer_payments_api.get_customer_payments() # Get a customer payment print customer_payments_api.get(payment_id) # Create a payment_customer customer_payments = CustomerPayment() customer_payments.set_customer_id(customer_id) invoices = [] invoice = Invoice() invoice.set_invoice_id(invoice_id) invoice.set_amount_applied(20.0) invoice.set_tax_amount_withheld(4.0) invoices.append(invoice) customer_payments.set_invoices(invoices) customer_payments.set_payment_mode('Cash') customer_payments.set_description('') customer_payments.set_date('2014-01-01') customer_payments.set_reference_number('') customer_payments.set_exchange_rate(30.0) customer_payments.set_amount(300.0) customer_payments.set_bank_charges(4.0) customer_payments.set_tax_account_id('') customer_payments.set_account_id(account_id)
def get_list(self,response): """This method parses the given resonse and creates invoice list object. Args: response(dict): Response containing json object for invoice list. Returns: instance: Invoice list object. """ invoice = response['invoices'] invoice_list = InvoiceList() for value in invoice: invoice_object = Invoice() invoice_object.set_invoice_id(value['invoice_id']) invoice_object.set_customer_name(value['customer_name']) invoice_object.set_customer_id(value['customer_id']) invoice_object.set_status(value['status']) invoice_object.set_invoice_number(value['invoice_number']) invoice_object.set_reference_number(value['reference_number']) invoice_object.set_date(value['date']) invoice_object.set_due_date(value['due_date']) invoice_object.set_due_days(value['due_days']) invoice_object.set_currency_id(value['currency_id']) invoice_object.set_currency_code(value['currency_code']) invoice_object.set_total(value['total']) invoice_object.set_balance(value['balance']) invoice_object.set_created_time(value['created_time']) invoice_object.set_is_emailed(value['is_emailed']) invoice_object.set_reminders_sent(value['reminders_sent']) invoice_object.set_payment_expected_date(value[\ 'payment_expected_date']) invoice_object.set_last_payment_date(value['last_payment_date']) invoice_list.set_invoices(invoice_object) page_context_object = PageContext() page_context = response['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_report_name(page_context['report_name']) page_context_object.set_applied_filter(page_context['applied_filter']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) invoice_list.set_page_context(page_context_object) return invoice_list