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_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
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_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
# 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(
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(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
# 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) print customer_payments_api.create(customer_payments)