Exemplo n.º 1
0
 def __init__(self):
     """This class is used to create object for credit notes."""
     self.creditnote_id = ''
     self.creditnote_number = ''
     self.date = ''
     self.status = ''
     self.reference_number = ''
     self.customer_id = ''
     self.customer_name = ''
     self.contact_persons = []
     self.currency_id = ''
     self.currency_code = ''
     self.exchange_rate = 0.0
     self.price_precision = 0
     self.template_id = ''
     self.template_name = ''
     self.is_emailed = True
     self.line_items = []
     self.sub_total = 0.0
     self.total = 0.0
     self.total_credits_used = 0.0
     self.total_refunded_amount = 0.0
     self.balance = 0.0
     self.taxes = []
     self.notes = ''
     self.terms = ''
     self.billing_address = Address()
     self.shipping_address = Address()
     self.created_time = ''
     self.last_modified_time = ''
     self.refund_mode = ''
     self.amount = ''
     self.from_account_id = ''
     self.description = ''
Exemplo n.º 2
0
 def __init__(self):
     """Initialize parameters for organization object. """
     self.organization_id = ''
     self.name = ''
     self.is_default_org = None
     self.account_created_date = ''
     self.time_zone = ''
     self.language_code = ''
     self.date_format = ''
     self.field_separator = ''
     self.fiscal_year_start_month = ''
     self.contact_name = ''
     self.industry_type = ''
     self.industry_size = ''
     self.company_id_label = ''
     self.company_id_value = ''
     self.tax_id_label = ''
     self.tax_id_value = ''
     self.currency_id = ''
     self.currency_code = ''
     self.currency_symbol = ''
     self.currency_format = ''
     self.price_precision = 0
     self.address = Address()
     self.org_address = ''
     self.remit_to_address = ''
     self.phone = ''
     self.fax = ''
     self.website = ''
     self.email = ''
     self.tax_basis = ''
     self.is_org_active = None
     self.name = ''
     self.value = ''
     self.version = ''
     self.plan_type = 0
     self.plane_name = ''
     self.plan_period = ''
     self.tax_group_enabled = None
     self.account_created_date_formatted = ""
     self.zi_migration_status = 0
     self.user_role = ''
     self.custom_fields = []
     self.is_new_customer_custom_fields = None
     self.is_portal_enabled = None
     self.portal_name = ''
     self.tax_type = ''
 def __init__(self):
     """Initialize parameters for Recurring invoice object."""
     self.recurrence_name = ''
     self.customer_id = ''
     self.contact_persons = []
     self.template_id = ''
     self.start_date = ''
     self.end_date = ''
     self.recurrence_frequency = ''
     self.repeat_every = 0
     self.payment_terms = 0
     self.payment_terms_label = ''
     self.exchange_rate = 0.0
     self.payment_options = {'payment_gateways': []}
     self.discount = ''
     self.is_discount_before_tax = ''
     self.discount_type = ''
     self.line_items = []
     self.salesperson_name = ''
     self.shipping_charge = 0.0
     self.adjustment = 0.0
     self.adjustment_description = ''
     self.notes = ''
     self.terms = ''
     self.recurring_invoice_id = ''
     self.status = ''
     self.total = 0.0
     self.customer_name = ''
     self.last_sent_date = ''
     self.next_invoice_date = ''
     self.created_time = ''
     self.last_modified_time = ''
     self.currency_id = ''
     self.price_precision = 0
     self.currency_code = ''
     self.currency_symbol = ''
     self.late_fee = {}
     self.sub_total = 0.0
     self.tax_total = 0.0
     self.allow_partial_payments = None
     self.taxes = []
     self.billing_address = Address()
     self.shipping_address = Address()
     self.template_name = ''
     self.salesperson_id = ''
     self.custom_fields = []
