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) invoice.set_salesperson_name(salesperson_name) custom_field = CustomField() #custom_field.set_index(1) custom_field.set_value('2 days') invoice.set_custom_fields(custom_field) line_items = LineItem() line_items.set_item_id(item_id) line_items.set_project_id('') line_items.set_expense_id('') line_items.set_name('drive')
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
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