def get_billing_address(self, response): """This method parses the given response and returns billing address object. Args: response(dict): Response containing json object for billing address. Returns: instacne: Billing address object. """ address = response['billing_address'] address_object = Address() address_object.set_address(address['address']) address_object.set_city(address['city']) address_object.set_state(address['state']) address_object.set_zip(address['zip']) address_object.set_country(address['country']) address_object.set_fax(address['fax']) address_object.set_is_update_customer(address['is_update_customer']) return address_object
def get_billing_address(self,response): """This method parses the response containing json object for billing address. Args: response(dict): Response containing json object for billing address. Returns: instance: Address object. """ billing_address=response['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']) billing_address_obj.set_is_update_customer(\ billing_address['is_update_customer']) return billing_address_obj
def get_shipping_address(self,response): """This method parses the json object and returns shipping address \ object. Args: response(dict): Response containing json object for shipping \ address. Returns: instance: Shipping address object. """ shipping_address=response['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']) shipping_address_obj.set_is_update_customer(\ shipping_address['is_update_customer']) return shipping_address_obj
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
cp.set_first_name('nivetha') cp.set_salutation('ms') con_per.append(cp) v = ContactPerson() v.set_first_name('varunaa') v.set_salutation('mr') v.set_is_primary_contact(True) con_per.append(v) contact.set_contact_persons(con_per) baddress = Address() baddress.set_address('45, suite street') baddress.set_city('California') baddress.set_state('CA') baddress.set_zip('9876') baddress.set_fax('+1-925-924-9600') #contact.set_billing_address(baddress) saddress = Address() saddress.set_address('45, suite street') saddress.set_city('California') saddress.set_state('CA') saddress.set_zip('9876') saddress.set_fax('+1-925-924-9600') contact.set_shipping_address(saddress) contact.set_notes('Payment option: Through check')
print invoice_api.enable_payment_reminder(invoice_id) #write off invoice print invoice_api.write_off_invoice(invoice_id) #cancel write off print invoice_api.cancel_write_off(invoice_id) #update billing address billing_address = Address() billing_address.set_address('43, Km street') billing_address.set_city('Chennai') billing_address.set_state('TamilNadu') billing_address.set_zip('3344') billing_address.set_country('India') billing_address.set_fax('67899') print invoice_api.update_billing_address(invoice_id, billing_address) print invoice_api.update_billing_address(invoice_id, billing_address, True) # update shipping address shipping_address = Address() shipping_address.set_address('43, Km street') shipping_address.set_city('Chennai') shipping_address.set_state('TamilNadu') shipping_address.set_zip('3344')
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_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
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
customer_id) # Email History print credit_notes_api.email_history(credit_note_id) # Get email content print credit_notes_api.get_email_content(credit_note_id) print credit_notes_api.get_email_content(credit_note_id, email_template_id) # Update billing address billing_address = Address() billing_address.set_address('43, Km street') billing_address.set_city('Chennai') billing_address.set_state('TamilNadu') billing_address.set_zip('3344') billing_address.set_country('India') billing_address.set_fax('67899') print credit_notes_api.update_billing_address(credit_note_id, billing_address) print credit_notes_api.update_billing_address(credit_note_id, billing_address, True) # Update shipping Address shipping_address = Address() shipping_address.set_address('35,srinagar') shipping_address.set_city('Mumbai') shipping_address.set_state('TamilNadu')
def get_bill(self, resp): """This method parses the given response and returns bills object. Args: resp(dict): Response containing json object for bill object. Returns: instance: Bill object. """ bill = resp['bill'] bill_obj = Bill() bill_obj.set_bill_id(bill['bill_id']) bill_obj.set_vendor_id(bill['vendor_id']) bill_obj.set_vendor_name(bill['vendor_name']) bill_obj.set_unused_credits_payable_amount(bill[\ 'unused_credits_payable_amount']) bill_obj.set_status(bill['status']) bill_obj.set_bill_number(bill['bill_number']) bill_obj.set_date(bill['date']) bill_obj.set_due_date(bill['due_date']) bill_obj.set_reference_number(bill['reference_number']) bill_obj.set_due_by_days(bill['due_by_days']) bill_obj.set_due_in_days(bill['due_in_days']) bill_obj.set_currency_id(bill['currency_id']) bill_obj.set_currency_code(bill['currency_code']) bill_obj.set_currency_symbol(bill['currency_symbol']) bill_obj.set_price_precision(bill['price_precision']) bill_obj.set_exchange_rate(bill['exchange_rate']) for value in bill['line_items']: line_item = LineItem() line_item.set_line_item_id(value['line_item_id']) line_item.set_account_id(value['account_id']) line_item.set_account_name(value['account_name']) line_item.set_description(value['description']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_tax_id(value['tax_id']) line_item.set_tax_name(value['tax_name']) line_item.set_tax_type(value['tax_type']) line_item.set_tax_percentage(value['tax_percentage']) line_item.set_item_total(value['item_total']) line_item.set_item_order(value['item_order']) bill_obj.set_line_items(line_item) bill_obj.set_sub_total(bill['sub_total']) bill_obj.set_tax_total(bill['tax_total']) bill_obj.set_total(bill['total']) for value in bill['taxes']: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) bill_obj.set_taxes(tax) bill_obj.set_payment_made(bill['payment_made']) bill_obj.set_balance(bill['balance']) billing_address = bill['billing_address'] billing_address_obj = Address() billing_address_obj.set_address(billing_address['address']) billing_address_obj.set_city(billing_address['city']) billing_address_obj.set_state(billing_address['state']) billing_address_obj.set_zip(billing_address['zip']) billing_address_obj.set_country(billing_address['country']) billing_address_obj.set_fax(billing_address['fax']) bill_obj.set_billing_address(billing_address_obj) for value in bill['payments']: payments = BillPayment() payments.set_payment_id(value['payment_id']) payments.set_bill_id(value['bill_id']) payments.set_bill_payment_id(value['bill_payment_id']) payments.set_payment_mode(value['payment_mode']) payments.set_description(value['description']) payments.set_date(value['date']) payments.set_reference_number(value['reference_number']) payments.set_exchange_rate(value['exchange_rate']) payments.set_amount(value['amount']) payments.set_paid_through_account_id(value[\ 'paid_through_account_id']) payments.set_paid_through_account_name(value[\ 'paid_through_account_name']) payments.set_is_single_bill_payment(value[\ 'is_single_bill_payment']) billing_address_obj.set_payments(payments) bill_obj.set_created_time(bill['created_time']) bill_obj.set_last_modified_time(bill['last_modified_time']) bill_obj.set_reference_id(bill['reference_id']) bill_obj.set_notes(bill['notes']) bill_obj.set_terms(bill['terms']) bill_obj.set_attachment_name(bill['attachment_name']) return bill_obj
def get_creditnote(self,response): """This method parses the given response and returns credit note object. Args: response(dict): Response containing json object for credit note. Returns: instance: Credit note object. """ creditnote=response['creditnote'] credit_note=CreditNote() credit_note.set_creditnote_id(creditnote['creditnote_id']) credit_note.set_creditnote_number(creditnote['creditnote_number']) credit_note.set_date(creditnote['date']) credit_note.set_status(creditnote['status']) credit_note.set_reference_number(creditnote['reference_number']) credit_note.set_customer_id(creditnote['customer_id']) credit_note.set_customer_name(creditnote['customer_name']) credit_note.set_contact_persons(creditnote['contact_persons']) credit_note.set_currency_id(creditnote['currency_id']) credit_note.set_currency_code(creditnote['currency_code']) credit_note.set_exchange_rate(creditnote['exchange_rate']) credit_note.set_price_precision(creditnote['price_precision']) credit_note.set_template_id(creditnote['template_id']) credit_note.set_template_name(creditnote['template_name']) credit_note.set_is_emailed(creditnote['is_emailed']) for value in creditnote['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_account_id(value['account_id']) line_item.set_account_name(value['account_name']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) 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']) credit_note.set_line_items(line_item) credit_note.set_sub_total(creditnote['sub_total']) credit_note.set_total(creditnote['total']) credit_note.set_total_credits_used(creditnote['total_credits_used']) credit_note.set_total_refunded_amount(\ creditnote['total_refunded_amount']) credit_note.set_balance(creditnote['balance']) taxes=[] for value in creditnote['taxes']: tax=Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) taxes.append(tax) credit_note.set_taxes(taxes) billing_address=creditnote['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']) credit_note.set_billing_address(billing_address_obj) shipping_address=creditnote['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']) credit_note.set_shipping_address(shipping_address_obj) credit_note.set_created_time(creditnote['created_time']) credit_note.set_last_modified_time(creditnote['last_modified_time']) return credit_note
print bill_api.delete(bill_id) # Void a bill print bill_api.void_a_bill(bill_id) # Mark a bill as open print bill_api.mark_a_bill_as_open(bill_id) # Update billing_ address billing_address=Address() billing_address.set_address('no. 2 kumaran streeet') billing_address.set_city('chennai') billing_address.set_state('Tamilnadu') billing_address.set_zip('908') billing_address.set_country('India') print bill_api.update_billing_address(bill_id,billing_address) ''' ''' param = {'status': 'paid'} bill_id = bill_api.get_bills(param).get_bills()[0].get_bill_id() payment_id = bill_api.list_bill_payments(bill_id)[0].get_payment_id() bill_payment_id = bill_api.list_bill_payments(bill_id)[0].get_bill_payment_id() # List bill payment print bill_api.list_bill_payments(bill_id)
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_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 organizations. print organizations_api.get_organizations() #Get organization print organizations_api.get(organization_id) #Create organization organization = Organization() organization.set_name("Jony and co") address = Address() address.set_street_address1("2/65") address.set_street_address2("vignesh plaza") address.set_city("MDU") address.set_state("TN") address.set_country("India") address.set_zip("322") organization.set_address(address) organization.set_industry_type("") organization.set_industry_size("") organization.set_fiscal_year_start_month("january") organization.set_currency_code("USD") organization.set_time_zone("Asia/Calcutta") organization.set_date_format("dd MMM yyyy") organization.set_field_separator("") organization.set_language_code("en") organization.set_tax_basis("accrual") organization.set_tax_type("tax") organization.set_org_address("")
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
cp.set_first_name('nivetha') cp.set_salutation('ms') con_per.append(cp) v = ContactPerson() v.set_first_name('varunaa') v.set_salutation('mr') v.set_is_primary_contact(True) con_per.append(v) #contact.set_contact_persons(con_per) baddress = Address() baddress.set_address('45, suite street') baddress.set_city('California') baddress.set_state('CA') baddress.set_zip('9876') baddress.set_fax('+1-925-924-9600') #contact.set_billing_address(baddress) saddress = Address() saddress.set_address('45, suite street') saddress.set_city('California') saddress.set_state('CA') saddress.set_zip('9876') saddress.set_fax('+1-925-924-9600') contact.set_shipping_address(saddress) contact.set_notes('Payment option: Through check' )