Exemplo n.º 4
0
 def __init__(self):
     """Initialize the parameters for contacts object."""
     self.contact_id = ''
     self.contact_name = ''
     self.company_name = ''
     self.contact_salutation = ''
     self.has_transaction = None
     self.contact_type = ''
     self.is_crm_customer = None
     self.primary_contact_id = ''
     self.price_precision = 0
     self.payment_terms = 0
     self.payment_terms_label = ''
     self.currency_id = ''
     self.currency_code = ''
     self.currency_symbol = ''
     self.outstanding_receivable_amount = 0.00
     self.outstanding_receivable_amount_bcy = 0.00
     self.outstanding_payable_amount = 0.00
     self.outstanding_payable_amount_bcy = 0.00
     self.unused_credits_receivable_amount = 0.00
     self.unused_credits_receivable_amount_bcy = 0.00
     self.unused_credits_payable_amount = 0.00
     self.unused_credits_payable_amount_bcy = 0.00
     self.status = ''
     self.payment_reminder_enabled = None
     self.notes = ''
     self.created_time = ''
     self.last_modified_time = ''
     self.first_name = ''
     self.last_name = ''
     self.email = ''
     self.phone = ''
     self.mobile = ''
     self.custom_fields = []
     self.track_1099 = None
     self.tax_id_type = ''
     self.tax_id_value = ''
     self.billing_address = Address()
     self.shipping_address = Address()
     self.contact_persons = []
     self.default_templates = DefaultTemplate()
Exemplo n.º 5
0
 def __init__(self):
     """Initialize parameters for Estimates object."""
     self.estimate_id = ''
     self.estimate_number = ''
     self.date = ''
     self.reference_number = ''
     self.status = ''
     self.customer_id = ''
     self.customer_name = ''
     self.contact_persons = []
     self.currency_id = ''
     self.currency_code = ''
     self.exchange_rate = 0.00
     self.expiry_date = ''
     self.discount = 0.00
     self.is_discount_before_tax = None
     self.discount_type = ''
     self.line_items = []
     self.shipping_charge = 0.00
     self.adjustment = 0.00
     self.adjustment_description = ''
     self.sub_total = 0.0
     self.total = 0.0
     self.tax_total = 0.0
     self.price_precision = 0
     self.taxes = []
     self.billing_address = Address()
     self.shipping_address = Address()
     self.notes = ''
     self.terms = ''
     self.custom_fields = []
     self.template_id = ''
     self.template_name = ''
     self.created_time = ''
     self.last_modified_time = ''
     self.salesperson_id = ''
     self.salesperson_name = ''
     self.accepted_date = ''
     self.declined_date = ''
