def get_organization(self, resp): """This method parses the given response and returns organization object. Args: resp(dict): Response containing json object for organization. """ organization = resp['organization'] organization_obj = Organization() organization_obj.set_organization_id(organization['organization_id']) organization_obj.set_name(organization['name']) organization_obj.set_is_default_org(organization['is_default_org']) organization_obj.set_user_role(organization['user_role']) organization_obj.set_account_created_date(organization[\ 'account_created_date']) organization_obj.set_time_zone(organization['time_zone']) organization_obj.set_language_code(organization['language_code']) organization_obj.set_date_format(organization['date_format']) organization_obj.set_field_separator(organization['field_separator']) organization_obj.set_fiscal_year_start_month(organization[\ 'fiscal_year_start_month']) organization_obj.set_contact_name(organization['contact_name']) organization_obj.set_industry_type(organization['industry_type']) organization_obj.set_industry_size(organization['industry_size']) organization_obj.set_company_id_label(organization['company_id_label']) organization_obj.set_company_id_value(organization['company_id_value']) organization_obj.set_tax_id_label(organization['tax_id_label']) organization_obj.set_tax_id_value(organization['tax_id_value']) organization_obj.set_currency_id(organization['currency_id']) organization_obj.set_currency_code(organization['currency_code']) organization_obj.set_currency_symbol(organization['currency_symbol']) organization_obj.set_currency_format(organization['currency_format']) organization_obj.set_price_precision(organization['price_precision']) address = organization['address'] address_obj = Address() address_obj.set_street_address1(address['street_address1']) address_obj.set_street_address2(address['street_address2']) address_obj.set_city(address['city']) address_obj.set_state(address['state']) address_obj.set_country(address['country']) address_obj.set_zip(address['zip']) organization_obj.set_address(address_obj) organization_obj.set_org_address(organization['org_address']) organization_obj.set_remit_to_address(organization['remit_to_address']) organization_obj.set_phone(organization['phone']) organization_obj.set_fax(organization['fax']) organization_obj.set_website(organization['website']) organization_obj.set_email(organization['email']) organization_obj.set_tax_basis(organization['tax_basis']) for value in organization['custom_fields']: custom_field = CustomField() custom_field.set_value(value['value']) custom_field.set_index(value['index']) custom_field.set_label(value['label']) organization_obj.set_custom_fields(custom_field) organization_obj.set_is_org_active(organization['is_org_active']) organization_obj.set_is_new_customer_custom_fields(organization[\ 'is_new_customer_custom_fields']) organization_obj.set_is_portal_enabled( organization['is_portal_enabled']) organization_obj.set_portal_name(organization['portal_name']) return organization_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
def get_contact(self, resp): """This method parses the given response and creates a contact object. Args: resp(dict): Response containing json object for contact. Returns: instance: Contact object. """ contact = Contact() response = resp['contact'] contact.set_contact_id(response['contact_id']) contact.set_contact_name(response['contact_name']) contact.set_company_name(response['company_name']) contact.set_contact_salutation(response['contact_salutation']) contact.set_price_precision(response['price_precision']) contact.set_has_transaction(response['has_transaction']) contact.set_contact_type(response['contact_type']) contact.set_is_crm_customer(response['is_crm_customer']) contact.set_primary_contact_id(response['primary_contact_id']) contact.set_payment_terms(response['payment_terms']) contact.set_payment_terms_label(response['payment_terms_label']) contact.set_currency_id(response['currency_id']) contact.set_currency_code(response['currency_code']) contact.set_currency_symbol(response['currency_symbol']) contact.set_outstanding_receivable_amount(response[\ 'outstanding_receivable_amount']) contact.set_outstanding_receivable_amount_bcy(response[\ 'outstanding_receivable_amount_bcy']) contact.set_outstanding_payable_amount(response[\ 'outstanding_payable_amount']) contact.set_outstanding_payable_amount_bcy(response[\ 'outstanding_payable_amount_bcy']) contact.set_unused_credits_receivable_amount(response[\ 'unused_credits_receivable_amount']) contact.set_unused_credits_receivable_amount_bcy(response[\ 'unused_credits_receivable_amount_bcy']) contact.set_unused_credits_payable_amount(response[\ 'unused_credits_payable_amount']) contact.set_unused_credits_payable_amount_bcy(response[\ 'unused_credits_payable_amount_bcy']) contact.set_status(response['status']) contact.set_payment_reminder_enabled(response[\ 'payment_reminder_enabled']) for value in response['custom_fields']: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_value(value['value']) custom_field.set_label(value['label']) contact_person.set_custom_fields(custom_field) billing_address = Address() billing_address.set_address(response['billing_address']['address']) billing_address.set_city(response['billing_address']['city']) billing_address.set_state(response['billing_address']['state']) billing_address.set_zip(response['billing_address']['zip']) billing_address.set_country(response['billing_address']['country']) billing_address.set_fax(response['billing_address']['fax']) contact.set_billing_address(billing_address) shipping_address = Address() shipping_address.set_address(response['shipping_address']['address']) shipping_address.set_city(response['shipping_address']['city']) shipping_address.set_state(response['shipping_address']['state']) shipping_address.set_zip(response['shipping_address']['zip']) shipping_address.set_country(response['shipping_address']['country']) shipping_address.set_fax(response['shipping_address']['fax']) contact.set_shipping_address(shipping_address) contact_persons = [] for value in response['contact_persons']: contact_person = ContactPerson() contact_person.set_contact_person_id(value['contact_person_id']) contact_person.set_salutation(value['salutation']) contact_person.set_first_name(value['first_name']) contact_person.set_last_name(value['last_name']) contact_person.set_email(value['email']) contact_person.set_phone(value['phone']) contact_person.set_mobile(value['mobile']) contact_person.set_is_primary_contact(value['is_primary_contact']) contact_persons.append(contact_person) contact.set_contact_persons(contact_persons) default_templates = DefaultTemplate() default_templates.set_invoice_template_id(response[ 'default_templates']['invoice_template_id']) default_templates.set_invoice_template_name(response[\ 'default_templates']['invoice_template_name']) default_templates.set_estimate_template_id(response[\ 'default_templates']['estimate_template_id']) default_templates.set_estimate_template_name(response[\ 'default_templates']['estimate_template_name']) default_templates.set_creditnote_template_id(response[\ 'default_templates']['creditnote_template_id']) default_templates.set_creditnote_template_name(response[\ 'default_templates']['creditnote_template_name']) default_templates.set_invoice_email_template_id(response[\ 'default_templates']['invoice_email_template_id']) default_templates.set_invoice_email_template_name(response[\ 'default_templates']['invoice_email_template_name']) default_templates.set_estimate_email_template_id(response[\ 'default_templates']['estimate_email_template_id']) default_templates.set_estimate_email_template_name(response[\ 'default_templates']['estimate_email_template_name']) default_templates.set_creditnote_email_template_id(response[\ 'default_templates']['creditnote_email_template_id']) default_templates.set_creditnote_email_template_name(response[\ 'default_templates']['creditnote_email_template_name']) contact.set_default_templates(default_templates) contact.set_notes(response['notes']) contact.set_created_time(response['created_time']) contact.set_last_modified_time(response['last_modified_time']) return contact
def get_estimate(self, response): """This method parses the given response and returns Estimate object. Args: response(dict): Response containing json object for estimate. Returns: instance: Estimate object. """ estimate = Estimate() resp = response['estimate'] estimate.set_estimate_id(resp['estimate_id']) estimate.set_estimate_number(resp['estimate_number']) estimate.set_date(resp['date']) estimate.set_reference_number(resp['reference_number']) estimate.set_status(resp['status']) estimate.set_customer_id(resp['customer_id']) estimate.set_customer_name(resp['customer_name']) estimate.set_contact_persons(resp['contact_persons']) estimate.set_currency_id(resp['currency_id']) estimate.set_currency_code(resp['currency_code']) estimate.set_exchange_rate(resp['exchange_rate']) estimate.set_expiry_date(resp['expiry_date']) estimate.set_discount(resp['discount']) estimate.set_is_discount_before_tax(resp['is_discount_before_tax']) estimate.set_discount_type(resp['discount_type']) line_items = resp['line_items'] for value in line_items: line_item = LineItem() line_item.set_item_id(value['item_id']) line_item.set_line_item_id(value['line_item_id']) 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']) estimate.set_line_items(line_item) estimate.set_shipping_charge(resp['shipping_charge']) estimate.set_adjustment(resp['adjustment']) estimate.set_adjustment_description(resp['adjustment_description']) estimate.set_sub_total(resp['sub_total']) estimate.set_total(resp['total']) estimate.set_tax_total(resp['tax_total']) estimate.set_price_precision(resp['price_precision']) taxes = resp['taxes'] for value in taxes: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) estimate.set_taxes(tax) billing_address = resp['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['zip']) estimate.set_billing_address(billing_address_object) shipping_address = resp['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['zip']) estimate.set_shipping_address(shipping_address_object) estimate.set_notes(resp['notes']) estimate.set_terms(resp['terms']) custom_fields = resp['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']) estimate.set_custom_fields(custom_field) estimate.set_template_id(resp['template_id']) estimate.set_template_name(resp['template_name']) estimate.set_created_time(resp['created_time']) estimate.set_last_modified_time(resp['last_modified_time']) estimate.set_salesperson_id(resp['salesperson_id']) estimate.set_salesperson_name(resp['salesperson_name']) return estimate
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') line_items.set_description('500 gb hard disk drive') line_items.set_item_order(1) line_items.set_rate(388) line_items.set_unit('nos') line_items.set_quantity(3.00)
def recurring_invoice(self, response): """This method parses the response and creates recurring invoice object. Args: response(dict): Response containing json object for recurring invoice. Returns: instance: Recurring invoice object. """ recurring_invoice = response['recurring_invoice'] recurring_invoice_obj = RecurringInvoice() recurring_invoice_obj.set_recurring_invoice_id(\ recurring_invoice['recurring_invoice_id']) recurring_invoice_obj.set_recurrence_name(\ recurring_invoice['recurrence_name']) recurring_invoice_obj.set_status(recurring_invoice['status']) recurring_invoice_obj.set_recurrence_frequency(\ recurring_invoice['recurrence_frequency']) recurring_invoice_obj.set_repeat_every(\ recurring_invoice['repeat_every']) recurring_invoice_obj.set_start_date(recurring_invoice['start_date']) recurring_invoice_obj.set_end_date(recurring_invoice['end_date']) recurring_invoice_obj.set_last_sent_date(\ recurring_invoice['last_sent_date']) recurring_invoice_obj.set_next_invoice_date(\ recurring_invoice['next_invoice_date']) recurring_invoice_obj.set_payment_terms(\ recurring_invoice['payment_terms']) recurring_invoice_obj.set_payment_terms_label(\ recurring_invoice['payment_terms_label']) recurring_invoice_obj.set_customer_id(recurring_invoice['customer_id']) recurring_invoice_obj.set_customer_name(\ recurring_invoice['customer_name']) recurring_invoice_obj.set_contact_persons(\ recurring_invoice['contact_persons']) recurring_invoice_obj.set_currency_id(recurring_invoice['currency_id']) recurring_invoice_obj.set_price_precision(\ recurring_invoice['price_precision']) recurring_invoice_obj.set_currency_code(\ recurring_invoice['currency_code']) recurring_invoice_obj.set_currency_symbol(\ recurring_invoice['currency_symbol']) recurring_invoice_obj.set_exchange_rate(\ recurring_invoice['exchange_rate']) recurring_invoice_obj.set_discount(recurring_invoice['discount']) recurring_invoice_obj.set_is_discount_before_tax(\ recurring_invoice['is_discount_before_tax']) recurring_invoice_obj.set_discount_type(\ recurring_invoice['discount_type']) line_items = [] for value in recurring_invoice['line_items']: line_item = LineItem() line_item.set_item_id(value['item_id']) line_item.set_line_item_id(value['line_item_id']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_discount_amount(value['discount_amount']) 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']) line_items.append(line_item) recurring_invoice_obj.set_line_items(line_items) recurring_invoice_obj.set_shipping_charge(\ recurring_invoice['shipping_charge']) recurring_invoice_obj.set_adjustment(recurring_invoice['adjustment']) recurring_invoice_obj.set_adjustment_description(\ recurring_invoice['adjustment_description']) recurring_invoice_obj.set_late_fee(recurring_invoice['late_fee']) recurring_invoice_obj.set_sub_total(recurring_invoice['sub_total']) recurring_invoice_obj.set_total(recurring_invoice['total']) recurring_invoice_obj.set_tax_total(recurring_invoice['tax_total']) recurring_invoice_obj.set_allow_partial_payments(\ recurring_invoice['allow_partial_payments']) taxes = [] for value in recurring_invoice['taxes']: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount['value_tax_amount'] taxes.append(tax) recurring_invoice_obj.set_taxes(taxes) custom_fields = [] for value in recurring_invoice['custom_fields']: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_value(value['value']) custom_fields.append(custom_field) recurring_invoice_obj.set_custom_fields(custom_fields) payment_gateways = recurring_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']) recurring_invoice_obj.set_payment_options(payment_gateway) billing_address = recurring_invoice['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']) recurring_invoice_obj.set_billing_address(billing_address_obj) shipping_address = recurring_invoice['shipping_address'] shipping_address_obj = Address() shipping_address_obj.set_address(shipping_address['address']) shipping_address_obj.set_city(shipping_address['city']) shipping_address_obj.set_state(shipping_address['state']) shipping_address_obj.set_zip(shipping_address['zip']) shipping_address_obj.set_country(shipping_address['country']) shipping_address_obj.set_fax(shipping_address['fax']) recurring_invoice_obj.set_shipping_address(shipping_address_obj) recurring_invoice_obj.set_template_id(recurring_invoice['template_id']) recurring_invoice_obj.set_template_name(\ recurring_invoice['template_name']) recurring_invoice_obj.set_notes(recurring_invoice['notes']) recurring_invoice_obj.set_terms(recurring_invoice['terms']) recurring_invoice_obj.set_salesperson_id(\ recurring_invoice['salesperson_id']) recurring_invoice_obj.set_salesperson_name(\ recurring_invoice['salesperson_name']) recurring_invoice_obj.set_created_time(\ recurring_invoice['created_time']) recurring_invoice_obj.set_last_modified_time(\ recurring_invoice['last_modified_time']) return recurring_invoice_obj
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
def get_contact(self, resp): """This method parses the given response and creates a contact object. Args: resp(dict): Response containing json object for contact. Returns: instance: Contact object. """ contact = Contact() response = resp['contact'] contact.set_contact_id(response['contact_id']) contact.set_contact_name(response['contact_name']) contact.set_company_name(response['company_name']) contact.set_contact_salutation(response['contact_salutation']) contact.set_price_precision(response['price_precision']) contact.set_has_transaction(response['has_transaction']) contact.set_contact_type(response['contact_type']) contact.set_is_crm_customer(response['is_crm_customer']) contact.set_primary_contact_id(response['primary_contact_id']) contact.set_payment_terms(response['payment_terms']) contact.set_payment_terms_label(response['payment_terms_label']) contact.set_currency_id(response['currency_id']) contact.set_currency_code(response['currency_code']) contact.set_currency_symbol(response['currency_symbol']) contact.set_outstanding_receivable_amount(response[\ 'outstanding_receivable_amount']) contact.set_outstanding_receivable_amount_bcy(response[\ 'outstanding_receivable_amount_bcy']) contact.set_outstanding_payable_amount(response[\ 'outstanding_payable_amount']) contact.set_outstanding_payable_amount_bcy(response[\ 'outstanding_payable_amount_bcy']) contact.set_unused_credits_receivable_amount(response[\ 'unused_credits_receivable_amount']) contact.set_unused_credits_receivable_amount_bcy(response[\ 'unused_credits_receivable_amount_bcy']) contact.set_unused_credits_payable_amount(response[\ 'unused_credits_payable_amount']) contact.set_unused_credits_payable_amount_bcy(response[\ 'unused_credits_payable_amount_bcy']) contact.set_status(response['status']) contact.set_payment_reminder_enabled(response[\ 'payment_reminder_enabled']) for value in response['custom_fields']: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_value(value['value']) custom_field.set_label(value['label']) contact.set_custom_fields(custom_field) billing_address = Address() billing_address.set_address(response['billing_address']['address']) billing_address.set_city(response['billing_address']['city']) billing_address.set_state(response['billing_address']['state']) billing_address.set_zip(response['billing_address']['zip']) billing_address.set_country(response['billing_address']['country']) billing_address.set_fax(response['billing_address']['fax']) contact.set_billing_address(billing_address) shipping_address = Address() shipping_address.set_address(response['shipping_address']['address']) shipping_address.set_city(response['shipping_address']['city']) shipping_address.set_state(response['shipping_address']['state']) shipping_address.set_zip(response['shipping_address']['zip']) shipping_address.set_country(response['shipping_address']['country']) shipping_address.set_fax(response['shipping_address']['fax']) contact.set_shipping_address(shipping_address) contact_persons = [] for value in response['contact_persons']: contact_person = ContactPerson() contact_person.set_contact_person_id(value['contact_person_id']) contact_person.set_salutation(value['salutation']) contact_person.set_first_name(value['first_name']) contact_person.set_last_name(value['last_name']) contact_person.set_email(value['email']) contact_person.set_phone(value['phone']) contact_person.set_mobile(value['mobile']) contact_person.set_is_primary_contact(value['is_primary_contact']) contact_persons.append(contact_person) contact.set_contact_persons(contact_persons) default_templates = DefaultTemplate() default_templates.set_invoice_template_id( response['default_templates']['invoice_template_id']) default_templates.set_invoice_template_name(response[\ 'default_templates']['invoice_template_name']) default_templates.set_estimate_template_id(response[\ 'default_templates']['estimate_template_id']) default_templates.set_estimate_template_name(response[\ 'default_templates']['estimate_template_name']) default_templates.set_creditnote_template_id(response[\ 'default_templates']['creditnote_template_id']) default_templates.set_creditnote_template_name(response[\ 'default_templates']['creditnote_template_name']) default_templates.set_invoice_email_template_id(response[\ 'default_templates']['invoice_email_template_id']) default_templates.set_invoice_email_template_name(response[\ 'default_templates']['invoice_email_template_name']) default_templates.set_estimate_email_template_id(response[\ 'default_templates']['estimate_email_template_id']) default_templates.set_estimate_email_template_name(response[\ 'default_templates']['estimate_email_template_name']) default_templates.set_creditnote_email_template_id(response[\ 'default_templates']['creditnote_email_template_id']) default_templates.set_creditnote_email_template_name(response[\ 'default_templates']['creditnote_email_template_name']) contact.set_default_templates(default_templates) contact.set_notes(response['notes']) contact.set_created_time(response['created_time']) contact.set_last_modified_time(response['last_modified_time']) return contact
estimate.set_discount_type(discount_type) estimate.set_salesperson_name(salesperson_name) line_items = LineItem() line_items.set_item_id(item_id) line_items.set_name(name) line_items.set_description(description) estimate.set_line_items(line_items) line_items1 = LineItem() line_items1.set_item_id(item_id) line_items1.set_name('at') line_items1.set_description('build') estimate.set_line_items(line_items1) custom_field = CustomField() custom_field.set_index('') custom_field.set_value('custom') estimate.set_custom_fields(custom_field) estimate.set_notes('looking forward for your business') estimate.set_terms('terms and conditions apply') estimate.set_shipping_charge(0.0) estimate.set_adjustment(0.0) estimate.set_adjustment_description('Adjustment') #print estimate_api.create(estimate) #print estimate_api.create(estimate, False) #estimate.set_estimate_number('35') #print estimate_api.create(estimate, True, True) #print estimate_api.create(estimate, None, False)
def __init__(self): """Initialize parameters for preferences list.""" self.preferences = Preference() self.custom_fields = CustomField() self.placeholders_address_format = PlaceholderAddressFormat()
estimate.set_discount_type(discount_type) estimate.set_salesperson_name(salesperson_name) line_items = LineItem() line_items.set_item_id(item_id) line_items.set_name(name) line_items.set_description(description) estimate.set_line_items(line_items) line_items1 = LineItem() line_items1.set_item_id(item_id) line_items1.set_name('at') line_items1.set_description('build') estimate.set_line_items(line_items1) custom_field = CustomField() custom_field.set_index('') custom_field.set_value('custom') estimate.set_custom_fields(custom_field) estimate.set_notes('looking forward for your business') estimate.set_terms('terms and conditions apply') estimate.set_shipping_charge(0.0) estimate.set_adjustment(0.0) estimate.set_adjustment_description('Adjustment') #print estimate_api.create(estimate) #print estimate_api.create(estimate, False) #estimate.set_estimate_number('35') #print estimate_api.create(estimate, True, True)