Exemplo n.º 6
0
 def __init__(self):
     """Initialize the parameters for bills object."""
     self.bill_id = ''
     self.bill_payment_id = ''
     self.vendor_id = ''
     self.vendor_name = ''
     self.unused_credits_payable_amount = 0.0
     self.status = ''
     self.bill_number = ''
     self.date = ''
     self.due_date = ''
     self.due_days = ''
     self.reference_number = ''
     self.due_by_days = 0
     self.due_in_days = ''
     self.currency_id = ''
     self.currency_code = ''
     self.currency_symbol = ''
     self.price_precision = 0
     self.exchange_rate = 0.0
     self.line_items = []
     self.sub_total = 0.0
     self.tax_total = 0.0
     self.total = 0.0
     self.taxes = []
     self.amount_applied = 0.0
     self.payment_made = 0.0
     self.balance = 0.0
     self.billing_address = Address()
     self.payments = []
     self.created_time = ''
     self.last_modified_time = ''
     self.reference_id = ''
     self.attachment_name = ''
     self.account_id = ''
     self.description = ''
     self.rate = 0.0
     self.quantity = 0.0
     self.tax_id = ''
     self.notes = ''
     self.terms = ''
     self.is_inclusive_tax = False
    def get_shipping_address(self,response):
        """This method parses the given response and returns address object 
            for shipping address.
     
        Args:
            response(dict): Response containing json object for shipping 
                address.

        Returns:
            instance: Address object for shipping address.

        """ 
        address = response['shipping_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_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
Exemplo n.º 9
0
# Delete a bill

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
Exemplo n.º 10
0
    def get_shipping_address(self, response):
        """This method parses the given response and returns shipping address 
            object.

        Args:
            response(dict): Response containing json object for shipping 
                address.
 
        Returns:
            instance: Shipping address object.

        """
        address = response['shipping_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
Exemplo n.º 11
0
#enable payment reminder

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')
Exemplo n.º 12
0
    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
    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_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
Exemplo n.º 16
0
    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
Exemplo n.º 17
0
    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
Exemplo n.º 18
0
#enable payment reminder

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')
    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
Exemplo n.º 20
0
con_per = []
cp = ContactPerson()
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)
Exemplo n.º 21
0
    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
Exemplo n.º 22
0
    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
Exemplo n.º 23
0
class Organization: 
    """This class is used to create object for organization."""
    def __init__(self):
        """Initialize parameters for organization object. """
        self.organization_id = ''
        self.name = ''
        self.is_default_org = None
        self.account_created_date = ''
        self.time_zone = ''
        self.language_code = ''
        self.date_format = ''
        self.field_separator = ''
        self.fiscal_year_start_month = ''
        self.contact_name = ''
        self.industry_type = ''
        self.industry_size = ''
        self.company_id_label = ''
        self.company_id_value = ''
        self.tax_id_label = ''
        self.tax_id_value = ''
        self.currency_id = ''
        self.currency_code = ''
        self.currency_symbol = ''
        self.currency_format = ''
        self.price_precision = 0
        self.address = Address()
        self.org_address = ''
        self.remit_to_address = ''
        self.phone = ''
        self.fax = ''
        self.website = ''
        self.email = ''
        self.tax_basis = ''
        self.is_org_active = None
        self.name = ''
        self.value = ''
        self.version = ''
        self.plan_type = 0
        self.plane_name = ''
        self.plan_period = ''
        self.tax_group_enabled = None
        self.account_created_date_formatted = ""
        self.zi_migration_status = 0
        self.user_role = ''
        self.custom_fields = []
        self.is_new_customer_custom_fields = None
        self.is_portal_enabled = None
        self.portal_name = ''
        self.tax_type = ''

    def set_organization_id(self, organization_id):
        """Set organization id.

        Args: 
            organization_id(str): Organization id.

        """
        self.organization_id = organization_id

    def get_organization_id(self):
        """Get organization id.

        Returns:
            str: Organization id.

        """
        return self.organization_id

    def set_name(self, name):
        """Set name.

        Args:
            name(str): Name.

        """
        self.name = name

    def set_is_default_org(self, is_default_org):
        """Set whether it is default organization.

        Args:
            is_default_org(bool): True if it is default organization else false.

        """
        self.is_default_org = is_default_org

    def get_is_default_org(self): 
        """Get whether it is default organization.

        Returns:
            bool: True if it is default organization else false.

        """
        return self.is_default_org

    def set_account_created_date(self, account_created_date):
        """Set account created date.

        Args:
            account_created_date(str): Account created date.

        """
        self.account_created_date = account_created_date

    def get_account_created_date(self):
        """Get account created date.

        Returns:
            str: Account created date.

        """
        return self.account_created_date

    def set_time_zone(self, time_zone):
        """Set time zone.

        Args:
            time_zone(str): Time zone.

        """
        self.time_zone = time_zone

    def get_time_zone(self):
        """Get time zone.

        Returns:
            str: Time zone.

        """
        return self.time_zone

    def set_language_code(self, language_code):
        """Set language code.

        Args:
            language_code(str): Language code.

        """
        self.language_code = language_code

    def get_language_code(self):
        """Get language code.

        Returns:
            str: Language code.

        """
        return self.language_code

    def set_date_format(self, date_format):
        """Set date format.

        Args:
            date_format(str): Date format.

        """
        self.date_format = date_format

    def get_date_format(self):
        """Get date format.

        Returns:
            str: Date format.

        """
        return self.date_format

    def set_field_separator(self, field_separator):
        """Set field separator.

        Args:
            field_separator(str): Field separator.

        """
        self.field_separator = field_separator

    def get_field_separator(self):
        """Get field separator.

        Returns:
            str: Field separator.

        """
        return self.field_separator

    def set_fiscal_year_start_month(self, fiscal_year_start_month):
        """Set fiscal year field separator.

        Args:
            fiscal_year_start_month(str): Fiscal year start month.

        """
        self.fiscal_year_start_month = fiscal_year_start_month

    def get_fiscal_year_start_month(self):
        """Get fiscal year start month.

        Returns:
            str: Fiscal year start month.

        """
        return self.fiscal_year_start_month

    def set_contact_name(self, contact_name): 
        """Set contact name.

        Args: 
            contact_name(str): Contact name.

        """
        self.contact_name = contact_name

    def get_contact_name(self):
        """Get contact name.

        Returns:
            str: Contact name.

        """
        return self.contact_name

    def set_industry_type(self, industry_type):
        """Set industry type.

        Args:
            industry_type(str): Industry type.

        """
        self.industry_type = industry_type

    def get_industry_type(self):
        """Get industry type.

        Returns:
            str: Industry type.

        """ 
        return self.industry_type

    def set_industry_size(self, industry_size):
        """Set industry size.

        Args:
            industry_size(str): Industry size.

        """
        self.industry_size = industry_size

    def get_industry_size(self):
        """Get industry size.

        Returns:
            str: Industry size.

        """
        return self.industry_size

    def set_company_id_label(self, company_id_label):
        """Set company id label.

        Args:
            company_id_label(str): Company id label.

        """
        self.company_id_label = company_id_label

    def get_company_id_label(self):
        """Get company id label.

        Returns:
            str: Company id label.

        """
        return self.company_id_label

    def set_company_id_value(self, company_id_value):
        """Set company id value.

        Args:
            company_id_value(str): Company id value.

        """
        self.company_id_value = company_id_value

    def get_company_id_value(self):
        """Get company id value.

        Returns:
            str: Company id value.

        """
        return self.company_id_value

    def set_tax_id_label(self, tax_id_label):
        """Set tax id label.

        Args:
            tax_id_label(str): Tax id label.

        """
        self.tax_id_label = tax_id_label

    def get_tax_id_label(self):
        """Get tax id label.

        Retruns:
            str: Tax id label.

        """
        return self.tax_id_label

    def set_tax_id_value(self, tax_id_value):
        """Set tax id value.

        Args:
            tax_id_value(str): Tax id value.

        """
        self.tax_id_value = tax_id_value

    def get_tax_id_value(self):
        """Get atx id value.

        Returns:
            str: Tax id value.

        """
        return self.tax_id_value

    def set_currency_id(self, currency_id):
        """Set currency id.

        Args:
            currency_id(str): Currency id.

        """
        self.currency_id = currency_id

    def get_currency_id(self):
        """Get currency id.

        Returns:
            str: Currency id.

        """
        return self.currency_id

    def set_currency_code(self, currency_code):
        """Set currency code.

        Args:
            currency_code(str): Currency code.

        """
        self.currency_code = currency_code

    def get_currency_code(self):
        """Get currency code.

        Returns:
            str: Currency code.

        """
        return self.currency_code

    def set_currency_symbol(self, currency_symbol):
        """Set currency symbol.

        Args:
            currency_symbol(str): Currency symbol.

        """ 
        self.currency_symbol = currency_symbol

    def get_currency_symbol(self):
        """Get currency symbol.

        Returns:
            str: Currency symbol.

        """
        return self.currency_symbol

    def set_currency_format(self, currency_format):
        """Set currency format.

        Args:
            currency_format(str): Currency format.

        """
        self.currency_format = currency_format

    def get_currency_format(self):
        """Get currency format.

        Retruns:
            str: Currency format.

        """
        return self.currency_format

    def set_price_precision(self, price_precision):
        """Set price precision.

        Args:
            price_precision(int): Price precision.

        """
        self.price_precision = price_precision

    def set_address(self, address):
        """Set address.

        Args:
            address(instance): Address

        """
        self.address = address

    def get_address(self):
        """Get address.

        Returns:
            instance: Address.

        """
        return self.address

    def set_org_address(self, org_address):
        """Set organization address.

        Args:
            org_address(str): Organization address.

        """
        self.org_address = org_address

    def get_org_address(self):
        """Get organization address.

        Returns:
            str: Organization address.

        """
        return self.org_address

    def set_remit_to_address(self, remit_to_address):
        """Set remit to address.

        Args:
            remit_to_address(str): Remit to address.
 
        """
        self.remit_to_address = remit_to_address

    def get_remit_to_address(self):
        """Get remit to address.

        Returns:
            str: Remit to address.

        """ 
        return self.remit_to_address

    def set_phone(self, phone):
        """Set phone.

        Args:
            phone(str): Phone.

        """
        self.phone = phone

    def get_phone(self):
        """Get phone.

        Returns:
            str: Phone.

        """
        return self.phone

    def set_fax(self, fax):
        """Set fax.

        Args:
            fax(str): Fax.

        """
        self.fax = fax

    def get_fax(self):
        """Get fax.

        Returns:
            str: Fax.

        """
        return self.fax

    def set_website(self, website):
        """Set website.

        Args:
            website(str): Website.

        """
        self.website = website

    def set_email(self, email):
        """Set email.

        Args:
            email(str): Email.

        """
        self.email = email

    def get_email(self):
        """Get email.

        Returns:
            str: Email.

        """
        return self.email

    def set_tax_basis(self, tax_basis):
        """Set tax basis.

        Args:
            tax_basis(str): Tax basis.
      
        """
        self.tax_basis = tax_basis

    def get_tax_basis(self):
        """Get tax basis.

        Returns:
            str: Tax basis.

        """
        return self.tax_basis

    def set_is_org_active(self, is_org_active):
        """Set whether it the organization is active or not.

        Args:
            is_org_active(bool): True if organization is active else false.

        """
        self.is_org_active = is_org_active

    def set_name(self, name):
        """Set name.

        Args:
            name(str): Name.

        """
        self.name = name

    def get_name(self):
        """Get name.

        Returns:
            str: Name.

        """
        return self.name

    def set_value(self, value):
        """Set value.

        Args:
            value(str): Value.

        """
        self.value = value

    def get_value(self):
        """Get value.

        Returns:
            str: Value.

        """
        return self.value

    def set_version(self, version):
        """Set version.
 
        Args:
            version(str): Version

        """
        self.version = version

    def get_version(self):
        """Get version.

        Returns:
            str: Version.

        """
        return self.version

    def set_plan_type(self, plan_type):
        """Set plan type.

        Args:
            plan_type(int): Plan type.

        """
        self.plan_type = plan_type

    def get_plan_type(self):
        """Get plan type.

        Returns: 
            int: Plan type.

        """
        return self.plan_type

    def set_plan_name(self, plan_name):
        """Set plan name.

        Args:
            plan_name(str): Plan name.

        """
        self.plan_name = plan_name

    def get_plan_name(self):
        """Get plan name.

        Args:
            str: Plan name.

        """
        return self.plan_name

    def set_plan_period(self, plan_period):
        """Set plan period.

        Args:
            plan_period(str): Plan period.

        """
        self.plan_period = plan_period

    def get_plan_period(self):
        """Get plan period.

        Returns:
            str: Plan period.

        """
        return self.plan_period

    def set_tax_group_enabled(self, tax_group_enabled):
        """Set tax group enabled.

        Args:
            tax_group_enabled(bool): Tax group enabled.

        """
        self.tax_group_enabled = tax_group_enabled

    def get_tax_group_enabled(self):
        """Get tax group enabled.

        Returns:
            bool: Tax group enabled.

        """
        return self.tax_group_enabled

    def set_account_created_date_formatted(self, account_created_date_formatted):
        """Set account created date formatted.

        Args:
            account_created_date_formatted(str): Account created date formatted.

        """
        self.account_created_date_formatted = account_created_date_formatted

    def get_account_created_date_formatted(self):
        """Get account created date formatted.

        Returns: 
            str: Account created date formatted.

        """
        return self.account_created_date_formatted

    def set_zi_migration_status(self, zi_migration_status):
        """Set zi migration status.

        Args:
            zi_migration_status(int): Zi migration status.

        """
        self.zi_migration_status = zi_migration_status

    def get_zi_migration_status(self):
        """Get zi migration status .

        Returns:
            int: Zi migration status.

        """
        return self.zi_migration_status

    def set_custom_fields(self, custom_field):
        """Set custom fields.

        Args:
            custom_field(instance): Custom field.

        """
        self.custom_fields.append(custom_field)

    def get_custom_fields(self):
        """Get custom fields.

        Returns:
            list of instance: List of custom fields object.

        """
        return self.custom_fields

    def set_user_role(self, user_role):
        """Set user role.

        Args:
            user_role(str): User role.

        """
        self.user_role = user_role

    def get_user_role(self):
        """Get user role.

        Returns:
            str: User role.

        """
        return self.user_role

    def set_is_new_customer_custom_fields(self, is_new_customer_custom_fields):
        """Set whether new customer custom fields or not.

        Args:
            is_new_customer_custom_fields(bool): True if new customer custom fields else False.

        """
        self.is_new_customer_custom_fields = is_new_customer_custom_fields

    def get_is_new_customer_custom_fields(self):
        """Get whether new customer custom fields or not.

        Returns:
            bool: True if new customer custom fields else false.

        """ 
        return self.is_new_customer_custom_fields

    def set_is_portal_enabled(self, is_portal_enabled):
        """Set whether portal is enabled or not.

        Args:
            is_portal_enabled(bool): True if portal enabled else false.

        """
        self.is_portal_enabled = is_portal_enabled

    def get_is_portal_enabled(self):
        """Get whether is portal enabled.

        Returns:
            bool: True if portal is enabled else false.

        """
        return self.is_portal_enabled

    def set_portal_name(self, portal_name):
        """Set portal name.

        Args:
            portal_name(str): Portal name.

        """
        self.portal_name = portal_name

    def get_portal_name(self):
        """Get portal name.

        Returns:
            str: Portal name.

        """
        return self.portal_name

    def set_tax_type(self, tax_type):
        """Set tax type.

        Args:
            tax_type(str): Tax type.

        """
        self.tax_type = tax_type

    def get_tax_type(self):
        """Get tax type.

        Returns:
            str: Tax type.

        """
        return self.tax_type

    def to_json(self):
        """This method is used to convert organizations object to json format.

        Returns:
            dict: Dictionary containing json object for organizations.

        """
        data = {}
        if self.name != '':
            data['name'] = self.name
        if self.address is not None:
            data['address'] = self.address.to_json()
        if self.industry_type != '':
            data['industry_type'] = self.industry_type
        if self.industry_size != '':
            data['industry_size'] = self.industry_size
        if self.fiscal_year_start_month != '':
            data['fiscal_year_start_month'] = self.fiscal_year_start_month
        if self.currency_code != '':
            data['currency_code'] = self.currency_code
        if self.time_zone != '':
            data['time_zone'] = self.time_zone
        if self.date_format != '':
            data['date_format'] = self.date_format
        if self.field_separator != '':
            data['field_separator'] = self.field_separator
        if self.language_code != '':
            data['language_code'] = self.language_code
        if self.tax_basis != '':
            data['tax_basis'] = self.tax_basis
        if self.org_address != '':
            data['org_address'] = self.org_address
        if self.remit_to_address != '':
            data['remit_to_address'] = self.remit_to_address
        if self.tax_type != '':
            data['tax_type'] = self.tax_type
        return data
Exemplo n.º 24
0
    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
Exemplo n.º 25
0
#Organization
organization_id = organizations_api.get_organizations()[0].get_organization_id()

# 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")
Exemplo n.º 26
0
                                         customer_id)
print credit_notes_api.email_credit_note(credit_note_id, email, attachments,
                                         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')
    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
Exemplo n.º 28
0
    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 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
Exemplo n.º 30
0
con_per = []
cp = ContactPerson()
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)
Exemplo n.º 31
0
print credit_notes_api.email_credit_note(credit_note_id,email)
print credit_notes_api.email_credit_note(credit_note_id,email,None,customer_id)
print credit_notes_api.email_credit_note(credit_note_id,email,attachments,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')