code
stringlengths
501
5.19M
package
stringlengths
2
81
path
stringlengths
9
304
filename
stringlengths
4
145
import json import os import pickle import time import urllib import requests __author__ = 'Saurav Koli' __version__ = '1.0' class ZohoAPITokens: def __init__(self, **kwargs): regionSpecificDomain = {'EU': 'https://accounts.zoho.eu', 'CN': 'https://accounts.zoho.com.cn', 'IN': 'https://accounts.zoho.in', None: 'https://accounts.zoho.com'} self.client_id = kwargs.get('client_id') self.client_secret = kwargs.get('client_secret') self.redirect_uri = kwargs.get('redirect_uri') self.scope = kwargs.get('scope') self.domain = kwargs.get('region') self.url = f'{regionSpecificDomain.get("self.domain")}/oauth/v2/token' self.confirmation_code = None self.token = None self.tokenPickleFile = 'token.pickle' self.params = { 'client_id' : self.client_id, 'client_secret': self.client_secret, 'redirect_uri' : self.redirect_uri, 'scope' : self.scope } def generate_access_and_refresh(self): ''' Generate access and refresh token using the confirmation code from the api portal. Args: confirmation_code: Returns: token dict: Dict with following data - access_token string: refresh_token string: api_domain string: token_type string: expires_in int: valid_until epoch: ''' params = self.params.copy() params.update({ 'code' : self.confirmation_code, 'grant_type' : 'authorization_code', }) response = requests.request("POST", f'{self.url}?' + urllib.parse.urlencode(params)) self.token = json.loads(response.text) if self.token.get('expires_in'): valid_until = time.time() + self.token.get('expires_in') self.token.update({'valid_until': valid_until}) self.writePickle() else: raise Exception(f'Error occured while requesting token : {self.token}') def refreshToken(self): ''' Generate access_token using refresh_token after the validity of the access_token has expired. Args: refresh_token: refresh token to generate new access token. Returns: new_token dict: dict with new access_token and validity. ''' params = self.params.copy() params.update({ 'refresh_token': self.token.get('refresh_token'), 'grant_type' : 'refresh_token' }) response = requests.request("POST", f'{self.url}?' + urllib.parse.urlencode(params)) refreshed_token = json.loads(response.text) access_token = refreshed_token.get('access_token') valid_until = time.time() + refreshed_token.get('expires_in') self.token.update({ 'access_token': access_token, 'valid_until' : valid_until }) self.writePickle() def writePickle(self): outfile = open(self.tokenPickleFile, 'wb') pickle.dump(self.token, outfile) outfile.close() def readPickle(self): infile = open(self.tokenPickleFile, 'rb') self.token = pickle.load(infile) infile.close() def auth_token(self): ''' Uses OAuth2.0 to generate and refresh access_token for servicedesk. Returns: access_token string: Bearer access_token to access servicedesk apis. ''' if not self.client_id or not self.client_secret: print("No Client ID and Client Secret present. Please read the documentation.") return f'ERROR: APPLICATION NOT CONFIGURED.' if not os.path.isfile(self.tokenPickleFile): print( f'ERROR: {self.tokenPickleFile} does not exist. No access and refresh token has been generated or missing.\n' f'Visit https://api-console.zoho.com/client/{self.client_id}, add Scope, Description and Generate the code.') self.confirmation_code = input("Enter the Generated Code : ") self.generate_access_and_refresh() else: self.readPickle() validity = self.token.get('valid_until') if not validity > time.time(): self.refreshToken() return self.token.get('access_token') def revokeRefreshToken(self): if os.path.isfile(self.tokenPickleFile): self.readPickle() response = requests.request("POST", f'{self.url}/revoke?token={self.token.get("refresh_token")}') revoked = json.loads(response.text) if revoked.get('status') == 'success': self.token = None os.remove(self.tokenPickleFile) print('Refresh token has been revoked. token.pickle file is deleted.') else: raise Exception('Unable to revoke refresh token. Please try again after sometime.') return 'Done' if __name__ == '__main__': sd = ZohoAPITokens( client_id='1000.J12PAVVP6OZOO0BV5LUYYJQTZ3E3FW', client_secret='238b374c82123f8bfe02e3621b11d44e6e4be76b82', redirect_uri='https://servicedesk.alef.ae', scope='SDPOnDemand.requests.ALL,SDPOnDemand.assets.ALL', ) for _ in range(0,5): print(sd.auth_token()) time.sleep(10) sd.revokeRefreshToken()
zoho-oauth2
/zoho_oauth2-1.0.7.tar.gz/zoho_oauth2-1.0.7/zoho_oauth2/main.py
main.py
import ast import json from requests import HTTPError from client.client import Client try: from urllib.parse import urlencode, quote except: from urllib import urlencode, quote try: from django.conf import settings as configuration except ImportError: try: import config as configuration except ImportError: print("Zoho configurations not found in config/django settings, must be passed while initializing") class Invoice: def __init__(self, config=None): if config is None: self.client = Client(configuration.ZOHO_SUBSCRIPTION_CONFIG) else: self.client = Client(config) def list_invoices_by_customer(self,customer_id): cache_key = "zoho_invoices_%s" % customer_id response = self.client.get_from_cache(cache_key) if response is None: invoices_by_customer_uri = 'invoices?customer_id=%s' % customer_id result = self.client.send_request("GET", invoices_by_customer_uri) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['invoices'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response def get_invoice(self,invoice_id): cache_key = "zoho_invoices_%s" % invoice_id response = self.client.get_from_cache(cache_key) if response is None: invoice_by_invoice_id_uri = 'invoices/%s'%invoice_id result = self.client.send_request("GET", invoice_by_invoice_id_uri) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['invoice'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response def get_invoice_pdf(self,invoice_id): data = {'query': {'accept': 'pdf'}} invoice_pdf_by_invoice_id_uri = 'invoices/%s'%invoice_id headers = {"Accept": "application/pdf"} result = self.client.send_request("GET", invoice_pdf_by_invoice_id_uri,data=data, headers=headers) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] return result
zoho-subscriptions
/zoho-subscriptions-1.0.1.tar.gz/zoho-subscriptions-1.0.1/subscriptions/invoice.py
invoice.py
import ast import json from requests import HTTPError from client.client import Client from subscriptions import addon from subscriptions.addon import Addon try: from urllib.parse import urlencode, quote except: from urllib import urlencode, quote try: from django.conf import settings as configuration except ImportError: try: import config as configuration except ImportError: print("Zoho configurations not found in config/django settings, must be passed while initializing") class Plan: add_on_types = ['recurring', 'one_time', ] def __init__(self, config=None): if config is None: self.client = Client(configuration.ZOHO_SUBSCRIPTION_CONFIG) else: self.client = Client(config) def list_plans(self, filters=None, with_add_ons=True, add_on_type=None): cache_key = 'plans' response = self.client.get_from_cache(cache_key) if response is None: list_of_plan_uri = 'plans' result = self.client.send_request("GET", list_of_plan_uri) response = result['plans'] self.client.add_to_cache(cache_key, response) if filters is not None: for plan in response: if (plan['name'] == filters['name'] or plan['plan_code'] == filters['plan_code']): return plan # if with_add_ons is not None: # if with_add_ons in add_on_type: # return None else: print("Returning from cache : " + cache_key) return response def get_plan(self, plan_code): cache_key = 'plan_%s' % plan_code response = self.client.get_from_cache(cache_key) if response is None: plan_by_plan_code = 'plans/%s' % plan_code result = self.client.send_request("GET", plan_by_plan_code) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['plan'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response def get_addons_for_plan(self,plan_code): cache_key = 'plans' addon_code_list = [] addon = Addon() response = self.client.get_from_cache(cache_key) if response is None: list_of_plan_uri = 'plans' result = self.client.send_request("GET", list_of_plan_uri) response = result['plans'] self.client.add_to_cache(cache_key, response) if plan_code is not None: for each_plan in response: if each_plan.get("addons"): if each_plan.get('plan_code')== plan_code: for each_addon_code in each_plan["addons"]: addon_code_list.append(addon.get_addon(each_addon_code['addon_code'])) return addon_code_list else: print("Returning from cache : " + cache_key) # Filter Plan def get_price_by_plan_code(self, plan_code): cache_key = 'plan_%s' % plan_code response = self.client.get_from_cache(cache_key) if response is None: plan_by_plan_code = 'plans/%s' % plan_code result = self.client.send_request("GET", plan_by_plan_code) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['plan'] self.client.add_to_cache(cache_key, response) recurring_price = response['recurring_price'] return recurring_price else: print("Returning from cache : " + cache_key) return response
zoho-subscriptions
/zoho-subscriptions-1.0.1.tar.gz/zoho-subscriptions-1.0.1/subscriptions/plan.py
plan.py
import ast import json from requests import HTTPError from client.client import Client from subscriptions.addon import Addon from subscriptions.customer import Customer from subscriptions.hostedpage import HostedPage from subscriptions.invoice import Invoice from subscriptions.plan import Plan try: from urllib.parse import urlencode, quote except: from urllib import urlencode, quote try: from django.conf import settings as configuration except ImportError: try: import config as configuration except ImportError: print("Zoho configurations not found in config/django settings, must be passed while initializing") class Subscription: def __init__(self, config=None): if config is None: self.client = Client(configuration.ZOHO_SUBSCRIPTION_CONFIG) else: self.client = Client(config) def plan(self): return Plan(self.client) def customer(self): return Customer(self.client) def add_on(self): return Addon(self.client) def invoice(self): return Invoice(self.client) def hosted_page(self): return HostedPage(self.client) def get(self, id): cache_key = "zoho_subscription_%s" % id response = self.client.get_from_cache(cache_key) if response is None: get_subscription_by_id_uri = "subscriptions/%s" % id response = self.client.send_request("GET", get_subscription_by_id_uri) self.client.add_to_cache(cache_key, response) else: print ("Returning from cache : " + cache_key) return response def create(self, data): return self.client.send_request("POST", 'subscriptions', data=data, headers=None) def buy_add_on(self, subscription_id, data): buy_add_on_uri = 'subscriptions/%s/buyonetimeaddon' % subscription_id return self.client.send_request("POST", buy_add_on_uri, data=data, headers=None) def associate_coupon(self, subscription_id, coupon_code): coupon_uri = 'subscriptions/%s/coupons/%s' % (subscription_id, coupon_code) return self.client.send_request("POST", coupon_uri) def reactivate(self, subscription_id): reactivate_uri = 'subscriptions/%s/reactivate' % subscription_id self.client.send_request("POST", reactivate_uri) def list_subscriptions_by_customer(self, customer_id): cache_key = "zoho_subscriptions_by_customer_%s" % customer_id response = self.client.get_from_cache(cache_key) if response is None: subscriptions_by_customer_uri = 'subscriptions?customer_id=%s' % customer_id result = self.client.send_request("GET", subscriptions_by_customer_uri) response = result['subscriptions'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response def get_subscriptions(self,subscription_id): cache_key = "zoho_subscriptions_by_customer_%s" % subscription_id response = self.client.get_from_cache(cache_key) if response is None: subscriptions_by_subscription_id_uri = 'subscriptions/%s'%subscription_id result = self.client.send_request("GET", subscriptions_by_subscription_id_uri) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['subscription'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response
zoho-subscriptions
/zoho-subscriptions-1.0.1.tar.gz/zoho-subscriptions-1.0.1/subscriptions/subscription.py
subscription.py
import ast import hashlib import json from requests import HTTPError from client.client import Client try: from urllib.parse import urlencode, quote except: from urllib import urlencode, quote try: from django.conf import settings as configuration except ImportError: try: import config as configuration except ImportError: print("Zoho configurations not found in config/django settings, must be passed while initializing") # class Customer: # def __init__(self, client): # self.client = client class Customer: def __init__(self, config=None): if config is None: self.client = Client(configuration.ZOHO_SUBSCRIPTION_CONFIG) else: self.client = Client(config) def get_list_customers_by_Email(self, customer_email): cache_key = 'zoho_customer_%s' % hashlib.md5(customer_email.encode('utf-8')).hexdigest() response = self.client.get_from_cache(cache_key) if response is None: list_of_customers_by_Email_uri = 'customers?email=%s' % customer_email result = self.client.send_request("GET", list_of_customers_by_Email_uri) response = result['customers'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response def get_customer_by_Email(self, customer_email): customers = self.get_list_customers_by_Email(customer_email) if len(customers) == 0: return {"message": f"customer with email {customer_email} not found"} return self.get_customer_by_id(customers[0]['customer_id']) def get_customer_by_id(self, customer_id): cache_key = 'zoho_customer_%s' % customer_id response = self.client.get_from_cache(cache_key) if response is None: customer_by_customer_id_uri = 'customers/%s' % customer_id result = self.client.send_request("GET", customer_by_customer_id_uri) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['customer'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response def update_customer(self, customer_id, data): cache_key = 'zoho_customer_%s' % customer_id headers = {'Content-type': 'application/json'} update_customer_by_customer_id = 'customers/%s' % customer_id result = self.client.send_request("PUT", update_customer_by_customer_id, data=data, headers=headers) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] if result['code'] == 0: customer_val = result['customer'] self.delete_customer_cache(cache_key) return customer_val else: return None def delete_customer_cache(self, cache_key_by_id): result = self.client.delete_from_cache(cache_key_by_id) return result def create_customer(self, data): headers = {'Content-type': 'application/json'} result = self.client.send_request("POST", 'customers', data=data, headers=headers) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: if result.get('customer'): customer = result['customer'] return customer
zoho-subscriptions
/zoho-subscriptions-1.0.1.tar.gz/zoho-subscriptions-1.0.1/subscriptions/customer.py
customer.py
import ast from requests import HTTPError from client.client import Client try: from urllib.parse import urlencode, quote except: from urllib import urlencode, quote try: from django.conf import settings as configuration except ImportError: try: import config as configuration except ImportError: print("Zoho configurations not found in config/django settings, must be passed while initializing") class Addon: def __init__(self, config=None): if config is None: self.client = Client(configuration.ZOHO_SUBSCRIPTION_CONFIG) else: self.client = Client(config) def list_addons(self, filters=None): cache_key = 'addons' response = self.client.get_from_cache(cache_key) if response is None: list_of_addons_uri = 'addons' result = self.client.send_request("GET", list_of_addons_uri) response = result['addons'] self.client.add_to_cache(cache_key, response) if filters is not None: for addon in response: if (addon['name'] == filters['name'] or addon['addon_code'] == filters['addon_code']): return addon else: print("Returning from cache : " + cache_key) return response def get_addon(self, addon_code=None): cache_key = 'addon_%s' % addon_code response = self.client.get_from_cache(cache_key) if response is None: addon_by_addon_code = 'addons/%s' % addon_code result = self.client.send_request("GET", addon_by_addon_code) if type(result) is HTTPError: result_bytes = result.response._content result_dict = ast.literal_eval(result_bytes.decode('utf-8')) return result_dict['message'] else: response = result['addon'] self.client.add_to_cache(cache_key, response) else: print("Returning from cache : " + cache_key) return response
zoho-subscriptions
/zoho-subscriptions-1.0.1.tar.gz/zoho-subscriptions-1.0.1/subscriptions/addon.py
addon.py
import ast import json import requests from cachetools import TTLCache from requests import HTTPError from utils.constants import DEFAULT_CACHE_MODE, DEFAULT_CACHE_TTL, ZOHO_AUTH_HEADER, ZOHO_AUTH_TOKEN_HEADER_PREFIX, \ ZOHO_ORG_ID_HEADER, ZOHO_SUBSCRIPTION_API_URL, DEFAULT_CACHE_MAXSIZE class Client: def __init__(self, config): self.auth_token = config["authtoken"] self.zoho_org_id = config["zohoOrgId"] try: self.cache_enabled = config["cache_enabled"] except KeyError: self.cache_enabled = DEFAULT_CACHE_MODE try: self.cache_ttl = config["cache_ttl"] except KeyError: self.cache_ttl = DEFAULT_CACHE_TTL self.requests = requests.Session() self.cache = TTLCache(ttl=self.cache_ttl, maxsize=DEFAULT_CACHE_MAXSIZE) def add_to_cache(self, key, value): if (self.cache_enabled is None) or (self.cache_enabled is False): pass else: self.cache[key] = value def get_from_cache(self, key): if (self.cache_enabled is None) or (self.cache_enabled is False): return None else: try: return self.cache[key] except KeyError: return None def delete_from_cache(self, key): if (self.cache_enabled is None) or (self.cache_enabled is False): return False else: try: self.cache.pop(key=key) return True except KeyError: return False # my_key = ast.literal_eval(key) # return self.cache.pop(key=key) def get_request_headers(self, headers): default_headers = { ZOHO_AUTH_HEADER: ZOHO_AUTH_TOKEN_HEADER_PREFIX + self.auth_token, ZOHO_ORG_ID_HEADER: self.zoho_org_id, 'Content-Type': "application/json" } if (headers is not None) and len(headers) > 0: default_headers.update(headers) return default_headers def send_request(self, method, uri, data=None, headers=None): try: response = requests.request(method, ZOHO_SUBSCRIPTION_API_URL + uri, data=json.dumps(data), headers=self.get_request_headers(headers)) response.raise_for_status() except HTTPError as http_err: return http_err except Exception as err: return None if response.headers['Content-Type'] == 'application/json;charset=UTF-8': return json.loads(response.text) else: return response.content
zoho-subscriptions
/zoho-subscriptions-1.0.1.tar.gz/zoho-subscriptions-1.0.1/client/client.py
client.py
## **ZohoBooks Python Client Library** ========================================= The Python library for integrating with the Zoho Books API. ## Installation --------------- Download the `Books` folder from github repository and add the files in them to your project. ## Documentation ---------------- [API Reference](https://www.zoho.com/books/api/v3/index.html) ## Usage -------- In order to access the Zoho Books APIs, users need to have a valid Zoho account and a valid Auth Token. ### **Sign up for a Zoho Account:** - - - For setting up a Zoho account, access the Zoho Books [Sign Up](https://www.zoho.com/books/signup) page and enter the requisite details - email address and password. ### **Generate Auth Token:** - - - To generate the Auth Token, you need to send an authentication request to Zoho Accounts in a prescribed URL format. [Refer here](https://www.zoho.com/books/api/v3/index.html) ## Python Wrappers - Sample ### How to access Zoho Books APIs through Python wrapper classes? ------------------------------------------------------------------ Below is a sample code for accessing the Books APIs through Python wrapper classes. Please import these classes: from books.model.Organization import Organization from books.model.Address import Address from books.api.OrganizationsApi import OrganizationsApi from books.service.ZohoBooks import ZohoBooks Once you're done with importing the requisite classes, you'll have to proceed to create an instance of OrganisationsAPI. ### **Create OrganisationsAPI instance:** - - - Now there are two ways of creating an instance of OrganisationsAPI. - Pass the AuthToken and create a OrganisationsAPIinstance. Sample code: organizations_api = OrganizationsApi({"authtoken"}, {"organization_id"}) - Pass the AuthToken and organisations id to first create an instance of ZohoBooks, and then proceed to get the instance of Organisations API. Sample code: zoho_books = ZohoBooks({"authtoken"}, {"organization_id"}) organizations_api = zoho_books.get_organizations_api() ### **Get the list of organizations:** - - - If you wish to get the list of all your Zoho Books organizations, you need to call the `get_organizations()` method in the format below: print organizations_api.get_organizations() It returns the list of organizations object as a response. ### **Get details of an organization:** - - - In order to get the details of a organization, you need to call the `get()` method by passing organization_id as a parameter. print organizations_api.get({"organization_id"}) ### **Create a new organization:** - - - Make use of the sample code below to create a new organization: organization = Organization() organization.set_name("ZOHO") address = Address() address.set_street_address1("9390 Research Blvd") address.set_street_address2("Bldg II, Suite 440") address.set_city("Austin") address.set_state("Texas") address.set_country("U.S.A") address.set_zip("78759") organization.set_address(address) organization.set_industry_type("") organization.set_industry_size("") organization.set_fiscal_year_start_month("january") organization.set_currency_code("USD") organization.set_time_zone("Asia/Calcutta") organization.set_date_format("dd MMM yyyy") organization.set_field_separator("") organization.set_language_code("en") organization.set_tax_basis("accrual") organization.set_tax_type("tax") organization.set_org_address("") organization.set_remit_to_address("") print organizations_api.create(organization) ### **Update an existing organization:** - - - Proceed to update the details of an existing organization with the help of the sample code below: organization = Organization() organization.set_name("ZOHO") address = Address() address.set_street_address1("9390 Research Blvd") address.set_street_address2("Bldg II, Suite 440") address.set_city("Austin") address.set_state("Texas") address.set_country("U.S.A") address.set_zip("78759") organization.set_address(address) organization.set_industry_type("") organization.set_industry_size("") organization.set_fiscal_year_start_month("january") organization.set_currency_code("INR") organization.set_time_zone("Asia/Calcutta") organization.set_date_format("dd MMM yyyy") organization.set_field_separator("") organization.set_language_code("en") organization.set_tax_basis("accrual") organization.set_tax_type("tax") organization.set_org_address("") organization.set_remit_to_address("") print organizations_api.update(organization_id, organization) ### **Get the parameters of an organization:** - - - To fetch organization parameters like address, currency code etc. use the sample code below: organization = organizations_api.get({"organization_id"}) currency_code = organization.get_currency_code() organization_address = organization.get_address() organization_name = organization.get_name() ### **Catch Exceptions:** - - - If there is any error encountered while calling the Python Wrappers of Zoho Books API, the respective class will throw the BooksException. Use the below mentioned code to catch the BooksException: try: organization = organizations_api.get({"organization_id"}) except BooksException as b_e: print "Error Code:" + b_e.get_code() + "\nError Message:" + b_e.get_message() For a full set of examples, click [here](../../tree/master/test).
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/README.md
README.md
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.BankAccountsParser import BankAccountsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'bankaccounts/' zoho_http_client = ZohoHttpClient() parser = BankAccountsParser() class BankAccountsApi: """Bank Accounts Api is used to 1.List all bank and credit card accounts of the organization. 2.Get detailed look of a specified account. 3.Create a bank account or a credit card account for an organization. 4.Modify an existing account. 5.Delete an existing bank account from an organization. 6.Make an account inactive. 7.Make an account active. 8.Get the details of last imported statement. 9.Delete the statement that was imported lastly. """ def __init__(self, authtoken, organization_id): """Initialize Bank accounts api using user's authtoken and organization id. Args: authotoken(str): Authtoken. organization id(str): Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_bank_accounts(self, parameter=None): """List all bank and credit accounts of an organization. Args: parameter(dict, optional): Filter with which the list has to be displayed. Defaults to None. Returns: instance: Bank accounts list object. """ resp = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(resp) def get(self, account_id): """Get bank account details. Args: account_id(str): Account id. Returns: instance: Bank accouts object. """ url = base_url + account_id resp = zoho_http_client.get(url, self.details) return parser.get_account_details(resp) def create(self, bank_account): """Create a bank account. Args: bank_account(instance): Bank accounts object. Returns: instance: Bank accounts object. """ json_object = dumps(bank_account.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_account_details(resp) def update(self, account_id, bank_account): """Update an existing bank account. Args: account_id(str): Account id. bank_account(instance): Bank account object. Returns: instance: Bank account object. """ url = base_url + account_id json_object = dumps(bank_account.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_account_details(resp) def delete(self, account_id): """Delete an existing bank account. Args: account_id(str): Account id. Returns: str: Success message('The account has been deleted.'). """ url = base_url + account_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def deactivate_account(self, account_id): """Deactivate a bank account. Args: account_id(str): Account id. Returns: str: Success message('The account has been marked as inactive.'). """ url = base_url + account_id + '/inactive' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def activate_account(self, account_id): """Activate a bank account. Args: account_id(str): Account id. str: Success message('The account has been marked as active.'). """ url = base_url + account_id + '/active' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def get_last_imported_statement(self, account_id): """Get the details of previously imported statement for the account. Args: account_id(str): Account id. Returns: instance: Statement object. """ url = base_url + account_id + '/statement/lastimported' resp = zoho_http_client.get(url, self.details) return parser.get_statement(resp) def delete_last_imported_statement(self, account_id, statement_id): """Delete the statement that was previously imported. Args: account_id(str): Account id. statement_id(str): Statement id. Returns: str: Success message('You have successfully deleted the last imported statement.'). Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + account_id + '/statement/' + statement_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/BankAccountsApi.py
BankAccountsApi.py
from os.path import basename from json import dumps from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.ContactParser import ContactParser from .Api import Api base_url = Api().base_url + 'contacts/' parser = ContactParser() zoho_http_client = ZohoHttpClient() class ContactsApi: """ContactsApi class is used: 1.To get the list of contacts for a particular organization. 2.To get details of particular contact. 3.To create a new contact for an organization. 4.To update a contact. 5.To delete a contact. 6.To mark a contact as active. 7.To mark a contact as inactive. 8.To enable payment reminders for a contact 9.To disable payment reminders for a contact. 10.To send email statement to a contact. 11.To get the statement mail content 12.To send email to a contact. 13.To list recent activities of a contact. 14.To list the refund history of a contact. 15.To track a contact for 1099 reporting. 16.To untrack a contact for 1099 reporting. """ def __init__(self, authtoken, organization_id): """Initialize Contacts Api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details={ 'authtoken': authtoken, 'organization_id': organization_id } def get_contacts(self, parameter=None): """List of contacts with pagination for a particular organization. Args: parameter(dict, optional): Filter with which the list has to be displayed. Defaults to None. Returns: instance: List of contact objects with pagination. """ response = zoho_http_client.get(base_url, self.details, parameter) return parser.get_contacts(response) def get(self, contact_id): """Get details of a contact. Args: contact_id(str): Contact_id of a particular contact. Returns: instance: Contact object. """ url = base_url + contact_id response = zoho_http_client.get(url, self.details, None) return parser.get_contact(response) def create(self, contact): """Create a contact. Args: contact(instance): Contact object. Returns: instance: Contact object. """ data = contact.to_json() field = { 'JSONString':dumps(data) } response = zoho_http_client.post(base_url, self.details, field, None) return parser.get_contact(response) def update(self, contact_id, contact): """Update a contact with the given information. Args: contact_id(str): Contact_id of the contact that has to be updated. contact(instance): Contact object which has the information that has to be updated. Returns: instance: Contact object. Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id data = contact.to_json() field = { 'JSONString':dumps(data) } response = zoho_http_client.put(url, self.details, field, None) return parser.get_contact(response) def delete(self, contact_id): """Delete a particular contact. Args: contact_id(str): Contact id of the contact to be deleted. Returns: str: Success message('The contact has been deleted'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def mark_active(self, contact_id): """Mark a contact as active. Args: contact_id(str): Contact id of the contact. Returns: str: Success message('The contact has been marked as active'). Raises: Books exception: If status is not '200' or '201'. """ url= base_url + contact_id + '/active' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def mark_inactive(self, contact_id): """Mark a contact as inactive. Args: contact_id(str): Contact id of the contact. Returns: str: Success message('The contact has been marked as inactive'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/inactive' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def enable_payment_reminder(self, contact_id): """Enable automated payment reminders for a contact. Args: contact_id(str): Contact id of the contact. Returns: str: Success message('All reminders associated with this contact have been enabled'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/paymentreminder/enable' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def disable_payment_reminder(self, contact_id): """Disable automated payment reminders for a contact. Args: contact_id(str): Contact id of the contact. Returns: str: Success message('All reminders associated with this contact have been disabled'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/paymentreminder/disable' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def email_statement(self, contact_id, email,start_date=None, end_date=None, attachments=None): """Email statement to the contact. If JSONString is not inputted, mail will be sent with the default mail content. Args: contact_id(str): Contact id of the contact. email(instance): Email. start_date(str, optional): Starting date of the statement. Default to None. end_date(str, optional): Ending date of the statement. Default to None. If starting date and ending date is not given current month's statement will be sent to the contact. attachments(list): List of files to be attached. Returns: str: Success message('Statement has to been sent to the customer'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/statements/email' data = {} data = email.to_json() if start_date is not None and end_date is not None: data['start_date'] = start_date data['end_date'] = end_date fields = { 'JSONString': dumps(data) } if attachments is None: response = zoho_http_client.post(url, self.details, fields) else: file_list = [] for value in attachments: attachment = { 'attachments': { 'filename': basename(value), 'content': open(value).read() } } file_list.append(attachment) response = zoho_http_client.post(url, self.details, fields, None, file_list) return parser.get_message(response) def get_statement_mail_content(self, contact_id, start_date, end_date): """Get the statement mail content. Args: start_date(str): Start date for statement. end_date(str): End date for statement. Returns: instance: Email object. Raises: Books exception:if status is not '200' or '201'. """ url = base_url + contact_id + '/statements/email' query_string = { 'start_date': start_date, 'end_date': end_date } response = zoho_http_client.get(url, self.details, query_string) return parser.get_mail_content(response) def email_contact(self, contact_id, email, attachments=None, send_customer_statement=None): """Send email to contact. Args: contact_id(str): Contact id of the contact. email(instance): Email object. attachments(list, optional): List of files to be attached. Default to None. send_customer_statement(bool, optional): Send customer statement pdf with email. Default to None. Returns: str: Success message('Email has been sent'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/email' json_object = dumps(email.to_json()) data = { 'JSONString': json_object } if attachments is not None and send_customer_statement is not None: file_list = [] for value in attachments: attachment = { 'attachments': { 'filename': basename(value), 'content': open(value).read() } } file_list.append(attachment) parameter = { 'send_customer_statement': send_customer_statement } response = zoho_http_client.post(url, self.details, data, parameter, file_list) elif attachments is not None: file_list = [] for value in attachments: attachment = { 'attachments': { 'filename': basename(value), 'content': open(value).read() } } file_list.append(attachment) response = zoho_http_client.post(url, self.details, data, None, file_list) elif send_customer_statement is not None: parameter = { 'send_customer_statement': send_customer_statement } response = zoho_http_client.post(url, self.details, data, parameter) else: response = zoho_http_client.post(url, self.details, data) return parser.get_message(response) def list_comments(self, contact_id): """List recent activities of a contact with pagination. Args: contact_id(str): Contact id of the contact. Returns: instance: Comments list object. Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/comments' response = zoho_http_client.get(url, self.details) return parser.get_comment_list(response) def get_comments(self, contact_id): """List recent activities of a contact. Args: contact_id(str): Contact id of the contact. Returns: list: List of comments object. Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/comments' response = zoho_http_client.get(url, self.details) return parser.get_comment_list(response).get_comments() def list_refunds(self, contact_id): """List the refund history of a contact with pagination. Args: contact_id(str): Contact id of the contact. Returns: instance: Refunds list object. Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/refunds' response = zoho_http_client.get(url, self.details) return parser.get_refund_list(response) def get_refunds(self, contact_id): """List the refund history of a contact. Args: contact_id(str): Contact id of the contact. Returns: list: List of refunds object. Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/refunds' response = zoho_http_client.get(url, self.details) return parser.get_refund_list(response).get_creditnote_refunds() def track_1099(self, contact_id): """Track a contact for 1099 reporting. Args: contact_id(str): Contact id of the contact. Returns: str: Success message('1099 tracking is enabled'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/track1099' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def untrack_1099(self, contact_id): """Track a contact for 1099 reporting. Args: contact_id(str): Contact id of the contact. Returns: str: Success message('1099 tracking is enabled'). Raises: Books exception: If status is not '200' or '201'. """ url = base_url + contact_id + '/untrack1099' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/ContactsApi.py
ContactsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.BankTransactionsParser import BankTransactionsParser from books.api.Api import Api from os.path import basename from json import dumps base_url = Api().base_url + 'banktransactions/' zoho_http_client = ZohoHttpClient() parser = BankTransactionsParser() class BankTransactionsApi: """Bank Transactions Api class is used to 1.Get all the transaction details involved in an account. 2.Get the details of a transaction. 3.Create a bank transaction based on allowed transaction types. 4.Update an existing bank transaction. 5.Delete a transaction from an account. 6.Get matching transactions. 7.Match an uncategorized transaction with an existing transaction in the account. 8.Unmatch a transaction that was previously matched and make it uncategorized. 9.Get a list of all the associated that were matched or categorized to the given imported transaction. 10.Exclude a transaction from your bank or credit card account. 11.Restore an excluded transaction in your account. 12.Categorize an uncategorized transaction by creating a new transaction. 13.Categorize an uncategorized transaction as a refund from credit note. 14.Categorize an uncategorized transaction as vendor payment. 15.Categorize an uncategorized transaction as customer payment. 16.categorize an uncategorized transaction as Expense. 17.Revert a categorized transaction as uncategorized. """ def __init__(self, authtoken, organization_id): """Initialize Bank transaction api using user's authtoken and organization id. Args: authotoken(str): User's Authtoken. organization id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_bank_transactions(self, parameter=None): """Get all transaction details involved in an account. Args: parameter: Filter with which the list has to be displayed. Returns: instance: Bank transaction list object. """ resp = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(resp) def get(self, transaction_id): """Get bank transaction details. Args: transaction_id(str): Transaction id. Returns: instance: Bank transaction object. """ url = base_url + transaction_id resp = zoho_http_client.get(url, self.details) return parser.get_transaction(resp) def create(self, transaction): """Create a bank transaction for an account. Args: transaction(instance): Bank Transaction object. Returns: instance: Bank transaction object. """ json_object = dumps(transaction.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_transaction(resp) def update(self, bank_transaction_id, transaction): """Update an existing transaction. Args: bank_transaction_id(str): Bank transaction id. transaction(instance): Bank transaction object. Returns: instance: Bank transaction object. """ url = base_url + bank_transaction_id json_object = dumps(transaction.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_transaction(resp) def delete(self, transaction_id): """Delete an existing transaction. Args: transaction_id(str): Transaction id. Returns: str: Success message('The transaction has been deleted.'). """ url = base_url + transaction_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_matching_transactions(self, bank_transaction_id, parameters=None): """Provide criteria to search for matching uncategorized transactions. Args: bank_transaction_id(str): Bank transaction id. parameters(dict, optional): Filter with which matching transactions has to be displayed. Returns: instance: Transactions list object. """ url = base_url + 'uncategorized/' + bank_transaction_id + \ '/match' resp = zoho_http_client.get(url, self.details, parameters) return parser.get_matching_transaction(resp) def match_a_transaction(self, transaction_id, transactions, account_id=None): """Match an uncategorized transaction with an existing transaction in the account. Args: transaction_id(str): Transaction id. transactions(list of instance): List of transactions object. account_id(str): Account id. Returns: str: Success message('The Uncategorized transaction is linked to the selected transaction(s) in Zoho Books.'). """ url = base_url + 'uncategorized/' + transaction_id + '/match' data = { 'transactions_to_be_matched': [] } for value in transactions: transactions_to_be_matched = {} transactions_to_be_matched['transaction_id'] = \ value.get_transaction_id() transactions_to_be_matched['transaction_type'] = \ value.get_transaction_type() data['transactions_to_be_matched'].append(\ transactions_to_be_matched) if account_id is None: query = None else: query = { 'account_id': account_id } json_string = { 'JSONString': dumps(data) } resp = zoho_http_client.post(url, self.details, json_string, query) return parser.get_message(resp) def unmatch_a_matched_transaction(self, transaction_id, account_id=None): """Unmatch a transaction that was previously matched and make it uncategorized. Args: transaction_id(str): Transaction id. account_id(str): Account id. Returns: str: Success message('The transaction has been unmatched.'). """ url = base_url + transaction_id + '/unmatch' if account_id is None: parameter = None else: parameter = { 'account_id': account_id } data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data, parameter) return parser.get_message(resp) def get_associated_transactions(self, transaction_id, sort_column=None): """Get a list of all the transactions that were matched or categorized to the given imported transaction. Args: transaction_id(str): Transaction id. sort_column(str): Param description. Allowed values are statement date. Defaults to None. Returns: instance: Transaction list object. """ url = base_url + transaction_id + '/associated' if sort_column is None: param = None else: param = { 'sort_column': sort_column } resp = zoho_http_client.get(url, self.details, param) return parser.get_associated_transaction(resp) def exclude_a_transaction(self, transaction_id, account_id=None): """Exclude a transaction from your bank or credit card account. Args: transaction_id(str): Transaction id. account_id(str, optional): Account id. Returns: str: Success message('The transaction has been excluded.'). """ url = base_url + 'uncategorized/' + transaction_id + '/exclude' if account_id is None: param = None else: param = { 'account_id': account_id } data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data, param) return parser.get_message(resp) def restore_a_transaction(self, transaction_id, account_id=None): """Restore a transaction. Args: transaction_id(str): Transaction id. account_id(str,optional): Account id. Returns: str: Success message('The excluded transactions has been restored.'). Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + 'uncategorized/' + transaction_id + '/restore' if account_id is None: param = None else: param = { 'account_id': account_id } data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data, param) return parser.get_message(resp) def categorize_an_uncategorized_transaction(self, transaction_id, \ transaction): """Categorize an uncategorized transaction by creating a new transaction. Args: transaction_id(str): Transaction id. transaction(instance): Bank transaction object. Returns: str: Success message('The transaction is now categorized.'). """ url = base_url + 'uncategorized/' + transaction_id + '/categorize' json_object = dumps(transaction.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def categorize_as_credit_note_refunds(self, transaction_id, credit_note): """Categorize an uncategorized transaction as a refund from a credit note. Args: transaction_id(str): Transaction id. credit_note(instance): Credit note object. Returns: str: Success message('The transaction is now categorized.'). """ url = base_url + 'uncategorized/' + transaction_id + \ '/categorize/creditnoterefunds' json_object = dumps(credit_note.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def categorize_as_vendor_payment(self, transaction_id, vendor_payment): """Categorize an uncategorized transaction as Vendor payment. Args: transaction_id(str): Transaction id. vendor_payment(instance): Vendor payment object. Returns: str: Success message('The transaction is now categorized.'). """ url = base_url + 'uncategorized/' + transaction_id + \ '/categorize/vendorpayments' json_object = dumps(vendor_payment.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def categorize_as_customer_payment(self, transaction_id, customer_payment, \ contact_ids=None): """Categorize an uncategorized transaction as Customer Payment. Args: transaction_id(str): Transaction id. customer_payment(instance): Customer payment object. contact_ids(str, optional): Contact ids. Defaults to None. Returns: str: Success message('The transaction is now categorized.'). """ url = base_url + 'uncategorized/' + transaction_id + \ '/categorize/customerpayments' json_object = dumps(customer_payment.to_json()) data = { 'JSONString': json_object } if contact_ids is None: param = None else: param = { 'contact_ids': contact_ids } resp = zoho_http_client.post(url, self.details, data, param) return parser.get_message(resp) def categorize_as_expense(self, transaction_id, expense, receipt=None): """Categorize an uncategorized transaction as expense. Args: transaction_id(str): Transaction id. expense(instance): Expense object. receipt(file, optional): File to be attached. Allowed Extensions are gif, png, jpeg, jpg, bmp and pdf. Returns: str: Success message('The transaction is now categorized.'). """ url = base_url + 'uncategorized/' + transaction_id + \ '/categorize/expense' json_object = dumps(expense.to_json()) data = { 'JSONString': json_object } if receipt is None: attachments = None else: attachments = [{ 'receipt': { 'filename': basename(receipt), 'content': open(receipt).read() } }] print(data) resp = zoho_http_client.post(url, self.details, data, None, attachments) return parser.get_message(resp) def uncategorize_a_categorized_transaction(self, transaction_id, account_id=None): """Revert a categorized transaction as uncategorized. Args: transaction_id(str): Transaction id. account_id(str, optional): Account id. Defaults to None. Returns: str: Success message('The transaction has been uncategorized.'). """ url = base_url + transaction_id + '/uncategorize' if account_id is None: query = None else: query = { 'account_id': account_id } data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data, query) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/BankTransactionsApi.py
BankTransactionsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.SettingsParser import SettingsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'organizations/' zoho_http_client = ZohoHttpClient() parser = SettingsParser() class OrganizationsApi: """Organization api is used to 1.List organizations. 2.Get the details of an organization. 3.Create an organization. 4.Update an organization. """ def __init__(self, authtoken, organization_id): """Initialize Settings Api using authtoken and organization id. Args: authtoken(str): User's Authtoken. organization_id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_organizations(self): """Get list of all organizations. Returns: instance: Organizations list object. """ resp = zoho_http_client.get(base_url, self.details) return parser.get_organizations(resp) def get(self, organization_id): """Get organization id. Args: organization_id(str): Organization id. Returns: instance: Organization object. """ url = base_url + organization_id resp = zoho_http_client.get(url, self.details) return parser.get_organization(resp) def create(self, organization): """Create an organization. Args: organization(instance): Organization object. Returns: instance: Organization object. """ json_obj = dumps(organization.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_organization(resp) def update(self, organization_id, organization): """Update organization. Args: organization_id(str): ORganization id. organization(instance): Organization object. Returns: instance: Organization object. """ url = base_url + organization_id json_obj = dumps(organization.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_organization(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/OrganizationsApi.py
OrganizationsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.ChartOfAccountsParser import ChartOfAccountsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'chartofaccounts/' parser = ChartOfAccountsParser() zoho_http_client = ZohoHttpClient() class ChartOfAccountsApi: """Chart of Accounts Api is used to: 1.List chart of Accounts. 2.Get the details of an account. 3.Creates an account with the given account type. 4.Updates an existing account. 5.Delete an existing account. 6.Update the account status as active. 7.Update the account status as inactive. 8.List all invoices transactions for the given account. 9.Deletes the transaction. """ def __init__(self, authtoken, organization_id): """Initilaize Chart of accounts api using user's authtoken and organization id. Args: authotoken(str): User's Authtoken. organization id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_chart_of_accounts(self, parameters=None): """Get list of chart of accounts. Args: parameters(dict, optional): Filter with which the list has to be displayed. Returns: instance: Chart of accounts list object. """ resp = zoho_http_client.get(base_url, self.details, parameters) return parser.get_list(resp) def get(self, account_id): """Get details of an account. Args: account_id(str): Account id. Returns: instance: Chart of accounts object. """ url = base_url + account_id resp = zoho_http_client.get(url, self.details) return parser.get_account(resp) def create(self, account): """Create an account. Args: account(instance): Chart of accounts object. Returns: instance: Chart of accounts object. """ json_object = dumps(account.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_account(resp) def update(self, account_id, account): """Update an account. Args: account_id(str): Account id. account(instance): Chart of accounts object. Returns: instance: Chart of accounts object. """ url = base_url + account_id json_object = dumps(account.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_account(resp) def delete(self, account_id): """Delete an account. Args: account_id(str): Account id. Returns: str: Success message('The account has been deleted.'). """ url = base_url + account_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def mark_an_account_as_active(self, account_id): """Mark an account as active. Args: account_id(str): Account id. Returns: str: Success message('The account has been marked as active.'). """ data = { 'JSONString': '' } url = base_url + account_id + '/active' resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def mark_an_account_as_inactive(self, account_id): """Mark an account as inactive. Args: account_id(str): Account id. Returns: str: Success message('The account has been marked as inactive.'). """ data = { 'JSONString': '' } url = base_url + account_id + '/inactive' resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def list_of_transactions(self, parameters=None): """List all involved transactions for a given account. Args: parameters(dict): Dictionary containing values for account id, date amount filter_by, transaction type and sort column. Returns: instance: Transaction list object. """ url = base_url + 'transactions' resp = zoho_http_client.get(url, self.details, parameters) return parser.get_transactions_list(resp) def delete_a_transaction(self, transaction_id): """Delete the transaction. Args: transaction_id(str): Transaction id. Returns: str: Success message('The transaction has been deleted.'). """ url = base_url + 'transactions/' + transaction_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/ChartOfAccountsApi.py
ChartOfAccountsApi.py
from os.path import basename from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.EstimatesParser import EstimatesParser from .Api import Api from json import dumps base_url = Api().base_url + 'estimates/' parser = EstimatesParser() zoho_http_client = ZohoHttpClient() class EstimatesApi: """Estimates Api class is used to: 1.List all estimates with pagination. 2.Get the details of an estimate. 3.Create an estimate. 4.Update an existing estimate. 5.Delete an existing estimate. 6.Mark a draft estimate as sent. 7.Mark a sent estimate as accepted. 8.Mark a sent estimate as declined. 9.Email an estimate to the customer. 10.Send estimates to your customer by email. 11.Get the email content of an estimate. 12.Export maximum of 25 pdfs as single pdf. 13.Export estimates as pdf and print them. 14.Update the billing address for the estimate. 15.Update the shipping address for the estimate. 16.Get all estimate pdf templates. 17.Update the pdf template associated with the template. 18.Get the complete history and comments of an estimate. 19.Add a comment for an estimate. 20.Update an existing comment of an estimate. 21.Delete an estimate comment. """ def __init__(self, authtoken, organization_id): """Initialize Estimates api using user's authtoken and organization id. Args: authtoken(str): Authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken':authtoken, 'organization_id':organization_id } def get_estimates(self, parameter=None): """Get list of estimates with pagination. Args: parameter(dict, optional): Filter with which the list has to be dispalyed. Returns: instance: Invoice list object. """ response = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(response) def get(self, estimate_id, print_pdf=None, accept=None): """Get details of an estimate. Args: estimate_id(str): Estimate id. print_pdf(bool, None): True to print pdf else False. accept(str, None): Get the details in particular format such as json/pdf/html. Default format is json. Allowed values are json, pdf and html. Returns: instance: Estimate object. """ url = base_url + estimate_id query = {} if print_pdf is not None and accept is not None: query = { 'print':print_pdf, 'accept':accept } resp = zoho_http_client.getfile(url, self.details, query) return resp elif print_pdf is True: query = { 'print':print_pdf, 'accept':'pdf' } resp = zoho_http_client.getfile(url, self.details, query) return resp elif accept is not None: query = { 'accept':accept } resp = zoho_http_client.getfile(url, self.details, query) return resp else: response = zoho_http_client.get(url, self.details) return parser.get_estimate(response) def create(self, estimate, send=None, ignore_auto_number_generation=None): """Create an estimate. Args: estimate(instance): Estimate object. send(bool, optional): True to send estimate to the contact persons associated with the estimate. Allowed values are true and false. ignore_auto_number_generation(bool, optional): True to ignore auto estimate number generation for this estimate. Allowed values are true and false. Returns: instance: Invoice object. """ query = {} if send is not None and ignore_auto_number_generation is not None: query = { 'send':send, 'ignore_auto_number_generation':ignore_auto_number_generation } elif send is not None or ignore_auto_number_generation is not None: query = { 'send': send } if send is not None else { 'ignore_auto_number_generation': ignore_auto_number_generation } else: query = None json_object = dumps(estimate.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.post(base_url, self.details, data, query) return parser.get_estimate(response) def update(self, estimate_id, estimate, ignore_auto_number_generation=None): """Update an existing estimate. Args: estimate_id(str): Estiamte id. estiamte(instance): Estiamte object. ignore_auto_number_generation(bool, optional): True to ignore auto estimate number generation for this estimate. Allowed values are true and false. Returns: instance: Estimates object. """ url = base_url + estimate_id query = {} if ignore_auto_number_generation is not None: query = { 'ignore_auto_number_generation': ignore_auto_number_generation } else: query = None json_object = dumps(estimate.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.put(url, self.details, data) return parser.get_estimate(response) def delete(self, estimate_id): """Delete an existing estimate. Args: estimate_id(str): Estimate id. Returns: str: Success message('The estimate has been deleted.'). """ url = base_url + estimate_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def mark_an_estimate_as_sent(self, estimate_id): """Mark a draft estimate as sent. Args: estimate_id(str): Estimate id. Returns: str: Success message('Estimate status has been changed to Sent.'). """ url = base_url + estimate_id + '/status/sent' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def mark_an_estimate_as_accepted(self, estimate_id): """Mark a sent estimate as accepted. Args: estimate_id(str): Estimate id. Returns: str: Success message('Estimate status has been changed to sent.'). """ url = base_url + estimate_id + '/status/accepted' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def mark_an_estimate_as_declined(self, estimate_id): """Mark a sent estimate as declined. Args: estimate_id(str): Estiamte id. Returns: str: Success message('Estimate status has been changed to accepted.'). """ url = base_url + estimate_id + '/status/declined' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def email_an_estimate(self, estimate_id, email, attachment=None): """Email an estimate to the customer. Args: estimate_id(str): Estimate id. email(instance): Email object. attachment(list of dict): List of dictionary containing details about files to be attached. Returns: instance: Email object. """ url = base_url + estimate_id + '/email' json_object = dumps(email.to_json()) data = { 'JSONString': json_object } if attachment is not None: file_list = [] for value in attachment: attachments = { 'attachments': { 'filename': basename(value), 'content':open(value).read() } } file_list.append(attachments) else: file_list = None response = zoho_http_client.post(url, self.details, data, None, \ file_list) return parser.get_message(response) def email_estimates(self, estimate_id): """Email estimates to the customer. Args: estimate_id(str): Estimate id. Returns: str: Success message('Mission accomplished.'). """ url = base_url + 'email' estimate_ids = { 'estimate_ids': estimate_id } response = zoho_http_client.post(url, self.details, '', \ estimate_ids) return parser.get_message(response) def get_estimate_email_content(self, estimate_id, email_template_id=None): """Get estimate email content. Args: estiamte_id(str): Estiamte id. email_template_id(str): Email template id. Returns: instance: Email object. """ url = base_url + estimate_id + '/email' query = {} if email_template_id is not None: query = { 'email_template_id':email_template_id } else: query = None response = zoho_http_client.get(url, self.details, query) return parser.get_email_content(response) def bulk_export_estimates(self, estimate_id): """Export maximum of 25 estimates as pdf. Args: estimate_id(str): Estimate id. Returns: file: Pdf containing details of estimate. """ url = base_url + 'pdf' query = { 'estimate_ids': estimate_id } response = zoho_http_client.getfile(url, self.details, query) return response def bulk_print_estimates(self, estimate_ids): """Export estimates as pdf and print them. Args: estimate_ids(str): Estimate ids. Returns: file: Pdf containing details of estimate. """ url = base_url + 'print' query = { 'estimate_ids': estimate_ids } response = zoho_http_client.getfile(url, self.details, query) return response def update_billing_address(self, estimate_id, address, is_update_customer=None): """Update billing address. Args: estimate_id(str): Estiamte id. address(instance): Address object. is_update_customer(bool, optional): True to update customer. Returns: instance: Address object. """ url = base_url + estimate_id + '/address/billing' json_object = dumps(address.to_json()) data = { 'JSONString': json_object } if is_update_customer is not None: query = { 'is_update_customer':is_update_customer } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_billing_address(response) def update_shipping_address(self, estimate_id, address, is_update_customer=None): """Update shipping address. Args: estimate_id(str): Estimate id. address(instance): Address object. is_update_customer(bool, optional): True to update customer else False. Returns: instance: Address object. """ url = base_url + estimate_id + '/address/shipping' json_object = dumps(address.to_json()) data = { 'JSONString': json_object } if is_update_customer is not None: query = { 'is_update_customer': is_update_customer } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_shipping_address(response) def list_estimate_template(self): """List all estimate pdf templates. Returns: instance: Template list object. """ url = base_url + 'templates' response = zoho_http_client.get(url, self.details) return parser.estimate_template_list(response) def update_estimate_template(self, estimate_id, template_id): """Update estimate template. Args: estimate_id(str): Estimate id. template_id(str): Template id. Returns: str: Success message('Estimate information has been updated.'). """ url = base_url + estimate_id + '/templates/' + template_id response = zoho_http_client.put(url, self.details, '') return parser.get_message(response) # Comments and History def list_comments_history(self, estimate_id): """Get complete history and comments. Args: estiamte_id(str): Estimate id. Returns: list of instance: list of comments object. """ url = base_url + estimate_id + '/comments' resp = zoho_http_client.get(url, self.details) return parser.get_comments(resp) def add_comment(self, estimate_id, description, show_comment_to_clients): """Add a comment for an estimate. Args: estimate_id(str): Estimate id. description(str): Description. show_comment_to_clients(bool): True to show comment to clients. Returns: instance: Comments object. """ url = base_url + estimate_id + '/comments' data = {} data['description'] = description data['show_comment_to_clients'] = show_comment_to_clients field = { 'JSONString': dumps(data) } resp = zoho_http_client.post(url, self.details, field) return parser.get_comment(resp) def update_comment(self, estimate_id, comment_id, description, show_comment_to_clients): """Update an existing comment. Args: estimate_id(str): Estimate id. comment_id(str): Comment id. description(str): Description. show_comments_to_clients(bool): True to show comments to clients. Returns: instance: Comments object. """ url = base_url +estimate_id + '/comments/' + comment_id data = {} data['description'] = description data['show_comment_to_clients'] = show_comment_to_clients field = { 'JSONString': dumps(data) } resp = zoho_http_client.put(url, self.details, field) return parser.get_comment(resp) def delete_comment(self, estimate_id, comment_id): """Delete an existing comment. Args: comment_id(str): Comment id. Returns: str: Success message('The comment has been deleted.'). """ url = base_url + estimate_id + '/comments/' + comment_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/EstimatesApi.py
EstimatesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.RecurringExpensesParser import RecurringExpensesParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'recurringexpenses/' parser = RecurringExpensesParser() zoho_http_client = ZohoHttpClient() class RecurringExpensesApi: """Recurring Expenses Api is used to 1.List recurring expenses with pagination . 2.Get the details of a recurring expense. 3.Create a recurring expense. 4.Update an existing recurring expense. 5.Delete an existing recurring expense. 6.Stop an active recurring expense. 7.Resume a stopped recurring expense. 8.List child expenses created from recurring expense. 9.Get history and comments of a recurring expense. """ def __init__(self, authtoken, organization_id): """Initialize Recurring Expenses Api using user's authtoken and organization id. Args: authotoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_recurring_expenses(self, param=None): """List recurring expenses with pagination. Args: parameter(dict, optional): Filter with which the list has to be displayed. Returns: instance: Recurring expenses list object. """ resp = zoho_http_client.get(base_url, self.details, param) return parser.get_list(resp) def get(self, recurring_expense_id): """Get details of a recurring expense. Args: recurring_expense_id: Recurring expense id. Returns: instance: Recurring expense object. """ url = base_url + recurring_expense_id resp = zoho_http_client.get(url, self.details) return parser.get_recurring_expense(resp) def create(self, recurring_expenses): """Create a recurring expense. Args: recurring_expenses(instance): Recurring expense object. Returns: instance: Recurring expense object. """ json_object = dumps(recurring_expenses.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_recurring_expense(resp) def update(self, recurring_expense_id, recurring_expenses): """Update an existing recurring expense. Args: recurring_expense_id(str): Recurring expense id. recurring_expenses(instance): Recurring expense object. Returns: instance: Recurring expense object. """ url = base_url + recurring_expense_id json_object = dumps(recurring_expenses.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_recurring_expense(resp) def delete(self, recurring_expense_id): """Delete an existing recurring expense. Args: recurring_expense_id(str): Recurring expense id. Returns: str: Success message('The recurring expense has been deleted.'). """ url = base_url + recurring_expense_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def stop_recurring_expense(self, recurring_expense_id): """Stop an active recurring expense. Args: recurring_expense_id(str): Recurring expense id. Returns: str: Success message('The recurring expense has been stopped.'). """ url = base_url + recurring_expense_id + '/status/stop' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp) def resume_recurring_expense(self, recurring_expense_id): """Resume a stopped recurring expense. Args: recurring_expense_id(str): Recurring expense id. Returns: str: Success message('Resume a stopped recurring expense.'). """ url = base_url + recurring_expense_id + '/status/resume' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp) def list_child_expenses_created(self, recurring_expense_id, parameter=None): """List child expenses created. Args: recurring_expense_id(str): Recurring Expense id. sort_column(str, optional): Sort child expenses created. Allowed values are date, account_name, vendor_name, paid_through_account_name, customer_name and total. Returns: instance: Expense history object. """ url = base_url + recurring_expense_id + '/expenses' if parameter is not None: query = { 'sort_column': parameter } else: query = None resp = zoho_http_client.get(url, self.details, query) return parser.get_expense_history(resp) def list_recurring_expense_comments_and_history(self, recurring_expense_id): """Get history and comments of recurring expense. Args: recurring_expense_id(str): Recurring expense id. Returns: instance: Comments list object. """ url = base_url + recurring_expense_id + '/comments' resp = zoho_http_client.get(url, self.details) return parser.get_comments(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/RecurringExpensesApi.py
RecurringExpensesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.SettingsParser import SettingsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'items/' zoho_http_client = ZohoHttpClient() parser = SettingsParser() class ItemsApi: """Items Api class is used to 1.List items. 2.Get an item. 3.Create an item. 4.Update an item. 5.Delete an item. 6.Mark item as active. 7.Mark item as inactive. """ def __init__(self, authtoken, organization_id): """Initialize Settings Api using authtoken and organization id. Args: authtoken(str): User's Authtoken. organization_id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def list_items(self): """Get the list of all active items with pagination. Returns: instance: Items list object. """ resp = zoho_http_client.get(base_url, self.details) return parser.get_items(resp) def get(self, item_id): """Get details of an item. Args: item_id(str): Item id. Returns: instance: Item object. """ url = base_url + item_id resp = zoho_http_client.get(url, self.details) return parser.get_item(resp) def create(self, item): """Create a new item. Args: item(instance): Item object. Returns: instance: Item object. """ json_obj = dumps(item.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_item(resp) def update(self, item_id, item): """Update an existing item. Args: item_id(str): Item id. item(instance): Item object. Returns: instance: Item object. """ url = base_url + item_id json_obj = dumps(item.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_item(resp) def delete_item(self, item_id): """Delete an item. Args: item_id(str): Item id. Returns: str: Success message('The item has been deleted.'). """ url = base_url + item_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def mark_item_as_active(self, item_id): """Mark an item as active. Args: item_id(str): Item id. Returns: str: Success message('The item has been marked as active.'). """ url = base_url + item_id + '/active' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def mark_item_as_inactive(self, item_id): """Mark an item as inactive. Args: item_id(str): Item id. Returns: str: Success message('The item has been marked as inactive.'). """ url = base_url + item_id + '/inactive' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/ItemsApi.py
ItemsApi.py
from os.path import basename from json import dumps from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.InvoicesParser import InvoicesParser from .Api import Api base_url = Api().base_url + 'invoices/' parser = InvoicesParser() zoho_http_client = ZohoHttpClient() class InvoicesApi: """Invoice Api class is used to: 1.List all invoices with pagination. 2.Get the details of an invoice. 3.Create an invoice. 4.Update an existing invoice. 5.Delete an existing invoice. 6.Mark a draft invoice as sent. 7.Mark an invoice status as void. 8.Mark a voided invoice as draft. 9.Email an invoice to the customer. 10.Send invoices to your customer by email. 11.Get the email content of an email. 12.Remind the customer about an unpaid invoice by email. 13.Remind the customer abount unpaid invoices by email. 14.Get the mail content of the payment reminder. 15.Export maximum of 25 invoices as pdf. 16.Export invoices as pdf and print them. 17.Disable automated payment reminders for an invoice. 18.Enable automated payment reminders for an invoice. 19.Write off the invoice balance amount of an invoice. 20.Cancel the write off amount of an invoice. 21.Update the billing address for an existing invoice. 22.Update the shipping address for an existing invoice. 23.Get all invoice pdf templates. 24.Update the pdf template associated with the invoice. 25.Get the list of payments made for an invoice. 26.Get the list of credits applied for an invoice. 27.Apply the customer credits to an invoice. 28.Delete a payment made to an invoice. 29.Delete a particular credit applied to an invoice. 30.Return a file attached to an invoice. 31.Attach a file to an invoice. 32.Send attachment while emailing the invoice. 33.Delete the file attached to the invoice. 34.Delete an expense receipt attached to an invoice. 35.Get the complete history and comments of an invoice. 36.Add a comment for an invoice. 37.Update an existing comment of an invoice. 38.Delete an invoice comment. """ def __init__(self, authtoken, organization_id): """Initialize Invoice api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken':authtoken, 'organization_id':organization_id } def get_invoices(self, parameter=None): """Get list of all invoices with pagination. Args: parameter(dict, optional): Filter with which the list has to be displayed. Returns: instance: Invoice list instance. """ response = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(response) def get(self, invoice_id, print_pdf=None, accept=None): """Get details of an invoice. Args: invoice_id(str): Inovice id. print_pdf(bool): True to print invoice as pdf else False. accept(str): Format in which the invoice details has to be downloaded. Default value is json. Allowed value is json, pdf and html. Returns: instance or file: If accept is None invoice object is returned else File containing invoice details is returned. """ url = base_url + invoice_id query = {} if print_pdf is not None and accept is not None: query = { 'print': print_pdf, 'accept': accept } resp = zoho_http_client.getfile(url, self.details, query) return resp elif print_pdf is not None: query = {'print': print_pdf} if print_pdf is True: query.update({'accept':'pdf'}) resp = zoho_http_client.getfile(url, self.details, query) return resp else: response = zoho_http_client.get(url, self.details, query) return parser.get(response) elif accept is not None: query = { 'accept': accept } resp = zoho_http_client.getfile(url, self.details, query) return resp else: response = zoho_http_client.get(url, self.details) return parser.get(response) def create(self, invoice, send=None, ignore_auto_number_generation=None): """Creat an invoice. Args: invoice(instance): Invoice object. send(bool, optional): To send invoice to the cocntact persons associated with the invoice. Allowed values are true and false. ignore_auto_number_generation(bool, optional): Ignore auto invoice number generation for the invoice. This mandates the invoice number. Allowed values are true and false. Returns: instance: Invoice object. """ json_object = dumps(invoice.to_json()) data = { 'JSONString': json_object } query = {} if send is not None and ignore_auto_number_generation is not None: query = { 'send':send, 'ignore_auto_number_generation': ignore_auto_number_generation } elif send is not None or ignore_auto_number_generation is not None: query = { 'send': send } if send is not None else { 'ignore_auto_number_generation': \ ignore_auto_number_generation } else: query = None response = zoho_http_client.post(base_url, self.details, data, query) return parser.get(response) def update(self, invoice_id, invoice, ignore_auto_number_generation=None): """Update an existing invoice. Args: invoie_id(str): Invoice id. invoice(instance): Invoice object. ignore_auto_number_generation(bool, optional): Ignore auto invoice number generation for the invoice. This mandates the invoice number. Allowed values are true and false. Returns: instance: Invoice object. """ url = base_url + invoice_id json_object = dumps(invoice.to_json()) data = { 'JSONString': json_object } if ignore_auto_number_generation is not None: query = { 'ignore_auto_number_generation': ignore_auto_number_generation } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get(response) def delete(self, invoice_id): """Delete an existing invoice. Args: invoice_id(str): Invoice id. Returns: str: Success message('The invoice has been deleted.'). """ url = base_url + invoice_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def mark_an_invoice_as_sent(self, invoice_id): """Mark an invoice as sent. Args: invoice_id(str): Invoice id. Returns: str: Success message('Inovice status has been changed to sent.'). """ url = base_url + invoice_id + '/status/sent' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def void_an_invoice(self, invoice_id): """Mark an invoice as void. Args: invoice_id(str): Invoice id. Returns: str: Success message('Invoice status has been changed to void.'). """ url = base_url + invoice_id + '/status/void' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def mark_as_draft(self, invoice_id): """Mark a voided invoice as draft. Args: invoice_id(str): Invoice id. Returns: str: Success message('Status of invoice changed form void to draft.'). """ url = base_url + invoice_id + '/status/draft/' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def email_an_invoice(self, invoice_id, email, attachment=None, \ send_customer_statement=None, send_attachment=None): """Email an invoice to the customer. Args: invoice_id(str): Invoice id. email(instance): Email object. attachment(list of string, optional): List of string containing the path of the attachment. send_customer_statement(bool, optional): True to send customer statement pdf with email else False. send_attachment(bool, optional): True to send the attachment with mail else False. Returns: str: Success message('Your invoice has been sent.'). """ url = base_url + invoice_id + '/email' json_object = dumps(email.to_json()) data = { 'JSONString': json_object } if attachment is not None and send_customer_statement is not None and \ send_attachment is not None: query = { 'send_customer_statement': send_customer_statement, 'send_attachment': send_attachment } file_list = [] for value in attachment: attachments = { 'attachments': { 'filename': basename(value), 'content':open(value).read() } } file_list.append(attachments) elif attachment is not None and send_customer_statement is not None: query = { 'send_customer_statement':send_customer_statement, } file_list = [] for value in attachment: attachments = { 'attachments': { 'filename': basename(value), 'content': open(value).read() } } file_list.append(attachments) elif attachment is not None and send_attachment is not None: query = { 'send_attachment':send_attachment } file_list = [] for value in attachment: attachments = { 'attachments': { 'filename':basename(value), 'content':open(value).read() } } file_list.append(attachments) elif send_customer_statement is not None and send_attachment is not None: query = { 'send_customer_statement':send_customer_statement, 'send_attachment':send_attachment } file_list = None elif attachment is not None: file_list = [] for value in attachment: attachments = { 'attachments': { 'filename': basename(value), 'content':open(value).read() } } file_list.append(attachments) query = None elif send_customer_statement is not None: query = { 'send_customer_statement':send_customer_statement, } file_list = None elif send_attachment is not None: query = { 'send_attachment':send_attachment } file_list = None else: query = None file_list = None response = zoho_http_client.post(url, self.details, data, query, file_list) return parser.get_message(response) def email_invoices(self, contact_id, invoice_ids, email=None, \ snail_mail=None): """Send invoice to customers by email. Args: contact_id(list of str): List of Contact ids. invoice_ids(str): Comma separated Invoice ids which are to be emailed. email(bool, optional): True to send via email. snail_mail(bool, optional): True to send via snail mail. Returns: str: Success message('Mission accomplished! We've sent all the invoices.'). """ query = { 'invoice_ids': invoice_ids } url = base_url + 'email' data = {} data['contacts'] = [] for value in contact_id: contacts = { 'contact_id':value, 'email':True, 'snail_mail': False } if (email is not None) and (snail_mail is not None): contacts = { 'contact_id':value, 'email':email, 'snail_mail':snail_mail } data['contacts'].append(contacts) fields = { 'JSONString': dumps(data) } print(data) response = zoho_http_client.post(url, self.details, fields, query) return parser.get_message(response) def get_email_content(self, invoice_id, email_template_id=None): """Get the email content of an invoice. Args: invoice_id(str): Invoice id. email_template_id(str, optional): Email template id. If None default template id will be inputted. Returns: instance: Email object. """ url = base_url + invoice_id + '/email' if email_template_id is not None: query = { 'email_template_id':email_template_id } else: query = None response = zoho_http_client.get(url, self.details, query) return parser.get_content(response) def remind_customer(self, invoice_id, email, attachment=None, \ send_customer_statement=None): """Remind customers abount unpaid invoices. Args: invoice_id(str): Invoice id. email(instance): Email object. attachment(list of dict, optional): List of dictionary objects containing details of files to be attached. send_customer_statement(bool, optional): True to send customer statement along with email else False. Returns: str: Success message('Your payment reminder has been sent.'). """ url = base_url + invoice_id + '/paymentreminder' json_object = dumps(email.to_json()) data = { 'JSONString': json_object } if send_customer_statement is not None and attachment is not None: query = { 'send_customer_statement':send_customer_statement } file_list = [] for value in attachment: attachments = { 'attachments': { 'filename': basename(value), 'content':open(value).read() } } file_list.append(attachments) elif send_customer_statement is not None: query = { 'send_customer_statement':send_customer_statement } file_list = None elif attachment is not None: file_list = [] for value in attachment: attachments = { 'attachments': { 'filename': basename(value), 'content':open(value).read() } } file_list.append(attachments) query = None else: query = None file_list = None response = zoho_http_client.post(url, self.details, data, query, file_list) return parser.get_message(response) def bulk_invoice_reminder(self, invoice_id): """Remind customers about unpaid invoices. Args: invoice_id(str): Invoice id. Returns: str: Success message('Success! All reminders have been sent.'). """ url = base_url + 'paymentreminder' invoice_ids = { 'invoice_ids': invoice_id } response = zoho_http_client.post(url, self.details, '', invoice_ids) return parser.get_message(response) def get_payment_reminder_mail_content(self, invoice_id): """Get the mail content of the payment reminder. Args: invoice_id(str): Invoice id. Returns: instance: Email object. """ url = base_url + invoice_id + '/paymentreminder' response = zoho_http_client.get(url, self.details) return parser.payment_reminder_mail_content(response) def bulk_export_invoices(self, invoice_id): """Export maximum of 25 invoices as pdf. Args: invoice_id(str): Comma separated invoice ids which are to be exported as pdfs. Returns: file: Pdf file containing invoice details. """ url = base_url + 'pdf' query = { 'invoice_ids': invoice_id } response = zoho_http_client.getfile(url, self.details, query) return response def bulk_print_invoices(self, invoice_id): """Export invoices as pdf and print them. Args: invoice_id(str): Invoice id. Returns: file: File that has to be printed. """ url = base_url + 'pdf' invoice_ids = { 'invoice_ids': invoice_id } response = zoho_http_client.getfile(url, self.details, invoice_ids) return response def disable_payment_reminder(self, invoice_id): """Disable payment reminer. Args: invoice_id(str): Invoice id. Returns: str: Success message('Reminders stopped.'). """ url = base_url + invoice_id + '/paymentreminder/disable' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def enable_payment_reminder(self, invoice_id): """Enable payment reminder. Args: invoice_id(str): Invoice id. Returns: str: Success message('Reminders enabled.'). """ url = base_url + invoice_id + '/paymentreminder/enable' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def write_off_invoice(self, invoice_id): """Write off the invoice balance amount of an invoice. Args: invoice_id(str): Invoice id. Returns: str: Success message('Invoice has been written off.'). """ url = base_url + invoice_id + '/writeoff' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def cancel_write_off(self, invoice_id): """Cancel the write off amount of an invoice. Args: invoice_id(str): Invoice id. Returns: str: Success message('The writeoff done for this invoice has been cancelled.'). """ url = base_url + invoice_id + '/writeoff/cancel' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def update_billing_address(self, invoice_id, address, \ is_update_customer=None): """Update billing address for the invoice. Args: invoice_id(str): Invoice id. address(instance): Address object. is_update_customer(bool, optional): True to update the address for all draft, unpaid invoice and future invoices. Returns: instance: Address object. """ url = base_url + invoice_id + '/address/billing' json_object = dumps(address.to_json()) data = { 'JSONString': json_object } if is_update_customer is not None: query = { 'is_update_customer': is_update_customer } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_billing_address(response) def update_shipping_address(self, invoice_id, address, \ is_update_customer=None): """Update shipping address for the invoice. Args: invoice_id(str): Invoice id. address(instance): Address object. is_update_customer(bool, optional): True to update the address for all draft, unpaid invoice and future invoices. Returns: instance: Address object. """ url = base_url + invoice_id + '/address/shipping' json_object = dumps(address.to_json()) data = { 'JSONString': json_object } if is_update_customer is not None: query = { 'is_update_customer': is_update_customer } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_shipping_address(response) def list_invoice_templates(self): """Get all invoice pdf templates. Returns: instance: Invoice template list object. """ url = base_url + 'templates' response = zoho_http_client.get(url, self.details) return parser.invoice_template_list(response) def update_invoice_template(self, invoice_id, template_id): """Update the pdf template associated with the invoice. Args: invoice_id(str): Invoice id. template_id(str): Tempalte id. Returns: str: Success message('Invoice information has been updated.'). """ url = base_url + invoice_id + '/templates/' + template_id response = zoho_http_client.put(url, self.details, '') return parser.get_message(response) ## Payments and Credits-------------------------------------------------------- def list_invoice_payments(self, invoice_id): """List the payments made for an invoice. Args: invoice_id(str): Invoice id. Returns: list of payments instance: List of Invoice payments list object. """ url = base_url + invoice_id + '/payments' response = zoho_http_client.get(url, self.details) return parser.payments_list(response) def list_credits_applied(self, invoice_id): """Get the list of credits applied for an invoice. Args: invoice_id(str): Invoice id. Returns: list of credits instance: List of credits object. """ url = base_url + invoice_id + '/creditsapplied' response = zoho_http_client.get(url, self.details) return parser.credits_list(response) def apply_credits(self, invoice_id, payments_and_credits): """Apply the customer credits either from credit notes or excess customer payments to an invoice. Args: invoice_id(str): Invoice id. payments_and_credits(instance): Payments object. Returns: instance: Payments and credits object. """ url = base_url + invoice_id + '/credits' data = {} invoice_payments = [] apply_credits = [] for value in payments_and_credits.invoice_payments: payments = {} payments['payment_id'] = value.get_payment_id() payments['amount_applied'] = value.get_amount_applied() invoice_payments.append(payments) for value in payments_and_credits.apply_creditnotes: credits = {} credits['creditnote_id'] = value.get_creditnote_id() credits['amount_applied'] = value.get_amount_applied() apply_credits.append(credits) data['invoice_payments'] = invoice_payments data['apply_creditnotes'] = apply_credits json_string = { 'JSONString': dumps(data) } response = zoho_http_client.post(url, self.details, json_string) return parser.apply_credits(response) def delete_payment(self, invoice_id, invoice_payment_id): """Delete a payment made to an invoice. Args: invoice_id(str): Invoice id. invoice_payment_id(str): Invoice payment id. Returns: str: Success message('The payment has been deleted.'). """ url = base_url + invoice_id + '/payments/' + invoice_payment_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def delete_applied_credit(self, invoice_id, creditnotes_invoice_id): """Delete a particular credit applied to an invoice. Args: invoice_id(str): Invoice id. creditnotes_invoice_id(str): Creditnotes invoice id. Returns: str: Success message('Credits applied to an invoice have been deleted.'). """ url = base_url + invoice_id + '/creditsapplied/' + \ creditnotes_invoice_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) ## Attachment------------------------------------------------------------------ def get_an_invoice_attachment(self, invoice_id, preview = None): """Get an invoice attachment. Args: invoice_id(str): Invoice id preview(bool): True to get the thumbnail of the attachment. Returns: file: File attached to the invoice. """ url = base_url + invoice_id + '/attachment' query_string = { 'preview': str(preview) } if preview is not None else None response = zoho_http_client.getfile(url, self.details, query_string) return response def add_attachment_to_an_invoice(self, invoice_id, attachment, \ can_send_in_mail=None): """Add a file to an invoice. Args: invoice_id(str): Invoice id. attachment(list of dict): List of dict containing details of the files to be attached. can_send_in_mail(bool, optional): True to send the attachment with the invoice when emailed. Returns: str: Success message('Your file has been successfully attached to the invoice.'). """ url = base_url + invoice_id + '/attachment' file_list = [] for value in attachment: attachments = { 'attachment': { 'filename':basename(value), 'content':open(value).read() } } file_list.append(attachments) if can_send_in_mail is not None: query = { 'can_send_in_mail':can_send_in_mail } else: query = None data = { 'JSONString': '' } response = zoho_http_client.post(url, self.details, data, query, \ file_list) return parser.get_message(response) def update_attachment_preference(self, invoice_id, can_send_in_mail): """Update whether to send attached file while emailing the invoice. Args: invoice_id(str): Invoice id. can_send_in_mail(bool): Boolean to send attachment with the invoice when emailed. Returns: str: Success message('Invoice information has been updated.'). """ url = base_url + invoice_id + '/attachment' query = { 'can_send_in_mail':can_send_in_mail, } data = { 'JSONString': '' } response = zoho_http_client.put(url, self.details, data, query) return parser.get_message(response) def delete_an_attachment(self, invoice_id): """Delete the file attached to the invoice. Args: invoice_id(str): Invoice id. Returns: str: Success message('Your file is no longer attached to the invoice.'). """ url = base_url + invoice_id + '/attachment' response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def delete_expense_receipt(self, expense_id): """Delete the expense receipts attached to an invoice which is raised from an expense. Args: expense_id: Expense id. Returns: str: Success message('The attached expense receipt has been deleted.'). """ url = base_url + 'expenses/' + expense_id + '/receipt' response = zoho_http_client.delete(url, self.details) return parser.get_message(response) #### Comments and History ----------------------------------------------------- def list_invoice_comments_history(self, invoice_id): """Get the complete history and comments of an invoice. Args: invoice_id(str): Invoice_id. Returns: instance: Comments list object. """ url = base_url + invoice_id + '/comments' response = zoho_http_client.get(url, self.details) return parser.comments_list(response) def add_comment(self, invoice_id, comments): """Add comment for an invoice. Args: invoice_id(str): Invoice id. comments(instance): Comments object. Returns: str: Success message('Comments added.'). """ url = base_url + invoice_id + '/comments' data = {} data['payment_expected_date'] = comments.get_payment_expected_date() data['description'] = comments.get_description() data['show_comment_to_clients'] = \ comments.get_show_comment_to_clients() json_string = { 'JSONString': dumps(data) } response = zoho_http_client.post(url, self.details, json_string) return parser.get_comment(response) def update_comment(self, invoice_id, comment_id, comments): """Update an existing comment of an invoice. Args: invoice_id(str): Invoice id. comment_id(str): Comment id. comments(instance): Comments object. Returns: instance: Comments object. """ url = base_url + invoice_id + '/comments/' + comment_id data = {} data['description'] = comments.get_description() data['show_comment_to_clients'] = \ comments.get_show_comment_to_clients() json_string = { 'JSONString': dumps(data) } response = zoho_http_client.put(url, self.details, json_string) return parser.get_comment(response) def delete_comment(self, invoice_id, comment_id): """Delete an invoice comment. Args: invoice_id(str): Invoice id. comment_id(str): Comment id. Returns: str: Success message.('The comment has been deleted.'). """ url = base_url + invoice_id + '/comments/' + comment_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/InvoicesApi.py
InvoicesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.ExpensesParser import ExpensesParser from os.path import basename from books.api.Api import Api from json import dumps base_url = Api().base_url + 'expenses/' parser = ExpensesParser() zoho_http_client = ZohoHttpClient() class ExpensesApi: """Expenses Api is used to: 1.List expenses with pagination. 2.Get the details of an expense. 3.Create a billable or non-billable expense. 4.Update an existing expense. 5.Delete an expense. 6.Get history and comments of an expense. 7.Returns the receipt attached to an expense. 8.Attach a receipt to an expense. 9.Delete the receipt attached to the expense. """ def __init__(self, authtoken, organization_id): """Initialize Expenses Api using user's authtoken and organization id. Args: authtoken(str): User's Authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken':authtoken, 'organization_id':organization_id } def get_expenses(self, parameter=None): """List expenses with pagination. Args: parameter(dict, optional): Filter with which expenses list has to be displayed. Defaults to None. Returns: instance: Expenses list object. """ resp = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(resp) def get(self, expense_id): """Get details of an expense. Args: expense_id(str): Expense id. Returns: instance: Expense object. """ url = base_url + expense_id resp = zoho_http_client.get(url, self.details) return parser.get_expense(resp) def create(self, expense, receipt=None): """Create an expense. Args: expense(instance): Expense object. receipt(file, optional): Expense receipt file to attach.Allowed Extensions: gif, png, jpeg, jpg, bmp and pdf. Returns: instance: Expense object. """ json_object = dumps(expense.to_json()) data = { 'JSONString': json_object } if receipt is not None: attachments = [{ 'receipt': { 'filename': basename(receipt), 'content': open(receipt).read() } }] else: attachments = None resp = zoho_http_client.post(base_url, self.details, data, None, \ attachments) return parser.get_expense(resp) def update(self, expense_id, expense, receipt=None): """Update an existing expense. Args: expense_id(str): Expense id. expense(instance): Expense object. receipt(file): Expense receipt file to attach. Allowed Extensions: gif, png, jpeg, jpg, bmp and pdf. Returns: instance: Expense object. """ url = base_url + expense_id json_object = dumps(expense.to_json()) data = { 'JSONString': json_object } if receipt is None: attachments = None else: attachments = [{ 'receipt': { 'filename': basename(receipt), 'content': open(receipt).read() } }] resp = zoho_http_client.put(url, self.details, data, None, attachments) return parser.get_expense(resp) def delete(self, expense_id): """Delete an existing expense. Args: expense_id(str): Expense id. Returns: str: Success message('The expense has been deleted.'). """ url = base_url + expense_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def list_comments_history(self, expense_id): """Get history and comments of an expense. Args: expense_id(str): Expense id. Returns: instance: comments list object. """ url = base_url + expense_id + '/comments' resp = zoho_http_client.get(url, self.details) return parser.get_comments(resp) def get_receipt(self, expense_id, preview=None): """Get the receipt attached to an expense. Args: expense_id(str): Expense id. preview(bool, optional): True to get the thumbnail of the receipt. Returns: file: Returns the receipt attached to the expense. """ url = base_url + expense_id + '/receipt' if preview is not None: query = { 'preview': preview } else: query = None resp = zoho_http_client.getfile(url, self.details, query) return resp def add_receipt(self, expense_id, receipt): """Attach a receipt to an expense. Args: expense_id(str): Expense id. receipt(file): Receipt to be attached.Allowed Extensions: gif, png, jpeg, jpg, bmp, pdf, xls, xlsx, doc and docx. Returns: str: Success message('The expense receipt has been attached.'). """ url = base_url + expense_id + '/receipt' attachments = [{ 'receipt': { 'filename': basename(receipt), 'content': open(receipt).read() } }] data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data, None, attachments) return parser.get_message(resp) def delete_receipt(self, expense_id): """Delete the receipt attached to the expense. Args: expense_id(str): Expense id. Returns: str: Success message('The attached expense receipt has been deleted.'). """ url = base_url + expense_id + '/receipt' resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/ExpensesApi.py
ExpensesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.RecurringInvoiceParser import RecurringInvoiceParser from .Api import Api from json import dumps base_url = Api().base_url + 'recurringinvoices/' parser = RecurringInvoiceParser() zoho_http_client = ZohoHttpClient() class RecurringInvoicesApi: """Recurring invoice api class is used: 1.To list all the recurring invoices with pagination. 2.To get details of a recurring invoice. 3.To create a recurring invoice. 4.To update an existing recurring invoice. 5.To delete an existing recurring invoice. 6.To stop an active recurring invoice. 7.To resume a stopped recurring invoice. 8.To update the pdf template associated with the recurring invoice. 9.To get the complete history and comments of a recurring invoice. """ def __init__(self, authtoken, organization_id): """Initialize Contacts Api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_recurring_invoices(self, parameter=None): """List of recurring invoices with pagination. Args: parameter(dict, optional): Filter with which the list has to be displayed. Defaults to None. Returns: instance: Recurring invoice list object. """ response = zoho_http_client.get(base_url, self.details, parameter) return parser.recurring_invoices(response) def get_recurring_invoice(self, recurring_invoice_id): """Get recurring invoice details. Args: recurring_invoice_id(str): Recurring invoice id. Returns: instance: Recurring invoice object. """ url = base_url + recurring_invoice_id response = zoho_http_client.get(url, self.details) return parser.recurring_invoice(response) def create(self, recurring_invoice): """Create recurring invoice. Args: recurring_invoice(instance): Recurring invoice object. Returns: instance: Recurring invoice object. """ json_object = dumps(recurring_invoice.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.post(base_url, self.details, data) return parser.recurring_invoice(response) def update(self, recurring_invoice_id, recurring_invoice): """Update an existing recurring invoice. Args: recurring_invoice_id(str): Recurring invoice id. recurring_invoice(instance): Recurring invoice object. Returns: instance: Recurring invoice object. """ url = base_url + recurring_invoice_id json_object = dumps(recurring_invoice.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.put(url, self.details, data) return parser.recurring_invoice(response) def delete(self, recurring_invoice_id): """Delete an existing recurring invoice. Args: recurring_invoice_id(str): Recurring invoice id. Returns: str: Success message('The recurring invoice has been deleted.'). """ url = base_url + recurring_invoice_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def stop_recurring_invoice(self, recurring_invoice_id): """Stop an active recurring invoice. Args: recurring_invoice_id(str): Recurring invoice id. Returns: str: Success message ('The recurring invoice has been stopped.'). """ url = base_url + recurring_invoice_id + '/status/stop' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def resume_recurring_invoice(self, recurring_invoice_id): """Resume an active recurring invoice. Args: recurring_invoice_id(str): Recurring invoice id. Returns: str: Success message ('The recurring invoice has been activated.'). """ url = base_url + recurring_invoice_id + '/status/resume' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def update_recurring_invoice_template(self, recurring_invoice_id, template_id): """Update the pdf template associated with the recurring invoice. Args: recurring_invoice_id(str): Recurring invoice id. template_id(str): Template id. Returns: str: Success message ('Recurring invoice information has been updated.'). """ url = base_url + recurring_invoice_id + '/templates/' + template_id response = zoho_http_client.put(url, self.details, '') return parser.get_message(response) def list_recurring_invoice_history(self, recurring_invoice_id): """List the complete history and comments of a recurring invoice. Args: recurring_invoice_id(str): Recurring invoice id. Returns: instance: Recurring invoice history and comments list object. """ url = base_url + recurring_invoice_id + '/comments' response = zoho_http_client.get(url, self.details) return parser.recurring_invoice_history_list(response)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/RecurringInvoicesApi.py
RecurringInvoicesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.CreditNotesParser import CreditNotesParser from os.path import basename from json import dumps from books.api.Api import Api base_url = Api().base_url + 'creditnotes/' parser = CreditNotesParser() zoho_http_client = ZohoHttpClient() class CreditNotesApi: """Creditnotes api class is used to 1.List Credits notes with pagination. 2.Get details of a credit note. 3.Create a credit note for a custoomer. 4.Update an existing creditnote. 5.Delete an existing creditnote. 6.Change an existing creditnote status to open. 7.Mark an existing creditnote as void. 8.Email a creditnote to a customer. 9.Get email history of a credit note. 10.Get email content of a credit note. 11.Update the billing address of an existing credit note. 12.Update the shipping address of an existing credit note. 13.Get all credit note pdf templates. 14.Update the pdf template associated with the creditnote. 15.List invooices to which the credit note is applied. 16.Apply credit note to existing invoices. 17.Delete the credits applied to an invoice. 18.List all refunds with pagination. 19.List all refunds of an existing credit note. 20.Get refund of a particular credit note. 21.Refund credit note amount. 22.Update the refunded transaction. 23.Delete a credit note refund. 24.Get history and comments of a credit note. 25.Add a comment to an existing credit note. 26.Delete a credit note comment. """ def __init__(self, authtoken, organization_id): """Initialize credit notes api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken':authtoken, 'organization_id':organization_id } def get_credit_notes(self, parameter=None): """List all credit notes with pagination. Args: parameter(dict, optional): Filter with which the list has to be displayed. Defaults to None. Returns: instance: Credit notes list object. Raises: Books Exception: If status is '200' or '201'. """ response = zoho_http_client.get(base_url, self.details, parameter) return parser.creditnotes_list(response) def get_credit_note(self, creditnote_id, print_pdf=None, accept=None): """Get details of a credit note. Args: creditnote_id(str): Credit note id. print_pdf(bool, optional): Export credit note pdf with default option. Allowed values are true, false,on and off. Returns: instance: Credit note object. Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + creditnote_id if print_pdf is not None and accept is not None: query = { 'print':str(print_pdf).lower(), 'accept':accept } response = zoho_http_client.getfile(url, self.details, query) return response elif print_pdf is not None: query = { 'print':str(print_pdf).lower() } if print_pdf: query.update({ 'accept':'pdf' }) response = zoho_http_client.getfile(url, self.details, query) return response else: response = zoho_http_client.get(url, self.details, query) return parser.get_creditnote(response) elif accept is not None: query = { 'accept':accept } response = zoho_http_client.getfile(url, self.details, query) return response else: response = zoho_http_client.get(url, self.details) return parser.get_creditnote(response) def create(self, credit_note, invoice_id=None, \ ignore_auto_number_generation=None): """Creates a credit note. Args: credit_note(instance): Credit note object. invoice_id(str, optional): Invoice id for which invoice has to be applied. ignore_auto_number_generation(bool, optional): True to ignore auto number generation else False. If set True this parameter becomes mandatory. Returns: instance: Credit note object. """ json_object = dumps(credit_note.to_json()) data = { 'JSONString': json_object } if invoice_id is not None and ignore_auto_number_generation is not \ None: query = { 'invoice_id':invoice_id, 'ignore_auto_number_generation':ignore_auto_number_generation } elif invoice_id is not None: query = { 'invoice_id':invoice_id } elif ignore_auto_number_generation is not None: query = { 'ignore_auto_number_generation':ignore_auto_number_generation } else: query = None response = zoho_http_client.post(base_url, self.details, data, query) return parser.get_creditnote(response) def update(self, credit_note_id, credit_note, \ ignore_auto_number_generation=None): """Update an existing credit note. Args: credit_note_id(str): Credit note id. credit_note(instance): Credit note object. ignore_auto_number_generation(bool, optional): True to ignore auto number generation. If this is set true then this parameter is mandatory. Returns: instance: Credit note object. """ url = base_url + credit_note_id json_object = dumps(credit_note.to_json()) data = { 'JSONString': json_object } if ignore_auto_number_generation is not None: query = { 'ignore_auto_number_generation':ignore_auto_number_generation } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_creditnote(response) def delete(self, creditnote_id): """Delete an existing credit note. Args: creditnote_id(str): Credit note id. Returns: str: Success message('The credit note has been deleted.'). """ url = base_url + creditnote_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def convert_to_open(self, creditnote_id): """Change an existing credit note status to open. Args: creditnote_id(str): Credit note id. Returns: str: Success message(the status of the credit note has been changed to open. """ url = base_url + creditnote_id + '/status/open' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def void_credit_note(self, creditnote_id): """Mark an existing credit note as void. Args: creditnote_id(str): Credit note id. Returns: str: Success message('The credit note has been marked as void.'). """ url = base_url + creditnote_id + '/status/void' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response) def email_credit_note(self, creditnote_id, email, attachment=None, customer_id=None): """Email a credit note to the customer. Args: creditnote_id(str): Creditnote id. email(instance): Email object. attachment(list of dict, optional): List of dictionary containing details of the files to be attached. customer_id(str, optional): Id of the customer. Returns: str: Success message('Your credit note has been sent.'). """ url = base_url + creditnote_id + '/email' json_object = dumps(email.to_json()) data = { 'JSONString': json_object } if attachment is not None and customer_id is not None: query = { 'customer_id':customer_id } file_list = [] for value in attachment: attachments = { 'attachments': { 'filename':basename(value), 'content':open(value).read() } } file_list.append(attachments) elif attachment is not None: file_list = [] for value in attachment: attachments = { 'attachments': { 'filename':basename(value), 'content':open(value).read() } } file_list.append(attachments) query = None elif customer_id is not None: query = { 'customer_id': customer_id } file_list = None else: query = None file_list = None response = zoho_http_client.post(url, self.details, data, query, file_list) return parser.get_message(response) def email_history(self, creditnote_id): """Get email history of a credit note. Args: creditnote_id(str): Credit note id. Returns: instance: Email object. """ url = base_url + creditnote_id + '/emailhistory' response = zoho_http_client.get(url, self.details) return parser.email_history(response) def get_email_content(self, creditnote_id, email_template_id=None): """Get email content of a credit note. Args: creditnote_id(str): Creditnote id. email_template_id(str, optional): Email template id. Returns: instance): Email object. """ url = base_url + creditnote_id + '/email' if email_template_id is not None: query = { 'email_template_id': email_template_id } else: query = None response = zoho_http_client.get(url, self.details, query) return parser.email(response) def update_billing_address(self, creditnote_id, address, is_update_customer=None): """Update billing address. Args: creditnote_id(str): Credit note id. address(instance): Address object. is_update_customer(bool, optional): True to update customer else False. Returns: instance: Address object. """ url = base_url + creditnote_id + '/address/billing' json_object = dumps(address.to_json()) data = { 'JSONString': json_object } if is_update_customer is not None: query = { 'is_update_customer': is_update_customer } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_billing_address(response) def update_shipping_address(self, creditnote_id, address, is_update_customer=None): """Update shipping address. Args: creditnote_id(str): Credit note id. address(instance): Address object. is_update_customer(bool, optional): True to update customer else False. Returns: instance: Address object. """ url = base_url + creditnote_id + '/address/shipping' json_object = dumps(address.to_json()) data = { 'JSONString': json_object } if is_update_customer is not None: query = { 'is_update_customer': is_update_customer } else: query = None response = zoho_http_client.put(url, self.details, data, query) return parser.get_shipping_address(response) def list_credit_note_template(self): """Get all credit note pdf templates. Returns: list of instance: List of templates object. """ url = base_url + 'templates' response = zoho_http_client.get(url, self.details) return parser.list_templates(response) def update_credit_note_template(self, creditnote_id, template_id): """Update credit note template. Args: creditnote_id(str): Credit note id. template_id(str): Template id. Returns: str: Success message('The credit note has been updated.'). """ url = base_url + creditnote_id + '/templates/' + template_id response = zoho_http_client.put(url, self.details, '') return parser.get_message(response) #### Apply to Invoice------------------------------------------------------------------------------------------------------------ def list_invoices_credited(self, creditnote_id): """List invoices to which credit note is applied. Args: creditnote_id(str): Credit note id. Returns: list of instance: List of invoices credited object. Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + creditnote_id + '/invoices' response = zoho_http_client.get(url, self.details) return parser.list_invoices_credited(response) def credit_to_invoice(self, creditnote_id, invoice): """List invoices to which the credited note is applied. Args: creditnote_id(str): Credit note id. invoice(instance): Invoice object. Returns: list of invoices: List of invoice objects. """ url = base_url + creditnote_id + '/invoices' invoices = { 'invoices': [] } for value in invoice: data = {} data['invoice_id'] = value.get_invoice_id() data['amount_applied'] = value.get_amount_applied() invoices['invoices'].append(data) json_string = { 'JSONString': dumps(invoices) } response = zoho_http_client.post(url, self.details, json_string) return parser.credit_to_invoice(response) def delete_invoices_credited(self, creditnote_id, creditnote_invoice_id): """Delete the credits applied to an invoice. Args: creditnote_id(str): Credit note id. creditnote_invoice_id(str): Credit note invoice id. Returns: str: Success message('Credits applied to an invoice have been deleted.'). """ url = base_url + creditnote_id + '/invoices/' + creditnote_invoice_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) ## REFUND----------------------------------------------------------------------------------------------------------------------- def list_credit_note_refunds(self, customer_id=None, sort_column=None): """List all refunds wiht pagination. Args: customer_id(str, optional): Customer id. sort_column(str, optional): Sort refund list. Allowed values are refund_mode, reference_number, date, creditnote_number, customer_name, amount_bcy and amount_fcy. Returns: instance: Credit notes refund list object. """ url = base_url + 'refunds' if customer_id is not None and sort_column is not None: parameter = { 'customer_id':customer_id, 'sort_column':sort_column } elif sort_column is not None or customer_id is not None: parameter = { 'sort_column': sort_column } if sort_column is not None else { 'customer_id': customer_id } else: parameter = None response = zoho_http_client.get(url, self.details, parameter) return parser.creditnote_refunds(response) def list_refunds_of_credit_note(self, creditnote_id): """List all refunds of an existing credit note. Args: creditnote_id(str): Credit note id. Returns: instance: Creditnotes refund list. """ url = base_url + creditnote_id + '/refunds' response = zoho_http_client.get(url, self.details) return parser.creditnote_refunds(response) def get_credit_note_refund(self, creditnote_id, creditnote_refund_id): """Get credit note refund. Args: creditnote_id(str): Credit note id. creditnote_refund_id(str): Creditnote refund id. Returns: instance: Creditnote refund object. """ url = base_url + creditnote_id + '/refunds/' + creditnote_refund_id response = zoho_http_client.get(url, self.details) return parser.get_creditnote_refund(response) def refund_credit_note(self, creditnote_id, creditnote): """Refund credit note amount. Args: creditnote_id(str): Credit note id. Returns: creditnote(instance): Credit note object. """ url = base_url + creditnote_id + '/refunds' json_object = dumps(creditnote.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.post(url, self.details, data) return parser.get_creditnote_refund(response) def update_credit_note_refund(self, creditnote_id, creditnote_refund_id, creditnote): """Update the refunded transaction. Args: creditnote_id(str): Credit note id. creditnote_refund_id(str): Credit note refund id. creditnote(instance): Credit note object. Returns: instance: Creditnote object. """ url = base_url + creditnote_id + '/refunds/' + creditnote_refund_id json_object = dumps(creditnote.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.put(url, self.details, data) return parser.get_creditnote_refund(response) def delete_credit_note_refund(self, creditnote_id, creditnote_refund_id): """Delete a credit note refund. Args: creditnote_id(str): Credit note id. creditnote_refund_id(str): Credit note refund id. Returns: str: Success message('The refund has been successfully deleted.'). """ url = base_url + creditnote_id + '/refunds/' + creditnote_refund_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) ## Comments and History---------------------------------------------------------------------------------------------------------- def list_creditnote_comments_history(self, creditnote_id): """Get history and comments of a credit note. Args: creditnote_id(str): Credit note id. Returns: instance: Comments list object. """ url = base_url + creditnote_id + '/comments' response = zoho_http_client.get(url, self.details) return parser.comments_list(response) def add_comment(self, creditnote_id, comments): """Add a comment to an existing credit note. Args: creditnote_id(str): Credit note id. comments(instance): Comments object. Returns: instance: Comments object. """ url = base_url + creditnote_id + '/comments' data = {} data['description'] = comments.get_description() json_string = { 'JSONString': dumps(data) } response = zoho_http_client.post(url, self.details, json_string) return parser.get_comment(response) def delete_comment(self, creditnote_id, comment_id): """Delete a credit note comment. Args: creditnote_id(str): Credit note id. comment_is(str): Comment id. Returns: str: Success message('The comment has been deleted.'). """ url = base_url + creditnote_id + '/comments/' + comment_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/CreditNotesApi.py
CreditNotesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.ProjectsParser import ProjectsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'projects/' zoho_http_client = ZohoHttpClient() parser = ProjectsParser() class ProjectsApi: """This class is used to 1. List all projects with pagination. 2.Get details of a project. 3.Create a new project. 4.Update an existing project. 5.Delete an existing project. 6.Mark a project as active. 7.Mark a project as inactive. 8.Clone a project. 9.Get list of tasks added to a project. 10.Get details of a task. 11.Add task to a project. 12.Update details of a task. 13.Delete a task added to a project. 14.Get list of users associated with a project. 15.Get details of a user in a project. 16.Assign users to a project. 17.Invite and add user to the project. 18.Update details of a user. 19.Remove user from the project. 20.List all time entries with pagination. 21.Get details of a time entry. 22.Logging time entries. 23.Update logged time entry. 24.Deleting logged time entry. 25.Deleting time entries. 26.Get current running timer. 27.Start tracking time spent. 28.Stop tracking time. 29.Get comments for a project. 30.Post comment to a project. 31.Delete a comment from a project. 32.List invoices created for this project. """ def __init__(self, authtoken, organization_id): """Initialize Projects api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_projects(self, parameters=None): """List all projects with pagination. Args: parameters(dict, optional): Filter with which the list has to be displayed. Returns: instance: Projects list object. """ resp = zoho_http_client.get(base_url, self.details, parameters) return parser.get_projects_list(resp) def get_project(self, project_id): """Get details of a project. Args: project_id(str): Project id. Returns: instance: Project object. """ url = base_url + project_id resp = zoho_http_client.get(url, self.details) return parser.get_project(resp) def create_project(self, project): """Create a new project. Args: project(instance): Project object. Returns: instance: Projects object """ json_object = dumps(project.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_project(resp) def update_project(self, project_id, project): """Update an existing project. Args: project_id(str): Project id. project(instance): Project object. Returns: instance: Project object. """ url = base_url + project_id json_object = dumps(project.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_project(resp) def delete_project(self, project_id): """Delete an existing project. Args: project_id(str): Project id. Returns: str: Success message('The project has been deleted.'). """ url = base_url + project_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def activate_project(self, project_id): """Mark project as active. Args: project_id(str): Project id. Returns: str: Success message('The selected project have been marked as active.'). """ url = base_url + project_id + '/active' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp) def inactivate_project(self, project_id): """Mark project as inactive. Args: project_id(str): Project id. Returns: str: Success message('The selected project have been marked as inactive.'). """ url = base_url + project_id + '/inactive' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp) def clone_project(self, project_id, project): """Cloning a project. Args: project_id(str): Project id. Returns: instance: Project object. """ url = base_url + project_id + '/clone' json_object = dumps(project.to_json()) data = { 'JSONString': json_object } print(data) resp = zoho_http_client.post(url, self.details, data) return parser.get_project(resp) def get_tasks(self, project_id, sort_column=None): """Get list of tasks added to a project. Args: project_id(str): Project id. sort_column(str): Sort column. Allowed Values: task_name, billed_hours, log_time and un_billed_hours. Returns: instance: Task list object. """ url = base_url + project_id + '/tasks' if sort_column is not None: parameter = { 'sort_column': sort_column } else: parameter = None resp = zoho_http_client.get(url, self.details, parameter) return parser.get_tasks_list(resp) def get_task(self, project_id, task_id): """Get details of a task. Args: project_id(str): Project id. task_id(str): Task id. Returns: instance: Task object. """ url = base_url + project_id + '/tasks/' + task_id resp = zoho_http_client.get(url, self.details) return parser.get_task(resp) def add_task(self, project_id, task): """Add task to project. Args: project_id(str): Project id. task(instance): Task object. Returns: instance: Task object. """ url = base_url + project_id + '/tasks' json_object = dumps(task.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_task(resp) def update_task(self, project_id, task_id, task): """Update details of a task. Args: project_id(str): Project id. task_id(str): Task id. Returns: instance: Task object. """ url = base_url + project_id + '/tasks/' + task_id json_object = dumps(task.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_task(resp) def delete_task(self, project_id, task_id): """Delete task added to a project. Args: project_id(str): Project id. task_id(str): Task id. Returns: str: Success message('The task has been deleted.'). """ url = base_url + project_id + '/tasks/' + task_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_users(self, project_id): """Get list of users associated with a project. Args: project_id(str): Project id. Returns: instance: Users list object. """ url = base_url + project_id + '/users' resp = zoho_http_client.get(url, self.details) return parser.get_users(resp) def get_user(self, project_id, user_id): """Get details of a user in a project. Args: project_id(str): Project id. user_id(str): User id. Returns: instance: USer object. Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + project_id + '/users/' + user_id resp = zoho_http_client.get(url, self.details) return parser.get_user(resp) def assign_users(self, project_id, users): """Assign users to a project. Args: project_id(str): Project id. users(list of instance): List of users object. Returns: instance: Users list object. """ url = base_url + project_id + '/users' users_obj = { 'users': [] } for value in users: user = value.to_json() users_obj['users'].append(user) json_object = dumps(users_obj) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_users(resp) def invite_user(self, project_id, user): """Invite and add user to the project. Args: project_id(str): Project id. user(instance): User object. Returns: instance: User object. """ url = base_url + project_id + '/users/invite' print(user.to_json()) json_object = dumps(user.to_json()) data = { 'JSONString': json_object } print(data) resp = zoho_http_client.post(url, self.details, data) return parser.get_user(resp) def update_user(self, project_id, user_id, user): """Update details of a user. Args: project_id(str): Project id. user_id(str): User id. user(instance): User object. Returns: instance: User object. """ url = base_url + project_id + '/users/' +user_id json_object = dumps(user.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_user(resp) def delete_user(self, project_id, user_id): """Remove user from the project. Args: project_id(str): Project id. user_id(str): User id. Returns: str: Success message('The staff has been removed.'). """ url = base_url + project_id + '/users/' + user_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_time_entries(self, parameters=None): """List all time entries with pagination. Args: parameters(dict, optional): Filter with which the list has to be displayed. Returns: instance: Time entries list object. """ url = base_url + 'timeentries' resp = zoho_http_client.get(url, self.details, parameters) return parser.get_time_entries_list(resp) def get_time_entry(self, time_entry_id): """Get details of time entry. Args: time_entry_id(str): Time entry id. Returns: instance: Time entry object. """ url = base_url + 'timeentries/' + time_entry_id resp = zoho_http_client.get(url, self.details) return parser.get_time_entry(resp) def log_time_entries(self, time_entry): """Logging time entries. Args: time_entry(instance): Time entry object. Returns: instance: Time entry. """ url = base_url + 'timeentries' json_object = dumps(time_entry.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_time_entry(resp) def update_time_entry(self, time_entry_id, time_entry): """Update logged time entry. Args: time_entry_id(str): Time entry id. time_entry(instance): Time entry object. Returns: instance: Time entry object. """ url = base_url + 'timeentries/' + time_entry_id json_object = dumps(time_entry.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_time_entry(resp) def delete_time_entry(self, time_entry_id): """Delete time entry. Args: time_entry_id(str): Time entry id. Returns: str: Success message('The time entry has been deleted.'). """ url = base_url + 'timeentries/' + time_entry_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def delete_time_entries(self, time_entry_ids): """Delete time entries. Args: time_entry_ids(str): Id of the time entries to be deleted. Returns: str: Success message('The selected timesheet entries have been deleted.'). """ url = base_url + 'timeentries' param = { 'time_entry_ids': time_entry_ids } resp = zoho_http_client.delete(url, self.details, param) return parser.get_message(resp) def get_timer(self): """Get current running timer. Returns: instance: Time entry object. Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + 'timeentries/runningtimer/me' resp = zoho_http_client.get(url, self.details) return parser.get_time_entry(resp) def start_timer(self, timer_entry_id): """Start tracking time spent. Args: timer_entry_id(str): Timer entry id. Returns: instance: Time entry object. """ url = base_url + 'timeentries/' + timer_entry_id + '/timer/start' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_time_entry(resp) def stop_timer(self): """Stop tracking time. Returns: instance: Time entry object. """ url = base_url + 'timeentries/timer/stop' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_time_entry(resp) def get_comments(self, project_id): """Get list of comments for a project. Args: project_id(str): Project id. Returns: instance: Comments list object. """ url = base_url + project_id + '/comments' resp = zoho_http_client.get(url, self.details) return parser.get_comments(resp) def post_comment(self, project_id, comment): """Post comment to a project. Args: project_id(str): Project id. comment(instance): Comment object. Returns: instance: Comment object. """ url = base_url + project_id + '/comments' data = { 'description': comment.get_description() } json_string = { 'JSONString': dumps(data) } resp = zoho_http_client.post(url, self.details, json_string) return parser.get_comment(resp) def delete_comment(self, project_id, comment_id): """Delete an existing comment. Args: project_id(str): Project id. comment_id(str): comment id. Returns: str: Success message('The comment has been deleted.'). """ url = base_url + project_id + '/comments/' + comment_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_invoices(self, project_id, sort_column=None): """List invoices created for this project. Args: project_id(str): Project id. Returns: instance: Invoices list object. """ url = base_url + project_id + '/invoices' if sort_column is not None: param = { 'sort_column': sort_column } else: param = None resp = zoho_http_client.get(url, self.details, param) return parser.get_invoice_list(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/ProjectsApi.py
ProjectsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.SettingsParser import SettingsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'users/' zoho_http_client = ZohoHttpClient() parser = SettingsParser() class UsersApi: """Uses Api class is used to 1.List of all users in an organization. 2.10.Get the details of an user. 3.Get the details of the current user. 4.Create an user for an organization. 5.Update the details of an existing user. 6.Delete an existing user. 7.Send invitation email to a user. 8.Mark an inactive user as active. 9.Mark an active user as inactive. """ def __init__(self, authtoken, organization_id): """Initialize Settings Api using authtoken and organization id. Args: authtoken(str): User's Authtoken. organization_id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_users(self, parameters=None): """Get the list of users in the organization. Args: parameters(dict, optional): Filter with which the list has to be displayed. Returns: instance: Users list object. """ resp = zoho_http_client.get(base_url, self.details, parameters) return parser.get_users(resp) def get(self, user_id): """Get the details of a user. Args: user_id(str): User id. Returns: instance: User object. """ url = base_url + user_id resp = zoho_http_client.get(url, self.details) return parser.get_user(resp) def current_user(self): """Get details of a user. Returns: instance: User object. """ url = base_url + 'me' resp = zoho_http_client.get(url, self.details) return parser.get_user(resp) def create(self, user): """Create a user for your organization. Args: user(instance): User object. Returns: instance: User object. """ json_obj = dumps(user.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_user(resp) def update(self, user_id, user): """Update the details of an user. Args: user_id(str): User id. user(instance): User object. Returns: instance: User object. """ url = base_url + user_id json_obj = dumps(user.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_user(resp) def delete(self, user_id): """Delete a user associated to the organization. Args: user_id(str): User id. Returns: str: Success message('The user has been removed from your organization.'). """ url = base_url + user_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def invite_user(self, user_id): """Send invitation email to a user. Args: user_id(str): User id. Returns: str: Success message('Your invitation has been sent.'). """ url = base_url + user_id + '/invite' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def mark_user_as_active(self, user_id): """Mark an inactive user as active. Args: user_id(str): User id. Returns: str: Success message('The user has been marked as active.'). """ url = base_url + user_id + '/active' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def mark_user_as_inactive(self, user_id): """Mark an active user as inactive. Args: user_id(str): User id. Returns: str: Success message('The user has been marked as inactive.'). """ url = base_url + user_id + '/inactive' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/UsersApi.py
UsersApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.CustomerPaymentsParser import CustomerPaymentsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'customerpayments/' parser = CustomerPaymentsParser() zoho_http_client = ZohoHttpClient() class CustomerPaymentsApi: """CustomerPaymentsApi class is used: 1.To list all the payments made by the customer. 2.To get the details of the customer payment. 3.To create a payment made by the customer. 4.To update a payment made by the customer. 5.To delete an existing customer payment. """ def __init__(self, authtoken, organization_id): """Initialize Customer payment's api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details={ 'authtoken': authtoken, 'organization_id': organization_id } def get_customer_payments(self, parameter=None): """List all customer payments with pagination. Args: parameter(dict, optional): Filter with which the list has to be displayed. Default to None. Returns: instance: Customer payments list object. """ response = zoho_http_client.get(base_url, self.details, parameter) return parser.customer_payments(response) def get(self, payment_id): """Get details of a customer payment. Args: payment_id(str): Payment id of the customer. Returns: instance: Customer payment object. """ url = base_url + payment_id response = zoho_http_client.get(url, self.details) return parser.get_customer_payment(response) def refund(self, payment_id, refund): """Refund excess of a customer payment. Args: payment_id(str): Payment id of the customer. refund(CreditNoteRefund): Refund the amount to customer. Returns: instance: Customer payment object. """ url = base_url + payment_id + '/refunds' data = refund.to_json() field = { 'JSONString': dumps(data) } response = zoho_http_client.post(url, self.details, field, None) return parser.payment_refunds(response) def get_refunds(self, payment_id): """List Refunds of a customer payment. Args: payment_id(str): Payment id of the customer. Returns: instance: Customer payment object. """ url = base_url + payment_id + '/refunds' response = zoho_http_client.get(url, self.details, None) return parser.payment_refunds(response) def create(self, customer_payment): """Create a payment made by the customer. Args: customer_payment(instance): customer payment object. Returns: instance: customer payment object. """ json_object = dumps(customer_payment.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.post(base_url,self.details,data) return parser.get_customer_payment(response) def update(self, payment_id, customer_payment): """Update a payment made by a customer. Args: payment_id(str): Payment id. customer_payment(instance): Customer payment object. Returns: instance: Customer payment object. """ url = base_url + payment_id json_object = dumps(customer_payment.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.put(url,self.details,data) return parser.get_customer_payment(response) def delete(self, payment_id): """Delete an existing customer payment. Args: payment_id(str): Payment id. Returns: str: Success message ('The payment has been deleted.') """ url = base_url + payment_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/CustomerPaymentsApi.py
CustomerPaymentsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.BankRulesParser import BankRulesParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'bankaccounts/rules/' zoho_http_client = ZohoHttpClient() parser = BankRulesParser() class BankRulesApi: """This class is used to 1.Fetch all the rules created for a specified bank or credit card account. 2.Get details of a specific rule. 3.Create a rule. 4.Update an existing rule. 5.Delete a rule. """ def __init__(self, authtoken, organization_id): """Initialize Bank rules Api using user's authtoken and organization id. Args: authotoken(str): User's Authtoken. organization id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_rules(self, account_id): """Get list of rules. Args: account_id(str): Account id for which the rules have to be listed. Returns: instance: Bank rules list object. """ param = { 'account_id': account_id } resp = zoho_http_client.get(base_url, self.details, param) return parser.get_rules(resp) def get(self, rule_id): """Get details of a rule. Args: rule_id(str): Rule id. Returns: instance: Bank rules object. """ url = base_url + rule_id resp = zoho_http_client.get(url, self.details) return parser.get_rule(resp) def create(self, rule): """Create a rule. Args: rule(instance): Bank rule object. Returns: instance: Bank rule object. """ json_object = dumps(rule.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_rule(resp) def update(self, rule_id, rule): """Update an existing rule. Args: rule_id(str): Rule id. Returns: instance: Bank rule object. """ url = base_url + rule_id json_object = dumps(rule.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_rule(resp) def delete(self, rule_id): """Delete an existing rule. Args: rule_id(str): Rule id. Returns: str: Success message('The rule has been deleted.'). """ url = base_url + rule_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/BankRulesApi.py
BankRulesApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.VendorPaymentsParser import VendorPaymentsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'vendorpayments/' parser = VendorPaymentsParser() zoho_http_client = ZohoHttpClient() class VendorPaymentsApi: """Vendor Payaments Api is used to 1.List all the paymnets made to your vendor. 2.Get the details of a vendor payment. 3.Create a payment made to the vendor. 4.Update an existing vendor payment. 5.Delete an existing vendor payment. """ def __init__(self, authtoken, organization_id): """Initialize Vendor payments api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_vendor_payments(self, parameter=None): """List all the payments made to the vendor. Args: parameter(dict, optional): Filter with which the list has to be displayed. Returns: instance: Vendor payments list object. """ resp = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(resp) def get(self, payment_id): """Get the details of vendor payment. Args: payment_id(str): Payment id. Returns: instance: Vendor payments object. """ url = base_url + payment_id resp = zoho_http_client.get(url, self.details) return parser.get_vendor_payment(resp) def create(self, vendor_payments): """Create a payment made to vendor. Args: vendor_payments(instance): Vendor payments object. Returns: instance: Vendor payments object. """ json_object = dumps(vendor_payments.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_vendor_payment(resp) def update(self, payment_id, vendor_payments): """Update an existing vendor payment. Args: payment_id(str): Payment id. vendor_payments(instance): Vendor payments object. Returns: instance: Vendor payments object. """ url = base_url + payment_id json_object = dumps(vendor_payments.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_vendor_payment(resp) def delete(self, payment_id): """Delete an existing vendor payment. Args: payment_id(str): Payment id. Returns: str: Success message('The paymenet has been deleted.'). """ url = base_url + payment_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/VendorPaymentsApi.py
VendorPaymentsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.BillsParser import BillsParser from books.api.Api import Api from os.path import basename from json import dumps base_url = Api().base_url + 'bills/' zoho_http_client = ZohoHttpClient() parser = BillsParser() class BillsApi: """Bills Api is used to 1.List all bills with pagination 2.Get the details of a bill. 3.Create a bill received from a vendor. 4.Update an existing bill. 5.delete an existing bill. 6.Mark a bill status as void. 7.Mark a void bill as open. 8.Update the billing address. 9.Get the list of payments made for the bill. 10.Apply the vendor credits from excess vendor payments to a bill. 11.Delete a payment made to a bill. 12.Returns a file attached to the bill. 13.Attach a file to a bill. 14.Delete the file attached to a bill. 15.Get the cmplete history and comments of a bill. 16.Add a comment for a bill. 17.Delete a bill comment. """ def __init__(self, authtoken, organization_id): """Initialize Bills api using user's authtoken and organization id. Args: authotoken(str): User's Authtoken. organization id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_bills(self, parameter=None): """List all bills with pagination. Args: parameter(dict, optional): Filter with which the list has to be displayed. Returns: instance: Bill list object. """ resp = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(resp) def get(self, bill_id): """Get the details of a bill. Args: bill_id(str): Bill id. Returns: instance: Bill object. """ url = base_url + bill_id resp = zoho_http_client.get(url, self.details) return parser.get_bill(resp) def create(self, bill, attachment=None): """Create a bill received from the vendor. Args: bill(instance): Bill object. attachment(file, optional): File to be attached with the bill. Allowed extensions are gif, png, jpeg, jpg, bmp and pdf. Returns: instance: Bill object. """ json_object = dumps(bill.to_json()) data = { 'JSONString': json_object } if attachment is None: attachments = None else: attachments = [{ 'attachment': { 'filename': basename(attachment), 'content': open(attachment).read() } }] resp = zoho_http_client.post(base_url, self.details, data, None, \ attachments) return parser.get_bill(resp) def update(self, bill_id, bill, attachment=None): """Update an existing bill. Args: bill_id(str): Bill id. bill(instance): Bill object. attachment(file, optional): File to be attached with the bill. Allowed extensions are gif, png, jpeg, jpg, bmp and pdf. Returns: instance: Bill object. """ url = base_url + bill_id json_object = dumps(bill.to_json()) data = { 'JSONString': json_object } if attachment is None: attachments = None else: attachments = [{ 'attachment': { 'filename': basename(attachment), 'content': open(attachment).read() } }] resp = zoho_http_client.put(url, self.details, data, None, \ attachments) return parser.get_bill(resp) def delete(self, bill_id): """Delete an existing bill. Args: bill_id(str): Bill id. Returns: str: Success message('The bill has been deleted.'). """ url = base_url + bill_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def void_a_bill(self, bill_id): """Mark a bill status as void. Args: bill_id(str): Bill id. Returns: str: Success message('The bill has been marked as void.'). """ url = base_url + bill_id + '/status/void' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp) def mark_a_bill_as_open(self, bill_id): """Mark a void bill as open. Args: bill_id(str): Bill id. Returns: str: Success message('The status of the bill has been changed from void to open.'). """ url = base_url + bill_id + '/status/open' resp = zoho_http_client.post(url, self.details, '') return parser.get_message(resp) def update_billing_address(self, bill_id, billing_address): """Update the billing address for the bill. Args: bill_id(str): Bill id. billing_address(instance): Billing address object. Returns: str: Success message('Billing address update.'). """ url = base_url + bill_id + '/address/billing' json_object = dumps(billing_address.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_message(resp) def list_bill_payments(self, bill_id): """Get the list of payments made for the bill. Args: bill_id(str): Bill id. Returns: instance: Payments list object. """ url = base_url + bill_id + '/payments' resp = zoho_http_client.get(url, self.details) return parser.get_payments_list(resp) def apply_credits(self, bill_id, bill_payments): """Apply the vendor credits from excess vendor payments to a bill. Args: bill_id(str): Bill id. bill_payments(list of instance): list of payments object. Returns: str: Success message('Credits have been applied to the bill.'). """ url = base_url + bill_id + '/credits' data = {} bill_payments_list = [] for value in bill_payments: bill_payment = {} bill_payment['payment_id'] = value.get_payment_id() bill_payment['amount_applied'] = value.get_amount_applied() bill_payments_list.append(bill_payment) data['bill_payments'] = bill_payments_list json_string = { 'JSONString': dumps(data) } resp = zoho_http_client.post(url, self.details, json_string) return parser.get_message(resp) def delete_a_payment(self, bill_id, bill_payment_id): """Delete a payment made to a bill. Args: bill_id(str): Bill id. bill_payment_id(str): Bill payment id. Returns: str: Success message('The payment has been deleted.'). Raises: Books Exception: If status is not '200' or '201'. """ url = base_url + bill_id + '/payments/' + bill_payment_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_a_bill_attachment(self, bill_id, preview=None): """Get the file attached to the bill. Args: bill_id(str): Bill id. preview(bool, optional): True to get the thumbnail of the attachment else False. Returns: file: File attached to the bill. """ if preview is not None: query = { 'preview': preview } else: query = None url = base_url + bill_id + '/attachment' resp = zoho_http_client.getfile(url, self.details, query) return resp def add_attachments_to_a_bill(self, bill_id, attachment): """Attach a file to a bill. Args: bill_id(str): Bill id. attachment(file): File to attach. Allowed extensions are gif, png, jpeg, jpg, bmp, pdf, xls, xlsx, doc, docx. Returns: str: Success message('The document has been deleted.'). """ url = base_url + bill_id + '/attachment' attachments = [{ 'attachment': { 'filename': basename(attachment), 'content': open(attachment).read() } }] data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data, None, attachments) return parser.get_message(resp) def delete_an_attachment(self, bill_id): """Delete the file attached to a bill. Args: bill_id(str): Bill id. Returns: str: Success message('The attachment has been deleted.'). """ url = base_url + bill_id + '/attachment' resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def list_bill_comments_and_history(self, bill_id): """Get the complete history and comments of a bill. Args: bill_id(str): Bill id. Returns: instance: Comments list object. """ url = base_url + bill_id + '/comments' resp = zoho_http_client.get(url, self.details) return parser.get_comments(resp) def add_comment(self, bill_id, description): """Add a comment for a bill. Args: bill_id(str): Bill id. description(str): Description. Returns: str: Success message('Comments added.'). """ url = base_url + bill_id + '/comments' data = { 'description': description } json_string = { 'JSONString': dumps(data) } resp = zoho_http_client.post(url, self.details, json_string) return parser.get_comment(resp) def delete_a_comment(self, bill_id, comment_id): """Delete a bill comment. Args: bill_id(str): Bill id. comment_id(str): Comment id. Returns: str: Success message('The comment has been deleted.'). Raises: Books Exception: If status is '200' or '201'. """ url = base_url + bill_id + '/comments/' + comment_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/BillsApi.py
BillsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.BaseCurrencyAdjustmentParser import BaseCurrencyAdjustmentParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'basecurrencyadjustment/' zoho_http_client = ZohoHttpClient() parser = BaseCurrencyAdjustmentParser() class BaseCurrencyAdjustmentApi: """Base Currency Adjsutment Api is used to: 1.List base currency adjustment. 2.Get base currency adjustment details. 3.List account details for base currency adjustment. 4.Creates a base currency adjustment. 5.Deletes a base currency adjustment. """ def __init__(self, authtoken, organization_id): """Initialize parameters for Base currency adjustment api. Args: authotoken(str): User's Authtoken. organization id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_base_currency_adjustments(self, parameters=None): """List base currency adjustment. Args: parameters(dict, optional): Filter with whichj the list has to be displayed. Defaults to None. Returns: instance: Base currency adjustment list object. """ resp = zoho_http_client.get(base_url, self.details, parameters) return parser.get_list(resp) def get(self, base_currency_adjustment_id): """Get base currency adjustment details. Args: base_currency_adjustment_id(str): Base currency adjustment id. Returns: instance: Base currency adjustment object. """ url = base_url + base_currency_adjustment_id resp = zoho_http_client.get(url, self.details) return parser.get_base_currency_adjustment(resp) def list_account_details(self, parameters): """List account details for base currency adjustments. Args: parameters(dict): Parameters with which the list has to be displayed. Returns: instance: Base currency adjustment object. """ url = base_url + 'accounts' resp = zoho_http_client.get(url, self.details, parameters) return parser.list_account_details(resp) def create(self, base_currency_adjustment, account_id): """Create base currency adjustment. Args: base_currency_adjustment(instance): Base currency adjustment object. account_ids(str): Account ids. Returns: instance: Base currency adjustment object. """ json_object = dumps(base_currency_adjustment.to_json()) data = { 'JSONString': json_object } account_ids = { 'account_ids': account_id } resp = zoho_http_client.post(base_url, self.details, data, account_ids) return parser.get_base_currency_adjustment(resp) def delete(self, base_currency_adjustment_id): """Delete an existing base currency adjustment. Args: base_currency_adjustment_id(str): Base currency adjustment id. Returns: str: Success message('The selected base currency adjustment has been deleted.'). """ url = base_url + base_currency_adjustment_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/BaseCurrencyAdjustmentApi.py
BaseCurrencyAdjustmentApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.SettingsParser import SettingsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'settings/' zoho_http_client = ZohoHttpClient() parser = SettingsParser() class SettingsApi: """This class is used to 1.List preferences that are configured. 2.Update the preferences that has been configured. 3.Create a unit that can be associated to a line item. 4.Delete a unit that has been associated to a line item. 5.Get the details of invoice settings. 6.Update the settings information of invoice. 7.Get the details of notes and terms. 8.Update invoice notes and terms. 9.Get estimate settings. 10.Update estimate settings. 11.Get estimate notes and terms. 12.Update estimate notes and terms. 13.List creditnotes settings. 14.Update creditnotes settings. 15.Get creditnote notes and term 16.Update creditnote notes and terms. 17.List currencies. 18.Get details of a currency. 19.Create a currency. 20.Update a currency. 21.Delete a currency. 22.List exchange rates. 23.Get an exchange rate. 24.Create an exchange rate. 25.Update an exchange rate. 26.Delete an exchange rate. 27.List taxes. 28.Get details of a tax. 29.Create a tax. 30.Update a tax. 31.Delete a tax. 32.Get a tax group. 33.Create a tax group. 34.Update a tax group. 35.Delete a tax group. 36.Get Opening balance. 37.Create opening balance. 38.Update opening balance. 39.Delete opening balance. 40.List auto payment reminder. 41.Get an auto payment reminder. 42.Enable auto reminder. 43.Disable auto reminder. 44.Update an auto reminder. 45.List manual reminders. 46.Get a manual reminder. 47.Update a manual reminder. """ def __init__(self, authtoken, organization_id): """Initialize Settings Api using authtoken and organization id. Args: authtoken(str): User's Authtoken. organization_id(str): User's Organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def list_preferences(self): """List of preferences that are configured. Returns: instance: Preference list object. """ url = base_url + 'preferences' resp = zoho_http_client.get(url, self.details) return parser.preference_list(resp) def update_preferences(self, preference): """Update preference. Args: preference(instance): Preference object. Returns: str: Success message('Preferences have been saved.'). """ url = base_url + 'preferences' json_object = dumps(preference.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_message(resp) def create_unit(self, unit): """Create a unit that can be associated to a line item. Args: unit(str): Unit. Eg: Kg. Returns: str: Success message('Unit added.'). """ url = base_url + 'units' data = { 'unit': unit } json_string = { 'JSONString': dumps(data) } resp = zoho_http_client.post(url, self.details, json_string) return parser.get_message(resp) def delete_unit(self, unit_id): """Delete a unit that has been associated to an item. Args: unit_id(str): Unit id. Returns: str: Success message('You have successfully deleted the unit.'). """ url = base_url + 'units/' + unit_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_invoice_settings(self): """Get the details of invoice settings. Returns: instance: Invoice settings object. """ url = base_url + 'invoices' resp = zoho_http_client.get(url, self.details) return parser.get_invoice_settings(resp) def update_invoice_settings(self, invoice_settings): """Update the settings information for invoices. Args: invoice_settings(instance): Invoice settings. Returns: instance: Invoice settings object. """ url = base_url + 'invoices' json_object = dumps(invoice_settings.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_invoice_settings(resp) def get_invoice_notes_and_terms(self): """Get the details of invoce notes and terms. Returns: instance: Notes and terms object. """ url = base_url + 'invoices/notesandterms' resp = zoho_http_client.get(url, self.details) return parser.get_notes_and_terms(resp) def update_invoice_notes_and_terms(self, invoice_notes_and_terms): """Update the notes and terms for an invoice. Args: invoice_notes_and_terms(instance): Invoice notes and terms object. Returns: instance: Invoice notes and terms object. """ url = base_url + 'invoices/notesandterms' json_object = dumps(invoice_notes_and_terms.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_notes_and_terms(resp) def get_estimate_settings(self): """Get estimate settings. Returns: instance: Estimate settings. """ url = base_url + 'estimates' resp = zoho_http_client.get(url, self.details) return parser.get_estimate_settings(resp) def update_estimate_settings(self, estimate_setting): """Update estimate settings. Args: estimate_setting(instance): Estimate setting object. Returns: instance: Estiamte setting object. """ url = base_url + 'estimates' json_object = dumps(estimate_setting.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_estimate_settings(resp) def get_estimates_notes_and_terms(self): """Get estimates notes and terms. Returns: instance: notes and terms object. """ url = base_url + 'estimates/notesandterms' resp = zoho_http_client.get(url, self.details) return parser.get_notes_and_terms(resp) def update_estimates_notes_and_terms(self, notes_and_terms): """Update estimate notes and terms. Args: notes_and_terms(instance): Notes and terms object. Returns: instance: Estimates notes and terms. """ url = base_url + 'estimates/notesandterms' json_object = dumps(notes_and_terms.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_notes_and_terms(resp) def list_creditnote_settings(self): """List creditnotes settings. Returns: instance: creditnotes settings. """ url = base_url + 'creditnotes' resp = zoho_http_client.get(url, self.details) return parser.get_creditnote_settings(resp) def update_creditnote_settings(self, creditnotes_settings): """Update creditnotes settings. Args: creditnotes_settings(instance): Creditnotes settings object. Returns: instance: Creditnotes settings object. """ url = base_url + 'creditnotes' json_object = dumps(creditnotes_settings.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_creditnote_settings(resp) def get_creditnote_notes_and_terms(self): """Get creditnotes notes and terms. Returns: instance: Creditnotes settings object. """ url = base_url + 'creditnotes/notesandterms' resp = zoho_http_client.get(url, self.details) return parser.get_notes_and_terms(resp) def update_creditnote_notes_and_terms(self, notes_and_terms): """Update creditnotes notes and terms. Args: notes_and_terms(instance): Notes and terms object. Returns: instance: Notes and terms object. """ url = base_url + 'creditnotes/notesandterms' json_object = dumps(notes_and_terms.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_notes_and_terms(resp) def get_currencies(self, param=None): """List of configured currencies with pagination. Args: param(dict, optional): Filter with which the list has to be displayed. Returns: instance: Currency list object. """ url = base_url + 'currencies' if param is not None: data = { 'filter_by': param } else: data = None resp = zoho_http_client.get(url, self.details, data) return parser.get_currencies(resp) def get_currency(self, currency_id): """Get the details of a currency. Args: currency_id(str): Currency id. Returns: instance: Currency object. """ url = base_url + 'currencies/' + currency_id resp = zoho_http_client.get(url, self.details) return parser.get_currency(resp) def create_currency(self, currency): """Create a currency for transactions. Args: currency(instance): Currency object. Returns: instance: Currency object. """ url = base_url + 'currencies' json_obj = dumps(currency.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.post(url, self.details, data) return parser.get_currency(resp) def update_currency(self, currency_id, currency): """Update the details of currency. Args: currency_id(str): Currency id. currency(instance): Currency object. Returns: instance: Currecny object. """ url = base_url + 'currencies/' + currency_id json_obj = dumps(currency.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_currency(resp) def delete_currency(self, currency_id): """Delete currency. Args: currency_id(str): Currency id. Returns: str: Success message('The currency has been deleted.'). """ url = base_url + 'currencies/' + currency_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def list_exchange_rates(self, currency_id, param=None): """List of exchange rates configured for the currency. Args: param(dict, optional): Filter with which the list has to be displayed. Returns: instance: Exchange rate list object. """ url = base_url + 'currencies/' + currency_id + '/exchangerates' resp = zoho_http_client.get(url, self.details, param) return parser.get_exchange_rates(resp) def get_exchange_rate(self, currency_id, exchange_rate_id): """Get details of an exchange rate that has been associated to the currency. Args: currency_id(str): Currency id. exchange_rate_id(str): Exchange rate id. Returns: instance: Exchange rate object. """ url = base_url + 'currencies/' + currency_id + '/exchangerates/' + \ exchange_rate_id resp = zoho_http_client.get(url, self.details) return parser.get_exchange_rate(resp) def create_exchange_rate(self, exchange_rate): """Create an exchange rate for the specified currency. Args: currency_id(str): Currency id. exchange_rate(instance): Exchange rate object. Returns: instance: Exchange rate object. """ url = base_url + 'currencies/' + exchange_rate.get_currency_id() + \ '/exchangerates' json_obj = dumps(exchange_rate.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.post(url, self.details, data) return parser.get_exchange_rate(resp) def update_exchange_rate(self, exchange_rate): """Update the details of exchange rate currency. Args: exchange_rate(instance): Exchnage rate object. Returns: str: Success message('The exchange rate has been update.'). """ url = base_url + 'currencies/' + exchange_rate.get_currency_id() + \ '/exchangerates/' + exchange_rate.get_exchange_rate_id() json_obj = dumps(exchange_rate.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_message(resp) def delete_exchange_rate(self, currency_id, exchange_rate_id): """Delete an exchnage rate for the specified currency. Args: currency_id(str): Currency id. exchange_rate_id(str): Exchange rate id. Returns: str: Success message('Exchange rate successfully deleted.'). """ url = base_url + 'currencies/' + currency_id + '/exchangerates/' + \ exchange_rate_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_taxes(self): """List of taxes with pagination. Returns: instance: Tax list object. """ url = base_url + 'taxes' resp = zoho_http_client.get(url, self.details) return parser.get_taxes(resp) def get_tax(self, tax_id): """Get details of a tax. Args: tax_id(str): Tax id. Returns: instance: Tax object. """ url = base_url + 'taxes/' + tax_id resp = zoho_http_client.get(url, self.details) return parser.get_tax(resp) def create_tax(self, tax): """Create tax. Args: tax(instance): Tax object. Returns: instance: Tax object. """ url = base_url + 'taxes' json_obj = dumps(tax.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.post(url, self.details, data) return parser.get_tax(resp) def update_tax(self, tax_id, tax): """Update the details of tax. Args: tax_id(str): Tax id. tax(instance): Tax object. Returns: instance: Tax object. """ url = base_url + 'taxes/' + tax_id json_obj = dumps(tax.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_tax(resp) def delete_tax(self, tax_id): """Delete tax. Args: tax_id(str): Tax id. Returns: str: Success message('The record has been deleted.'). """ url = base_url + 'taxes/' + tax_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_tax_group(self, tax_group_id): """Get details of a tax group with associated taxes. Args: tax_group_id(str): Tax group id. Returns: instance: Tax group object. """ url = base_url + 'taxgroups/' + tax_group_id resp = zoho_http_client.get(url, self.details) return parser.get_tax_group(resp) def create_tax_group(self, tax_group): """Create a tax group associating multiple taxes. Args: tax_group_name(str): Tax group name. taxes(str): List of tax ids associated to the tax group. Returns: instance: Tax group object. """ url = base_url + 'taxgroups' json_obj = dumps(tax_group.to_json()) data = { 'JSONString': json_obj } print(data) resp = zoho_http_client.post(url, self.details, data) return parser.get_tax_group(resp) def update_tax_group(self, tax_group): """Update tax group. Args: tax_group_id(str): Tax group id. tax_group_name(str): Tax group name. taxes(str): List of tax ids associated to that tax group. Returns: instance: Tax group object. """ url = base_url + 'taxgroups/' + tax_group.get_tax_group_id() json_obj = dumps(tax_group.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_message(resp) def delete_tax_group(self, tax_group_id): """Delete tax group. Args: tax_group_id(str): Tax group id. Returns: str: Success message('The tax group has been deleted.'). """ url = base_url + 'taxgroups/' + tax_group_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def get_opening_balance(self): """Get opening balance. Returns: instance: Opening balance object. """ url = base_url + 'openingbalances' resp = zoho_http_client.get(url, self.details) return parser.get_opening_balance(resp) def create_opening_balance(self, opening_balance): """Create opening balance. Args: opening_balance(instance): Opening balance object. Returns: instance: Opening balance object. """ url = base_url + 'openingbalances' json_object = dumps(opening_balance.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(url, self.details, data) return parser.get_opening_balance(resp) def update_opening_balance(self, opening_balance): """Update opening balance. Args: opening_balance(instance): Opening balance object. Returns: instance: Opening balance object. """ url = base_url + 'openingbalances' json_object = dumps(opening_balance.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_opening_balance(resp) def delete_opening_balance(self): """Delete the entered opening balance. Returns: str: Success message('The entered opening balance has been deleted.'). """ url = base_url + 'openingbalances' resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp) def list_auto_payment_reminder(self): """List auto payment reminder. Returns: instance: Autoreminders list object. """ url = base_url + 'autoreminders' resp = zoho_http_client.get(url, self.details) return parser.get_autoreminders(resp) def get_auto_payment_reminder(self, reminder_id): """Get auto payment reminder. Args: reminder_id(str): Reminder id. Returns: instance: Auto payment reminder object. """ url = base_url + 'autoreminders/' + reminder_id resp = zoho_http_client.get(url, self.details) return parser.get_autoreminder(resp) def enable_auto_reminder(self, reminder_id): """Enable automated payment reminder. Args: reminder_id(str): Reminder id. Returns: str: Success message('Payment reminder has been enabled.'). """ url = base_url + 'autoreminders/' + reminder_id + '/enable' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def disable_auto_reminder(self, reminder_id): """Disable automated payment reminder. Args: reminder_id(str): Reminder id. Returns: str: Success message('Payment reminder has been disabled.'). """ url = base_url + 'autoreminders/' + reminder_id + '/disable' data = { 'JSONString': '' } resp = zoho_http_client.post(url, self.details, data) return parser.get_message(resp) def update_auto_reminder(self, reminder_id, autoreminder): """Update an auto reminder. Args: reminder_id(str): Reminder id. autoreminder(instance): Auto reminder object. Returns: str: Success message('Your payment reminder preferences have been saved.'). """ url = base_url + 'autoreminders/' + reminder_id json_obj = autoreminder.to_json() data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_message(resp) def list_manual_reminders(self, type_of_reminder=None): """List of manual reminders. Args: type_of_reminder(str): Type to select between open or overdue reminder. Returns: instance: Manual reminder list object. """ url = base_url + 'manualreminders' if type_of_reminder is not None: param = { 'type': type_of_reminder } else: param = None resp = zoho_http_client.get(url, self.details) return parser.get_manual_reminders(resp) def get_manual_reminder(self, reminder_id): """Get the details of a manual reminder. Args: manual_reminder(instance): Manual reminder object. Returns: instance: Manual reminder object. """ url = base_url + 'manualreminders/' + reminder_id resp = zoho_http_client.get(url, self.details) return parser.get_manual_reminder(resp) def update_manual_reminder(self, reminder_id, manual_reminder): """Update manual reminder. Args: reminder_id(str): Reminder id. manual_reminder(instance): Manual reminder. Returns: instance: Manual reminder. """ url = base_url + 'manualreminders/' + reminder_id json_obj = dumps(manual_reminder.to_json()) data = { 'JSONString': json_obj } resp = zoho_http_client.put(url, self.details, data) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/SettingsApi.py
SettingsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.JournalsParser import JournalsParser from books.api.Api import Api from json import dumps base_url = Api().base_url + 'journals/' zoho_http_client = ZohoHttpClient() parser = JournalsParser() class JournalsApi: """Journals Api class is used to: 1.Get journals list. 2.Get the details of the journal. 3.Create a journal. 4.Updates the journal with given information. 5.Deletes the given journal. """ def __init__(self, authtoken, organization_id): """Initialize parameters for Journals Api. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details = { 'authtoken': authtoken, 'organization_id': organization_id } def get_journals(self, parameter=None): """Get Journals list. Args: parameter(dict): Filter with which the list has to be displayed. Returns: instance: Journals List object. """ resp = zoho_http_client.get(base_url, self.details, parameter) return parser.get_list(resp) def get(self, journal_id): """Get details of a journal. Args: journal_id(str): Journal id. Returns: instance: Journals object. """ url = base_url + journal_id resp = zoho_http_client.get(url, self.details) return parser.get_journal(resp) def create(self, journal): """Create a journal. Args: journal(instance): Journal object. Returns: instance: Journal object. """ json_object = dumps(journal.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.post(base_url, self.details, data) return parser.get_journal(resp) def update(self, journal_id, journal): """Update an existing journal. Args: journal_id(str): Journal id. journal(instance): Journal object. Returns: instance: Journal object. """ url = base_url + journal_id json_object = dumps(journal.to_json()) data = { 'JSONString': json_object } resp = zoho_http_client.put(url, self.details, data) return parser.get_journal(resp) def delete(self, journal_id): """Delete the given journal. Args: journal_id(str): Journal id. """ url = base_url + journal_id resp = zoho_http_client.delete(url, self.details) return parser.get_message(resp)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/JournalsApi.py
JournalsApi.py
from books.util.ZohoHttpClient import ZohoHttpClient from books.parser.ContactParser import ContactParser from .Api import Api from json import dumps base_url = Api().base_url + 'contacts/' parser = ContactParser() zoho_http_client = zoho_http_client = ZohoHttpClient() class ContactPersonsApi: """ContactPersonsApi class is used to: 1.To get the list of contact persons of a contact with pagination. 2.To get the details of a contact person. 3.To create a contact person for a contact. 4.To update an existing contact person. 5.To delete a contact person. 6.To mark a contact person as primary for the contact. """ def __init__(self, authtoken, organization_id): """Initialize ContactPersons Api using user's authtoken and organization id. Args: authtoken(str): User's authtoken. organization_id(str): User's organization id. """ self.details={ 'authtoken':authtoken, 'organization_id':organization_id, } def get_contact_persons(self, contact_id): """List contact persons of a contact with pagination. Args: contact_id(str): Contact id of a contact. Returns: instance: Contact Persons list object. """ url = base_url + contact_id + '/contactpersons' response=zoho_http_client.get(url, self.details) return parser.get_contact_persons(response) def get(self, contact_person_id): """Get the contact persons details. Args: contact_id(str): Contact id of a contact. Returns: instance: Contact Person object. """ url = base_url + 'contactpersons/' + contact_person_id response = zoho_http_client.get(url, self.details) return parser.get_contact_person(response) def create(self, contact_person): """Create a contact person for contact. Args: contact_id(str): Contact_id of a contact. Returns: instance: Contact person object. """ url = base_url + 'contactpersons' json_object = dumps(contact_person.to_json()) print(json_object) data = { 'JSONString': json_object } response = zoho_http_client.post(url, self.details, data) return parser.get_contact_person(response) def update(self, contact_person_id, contact_person): """Update an existing contact person. Args: contact_id(str): Contact_id of a contact. contact_person(instance): Contact person object. Returns: instance: Contact person object. """ url = base_url + 'contactpersons/' + contact_person_id json_object = dumps(contact_person.to_json()) data = { 'JSONString': json_object } response = zoho_http_client.put(url, self.details, data) return parser.get_contact_person(response) def delete(self, contact_person_id): """Delete a contact person. Args: contact_person_id(str): Contact person id of a contact person. Returns: str: Success message('The contact person has been deleted'). """ url = base_url + 'contactpersons/' + contact_person_id response = zoho_http_client.delete(url, self.details) return parser.get_message(response) def mark_as_primary_contact(self, contact_person_id): """Mark a contact person as primary for the contact. Args: contact_person_id(str): Contact person id of a contact person. Returns: str: Success message('This contact person has been marked as your primary contact person.'). """ url = base_url + 'contactpersons/' + contact_person_id + '/primary' response = zoho_http_client.post(url, self.details, '') return parser.get_message(response)
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/api/ContactPersonsApi.py
ContactPersonsApi.py
from books.model.Contact import Contact from books.model.Email import Email from books.model.Address import Address from books.model.ContactPerson import ContactPerson from books.model.ContactPersonList import ContactPersonList from books.model.CustomField import CustomField from books.model.DefaultTemplate import DefaultTemplate from books.model.PageContext import PageContext from books.model.ContactList import ContactList from books.model.ToContact import ToContact from books.model.FromEmail import FromEmail from books.model.CommentList import CommentList from books.model.Comment import Comment from books.model.CreditNoteRefundList import CreditNoteRefundList from books.model.CreditNoteRefund import CreditNoteRefund class ContactParser: """This class is used to parse the json for contact.""" 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_gst_treatment(response['gst_treatment']) contact.set_gst_no(response['gst_no']) contact.set_place_of_contact(response['place_of_contact']) 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 def get_contacts(self, resp): """This method parses the given response and creates a contact list object. Args: resp(dict): Response containing json object for contact list. Returns: instance: Contact list object. """ contacts_list = ContactList() response = resp['contacts'] for value in resp['contacts']: contact = Contact() contact.set_contact_id(value['contact_id']) contact.set_contact_name(value['contact_name']) contact.set_company_name(value['company_name']) contact.set_gst_treatment(value['gst_treatment']) contact.set_gst_no(value['gst_no']) contact.set_place_of_contact(value['place_of_contact']) contact.set_contact_type(value['contact_type']) contact.set_status(value['status']) contact.set_payment_terms(value['payment_terms']) contact.set_payment_terms_label(value['payment_terms_label']) contact.set_currency_id(value['currency_id']) contact.set_currency_code(value['currency_code']) contact.set_outstanding_receivable_amount(value[\ 'outstanding_receivable_amount']) contact.set_outstanding_payable_amount(value[\ 'outstanding_payable_amount']) contact.set_unused_credits_receivable_amount(value[\ 'unused_credits_receivable_amount']) contact.set_unused_credits_payable_amount(value[\ 'unused_credits_payable_amount']) contact.set_first_name(value['first_name']) contact.set_last_name(value['last_name']) contact.set_email(value['email']) contact.set_phone(value['phone']) contact.set_mobile(value['mobile']) contact.set_created_time(value['created_time']) contact.set_last_modified_time(value['last_modified_time']) contacts_list.set_contacts(contact) page_context_object = PageContext() page_context = resp['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_applied_filter(page_context['applied_filter']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) contacts_list.set_page_context(page_context_object) return contacts_list def get_contact_person(self, resp): """This method parses the given response and creates a contact person object. Args: resp(dict): Response containing json object for contact person. Returns: instance: Contact person object. """ contact_person = ContactPerson() response = resp['contact_person'] contact_person.set_contact_id(response['contact_id']) contact_person.set_contact_person_id(response['contact_person_id']) contact_person.set_salutation(response['salutation']) contact_person.set_first_name(response['first_name']) contact_person.set_last_name(response['last_name']) contact_person.set_email(response['email']) contact_person.set_phone(response['phone']) contact_person.set_mobile(response['mobile']) contact_person.set_is_primary_contact(response['is_primary_contact']) return contact_person def get_contact_persons(self, response): """This method parses the given repsonse and creates contact persons list object. Args: response(dict): Response containing json object for contact persons list. Returns: instance: Contact person list object. """ resp = response['contact_persons'] contact_person_list = ContactPersonList() for value in resp: 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_person_list.set_contact_persons(contact_person) page_context_object = PageContext() page_context = response['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) contact_person_list.set_page_context(page_context_object) return contact_person_list def get_message(self, response): """This method parses the given response and returns the message. Args: response(dict): Response containing json object. Returns: str: Success message. """ return response['message'] def get_mail_content(self, response): """This method parses the give response and creates object for email. Args: response(dict): Response containing json object for email . Returns: instance: Email object. """ email = Email() data = response['data'] email.set_body(data['body']) email.set_contact_id(data['contact_id']) email.set_subject(data['subject']) for to_contact in data['to_contacts']: to_contacts = ToContact() to_contacts.set_first_name(to_contact['first_name']) to_contacts.set_selected(to_contact['selected']) to_contacts.set_phone(to_contact['phone']) to_contacts.set_email(to_contact['email']) to_contacts.set_last_name(to_contact['last_name']) to_contacts.set_salutation(to_contact['salutation']) to_contacts.set_contact_person_id(to_contact['contact_person_id']) to_contacts.set_mobile(to_contact['mobile']) email.set_to_contacts(to_contacts) email.set_file_name(data['file_name']) for value in data['from_emails']: from_emails = FromEmail() from_emails.set_user_name(value['user_name']) from_emails.set_selected(value['selected']) from_emails.set_email(value['email']) from_emails.set_is_org_email_id(value['is_org_email_id']) email.set_from_emails(from_emails) return email def get_comment_list(self, response): """This method parses the given response and creates object for comments list. Args: response(dict): Response containing json object for comments list. Returns: instance: cComments list object. """ comment_list = CommentList() contact_comments = response['contact_comments'] for value in contact_comments: contact_comment = Comment() contact_comment.set_comment_id(value['comment_id']) contact_comment.set_contact_id(value['contact_id']) contact_comment.set_contact_name(value['contact_name']) contact_comment.set_description(value['description']) contact_comment.set_commented_by_id(value['commented_by_id']) contact_comment.set_commented_by(value['commented_by']) contact_comment.set_date(value['date']) contact_comment.set_date_description(value['date_description']) contact_comment.set_time(value['time']) contact_comment.set_transaction_id(value['transaction_id']) contact_comment.set_transaction_type(value['transaction_type']) contact_comment.set_is_entity_deleted(value['is_entity_deleted']) contact_comment.set_operation_type(value['operation_type']) comment_list.set_comments(contact_comment) page_context = response['page_context'] page_context_object = PageContext() page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_applied_filter(page_context['applied_filter']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) comment_list.set_page_context(page_context_object) return comment_list def get_refund_list(self, response): """This method parses the given response and creates refund list object. Args: response(dict): Response containing json object for refund list. Returns: instance: Refund list object. """ list_refund = CreditNoteRefundList() creditnote_refunds = response['creditnote_refunds'] for value in creditnote_refunds: creditnote_refund = CreditNoteRefund() creditnote_refund.set_creditnote_refund_id(value[\ 'creditnote_refund_id']) creditnote_refund.set_creditnote_id(value['creditnote_id']) creditnote_refund.set_date(value['date']) creditnote_refund.set_refund_mode(value['refund_mode']) creditnote_refund.set_reference_number(value['reference_number']) creditnote_refund.set_creditnote_number(value['creditnote_number']) creditnote_refund.set_customer_name(value['customer_name']) creditnote_refund.set_description(value['description']) creditnote_refund.set_amount_bcy(value['amount_bcy']) creditnote_refund.set_amount_fcy(value['amount_fcy']) list_refund.set_creditnote_refunds(creditnote_refund) page_context = response['page_context'] page_context_object = PageContext() page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_report_name(page_context['report_name']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) list_refund.set_page_context(page_context_object) return list_refund
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/ContactParser.py
ContactParser.py
from books.model.BankAccount import BankAccount from books.model.BankAccountList import BankAccountList from books.model.Transaction import Transaction from books.model.Statement import Statement from books.model.PageContext import PageContext class BankAccountsParser: """This class is used to parse the json response for Bank accounts.""" def get_list(self, resp): """This method parses the given response and returns bank account list object. Args: resp(dict): Response containing json object for Bank account list. Returns: instance: Bank account list object. """ bank_account_list = BankAccountList() for value in resp['bankaccounts']: bank_accounts = BankAccount() bank_accounts.set_account_id(value['account_id']) bank_accounts.set_account_name(value['account_name']) bank_accounts.set_currency_id(value['currency_id']) bank_accounts.set_currency_code(value['currency_code']) bank_accounts.set_account_type(value['account_type']) bank_accounts.set_uncategorized_transactions(\ value['uncategorized_transactions']) bank_accounts.set_is_active(value['is_active']) bank_accounts.set_balance(value['balance']) bank_accounts.set_bank_name(value['bank_name']) bank_accounts.set_routing_number(value['routing_number']) bank_accounts.set_is_primary_account(value['is_primary_account']) bank_accounts.set_is_paypal_account(value['is_paypal_account']) if value['is_paypal_account']: bank_accounts.set_paypal_email_address(\ value['paypal_email_address']) bank_account_list.set_bank_accounts(bank_accounts) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) bank_account_list.set_page_context(page_context_obj) return bank_account_list def get_account_details(self, resp): """This method parses the given response and returns bank account object. Args: resp(dict): Response containing json object for bank accounts. Returns: instance: Bank accounts object. Raises: Books Exception: If status is not '200' or '201'. """ bank_account = resp['bankaccount'] bank_account_obj = BankAccount() bank_account_obj.set_account_id(bank_account['account_id']) bank_account_obj.set_account_name(bank_account['account_name']) bank_account_obj.set_currency_id(bank_account['currency_id']) bank_account_obj.set_currency_code(bank_account['currency_code']) bank_account_obj.set_account_type(bank_account['account_type']) bank_account_obj.set_account_number(bank_account['account_number']) bank_account_obj.set_uncategorized_transactions(\ bank_account['uncategorized_transactions']) bank_account_obj.set_is_active(bank_account['is_active']) bank_account_obj.set_balance(bank_account['balance']) bank_account_obj.set_bank_name(bank_account['bank_name']) bank_account_obj.set_routing_number(bank_account['routing_number']) bank_account_obj.set_is_primary_account(bank_account[\ 'is_primary_account']) bank_account_obj.set_is_paypal_account(bank_account[\ 'is_paypal_account']) if bank_account['is_paypal_account']: bank_account_obj.set_paypal_email_address(\ bank_account['paypal_email_address']) bank_account_obj.set_description(bank_account['description']) return bank_account_obj def get_message(self, resp): """This message parses the given response and returns message string. Args: resp(dict): Response containing json object for message. Returns: str: Success message. """ return resp['message'] def get_statement(self, resp): """This method parses the given response and returns statement object. Args: resp(dict): Response containing json onbject for statement. Returns: instance: Statement object. """ statement = resp['statement'] statement_obj = Statement() statement_obj.set_statement_id(statement['statement_id']) statement_obj.set_from_date(statement['from_date']) statement_obj.set_to_date(statement['to_date']) statement_obj.set_source(statement['source']) for value in statement['transactions']: transactions = Transaction() transactions.set_transaction_id(value['transaction_id']) transactions.set_debit_or_credit(value['debit_or_credit']) transactions.set_date(value['date']) transactions.set_customer_id(value['customer_id']) transactions.set_payee(value['payee']) transactions.set_reference_number(value['reference_number']) transactions.set_amount(value['amount']) transactions.set_status(value['status']) statement_obj.set_transactions(transactions) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) statement_obj.set_page_context(page_context_obj) return statement_obj
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/BankAccountsParser.py
BankAccountsParser.py
from books.model.Estimate import Estimate from books.model.EstimateList import EstimateList from books.model.Address import Address from books.model.Email import Email from books.model.ContactPerson import ContactPerson from books.model.LineItem import LineItem from books.model.PageContext import PageContext from books.model.Tax import Tax from books.model.CustomField import CustomField from books.model.Email import Email from books.model.EmailTemplate import EmailTemplate from books.model.ToContact import ToContact from books.model.FromEmail import FromEmail from books.model.Template import Template from books.model.Comment import Comment from books.model.CommentList import CommentList from books.model.TemplateList import TemplateList class EstimatesParser: """This class is used to parse the json for estimates.""" def get_list(self, response): """This method parses the given response and returns estimates list object. Args: response(dict): Response containing json object for estimates. Returns: instance: Estimates list object. """ resp = response['estimates'] estimate_list = EstimateList() for value in resp: estimates = Estimate() estimates.set_estimate_id(value['estimate_id']) estimates.set_customer_name(value['customer_name']) estimates.set_customer_id(value['customer_id']) estimates.set_status(value['status']) estimates.set_estimate_number(value['estimate_number']) estimates.set_reference_number(value['reference_number']) estimates.set_date(value['date']) estimates.set_currency_id(value['currency_id']) estimates.set_currency_code(value['currency_code']) estimates.set_total(value['total']) estimates.set_created_time(value['created_time']) estimates.set_accepted_date(value['accepted_date']) estimates.set_declined_date(value['declined_date']) estimates.set_expiry_date(value['expiry_date']) estimate_list.set_estimates(estimates) page_context_object = PageContext() page_context = response['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_report_name(page_context['report_name']) page_context_object.set_applied_filter(page_context['applied_filter']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) estimate_list.set_page_context(page_context_object) return estimate_list def get_estimate(self, response): """This method parses the given response and returns Estimate object. Args: response(dict): Response containing json object for estimate. Returns: instance: Estimate object. """ estimate = Estimate() resp = response['estimate'] estimate.set_estimate_id(resp['estimate_id']) estimate.set_estimate_number(resp['estimate_number']) estimate.set_date(resp['date']) estimate.set_reference_number(resp['reference_number']) estimate.set_status(resp['status']) estimate.set_customer_id(resp['customer_id']) estimate.set_customer_name(resp['customer_name']) estimate.set_contact_persons(resp['contact_persons']) estimate.set_currency_id(resp['currency_id']) estimate.set_currency_code(resp['currency_code']) estimate.set_exchange_rate(resp['exchange_rate']) estimate.set_expiry_date(resp['expiry_date']) estimate.set_discount(resp['discount']) estimate.set_is_discount_before_tax(resp['is_discount_before_tax']) estimate.set_discount_type(resp['discount_type']) line_items = resp['line_items'] for value in line_items: line_item = LineItem() line_item.set_item_id(value['item_id']) line_item.set_line_item_id(value['line_item_id']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_discount(value['discount']) line_item.set_tax_id(value['tax_id']) line_item.set_tax_name(value['tax_name']) line_item.set_tax_type(value['tax_type']) line_item.set_tax_percentage(value['tax_percentage']) line_item.set_item_total(value['item_total']) estimate.set_line_items(line_item) estimate.set_shipping_charge(resp['shipping_charge']) estimate.set_adjustment(resp['adjustment']) estimate.set_adjustment_description(resp['adjustment_description']) estimate.set_sub_total(resp['sub_total']) estimate.set_total(resp['total']) estimate.set_tax_total(resp['tax_total']) estimate.set_price_precision(resp['price_precision']) taxes = resp['taxes'] for value in taxes: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) estimate.set_taxes(tax) billing_address = resp['billing_address'] billing_address_object = Address() billing_address_object.set_address(billing_address['address']) billing_address_object.set_city(billing_address['city']) billing_address_object.set_state(billing_address['state']) billing_address_object.set_zip(billing_address['zip']) billing_address_object.set_country(billing_address['country']) billing_address_object.set_fax(billing_address['zip']) estimate.set_billing_address(billing_address_object) shipping_address = resp['shipping_address'] shipping_address_object = Address() shipping_address_object.set_address(shipping_address['address']) shipping_address_object.set_city(shipping_address['city']) shipping_address_object.set_state(shipping_address['state']) shipping_address_object.set_zip(shipping_address['zip']) shipping_address_object.set_country(shipping_address['country']) shipping_address_object.set_fax(shipping_address['zip']) estimate.set_shipping_address(shipping_address_object) estimate.set_notes(resp['notes']) estimate.set_terms(resp['terms']) custom_fields = resp['custom_fields'] for value in custom_fields: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_show_on_pdf(value['show_on_pdf']) custom_field.set_value(value['value']) custom_field.set_label(value['label']) estimate.set_custom_fields(custom_field) estimate.set_template_id(resp['template_id']) estimate.set_template_name(resp['template_name']) estimate.set_created_time(resp['created_time']) estimate.set_last_modified_time(resp['last_modified_time']) estimate.set_salesperson_id(resp['salesperson_id']) estimate.set_salesperson_name(resp['salesperson_name']) return estimate def get_message(self, response): """This method parses the given response and returns success message. Args: response(dict): Response containing json object. Returns: str: Success message. """ return response['message'] def get_email_content(self, response): """This method parses the given response and returns email object. Args: response(dict): Response containing json object for email content. Returns: instance: Email object. """ email = Email() data = response['data'] email.set_body(data['body']) email.set_error_list(data['error_list']) email.set_subject(data['subject']) for value in data['emailtemplates']: email_templates = EmailTemplate() email_templates.set_selected(value['selected']) email_templates.set_name(value['name']) email_templates.set_email_template_id(value['email_template_id']) email.set_email_templates(email_templates) to_contacts = data['to_contacts'] for value in to_contacts: to_contact = ToContact() to_contact.set_first_name(value['first_name']) to_contact.set_selected(value['selected']) to_contact.set_phone(value['phone']) to_contact.set_email(value['email']) to_contact.set_contact_person_id(value['contact_person_id']) to_contact.set_last_name(value['last_name']) to_contact.set_salutation(value['salutation']) to_contact.set_mobile(value['mobile']) email.set_to_contacts(to_contact) email.set_file_name(data['file_name']) from_emails = data['from_emails'] for value in from_emails: from_email = FromEmail() from_email.set_user_name(value['user_name']) from_email.set_selected(value['selected']) from_email.set_email(value['email']) email.set_from_emails(from_email) email.set_customer_id(data['customer_id']) return email def get_billing_address(self, response): """This method parses the given response and returns billing address object. Args: response(dict): Response containing json object for billing address. Returns: instacne: Billing address object. """ address = response['billing_address'] address_object = Address() address_object.set_address(address['address']) address_object.set_city(address['city']) address_object.set_state(address['state']) address_object.set_zip(address['zip']) address_object.set_country(address['country']) address_object.set_fax(address['fax']) address_object.set_is_update_customer(address['is_update_customer']) return address_object def get_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 def estimate_template_list(self, response): """This method parses the given response and returns estimate template list object. Args: response(dict): Response containing json object for estimate template list. Returns: instance: Template list object. """ template_list = TemplateList() resp = response['templates'] for value in resp: template = Template() template.set_template_name(value['template_name']) template.set_template_id(value['template_id']) template.set_template_type(value['template_type']) template_list.set_templates(template) return template_list def get_comments(self, response): """This method parses the given response and returns comments list object. Args: response(dict): Response containing json object for comments list. Returns: instance: Comments list object. """ comments = response['comments'] comments_list = CommentList() for value in comments: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_estimate_id(value['estimate_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_comment_type(value['comment_type']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_operation_type(value['operation_type']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments_list.set_comments(comment) return comments_list def get_comment(self, response): """This method parses the given response and returns comments object. Args: response(dict): Response containing json object for comments object. Returns: instance: Comments object. """ comment = response['comment'] comment_object = Comment() comment_object.set_comment_id(comment['comment_id']) comment_object.set_estimate_id(comment['estimate_id']) comment_object.set_description(comment['description']) comment_object.set_commented_by_id(comment['commented_by_id']) comment_object.set_commented_by(comment['commented_by']) comment_object.set_date(comment['date']) comment_object.set_date_description(comment['date_description']) comment_object.set_time(comment['time']) comment_object.set_comment_type(comment['comment_type']) return comment_object
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/EstimatesParser.py
EstimatesParser.py
from books.model.Bill import Bill from books.model.BillList import BillList from books.model.LineItem import LineItem from books.model.Address import Address from books.model.Tax import Tax from books.model.BillPayment import BillPayment from books.model.PageContext import PageContext from books.model.Comment import Comment from books.model.CommentList import CommentList class BillsParser: """This class is used to parse the json for Bills""" def get_list(self, resp): """This method parses the given response and returns bill list object. Args: resp(dict): Response containing json object for bill list. Returns: instance: Bill list object. """ bill_list = BillList() for value in resp['bills']: bill = Bill() bill.set_bill_id(value['bill_id']) bill.set_vendor_id(value['vendor_id']) bill.set_vendor_name(value['vendor_name']) bill.set_status(value['status']) bill.set_bill_number(value['bill_number']) bill.set_reference_number(value['reference_number']) bill.set_date(value['date']) bill.set_due_date(value['due_date']) bill.set_due_days(value['due_days']) bill.set_currency_id(value['currency_id']) bill.set_currency_code(value['currency_code']) bill.set_total(value['total']) bill.set_balance(value['balance']) bill.set_created_time(value['created_time']) bill_list.set_bills(bill) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) bill_list.set_page_context(page_context_obj) return bill_list 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_message(self, resp): """This method parses the given response and returns string message. Args: resp(dict): Response containing json object for success message. Returns: str: Success message. """ return resp['message'] def get_payments_list(self, resp): """This method parses the given response and returns payments list object. Args: resp(dict): Response containing json object for payments list. Returns: list of instance: List of payments object. """ payments = [] for value in resp['payments']: payment = BillPayment() payment.set_payment_id(value['payment_id']) payment.set_bill_id(value['bill_id']) payment.set_bill_payment_id(value['bill_payment_id']) payment.set_vendor_id(value['vendor_id']) payment.set_vendor_name(value['vendor_name']) payment.set_payment_mode(value['payment_mode']) payment.set_description(value['description']) payment.set_date(value['date']) payment.set_reference_number(value['reference_number']) payment.set_exchange_rate(value['exchange_rate']) payment.set_amount(value['amount']) payment.set_paid_through(value['paid_through']) payment.set_is_single_bill_payment(value['is_single_bill_payment']) payments.append(payment) return payments def get_comments(self, resp): comments = CommentList() for value in resp['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_bill_id(value['bill_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_comment_type(value['comment_type']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_operation_type(value['operation_type']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments.set_comments(comment) return comments def get_comment(self, resp): comment = resp['comment'] comment_obj = Comment() comment_obj.set_comment_id(comment['comment_id']) comment_obj.set_bill_id(comment['bill_id']) comment_obj.set_description(comment['description']) comment_obj.set_commented_by_id(comment['commented_by_id']) comment_obj.set_commented_by(comment['commented_by']) comment_obj.set_comment_type(comment['comment_type']) comment_obj.set_date(comment['date']) comment_obj.set_date_description(comment['date_description']) comment_obj.set_time(comment['time']) comment_obj.set_comment_type(comment['comment_type']) return comment_obj
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/BillsParser.py
BillsParser.py
from books.model.Journal import Journal from books.model.JournalList import JournalList from books.model.PageContext import PageContext from books.model.LineItem import LineItem class JournalsParser: """This class is used to parse the given json for Jornals.""" def get_list(self, resp): """This method parses the given response for journals list. Args: journals(dict): Response containing json object for journals list. Returns: instance: Journals list object. """ journals_list = JournalList() for value in resp['journals']: journal = Journal() journal.set_journal_id(value['journal_id']) journal.set_journal_date(value['journal_date']) journal.set_entry_number(value['entry_number']) journal.set_reference_number(value['reference_number']) journal.set_notes(value['notes']) journal.set_total(value['total']) journals_list.set_journals(journal) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) if 'from_date' in page_context: page_context_obj.set_from_date(page_context['from_date']) if 'to_date' in page_context: page_context_obj.set_to_date(page_context['to_date']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) journals_list.set_page_context(page_context_obj) return journals_list def get_journal(self, resp): """This method parses the given response and returns journals object. Args: resp(dict): Response containing json object for journal. Returns: instance: Journal object. """ journal = resp['journal'] journal_obj = Journal() journal_obj.set_journal_id(journal['journal_id']) journal_obj.set_entry_number(journal['entry_number']) journal_obj.set_reference_number(journal['reference_number']) journal_obj.set_notes(journal['notes']) journal_obj.set_currency_id(journal['currency_id']) journal_obj.set_currency_symbol(journal['currency_symbol']) journal_obj.set_journal_date(journal['journal_date']) for value in journal['line_items']: line_item = LineItem() line_item.set_line_id(value['line_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_debit_or_credit(value['debit_or_credit']) 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_amount(value['amount']) journal_obj.set_line_items(line_item) journal_obj.set_line_item_total(journal['line_item_total']) journal_obj.set_total(journal['total']) journal_obj.set_price_precision(journal['price_precision']) journal_obj.set_created_time(journal['created_time']) journal_obj.set_last_modified_time(journal['last_modified_time']) for value in journal['taxes']: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) journal_obj.set_taxes(tax) return journal_obj def get_message(self, resp): """This method parses the given response and returns string message. Args: resp(dict): Response containing json object for message. Returns: str: Success message. """ return resp['message']
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/JournalsParser.py
JournalsParser.py
from books.model.Transaction import Transaction from books.model.TransactionList import TransactionList from books.model.PageContext import PageContext from books.model.Instrumentation import Instrumentation from books.model.SearchCriteria import SearchCriteria class BankTransactionsParser: """This class is used to parse the json response for Bank transactions.""" def get_list(self, resp): """This method parses the given response and returns bank transaction list. Args: resp(dict): Response containing json object for Bank transaction list. Returns: instance: Bank transaction list object. """ bank_transaction_list = TransactionList() for value in resp['banktransactions']: bank_transaction = Transaction() bank_transaction.set_transaction_id(value['transaction_id']) bank_transaction.set_date(value['date']) bank_transaction.set_amount(value['amount']) bank_transaction.set_transaction_type(value['transaction_type']) bank_transaction.set_status(value['status']) bank_transaction.set_source(value['source']) bank_transaction.set_account_id(value['account_id']) bank_transaction.set_customer_id(value['customer_id']) bank_transaction.set_payee(value['payee']) bank_transaction.set_currency_id(value['currency_id']) bank_transaction.set_currency_code(value['currency_code']) bank_transaction.set_debit_or_credit(value['debit_or_credit']) bank_transaction.set_offset_account_name(value['offset_account_name']) bank_transaction.set_reference_number(value['reference_number']) bank_transaction.set_imported_transaction_id(value[\ 'imported_transaction_id']) bank_transaction_list.set_transactions(bank_transaction) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) bank_transaction_list.set_page_context(page_context_obj) return bank_transaction_list def get_transaction(self, resp): """This method parses the given response and returns Bank Transaction object. Args: resp(dict): Response containing json object for Bank transaction. Returns: instance: Bank transaction object. """ transactions = Transaction() bank_transaction = resp['banktransaction'] transactions.set_transaction_id(bank_transaction['transaction_id']) transactions.set_from_account_id(bank_transaction['from_account_id']) transactions.set_from_account_name(bank_transaction[\ 'from_account_name']) transactions.set_to_account_id(bank_transaction['to_account_id']) transactions.set_to_account_name(bank_transaction['to_account_name']) transactions.set_transaction_type(bank_transaction['transaction_type']) transactions.set_currency_id(bank_transaction['transaction_type']) transactions.set_currency_code(bank_transaction['currency_code']) transactions.set_amount(bank_transaction['amount']) transactions.set_exchange_rate(bank_transaction['exchange_rate']) transactions.set_date(bank_transaction['date']) transactions.set_reference_number(bank_transaction['reference_number']) transactions.set_description(bank_transaction['description']) transactions.set_imported_transaction(bank_transaction[\ 'imported_transactions']) return transactions def get_message(self, resp): """This method parses the given response and returns message. Args: resp(dict): Response containing json object for message. Returns: str: Success message('The transaction hasbeen deleted.'). """ return resp['message'] def get_matching_transaction(self, resp): """This method parses the given response and returns matching transactions list. Args: resp(dict): Response containing json object for matching transactions. Returns: instance: Transaction list object. """ transaction_list = TransactionList() for value in resp['matching_transactions']: transaction = Transaction() transaction.set_transaction_id(value['transaction_id']) transaction.set_date(value['date']) transaction.set_date_formatted(value['date_formatted'] if 'date_formatted' in value else None) transaction.set_transaction_type(value['transaction_type']) transaction.set_transaction_type_formatted(value[\ 'transaction_type_formatted'] if 'transaction_type_formatted' in value else None) transaction.set_reference_number(value['reference_number']) transaction.set_amount(value['amount']) transaction.set_amount_formatted(value['amount_formatted'] if 'amount_formatted' in value else None) transaction.set_debit_or_credit(value['debit_or_credit']) transaction.is_best_match = value['is_best_match'] if 'is_best_match' in value else None transaction.offset_account_name = value['offset_account_name'] if 'offset_account_name' in value else None transaction_list.set_transactions(transaction) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) for value in page_context['search_criteria']: criteria = SearchCriteria() criteria.set_column_name(value['column_name']) if value['comparator'] != 'range': criteria.set_search_text(value['search_text']) else: criteria.set_search_text('{} -- {}'.format(value['search_text_0'], value['search_text_0'])) criteria.set_comparator(value['comparator']) page_context_obj.set_search_criteria(criteria) transaction_list.set_page_context(page_context_obj) '''instrumentation_obj = Instrumentation() instrumentation = resp['instrumentation'] instrumentation_obj.set_query_execution_time(instrumentation[\ 'query_execution_time']) instrumentation_obj.set_request_handling_time(instrumentation[\ 'request_handling_time']) instrumentation_obj.set_response_write_time(instrumentation[\ 'response_write_time']) instrumentation_obj.set_page_context_write_time(instrumentation[\ 'page_context_write_time']) transaction_list.set_instrumentation(instrumentation_obj)''' return transaction_list def get_associated_transaction(self, resp): """This method parses the given response and returns associated transactions list. Args: resp(dict): Response containing json object for associated transactions. Returns: instance: Transaction object. """ transaction = resp['transaction'] transaction_obj = Transaction() transaction_obj.set_imported_transaction_id(transaction[\ 'imported_transaction_id']) transaction_obj.set_date(transaction['date']) transaction_obj.set_amount(transaction['amount']) transaction_obj.set_payee(transaction['payee']) transaction_obj.set_reference_number(transaction['reference_number']) transaction_obj.set_description(transaction['description']) transaction_obj.set_status(transaction['status']) transaction_obj.set_status_formatted(transaction['status_formatted']) for value in transaction['associated_transactions']: transaction = Transaction() transaction.set_transaction_id(value['transaction_id']) transaction.set_date(value['date']) transaction.set_debit_or_credit(value['debit_or_credit']) transaction.set_transaction_type(value['transaction_type']) transaction.set_amount(value['amount']) transaction.set_customer_id(value['customer_id']) transaction.set_customer_name(value['customer_name']) transaction_obj.set_associated_transaction(transaction) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) '''instrumentation_obj = Instrumentation() instrumentation = resp['instrumentation'] instrumentation_obj.set_query_execution_time(instrumentation[\ 'query_execution_time']) instrumentation_obj.set_request_handling_time(instrumentation[\ 'request_handling_time']) instrumentation_obj.set_response_write_time(instrumentation[\ 'response_write_time']) instrumentation_obj.set_page_context_write_time(instrumentation[\ 'page_context_write_time']) transaction_obj.set_instrumentation(instrumentation_obj)''' return transaction_obj
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/BankTransactionsParser.py
BankTransactionsParser.py
from books.model.BankRule import BankRule from books.model.BankRuleList import BankRuleList from books.model.Criteria import Criteria class BankRulesParser: """This class is used to parse the json response for Bank rules.""" def get_rules(self, resp): """This method parses the given response and returns list of bank rules object. Args: resp(dict): Dictionary containing json object for bank rules. Returns: list of instance: List of Bank rules object. """ bank_rules = BankRuleList() for value in resp['rules']: bank_rule = BankRule() bank_rule.set_rule_id(value['rule_id']) bank_rule.set_rule_name(value['rule_name']) bank_rule.set_rule_order(value['rule_order']) bank_rule.set_apply_to(value['apply_to']) bank_rule.set_criteria_type(value['criteria_type']) bank_rule.set_record_as(value['record_as']) bank_rule.set_account_id(value['account_id']) bank_rule.set_account_name(value['account_name']) for criteria_value in value['criterion']: criteria = Criteria() criteria.set_criteria_id(criteria_value['criteria_id']) criteria.set_field(criteria_value['field']) criteria.set_comparator(criteria_value['comparator']) criteria.set_value(criteria_value['value']) bank_rule.set_criterion(criteria) bank_rules.set_bank_rules(bank_rule) return bank_rules def get_rule(self, resp): """This method parses the given response and returns bank rule object. Args: resp(dict): Dictionary containing json object for bank rules. Returns: instance: Bank rules object. """ bank_rule = BankRule() rule = resp['rule'] bank_rule.set_rule_id(rule['rule_id']) bank_rule.set_rule_name(rule['rule_name']) bank_rule.set_rule_order(rule['rule_order']) bank_rule.set_apply_to(rule['apply_to']) bank_rule.set_criteria_type(rule['criteria_type']) bank_rule.set_record_as(rule['record_as']) for value in rule['criterion']: criteria = Criteria() criteria.set_criteria_id(value['criteria_id']) criteria.set_field(value['field']) criteria.set_comparator(value['comparator']) criteria.set_value(value['value']) bank_rule.set_criterion(criteria) bank_rule.set_account_id(rule['account_id']) bank_rule.set_account_name(rule['account_name']) bank_rule.set_tax_id(rule['tax_id']) bank_rule.set_customer_id(rule['customer_id']) bank_rule.set_customer_name(rule['customer_name']) bank_rule.set_reference_number(rule['reference_number']) return bank_rule def get_message(self, resp): """This method parses the given response and returns message string. Args: resp(dict): Dictionary containing json object for message. Returns: str: Success message. """ return resp['message']
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/BankRulesParser.py
BankRulesParser.py
from books.model.Invoice import Invoice from books.model.PageContext import PageContext from books.model.InvoiceList import InvoiceList from books.model.LineItem import LineItem from books.model.Tax import Tax from books.model.CustomField import CustomField from books.model.Address import Address from books.model.PaymentGateway import PaymentGateway from books.model.Email import Email from books.model.FromEmail import FromEmail from books.model.ToContact import ToContact from books.model.EmailTemplate import EmailTemplate from books.model.Template import Template from books.model.InvoicePayment import InvoicePayment from books.model.InvoiceCredited import InvoiceCredited from books.model.InvoiceCreditedList import InvoiceCreditedList from books.model.Comment import Comment from books.model.PaymentAndCredit import PaymentAndCredit from books.model.CommentList import CommentList from books.model.PaymentList import PaymentList from books.model.TemplateList import TemplateList class InvoicesParser: """This class is used to parse the json for Invoices.""" def get_list(self,response): """This method parses the given resonse and creates invoice list object. Args: response(dict): Response containing json object for invoice list. Returns: instance: Invoice list object. """ invoice = response['invoices'] invoice_list = InvoiceList() for value in invoice: invoice_object = Invoice() invoice_object.set_invoice_id(value['invoice_id']) invoice_object.set_customer_name(value['customer_name']) invoice_object.set_customer_id(value['customer_id']) invoice_object.set_status(value['status']) invoice_object.set_invoice_number(value['invoice_number']) invoice_object.set_reference_number(value['reference_number']) invoice_object.set_date(value['date']) invoice_object.set_due_date(value['due_date']) invoice_object.set_due_days(value['due_days']) invoice_object.set_currency_id(value['currency_id']) invoice_object.set_currency_code(value['currency_code']) invoice_object.set_total(value['total']) invoice_object.set_balance(value['balance']) invoice_object.set_created_time(value['created_time']) invoice_object.set_is_emailed(value['is_emailed']) invoice_object.set_reminders_sent(value['reminders_sent']) invoice_object.set_payment_expected_date(value[\ 'payment_expected_date']) invoice_object.set_last_payment_date(value['last_payment_date']) invoice_list.set_invoices(invoice_object) page_context_object = PageContext() page_context = response['page_context'] page_context_object.set_page(page_context['page']) page_context_object.set_per_page(page_context['per_page']) page_context_object.set_has_more_page(page_context['has_more_page']) page_context_object.set_report_name(page_context['report_name']) page_context_object.set_applied_filter(page_context['applied_filter']) page_context_object.set_sort_column(page_context['sort_column']) page_context_object.set_sort_order(page_context['sort_order']) invoice_list.set_page_context(page_context_object) return invoice_list def get(self,response): """This method parses the given response and returns Invoice object. Args: response(dict): Request containing json obect for invoices. Returns: instance: Invoice object. """ invoice = response['invoice'] invoice_object = Invoice() invoice_object.set_invoice_id(invoice['invoice_id']) invoice_object.set_invoice_number(invoice['invoice_number']) invoice_object.set_date(invoice['date']) invoice_object.set_status(invoice['status']) invoice_object.set_payment_terms(invoice['payment_terms']) invoice_object.set_payment_terms_label(invoice['payment_terms_label']) invoice_object.set_due_date(invoice['due_date']) invoice_object.set_payment_expected_date(invoice[\ 'payment_expected_date']) invoice_object.set_last_payment_date(invoice['last_payment_date']) invoice_object.set_reference_number(invoice['reference_number']) invoice_object.set_customer_id(invoice['customer_id']) invoice_object.set_customer_name(invoice['customer_name']) invoice_object.set_contact_persons(invoice['contact_persons_details']) invoice_object.set_currency_id(invoice['currency_id']) invoice_object.set_currency_code(invoice['currency_code']) invoice_object.set_exchange_rate(invoice['exchange_rate']) invoice_object.set_discount(invoice['discount']) invoice_object.gst_no = invoice['gst_no'] invoice_object.set_is_discount_before_tax(invoice[\ 'is_discount_before_tax']) invoice_object.set_discount_type(invoice['discount_type']) invoice_object.set_recurring_invoice_id(invoice[\ 'recurring_invoice_id']) line_items = invoice['line_items'] for value in line_items: line_item = LineItem() line_item.set_line_item_id(value['line_item_id']) line_item.set_item_id(value['item_id']) line_item.set_project_id(value['project_id']) line_item.set_time_entry_ids(value['time_entry_ids']) line_item.set_expense_id(value['expense_id']) line_item.set_expense_receipt_name(value['expense_receipt_name']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_bcy_rate(value['bcy_rate']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_discount(value['discount']) line_item.set_tax_id(value['tax_id']) line_item.set_tax_name(value['tax_name']) line_item.set_tax_type(value['tax_type']) line_item.set_tax_percentage(value['tax_percentage']) line_item.set_hsn_or_sac(value['hsn_or_sac']) line_item.set_item_total(value['item_total']) invoice_object.set_line_items(line_item) invoice_object.set_shipping_charge(invoice['shipping_charge']) invoice_object.set_adjustment(invoice['adjustment']) invoice_object.set_adjustment_description(invoice[\ 'adjustment_description']) invoice_object.set_sub_total(invoice['sub_total']) invoice_object.set_tax_total(invoice['tax_total']) invoice_object.set_total(invoice['total']) taxes = invoice['taxes'] for value in taxes: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount(value['tax_amount']) invoice_object.set_taxes(tax) invoice_object.set_payment_reminder_enabled(invoice[\ 'payment_reminder_enabled']) invoice_object.set_payment_made(invoice['payment_made']) invoice_object.set_credits_applied(invoice['credits_applied']) invoice_object.set_tax_amount_withheld(invoice['tax_amount_withheld']) invoice_object.set_balance(invoice['balance']) invoice_object.set_write_off_amount(invoice['write_off_amount']) invoice_object.set_allow_partial_payments(invoice[\ 'allow_partial_payments']) invoice_object.set_price_precision(invoice['price_precision']) payment_gateways = invoice['payment_options']['payment_gateways'] for value in payment_gateways: payment_gateway = PaymentGateway() payment_gateway.set_configured(value['configured']) payment_gateway.set_additional_field1(value['additional_field1']) payment_gateway.set_gateway_name(value['gateway_name']) invoice_object.set_payment_options(payment_gateway) invoice_object.set_is_emailed(invoice['is_emailed']) invoice_object.set_reminders_sent(invoice['reminders_sent']) invoice_object.set_last_reminder_sent_date(invoice[\ 'last_reminder_sent_date']) billing_address = invoice['billing_address'] billing_address_object = Address() billing_address_object.set_address(billing_address['address']) billing_address_object.set_city(billing_address['city']) billing_address_object.set_state(billing_address['state']) billing_address_object.set_zip(billing_address['zip']) billing_address_object.set_country(billing_address['country']) billing_address_object.set_fax(billing_address['fax']) invoice_object.set_billing_address(billing_address_object) shipping_address = invoice['shipping_address'] shipping_address_object = Address() shipping_address_object.set_address(shipping_address['address']) shipping_address_object.set_city(shipping_address['city']) shipping_address_object.set_state(shipping_address['state']) shipping_address_object.set_zip(shipping_address['zip']) shipping_address_object.set_country(shipping_address['country']) shipping_address_object.set_fax(shipping_address['fax']) invoice_object.set_shipping_address(shipping_address_object) invoice_object.set_notes(invoice['notes']) invoice_object.set_terms(invoice['terms']) custom_fields = invoice['custom_fields'] for value in custom_fields: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_show_on_pdf(value['show_on_pdf']) custom_field.set_value(value['value']) custom_field.set_label(value['label']) invoice_object.set_custom_fields(custom_field) invoice_object.set_template_id(invoice['template_id']) invoice_object.set_template_name(invoice['template_name']) invoice_object.set_created_time(invoice['created_time']) invoice_object.set_last_modified_time(invoice['last_modified_time']) invoice_object.set_attachment_name(invoice['attachment_name']) invoice_object.set_can_send_in_mail(invoice['can_send_in_mail']) invoice_object.set_salesperson_id(invoice['salesperson_id']) invoice_object.set_salesperson_name(invoice['salesperson_name']) return invoice_object def get_message(self,response): """This message parses the given response and returns string. Args: response(dict): Request containing json object. Returns: str: Success message. """ return response['message'] def get_content(self,response): """This message parses the given response and returns email object. Args: response(dict): Request containing json object for email content. Returns: instance: Email object. """ data = response['data'] email = Email() email.set_gateways_configured(data['gateways_configured']) email.set_deprecated_placeholders_used(data[\ 'deprecated_placeholders_used']) email.set_body(data['body']) email.set_error_list(data['error_list']) email.set_subject(data['subject']) for value in data['emailtemplates']: email_template = EmailTemplate() email_template.set_selected(value['selected']) email_template.set_name(value['name']) email_template.set_email_template_id(value['email_template_id']) email.set_email_templates(email_template) for value in data['to_contacts']: to_contact = ToContact() to_contact.set_first_name(value['first_name']) to_contact.set_selected(value['selected']) to_contact.set_phone(value['phone']) to_contact.set_email(value['email']) to_contact.set_contact_person_id(value['contact_person_id']) to_contact.set_last_name(value['last_name']) to_contact.set_salutation(value['salutation']) to_contact.set_mobile(value['mobile']) email.set_to_contacts(to_contact) email.set_attachment_name(data['attachment_name']) email.set_file_name(data['file_name']) for value in data['from_emails']: from_email = FromEmail() from_email.set_user_name(value['user_name']) from_email.set_selected(value['selected']) from_email.set_email(value['email']) email.set_from_emails(from_email) email.set_customer_id(data['customer_id']) return email def payment_reminder_mail_content(self,response): """This method parses the given response and returns the email object. Args: response(dict): Response containing json object for email content. Returns: instance: Email object. """ data = response['data'] email = Email() email.set_body(data['body']) email.set_gateways_associated(data['gateways_associated']) email.set_error_list(data['error_list']) email.set_subject(data['subject']) email.set_attach_pdf(data['attach_pdf']) email.set_file_name(data['file_name']) for value in data['from_emails']: from_email = FromEmail() from_email.set_user_name(value['user_name']) from_email.set_selected(value['selected']) from_email.set_email(value['email']) from_email.set_is_org_email_id(value['is_org_email_id']) email.set_from_emails(from_email) email.set_file_name_without_extension(data[\ 'file_name_without_extension']) email.set_deprecated_placeholders_used(data[\ 'deprecated_placeholders_used']) email.set_gateways_configured(data['gateways_configured']) for value in data['to_contacts']: to_contact = ToContact() to_contact.set_first_name(value['first_name']) to_contact.set_selected(value['selected']) to_contact.set_phone(value['phone']) to_contact.set_email(value['email']) to_contact.set_last_name(value['last_name']) to_contact.set_salutation(value['salutation']) to_contact.set_contact_person_id(value['contact_person_id']) to_contact.set_mobile(value['mobile']) email.set_to_contacts(to_contact) email.set_attachment_name(data['attachment_name']) email.set_customer_id(data['customer_id']) return email def get_billing_address(self,response): """This method parses the given response and returns address object for billing address. Args: response(dict): Resonse containing json object for billing address. Returns: instance: Address object for billing address. """ address = response['billing_address'] address_object = Address() address_object.set_address(address['address']) address_object.set_city(address['city']) address_object.set_state(address['state']) address_object.set_zip(address['zip']) address_object.set_country(address['country']) address_object.set_fax(address['fax']) address_object.set_is_update_customer(address['is_update_customer']) return address_object def get_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 invoice_template_list(self,response): """This method parses the given response and returns list of templates object. Args: response(dict): Response containing json object for templates list. Returns: list of instances: list of templates object. """ templates = TemplateList() for value in response['templates']: template = Template() template.set_template_name(value['template_name']) template.set_template_id(value['template_id']) template.set_template_type(value['template_type']) templates.set_templates(template) return templates def payments_list(self,response): """This method parses the given response and returns list of invoice payments. Args: response(dict): Response containing json object for invoice payments list. Returns: lsit of instances: List of invoice payments object. """ payments = PaymentList() for value in response['payments']: payment = InvoicePayment() payment.set_payment_id(value['payment_id']) payment.set_payment_number(value['payment_number']) payment.set_invoice_id(value['invoice_id']) payment.set_invoice_payment_id(value['invoice_payment_id']) payment.set_payment_mode(value['payment_mode']) payment.set_description(value['description']) payment.set_date(value['date']) payment.set_reference_number(value['reference_number']) payment.set_exchange_rate(value['exchange_rate']) payment.set_amount(value['amount']) payment.set_tax_amount_withheld(value['tax_amount_withheld']) payment.set_is_single_invoice_payment(value[\ 'is_single_invoice_payment']) payments.set_payments(payment) return payments def credits_list(self,response): """This method parses the given repsonse and returns list of credits. Args: response(dict): Response containing json object for credits. Returns: instance: Invoice credited list object. """ credits = InvoiceCreditedList() for value in response['credits']: credit = InvoiceCredited() credit.set_creditnote_id(value['creditnote_id']) credit.set_creditnotes_invoice_id(value['creditnotes_invoice_id']) credit.set_credited_date(value['credited_date']) credit.set_amount_applied(value['amount_applied']) credits.set_invoices_credited(credit) return credits def apply_credits(self,response): """This method parses the given response and returns Payments and credits object. Args: response(dict): Response containing json object for apply credits. Returns: instance: Payments and credits object. """ use_credits = response['use_credits'] payments_and_credits = PaymentAndCredit() for value in use_credits['invoice_payments']: invoice_payments = InvoicePayment() invoice_payments.set_invoice_payment_id(value[\ 'invoice_payment_id']) invoice_payments.set_payment_id(value['payment_id']) invoice_payments.set_invoice_id(value['invoice_id']) invoice_payments.set_amount_used(value['amount_used']) payments_and_credits.set_payments(invoice_payments) for value in use_credits['apply_creditnotes']: credits = InvoiceCredited() credits.set_creditnotes_invoice_id(value['creditnotes_invoice_id']) credits.set_creditnote_id(value['creditnote_id']) credits.set_invoice_id(value['invoice_id']) credits.set_amount_applied(value['amount_applied']) payments_and_credits.set_apply_creditnotes(credits) return payments_and_credits def comments_list(self,response): """This method parses the given response and returns list of comments. Args: response(dict): Response containing json object for comments list. Returns: instance: Comments list object. """ comments = CommentList() for value in response['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_invoice_id(value['invoice_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_comment_type(value['comment_type']) comment.set_operation_type(value['operation_type']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments.set_comments(comment) return comments def get_comment(self,response): """This method parses the given response and returns comments object. Args: response(dict): Response containing json object for comments. Returns: instance: Comments object. """ comment = response['comment'] comment_obj = Comment() comment_obj.set_comment_id(comment['comment_id']) comment_obj.set_invoice_id(comment['invoice_id']) comment_obj.set_description(comment['description']) comment_obj.set_commented_by_id(comment['commented_by_id']) comment_obj.set_commented_by(comment['commented_by']) comment_obj.set_date(comment['date']) comment_obj.set_date_description(comment['date_description']) comment_obj.set_time(comment['time']) comment_obj.set_comment_type(comment['comment_type']) return comment_obj
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/InvoicesParser.py
InvoicesParser.py
from books.model.VendorPayment import VendorPayment from books.model.VendorPaymentList import VendorPaymentList from books.model.Bill import Bill class VendorPaymentsParser: """This class is used to parse the json response for Vendor payments.""" def get_list(self, resp): """This method parses the given response and returns vendor payments list object. Args: resp(dict): Dictionary containing json object for vendor payments list. Returns: instance: Vendor payments list object. """ vendor_payments_list = VendorPaymentList() for value in resp['vendorpayments']: vendor_payment = VendorPayment() vendor_payment.set_payment_id(value['payment_id']) vendor_payment.set_vendor_id(value['vendor_id']) vendor_payment.set_vendor_name(value['vendor_name']) vendor_payment.set_payment_mode(value['payment_mode']) vendor_payment.set_description(value['description']) vendor_payment.set_date(value['date']) vendor_payment.set_reference_number(value['reference_number']) vendor_payment.set_exchange_rate(value['exchange_rate']) vendor_payment.set_amount(value['amount']) vendor_payment.set_paid_through_account_id(value[\ 'paid_through_account_id']) vendor_payment.set_paid_through_account_name(value[\ 'paid_through_account_name']) vendor_payment.set_balance(value['balance']) vendor_payments_list.set_vendor_payments(vendor_payment) return vendor_payments_list def get_vendor_payment(self, resp): """This method is used to parse the given response and returns vendor payments object. Args: resp(dict): Dictionary containing json object for vendor payments. Returns: instance: Vendor payments object. """ vendor_payment_obj = VendorPayment() vendor_payment = resp['vendorpayment'] vendor_payment_obj.set_payment_id(vendor_payment['payment_id']) vendor_payment_obj.set_vendor_id(vendor_payment['vendor_id']) vendor_payment_obj.set_vendor_name(vendor_payment['vendor_name']) vendor_payment_obj.set_payment_mode(vendor_payment['payment_mode']) vendor_payment_obj.set_description(vendor_payment['description']) vendor_payment_obj.set_date(vendor_payment['date']) vendor_payment_obj.set_reference_number(vendor_payment[\ 'reference_number']) vendor_payment_obj.set_exchange_rate(vendor_payment['exchange_rate']) vendor_payment_obj.set_amount(vendor_payment['amount']) vendor_payment_obj.set_currency_symbol(vendor_payment[\ 'currency_symbol']) vendor_payment_obj.set_paid_through_account_id(vendor_payment[\ 'paid_through_account_id']) vendor_payment_obj.set_paid_through_account_name(vendor_payment[\ 'paid_through_account_name']) for value in vendor_payment['bills']: bill = Bill() bill.set_bill_number(value['bill_number']) bill.set_bill_payment_id(value['bill_payment_id']) bill.set_bill_id(value['bill_id']) bill.set_total(value['total']) bill.set_balance(value['balance']) bill.set_amount_applied(value['amount_applied']) bill.set_date(value['date']) bill.set_due_date(value['due_date']) vendor_payment_obj.set_bills(bill) return vendor_payment_obj def get_message(self, resp): """This message parses the given response and returns message string. Args: resp(dict): Response containing json object for message. Returns: str: Success message. """ return resp['message']
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/VendorPaymentsParser.py
VendorPaymentsParser.py
from books.model.PreferenceList import PreferenceList from books.model.Preference import Preference from books.model.CustomField import CustomField from books.model.PlaceholderAddressFormat import PlaceholderAddressFormat from books.model.Autoreminder import Autoreminder from books.model.AutoReminderList import AutoReminderList from books.model.Term import Term from books.model.AddressFormat import AddressFormat from books.model.Invoice import Invoice from books.model.Estimate import Estimate from books.model.Contact import Contact from books.model.Organization import Organization from books.model.Customer import Customer from books.model.Organization import Organization from books.model.Address import Address from books.model.UserList import UserList from books.model.User import User from books.model.EmailId import EmailId from books.model.PageContext import PageContext from books.model.Item import Item from books.model.ItemList import ItemList from books.model.InvoiceSetting import InvoiceSetting from books.model.NotesAndTerms import NotesAndTerms from books.model.EstimateSetting import EstimateSetting from books.model.CreditnoteSetting import CreditnoteSetting from books.model.CurrencyList import CurrencyList from books.model.Currency import Currency from books.model.ExchangeRate import ExchangeRate from books.model.ExchangeRateList import ExchangeRateList from books.model.TaxList import TaxList from books.model.Tax import Tax from books.model.TaxGroup import TaxGroup from books.model.OpeningBalance import OpeningBalance from books.model.Account import Account from books.model.PlaceHolder import PlaceHolder from books.model.ManualReminder import ManualReminder from books.model.ManualReminderList import ManualReminderList class SettingsParser: """This class is used to parse the json for Settings.""" def preference_list(self, resp): """This method parses the given response and returns preferneces object. Args: resp(dict): Response containing json obejct for preferences. Returns: instance: Prefenreces object. Raises: Books Exception: If status is not '200' or '201'. """ preferences = resp['preferences'] preferences_list = PreferenceList() preference_obj = Preference() preference_obj.set_convert_to_invoice(preferences[\ 'convert_to_invoice']) preference_obj.set_attach_pdf_for_email(preferences[\ 'attach_pdf_for_email']) preference_obj.set_estimate_approval_status(preferences[\ 'estimate_approval_status']) preference_obj.set_notify_me_on_online_payment(preferences[\ 'notify_me_on_online_payment']) preference_obj.set_send_payment_receipt_acknowledgement(preferences[\ 'send_payment_receipt_acknowledgement']) preference_obj.set_auto_notify_recurring_invoice(preferences[\ 'auto_notify_recurring_invoice']) preference_obj.set_snail_mail_include_payment_stub(preferences[\ 'snail_mail_include_payment_stub']) preference_obj.set_is_show_powered_by(preferences['is_show_powered_by']) preference_obj.set_attach_expense_receipt_to_invoice(preferences[\ 'attach_expense_receipt_to_invoice']) preference_obj.set_is_estimate_enabled(preferences[\ 'is_estimate_enabled']) preference_obj.set_is_project_enabled(preferences['is_project_enabled']) preference_obj.set_is_purchaseorder_enabled(preferences[\ 'is_purchaseorder_enabled']) preference_obj.set_is_salesorder_enabled(preferences[\ 'is_salesorder_enabled']) preference_obj.set_is_pricebooks_enabled(preferences[\ 'is_pricebooks_enabled']) preference_obj.set_attach_payment_receipt_with_acknowledgement(\ preferences['attach_payment_receipt_with_acknowledgement']) for value in preferences['auto_reminders']: auto_reminder = Autoreminder() auto_reminder.set_payment_reminder_id(value['payment_reminder_id']) auto_reminder.set_is_enabled(value['is_enabled']) auto_reminder.set_notification_type(value['notification_type']) auto_reminder.set_address_type(value['address_type']) auto_reminder.set_number_of_days(value['number_of_days']) auto_reminder.set_subject(value['subject']) auto_reminder.set_body(value['body']) preference_obj.set_auto_reminders(auto_reminder) terms = preferences['terms'] terms_obj = Term() terms_obj.set_invoice_terms(terms['invoice_terms']) terms_obj.set_estimate_terms(terms['estimate_terms']) terms_obj.set_creditnote_terms(terms['creditnote_terms']) preference_obj.set_terms(terms_obj) address_formats_obj = AddressFormat() address_formats = preferences['address_formats'] address_formats_obj.set_organization_address_format(address_formats[\ 'organization_address_format']) address_formats_obj.set_customer_address_format(address_formats[\ 'customer_address_format']) preference_obj.set_address_formats(address_formats_obj) preferences_list.set_preferences(preference_obj) custom_fields = resp['customfields'] custom_fields_obj = CustomField() for value in custom_fields['invoice']: invoice = Invoice() invoice.set_index(value['index']) invoice.set_show_in_all_pdf(value['show_in_all_pdf']) invoice.set_label(value['label']) custom_fields_obj.set_invoice(invoice) for value in custom_fields['contact']: contact = Contact() contact.set_index(value['index']) contact.set_show_in_all_pdf(vlaue['show_in_all_pdf']) contact.set_label(value['label']) custom_fields_obj.set_contact(contact) for value in custom_fields['estimate']: estimate = Estimate() estimate.set_index(value['index']) estimate.set_show_in_all_pdf(value['show_in_all_pdf']) estimate.set_label(value['label']) custom_fields_obj.set_estimate(estimate) preferences_list.set_custom_fields(custom_fields_obj) placeholders_address_format = resp['placeholders_address_format'] placeholders_address_format_obj = PlaceholderAddressFormat() for value in placeholders_address_format['organization']: organization = Organization() organization.set_value(value['value']) organization.set_name(value['name']) placeholders_address_format_obj.set_organization(organization) for value in placeholders_address_format['customer']: customer = Customer() customer.set_name(value['name']) customer.set_value(value['value']) placeholders_address_format_obj.set_customer(customer) preferences_list.set_placeholders_address_format(\ placeholders_address_format_obj) return preferences_list def get_message(self, resp): """This message parses the given response and returns message string. Args: resp(dict): Response containing json object for message. Returns: str: Success message. """ return resp['message'] def get_organizations(self, resp): """This message parses the given response and returns organizations list. Args: resp(dict): Response containing json object for organizations list. Returns: instance: Organizations list object. """ organizations_list = [] for value in resp['organizations']: organization = Organization() organization.set_organization_id(value['organization_id']) organization.set_name(value['name']) organization.set_contact_name(value['contact_name']) organization.set_email(value['email']) organization.set_is_default_org(value['is_default_org']) organization.set_version(value['version']) organization.set_plan_type(value['plan_type']) organization.set_tax_group_enabled(value['tax_group_enabled']) organization.set_plan_name(value['plan_name']) organization.set_plan_period(value['plan_period']) organization.set_language_code(value['language_code']) organization.set_fiscal_year_start_month(value[\ 'fiscal_year_start_month']) organization.set_account_created_date(value[\ 'account_created_date']) organization.set_account_created_date_formatted(value[\ 'account_created_date_formatted']) organization.set_time_zone(value['time_zone']) organization.set_is_org_active(value['is_org_active']) organization.set_currency_id(value['currency_id']) organization.set_currency_code(value['currency_code']) organization.set_currency_symbol(value['currency_symbol']) organization.set_currency_format(value['currency_format']) organization.set_price_precision(value['price_precision']) organizations_list.append(organization) return organizations_list 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 get_users(self, resp): """This method parses the given response and returns USers list object. Args: resp(dict): Response containing json object for users list. Returns: instance: Users list object. """ users_list = UserList() for value in resp['users']: user = User() user.set_user_id(value['user_id']) user.set_role_id(value['role_id']) user.set_name(value['name']) user.set_email(value['email']) user.set_user_role(value['user_role']) user.set_status(value['status']) user.set_is_current_user(value['is_current_user']) user.set_photo_url(value['photo_url']) users_list.set_users(user) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) users_list.set_page_context(page_context_obj) return users_list def get_user(self, resp): """This method parses the given response and returns user object. Args: resp(dict): Response containing json object for user. Returns: instance: User object. Raises: Books Exception: If status is not '200' or '201'. """ user = resp['user'] user_obj = User() user_obj.set_user_id(user['user_id']) user_obj.set_name(user['name']) for value in user['email_ids']: email_id = EmailId() email_id.set_is_selected(value['is_selected']) email_id.set_email(value['email']) user_obj.set_email_ids(email_id) user_obj.set_status(user['status']) user_obj.set_user_role(user['user_role']) user_obj.set_created_time(user['created_time']) user_obj.set_photo_url(user['photo_url']) return user_obj def get_items(self, resp): """This method parses the given response and returns items list object. Args: resp(dict): Response containing json object for items list. Returns: instance: Items list object. """ items_list = ItemList() for value in resp['items']: item = Item() item.set_item_id(value['item_id']) item.set_name(value['name']) item.set_status(value['status']) item.set_description(value['description']) item.set_rate(value['rate']) item.set_tax_id(value['tax_id']) item.set_tax_name(value['tax_name']) item.set_tax_percentage(value['tax_percentage']) for tp in value['item_tax_preferences']: item.set_item_tax_preferences(tp) items_list.set_items(item) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) items_list.set_page_context(page_context_obj) return items_list def get_item(self, resp): """This method parses the given response and returns item object. Args: resp(dict): Response containing json object for item. Returns: instance: Item object. """ item = resp['item'] item_obj = Item() item_obj.set_item_id(item['item_id']) item_obj.set_name(item['name']) item_obj.set_status(item['status']) item_obj.set_description(item['description']) item_obj.set_rate(item['rate']) item_obj.set_unit(item['unit']) item_obj.set_account_id(item['account_id']) item_obj.set_account_name(item['account_name']) item_obj.set_tax_id(item['tax_id']) item_obj.set_tax_name(item['tax_name']) item_obj.set_tax_percentage(item['tax_percentage']) item_obj.set_tax_type(item['tax_type']) return item_obj def get_invoice_settings(self, resp): """This method parses the given response and returns invoice settings object. Args: resp(dict): Response containing json object for invoice settings. Returns: instance: Invoice settings object. """ invoice_settings = resp['invoice_settings'] invoice_settings_obj = InvoiceSetting() invoice_settings_obj.set_auto_generate(invoice_settings[\ 'auto_generate']) invoice_settings_obj.set_prefix_string(invoice_settings[\ 'prefix_string']) invoice_settings_obj.set_start_at(invoice_settings['start_at']) invoice_settings_obj.set_next_number(invoice_settings['next_number']) invoice_settings_obj.set_quantity_precision(invoice_settings[\ 'quantity_precision']) invoice_settings_obj.set_discount_type(invoice_settings[\ 'discount_type']) invoice_settings_obj.set_is_discount_before_tax(invoice_settings[\ 'is_discount_before_tax']) invoice_settings_obj.set_reference_text(invoice_settings[\ 'reference_text']) invoice_settings_obj.set_notes(invoice_settings['notes']) invoice_settings_obj.set_terms(invoice_settings['terms']) invoice_settings_obj.set_is_shipping_charge_required(invoice_settings[\ 'is_shipping_charge_required']) invoice_settings_obj.set_is_adjustment_required(invoice_settings[\ 'is_adjustment_required']) invoice_settings_obj.set_is_open_invoice_editable(invoice_settings[\ 'is_open_invoice_editable']) invoice_settings_obj.set_warn_convert_to_open(invoice_settings[\ 'warn_convert_to_open']) invoice_settings_obj.set_warn_create_creditnotes(invoice_settings[\ 'warn_create_creditnotes']) invoice_settings_obj.set_attach_expense_receipt_to_invoice(\ invoice_settings['attach_expense_receipt_to_invoice']) invoice_settings_obj.set_invoice_item_type(invoice_settings[\ 'invoice_item_type']) invoice_settings_obj.set_is_sales_person_required(invoice_settings[\ 'is_sales_person_required']) return invoice_settings_obj def get_notes_and_terms(self, resp): """This method parses the given response and returns notes and terms object. Args: resp(dict): Dictionary containing json object for estimate settings. Returns: instance: Notes and terms object. """ notes_and_terms = resp['notes_and_terms'] notes_and_terms_obj = NotesAndTerms() notes_and_terms_obj.set_notes(notes_and_terms['notes']) notes_and_terms_obj.set_terms(notes_and_terms['terms']) return notes_and_terms_obj def get_estimate_settings(self, resp): """This method parses the given response and returns estimate settings object. Args: resp: Dictionary containing json object for estimate settings. Returns: instance: Estimate settings object. """ estimate_settings = resp['estimate_settings'] estimate_settings_obj = EstimateSetting() estimate_settings_obj.set_auto_generate(estimate_settings[\ 'auto_generate']) estimate_settings_obj.set_prefix_string(estimate_settings[\ 'prefix_string']) estimate_settings_obj.set_start_at(estimate_settings['start_at']) estimate_settings_obj.set_next_number(estimate_settings['next_number']) estimate_settings_obj.set_quantity_precision(estimate_settings[\ 'quantity_precision']) estimate_settings_obj.set_discount_type(estimate_settings[\ 'discount_type']) estimate_settings_obj.set_is_discount_before_tax(estimate_settings[\ 'is_discount_before_tax']) estimate_settings_obj.set_reference_text(estimate_settings[\ 'reference_text']) estimate_settings_obj.set_notes(estimate_settings['notes']) estimate_settings_obj.set_terms(estimate_settings['terms']) estimate_settings_obj.set_terms_to_invoice(estimate_settings[\ 'terms_to_invoice']) estimate_settings_obj.set_notes_to_invoice(estimate_settings[\ 'notes_to_invoice']) estimate_settings_obj.set_warn_estimate_to_invoice(estimate_settings[\ 'warn_estimate_to_invoice']) estimate_settings_obj.set_is_sales_person_required(estimate_settings[\ 'is_sales_person_required']) return estimate_settings_obj def get_creditnote_settings(self, resp): """This method parses the given response and returns creditnote settings. Args: resp(dict): Dictionary containing json object for creditnote settings. Returns: instance: Creditnotes settings object. """ creditnote_settings_obj = CreditnoteSetting() creditnote_settings = resp['creditnote_settings'] creditnote_settings_obj.set_auto_generate(creditnote_settings[\ 'auto_generate']) creditnote_settings_obj.set_prefix_string(creditnote_settings[\ 'prefix_string']) creditnote_settings_obj.set_reference_text(creditnote_settings[\ 'reference_text']) creditnote_settings_obj.set_next_number(creditnote_settings[\ 'next_number']) creditnote_settings_obj.set_notes(creditnote_settings['notes']) creditnote_settings_obj.set_terms(creditnote_settings['terms']) return creditnote_settings_obj def get_currencies(self, resp): """This method parses the given response and returns currency list object. Args: resp(dict): Response containing json object for list of currencies. Returns: instance: Currency list object. """ currency_list = CurrencyList() for value in resp['currencies']: currency = Currency() currency.set_currency_id(value['currency_id']) currency.set_currency_code(value['currency_code']) currency.set_currency_name(value['currency_name']) currency.set_currency_symbol(value['currency_symbol']) currency.set_price_precision(value['price_precision']) currency.set_currency_format(value['currency_format']) currency.set_is_base_currency(value['is_base_currency']) currency.set_exchange_rate(value['exchange_rate']) currency.set_effective_date(value['effective_date']) currency_list.set_currencies(currency) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) currency_list.set_page_context(page_context_obj) return currency_list def get_currency(self, resp): """This method parses the given response and returns currency object. Args: resp(dict): Response containing json object for currency. Returns: instance: Currency object. """ currency_obj = Currency() currency = resp['currency'] currency_obj.set_currency_id(currency['currency_id']) currency_obj.set_currency_code(currency['currency_code']) currency_obj.set_currency_name(currency['currency_name']) currency_obj.set_currency_symbol(currency['currency_symbol']) currency_obj.set_price_precision(currency['price_precision']) currency_obj.set_currency_format(currency['currency_format']) currency_obj.set_is_base_currency(currency['is_base_currency']) return currency_obj def get_exchange_rates(self, resp): """This method parses the given response and returns exchange rates list. Args: resp(dict): Response containing json object for exchange rate. Returns: list of instance: List of exchange rates object. """ exchange_rates = ExchangeRateList() for value in resp['exchange_rates']: exchange_rate = ExchangeRate() exchange_rate.set_exchange_rate_id(value['exchange_rate_id']) exchange_rate.set_currency_id(value['currency_id']) exchange_rate.set_currency_code(value['currency_code']) exchange_rate.set_effective_date(value['effective_date']) exchange_rate.set_rate(value['rate']) exchange_rates.set_exchange_rates(exchange_rate) return exchange_rates def get_exchange_rate(self, resp): """This method parses the given response and returns exchange rate object. Args: resp(dict): Response containing json object for exchange rate object. Returns: instance: Exchange rate object. """ exchange_rate = resp['exchange_rate'] exchange_rate_obj = ExchangeRate() exchange_rate_obj.set_exchange_rate_id(exchange_rate[\ 'exchange_rate_id']) exchange_rate_obj.set_currency_id(exchange_rate['currency_id']) exchange_rate_obj.set_currency_code(exchange_rate['currency_code']) exchange_rate_obj.set_effective_date(exchange_rate['effective_date']) exchange_rate_obj.set_rate(exchange_rate['rate']) return exchange_rate_obj def get_taxes(self, resp): """This method parses the given response and returns tax list object. Args: resp(dict): Response containing json object for taxes. Returns: instance: Tax list object. """ tax_list = TaxList() for value in resp['taxes']: tax = Tax() tax.set_tax_id(value['tax_id']) tax.set_tax_name(value['tax_name']) tax.set_tax_percentage(value['tax_percentage']) tax.set_tax_type(value['tax_type']) tax_list.set_taxes(tax) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) tax_list.set_page_context(page_context_obj) return tax_list def get_tax(self, resp): """This method parses the given response and returns tax object. Args: resp(dict): Response containing json object for tax. Returns: instance: Tax object. """ tax_obj = Tax() tax = resp['tax'] tax_obj.set_tax_id(tax['tax_id']) tax_obj.set_tax_name(tax['tax_name']) tax_obj.set_tax_percentage(tax['tax_percentage']) tax_obj.set_tax_type(tax['tax_type']) return tax_obj def get_tax_group(self, resp): """This method parses the given response and returns Tax group object. Args: resp(dict): Response containing json object for tax group. Returns: instance: Tax group object. Raises: Books Exception: If status is not '200' or '201'. """ tax_group_obj = TaxGroup() tax_group = resp['tax_group'] tax_group_obj.set_tax_group_id(tax_group['tax_group_id']) tax_group_obj.set_tax_group_name(tax_group['tax_group_name']) tax_group_obj.set_tax_group_percentage(tax_group[\ 'tax_group_percentage']) for value in tax_group['taxes']: tax = Tax() tax.set_tax_id(value['tax_id']) tax.set_tax_name(value['tax_name']) tax.set_tax_percentage(value['tax_percentage']) tax.set_tax_type(value['tax_type']) tax_group_obj.set_taxes(tax) return tax_group_obj def get_opening_balance(self, resp): """This method parses the given response and returns opening balance object. Args: resp(dict): Response containing json object for opening balance. Returns: instance: Opening balance object. """ opening_balance_obj = OpeningBalance() opening_balance = resp['opening_balance'] opening_balance_obj.set_opening_balance_id(opening_balance[\ 'opening_balance_id']) opening_balance_obj.set_date(opening_balance['date']) for value in opening_balance['accounts']: accounts = Account() accounts.set_account_split_id(value['account_split_id']) accounts.set_account_id(value['account_id']) accounts.set_account_name(value['account_name']) accounts.set_debit_or_credit(value['debit_or_credit']) accounts.set_exchange_rate(value['exchange_rate']) accounts.set_currency_id(value['currency_id']) accounts.set_currency_code(value['currency_code']) accounts.set_bcy_amount(value['bcy_amount']) accounts.set_amount(value['amount']) opening_balance_obj.set_accounts(accounts) return opening_balance_obj def get_autoreminders(self, resp): """This method parses the given response and returns autoreminders list. Args: resp(dict): Response containing json object for autoreminders. Returns: instance: Reminder list object. """ autoreminders = AutoReminderList() for value in resp['autoreminders']: autoreminders_obj = Autoreminder() autoreminders_obj.set_autoreminder_id(value['autoreminder_id']) autoreminders_obj.set_is_enabled(value['is_enabled']) autoreminders_obj.set_notification_type(value['type']) autoreminders_obj.set_address_type(value['address_type']) autoreminders_obj.set_number_of_days(value['number_of_days']) autoreminders_obj.set_subject(value['subject']) autoreminders_obj.set_body(value['body']) autoreminders_obj.set_order(value['order']) autoreminders.set_auto_reminders(autoreminders_obj) return autoreminders def get_autoreminder(self, resp): """Get auto reminder. Args: resp(dict): Response containing json object for auto reminders object. Returns: instance: Auto reminders object. """ autoreminder = resp['autoreminder'] autoreminder_obj = Autoreminder() autoreminder_obj.set_autoreminder_id(autoreminder['autoreminder_id']) autoreminder_obj.set_is_enabled(autoreminder['is_enabled']) autoreminder_obj.set_notification_type(autoreminder['type']) autoreminder_obj.set_address_type(autoreminder['address_type']) autoreminder_obj.set_number_of_days(autoreminder['number_of_days']) autoreminder_obj.set_subject(autoreminder['subject']) autoreminder_obj.set_body(autoreminder['body']) placeholders_obj = PlaceHolder() placeholders = resp['placeholders'] for value in placeholders['Invoice']: invoice = Invoice() invoice.set_name(value['name']) invoice.set_value(value['value']) placeholders_obj.set_invoice(invoice) for value in placeholders['Customer']: customer = Customer() customer.set_name(value['name']) customer.set_value(value['value']) placeholders_obj.set_customer(customer) for value in placeholders['Organization']: organization = Organization() organization.set_value(value['value']) organization.set_name(value['name']) placeholders_obj.set_organization(organization) autoreminder_obj.set_placeholders(placeholders) return autoreminder_obj def get_manual_reminders(self, resp): """This method parses the given response and returns manual reminders list. Args: resp(dict): Response containing json object for manual reminders list. Returns: list of instance: List of manual reminders object. """ manual_reminders = ManualReminderList() for value in resp['manualreminders']: manual_reminder = ManualReminder() manual_reminder.set_manualreminder_id(value['manualreminder_id']) manual_reminder.set_type(value['type']) manual_reminder.set_subject(value['subject']) manual_reminder.set_body(value['body']) manual_reminder.set_cc_me(value['cc_me']) manual_reminders.set_manual_reminders(manual_reminder) return manual_reminders def get_manual_reminder(self, resp): """Get manual reminder. Args: resp(dict): Response containing json object for manual reminder. Returns: instance: Manual reminders object. """ manualreminder = resp['manualreminder'] manualreminder_obj = ManualReminder() manualreminder_obj.set_manualreminder_id(manualreminder[\ 'manualreminder_id']) manualreminder_obj.set_type(manualreminder['type']) manualreminder_obj.set_subject(manualreminder['subject']) manualreminder_obj.set_body(manualreminder['body']) manualreminder_obj.set_cc_me(manualreminder['cc_me']) placeholders = resp['placeholders'] placeholders_obj = PlaceHolder() for value in placeholders['Invoice']: invoice = Invoice() invoice.set_name(value['name']) invoice.set_value(value['value']) placeholders_obj.set_invoice(invoice) for value in placeholders['Customer']: customer = Customer() customer.set_name(value['name']) customer.set_value(value['value']) placeholders_obj.set_customer(customer) for value in placeholders['Organization']: organization = Organization() organization.set_name(value['name']) organization.set_value(value['value']) placeholders_obj.set_organization(organization) manualreminder_obj.set_placeholders(placeholders_obj) return manualreminder_obj
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/SettingsParser.py
SettingsParser.py
from books.model.BaseCurrencyAdjustment import BaseCurrencyAdjustment from books.model.BaseCurrencyAdjustmentList import BaseCurrencyAdjustmentList from books.model.PageContext import PageContext from books.model.Account import Account class BaseCurrencyAdjustmentParser: """This class is used to parse the json object for Base Currency adjustment Api.""" def get_list(self, resp): """This method parses the given response and returns base currency adjustment list object. Args: resp(dict): Response containing json for base currency adjustments list. Returns: instance: Base currency list object. """ base_currency_adjustment_list = BaseCurrencyAdjustmentList() for value in resp['base_currency_adjustments']: base_currency_adjustment = BaseCurrencyAdjustment() base_currency_adjustment.set_base_currency_adjustment_id(\ value['base_currency_adjustment_id']) base_currency_adjustment.set_adjustment_date(value[\ 'adjustment_date']) base_currency_adjustment.set_exchange_rate(value['exchange_rate']) base_currency_adjustment.set_currency_id(value['currency_id']) base_currency_adjustment.set_currency_code(value['currency_code']) base_currency_adjustment.set_notes(value['notes']) base_currency_adjustment.set_gain_or_loss(value['gain_or_loss']) base_currency_adjustment_list.set_base_currency_adjustments(\ base_currency_adjustment) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) base_currency_adjustment_list.set_page_context(page_context_obj) return base_currency_adjustment_list def get_base_currency_adjustment(self, resp): """This method parses the given response and returns the base currency adjustment details object. Args: resp(dict): Response containing json object for base currency adjustment. Returns: instance: Base currency adjustment object. """ data = resp['data'] base_currency_adjustment = BaseCurrencyAdjustment() base_currency_adjustment.set_base_currency_adjustment_id(data[\ 'base_currency_adjustment_id']) base_currency_adjustment.set_currency_id(data['currency_id']) base_currency_adjustment.set_currency_code(data['currency_code']) base_currency_adjustment.set_adjustment_date(data['adjustment_date']) base_currency_adjustment.set_exchange_rate(data['exchange_rate']) base_currency_adjustment.set_notes(data['notes']) for value in data['accounts']: account = Account() account.set_account_id(value['account_id']) account.set_account_name(value['account_name']) account.set_bcy_balance(value['bcy_balance']) account.set_fcy_balance(value['fcy_balance']) account.set_adjusted_balance(value['adjusted_balance']) account.set_gain_or_loss(value['gain_or_loss']) account.set_gl_specific_type(value['gl_specific_type']) base_currency_adjustment.set_accounts(account) return base_currency_adjustment def list_account_details(self, resp): """This method parses the given response and returns list of account details for base currency adjustment. Args: resp(dict): Response containing json object for account details list. Returns: instance: Base currency adjustment object. """ data = resp['data'] base_currency_adjustment = BaseCurrencyAdjustment() base_currency_adjustment.set_adjustment_date(data['adjustment_date']) base_currency_adjustment.set_adjustment_date_formatted(data[\ 'adjustment_date_formatted']) base_currency_adjustment.set_exchange_rate(data['exchange_rate']) base_currency_adjustment.set_exchange_rate_formatted(data[\ 'exchange_rate_formatted']) base_currency_adjustment.set_currency_id(data['currency_id']) for value in data['accounts']: accounts = Account() accounts.set_account_id(value['account_id']) accounts.set_account_name(value['account_name']) accounts.set_gl_specific_type(value['gl_specific_type']) accounts.set_fcy_balance(value['fcy_balance']) accounts.set_fcy_balance_formatted(value['fcy_balance_formatted']) accounts.set_bcy_balance(value['bcy_balance']) accounts.set_bcy_balance_formatted(value['bcy_balance_formatted']) accounts.set_adjusted_balance(value['adjusted_balance']) accounts.set_adjusted_balance_formatted(value[\ 'adjusted_balance_formatted']) accounts.set_gain_or_loss(value['gain_or_loss']) accounts.set_gain_or_loss_formatted(value['gain_or_loss_formatted']) base_currency_adjustment.set_accounts(accounts) base_currency_adjustment.set_notes(data['notes']) base_currency_adjustment.set_currency_code(data['currency_code']) return base_currency_adjustment def get_message(self, resp): """This method parses the given response and returns message. Args: resp(dict): Response containing json object for message. Returns: str: Success message. """ return resp['message']
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/BaseCurrencyAdjustmentParser.py
BaseCurrencyAdjustmentParser.py
from books.model.ChartOfAccount import ChartOfAccount from books.model.ChartOfAccountList import ChartOfAccountList from books.model.TransactionList import TransactionList from books.model.Transaction import Transaction from books.model.PageContext import PageContext class ChartOfAccountsParser: """This class parses the json response for chart of accounts.""" def get_list(self, resp): """This method parses the given response and returns chart of accounts list. Args: resp(dict): Dictionary containing json object for chart of accounts list. Returns: instance: Chart of accounts list object. """ chart_of_accounts_list = ChartOfAccountList() for value in resp['chartofaccounts']: chart_of_accounts = ChartOfAccount() chart_of_accounts.set_account_id(value['account_id']) chart_of_accounts.set_account_name(value['account_name']) chart_of_accounts.set_account_type(value['account_type']) chart_of_accounts.set_is_active(value['is_active']) chart_of_accounts.set_is_user_created(value['is_user_created']) chart_of_accounts.set_is_involved_in_transaction(value[\ 'is_involved_in_transaction']) chart_of_accounts.set_is_system_account(value['is_system_account']) chart_of_accounts_list.set_chartofaccounts(chart_of_accounts) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) chart_of_accounts_list.set_page_context(page_context_obj) return chart_of_accounts_list def get_account(self, resp): """This method parses the given response and returns chart of accounts object. Args: resp(dict): Dictionary containing json object for chart of accounts. Returns: instance: Chart of accounts object. """ chart_of_account = resp['chart_of_account'] chart_of_account_obj = ChartOfAccount() chart_of_account_obj.set_account_id(chart_of_account['account_id']) chart_of_account_obj.set_account_name(chart_of_account['account_name']) chart_of_account_obj.set_is_active(chart_of_account['is_active']) chart_of_account_obj.set_account_type(chart_of_account['account_type']) chart_of_account_obj.set_account_type_formatted(chart_of_account[\ 'account_type_formatted']) chart_of_account_obj.set_description(chart_of_account['description']) return chart_of_account_obj def get_message(self, resp): """This method parses the given response and returns string message. Args: reps(dict): Dictionary containing json object for message. Returns: str: Success message. """ return resp['message'] def get_transactions_list(self, resp): """This method parses the given response and returns transactions list. Args: resp(dict): Dictionary containing json object for transactions list. Returns: instance: Transaction list object. """ transactions_list = TransactionList() for value in resp['transactions']: transactions = Transaction() transactions.set_categorized_transaction_id(value[\ 'categorized_transaction_id']) transactions.set_transaction_type(value['transaction_type']) transactions.set_transaction_id(value['transaction_id']) transactions.set_transaction_date(value['transaction_date']) transactions.set_transaction_type_formatted(value[\ 'transaction_type_formatted']) transactions.set_account_id(value['account_id']) transactions.set_customer_id(value['customer_id']) transactions.set_payee(value['payee']) transactions.set_description(value['description']) transactions.set_entry_number(value['entry_number']) transactions.set_currency_id(value['currency_id']) transactions.set_currency_code(value['currency_code']) transactions.set_debit_or_credit(value['debit_or_credit']) transactions.set_offset_account_name(value['offset_account_name']) transactions.set_reference_number(value['reference_number']) transactions.set_reconcile_status(value['reconcile_status']) transactions.set_debit_amount(value['debit_amount']) transactions.set_credit_amount(value['credit_amount']) transactions_list.set_transactions(transactions) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) transactions_list.set_page_context(page_context_obj) return transactions_list
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/ChartOfAccountsParser.py
ChartOfAccountsParser.py
from books.model.CustomerPayment import CustomerPayment from books.model.CustomerPaymentList import CustomerPaymentList from books.model.CreditNoteRefund import CreditNoteRefund from books.model.CreditNoteRefundList import CreditNoteRefundList from books.model.PageContext import PageContext from books.model.Invoice import Invoice class CustomerPaymentsParser: """This class is used to parse the json for customer payments.""" def customer_payments(self,response): """This method parses the given response and returns customer payments list object. Args: response(dict): Response containing json object for customer payments list. Returns: instance: Customer payments list object. """ customer_payment_list=CustomerPaymentList() for value in response['customerpayments']: customer_payment=CustomerPayment() customer_payment.set_payment_id(value['payment_id']) customer_payment.set_payment_number(value['payment_number']) customer_payment.set_invoice_numbers(value['invoice_numbers']) customer_payment.set_date(value['date']) customer_payment.set_payment_mode(value['payment_mode']) customer_payment.set_amount(value['amount']) customer_payment.set_bcy_amount(value['bcy_amount']) customer_payment.set_unused_amount(value['unused_amount']) customer_payment.set_bcy_unused_amount(value['bcy_unused_amount']) customer_payment.set_account_id(value['account_id']) customer_payment.set_account_name(value['account_name']) customer_payment.set_description(value['description']) customer_payment.set_reference_number(value['reference_number']) customer_payment.set_customer_id(value['customer_id']) customer_payment.set_customer_name(value['customer_name']) customer_payment.set_created_time(value['created_time']) customer_payment.set_last_modified_time(\ value['last_modified_time']) customer_payment_list.set_customer_payments(customer_payment) page_context=response['page_context'] page_context_obj=PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) customer_payment_list.set_page_context(page_context_obj) return customer_payment_list def payment_refunds(self,response): """This method parses the given response and returns credit notes refund list. Args: response(dict): Repsonse containing json object for credit notes list. Returns: instance: Creditnote list object. """ payment_refunds_list=CreditNoteRefundList() if 'payment_refunds' not in response: response['payment_refunds'] = [response['payment_refund']] for value in response['payment_refunds']: payment_refund=CreditNoteRefund() payment_refund.set_creditnote_refund_id(value['payment_refund_id']) payment_refund.set_creditnote_id(value['payment_id']) payment_refund.set_date(value['date']) payment_refund.set_refund_mode(value['refund_mode']) payment_refund.set_reference_number(value['reference_number']) payment_refund.set_description(value['description']) payment_refund.set_amount(value['amount']) payment_refunds_list.set_creditnote_refunds(payment_refund) if 'page_context' in response: page_context=response['page_context'] page_context_obj=PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) payment_refunds_list.set_page_context(page_context_obj) return payment_refunds_list def get_customer_payment(self,response): """This method parses the given response and returns customer payments object. Args: response(dict): Response containing json object for customer payments. Returns: instance: Customer payments object. """ payment=response['payment'] customer_payment=CustomerPayment() customer_payment.set_payment_id(payment['payment_id']) customer_payment.set_customer_id(payment['customer_id']) customer_payment.set_customer_name(payment['customer_name']) customer_payment.set_payment_mode(payment['payment_mode']) customer_payment.set_date(payment['date']) customer_payment.set_account_id(payment['account_id']) customer_payment.set_account_name(payment['account_name']) customer_payment.set_exchange_rate(payment['exchange_rate']) customer_payment.set_amount(payment['amount']) customer_payment.set_bank_charges(payment['bank_charges']) customer_payment.set_tax_account_id(payment['tax_account_id']) customer_payment.set_tax_account_name(payment['tax_account_name']) customer_payment.set_tax_amount_withheld(\ payment['tax_amount_withheld']) customer_payment.set_description(payment['description']) customer_payment.set_reference_number(payment['reference_number']) invoices=[] for value in payment['invoices']: invoice=Invoice() invoice.set_invoice_number(value['invoice_number']) invoice.set_invoice_payment_id(value['invoice_payment_id']) invoice.set_invoice_id(value['invoice_id']) invoice.set_amount_applied(value['amount_applied']) invoice.set_tax_amount_withheld(value['tax_amount_withheld']) invoice.set_total(value['total']) invoice.set_balance(value['balance']) invoice.set_date(value['date']) invoice.set_due_date(value['due_date']) invoices.append(invoice) customer_payment.set_invoices(invoices) return customer_payment def get_message(self,response): """This method parses the given response and returns the message. Args: response(dict): Response containing json object. Returns: str: Success message. """ return response['message']
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/CustomerPaymentsParser.py
CustomerPaymentsParser.py
from books.model.RecurringExpense import RecurringExpense from books.model.RecurringExpenseList import RecurringExpenseList from books.model.Expense import Expense from books.model.ExpenseList import ExpenseList from books.model.Comment import Comment from books.model.PageContext import PageContext from books.model.CommentList import CommentList class RecurringExpensesParser: """This class is used to parse the json for recurring expenses. """ def get_list(self, resp): """This method parses the given response and returns recurring expenses list object. Args: resp(dict): Response containing json object for recurring expenses list. Returns: instance: Recurring expenses list object. """ recurring_expenses_list = RecurringExpenseList() for value in resp['recurring_expenses']: recurring_expenses = RecurringExpense() recurring_expenses.set_recurring_expense_id(\ value['recurring_expense_id']) recurring_expenses.set_recurrence_name(value['recurrence_name']) recurring_expenses.set_recurrence_frequency(\ value['recurrence_frequency']) recurring_expenses.set_repeat_every(value['repeat_every']) recurring_expenses.set_last_created_date(\ value['last_created_date']) recurring_expenses.set_next_expense_date(\ value['next_expense_date']) recurring_expenses.set_account_name(value['account_name']) recurring_expenses.set_paid_through_account_name(\ value['paid_through_account_name']) recurring_expenses.set_description(value['description']) recurring_expenses.set_currency_id(value['currency_id']) recurring_expenses.set_currency_code(value['currency_code']) recurring_expenses.set_total(value['total']) recurring_expenses.set_is_billable(value['is_billable']) recurring_expenses.set_customer_name(value['customer_name']) recurring_expenses.set_vendor_name(value['vendor_name']) recurring_expenses.set_status(value['status']) recurring_expenses.set_created_time(value['created_time']) recurring_expenses_list.set_recurring_expenses(recurring_expenses) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) recurring_expenses_list.set_page_context(page_context_obj) return recurring_expenses_list def get_recurring_expense(self, resp): """This method parses the given response and returns recurring expenses object. Args: resp(dict): Response containing json object for recurring expenses. Returns: instance: Recurring expenses object. """ recurring_expense = resp['recurring_expense'] recurring_expense_obj = RecurringExpense() recurring_expense_obj.set_recurring_expense_id(\ recurring_expense['recurring_expense_id']) recurring_expense_obj.set_recurrence_name(\ recurring_expense['recurrence_name']) recurring_expense_obj.set_start_date(recurring_expense['start_date']) recurring_expense_obj.set_end_date(recurring_expense['end_date']) recurring_expense_obj.set_recurrence_frequency(\ recurring_expense['recurrence_frequency']) recurring_expense_obj.set_repeat_every(\ recurring_expense['repeat_every']) recurring_expense_obj.set_last_created_date(\ recurring_expense['last_created_date']) recurring_expense_obj.set_next_expense_date(\ recurring_expense['next_expense_date']) recurring_expense_obj.set_account_id(recurring_expense['account_id']) recurring_expense_obj.set_account_name(\ recurring_expense['account_name']) recurring_expense_obj.set_paid_through_account_id(\ recurring_expense['paid_through_account_id']) recurring_expense_obj.set_paid_through_account_name(\ recurring_expense['paid_through_account_name']) recurring_expense_obj.set_vendor_id(recurring_expense['vendor_id']) recurring_expense_obj.set_vendor_name(recurring_expense['vendor_name']) recurring_expense_obj.set_currency_id(recurring_expense['currency_id']) recurring_expense_obj.set_currency_code(\ recurring_expense['currency_code']) recurring_expense_obj.set_exchange_rate(\ recurring_expense['exchange_rate']) recurring_expense_obj.set_tax_id(recurring_expense['tax_id']) recurring_expense_obj.set_tax_name(recurring_expense['tax_name']) recurring_expense_obj.set_tax_percentage(\ recurring_expense['tax_percentage']) recurring_expense_obj.set_tax_amount(recurring_expense['tax_amount']) recurring_expense_obj.set_sub_total(recurring_expense['sub_total']) recurring_expense_obj.set_total(recurring_expense['total']) recurring_expense_obj.set_bcy_total(recurring_expense['bcy_total']) recurring_expense_obj.set_amount(recurring_expense['amount']) recurring_expense_obj.set_description(recurring_expense['description']) recurring_expense_obj.set_is_inclusive_tax(\ recurring_expense['is_inclusive_tax']) recurring_expense_obj.set_is_billable(recurring_expense['is_billable']) recurring_expense_obj.set_customer_id(recurring_expense['customer_id']) recurring_expense_obj.set_customer_name(\ recurring_expense['customer_name']) recurring_expense_obj.set_status(recurring_expense['status']) recurring_expense_obj.set_created_time(\ recurring_expense['created_time']) recurring_expense_obj.set_last_modified_time(\ recurring_expense['last_modified_time']) recurring_expense_obj.set_project_id(recurring_expense['project_id']) recurring_expense_obj.set_project_name(\ recurring_expense['project_name']) return recurring_expense_obj def get_message(self, response): """This method parses the json object and returns the message string. Args: response(dict): Response containing json object for message. Returns: str: Success message. """ return response['message'] def get_expense_history(self, resp): """This method parses the json object and returns expense history list. Args: resp(dict): Response containing json object for expense history. Returns: instance: Expenses list object. """ expenses_list = ExpenseList() for value in resp['expensehistory']: expense = Expense() expense.set_expense_id(value['expense_id']) expense.set_date(value['date']) expense.set_account_name(value['account_name']) expense.set_vendor_name(value['vendor_name']) expense.set_paid_through_account_name(\ value['paid_through_account_name']) expense.set_customer_name(value['customer_name']) expense.set_total(value['total']) expense.set_status(value['status']) expenses_list.set_expenses(expense) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) expenses_list.set_page_context(page_context_obj) return expenses_list def get_comments(self, resp): """This method parses the given response and returns comments list. Args: resp(dict): Response containing comments list. Returns: instance: Comments List object. """ comments_list = CommentList() for value in resp['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_recurring_expense_id(value['recurring_expense_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_operation_type(value['operation_type']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments_list.set_comments(comment) return comments_list
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/RecurringExpensesParser.py
RecurringExpensesParser.py
from books.model.ProjectList import ProjectList from books.model.Project import Project from books.model.PageContext import PageContext from books.model.TaskList import TaskList from books.model.Task import Task from books.model.User import User from books.model.TimeEntryList import TimeEntryList from books.model.TimeEntry import TimeEntry from books.model.Comment import Comment from books.model.InvoiceList import InvoiceList from books.model.Invoice import Invoice from books.model.UserList import UserList from books.model.CommentList import CommentList class ProjectsParser: """This class is used to parse the json object for Projects.""" def get_projects_list(self, resp): """This method parses the given response and returns projects list object. Args: resp(dict): Response containing json object for projects. Returns: instance: Projects list object. """ projects_list = ProjectList() for value in resp['projects']: project = Project() project.set_project_id(value['project_id']) project.set_project_name(value['project_name']) project.set_customer_id(value['customer_id']) project.set_customer_name(value['customer_name']) project.set_description(value['description']) project.set_status(value['status']) project.set_billing_type(value['billing_type']) #project.set_rate(value['rate']) project.set_created_time(value['created_time']) projects_list.set_projects(project) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) projects_list.set_page_context(page_context_obj) return projects_list def get_project(self, resp): """This method parses the given response and returns projects object. Args: resp(dict): Dictionary containing json object for projects. Returns: instance: Projects object. """ project_obj = Project() project = resp['project'] project_obj.set_project_id(project['project_id']) project_obj.set_project_name(project['project_name']) project_obj.set_customer_id(project['customer_id']) project_obj.set_customer_name(project['customer_name']) project_obj.set_currency_code(project['currency_code']) project_obj.set_description(project['description']) project_obj.set_status(project['status']) project_obj.set_billing_type(project['billing_type']) project_obj.set_budget_type(project['budget_type']) project_obj.set_total_hours(project['total_hours']) project_obj.set_billed_hours(project['billed_hours']) project_obj.set_un_billed_hours(project['un_billed_hours']) project_obj.set_created_time(project['created_time']) for value in project['tasks']: task = Task() task.set_task_id(value['task_id']) task.set_task_name(value['task_name']) task.set_description(value['description']) task.set_rate(value['rate']) task.set_budget_hours(value['budget_hours']) task.set_total_hours(value['total_hours']) task.set_billed_hours(value['billed_hours']) task.set_un_billed_hours(value['un_billed_hours']) project_obj.set_tasks(task) for value in project['users']: user = User() user.set_user_id(value['user_id']) user.set_is_current_user(value['is_current_user']) user.set_user_name(value['user_name']) user.set_email(value['email']) user.set_user_role(value['user_role']) user.set_status(value['status']) user.set_rate(value['rate']) user.set_budget_hours(value['budget_hours']) user.set_total_hours(value['total_hours']) user.set_billed_hours(value['billed_hours']) user.set_un_billed_hours(value['un_billed_hours']) project_obj.set_users(user) return project_obj def get_message(self, resp): """This method parses the given response and returns string message. Args: resp(dict): Response containing json object for string message. Returns: str: Success message. """ return resp['message'] def get_tasks_list(self, resp): """This method parses the given response and returns tasks list object. Args: resp(dict): Response containing json object for tasks list. Returns: instance: Task list object. """ task_list = TaskList() for value in resp['task']: task = Task() task.set_project_id(value['project_id']) task.set_task_id(value['task_id']) task.set_currency_id(value['currency_id']) task.set_customer_id(value['customer_id']) task.set_task_name(value['task_name']) task.set_project_name(value['project_name']) task.set_customer_name(value['customer_name']) task.set_billed_hours(value['billed_hours']) task.set_log_time(value['log_time']) task.set_un_billed_hours(value['un_billed_hours']) task_list.set_tasks(task) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) task_list.set_page_context(page_context_obj) return task_list def get_task(self, resp): """This method parses the given response and returns task object. Args: resp(dict): Response containing json object for task. Returns: instance: Task object. """ task_obj = Task() task = resp['task'] task_obj.set_project_id(task['project_id']) task_obj.set_project_name(task['project_name']) task_obj.set_task_id(task['task_id']) task_obj.set_task_name(task['task_name']) task_obj.set_description(task['description']) task_obj.set_rate(task['rate']) return task_obj def get_users(self, resp): """This method parses the given response and returns list of users object. Args: resp(dict): Response containing json object for users list object. Returns: instance: Users list object. """ users = UserList() for value in resp['users']: user = User() user.set_user_id(value['user_id']) user.set_is_current_user(value['is_current_user']) user.set_user_name(value['user_name']) user.set_email(value['email']) user.set_user_role(value['user_role']) user.set_status(value['status']) user.set_rate(value['rate']) user.set_budget_hours(value['budget_hours']) users.set_users(user) return users def get_user(self, resp): """This method parses the given response and returns user object. Args: resp(dict): Response containing json object for user. Returns: instance: User object. """ user_obj = User() user = resp['user'] user_obj.set_project_id(user['project_id']) user_obj.set_user_id(user['user_id']) user_obj.set_is_current_user(user['is_current_user']) user_obj.set_user_name(user['user_name']) user_obj.set_email(user['email']) user_obj.set_user_role(user['user_role']) return user_obj def get_time_entries_list(self, resp): """This method parses the given response and returns time entries list object. Args: resp(dict): Response containing json object for time entries. Returns: instance: Time entries list object. """ time_entries_list = TimeEntryList() for value in resp['time_entries']: time_entry = TimeEntry() time_entry.set_time_entry_id(value['time_entry_id']) time_entry.set_project_id(value['project_id']) time_entry.set_project_name(value['project_name']) time_entry.set_customer_id(value['customer_id']) time_entry.set_customer_name(value['customer_name']) time_entry.set_task_id(value['task_id']) time_entry.set_task_name(value['task_name']) time_entry.set_user_id(value['user_id']) time_entry.set_is_current_user(value['is_current_user']) time_entry.set_user_name(value['user_name']) time_entry.set_log_date(value['log_date']) time_entry.set_begin_time(value['begin_time']) time_entry.set_end_time(value['end_time']) time_entry.set_log_time(value['log_time']) time_entry.set_billed_status(value['billed_status']) time_entry.set_notes(value['notes']) time_entry.set_timer_started_at(value['timer_started_at']) time_entry.set_timer_duration_in_minutes(value[\ 'timer_duration_in_minutes']) time_entry.set_created_time(value['created_time']) time_entries_list.set_time_entries(time_entry) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) time_entries_list.set_page_context(page_context_obj) return time_entries_list def get_time_entry(self, resp): """This method parses the given response and returns time entry object. Args: resp(dict):Response containing json object for time entry. Returns: instance: Time entry object """ time_entry = resp['time_entry'] time_entry_obj = TimeEntry() time_entry_obj.set_time_entry_id(time_entry['time_entry_id']) time_entry_obj.set_project_id(time_entry['project_id']) time_entry_obj.set_project_name(time_entry['project_name']) time_entry_obj.set_task_id(time_entry['task_id']) time_entry_obj.set_task_name(time_entry['task_name']) time_entry_obj.set_user_id(time_entry['user_id']) time_entry_obj.set_user_name(time_entry['user_name']) time_entry_obj.set_is_current_user(time_entry['is_current_user']) time_entry_obj.set_log_date(time_entry['log_date']) time_entry_obj.set_begin_time(time_entry['begin_time']) time_entry_obj.set_end_time(time_entry['end_time']) time_entry_obj.set_log_time(time_entry['log_time']) time_entry_obj.set_billed_status(time_entry['billed_status']) time_entry_obj.set_notes(time_entry['notes']) time_entry_obj.set_timer_started_at(time_entry['timer_started_at']) time_entry_obj.set_timer_duration_in_minutes(time_entry[\ 'timer_duration_in_minutes']) time_entry_obj.set_created_time(time_entry['created_time']) return time_entry_obj def get_comments(self, resp): """This method parses the given response and returns comments list object. Args: resp(dict): Response containing json object for comments list. Returns: list of instance: Comments list object. """ comments = CommentList() for value in resp['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_project_id(value['project_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_is_current_user(value['is_current_user']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comments.set_comments(comment) return comments def get_comment(self, resp): """This method parses the given response and returns comment object. Args: resp(dict): Response containing json object for comment object. Returns: instance: Comment object. """ comment = resp['comment'] comment_obj = Comment() comment_obj.set_comment_id(comment['comment_id']) comment_obj.set_project_id(comment['project_id']) comment_obj.set_description(comment['description']) comment_obj.set_commented_by_id(comment['commented_by_id']) comment_obj.set_commented_by(comment['commented_by']) comment_obj.set_date(comment['date']) comment_obj.set_date_description(comment['date_description']) comment_obj.set_time(comment['time']) return comment_obj def get_invoice_list(self, resp): """This method parses the given response and returns invoice list object. Args: resp(dict): Response containing json object for invoice list object. Returns: instance: Invoice list object. """ invoices = InvoiceList() for value in resp['invoices']: invoice = Invoice() invoice.set_invoice_id(value['invoice_id']) invoice.set_customer_name(value['customer_name']) invoice.set_customer_id(value['customer_id']) invoice.set_status(value['status']) invoice.set_invoice_number(value['invoice_number']) invoice.set_reference_number(value['reference_number']) invoice.set_date(value['date']) invoice.set_due_date(value['due_date']) invoice.set_total(value['total']) invoice.set_balance(value['balance']) invoice.set_created_time(value['created_time']) invoices.set_invoices(invoice) page_context = resp['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) invoices.set_page_context(page_context) return invoices
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/ProjectsParser.py
ProjectsParser.py
from books.model.Expense import Expense from books.model.ExpenseList import ExpenseList from books.model.Comment import Comment from books.model.PageContext import PageContext from books.model.CommentList import CommentList class ExpensesParser: """This class is used to parse the json for Expenses.""" def get_list(self, resp): """This method parses the given response and returns Expense list object. Args: resp(dict): Response containing json object for Expenses list. Returns: instance: Expenses list object. """ expenses = resp['expenses'] expense_list = ExpenseList() for value in expenses: expense = Expense() expense.set_expense_id(value['expense_id']) expense.set_date(value['date']) expense.set_account_name(value['account_name']) expense.set_paid_through_account_name(value[\ 'paid_through_account_name']) expense.set_description(value['description']) expense.set_currency_id(value['currency_id']) expense.set_currency_code(value['currency_code']) expense.set_bcy_total(value['bcy_total']) expense.set_total(value['total']) expense.set_is_billable(value['is_billable']) expense.set_reference_number(value['reference_number']) expense.set_customer_id(value['customer_id']) expense.set_customer_name(value['customer_name']) expense.set_vendor_id(value['vendor_id']) expense.set_vendor_name(value['vendor_name']) expense.set_status(value['status']) expense.set_created_time(value['created_time']) expense.set_expense_receipt_name(value['expense_receipt_name']) expense_list.set_expenses(expense) page_context_obj = PageContext() page_context = resp['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) expense_list.set_page_context(page_context) return expense_list def get_expense(self, resp): """This method parses the given response and returns expense object. Args: resp(dict): Response containing json object for expense. Returns: instance: Expense object. """ expense = resp['expense'] expense_obj = Expense() expense_obj.set_expense_id(expense['expense_id']) expense_obj.set_expense_item_id(expense['expense_item_id']) expense_obj.set_account_id(expense['account_id']) expense_obj.set_account_name(expense['account_name']) expense_obj.set_paid_through_account_id(expense[\ 'paid_through_account_id']) expense_obj.set_paid_through_account_name(expense[\ 'paid_through_account_name']) expense_obj.set_vendor_id(expense['vendor_id']) expense_obj.set_vendor_name(expense['vendor_name']) expense_obj.set_date(expense['date']) expense_obj.set_tax_id(expense['tax_id']) expense_obj.set_tax_name(expense['tax_name']) expense_obj.set_tax_percentage(expense['tax_percentage']) expense_obj.set_currency_id(expense['currency_id']) expense_obj.set_currency_code(expense['currency_code']) expense_obj.set_exchange_rate(expense['exchange_rate']) expense_obj.set_tax_amount(expense['tax_amount']) expense_obj.set_sub_total(expense['sub_total']) expense_obj.set_total(expense['total']) expense_obj.set_bcy_total(expense['bcy_total']) expense_obj.set_amount(expense['amount']) expense_obj.set_is_inclusive_tax(expense['is_inclusive_tax']) expense_obj.set_reference_number(expense['reference_number']) expense_obj.set_description(expense['description']) expense_obj.set_is_billable(expense['is_billable']) expense_obj.set_customer_id(expense['customer_id']) expense_obj.set_customer_name(expense['customer_name']) expense_obj.set_expense_receipt_name(expense['expense_receipt_name']) expense_obj.set_created_time(expense['created_time']) expense_obj.set_last_modified_time(expense['last_modified_time']) expense_obj.set_status(expense['status']) expense_obj.set_invoice_id(expense['invoice_id']) expense_obj.set_invoice_number(expense['invoice_number']) expense_obj.set_project_id(expense['project_id']) expense_obj.set_project_name(expense['project_name']) return expense_obj def get_message(self, resp): """This method parses the given json string and returns string message. Args: resp(dict): Response containing json object for success message. Returns: str: Success message. """ return resp['message'] def get_comments(self, resp): """This method parses the given json string and returns comments list. Args: resp(dict): Response containing json object for comments. Returns: instance: Comments list object. """ comments = CommentList() for value in resp['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_expense_id(value['expense_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_operation_type(value['operation_type']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments.set_comments(comment) return comments
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/ExpensesParser.py
ExpensesParser.py
from books.model.RecurringInvoice import RecurringInvoice from books.model.RecurringInvoiceList import RecurringInvoiceList from books.model.PageContext import PageContext from books.model.LineItem import LineItem from books.model.CustomField import CustomField from books.model.Address import Address from books.model.PaymentGateway import PaymentGateway from books.model.Comment import Comment from books.model.CommentList import CommentList class RecurringInvoiceParser: """This class is used to parse the json for Recurring invoice.""" def recurring_invoices(self, response): """This method parses the given response and creates recurring invoices list object. Args: response(dict): Response containing json object for recurring invoice list. Returns: instance: Recurring invoice list object. """ recurring_invoices_list = RecurringInvoiceList() recurring_invoices = [] for value in response['recurring_invoices']: recurring_invoice = RecurringInvoice() recurring_invoice.set_recurring_invoice_id(\ value['recurring_invoice_id']) recurring_invoice.set_recurrence_name(value['recurrence_name']) recurring_invoice.set_status(value['status']) recurring_invoice.set_total(value['total']) recurring_invoice.set_customer_id(value['customer_id']) recurring_invoice.set_customer_name(value['customer_name']) recurring_invoice.set_start_date(value['start_date']) recurring_invoice.set_end_date(value['end_date']) recurring_invoice.set_last_sent_date(value['last_sent_date']) recurring_invoice.set_next_invoice_date(value['next_invoice_date']) recurring_invoice.set_recurrence_frequency(\ value['recurrence_frequency']) recurring_invoice.set_repeat_every(value['repeat_every']) recurring_invoice.set_created_time(value['created_time']) recurring_invoice.set_last_modified_time(\ value['last_modified_time']) recurring_invoices.append(recurring_invoice) recurring_invoices_list.set_recurring_invoices(recurring_invoices) page_context = response['page_context'] page_context_obj = PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) recurring_invoices_list.set_page_context(page_context_obj) return recurring_invoices_list def recurring_invoice(self, response): """This method parses the response and creates recurring invoice object. Args: response(dict): Response containing json object for recurring invoice. Returns: instance: Recurring invoice object. """ recurring_invoice = response['recurring_invoice'] recurring_invoice_obj = RecurringInvoice() recurring_invoice_obj.set_recurring_invoice_id(\ recurring_invoice['recurring_invoice_id']) recurring_invoice_obj.set_recurrence_name(\ recurring_invoice['recurrence_name']) recurring_invoice_obj.set_status(recurring_invoice['status']) recurring_invoice_obj.set_recurrence_frequency(\ recurring_invoice['recurrence_frequency']) recurring_invoice_obj.set_repeat_every(\ recurring_invoice['repeat_every']) recurring_invoice_obj.set_start_date(recurring_invoice['start_date']) recurring_invoice_obj.set_end_date(recurring_invoice['end_date']) recurring_invoice_obj.set_last_sent_date(\ recurring_invoice['last_sent_date']) recurring_invoice_obj.set_next_invoice_date(\ recurring_invoice['next_invoice_date']) recurring_invoice_obj.set_payment_terms(\ recurring_invoice['payment_terms']) recurring_invoice_obj.set_payment_terms_label(\ recurring_invoice['payment_terms_label']) recurring_invoice_obj.set_customer_id(recurring_invoice['customer_id']) recurring_invoice_obj.set_customer_name(\ recurring_invoice['customer_name']) recurring_invoice_obj.set_contact_persons(\ recurring_invoice['contact_persons']) recurring_invoice_obj.set_currency_id(recurring_invoice['currency_id']) recurring_invoice_obj.set_price_precision(\ recurring_invoice['price_precision']) recurring_invoice_obj.set_currency_code(\ recurring_invoice['currency_code']) recurring_invoice_obj.set_currency_symbol(\ recurring_invoice['currency_symbol']) recurring_invoice_obj.set_exchange_rate(\ recurring_invoice['exchange_rate']) recurring_invoice_obj.set_discount(recurring_invoice['discount']) recurring_invoice_obj.set_is_discount_before_tax(\ recurring_invoice['is_discount_before_tax']) recurring_invoice_obj.set_discount_type(\ recurring_invoice['discount_type']) line_items = [] for value in recurring_invoice['line_items']: line_item = LineItem() line_item.set_item_id(value['item_id']) line_item.set_line_item_id(value['line_item_id']) line_item.set_name(value['name']) line_item.set_description(value['description']) line_item.set_item_order(value['item_order']) line_item.set_rate(value['rate']) line_item.set_quantity(value['quantity']) line_item.set_unit(value['unit']) line_item.set_discount_amount(value['discount_amount']) line_item.set_discount(value['discount']) line_item.set_tax_id(value['tax_id']) line_item.set_tax_name(value['tax_name']) line_item.set_tax_type(value['tax_type']) line_item.set_tax_percentage(value['tax_percentage']) line_item.set_item_total(value['item_total']) line_items.append(line_item) recurring_invoice_obj.set_line_items(line_items) recurring_invoice_obj.set_shipping_charge(\ recurring_invoice['shipping_charge']) recurring_invoice_obj.set_adjustment(recurring_invoice['adjustment']) recurring_invoice_obj.set_adjustment_description(\ recurring_invoice['adjustment_description']) recurring_invoice_obj.set_late_fee(recurring_invoice['late_fee']) recurring_invoice_obj.set_sub_total(recurring_invoice['sub_total']) recurring_invoice_obj.set_total(recurring_invoice['total']) recurring_invoice_obj.set_tax_total(recurring_invoice['tax_total']) recurring_invoice_obj.set_allow_partial_payments(\ recurring_invoice['allow_partial_payments']) taxes = [] for value in recurring_invoice['taxes']: tax = Tax() tax.set_tax_name(value['tax_name']) tax.set_tax_amount['value_tax_amount'] taxes.append(tax) recurring_invoice_obj.set_taxes(taxes) custom_fields = [] for value in recurring_invoice['custom_fields']: custom_field = CustomField() custom_field.set_index(value['index']) custom_field.set_value(value['value']) custom_fields.append(custom_field) recurring_invoice_obj.set_custom_fields(custom_fields) payment_gateways = recurring_invoice['payment_options'][\ 'payment_gateways'] for value in payment_gateways: payment_gateway = PaymentGateway() payment_gateway.set_configured(value['configured']) payment_gateway.set_additional_field1(value['additional_field1']) payment_gateway.set_gateway_name(value['gateway_name']) recurring_invoice_obj.set_payment_options(payment_gateway) billing_address = recurring_invoice['billing_address'] billing_address_obj = Address() billing_address_obj.set_address(billing_address['address']) billing_address_obj.set_city(billing_address['city']) billing_address_obj.set_state(billing_address['state']) billing_address_obj.set_zip(billing_address['zip']) billing_address_obj.set_country(billing_address['country']) billing_address_obj.set_fax(billing_address['fax']) recurring_invoice_obj.set_billing_address(billing_address_obj) shipping_address = recurring_invoice['shipping_address'] shipping_address_obj = Address() shipping_address_obj.set_address(shipping_address['address']) shipping_address_obj.set_city(shipping_address['city']) shipping_address_obj.set_state(shipping_address['state']) shipping_address_obj.set_zip(shipping_address['zip']) shipping_address_obj.set_country(shipping_address['country']) shipping_address_obj.set_fax(shipping_address['fax']) recurring_invoice_obj.set_shipping_address(shipping_address_obj) recurring_invoice_obj.set_template_id(recurring_invoice['template_id']) recurring_invoice_obj.set_template_name(\ recurring_invoice['template_name']) recurring_invoice_obj.set_notes(recurring_invoice['notes']) recurring_invoice_obj.set_terms(recurring_invoice['terms']) recurring_invoice_obj.set_salesperson_id(\ recurring_invoice['salesperson_id']) recurring_invoice_obj.set_salesperson_name(\ recurring_invoice['salesperson_name']) recurring_invoice_obj.set_created_time(\ recurring_invoice['created_time']) recurring_invoice_obj.set_last_modified_time(\ recurring_invoice['last_modified_time']) return recurring_invoice_obj def get_message(self, response): """This method parses the json object and returns the message string. Args: response(dict): Response containing json object. Returns: string: Success message. """ return response['message'] def recurring_invoice_history_list(self, response): """This method parses the json object and returns list of comments object. Args: response(dict): Response containing json object. Returns: instance: Comments list object. """ comments = CommentList() for value in response['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_recurring_invoice_id(value['recurring_invoice_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_comment_type(value['comment_type']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_operation_type(value['operation_type']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments.set_comments(comment) return comments
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/RecurringInvoiceParser.py
RecurringInvoiceParser.py
from books.model.CreditNote import CreditNote from books.model.PageContext import PageContext from books.model.CreditNoteList import CreditNoteList from books.model.LineItem import LineItem from books.model.Address import Address from books.model.EmailHistory import EmailHistory from books.model.Email import Email from books.model.EmailTemplate import EmailTemplate from books.model.ToContact import ToContact from books.model.FromEmail import FromEmail from books.model.Template import Template from books.model.InvoiceCredited import InvoiceCredited from books.model.InvoiceCreditedList import InvoiceCreditedList from books.model.Invoice import Invoice from books.model.InvoiceList import InvoiceList from books.model.CreditNoteRefund import CreditNoteRefund from books.model.CreditNoteRefundList import CreditNoteRefundList from books.model.Comment import Comment from books.model.CommentList import CommentList class CreditNotesParser: """This class is used to parse the json for credit notes.""" def creditnotes_list(self,response): """This method parses the given response and creates a creditnotes list object. Args: response(dict):Response containing json object for credit notes list. Returns: instance: Creditnotes list object. """ credit_notes_list=CreditNoteList() credit_notes=[] for value in response['creditnotes']: credit_note=CreditNote() credit_note.set_creditnote_id(value['creditnote_id']) credit_note.set_creditnote_number(value['creditnote_number']) credit_note.set_status(value['status']) credit_note.set_reference_number(value['reference_number']) credit_note.set_date(value['date']) credit_note.set_total(value['total']) credit_note.set_balance(value['balance']) credit_note.set_customer_id(value['customer_id']) credit_note.set_customer_name(value['customer_name']) credit_note.set_currency_id(value['currency_id']) credit_note.set_currency_code(value['currency_code']) credit_note.set_created_time(value['created_time']) credit_note.set_last_modified_time(value['last_modified_time']) credit_note.set_is_emailed(value['is_emailed']) credit_notes.append(credit_note) credit_notes_list.set_creditnotes(credit_notes) page_context_obj=PageContext() page_context=response['page_context'] page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_applied_filter(page_context['applied_filter']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) credit_notes_list.set_page_context(page_context_obj) return credit_notes_list 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_message(self,response): """This method parses the json object and returns string message. Args: response(dict): Response containing json object. Returns: str: Success message. """ return response['message'] def email_history(self,response): """This method parses the json object and returns list of email \ history object. Args: response(dict): Response containing json object for email history. Returns: list of instance: List of email history object. """ email_history=[] for value in response['email_history']: email_history_obj=EmailHistory() email_history_obj.set_mailhistory_id(value['mailhistory_id']) email_history_obj.set_from(value['from']) email_history_obj.set_to_mail_ids(value['to_mail_ids']) email_history_obj.set_subject(value['subject']) email_history_obj.set_date(value['date']) email_history_obj.set_type(value['type']) email_history.append(email_history_obj) return email_history def email(self,response): """This method parses the response and returns email object. Args: response(dict): Response containing json object for email. Returns: instance: Email object. """ data=response['data'] email=Email() email.set_body(data['body']) email.set_error_list(data['error_list']) email.set_subject(data['subject']) for value in data['emailtemplates']: email_template=EmailTemplate() email_template.set_selected(value['selected']) email_template.set_name(value['name']) email_template.set_email_template_id(value['email_template_id']) email.set_email_templates(email) for value in data['to_contacts']: to_contact=ToContact() to_contact.set_first_name(value['first_name']) to_contact.set_selected(value['selected']) to_contact.set_phone(value['phone']) to_contact.set_email(value['email']) to_contact.set_last_name(value['last_name']) to_contact.set_salutation(value['salutation']) to_contact.set_contact_person_id(value['contact_person_id']) to_contact.set_mobile(value['mobile']) email.set_to_contacts(to_contact) email.set_file_name(data['file_name']) email.set_file_name_without_extension(\ data['file_name_without_extension']) for value in data['from_emails']: from_email=FromEmail() from_email.set_user_name(value['user_name']) from_email.set_selected(value['selected']) from_email.set_email(value['email']) from_email.set_is_org_email_id(value['is_org_email_id']) email.set_from_emails(from_email) email.set_customer_id(data['customer_id']) return email def get_billing_address(self,response): """This method parses the response containing json object for billing address. Args: response(dict): Response containing json object for billing address. Returns: instance: Address object. """ billing_address=response['billing_address'] billing_address_obj=Address() billing_address_obj.set_address(billing_address['address']) billing_address_obj.set_city(billing_address['city']) billing_address_obj.set_state(billing_address['state']) billing_address_obj.set_zip(billing_address['zip']) billing_address_obj.set_country(billing_address['country']) billing_address_obj.set_fax(billing_address['fax']) billing_address_obj.set_is_update_customer(\ billing_address['is_update_customer']) return billing_address_obj def get_shipping_address(self,response): """This method parses the json object and returns shipping address \ object. Args: response(dict): Response containing json object for shipping \ address. Returns: instance: Shipping address object. """ shipping_address=response['shipping_address'] shipping_address_obj=Address() shipping_address_obj.set_address(shipping_address['address']) shipping_address_obj.set_city(shipping_address['city']) shipping_address_obj.set_state(shipping_address['state']) shipping_address_obj.set_zip(shipping_address['zip']) shipping_address_obj.set_country(shipping_address['country']) shipping_address_obj.set_fax(shipping_address['fax']) shipping_address_obj.set_is_update_customer(\ shipping_address['is_update_customer']) return shipping_address_obj def list_templates(self,response): """This method parses the json object and returns templates list. Args: response(dict): Response containing json object for templates list. Returns: lsit of instance: Lsit of templates object. """ templates=[] for value in response['templates']: template=Template() template.set_template_name(value['template_name']) template.set_template_id(value['template_id']) template.set_template_type(value['template_type']) templates.append(template) return templates def list_invoices_credited(self,response): """This method parses the json object and returns list of invoices credited. Args: response(dict): Response containing json object for invoices credited. Returns: instance: Invoices credited list object. """ invoices_credited = InvoiceCreditedList() for value in response['invoices_credited']: invoice_credited = InvoiceCredited() invoice_credited.set_creditnote_id(value['creditnote_id']) invoice_credited.set_invoice_id(value['invoice_id']) invoice_credited.set_creditnotes_invoice_id(\ value['creditnote_invoice_id']) invoice_credited.set_date(value['date']) invoice_credited.set_invoice_number(value['invoice_number']) invoice_credited.set_creditnotes_number(value['creditnote_number']) invoice_credited.set_credited_amount(value['credited_amount']) invoices_credited.set_invoices_credited(invoice_credited) return invoices_credited def credit_to_invoice(self,response): """This method parses the given response and returns invoices object. Args: response(dict): Responses containing json object for credit to invoice. Returns: instance: Invoice List object. """ invoices = InvoiceList() for value in response['apply_to_invoices']['invoices']: invoice=Invoice() invoice.set_invoice_id(value['invoice_id']) invoice.set_amount_applied(value['amount_applied']) invoices.set_invoices(invoice) return invoices def creditnote_refunds(self,response): """This method parses the given response and returns credit notes refund list. Args: response(dict): Repsonse containing json object for credit notes list. Returns: instance: Creditnote list object. """ creditnotes_refund_list=CreditNoteRefundList() for value in response['creditnote_refunds']: creditnotes_refund=CreditNoteRefund() creditnotes_refund.set_creditnote_refund_id(\ value['creditnote_refund_id']) creditnotes_refund.set_creditnote_id(value['creditnote_id']) creditnotes_refund.set_date(value['date']) creditnotes_refund.set_refund_mode(value['refund_mode']) creditnotes_refund.set_reference_number(value['reference_number']) creditnotes_refund.set_creditnote_number(\ value['creditnote_number']) creditnotes_refund.set_customer_name(value['customer_name']) creditnotes_refund.set_description(value['description']) creditnotes_refund.set_amount_bcy(value['amount_bcy']) creditnotes_refund.set_amount_fcy(value['amount_fcy']) creditnotes_refund_list.set_creditnote_refunds(creditnotes_refund) page_context=response['page_context'] page_context_obj=PageContext() page_context_obj.set_page(page_context['page']) page_context_obj.set_per_page(page_context['per_page']) page_context_obj.set_has_more_page(page_context['has_more_page']) page_context_obj.set_report_name(page_context['report_name']) page_context_obj.set_sort_column(page_context['sort_column']) page_context_obj.set_sort_order(page_context['sort_order']) creditnotes_refund_list.set_page_context(page_context_obj) return creditnotes_refund_list def get_creditnote_refund(self,response): """This method parses the given repsonse and returns credit note refund object. Args: response(dict): Response containing json object for credit note refund. Returns: isntacne: Credit note object. """ creditnote_refund=response['creditnote_refund'] creditnote_refund_obj=CreditNoteRefund() creditnote_refund_obj.set_creditnote_refund_id(\ creditnote_refund['creditnote_refund_id']) creditnote_refund_obj.set_creditnote_id(\ creditnote_refund['creditnote_id']) creditnote_refund_obj.set_date(creditnote_refund['date']) creditnote_refund_obj.set_refund_mode(creditnote_refund['refund_mode']) creditnote_refund_obj.set_reference_number(\ creditnote_refund['reference_number']) creditnote_refund_obj.set_amount(creditnote_refund['amount']) creditnote_refund_obj.set_exchange_rate(\ creditnote_refund['exchange_rate']) creditnote_refund_obj.set_from_account_id(\ creditnote_refund['from_account_id']) creditnote_refund_obj.set_from_account_name(\ creditnote_refund['from_account_name']) creditnote_refund_obj.set_description(creditnote_refund['description']) return creditnote_refund_obj def comments_list(self,response): """This method parses the given response and returns the comments list. Args: response(dict): Response containing json object for comments list. Returns: list of instance: List of comments object. """ comments_list = CommentList() for value in response['comments']: comment = Comment() comment.set_comment_id(value['comment_id']) comment.set_creditnote_id(value['creditnote_id']) comment.set_description(value['description']) comment.set_commented_by_id(value['commented_by_id']) comment.set_commented_by(value['commented_by']) comment.set_comment_type(value['comment_type']) comment.set_date(value['date']) comment.set_date_description(value['date_description']) comment.set_time(value['time']) comment.set_operation_type(value['operation_type']) comment.set_transaction_id(value['transaction_id']) comment.set_transaction_type(value['transaction_type']) comments_list.set_comments(comment) return comments_list def get_comment(self,response): """This method parses the given response and returns comments object. Args: response(dict): Response containing json object for comments. Returns: instance: Comments object. """ comment=response['comment'] comment_obj=Comment() comment_obj.set_comment_id(comment['comment_id']) comment_obj.set_creditnote_id(comment['creditnote_id']) comment_obj.set_description(comment['description']) comment_obj.set_commented_by_id(comment['commented_by_id']) comment_obj.set_commented_by(comment['commented_by']) comment_obj.set_date(comment['date']) return comment_obj
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/parser/CreditNotesParser.py
CreditNotesParser.py
from json import loads from mimetypes import guess_type from random import choice from re import search from string import digits, ascii_letters from urllib.parse import urlencode from httplib2 import Http from books.exception.BooksException import BooksException _BOUNDARY_CHARS = digits + ascii_letters class ZohoHttpClient: """This class is used to create get, post, put and delete connections for the request.""" def get(self, url, details, query=None): """This method is used to make get request for the given url and query string. Args: url(str): Url passed by the user. details(dict): Dictionary containing authtoken and organization id. query(dict, optional): Additional parameters. Default to None. Returns: dict: Dictionary containing response content. """ http, headers = get_http_connection(details['authtoken']) if 'organization_id' in details and details['organization_id'] != '': url = url + '?' + form_query_string({'organization_id': details['organization_id']}) if query is not None: url += '&' + form_query_string(query) print("URL: {}".format(url)) resp, content = http.request(url, 'GET', headers=headers) response = get_response(resp['status'], content) return response def getfile(self, url, details, query=None): """This method is used to make get request for the given url and query string. Args: url(str): Url passed by the user. details(dict): Dictionary containing authtoken and organization id. query(dict, optional): Additional parameters. Default to None. Returns: dict: Dictionary containing response content. """ http = Http(timeout=60 * 1000) url = url + '?' + form_query_string(details) if query is not None: url += '&' + form_query_string(query) headers = { 'Accept': \ 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Content-type': 'application/x-www-form-urlencoded', 'User-Agent': 'ZohoBooks-Python-Wrappers/1.0', 'Accept-Charset': 'UTF-8' } resp, content = http.request(url, 'GET', headers=headers) if resp['status'] == '200' or resp['status'] == '201': attachment = resp['content-disposition'] regex = search(r'".*"', attachment) filename = regex.group().strip('"') if regex is not None else \ 'attachment.' + query['accept'] file_location = "/home/likewise-open/ZOHOCORP/chitra-2327/Downloads/" file_name = open(file_location + filename, "w") file_name.write(content) file_name.close() return file_name else: raise BooksException(convert(loads(content))) def post(self, url, details, field, query_string=None, attachment=None): """This method is used to make post request for the given url and query string. Args: url(str): Url passed by the user. details(dict): Dictionary containing authtoken and organization id. data(dict): Dictionary containing required parameters. query(dict, optional): Additional parameters. Default to None. attachment(dict, None): Files to be attached. Default to None. Returns: dict: Dictionary containing response content. """ http, headers = get_http_connection(details['authtoken']) url = url + '?' + form_query_string({'organization_id': details['organization_id']}) if query_string is not None: url = url + '&' + form_query_string(query_string) print("URL: {}".format(url)) print("Body: {}".format(field)) if attachment is None: body = urlencode(field) else: body, headers_to_be_appended = encode_multipart(field, attachment) headers = {**headers, **headers_to_be_appended} resp, content = http.request(url, 'POST', headers=headers, body=body) response = get_response(resp['status'], content) return response def put(self, url, details, field, query=None, attachment=None): """This method is used to make put request for the given url and query string. Args: url(str): Url passed by the user. details(dict): Dictionary containing authtoken and organization id. data(dict): Dictionary containing required parameters. query(dict, optional): Additional parameters. Default to None. attachment(dict, None): Files to be attached. Default to None. Returns: tuple: Tuple containing response status(str) and content(dict). """ http, headers = get_http_connection(details['authtoken']) url = url + '?' + form_query_string(details) if query is not None: url = url + '&' + form_query_string(query) print("URL: {}".format(url)) print("Body: {}".format(field)) if attachment is None: body = urlencode(field) else: body, headers = encode_multipart(field, attachment) resp, content = http.request(url, 'PUT', headers=headers, body=body) # print content response = get_response(resp['status'], content) return response def delete(self, url, details, param=None): """This method is used to make delete request for the given url and query string. Args: url(str): Url passed by the user. details(dict): Dictionary containing authtoken and organization id. param(dict): Parameters to be passed in query string. Returns: tuple: Tuple containing response status(str) and content(dict). """ http, headers = get_http_connection(details['authtoken']) url = url + '?' + form_query_string(details) if param is not None: url = url + '&' + form_query_string(param) response, content = http.request(url, 'DELETE', headers=headers) # print content response = get_response(response['status'], content) return response def form_query_string(parameter): """This method is used to form query string. Args: parameter(dict): Parameters to be converted to query string. Returns: str: Query string. """ query = '' length = len(parameter) for key, value in list(parameter.items()): length = length - 1 query += str(key) + '=' + str(value) if length != 0: query += '&' return query def encode_multipart(fields, file_list, boundary=None): """This method is used to encode multipart data. Args: fields(dict): Parameters in key value pair. files(dict): Files to be attached. boundary(str, optional): Boundary. Default to None. Returns: tuple: Tuple containing body(list) and headers(dict). """ def escape_quote(s): return s.replace('"', '\\"') if boundary is None: boundary = ''.join(choice(_BOUNDARY_CHARS) for i in range(30)) lines = [] if fields['JSONString'] != '""': for name, value in list(fields.items()): lines.extend(('--{0}'.format(boundary), 'Content-Disposition: form-data; name="{0}"' \ .format(escape_quote(name)), '', str(value), )) for files in file_list: for name, value in list(files.items()): filename = value['filename'] if 'mimetype' in value: mimetype = value['mimetype'] else: mimetype = guess_type(filename)[0] or \ 'application/octet-stream' lines.extend(('--{0}'.format(boundary), \ 'Content-Disposition: form-data; name="{0}";filename="{1}"' \ .format(escape_quote(name), escape_quote(filename)), 'Content-Type: {0}'.format(mimetype), '', value['content'], )) lines.extend(('--{0}--'.format(boundary), '',)) body = '\r\n'.join(lines) headers = { 'Content-Type': 'multipart/form-data; boundary={0}' \ .format(boundary), 'Content-Length': str(len(body)), } return (body, headers) def convert(input): """This method is used to convert unicode objects into strings. Args: input(dict): dictionary of unicode objects Returns: dict: dictionary of string """ if isinstance(input, dict): return {convert(key): convert(value) for key, value in \ input.items()} elif isinstance(input, list): return [convert(element) for element in input] elif isinstance(input, str): return input.encode('utf-8') else: return input def get_response(status, content): """This method checks the status code and returns respective response message or exception. Args: status(str): Response status code. content(dict): Dictionary containing code and message. Returns: dict: Response message Raises: Books Exception: If status is not '200' or '201'. """ resp = loads(content) response = resp if status != '200' and status != '201': raise BooksException(response) else: return response def get_http_connection(oauth_token): http = Http(timeout=60 * 1000) headers = { 'Accept': 'application/json', 'Content-type': 'application/x-www-form-urlencoded', 'User-Agent': 'ZohoBooks-Python-Wrappers/1.0', 'Accept-Charset': 'UTF-8', 'Authorization': 'Zoho-oauthtoken {}'.format(oauth_token) } return http, headers
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/util/ZohoHttpClient.py
ZohoHttpClient.py
class Comment: """This class is used to create object for comments.""" def __init__(self): """Initialize parameters for comments.""" self.comment_id = '' self.contact_id = '' self.contact_name = '' self.description = '' self.commented_by_id = '' self.commented_by = '' self.date = '' self.date_description = '' self.time = '' self.transaction_id = '' self.transaction_type = '' self.is_entity_deleted = None self.operation_type = '' self.estimate_id = '' self.comment_type = '' self.invoice_id = '' self.payment_expected_date = '' self.show_comment_to_clients = None self.recurring_invoice_id = '' self.creditnote_id = '' self.expense_id = '' self.recurring_expense_id = '' self.bill_id = '' self.project_id = '' self.is_current_user = None def set_is_current_user(self, is_current_user): """Set whether it is current user or not. Args: is_current_user(bool): True if it is current user else false. """ self.is_current_user = is_current_user def get_is_current_user(self): """Get whether it is current user or not. Returns: bool: True if it is current user else false. """ return self.is_current_user def set_comment_id(self, comment_id): """Set comment id. Args: comment_id(str): Comment id. """ self.comment_id = comment_id def get_comment_id(self): """Get comment id. Returns: str: Comment id. """ return self.comment_id def set_contact_id(self, contact_id): """Set contact id. Args: contact_id(str): Contact id. """ self.contact_id = contact_id def get_contact_id(self): """Get contact id. Returns: str: Contact id. """ return self.contact_id 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_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get descritpion. Returns: str: Description. """ return self.description def set_commented_by_id(self, commented_by_id): """Set commented by id. Args: commented_by_id(str): Commented by id. """ self.commented_by_id = commented_by_id def get_commented_by_id(self): """Get commented by id. Returns: str: Commented by id. """ return self.commented_by_id def set_commented_by(self, commented_by): """Set commented by. Args: commented_by(str): Commented by. """ self.commented_by = commented_by def get_commented_by(self): """Get commented by. Returns: str: Commented by. """ return self.commented_by def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_date_description(self, date_description): """Set date description. Args: date_description(str): Date description. """ self.date_description = date_description def get_date_description(self): """Get date description. Returns: str: Date description. """ return self.date_description def set_time(self, time): """Set time. Args: time(str): Time. """ self.time = time def get_time(self): """Get time. Returns: str: Time. """ return self.time def set_transaction_id(self, transaction_id): """Set transaction id. Args: transaction_id(str): Transaction id. """ self.transaction_id = transaction_id def get_transaction_id(self): """Get transaction id. Returns: str: Transaction id. """ return self.transaction_id def set_transaction_type(self, transaction_type): """Set transaction type. Args: transaction_type(str): Transaction type. """ self.transaction_type = transaction_type def get_transaction_type(self): """Get transaction type. Returns: str: Transaction type. """ return self.transaction_type def set_is_entity_deleted(self, is_entity_deleted): """Set whether entity is deleted or not. Args: is_entity_deleted(bool): True if entity is deleted else False. """ self.is_entity_deleted = is_entity_deleted def get_is_entity_deleted(self): """Get whether entity is deleted or not. Returns: bool: True if entity is deleted else False. """ return self.is_entity_deleted def set_operation_type(self, operation_type): """Set operation type. Args: operatipon_type(str): Operation type. """ self.operation_type = operation_type def get_operation_type(self): """Get operation type. Returns: str: Operation type. """ return self.operation_type def set_comment_type(self, comment_type): """Set comment type. Args: comment_type(Str): Comment type. """ self.comment_type = comment_type def get_comment_type(self): """Get comment type. Returns: str: Comment type. """ return self.comment_type def set_estimate_id(self, estimate_id): """Set estimate id. Args: estimate_id(str): Estimate id. """ self.estimate_id = estimate_id def get_estimate_id(self): """Get estimate id. Returns: str: Estimate id. """ return self.estimate_id def set_invoice_id(self, invoice_id): """Set invoice id. Args: invoice_id(str): Invoice id. """ self.invoice_id = invoice_id def get_invoice_id(self): """Get invoice id. Returns: str: Invoice id. """ return self.invoice_id def set_payment_expected_date(self, payment_expected_date): """Set payment expected date. Args: payment_expected_date(str): Payment expected date. """ self.payment_expected_date = payment_expected_date def get_payment_expected_date(self): """Get payment expected date. Returns: str: Payment expected date. """ return self.payment_expected_date def set_show_comment_to_clients(self, show_comment_to_clients): """Set whether to show comment to clients. Args: show_comment_to_client(bool): True to show comment to clients else False. """ self.show_comment_to_clients = show_comment_to_clients def get_show_comment_to_clients(self): """Get whether to show comment to clients. Returns: bool: True to show comment to clients else False. """ return self.show_comment_to_clients def set_recurring_invoice_id(self, recurring_invoice_id): """Set recurring invoice id. Args: recurring_invoice_id(str): Recurring invoice id. """ self.recurring_invoice_id = recurring_invoice_id def get_recurring_invoice_id(self): """Get recurring invoice id. Returns: str: Recurring invoice id. """ return self.recurring_invoice_id def set_creditnote_id(self, creditnote_id): """Set creditnote id. Args: creditnote_id (str): Creditnote id. """ self.creditnote_id = creditnote_id def get_creditnote_id(self): """Get creditnote id. Args: str: Creditnote id. """ return self.creditnote_id def set_expense_id(self, expense_id): """Set expense id. Args: expense_id(str): Expense id. """ self.expense_id = expense_id def get_expense_id(self): """Get expense id. Returns: str: Expense id. """ return self.expense_id def set_recurring_expense_id(self, recurring_expense_id): """Set recurring expense id. Args: recurring_expense_id(str): Recurring expense id. """ self.recurring_expense_id = recurring_expense_id def get_recurring_expense_id(self): """Get recurring expense id. Returns: str: Recurring expense id. """ return self.recurring_expense_id def set_bill_id(self, bill_id): """Set bill id. Args: bill_id(str): Bill id. """ self.bill_id = bill_id def get_bill_id(self): """Get bill id. Returns: str: Bill id. """ return self.bill_id def set_project_id(self, project_id): """Set project id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Comment.py
Comment.py
class InvoicePayment: """This class is used to create object for Invoice Payments.""" def __init__(self): """Initialize parameters for Invoice payments.""" self.invoice_payment_id = '' self.payment_id = '' self.invoice_id = '' self.amount_used = 0.0 self.amount_applied = 0.0 self.payment_number = '' self.payment_mode = '' self.description = '' self.date = '' self.reference_number = '' self.exchange_rate = 0.00 self.amount = 0.00 self.tax_amount_withheld = 0.0 self.is_single_invoice_payment = None def set_invoice_payment_id(self, invoice_payment_id): """Set invoice payment id. Args: invoice_payment_id(str): Invoice payment id. """ self.invoice_payment_id = invoice_payment_id def get_invoice_payment_id(self): """Get invoice payment id. Returns: str: Invoice payment id. """ return self.invoice_payment_id def set_invoice_id(self, invoice_id): """Set invoice id. Args: invoice_id(str): Invoice id. """ self.invoice_id = invoice_id def get_invoice_id(self): """Get invoice id. Returns: str: Invoice id. """ return self.invoice_id def set_payment_id(self, payment_id): """Set payment id. Args: payment_id(str): Payment id. """ self.payment_id = payment_id def get_payment_id(self): """Get payment id. Returns: str: Payment id. """ return self.payment_id def set_amount_applied(self, amount_applied): """Set amount applied. Args: amount_applied(float): Amount applied. """ self.amount_applied = amount_applied def get_amount_applied(self): """Get amount applied. Returns: float: Amount applied. """ return self.amount_applied def set_amount_used(self, amount_used): """Set amount used. Args: amount_used(float): Amount used. """ self.amount_used = amount_used def get_amount_used(self): """Get amount used. Returns: float: Amount used. """ return self.amount_used def set_payment_number(self, payment_number): """Set payment number. Args: payment_number(str): Payment number. """ self.payment_number = payment_number def get_payment_number(self): """Get payment number. Returns: str: Payment number. """ return self.payment_number def set_payment_mode(self, payment_mode): """Set payment mode. Args: payment_mode(str): Payment mode. """ self.payment_mode = payment_mode def get_payment_mode(self): """Get payment mode. Returns: str: Payment mode. """ return self.payment_mode def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_tax_amount_withheld(self, tax_amount_withheld): """Set tax amount withheld. Args: tax_amount_withheld(float): Tax amount withheld. """ self.tax_amount_withheld = tax_amount_withheld def get_tax_amount_withheld(self): """Get tax amount withheld. Returns: float: Tax amount withheld. """ return self.tax_amount_withheld def set_is_single_invoice_payment(self, is_single_invoice_payment): """Set whether it is single invoice payment. Args: is_single_invoice_payment(bool): True if it is single invoice payment else False. """ self.is_single_invoice_payment = is_single_invoice_payment def get_is_single_invoice_payment(self): """Get whether it is single invoice payment. Returns: bool: True if it is single invoice payment else False. """ return self.is_single_invoice_payment
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/InvoicePayment.py
InvoicePayment.py
class Transaction: """This class is used to create object for transaction.""" def __init__(self): """Initialize parameters for transactions object.""" self.transaction_id = '' self.debit_or_credit = '' self.date = '' self.customer_id = '' self.payee = '' self.reference_number = '' self.transaction_type = '' self.amount = '' self.status = '' self.date_formatted = '' self.transaction_type_formatted = '' self.amount_formatted = '' self.customer_name = '' self.from_account_id = '' self.from_account_name = '' self.to_account_id = '' self.to_account_name = '' self.currency_id = '' self.currency_code = '' self.payment_mode = '' self.exchange_rate = 0.0 self.reference_number = '' self.description = '' self.imported_transaction_id = '' self.associated_transactions = [] self.categorized_transaction_id = '' self.transaction_date = '' self.account_id = '' self.entry_number = '' self.offset_account_name = '' self.reconcile_status = '' self.debit_amount = 0.0 self.credit_amount = 0.0 self.source = '' self.imported_transactions = [] self.status_formatted = '' def set_imported_transaction_id(self, imported_transaction_id): """Set imported transaction id. Args: imported_transaction_id(str): Imported transaction id. """ self.imported_transaction_id = imported_transaction_id def get_imported_transaction_id(self): """Get imported transaction id. Returns: str: Imported transaction id. """ return self.imported_transaction_id def set_transaction_id(self, transaction_id): """Set transaction id. Args: transaction_id(str): Transaction_id. """ self.transaction_id = transaction_id def get_transaction_id(self): """Get transaction id. Returns: str: Transaction id. """ return self.transaction_id def set_debit_or_credit(self, debit_or_credit): """Set whether debit or credit. Args: debit_or_credit(str): Debit or credit. """ self.debit_or_credit = debit_or_credit def get_debit_or_credit(self): """Get whether debit or credit. Returns: str: Debit or credit. """ return self.debit_or_credit def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(self): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_payee(self, payee): """Set payee. Args: payee(str): Payee. """ self.payee = payee def get_payee(self): """Get payee. Returns: str: Payee. """ return self.payee def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_transaction_type(self, transaction_type): """Set transaction type. Args: transaction_type(str): Transaction type. """ self.transaction_type = transaction_type def get_transaction_type(self): """Get transaction type. Returns: str: Transaction type. """ return self.transaction_type def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_date_formatted(self, date_formatted): """Set date formatted. Args: date_formatted(str): Date formatted. """ self.date_formatted = date_formatted def get_date_formatted(self): """Get date formatted. Returns: str: Date formatted. """ def set_transaction_type_formatted(self, transaction_type_formatted): """Set transaction type formatted. Args: transaction_type_formatted(str): Transaction type formatted. """ self.transaction_type_formatted = transaction_type_formatted def get_transaction_type_formatted(self): """Get transaction type formatted. Returns: str: Transaction type formatted. """ return self.transaction_type_formatted def set_amount_formatted(self, amount_formatted): """Set amount formatted. Args: amount_formatted(str): Amount formatted. """ self.amount_formatted = amount_formatted def get_amount_formatted(self): """Get amount formatted. Returns: str: Amount formatted. """ return self.amount_formatted def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_from_account_id(self, from_account_id): """Set from account id. Args: from_account_id(str): From account id. """ self.from_account_id = from_account_id def get_from_account_id(self): """Get from account id. Returns: str: From account id. """ return self.from_account_id def set_from_account_name(self, from_account_name): """Set from account name. Args: from_account_name(str): From account name. """ self.from_account_name = from_account_name def get_from_account_name(self): """Get from account name. Returns: str: From account name. """ return self.from_account_name def set_to_account_id(self, to_account_id): """Set to account id. Args: to_account_id(str): To account id. """ self.to_account_id = to_account_id def get_to_account_id(self): """Get to account id. Returns: str: To account id. """ return self.to_account_id def set_to_account_name(self, to_account_name): """Set to account name. Args: to_account_name(str): To account name. """ self.to_account_name = to_account_name def get_to_account_name(self): """Get to account name. Returns: str: To account name. """ return self.to_account_name def set_currency_id(self, currency_id): """Set currency id. Args: currency_id(str): Currency id. """ self.currecny_id = currency_id def get_currency_id(self): """Get currency id. Returns: str: Currecny id. """ return self.currency_id def set_currency_code(self, currency_code): """Set currecny code. Args: currency_code(str): Currecny code. """ self.currecy_code = currency_code def get_currency_code(self): """Get currecny code. Returns: str: Currecny code. """ return self.currecny_code def set_payment_mode(self, payment_mode): """Set payment mode. Args: payment_mode(str): Payment mode. """ self.payment_mode = payment_mode def get_payment_mode(self): """Get payment mode. Returns: str: Payment mode. """ return self.payment_mode def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchaneg_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_currency_id(self, currency_id): """Set currency id. Args: currency_id(str): Currency id. """ self.currecny_id = currency_id def get_currency_id(self): """Get currecny 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_currecny_code(self): """Get currecny code. Returns: str: Currency code. """ return self.currency_code def set_payment_mode(self, payment_mode): """Set payment mode. Args: payment_mode(str): Payment mode. """ self.payment_mode = payment_mode def get_payment_mode(self): """Get payment mode. Returns: str: Payment mode. """ return self.payment_mode def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_associated_transactions(self, transactions): """Set associated transacctions. Args: transactions(instance): Transaction object. """ self.associated_transactions.append(transactions) def get_associated_transactions(self): """Get associated transactions. Returns: list of instance: List of transactions object. """ return self.associated_transactions def set_categorized_transaction_id(self, categorized_transaction_id): """Set categorized transaction id. Args: categorized_transaction_id(str): Categorized transaction id. """ self.categorized_transaction_id = categorized_transaction_id def get_categorized_transaction_id(self): """Get categorized transaction id. Returns: str: Categorized transaction id. """ return self.categorized_transaction_id def set_transaction_date(self, transaction_date): """Set transaction date. Args: transaction_date(str): Transaction date. """ self.transaction_date = transaction_date def get_transaction_date(self): """Get transaction date. Returns: str: Transaction date. """ return self.transaction_date def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_entry_number(self, entry_number): """Set entry number. Args: entry_number(str): Entry number. """ self.entry_number = entry_number def get_entry_number(self): """Get entry number. Returns: str: Entry number. """ return self.entry_number def set_offset_account_name(self, offset_account_name): """Set offset account name. Args: offset_account_name(str): Offset account name. """ self.offset_account_name = offset_account_name def get_offset_account_name(self): """Get offset_account_name. Returns: str: Offset account name. """ return self.offset_account_name def set_reconcile_status(self, reconcile_status): """Set reconcile status. Args: reconcile_status(str): Reconcile status. """ self.reconcile_status = reconcile_status def get_reconcile_status(self): """Get reconcile status. Returns: str: Reconcile status. """ return self.reconcile_status def set_debit_amount(self, debit_amount): """Set debit amount. Args: debit_amount(float): Debit amount. """ self.debit_amount = debit_amount def get_debit_amount(self): """Get debit amount. Returns: float: Debit amount. """ return self.debit_amount def set_credit_amount(self, credit_amount): """Set ccredit amount. Args: credit_amount(flaot): Credit amount. """ self.credit_amount = credit_amount def get_credit_amount(self): """Get credit amount. Returns: float: Credit amount. """ return self.credit_amount def set_source(self, source): """Set source. Args: source(str): Source. """ self.source = source def get_source(self): """Get source. Returns: str: Source. """ return self.source def set_imported_transaction(self, imported_transactions): """Set imported transactions. Args: imported_transaction: Imported transaction. """ self.imported_transactions.append(imported_transactions) def get_imported_transaction(self): """Get imported transactions. Returns: list: List of imported transactions. """ return self.imported_transactions def set_status_formatted(self, status_formatted): """Set status formatted. Args: status_formatted(str): Status formatted. """ self.status_formatted = status_formatted def get_status_formatted(self): """Get status formatted. Returns: str: Status formatted. """ return self.status_formatted def to_json(self): """This method is used to convert taransaction object to json format. Returns: dict: Dictionary containing json object for transaction. """ data = {} if self.from_account_id != '': data['from_account_id'] = self.from_account_id if self.to_account_id != '': data['to_account_id'] = self.to_account_id if self.transaction_type != '': data['transaction_type'] = self.transaction_type if self.amount > 0: data['amount'] = self.amount if self.payment_mode != '': data['payment_mode'] = self.payment_mode if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.date != '': data['date'] = self.date if self.customer_id != '': data['customer_id'] = self.customer_id if self.reference_number != '': data['reference_number'] = self.reference_number if self.description != '': data['description'] = self.description if self.currency_id != '': data['currency_id'] = self.currency_id return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Transaction.py
Transaction.py
class InvoiceCredited: """This class is used to create objecctfor Invoices Credited.""" def __init__(self): """Initialize parameters for Invoices credited.""" self.creditnote_id = '' self.invoice_id = '' self.creditnotes_invoice_id = '' self.date = '' self.invoice_number = '' self.creditnotes_number = '' self.credited_amount = 0.0 self.credited_date = '' self.amount_applied = 0.0 def set_creditnote_id(self, creditnote_id): """Set credit note id. Args: creditnote_id(str): Credit note id. """ self.creditnote_id = creditnote_id def get_creditnote_id(self): """Get credit note id. Returns: str: Credit note id. """ return self.creditnote_id def set_invoice_id(self, invoice_id): """Set invoice id. Args: invoice_id(str): Invoice id. """ self.invoice_id = invoice_id def get_invoice_id(self): """Get invoice id. Returns: str: Invoice id. """ return self.invoice_id def set_creditnotes_invoice_id(self, creditnotes_invoice_id): """Set credit note invoice id. Args: creditnotes_invoice_id(str): Credditnote invoice id. """ self.creditnotes_invoice_id = creditnotes_invoice_id def get_creditnotes_invoice_id(self): """Get creditnotes invoice id. Returns: str: Creditnotes invoice id. """ return self.creditnotes_invoice_id def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_invoice_number(self, invoice_number): """Set invoice number. Args: invoice_number(str): Invoice number. """ self.invoice_number = invoice_number def get_invoice_number(self): """Get invoice number. Returns: str: Invoice number. """ return self.invoice_number def set_creditnotes_number(self, creditnotes_number): """Set creditnote number. Args: creditnote_number(str): Creditnote number. """ self.creditnotes_number = creditnotes_number def get_creditnotes_number(self): """Get creditnote number. Returns: str: Creditnote number. """ return self.creditnotes_number def set_credited_amount(self, credited_amount): """Set credited amount. Args: credited_amount(float): Credited amount. """ self.credited_amount = credited_amount def get_credited_amount(self): """Get credited amount. Returns: float: Credited amount. """ return self.credited_amount def set_credited_date(self, credited_date): """Set credited date. Args: credited_date(str): Credited date. """ self.credited_date = credited_date def get_credited_date(self): """Get credited date. Returns: str: Credited date. """ return self.credited_date def set_amount_applied(self, amount_applied): """Set amount applied. Args: amount_applied(float): Amount applied. """ self.amount_applied = amount_applied def get_amount_applied(self): """Get amount applied. Returns: float: Amount applied. """ return self.amount_applied
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/InvoiceCredited.py
InvoiceCredited.py
class BaseCurrencyAdjustment: """This class is used to create object for Base Currency adjustment.""" def __init__(self): """Initialize parameters for Base currency adjustment.""" self.base_currency_adjustment_id = '' self.adjustment_date = '' self.exchange_rate = 0.0 self.exchange_rate_formatted = '' self.currency_id = '' self.currency_code = '' self.notes = '' self.gain_or_loss = 0.0 self.adjustment_date_formatted = '' self.accounts = [] def set_base_currency_adjustment_id(self, base_currency_adjustment_id): """Set base currency adjustment id. Args: base_currency_adjustment_id(str): Base currency adjustment id. """ self.base_currency_adjustment_id = base_currency_adjustment_id def get_base_currency_adjustment_id(self): """Get base currency adjustment id. Returns: str: Base currency adjustment id. """ return self.base_currency_adjustment_id def set_adjustment_date(self, adjustment_date): """Set adjustment date. Args: adjustment_date(str): Adjustment date. """ self.adjustment_date = adjustment_date def get_adjustment_date(self): """Get adjustment date. Returns: str: Adjustment date. """ return self.adjustment_date def set_exchange_rate(self, exchange_rate): """Set exchaneg rate. Args: exchaneg_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_exchange_rate_formatted(self, exchange_rate_formatted): """Set exchange rate formatted. Args: exchange_rate_formatted(str): Exchange rate formatted. """ self.exchange_rate_formatted = exchange_rate_formatted def get_exchange_rate_formatted(self): """Get exchange rate formatted. Returns: str: Exchange rate formatted. """ return self.exchange_rate_formatted 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 currecny code. Returns: str: Currency code. """ return self.currency_code def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_gain_or_loss(self, gain_or_loss): """Set gain or loss. Args: gain_or_loss(float): Gain or loss. """ self.gain_or_loss = gain_or_loss def get_gain_or_loss(self): """Get gain or loss. Returns: float: Gain or loss. """ return self.gain_or_loss def set_adjustment_date_formatted(self, adjustment_date_formatted): """Set adjustment date formatted. Args: adjustment_date_formatted(str): Adjustment date formatted. """ self.adjustment_date_formatted = adjustment_date_formatted def get_adjustment_date_foramtted(self): """Get adjustment date formatted. Returns: str: Adjustment date formatted. """ return self.adjustment_date_formatted def set_accounts(self, accounts): """Set accounts. Args: accounts(instance): Accounts. """ self.accounts.append(accounts) def get_accounts(self): """Get accounts. Returns: instance: Accounts. """ return self.accounts def to_json(self): """This method is used to convert base currency adjusment object in json format. Returns: dict: Dictionary containing json object for base currency adjustment. """ data = {} if self.currency_id != '': data['currency_id'] = self.currency_id if self.adjustment_date != '': data['adjustment_date'] = self.adjustment_date if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.notes != '': data['notes'] = self.notes return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/BaseCurrencyAdjustment.py
BaseCurrencyAdjustment.py
class Account: """This class is used to create object for accounts object.""" def __init__(self): """Initialize parameters for Accounts.""" self.account_id = '' self.account_name = '' self.bcy_balance = 0.0 self.bcy_balance_formatted = '' self.fcy_balance = 0.0 self.fcy_balance_formatted = '' self.adjusted_balance = 0.0 self.adjusted_balance_formatted = '' self.gain_or_loss = 0.0 self.gain_or_loss_formatted = '' self.gl_specific_type = 0 self.account_split_id = '' self.debit_or_credit = '' self.exchange_rate = 0.0 self.currency_id = '' self.currency_code = '' self.bcy_amount = 0.0 self.amount = 0.0 def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_bcy_balance(self, bcy_balance): """Set bcy balance. Args: bcy_balance(float): Bcy balance. """ self.bcy_balance = bcy_balance def get_bcy_balance(self): """Get bcy balance. Returns: float: Bcy balance. """ return self.bcy_balance def set_bcy_balance_formatted(self, bcy_balance_formatted): """Set bcy balance formatted. Args: bcy_balance_formatted(str): Bcy balance formatted. """ self.bcy_balance_formatted = bcy_balance_formatted def get_bcy_balance_formatted(self): """Get bcy balance formatted. Returns: str: Bcy balance formatted. """ return self.bcy_balance_formatted def set_fcy_balance(self, fcy_balance): """Set fcy balance. Args: fcy_balance(float): Fcy balance. """ self.fcy_balance = fcy_balance def get_fcy_balance(self): """Get fcy balance. Returns: float: Fcy balance. """ return self.fcy_balance def set_fcy_balance_formatted(self, fcy_balance_formatted): """Set fcy balance formatted. Args: fcy_balance_formatted(str): Fcy balance formatted. """ self.fcy_balance_formatted = fcy_balance_formatted def get_fcy_balance_formatted(self): """Get fcy balance formatted. Returns: str: Fcy balance formatted. """ return self.fcy_balance_formatted def set_adjsuted_balance(self, adjusted_balance): """Set adjusted balance. Args: adjusted_balance(float): Adjusted balance. """ self.adjusted_balance = adjusted_balance def get_adjusted_balance(self): """Get adjusted balance. Returns: float: Adjusted balance. """ return self.adjusted_balance def set_adjusted_balance(self, adjusted_balance): """Set adjusted balance. Args: adjusted_balance(float): Adjusted balance. """ self.adjusted_balance = adjusted_balance def get_adjusted_balance(self): """Get adjusted balance. Returns: float: Adjusted balance. """ return self.adjusted_balance def set_adjusted_balance_formatted(self, adjusted_balance_formatted): """Set adjusted balance formatted. Args: adjusted_balance_formatted(str): Adjusted balance formatted. """ self.adjusted_balance_formatted = adjusted_balance_formatted def get_adjusted_balance_formatted(self): """Get adjusted balance formatted. Returns: str: Adjusted balance formatted. """ return self.adjusted_balance_formatted def set_gain_or_loss(self, gain_or_loss): """Set gain or loss. Args: gain_or_loss(float): Gain or loss. """ self.gain_or_loss = gain_or_loss def get_gain_or_loss(self): """Get gain or loss. Returns: float: Gain or loss. """ return self.gain_or_loss def set_gain_or_loss_formatted(self, gain_or_loss_formatted): """Set gain or loss formatted. Args: gain_or_loss_formatted(str): Gain or loss formatted. """ self.gain_or_loss_formatted = gain_or_loss_formatted def get_gain_or_loss_formatted(self): """Get gain or loss formatted. Returns: str: Gain or loss formatted. """ return self.gain_or_loss_formatted def set_gl_specific_type(self, gl_specific_type): """Set gl specific type. Args: gl_specific_type(int): Gl specific type. """ self.gl_specific_type = gl_specific_type def get_gl_specific_type(self): """Get gl specific type. Returns: int: Gl specific type. """ return self.gl_specific_type def set_account_split_id(self, account_split_id): """Set account split id. Args: account_split_id(str): Account split id. """ self.account_split_id = account_split_id def get_account_split_id(self): """Get account split id. Returns: str: Account split id. """ return self.account_split_id def set_debit_or_credit(self, debit_or_credit): """Set debit or credit. Args: debit_or_credit(str): Debit or credit. """ self.debit_or_credit = debit_or_credit def get_debit_or_credit(self): """Get debit or credit. Returns: str: Debit or credit. """ return self.debit_or_credit def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_currency_id(self, currency_id): """Set currency id. Args: str: Currecny 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_bcy_amount(self, bcy_amount): """Set bcy amount. Args: bcy_amount(float): Bcy amount. """ self.bcy_amount = bcy_amount def get_bcy_amount(self): """Get bcy amount. Returns: float: Bcy amount. """ return self.bcy_amount def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def to_json(self): """This method is used to create json object for accounts. Returns: dict: Dictionary containing json object for accounts. """ data = {} if self.account_id != '': data['account_id'] = self.account_id if self.debit_or_credit != '': data['debit_or_credit'] = self.debit_or_credit if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.currency_id != '': data['currency_id'] = self.currency_id if self.amount > 0: data['amount'] = self.amount return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Account.py
Account.py
class TaxGroup: """This class is used to create object for tax group.""" def __init__(self): """Initialize parameters for tax group. """ self.tax_group_id = '' self.tax_group_name = '' self.tax_group_percentage = 0 self.taxes = '' def set_tax_group_id(self, tax_group_id): """Set tax group id. Args: tax_group_id(str): Tax group id. """ self.tax_group_id = tax_group_id def get_tax_group_id(self): """Get tax group id. Returns: str: Tax group id. """ return self.tax_group_id def set_tax_group_name(self, tax_group_name): """Set tax group name. Args: tax_group_name(str): Tax group name. """ self.tax_group_name = tax_group_name def get_tax_group_name(self): """Get tax group name. Returns: str: Tax group name. """ return self.tax_group_name def set_tax_group_percentage(self, tax_group_percentage): """Set tax group percentage. Args: tax_group_percentage(int): Tax group percentage. """ self.tax_group_percentage = tax_group_percentage def get_tax_group_percentage(self): """Get tax group percentage. Returns: int: Tax group percentage. """ return self.tax_group_percentage def set_taxes(self, taxes): """Set taxes. Args: taxes(str): Taxes. """ self.taxes = taxes def get_taxes(self): """Get taxes. Returns: str: Taxes. """ return self.taxes def to_json(self): """This method is used to create json object for tax group. Returns: dict: Dictionary containing json object for tax group. """ data = {} if self.tax_group_name != '': data['tax_group_name'] = self.tax_group_name if self.taxes != '': data['taxes'] = self.taxes return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/TaxGroup.py
TaxGroup.py
class BillPayment: """This class is used to create object for payments.""" def __init__(self): """Initialize parameters for Payments object.""" self.payment_id = '' self.bill_id = '' self.bill_payment_id = '' self.payment_mode = '' self.description = '' self.date = '' self.reference_number = '' self.exchange_rate = 0.0 self.amount = 0.0 self.paid_through_account_id = '' self.paid_through_account_name = '' self.is_single_bill_payment = None self.amount_applied = 0.0 self.vendor_id = '' self.vendor_name = '' self.paid_through = "" def set_paid_through(self, paid_through): """Set paid through. Args: paid_through(str): Paid through. """ self.paid_through = paid_through def get_paid_through(self): """Get paid through. Returns: str: Paid through. """ return self.paid_through def set_vendor_name(self, vendor_name): """Set vendor name. Args: vendor_name(str): Vendor name. """ self.vendor_name = vendor_name def get_vendor_name(self): """Get vendor name. Returns: str: Vendor name. """ return self.vendor_name def set_vendor_id(self, vendor_id): """Set vendor id. Args: vendor_id(str): Vendor id. """ self.vendor_id = vendor_id def get_vendor_id(self): """Get vendor id. Returns: str: Vendor id. """ return self.vendor_id def set_amount_applied(self, amount_applied): """Set amount applied. Args: amount_applied(float): Amount applied. """ self.amount_applied = amount_applied def get_amount_applied(self): """Get amount applied. Returns: float: Amount applied. """ return self.amount_applied def set_payment_id(self, payment_id): """Set payment id. Args: payment_id(str): Payment id. """ self.payment_id = payment_id def get_payment_id(self): """Get payment id. Returns: str: Payment id. """ return self.payment_id def set_bill_id(self, bill_id): """Set bill id. Args: bill_id(str): Bill id. """ self.bill_id = bill_id def get_bill_id(self): """Get bill id. Returns: str: Bill id. """ return bill_id def set_bill_payment_id(self, bill_payment_id): """Set bill payment id. Args: bill_payment_id(str): Bill payment id. """ self.bill_payment_id = bill_payment_id def get_bill_payment_id(self): """Get bill payment id. Returns: str: Bill payment id. """ return self.bill_payment_id def set_payment_mode(self, payment_mode): """Set payment id. Args: payment_mode(str): Payment mode. """ self.payment_mode = payment_mode def get_payment_mode(self): """Get payment mode. Returns: str: Payment mode. """ return self.payment_mode def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_reference_number(self, reference_number): """Set reference number. Args: reerence_number(str): Refference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_paid_through_account_id(self, paid_through_account_id): """Set paid through account id. Args: paid_through_account_id(str): Paid through account id. """ self.paid_through_account_id = paid_through_account_id def get_paid_through_account_id(self): """Get paid through account id. Returns: str: Paid through account id. """ return self.paid_through_account_id def set_paid_through_account_name(self, paid_through_account_name): """Set paid through account name. Args: paid_through_account_name(str): Paid through account name. """ self.paid_through_account_name = paid_through_account_name def get_paid_through_account_name(self, paid_through_acount_name): """Get paid through account name. Returns: str: Paid through account name. """ return self.paid_through_account_name def set_is_single_bill_payment(self, is_single_bill_payment): """Set whether it is single payment bill. Args: is_single_bill_payment(bool): True if it is single bill payment. """ self.is_single_bill_payment = is_single_bill_payment def get_is_single_bill_payment(self): """Get whether it is single payment bill. Returns: bool: True if it is single bill payment. """ return self.is_single_bill_payment
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/BillPayment.py
BillPayment.py
class Address: """This class is used to create an object for Address.""" def __init__(self): """Initialize parameters for address object""" self.address = '' self.city = '' self.state = '' self.zip = '' self.country = '' self.fax = '' self.is_update_customer = None self.street_address1 = '' self.street_address2 = '' def set_address(self, address): """Set address. Args: address(str): Address. """ self.address = address def get_address(self): """Get address. Returns: str: Address. """ return self.address def set_city(self, city): """Set city. Args: str: City. """ self.city = city def get_city(self): """Get city. Returns: str: City. """ return self.city def set_state(self, state): """Set state. Args: state(str): State. """ self.state = state def get_state(self): """Get the state. Returns: str: State. """ return self.state def set_zip(self, zip_code): """Set zip. Args: zip_code(str): Zip code. """ self.zip = zip_code def get_zip(self): """Get zip. Returns: str: Zip code. """ return self.zip def set_country(self, country): """Set country. Args: country(str): Country. """ self.country = country def get_country(self): """Get country. Returns: str: Country. """ return self.country 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_is_update_customer(self, is_update_customer): """Set whether to update customer. Args: is_update_customer(bool): True to update customer else False. """ self.is_update_customer = is_update_customer def get_is_update_customer(self): """Get is update customer Returns: bool: True to update customer else False. """ return self.is_update_customer def set_street_address1(self, street_address1): """Set street address1. Args: street_address1(str): Street address 1. """ self.street_address1 = street_address1 def get_street_address1(self): """Get street address1. Returns: str: Street address 1. """ return self.street_address1 def set_street_address2(self, street_address2): """Set street address 2. Args: street_address2(str): street address 2. """ self.street_address2 = street_address2 def get_street_address2(self): """Get street address 2. Returns: str: Street address 2. """ return self.street_address2 def to_json(self): """This method is used to convert the address object to JSON object. Returns: dict: Dictionary containing details of address object. """ address = {} if self.street_address1 != '': address['street_address1'] = self.street_address1 if self.street_address2 != '': address['street_address2'] = self.street_address2 if self.address != '': address['address'] = self.address if self.city != '': address['city'] = self.city if self.state != '': address['state'] = self.state if self.zip != '': address['zip'] = self.zip if self.country != '': address['country'] = self.country if self.fax != '': address['fax'] = self.fax return address
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Address.py
Address.py
from books.model.Address import Address from books.model.DefaultTemplate import DefaultTemplate class Contact: """This class is used to create object for contacts.""" 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() self.gst_treatment = '' self.place_of_contact = '' self.gst_no = '' def set_gst_no(self, gst_no): """Set gst_no for the contact. Args: gst_no(str): gst_no of the contact. """ self.gst_no = gst_no def get_gst_no(self): """Get gst_no of the contact. Returns: str: gst_no of the contact. """ return self.gst_no def set_place_of_contact(self, place_of_contact): """Set place_of_contact for the contact. Args: place_of_contact(str): place_of_contact of the contact. """ self.place_of_contact = place_of_contact def get_place_of_contact(self): """Get place_of_contact of the contact. Returns: str: place_of_contact of the contact. """ return self.place_of_contact def set_gst_treatment(self, gst_treatment): """Set gst_treatment for the contact. Args: gst_treatment(str): gst_treatment of the contact. """ self.gst_treatment = gst_treatment def get_gst_treatment(self): """Get gst_treatment of the contact. Returns: str: gst_treatment of the contact. """ return self.gst_treatment def set_contact_id(self, contact_id): """Set contact id for the contact. Args: contact_id(str): Contact id of the contact. """ self.contact_id = contact_id def get_contact_id(self): """Get contact_id of the contact. Returns: str: Contact id of the contact. """ return self.contact_id def set_contact_name(self, contact_name): """Set contact name for the contact. Args: contact_name(str): Contact name of the contact. """ self.contact_name = contact_name def get_contact_name(self): """Get contact name of the contact. Returns: str: Contact name of the contact. """ return self.contact_name def set_has_transaction(self, has_transaction): """Set whether the contact has transaction or not. Args: has_transaction(bool): True if the contact has transactions else False. """ self.has_transaction = has_transaction def get_has_transaction(self): """Get whether the contact has transaction or not. Returns: bool: True if the contact has transactions else False. """ return self.has_transaction def set_contact_type(self, contact_type): """Set contact type of the contact. Args: contact_type(str): Contact type of the contact. """ self.contact_type = contact_type def get_contact_type(self): """Get contact type of the contact. Returns: str: Contact type of the contact. """ return self.contact_type def set_is_crm_customer(self, is_crm_customer): """Set whether the contact is crm customer or not. Args: is_crm_customer(bool): True if the contact is crm customer else False. """ self.is_crm_customer = is_crm_customer def get_is_crm_customer(self): """Get whether the contact is crm customer or not. Returns: bool: True if the contact is crm customer else False . """ return self.is_crm_customer def set_primary_contact_id(self, primary_contact_id): """Set primary contact id for the contact. Args: primary_contact_id(str): Primary contact id for the contact. """ self.primary_conatact_id = primary_contact_id def get_primary_conatact_id(self): """Get primary contact id for the contact. Returns: str: Primary contact id for the contact. """ return self.primary_conatact_id def set_payment_terms(self, payment_terms): """Set payment terms for the contact. Args: payment_terms(int): Payment terms for the contact. """ self.payment_terms = payment_terms def get_payment_terms(self): """Get payment terms of the contact. Returns: int: Payment terms of the contact. """ return self.payment_terms def set_payment_terms_label(self, payment_terms_label): """Set payment terms label for the contact. Args: payment_terms_label(str): Payment terms for the contact. """ self.payment_terms_label = payment_terms_label def get_payment_terms_label(self): """Get payment terms label of the contact. Returns: str: Payment terms label of the contact. """ return self.payment_terms_label def set_currency_id(self, currency_id): """ Set currency id for the contact. Args: currency_id(str): Currency id for the contact. """ self.currency_id = currency_id def get_currency_id(self): """Get currency id of the contact. Args: currency_id(str): Currency id for the contact. """ return self.currency_id def set_currency_code(self, currency_code): """Set currency code for the contact. Args: currency_code(str): Currency code for the contact. """ self.currency_code = currency_code def get_currency_code(self): """Get currency code of the contact. Returns: str: Currency code of the contact. """ return self.currency_code def set_currency_symbol(self, currency_symbol): """Set currency symbol for the contact. Args: currency_symbol(str): Currency symbol for the contact. """ self.currency_symbol = currency_symbol def get_currency_symbol(self): """Get currency symbol of the contact. Returns: str: Currency symbol of the contact. """ return self.currency_symbol def set_outstanding_receivable_amount(self, outstanding_receivable_amount): """Set outstanding receivable amount for the contact. Args: outstanding_receivable_amount(float): Outstanding receivable amount for the contact. """ self.outstanding_receivable_amount = outstanding_receivable_amount def get_outstanding_receivable_amount(self): """Get outstanding receivable amount of the contact. Returns: float: Outstanding receivable amount of the contact. """ return self.outstanding_receivable_amount def set_outstanding_receivable_amount_bcy(self, \ outstanding_receivable_amount_bcy): """Set outstanding receivable amount bcy for the contact. Args: outstanding_receivable_amount_bcy(float): Outstanding receivable amount bcy for the contact. """ self.outstanding_receivable_amount_bcy = \ outstanding_receivable_amount_bcy def get_outstanding_receivable_amount_bcy(self): """Get the outstanding receivable amount bcy of the contact. Returns: float: Outstanding receivable amount bcy of the contact. """ return self.outstanding_receivable_amount_bcy def set_outstanding_payable_amount(self, outstanding_payable_amount): """Set the outstanding payable amount for the contact. Args: outstanding_payable_amount(float): Outstanding payable amount for the contact. """ self.outstanding_payable_amount = outstanding_payable_amount def get_outstanding_payable_amount(self): """Get the outstanding payable amount of the contact. Returns: float: Outstanding payable amount of the contact. """ return self.outstanding_payable_amount def set_outstanding_payable_amount_bcy(self, \ outstanding_payable_amount_bcy): """Set outstanding payable amount bcy for the contact. Args: outstanding_payable_amount_bcy(float): Outstanding payable amount bcy for the contact. """ self.outstanding_payable_amount_bcy = outstanding_payable_amount_bcy def get_outstanding_payable_amount_bcy(self): """Get outstanding payable amount bcy of the contact. Returns: float: Outstanding payable amount bcy of the contact. """ return self.outstanding_payable_amount_bcy def set_unused_credits_receivable_amount(self, \ unused_credits_receivable_amount): """Set unused credits receivable amount for the contact. Args: unused_credits_receivable_amount(float): Unused credits receivable amount for the contact. """ self.unused_credits_receivable_amount = \ unused_credits_receivable_amount def get_unused_credits_receivable_amount(self): """Get unused credits receivable amount of the contact. Returns: float: Unused credits receivable amount for the contact. """ return self.unused_credits_receivable_amount def set_unused_credits_receivable_amount_bcy(self, \ unused_credits_receivable_amount_bcy): """Set unused credits receivable amount bcy for the contact. Args: unused_credits_receivable_amount_bcy(float): Unused credits receivable amount bcy for the contact. """ self.unused_credits_receivable_amount_bcy = \ unused_credits_receivable_amount_bcy def get_unused_credits_receivable_amount_byc(self): """Get unused credits receivable amount bcy of the contact. Returns: float: Unused credits receivable amount bcy of the contact. """ return self.unused_credits_receivable_amount_bcy def set_unused_credits_payable_amount(self, unused_credits_payable_amount): """Set unused credits payable amount for the contact. Args: unused_credits_payable_amount(float): Unused credits payable amount for the contact. """ self.unused_credits_payable_amount = unused_credits_payable_amount def get_unused_credits_payable_amount(self): """Get unused payable amount of the contact. Returns: float: Unused payable amount of the contact. """ return self.unused_credits_payable_amount def set_unused_credits_payable_amount_bcy(self, \ unused_credits_payable_amount_bcy): """Set unused credits payable amount bcy for the contact. Args: unused_credits_payable_amount_bcy(float): Unused credits payable amount bcy for the contact. """ self.unused_credits_payable_amount_bcy = \ unused_credits_payable_amount_bcy def get_unused_credits_payable_amount_bcy(self): """Get unused credits payable amount bcy of the contact. Returns: float: Unused credits payable amount bcy of the contact. """ return self.unused_credits_payable_amount_bcy def set_status(self, status): """Set status for the contact. Args: status(str): Status of the contact. """ self.status = status def get_status(self): """Get status of the contact. Returns: str: Status of the contact. """ return self.status def set_payment_reminder_enabled(self, payment_reminder_enabled): """Set whether to enabe payment reminder for the contact. Args: payment_reminder_enabled(bool): True if enable payment reminder else false. """ self.payment_reminder_enabled = payment_reminder_enabled def get_payment_reminder_enabled(self): """Get whether the payment reminder is enabled or not Returns: bool: True if payment reminder is enabled else false. """ return self.payment_reminder_enabled def set_notes(self, notes): """Set notes for the contact. Args: notes(str): Notes for contact. """ self.notes = notes def get_notes(self): """Get notes of the contact. Returns: str: Notes of the contact. """ return self.notes def set_created_time(self, created_time): """Set created time for the contact. Args: created_time(str): Created time for the contact. """ self.created_time = created_time def get_created_time(self): """Get created of the contact. Returns: str: Created time of the contact. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time for the contact. Args: last_modified_time(str): Last modified time for the contact. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time of the contact. Returns: str: Last modified time of the contact. """ return self.last_modified_time def set_billing_address(self, billing_address): """Set billing address for the contact. Args: billing_address(Address): Billing address for the contact. """ self.billing_address = billing_address def get_billing_address(self): """Get billing address of the contact. Returns: Address: Billing address of the contact. """ return self.billing_address def set_shipping_address(self, shipping_address): """Set shipping address for the contact. Args: shipping_address(Address): Shipping address for the contact. """ self.shipping_address = shipping_address def get_shipping_address(self): """Get shipping address of the contact. Returns: Address: Shipping address of the contact. """ return self.shipping_address def set_contact_persons(self, contact_person): """Set contact persons for the contact. Args: contact_person(list): List of contact persons object. """ self.contact_persons.extend(contact_person) def get_contact_persons(self): """Get contact persons of a contact. Returns: list: List of contact persons. """ return self.contact_persons def set_default_templates(self, default_templates): """Set default templates for the contact. Args: default_templates(instance): Default templates object. """ self.default_templates = default_templates def get_default_templates(self): """Get default templates of the contact. Returns: instance: Default templates instance. """ return self.default_templates def set_custom_fields(self, custom_field): """Set custom fields for a contact. Args: custom_field(instance): Custom field object. """ self.custom_fields.append(custom_field) def get_custom_fields(self): """Get custom fields of the contact. Returns: instance: Custom field of the contact. """ return self.custom_fields def set_company_name(self, company_name): """Set company name for the contact. Args: company_name(str): Company name of the contact. """ self.company_name = company_name def get_company_name(self): """Get company name of the contact. Returns: str: cCompany name of the contact. """ return self.company_name def set_contact_salutation(self, contact_salutation): """Set salutation for the contact. Args: contact_salutation(str): Salutation of the contact. """ self.contact_salutation = contact_salutation def get_contact_salutation(self): """Get salutation of the contact. Returns: str: Salutation of the contact """ return self.contact_salutation def set_price_precision(self, price_precision): """Set price precision for the contact. Args: price_precision(int): Price precision for the contact. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision of the contact. Returns: int: Price precision of the contact. """ return self.price_precision def set_track_1099(self, track_1099): """Set to track a contact for 1099 reporting. Args: track_1099(bool): True to track a contact for 1099 reporting else False. """ self.track_1099 = track_1099 def get_track_1099(self): """Get whether a contact is set for 1099 tracking. Returns: bool: True if a contact is set for 1099 tracking else False. """ return self.track_1099 def set_tax_id_type(self, tax_id_type): """Set tax id type for a contact. Args: tax_id_type(str): tax id type for a contact """ self.tax_id_type = tax_id_type def get_tax_id_type(self): """Get tax id type of a contact. Returns: str: Tax id type for a contact. """ return self.tax_id_type def set_tax_id_value(self, tax_id_value): """Set tax id value for a contact. Args: tax_id_value(str): Tax id value for a contact. """ self.tax_id_value = tax_id_value def get_tax_id_value(self): """Get tax id value of a contact. Returns: str: Tax id value of a contact. """ return self.tax_id_value def set_first_name(self, first_name): """Set first name. Args: first_name = First name. """ self.first_name = first_name def get_first_name(self): """Get first name. Returns: str: First name. """ return self.first_name def set_last_name(self, last_name): """Set last name. Args: last_name = Last name. """ self.last_name = last_name def get_last_name(self): """Get last name. Returns: str: Last name. """ return self.last_name 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_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_mobile(self, mobile): """Set mobile. Args: mobile(str): Mobile. """ self.mobile = mobile def to_json(self): """This method is used to convert the contact object to JSON object. Returns: dict: Dictionary containing details of contact object. """ data = {} data['email'] = self.email if self.company_name != '': data['company_name'] = self.company_name if self.contact_name != '': data['contact_name'] = self.contact_name if self.payment_terms != '': data['payment_terms'] = self.payment_terms if self.payment_terms_label != '': data['payment_terms_label'] = self.payment_terms_label if self.currency_id != '': data['currency_id'] = self.currency_id if self.billing_address is not None: billing_address = self.billing_address data['billing_address'] = billing_address.to_json() if self.shipping_address is not None: shipping_address = self.shipping_address data['shipping_address'] = shipping_address.to_json() if self.gst_no != '': data['gst_no'] = self.gst_no if self.place_of_contact != '': data['place_of_contact'] = self.place_of_contact if self.gst_treatment != '': data['gst_treatment'] = self.gst_treatment if self.contact_persons: data['contact_persons'] = [] for value in self.contact_persons: data['contact_persons'].append(value.to_json()) if self.notes != '': data['notes'] = self.notes return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Contact.py
Contact.py
class RecurringExpense: """This class is used to create object for Recurring Expenses.""" def __init__(self): """Initialize parameters for Recurring expenses.""" self.account_id = '' self.paid_through_account_id = '' self.recurrence_name = '' self.start_date = '' self.end_date = '' self.recurrence_frequency = '' self.repeat_every = 0 self.repeat_frequency = '' self.amount = 0.0 self.tax_id = '' self.is_inclusive_tax = None self.is_billable = None self.customer_id = '' self.vendor_id = '' self.project_id = '' self.currency_id = '' self.exchange_rate = 0.0 self.recurring_expense_id = '' self.last_created_date = '' self.next_expense_date = '' self.account_name = '' self.paid_through_account_name = '' self.vendor_name = '' self.currency_code = '' self.tax_name = '' self.tax_percentage = 0 self.tax_amount = 0.0 self.sub_total = 0.0 self.total = 0.0 self.bcy_total = 0.0 self.description = '' self.customer_name = '' self.status = '' self.created_time = '' self.last_modified_time = '' self.project_name = '' def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_paid_through_account_id(self, paid_through_account_id): """Set paid through account id. Args: paid_through_account_id(str): Paid through account id. """ self.paid_through_account_id = paid_through_account_id def get_paid_through_account_id(self): """Get paid through account id. Returns: str: Paid through account id. """ return self.paid_through_account_id def set_recurrence_name(self, recurrence_name): """Set recurrence name. Args: recurrence_name(str): Recurrence name. """ self.recurrence_name = recurrence_name def get_recurrence_name(self): """Get recurrence name. Returns: str: Recurrence name. """ return self.recurrence_name def set_start_date(self, start_date): """Set start date. Args: start_date(str): Start date. """ self.start_date = start_date def get_start_date(self): """Get start date. Returns: str: Start date. """ return self.start_date def set_end_date(self, end_date): """Set end date. Args: end_date(str): End date. """ self.end_date = end_date def get_end_date(self): """Get end date. Returns: str: End date. """ return self.end_date def set_recurrence_frequency(self, recurrence_frequency): """Set recurrence frequency. Args: recurrence_frequency(str): Recurrence frequency. """ self.recurrence_frequency = recurrence_frequency def get_recurrence_frequency(self): """Get recurrence frequency. Returns: str: Recurrence frequency. """ return self.recurrence_frequency def set_repeat_every(self, repeat_every): """Set repeat every. Args: repeat_every(int): Repeat every. """ self.repeat_every = repeat_every def get_repeat_every(self): """Get repeat every. Returns: int: Repeat every. """ return self.repeat_every def set_repeat_frequency(self, repeat_frequency): """Set repeat frequency. Args: repeat_frequency(str): Repeat frequency. """ self.repeat_frequency = repeat_frequency def get_repeat_frequency(self): """Get repeat frequency. Returns: str: Repeat frequency. """ return self.repeat_frequency def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_tax_id(self, tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str: Tax id. """ return self.tax_id def set_is_inclusive_tax(self, is_inclusive_tax): """Set whether tax is inclusive. Args: is_inclusive_tax(bool): True if tax is inclusive else False. """ self.is_inclusive_tax = is_inclusive_tax def get_is_inclusive_tax(self): """Get whether tax is inclusive. Returns: bool: True if tax is inclusive else False. """ return self.is_inclusive_tax def set_is_billable(self, is_billable): """Set whether Recurring Expense is billable. Args: is_billable(bool): True if billable else False. """ self.is_billable = is_billable def get_is_billable(self): """Get whether Recurring Expense is billable. Returns: bool: True if billable else False. """ return self.is_billable def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_vendor_id(self, vendor_id): """Set vendor id. Args: vendor_id(str): Vendor id. """ self.vendor_id = vendor_id def get_vendor_id(self): """Get vendor id. Returns: str: Get vendor id. """ return self.vendor_id def set_project_id(self, project_id): """Set project id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id 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_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_recurring_expense_id(self, recurring_expense_id): """Set recurring expense id. Args: recurring_expense_id(str): Recurring expense id. """ self.recurring_expense_id = recurring_expense_id def get_recurring_expense_id(self): """Get recurring expense id. Returns: str: Recurring expense id. """ return self.recurring_expense_id def set_last_created_date(self, last_created_date): """Set last created date. Args: last_created_date(str): Last created date. """ self.last_created_date = last_created_date def get_last_created_date(self): """Get last created date. Returns: str: Last created date. """ return self.last_created_date def set_next_expense_date(self, next_expense_date): """Set next expense date. Args: next_expense_date(str): Next expense date. """ self.next_expense_date = next_expense_date def get_next_expense_date(self): """Get next expense date. Returns: str: Next expense date. """ return self.next_expense_date def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Return: str: Account name. """ return self.account_name def set_paid_through_account_name(self, paid_through_account_name): """Set paid through account name. Args: paid_through_account_name(str): Paid through account name. """ self.paid_through_account_name = paid_through_account_name def get_paid_through_account_name(self): """Get paid through account name. Returns: str: Paid through account name. """ return self.paid_through_account_name def set_vendor_name(self, vendor_name): """Set vendor name. Args: vendor_name(str): Vendor name. """ self.vendor_name = vendor_name def get_vendor_name(self): """Get vendor name. Returns: str: Vendor name. """ return self.vendor_name 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_tax_name(self, tax_name): """Set tax name. Args: tax_name(str): Tax name. """ self.tax_name = tax_name def get_tax_name(self): """Get tax name. Returns: str: Tax name. """ return self.tax_name def set_tax_percentage(self, tax_percentage): """Set tax percentage. Args: tax_percentage(int): Tax percentage. """ self.tax_percentage = tax_percentage def set_tax_amount(self, tax_amount): """Set tax amount. Args: tax_amount(float): Tax amount. """ self.tax_amount = tax_amount def get_tax_amount(self): """Get tax amount. Returns: float: Tax amount. """ return self.tax_amount def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_bcy_total(self, bcy_total): """Set bcy total. Args: bcy_total(float): Bcy total. """ self.bcy_total = bcy_total def get_bcy_total(self): """Get bcy total. Returns: float: Bcy total. """ return self.bcy_total def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = '' def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def set_project_name(self, project_name): """Set project name. Args: project_name(str): Project name. """ self.project_name = project_name def get_project_name(self): """Get project name. Returns: str: Project name. """ return self.project_name def to_json(self): """This method is used to convert recurring expenses object to json object. Returns: dict: Dictionary coontaining json object for recurring expenses. """ data = {} if self.account_id != '': data['account_id'] = self.account_id if self.paid_through_account_id != '': data['paid_through_account_id'] = self.paid_through_account_id if self.recurrence_name != '': data['recurrence_name'] = self.recurrence_name if self.start_date != '': data['start_date'] = self.start_date if self.end_date != '': data['end_date'] = self.end_date if self.recurrence_frequency != '': data['recurrence_frequency'] = self.recurrence_frequency if self.repeat_every > 0: data['repeat_every'] = self.repeat_every if self.amount > 0: data['amount'] = self.amount if self.tax_id != '': data['tax_id'] = self.tax_id if self.is_inclusive_tax is not None: data['is_inclusive_tax'] = self.is_inclusive_tax if self.is_billable is not None: data['is_billable'] = self.is_billable if self.customer_id != '': data['customer_id'] = self.customer_id if self.vendor_id != '': data['vendor_id'] = self.vendor_id if self.project_id != '': data['project_id'] = self.project_id if self.currency_id != '': data['currency_id'] = self.currency_id if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/RecurringExpense.py
RecurringExpense.py
from books.model.PlaceHolder import PlaceHolder class Autoreminder: """This class is used to create object for auto reminders.""" def __init__(self): """Initialize parameters for auto reminders object.""" self.payment_reminder_id = '' self.is_enabled = None self.notification_type = '' self.address_type = '' self.number_of_days = 0 self.subject = '' self.body = '' self.autoreminder_id = '' self.order = 0 self.name = '' self.cc_addresses = '' self.placeholder = PlaceHolder() def set_cc_addresses(self, cc_addresses): """Set cc addresses. Args: cc_addresses(str): Cc addresses. """ self.cc_addresses = cc_addresses def get_cc_addresses(self): """Get cc addresses. Returns: str: Cc addresses. """ return self.cc_addresses 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_payment_reminder_id(self, payment_reminder_id): """Set payment reminder id. Args: payment_reminder_id(str): Payment reminder id. """ self.payment_reminder_id = payment_reminder_id def get_payment_reminder_id(self): """Get payment reminder id. Returns: str: Payment reminder id. """ return self.payment_reminder_id def set_is_enabled(self, is_enabled): """Set whether it is enabled or not. Args: is_enabled(bool): True to enable else False. """ self.is_enabled = is_enabled def get_is_enabled(self): """Get is enabled. Returns: bool: True if enabled else false. """ return self.is_enabled def set_notification_type(self, notification_type): """Set notification type. Args: notification_type(str): Notification type. """ self.notification_type = notification_type def get_notification_type(self): """Get notification type. Returns: str: Notification type. """ return self.notification_type def set_address_type(self, address_type): """Set address type. Args: address_type(str): Address type. """ self.address_type = address_type def get_address_type(self): """Get address type. Returns: str: Address type. """ return self.address_type def set_number_of_days(self, number_of_days): """Set number of days. Args: number_of_days(int): Number of days. """ self.number_of_days = number_of_days def get_number_of_days(self): """Get number of days. Returns: int: Number of days. """ return self.number_of_days def set_subject(self, subject): """Set subject. Args: subject(str): Subject. """ self.subject = subject def get_subject(self): """Get subject. Returns: str: Subject. """ return self.subject def set_body(self, body): """Set body. Args: body(str): Body. """ self.body = body def get_body(self): """Get body. Returns: str: Body. """ return self.body def set_autoreminder_id(self, autoreminder_id): """Set autoreminder id. Args: autoreminder_id(str): Auto reminder id. """ self.autoreminder_id = autoreminder_id def get_autoreminder_id(self): """Get autoreminder id. Returns: str: Auto reminder id. """ return self.autoreminder_id def set_order(self, order): """Set order. Args: order(int): Order. """ self.order = order def get_order(self): """Get order. Returns: int: Order. """ return self.order def set_placeholders(self, placeholders): """Set place holders. Args: place_holders: Palce holders object. """ self.placeholders = placeholders def get_placeholders(self): """Get place holders. Returns: instance: Place holders. """ return self.placeholders def to_json(self): """This method is used to convert auto reminder object to json object. Returns: dict: Dictionary cocntaining json object for autoreminder. """ data = {} if self.is_enabled != '': data['is_enabled'] = self.is_enabled if self.notification_type != '': data['type'] = self.notification_type if self.address_type != '': data['address_type'] = self.address_type if self.subject != '': data['subject'] = self.subject if self.body != '': data['body'] = self.body return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Autoreminder.py
Autoreminder.py
from books.model.Address import Address class CreditNote: """This class creates object for credit notes.""" 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 = '' def set_creditnote_id(self, creditnote_id): """Set creditnote id. Args: creditnote_id(str): Credit note id. """ self.creditnote_id = creditnote_id def get_creditnote_id(self): """Get creditnote id. Returns: str: Creditnote id. """ return self.creditnote_id def set_creditnote_number(self, creditnote_number): """Set creditnote number. Args: creditnote_number(str):Creditnote number. """ self.creditnote_number = creditnote_number def get_creditnote_number(self): """Get creditnote number. Returns: str: Creditnote number. """ return self.creditnote_number def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customerid. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_contact_persons(self, contact_person): """Set contact person. Args: contact_person(list): Contact person. """ self.contact_persons.extend(contact_person) def get_contact_persons(self): """Get contact persons. Returns: list of instance: List of contact person object. """ return self.contact_persons 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 currenccy code. Returns: str: Currecny code. """ return self.currency_code def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange ratte. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_price_precision(self, price_precision): """Set price precision. Args: price_precision(float): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: float: Price precision. """ return self.price_precision def set_template_id(self, template_id): """Set template id. Args: template_id(str): Template id. """ self.template_id = template_id def get_template_id(self): """Get template id. Returns: str: Template id. """ return self.template_id def set_template_name(self, template_name): """Set template name. Args: template_name(str): Template name. """ self.template_name = template_name def get_template_name(self): """Get template name. Returns: str: Template name. """ return self.template_name def set_is_emailed(self, is_emailed): """Set whether is emailed or not. Args: is_emailed(bool): True if emailed else False. """ self.is_emailed = is_emailed def get_is_emailed(self): """Get whether is emailed or not. Returns: bool: True if emailed else False. """ return self.is_emailed def set_line_items(self, line_items): """Set line items. Args: line_items(instance): Line items object. """ self.line_items.append(line_items) def get_line_items(self): """Get line items. Returns: list of instance: List of lineitems object. """ return self.line_items def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_total_credits_used(self, total_credits_used): """Set total credits used. Args: total_credits_used(float): Total credits used. """ self.total_credits_used = total_credits_used def get_total_credits_used(self): """Get total credits used. Returns: float: Total credits used. """ return self.total_credits_used def set_total_refunded_amount(self, total_refunded_amount): """Set total refunded amount. Args: total_refunded_amount(float): Total refunded amount. """ self.total_refunded_amount = total_refunded_amount def get_total_refunded_amount(self): """Get total refunded amount. Returns: float: Total refunded amount. """ return self.total_refunded_amount def set_balance(self, balance): """Set balance. Args: balance(float): Balance. """ self.balance = balance def get_balance(self): """Get balance. Returns: float: Balance. """ return self.balance def set_taxes(self, taxes): """Set taxes. Args: taxes(list of instance): List of tax object. """ self.taxes.extend(taxes) def get_taxes(self): """Get taxes. Returns: list: List of objects. """ return self.taxes def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def set_shipping_address(self, address): """Set shipping address. Arg: address(instance): Address object. """ self.shipping_address = address def get_shipping_address(self): """Get shipping address. Returns: instance: Address object. """ return self.shipping_address def set_billing_address(self, address): """Set billing address. Args: address: Address object. """ self.billing_address = address def get_billing_address(self): """Get billing address. Returns: instance: Address object. """ return self.billing_address def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created ime. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modifiedd time. """ return self.last_modified_time def set_refund_mode(self, refund_mode): """Set refund mode. Args: refund_mode(str): Refund mode. """ self.refund_mode = refund_mode def get_refund_mode(self): """Get refund mode. Returns: str: Refund mode. """ return self.refund_mode def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_from_account_id(self, from_account_id): """Set from account id. Args: from_account_id(str): From account id. """ self.from_account_id = from_account_id def get_from_account_id(self): """Get from account id. Returns: str: From account id. """ return self.from_account_id def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def to_json(self): """This method is used to convert credit notes object to json object. Returns: dict: Dictionary containing json object for credit notes. """ data = {} if self.customer_id != '': data['customer_id'] = self.customer_id if self.contact_persons: data['contact_persons'] = self.contact_persons if self.reference_number != '': data['reference_number'] = self.reference_number if self.template_id != '': data['template_id'] = self.template_id if self.date != '': data['date'] = self.date if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.line_items: data['line_items'] = [] for value in self.line_items: line_item = value.to_json() data['line_items'].append(line_item) if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms if self.creditnote_number != '': data['creditnote_number'] = self.creditnote_number return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/CreditNote.py
CreditNote.py
class InvoiceSetting: """This class is used to create object for invoice settings.""" def __init__(self): """Initialize parameters for Invoice settings.""" self.auto_generate = None self.prefix_string = '' self.start_at = 0 self.next_number = '' self.quantity_precision = 0 self.discount_type = '' self.is_discount_before_tax = None self.reference_text = '' self.default_template_id = '' self.notes = '' self.terms = '' self.is_shipping_charge_required = None self.is_adjustment_required = None self.is_open_invoice_editable = None self.warn_convert_to_open = None self.warn_create_creditnotes = None self.attach_expense_receipt_to_invoice = '' self.invoice_item_type = '' self.is_sales_person_required = None self.is_show_invoice_setup = None self.discount_enabled = None def set_discount_enabled(self, discount_enabled): """Set discount enabled. Args: discount_enabled(str): Discount enabled. """ self.discount_enabled = discount_enabled def get_discount_enabled(self): """Get discount enabled. Returns: str: Discount enabled. """ return self.discount_enabled def set_default_template_id(self, default_template_id): """Set default template id. Args: default_template_id(str): Default template id. """ self.default_template_id = default_template_id def get_default_template_id(self): """Get default template id. Returns: str: Default template id. """ return self.default_template_id def set_auto_generate(self, auto_generate): """Set auto generate. Args: auto_generate(bool): Auto generate. """ self.auto_generate = auto_generate def get_auto_generate(self): """Get auto generate. Returns: bool: Auto generate. """ return self.auto_generate def set_prefix_string(self, prefix_string): """Set prefix string. Args: prefix_string(str): Prefix string. """ self.prefix_string = prefix_string def get_prefix_string(self): """Get prefix string. Returns: str: Prefix string. """ return self.prefix_string def set_start_at(self, start_at): """Set start at. Args: start_at(int): Start at. """ self.start_at = start_at def get_start_at(self): """Get start at. Returns: int: Start at. """ return self.start_at def set_next_number(self, next_number): """Set next number. Args: next_number(str): Next number. """ self.next_number = next_number def get_next_number(self): """Get next number. Returns: str: Next number. """ return self.next_number def set_quantity_precision(self, quantity_precision): """Set quantity precision. Args: quantity_precision(int): Quantity precision. """ self.quantity_precision = quantity_precision def get_quantity_precision(self): """Get quantity precision. Returns: int: Quantity precision. """ return self.quantity_precision def set_discount_type(self, discount_type): """Set discount type. Args: discount_type(str): Discount type. """ self.discount_type = discount_type def get_discount_type(self): """Get discount type. Returns: str: Discount type. """ return self.discount_type def set_is_discount_before_tax(self, is_discount_before_tax): """Set whether it is discount before tax. Args: is_discount_before_tax(bool): True to discount before tax. """ self.is_discount_before_tax = is_discount_before_tax def get_is_discount_before_tax(self): """Get whether to discount before tax. Returns: bool: True to discount before tax else false. """ return self.is_discount_before_tax def set_reference_text(self, reference_text): """Set reference text. Args: reference_text(str): Reference text. """ self.reference_text = reference_text def get_reference_text(self): """Get reference text. Returns: str: Reference text. """ return self.reference_text def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def set_is_shipping_charge_required(self, is_shipping_charge_required): """Set whether shipping charge is required or not. Args: is_shipping_charge_required(bool): True if shipping charge is required else false. """ self.is_shipping_charge_required = is_shipping_charge_required def get_is_shipping_charge_required(self): """Get whether shipping charge is required or not. Returns: bool: True if shipping charge is required or not. """ return self.is_shipping_charge_required def set_is_adjustment_required(self, is_adjustment_required): """Set whether adjustment is required. Args: is_adjustment_required(bool): True if adjustment is required else false. """ self.is_adjustment_required = is_adjustment_required def get_is_adjustment_required(self): """Get whether adjustment is required. Returns: bool: True if adjustment is required. """ return self.is_adjustment_required def set_is_open_invoice_editable(self, is_open_invoice_editable): """Set whether open invoice editable. Args: is_open_invoice_editable(bool): True if open invoice editable else false. """ self.is_open_invoice_editable = is_open_invoice_editable def get_is_open_invoice_editable(self): """Get whether open invoice editable. Returns: bool: True if open invoice editable else false. """ return self.is_open_invoice_editable def set_warn_convert_to_open(self, warn_convert_to_open): """Set whether to enable warning while converting to open. Args: warn_convert_to_open(bool): True to warn while converting to open else false. """ self.warn_convert_to_open = warn_convert_to_open def get_warn_convert_to_open(self): """Get whether to enable warning while converting to open. Returns: bool: True if warning while converting to open is enabled else false. """ return self.warn_convert_to_open def set_warn_create_creditnotes(self, warn_create_creditnotes): """Set whether to enable warning while creating creditnotes. Args: warn_create_creditnotes(bool): True to warn while creating creditnotes else false. """ self.warn_create_creditnotes = warn_create_creditnotes def get_warn_create_creditnotes(self): """Get whether warning while creating creditnotes is enabled or not. Returns: bool: True to warn while creating creditnotes else false. """ return self.warn_create_creditnotes def set_attach_expense_receipt_to_invoice(self, \ attach_expense_receipt_to_invoice): """Set attach expense receipt to invoice. Args: attach_expense_receipt_to_invoice(str): Attach expense receipt to invoice. """ self.attach_expense_receipt_to_invoice = \ attach_expense_receipt_to_invoice def get_attach_expense_receipt_to_invoice(self): """Get attach expense receipt to invoice. Returns: str: Attach expense receipt to invoice. """ return self.attach_expense_receipt_to_invoice def set_is_open_invoice_editable(self, is_open_invoice_editable): """Set whether to open invoice editable. Args: is_open_invoice_editable(bool): True to open invoice editable else false. """ self.is_open_invoice_editable = is_open_invoice_editable def get_is_open_invoice_editable(self): """Get whether to open invoice editable. Returns: bool: True to open invoice editable else false. """ return self.is_open_invoice_editable def set_is_sales_person_required(self, is_sales_person_required): """Set whether sales person is required or not. Args: is_sales_person_required(bool): True if sales person is required else false. """ self.is_sales_person_required = is_sales_person_required def get_is_sales_person_required(self): """Get whether sales person is required or not. Returns: bool: True if sales person is required else false. """ return self.is_sales_person_required def set_is_show_invoice_setup(self, is_show_invoice_setup): """Set whether to show invoice setup. Args: is_show_invoice_setup(bool): True to show invoice setup. """ self.is_show_invoice_setup = is_show_invoice_setup def get_is_show_invoice_setup(self): """Get whether to show invoice setup. Returns: bool: True to show invoice setup. """ return self.is_show_invoice_setup def set_invoice_item_type(self, invoice_item_type): """Set invoice item type. Args: invoice_item_type(str): Invoice item type. """ self.invoice_item_type = invoice_item_type def get_invoice_item_type(self): """Get invoice item type. Returns: str: Invoice item type. """ return self.invoice_item_type def to_json(self): """This method is used to convert invoice settings in json format. Returns: dict: Dictionary containing json object for invoice settings. """ data = {} if self.auto_generate is not None: data['auto_generate'] = self.auto_generate if self.prefix_string != None: data['prefix_string'] = self.prefix_string if self.start_at > 0: data['start_at'] = self.start_at if self.next_number != '': data['next_number'] = self.next_number if self.quantity_precision > 0: data['quantity_precision'] = self.quantity_precision if self.discount_enabled is not None: data['discount_enabled'] = self.discount_enabled if self.reference_text != '': data['reference_text'] = self.reference_text if self.default_template_id != '': data['default_template_id'] = self.default_template_id if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms if self.is_shipping_charge_required is not None: data['is_shipping_charge_required'] = \ self.is_shipping_charge_required if self.is_adjustment_required is not None: data['is_adjustment_required'] = \ self.is_adjustment_required if self.invoice_item_type != '': data['invoice_item_type'] = self.invoice_item_type if self.discount_type != '': data['discount_type'] = self.discount_type if self.warn_convert_to_open is not None: data['warn_convert_to_open'] = self.warn_convert_to_open if self.warn_create_creditnotes is not None: data['warn_create_creditnotes'] = self.warn_create_creditnotes if self.is_open_invoice_editable is not None: data['is_open_invoice_editable'] = self.is_open_invoice_editable if self.is_sales_person_required is not None: data['is_sales_person_required'] = self.is_sales_person_required return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/InvoiceSetting.py
InvoiceSetting.py
class PaymentGateway: """This class is used to create object for payment gateway object.""" def __init__(self): """Initialize parameters for Payment gateway object.""" self.gateway_name = '' self.gateway_name_formatted = '' self.identifier = '' self.additional_field1 = '' self.additional_field2 = '' self.additional_field3 = '' self.deposit_to_account_id = '' self.deposit_to_account_name = '' self.configured = None def set_gateway_name(self, gateway_name): """Set gateway name associated with recurring profile. Args: gateway_name(str): Gateway name associated with recurring profile. Allowed values are paypal, authorize_net, payflow_pro, stripe, 2checkout and braintree. """ self.gateway_name = gateway_name def get_gateway_name(self): """Get gateway name. Returns: str: Gateway name associated with recurring profile. """ return self.gateway_name def set_gateway_name_formatted(self, gateway_name_formatted): """Set gateway name formatted. Args: gateway_name_formatted(str): Gateway name formatted. """ self.gateway_name_formatted = gateway_name_formatted def get_gateway_name_formatted(self): """Get gateway name formatted. Returns: str: Gateway name formatted. """ return self.gateway_name_formatted def set_identifier(self, identifier): """Set identifier. Args: identifier(str): Identifier. """ self.identifier = identifier def get_identifier(self): """Get identifier. Returns: str: Identifier. """ return self.identifier def set_additional_field1(self, additional_field1): """Set additional field1. Args: additional_field1(str): Paypal payment method.Allowed values are standard and adaptive. """ self.additional_field1 = additional_field1 def get_additional_field1(self): """Get additional field1. Returns: str: Paypal payment method. """ return self.additional_field1 def set_additional_field2(self, additional_field2): """Set additional field2. Args: additional_field2(str): Paypal payment method.Allowed values are standard and adaptive. """ self.additional_field2 = additional_field2 def get_additional_field2(self): """Get additional field2. Returns: str: Paypal payment method. """ return self.additional_field2 def set_additional_field3(self, additional_field3): """Set additional field3. Args: additional_field3(str): Paypal payment method.Allowed values are standard and adaptive. """ self.additional_field3 = additional_field3 def get_additional_field3(self): """Get additional fiield3. Returns: str: Paypal payment method. """ return self.additional_field3 def set_deposit_to_account_id(self, deposit_to_account_id): """Set deposit to account id. Args: deposit_to_account_id(str): Deposit to account id. """ self.deposit_to_account_id = deposit_to_account_id def get_deposit_to_account_id(self): """Get deposit to account id. Returns: str: Deposit to account id. """ return self.deposit_to_account_id def set_deposit_to_account_name(self, deposit_to_account_name): """Set deposit to account name. Args: deposit_to_account_name(str): Deposit to account name. """ self.deposit_to_account_name = deposit_to_account_name def get_deposit_to_account_name(self): """Get deposit to account name. Returns: str: Deposit to account name. """ return self.deposit_to_account_name def set_configured(self, configured): """Set Whether to configure or not. Args: configured(bool): Configured. """ self.configured = configured def get_configured(self): """Get configured. Returns: bool: Configured. """ return self.configured def to_json(self): """This method is used to convert payment gateway object to json object. Returns: dict: Dictionary containing json object for payment gatewqay. """ data = {} if self.gateway_name != '': data['gateway_name'] = self.gateway_name if self.additional_field1 != '': data['additional_field1'] = self.additional_field1 return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/PaymentGateway.py
PaymentGateway.py
class ToContact: """This class is used to create object for to Contacts.""" def __init__(self): """Initialize parameters for to contacts.""" self.first_name = '' self.selected = None self.phone = '' self.email = '' self.last_name = '' self.salutation = '' self.contact_person_id = '' self.mobile = '' def set_first_name(self, first_name): """Set first name. Args: first_name(str): First name. """ self.first_name = first_name def get_first_name(self): """Get first name. Returns: str: First name. """ return self.first_name def set_selected(self, selected): """Set selected. Args: selected(bool): Selected. """ self.selected = selected def get_selected(self): """Get selected. Returns: bool: Selected. """ return self.selected 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_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_last_name(self, last_name): """Set last name. Args: last_name(str): Last name. """ self.last_name = last_name def get_last_name(self): """Get last name. Returns: str: Last name. """ return self.last_name def set_salutation(self, salutation): """Set salutation. Args: salutation(str): Salutation. """ self.salutation = salutation def get_salutation(self): """Get salutation. Returns: str: Salutation. """ return self.salutation def set_contact_person_id(self, contact_person_id): """Set contact person id. Args: contact_person_id(str): Contact person id. """ self.contact_person_id = contact_person_id def get_contact_person_id(self): """Get person id. Returns: str: Contact person id. """ return self.contact_person_id def set_mobile(self, mobile): """Set mobile. Args: mobile(str): Mobile. """ self.mobile = mobile def get_mobile(self): """Get mobile. Returns: str: Mobile. """ return self.mobile
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/ToContact.py
ToContact.py
class Journal: """This class is used to create object for Journals.""" def __init__(self): """Initilaize parameters for journals object.""" self.journal_date = '' self.reference_number = '' self.notes = '' self.line_items = [] self.journal_id = '' self.entry_number = '' self.currency_id = '' self.currency_symbol = '' self.journal_date = '' self.line_item_total = 0.0 self.total = 0.0 self.price_precision = 0 self.taxes = [] self.created_time = '' self.last_modified_time = '' def set_journal_date(self, journal_date): """Set journal date. Args: journal_date(str): Journal date. """ self.journal_date = journal_date def get_journal_date(self): """Get journal date. Returns: str: Journal date. """ return self.journal_date def set_reference_number(self, reference_number): """Set reference date. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.note = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_line_items(self, line_item): """Set line items. Args: line_items(instance): Line items. """ self.line_items.append(line_item) def get_line_items(self): """Get line items. Returns: list of instance: List of instance object. """ return self.line_items def set_journal_id(self, journal_id): """Set journal id. Args: journal_id(str): Journal id. """ self.journal_id = journal_id def get_journal_id(self): """Get journal id. Returns: str: Journal id. """ return self.journal_id def set_entry_number(self, entry_number): """Set entry number. Args: entry_number(str): Entry number. """ self.entry_number = entry_number def get_entry_number(self): """Get entry number. Returns: str: Entry number. """ return self.entry_number def set_currency_id(self, currency_id): """Set currecny 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_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_journal_date(self, journal_date): """Set journal date. Args: journal_date(str): Journal date. """ self.journal_date = journal_date def get_journal_date(self): """Get journal date. Returns: str: Journal date. """ return self.journal_date def set_line_item_total(self, line_item_total): """Set line item total. Args: lin_item_total(float): Line item total. """ self.line_item_total = line_item_total def get_line_item_total(self): """Get line item total. Returns: float: Line item total. """ return self.line_item_total def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_price_precision(self, price_precision): """Set price precision. Args: price_precision(int): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: int: Price precision. """ return self.price_precision def set_taxes(self, tax): """Set taxes. Args: tax(instance): Tax. """ self.taxes.append(tax) def get_taxes(self): """Get taxes. Returns: list of instance: List of tax object. """ return self.taxes def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def to_json(self): """This method is used to create json object for journals. Returns: dict: Response containing json object for journals. """ data = {} if self.journal_date != '': data['journal_date'] = self.journal_date if self.reference_number != '': data['reference_number'] = self.reference_number if self.notes != '': data['notes'] = self.notes if self.line_items: data['line_items'] = [] for value in self.line_items: line_item = value.to_json() data['line_items'].append(line_item) return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Journal.py
Journal.py
from books.model.Address import Address class Bill: """This class is used to create an object for Bills.""" 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 set_bill_id(self, bill_id): """Set bill id. Args: bill_id(str): Bill id. """ self.bill_id = bill_id def get_bill_id(self): """Get bill id. Returns: str: Bill id. """ return self.bill_id def set_bill_payment_id(self, bill_payment_id): """Set bill payment id. Args: bill_payment_id(str): Bill payment id. """ self.bill_payment_id = bill_payment_id def get_bill_payment_id(self): """Get bill payment id. Returns: str: Bill payment id. """ return self.bill_payment_id def set_amount_applied(self, amount_applied): """Set amount applied. Args: amount_applied(float): Amount applied. """ self.amount_applied = amount_applied def get_amount_applied(self): """Get amount applied. Returns: float: Amount applied. """ return self.amount_applied def set_vendor_id(self, vendor_id): """Set vendor id. Args: vendor_id(str): Vendor id. """ self.vendor_id = vendor_id def set_is_inclusive_tax(self, is_inclusive_tax): """Set vendor id. Args: is_inclusive_tax(bool): is_inclusive_tax. """ self.is_inclusive_tax = is_inclusive_tax def get_vendor_id(self): """Get vendor id. Returns: str: Vendor id. """ return self.vendor_id def set_vendor_name(self, vendor_name): """Set vendor name. Args: vendor_name(str): Vendor name. """ self.vendor_name = vendor_name def get_vendor_name(self): """Get vendor name. Returns: str: Vendor name. """ return self.vendor_name def set_unused_credits_payable_amount(self, unused_credits_payable_amount): """Set unused amount payable amount. Args: unused_credits_payable_amount(float): Unused amount payable amount. """ self.unused_credits_payable_amount = unused_credits_payable_amount def get_unused_payable_amount(self): """Get unused amount payable amount. Returns: float: Unused amount payable amount. """ return self.unused_credits_payable_amount def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_bill_number(self, bill_number): """Set bill number. Args: bill_number(str): Bill number. """ self.bill_number = bill_number def get_bill_number(self): """Get bill number. Returns: str: Bill number. """ return self.bill_number def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_due_date(self, due_date): """Set due date. Args: due_date(str): Due date. """ self.due_date = due_date def get_due_date(self): """Get due date. Returns: str: Due date. """ return self.due_date def set_due_by_days(self, due_by_days): """Set due by days. Args: due_by_days(int): Due by days. """ self.due_by_days = due_by_days def get_due_by_days(self): """Get due by days. Returns: int: Due by days. """ return self.due_by_days def set_due_in_days(self, due_in_days): """Set due in days. Args: due_in_days(str): Due in days. """ self.due_in_days = self.due_in_days def get_due_in_days(self): """Get due in days. Returns: str: Due in days. """ return self.due_in_days 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 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_price_precision(self, price_precision): """Set price precision. Args: price_precision(int): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: int: Price precision. """ return self.price_precision def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_line_items(self, line_item): """Set line items. Args: line_item(instance): Line item object. """ self.line_items.append(line_item) def get_line_items(self): """Get line items. Returns: list of instance: List of line items object. """ return self.line_items def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_tax_total(self, tax_total): """Set tax total. Args: tax_total(float): Tax total. """ self.tax_total = tax_total def get_tax_total(self): """Get tax total. Returns: tax_total(float): Tax total. """ return self.tax_total def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_taxes(self, tax): """Set taxes. Args: tax(instance): Tax object. """ self.taxes.append(tax) def get_taxes(self): """Get taxes. Returns: list of instance: List of tax object. """ return self.taxes def set_payment_made(self, payment_made): """Set payment made. Args: payment_made(float): Payment made. """ self.payment_made = payment_made def get_payment_made(self): """Get payment made. Returns: float: Payment made. """ return self.payment_made def set_balance(self, balance): """Set balance. Args: balance(float): Balance. """ self.balance = balance def get_balance(self): """Get balance. Returns: float: Balance. """ return self.balance def set_billing_address(self, billing_address): """Set billling address, Args: billing_address(instance): Billing address object. """ self.billing_address = billing_address def get_billing_address(self): """Get billing address. Returns: instance: Billing address object. """ return self.billing_address def set_payments(self, payments): """Set payments. Args: payments(instance): Payments object. """ self.payments.append(payment) def get_payments(self): """Get payments. Returns: list of instance: List of payments object. """ return self.payments def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def set_reference_id(self, reference_id): """Set reference id. Args: reference_id(str): Reference id. """ self.reference_id = reference_id def get_reference_id(self): """Get reference id. Returns: str: Reference id. """ return self.reference_id def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def set_attachment_name(self, attachment_name): """Set attachment name. Args: attachment_name(str): Attachment name. """ self.attachment_name = attachment_name def get_attachment_name(self): """Get attachment name. Returns: str: Attachment name. """ return self.attachment_name def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_rate(self, rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def set_quantity(self, quantity): """Set quantity. Args: quantity(float): Quantity. """ self.quantity = quantity def get_quantity(self): """Get quantity. Returns: float: Quantity. """ return self.quantity def set_tax_id(self, tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str: Tax id. """ return self.tax_id def set_due_days(self, due_days): """Set due days. Args: due_days(str): Due days. """ self.due_days = due_days def get_due_days(self): """Get due days. Returns: str: Due days. """ return self.due_days def to_json(self): """This method is used to convert bill object to json object. Returns: dict: Dictionary containing json object for Bills. """ data = {} if self.bill_id != '': data['bill_id'] = self.bill_id if self.amount_applied > 0: data['amount_applied'] = self.amount_applied if self.vendor_id != '': data['vendor_id'] = self.vendor_id if self.is_inclusive_tax: data['is_inclusive_tax'] = self.is_inclusive_tax if self.bill_number != '': data['bill_number'] = self.bill_number if self.reference_number != '': data['reference_number'] = self.reference_number if self.date != '': data['date'] = self.date if self.due_date != '': data['due_date'] = self.due_date if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.line_items: data['line_items'] = [] for value in self.line_items: line_item = value.to_json() data['line_items'].append(line_item) if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Bill.py
Bill.py
class CreditnoteSetting: """This class is used to create object for creditnotes settings.""" def __init__(self): """Initialize parameters for creditnotes settings.""" self.auto_generate = None self.prefix_string = "" self.reference_text = "" self.next_number = "" self.notes = "" self.terms = "" def set_auto_generate(self, auto_generate): """Set whether auto number generation is enabled. Args: auto_generate(bool): True to enable auto number genration else false. """ self.auto_generate = auto_generate def get_auto_generate(self): """Set whether auto number generation is enabled. Returns: bool: True to enable auto number genration else false. """ return self.auto_generate def set_prefix_string(self, prefix_string): """Set prefix string. Args: prefix_string(str): Prefix string. """ self.prefix_string = prefix_string def get_prefix_string(self): """Get prefix string. Returns: str: Prefix string. """ return self.prefix_string def set_reference_text(self, reference_text): """Set reference text. Args: reference_text(str): Reference text. """ self.reference_text = reference_text def get_reference_text(self): """Get reference text. Returns: str: Reference text. """ return self.reference_text def set_next_number(self, next_number): """Set reference number. Args: reference_number(str): Reference number. """ self.next_number = next_number def get_next_number(self): """Get next number. Returns: str: Next number. """ return self.next_number def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def to_json(self): """This method is used to convert creditnote setting object to json objcet. Returns: dict: Dictionary containing json object for credit note setting. """ data = {} if self.auto_generate is not None: data['auto_generate'] = self.auto_generate if self.prefix_string != '': data['prefix_string'] = self.prefix_string if self.reference_text != '': data['reference_text'] = self.reference_text if self.next_number != '': data['next_number'] = self.next_number if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/CreditnoteSetting.py
CreditnoteSetting.py
class BankRule: """This class is used to create object for bank rules.""" def __init__(self): """Initialize parameters for Bank rules.""" self.rule_id = '' self.rule_name = '' self.rule_order = 0 self.apply_to = '' self.target_account_id = '' self.apply_to = '' self.criteria_type = '' self.criterion = [] self.record_as = '' self.account_id = '' self.account_name = '' self.tax_id = '' self.reference_number = '' self.customer_id = '' self.customer_name = '' def set_rule_id(self, rule_id): """Set rule id. Args: rule_id(str): Rule id. """ self.rule_id = rule_id def get_rule_id(self): """Get rule id. Returns: str: Rule id. """ return self.rule_id def set_rule_name(self, rule_name): """Set rule name. Args: rule_name(str): Rule name. """ self.rule_name = rule_name def get_rule_name(self): """Get rule name. Returns: str:Rule name. """ return self.rule_name def set_rule_order(self, rule_order): """Set rule order. Args: rule_order(int): Rule order. """ self.rule_order = rule_order def get_rule_order(self): """Get rule order. Returns: int: Rule order. """ return self.rule_order def set_apply_to(self, apply_to): """Set apply to. Args: apply_to(str): Apply to. """ self.apply_to = apply_to def get_apply_to(self): """Get apply to. Returns: str: Apply to. """ return self.apply_to def set_criteria_type(self, criteria_type): """Set criteria type. Args: criteria_type(str): Criteria type. """ self.criteria_type = criteria_type def get_criteria_type(self): """Get criteria type. Returns: str: Criteria type. """ return self.criteria_type def set_target_account_id(self, target_account_id): """Set target account id. Args: target_account_id(str): Target account id. """ self.target_account_id = target_account_id def get_target_account_id(self): """Get target account id. Returns: str: Target account id. """ return self.target_account_id def set_criterion(self, criteria): """Set criterion. Args: criteria(instance): Criteria object. """ self.criterion.append(criteria) def get_criterion(self): """Get criterion. Returns: list of instance: List of criteria object. """ return self.criterion def set_record_as(self, record_as): """Set record as. Args: record_as(str): Record as. """ self.record_as = record_as def get_record_as(self): """Get record as. Returns: str: Record as. """ return self.record_as def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_tax_id(self, tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str:Tax id. """ return self.tax_id def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = '' def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def to_json(self): """This method is used to convert bills object to json object. Returns: dict: Dictionary containing json object for bank rules. """ data = {} if self.rule_name != '': data['rule_name'] = self.rule_name if self.target_account_id != '': data['target_account_id'] = self.target_account_id if self.apply_to != '': data['apply_to'] = self.apply_to if self.criteria_type != '': data['criteria_type'] = self.criteria_type if self.criterion: data['criterion'] = [] for value in self.criterion: criteria = value.to_json() data['criterion'].append(criteria) if self.record_as != '': data['record_as'] = self.record_as if self.account_id != '': data['account_id'] = self.account_id if self.tax_id != '': data['tax_id'] = self.tax_id if self.reference_number != '': data['reference_number'] = self.reference_number if self.customer_id != '': data['customer_id'] = self.customer_id return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/BankRule.py
BankRule.py
class DefaultTemplate: """This class is used to create object for default templates.""" def __init__(self): """Initialize the parameters for default temmplates.""" self.invoice_template_id = '' self.invoice_template_name = '' self.estimate_template_id = '' self.estimate_template_name = '' self.creditnote_template_id = '' self.creditnote_template_name = '' self.invoice_email_template_id = '' self.invoice_email_template_name = '' self.estimate_email_template_id = '' self.estimate_email_template_name = '' self.creditnote_email_template_id = '' self.creditnote_email_template_name = '' def set_invoice_template_id(self, invoice_template_id): """Set default invoice template id used for this contact while creating invoice. Args: invoice_template_id(str): Default invoice template id used for this contact while creating invoice. """ self.invoice_template_id = invoice_template_id def get_invoice_template_id(self): """Get default invoice template id used for this contact while creating invoice. Returns: str: Default invoice template id used for this contact while creating invoice. """ return self.invoice_template_id def set_invoice_template_name(self, invoice_template_name): """Set default invoice template name used for this contact while creating invoice. Args: invoice_template_name(str): Default invoice template name used for this contact while creating invoice. """ self.invoice_template_name = invoice_template_name def get_invoice_template_name(self): """Get default invoice template name used for this contact while creating invoice. Returns: str: Default invoice template name used for this contact while creating invoice. """ return self.invoice_template_name def set_estimate_template_id(self, estimate_template_id): """Set default estimate template id used for this contact while creating estimate. Args: estimate_template_id(str): Default estimate template id used for this contact while creating estimate. """ self.estimate_template_id = estimate_template_id def get_estimate_template_id(self): """Get default estimate template id used for this contact while creating estimate. Returns: str: Default estimate template id used for this contact while creating estimate. """ return self.estimate_template_id def set_estimate_template_name(self, estimate_template_name): """Set default estimate template name used for this contact while creating estimate. Args: estimate_template_name(str): Default estimate template name used for this contact while creating estimate. """ self.estimate_template_name = estimate_template_name def get_estimate_template_name(self): """Get default estimate template name used for this contact while creating estimate. Returns: str: Default estimate template name used for this contact while creating estimate. """ return self.estimate_template_name def set_creditnote_template_id(self, creditnote_template_id): """Set default creditnote template id used for this contact while creating creditnote. Args: creditnote_template_id(str): Default creditnote template id used for this contact while creating creditnote. """ self.creditnote_template_id = creditnote_template_id def get_creditnote_template_id(self): """Get default creditnote template id used for this contact while creating creditnote. Returns: str: Default creditnote template id used for this contact while creating creditnote. """ return self.creditnote_template_id def set_creditnote_template_name(self, creditnote_template_name): """Set default creditnote template name used for this contact while creating creditnote. Args: creditnote_template_name(str): Default creditnote template name used for this contact while creating creditnote. """ self.creditnote_template_name = creditnote_template_name def get_creditnote_template_name(self): """Get default creditnote template id used for this contact while creating creditnote. Returns: str: Default creditnote template id used for this contact while creating creditnote. """ return self.creditnote_template_name def set_invoice_email_template_id(self, invoice_email_template_id): """Set default invoice email template id used for this contact while creating invoice. Args: invoice_email_template_id(str): Default invoice template id used for this contact while creating invoice """ self.invoice_email_template_id = invoice_email_template_id def get_invoice_email_template_id(self): """Get default invoice email template id used for this contact while creating invoice. Returns: str: Default invoice email template id used for this contact while creating invoice. """ return self.invoice_email_template_id def set_invoice_email_template_name(self, invoice_email_template_name): """Set default invoice email template name used for this contact while creating invocie. Args: invoice_email_template_name(str): Default invoice email template name used for this contact while creating invocie. """ self.invoice_email_template_name = invoice_email_template_name def get_invoice_email_template_name(self): """Get default invoice email template name used for this contact while creating invoice. Returns: str: Default invoice email template name used for this contact while creating invoice. """ return self.invoice_email_template_name def set_estimate_email_template_id(self, estimate_email_template_id): """Set default estimate template id used for this contact while creating estimate. Args: estimate_email_template_id(str): Default estimate template id used for this cotnact while creating estimate. """ self.estimate_email_template_id = estimate_email_template_id def get_estimate_email_template_id(self): """Get default estimate email template id used for this contact while creating estimate. Returns: str: Default estimate template id used for this cotnact while creating estimate. """ return self.estimate_email_template_id def set_estimate_email_template_name(self, estimate_email_template_name): """Set default estimate email template name used for this contact while creating estimate. Args: estimate_email_template_name(str): Default estimate email template name used for this contact while ccreating estimate. """ self.estimate_email_template_name = estimate_email_template_name def get_estimate_email_template_name(self): """Get default estimate email template name used for this contact while creating estimate. Returns: str: Default estimate email template name used for this contact while creating estimate. """ return self.estimate_email_template_name def set_creditnote_email_template_id(self, creditnote_email_template_id): """Set default creditnote email template id used for this contact while creating creditnote. Args: creditnote_email_template_id(str): Default creditnote email template id used for this contact while creating creditnote. """ self.creditnote_email_template_id = creditnote_email_template_id def get_creditnote_email_template_id(self): """Get default creditnote email template id used for this contact while creating creditnote. Returns: str: Default creditnote email template id used for this contact while creating creditnote. """ return self.creditnote_email_template_id def set_creditnote_email_template_name(self, creditnote_email_template_name): """Set default creditnote email template name used for this contact while creating creditnote. Args: creditnote_email_template_name(str): Default creditnote email template name used for this contact while creating creditnote. """ self.creditnote_email_template_name = creditnote_email_template_name def get_creditnote_email_template_name(self): """Get default creditnote email template name used for this contact while creating creditnote. Returns: str: Default creditnote email template name used for this contact while creating creditnote. """ return self.creditnote_email_template_name
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/DefaultTemplate.py
DefaultTemplate.py
from books.model.Term import Term from books.model.AddressFormat import AddressFormat class Preference: """This class is used to create object for preferences.""" def __init__(self): """Initialize parameters for Preferences object.""" self.convert_to_invoice = None self.attach_pdf_for_email = '' self.estimate_approval_status = '' self.notify_me_on_online_payment = None self.send_payment_receipt_acknowledgement = None self.auto_notify_recurring_invoice = None self.snail_mail_include_payment_stub = None self.is_show_powered_by = None self.attach_expense_receipt_to_invoice = None self.is_estimate_enabled = None self.is_project_enabled = None self.is_purchaseorder_enabled = None self.is_salesorder_enabled = None self.is_salesorder_enabled = None self.is_pricebooks_enabled = None self.attach_payment_receipt_with_acknowledgement = None self.auto_reminders = [] self.terms = Term() self.address_formats = AddressFormat() self.allow_auto_categorize = '' def set_allow_auto_categorize(self, allow_auto_categorize): """Set allow auto categorize. Args: allow_auto_categorize(str): Allow auto categorize. """ self.allow_auto_categorize = allow_auto_categorize def get_allow_auto_categorize(self): """Get allow auto categorize. Returns: str: Allow auto categorize. """ return self.allow_auto_categorize def set_convert_to_invoice(self, convert_to_invoice): """Set whether to convert to invoice. Args: convert_to_invoice(bool): True to Convert to invoice else False. """ self.convert_to_invoice = convert_to_invoice def get_convert_to_invoice(self): """Get whether to convert to invoice. Returns: bool: True to Convert to invoice else false. """ return self.convert_to_invoice def set_attach_pdf_for_email(self, attach_pdf_for_email): """Set whether to attach pdf for email. Args: attach_pdf_for_email(bool): True to attach pdf for email. """ self.attach_pdf_for_email = attach_pdf_for_email def get_attach_pdf_for_email(self): """Get whether to attach pdf for email. Returns: bool: True to attach pdf for email. """ return self.attach_pdf_for_email def set_estimate_approval_status(self, estimate_approval_status): """Set estimate approval status. Args: estimate_approval_status(bool): Estimate approval status. """ self.estimate_approval_status = estimate_approval_status def get_estimate_approval_status(self): """Get estimate approval status. Returns: bool: Estimate approval status. """ return self.estimate_approval_status def set_notify_me_on_online_payment(self, notify_me_on_online_payment): """Set whether to notify me on online payment. Args: notify_me_on_online(bool): True to notify online payment else false. """ self.notify_me_on_online_payment = notify_me_on_online_payment def get_notify_me_on_online_payment(self): """Get whether to notify me on online payment. Returns: bool: True to notify online payment else False. """ return self.notify_me_on_online_payment def set_send_payment_receipt_acknowledgement(self, \ send_payment_receipt_acknowledgement): """Set whether to send payment receipt acknowledgement. Args: send_payment_receipt_acknowledgement(bool): True to send payment receipt acknowledgemnt else False. """ self.send_payment_receipt_acknowledgement = \ send_payment_receipt_acknowledgement def get_send_payment_receipt_acknowledgement(self): """Get whether to send payment receipt acknowledgement. Returns: bool: True to send payment receipt acknowledgemnt else False. """ return self.send_payment_receipt_acknowledgement def set_auto_notify_recurring_invoice(self, auto_notify_recurring_invoice): """Set whether to notify invoice automatically or not. Args: auto_notify_recurring_invoice(bool): True to auto notify recurring invoice else false. """ self.auto_notify_recurring_invoice = auto_notify_recurring_invoice def get_auto_notify_recurring_invoice(self): """Get whether to notify invoice automatically or not. Returns: bool: True if auto notify is enabled else false. """ return self.auto_notify_recurring_invoice def set_snail_mail_include_payment_stub(self, \ snail_mail_include_payment_stub): """Set snail mail include payment stub. Args: snail_mail_include_payment_stub(bool): Snail mail paymanet stub. """ self.snail_mail_include_payment_stub = snail_mail_include_payment_stub def get_snail_mail_include_payment_stub(self): """Get snail mail payment include stub. Returns: bool: Snail mail payment include stub. """ return self.snail_mail_include_payment_stub def set_is_show_powered_by(self, is_show_powered_by): """Set whether to show powered by. Args: is_show_powered_by(bool): True to show powered by. """ self.is_show_powered_by = is_show_powered_by def get_is_show_powered_by(self): """Get whether to show powered by. Returns: bool: True to show powered by else false. """ return self.is_show_powered_by def set_attach_expense_receipt_to_invoice(self, attach_receipt_to_invoice): """Set whether to attach receipt to invoice. Args: attach_receipt_to_invoice(bool): True to attach receipt to invoice. """ self.attach_expense_receipt_to_invoice = attach_receipt_to_invoice def get_attach_expense_receipt_to_invoice(self): """Get whether to attach receipt to invoice. Returns: bool: True to attach receipt to invoice. """ return self.attach_expense_receipt_to_invoice def set_is_estimate_enabled(self, is_estimate_enabled): """Set whether to enable estimate or not. Args: is_estimate_enabled(bool): True to enable estimate else False. """ self.is_estimate_enabled = is_estimate_enabled def get_is_estimate_enabled(self): """Get whether to enable estimate or not. Returns: bool: True to enable estimate else false. """ return self.is_estimate_enabled def set_is_project_enabled(self, is_project_enabled): """Set whether to enable project or not. Args: is_project_enabled(bool): True to enable project else False. """ self.is_project_enabled = is_project_enabled def get_is_project_enabled(self): """Get whether to enable project or not. Returns: bool: True to enable project else False. """ return self.is_project_enabled def set_is_purchaseorder_enabled(self, is_purchaseorder_enabled): """Set whether is purchaseorder enabled. Args: is_purchaseorder_enabled(bool):True if purchase order is enabled else false. """ self.is_purchaseorder_enabled = is_purchaseorder_enabled def get_is_purchaseorder_enabled(self): """Get whether is purchase order enabled. Returns: bool: True if purchase order is enabled else false. """ return self.is_purchaseorder_enabled def set_is_salesorder_enabled(self, is_salesorder_enabled): """Set whether salesorder is enabled. Args: is_salesorder_enabled(bool): True if salesorder is enabled else false. """ self.is_salesorder_enabled = is_salesorder_enabled def get_is_salesorder_enabled(self): """Get whether salesorder is enabled. Returns: bool: True if sales order is enabled else false. """ return self.is_salesorder_enabled def set_is_pricebooks_enabled(self, is_pricebooks_enabled): """Set is pricebooks enabled. Args: is_pricebooks_enabled(bool): True if pricebooks is enabled else false. """ self.is_pricebooks_enabled = is_pricebooks_enabled def get_is_pricebooks_enabled(self): """Get is pricebooks enabled. Returns: bool: True if price books is enabled else false. """ return self.is_pricebooks_enabled def set_attach_payment_receipt_with_acknowledgement(self, \ attach_payment_receipt_with_acknowledgement): """Set attachpayment receipt with acknowledgemnt. Args: attach_payment_receipt_with_acknowledgement(bool): True to attach payment receipt with acknowledgemnt. """ self.attach_payment_receipt_with_acknowledgement = \ attach_payment_receipt_with_acknowledgement def get_attach_payment_receipt_with_acknowledgemnt(self): """Get attach payment receipt with acknowledgement. Returns: bool: True to attach payment receipt with acknowledgment. """ return self.attach_payment_receipt_with_acknowledgement def set_auto_reminders(self, auto_reminder): """Set auto reminders. Args: auto_reminder(instance): Auto reminders. """ self.auto_reminders.append(auto_reminder) def get_auto_reminders(self): """Get auto reminders. Returns: list of instance: List of auto reminder object. """ return self.auto_reminders def set_terms(self, term): """Set terms. Args: term(instance): Terms object. """ self.terms = term def get_terms(self): """Get terms. Returns: instance: Term object. """ return self.terms def set_address_formats(self, address_formats): """Set address formats. Args: address_formats(instance): Address Formats. """ self.address_formats = address_formats def get_address_formats(self): """Get address formats. Returns: instance: Address formats. """ return self.address_formats def to_json(self): """This method is used to convert preference object to json format. Returns: dict: Dictionary containing json object for preferences. """ data = {} if self.convert_to_invoice is not None: data['convert_to_invoice'] = self.convert_to_invoice if self.notify_me_on_online_payment is not None: data['notify_me_on_online_payment'] = \ self.notify_me_on_online_payment if self.send_payment_receipt_acknowledgement is not None: data['send_payment_receipt_acknowledgement'] = \ self.send_payment_receipt_acknowledgement if self.auto_notify_recurring_invoice is not None: data['auto_notify_recurring_invoice'] = \ self.auto_notify_recurring_invoice if self.snail_mail_include_payment_stub != None: data['snail_mail_include_payment_stub'] = \ self.snail_mail_include_payment_stub if self.is_show_powered_by != None: data['is_show_powered_by'] = self.is_show_powered_by if self.attach_expense_receipt_to_invoice != None: data['attach_expense_receipt_to_invoice'] = \ self.attach_expense_receipt_to_invoice if self.is_estimate_enabled != None: data['is_estimate_enabled'] = self.is_estimate_enabled if self.is_project_enabled != None: data['is_project_enabled'] = self.is_project_enabled return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Preference.py
Preference.py
class CustomerPayment: """This class is used to create object for customer payments.""" def __init__(self): """Initialize parameters for customer payments.""" self.customer_id = '' self.invoices = [] self.payment_mode = '' self.description = '' self.date = '' self.reference_number = '' self.exchange_rate = 0.0 self.amount = 0.0 self.bank_charges = 0.0 self.tax_account_id = '' self.account_id = '' self.payment_id = '' self.invoice_id = '' self.payment_number = '' self.invoice_numbers = '' self.bcy_amount = 0 self.unused_amount = 0 self.bcy_unused_amount = 0 self.account_name = '' self.customer_name = '' self.created_time = '' self.last_modified_time = '' self.tax_account_name = '' self.tax_amount_withheld = 0.0 self.amount_applied = 0.0 def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_invoices(self, invoice): """Set invoices. Args: invoice(list) : List of invoice object. """ self.invoices.extend(invoice) def get_invoices(self): """Get invoices. Returns: list: List of invoices. """ return self.invoices def set_payment_mode(self, payment_mode): """Set mode of payment for the payment received. Args: payment_mode(str): Mode of payment. """ self.payment_mode = payment_mode def get_payment_mode(self): """Get mode of payment of the payment received. Returns: str: Mode of payment. """ return self.payment_mode def set_description(self, description): """Set description for the customer payment. Args: description(str): Description for the customer payment. """ self.description = description def get_description(self): """Get description of the customer payment. Returns: str: Description of the customer payment. """ return self.description def set_date(self, date): """Set date at which the payment is made. Args: date(str): Date at which payment is made. """ self.date = date def get_date(self): """Get date at which payment is made. Returns: str: Date at which payment is made. """ return self.date def set_reference_number(self, reference_number): """Set reference number for the customer payment. Args: reference_number(str): Reference number for the customer payment. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number of the customer payment. Returns: str: Reference number of the customer payment. """ return self.reference_number def set_exchange_rate(self, exchange_rate): """Set exchange rate for the currency. Args: exchange_rate(float): Exchange rate for thee currency. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate of the currency. Returns: float: Exchange rate of the currency. """ return self.exchange_rate def set_amount(self, amount): """Set payment amount made by the customer. Args: amount(float): Payment amount made by the customer. """ self.amount = amount def get_amount(self): """Get payment amount made by the customer. Returns: float: Payment amount made by the customer. """ return self.amount def set_bank_charges(self, bank_charges): """Set bank charges incurred. Args: bank_charges(float): Bank charges incurred. """ self.bank_charges = bank_charges def get_bank_charges(self): """Get bank charges incurred. Returns: float: Bank charges incurred. """ return self.bank_charges def set_tax_account_id(self, tax_account_id): """Set id for the tax account incase of withholding tax. Args: tax_account_id(str): Id for the tax account. """ self.tax_account_id = tax_account_id def get_tax_account_id(self): """Get id of the tax account. Returns: str: Id of the tax account. """ return self.tax_account_id def set_account_id(self, account_id): """Set ID for the cash/ bank account to which the payment has to be deposited. Args: account_id(str): Id for the cash or bank account. """ self.account_id = account_id def get_account_id(self): """Get ID of the cash/ bank account to which the payment has to be deposited. Returns: str: Id of the cash or bank account. """ return self.account_id def set_payment_id(self, payment_id): """Set payment id. Args: payment_id(str): Payment id. """ self.payment_id = payment_id def get_payment_id(self): """Get payment id. Returns: str: Payment id. """ return self.payment_id def set_payment_number(self, payment_number): """Set payment number. Args: payment_number(str): Payment number. """ self.payment_number = payment_number def get_payment_number(self): """Get payment number. Returns: str: Payment number. """ return self.payment_number def set_invoice_numbers(self, invoice_numbers): """Set invoice numbers. Args: invoice_numbers(str): invoice_numbers """ self.invoice_numbers = invoice_numbers def get_invoice_numbers(self): """Get invoice numbers. Returns: str: Invoice numbers """ return self.invoice_numbers def set_bcy_amount(self, bcy_amount): """Set bcy amount. Args: bcy_amount(int): bcy amount. """ self.bcy_amount = bcy_amount def get_bcy_amount(self): """Get bcy amount. Returns: int: bcy amount. """ return self.bcy_amount def set_unused_amount(self, unused_amount): """Set unused amount. Args: unused_amount(int): Unused amount. """ self.unused_amount = unused_amount def get_unused_amount(self): """Get unused amount. Returns: int: Unused amount. """ return self.unused_amount def set_bcy_unused_amount(self, bcy_unused_amount): """Set bcy unused amount. Args: bcy_unused_amount(int): bcy unused amount. """ self.bcy_unused_amount = bcy_unused_amount def get_bcy_unused_amount(self): """Get bcy unused amount. Returns: int: bcy unused amount. """ return self.bcy_unused_amount def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_customer_name(self, customer_name): """Set customer name. customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def set_tax_account_name(self, tax_account_name): """Set tax account name. Args: tax_account_name(str): Tax Account name. """ self.tax_account_name = tax_account_name def get_tax_account_name(self): """Get tax account name. Returns: str: Tax account name. """ return self.tax_account_name def set_tax_amount_withheld(self, tax_amount_withheld): """Set amount withheld for tax. Args: tax_amount_withheld(float): Amount withheld for tax. """ self.tax_amount_withheld = tax_amount_withheld def get_tax_amount_withheld(self): """Get amount withheld for tax. Returns: float: Amount withheld for tax. """ return self.tax_amount_withheld def to_json(self): """This method is used to convert customer payment object to json object. Returns: dict: Dictionary containing json object for customer payments. """ data = {} if self.customer_id != '': data['customer_id'] = self.customer_id if self.invoices: data['invoices'] = [] for value in self.invoices: invoice = value.to_json() data['invoices'].append(invoice) if self.payment_mode != '': data['payment_mode'] = self.payment_mode if self.description != '': data['description'] = self.description if self.date != '': data['date'] = self.date if self.reference_number != '': data['reference_number'] = self.reference_number if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.amount > 0: data['amount'] = self.amount if self.bank_charges > 0: data['bank_charges'] = self.bank_charges if self.tax_account_id != '': data['tax_account_id'] = self.tax_account_id if self.account_id != '': data['account_id'] = self.account_id if self.invoice_id != '': data['invoice_id'] = self.invoice_id if self.amount_applied > 0: data['amount_applied'] = self.amount_applied if self.payment_number != '': data['payment_number'] = self.payment_number return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/CustomerPayment.py
CustomerPayment.py
class LineItem: """This class is used to create object for line items.""" def __init__(self): """Initialize the parameters for line items.""" self.item_id = '' self.line_item_id = '' self.name = '' self.description = '' self.item_order = 0 self.bcy_rate = 0.0 self.rate = 0.00 self.quantity = 0 self.unit = '' self.discount = 0.00 self.tax_id = '' self.tax_name = '' self.tax_type = '' self.tax_percentage = 0.0 self.item_total = 0.0 self.expense_id = '' self.expense_item_id = '' self.expense_receipt_name = '' self.time_entry_ids = '' self.project_id = '' self.account_id = '' self.account_name = '' self.line_id = '' self.debit_or_credit = '' self.amount = 0.0 self.discount_amount = 0.0 self.hsn_or_sac = '' def set_hsn_or_sac(self,hsn_or_sac): """Set hsn_or_sac. Args: hsn_or_sac(str): hsn_or_sac. """ self.hsn_or_sac = hsn_or_sac def get_hsn_or_sac(self): """Get hsn_or_sac. Returns: str: hsn_or_sac. """ return self.hsn_or_sac def set_item_id(self,item_id): """Set item id. Args: item_id(str): Item id. """ self.item_id = item_id def get_item_id(self): """Get item id. Returns: str: Item id. """ return self.item_id def set_line_item_id(self,line_item_id): """Set line item id. Args: line_item_id(str): line_item_id """ self.line_item_id = line_item_id def get_line_item_id(self): """Get line item id. Returns: str: line item id. """ return self.line_item_id def set_name(self,name): """Set name of the line item. Args: name(str): Name of the line item. """ self.name = name def get_name(self): """Get name of the line item. Returns: str: Name of the line item. """ return self.name def set_description(self,description): """Set description of the line item. Args: description(str): Description of the line item. """ self.description = description def get_description(self): """Get description of the line item. Returns: str: Descritpion of the line item. """ return self.description def set_item_order(self,item_order): """Set item order. Args: item_order(int): Item order. """ self.item_order = item_order def get_item_order(self): """Get item order. Returns: int: Item order. """ return self.item_order def set_bcy_rate(self,bcy_rate): """Set bcy rate. Args: bcy_rate(float): Bcy rate. """ self.bc_rate = bcy_rate def get_bcy_rate(self): """Get bcy rate. Returns: float: Bcy rate. """ return self.bcy_rate def set_rate(self,rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def set_quantity(self,quantity): """Set quantity. Args: quantity(float): Quantity. """ self.quantity = quantity def get_quantity(self): """Get quantity. Returns: float: Quantity. """ return self.quantity def set_unit(self,unit): """Set unit. Args: unit(str): Unit. """ self.unit = unit def get_unit(self): """Get unit. Returns: str: Unit. """ return self.unit def set_discount(self,discount): """Set discount. Args: discount(str): Discount. """ self.discount = discount def get_discount(self): """Get discount. Returns: str: Discount. """ return self.discount def set_tax_id(self,tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str: Tax id. """ return self.tax_id def set_tax_name(self,tax_name): """Set tax name. Args: tax_name(str): Tax name. """ self.tax_name = tax_name def get_tax_name(self): """Get tax name. Returns: str: Tax name. """ return self.tax_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 set_tax_percentage(self,tax_percentage): """Set tax percentage. Args: tax_percentage(str): Tax percentage. """ self.tax_percentage = tax_percentage def get_tax_percentage(self): """Get tax percentage. Returns: str: Tax percentage. """ return self.tax_percentage def set_item_total(self,item_total): """Set item total. Args: item_total(int): Item total. """ self.item_total = item_total def get_item_total(self): """Get item total. Returns: int: Item total. """ return self.item_total def set_expense_id(self,expense_id): """Set expense id. Args: expense_id(str): Expense id. """ self.expense_id = expense_id def get_expense_id(self): """Get expense id. Args: expense_id(str): Expense id. """ return self.expense_id def set_expense_item_id(self,expense_item_id): """Set expense item id. Args: expense_item_id(str): Expense item id. """ self.expense_item_id = expense_item_id def get_expense_item_id(self): """Get expense item id. Returns: str: Expense item id. """ return self.expense_item_id def set_expense_receipt_name(self,expense_receipt_name): """Set expense receipt name. Args: expense_receipt_name(str): Expense receipt name. """ self.expense_receipt_name = expense_receipt_name def get_expense_receipt_name(self): """Get expense receipt name. Returns: str: Expense receipt name. """ return self.expense_receipt_name def set_time_entry_ids(self,time_entry_ids): """Set time entry ids. Args: time_entry_ids(str): Time entry ids. """ self.time_entry_ids = time_entry_ids def get_time_entry_ids(self): """Get time entry ids. Returns: str: Time entry ids. """ return self.time_entry_ids def set_project_id(self,project_id): """Set project id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id def set_account_id(self,account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_account_name(self,account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_line_id(self,line_id): """Set line id. Args: line_id(str): Line id. """ self.line_id = line_id def get_line_id(self): """Get line id. Returns: str: Line id. """ return self.line_id def set_debit_or_credit(self,debit_or_credit): """Set debit or credit. Args: debit_or_credit(str): Debit or credit. """ self.debit_or_credit = debit_or_credit def get_debit_or_credit(self): """Get debit or credit. Returns: str: Debit or credit. """ return self.debit_or_credit def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_discount_amount(self,discount_amount): """Set discount amount. Args: discount_amount(float): Discount amount. """ self.discount_amount = discount_amount def get_discount_amount(self): """Get discount amount. Returns: float: Discount amount. """ return self.discount_amount def to_json(self): """This method is used to create json object for line items. Returns: dict: Dictionary containing json object for line items. """ line_item = {} if self.item_id != '': line_item['item_id'] = self.item_id if self.account_id != '': line_item['account_id'] = self.account_id if self.name != '': line_item['name'] = self.name if self.description != '': line_item['description'] = self.description if self.unit != '': line_item['unit'] = self.unit if self.rate != None: line_item['rate'] = self.rate if self.item_order != None: line_item['item_order'] = self.item_order if self.quantity != None: line_item['quantity'] = self.quantity if self.discount is not None: line_item['discount'] = self.discount if self.tax_id != '': line_item['tax_id'] = self.tax_id if self.amount > 0: line_item['amount'] = self.amount if self.debit_or_credit != '': line_item['debit_or_credit'] = self.debit_or_credit if self.hsn_or_sac != '': line_item['hsn_or_sac'] = self.hsn_or_sac return line_item
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/LineItem.py
LineItem.py
class EstimateSetting: """This class is used to create object for estimate settings.""" def __init__(self): """Initialize parameters for estimate settings.""" self.auto_generate = None self.prefix_string = "" self.start_at = 0 self.next_number = "" self.quantity_precision = 0 self.discount_type = "" self.is_discount_before_tax = None self.reference_text = "" self.notes = "" self.terms = "" self.terms_to_invoice = None self.notes_to_invoice = None self.warn_estimate_to_invoice = None self.is_sales_person_required = None self.default_template_id = "" def set_default_template_id(self, default_template_id): """Set default template id. Args: default_template_id(str): Default template id. """ self.default_template_id = default_template_id def get_default_template_id(self): """Get default template id. Returns: str: Default template id. """ return self.default_template_id def set_auto_generate(self, auto_generate): """Set whether to enable or disable auto number generation. Args: auto_generate(bool): True to enable auto number generation. """ self.auto_generate = auto_generate def get_auto_generate(self): """Get whether to enable or disable auto number generation. Returns: bool: True to enable auto number generation. """ return self.auto_generate def set_prefix_string(self, prefix_string): """Set prefix string. Args: prefix_string(str): Prefix string. """ self.prefix_string = prefix_string def get_prefix_string(self): """Get prefix string. Returns: str: Prefix string. """ return self.prefix_string def set_start_at(self, start_at): """Set start at. Args: start_at(int): Start at. """ self.start_at = start_at def get_start_at(self): """Get start at. Returns: str: Get start at. """ return self.start_at def set_next_number(self, next_number): """Set next number. Args: next_number(str): Next number. """ self.next_number = next_number def get_next_number(self): """Get next number. Returns: str: Next number. """ return self.next_number def set_quantity_precision(self, quantity_precision): """Set quantity precision. Args: quantity_precision(int): Quantity precision. """ self.quantity_precision = quantity_precision def get_quantity_precision(self): """Get quantity precision. Returns: int: Quantity precision. """ return self.quantity_precision def set_discount_type(self, discount_type): """Set discount type. Args: discount_type(str): Discount type. """ self.discount_type = discount_type def get_discount_type(self): """Get discount type. Returns: str: Discount type. """ return self.discount_type def set_is_discount_before_tax(self, is_discount_before_tax): """Set whether to discount before tax. Args: is_discount_before_tax(bool): True to discount before tax. """ self.is_discount_before_tax = is_discount_before_tax def get_is_discount_before_tax(self): """Get whether to discount before tax. Returns: bool: True to discount before tax else false. """ return self.is_discount_before_tax def set_reference_text(self, reference_text): """Set reference text. Args: reference_text(str): Reference text. """ self.reference_text = reference_text def get_reference_text(self): """Get reference text. Returns: str: Reference text. """ return self.reference_text def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def set_terms_to_invoice(self, terms_to_invoice): """Set terms to invoice. Args: terms_to_invoice(bool): True to determine whether terms and conditions field is to be copied from estimate to invoice else False. """ self.terms_to_invoice = terms_to_invoice def get_terms_to_invoice(self): """Get terms to invoice. Returns: bool: True to determine whether terms and conditions field is to be copied from estimate to invoice else False. """ return self.terms_to_invoice def set_notes_to_invoice(self, notes_to_invoice): """Set notes to invoice. Args: notes_to_invoice(bool): True to determine whether customer notes field is to be copied from estimate to invoice. """ self.notes_to_invoice = notes_to_invoice def get_notes_to_invoice(self): """Get notes to invoice. Returns: bool: True to determine whether customer notes field is to be copied from estimate to invoice. """ return self.notes_to_invoice def set_warn_estimate_to_invoice(self, warn_estimate_to_invoice): """Set whether to warn while converting from estimate to invoice. Args: warn_estimate_to_invoice(bool): True to warn while converting from estiamte to invoice. """ self.warn_estimate_to_invoice = warn_estimate_to_invoice def get_warn_estimate_to_invoice(self): """Get whether to warn while converting form estimate to invoice. Returns: bool: True to warn while converting from estimate to invoice. """ return self.warn_estimate_to_invoice def set_is_sales_person_required(self, is_sales_person_required): """Set whether sales person is required. Args: is_sales_person_required(bool): True if sales person is required else false. """ self.is_sales_person_required = is_sales_person_required def get_is_sales_person_required(self): """Get whether sales person is required. Returns: bool: True if sales person is required. """ return self.is_sales_person_required def to_json(self): """This method is used to convert estimate setting object to json object. Returns: dict: Dictionary containing json object for estimate setting. """ data = {} if self.auto_generate != None: data['auto_generate'] = self.auto_generate if self.prefix_string != "": data['prefix_string'] = self.prefix_string if self.start_at > 0: data['start_at'] = self.start_at if self.next_number != '': data['next_number'] = self.next_number if self.quantity_precision > 0: data['quantity_precision'] = self.quantity_precision if self.discount_type != '': data['discount_type'] = self.discount_type if self.reference_text != '': data['reference_text'] = self.reference_text if self.default_template_id != '': data['default_template_id'] = self.default_template_id if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms if self.terms_to_invoice is not None: data['terms_to_invoice'] = self.terms_to_invoice if self.notes_to_invoice is not None: data['notes_to_invoice'] = self.notes_to_invoice if self.warn_estimate_to_invoice is not None: data['warn_estimate_to_invoice'] = self.warn_estimate_to_invoice if self.is_sales_person_required is not None: data['is_sales_person_required'] = self.is_sales_person_required return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/EstimateSetting.py
EstimateSetting.py
from books.model.Address import Address class RecurringInvoice: """This class is used to creat object for Recurring invoice.""" 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 = [] def set_custom_fields(self, custom_fields): """Set custom fields. Args: custom_fields(list): List of custom fields. """ self.custom_fields.extend(custom_fields) def get_custom_fields(self): """Get custom fields. Returns: list: List of custom fields. """ return self.custom_fields 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_recurrence_name(self, recurrence_name): """Set name of the recurring invoice. Args: recurrence_name(str): Name of the recurring invoice. """ self.recurrence_name = recurrence_name def get_recurrence_name(self): """Get name of the recurring invoice. Returns: str: Name of the recurring invoice.. """ return self.recurrence_name def set_customer_id(self, customer_id): """Set ID for the customer for which recurring invoice has been created. Args: customer_id(str): Customer id for which recurring invoice has been created. """ self.customer_id = customer_id def get_customer_id(self): """Get ID for the customer for which recurring invoice has been created. Returns: str: Customer id for which recurring invoice has been created. """ return self.customer_id def set_contact_persons(self, contact_persons): """Set Contact persons associated with the recurring invoice. Args: contact_persons(list): List of contact persons id. """ self.contact_persons.extend(contact_persons) def get_contact_persons(self): """Get contact persons associated with the recurring invoice. Returns: list: List of contact persons id. """ return self.contact_persons def set_template_id(self, template_id): """Set ID of the pdf template associated with the recurring profile. Args: template_id(str): Template id. """ self.template_id = template_id def get_template_id(self): """Get ID of the pdf template associated with the recurring profile. Returns: str: Template id. """ return self.template_id def set_start_date(self, start_date): """Set start date for the recurring invoice. Args: start_date(str): Starting date of the recurring invoice. """ self.start_date = start_date def get_start_date(self): """Get start date of the recurring invoice. Returns: str: Starting date of the recurring invoice. """ return self.start_date def set_end_date(self, end_date): """Set the date at which the recurring invoice has to be expires. Args: end_date(str): Date on which recurring invoice expires. """ self.end_date = end_date def get_end_date(self): """Get the date at which the recurring invoice has to be expires. Returns: str: Date on which recurring invoice expires. """ return self.end_date def set_recurrence_frequency(self, recurrence_frequency): """Set the frequency for the recurring invoice. Args: recurrence_frequency(str): Frequency for the recurring invoice. Allowed values re days, weeks, months and years. """ self.recurrence_frequency = recurrence_frequency def get_recurrence_frequency(self): """Get the frequency of the recurring invoice. Returns: str: Frequency of the recurring invoice. """ return self.recurrence_frequency def set_repeat_every(self, repeat_every): """Set frequency to repeat. Args: repeat_every(int): Frequency to repeat. """ self.repeat_every = repeat_every def get_repeat_every(self): """Get frequency to repeat. Returns: int: Frequency to repeat. """ return self.repeat_every def set_payment_terms(self, payment_terms): """Set payment terms in days. Invoice due date will be calculated based on this. Args: payment_terms(int): Payment terms in days.Example 15, 30, 60. """ self.payment_terms = payment_terms def get_payment_terms(self): """Get payment terms. Returns: int: Payment terms in days. """ return self.payment_terms def set_payment_terms_label(self, payment_terms_label): """Set payment terms label. Args: payment_terms_label(str): Payment terms label. Default value for 15 days is "Net 15". """ self.payment_terms_label = payment_terms_label def get_payment_terms_label(self): """Get payment terms label. Returns: str: Payment terms label. """ return self.payment_terms_label def set_exchange_rate(self, exchange_rate): """Set exchange rate for the currency. Args: exchange_rate(float): Exchange rate for currency. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate of the currency. Returns: float: Exchange rate of the currency. """ return self.exchange_rate def set_payment_options(self, payment_gateways): """Set payment options associated with the recurring invoice, online payment gateways. Args: payment_gateways(instance): Online payment gateway through which payment can be made. """ self.payment_options['payment_gateways'].append(payment_gateways) def get_payment_options(self): """Get payment options associated with the recurring invoice, online payment gateways. Returns: dict: Payment options details. """ return self.payment_options def set_discount(self, discount): """Set discount applied to the invoice. Args: discount(str): Discount applied to the invoice. It can be either in % or in amount. """ self.discount = discount def get_discount(self): """Get discount applied to the invoice. Returns: str: Discount applied to the invoice. """ return self.discount def set_is_discount_before_tax(self, is_discount_before_tax): """Set whether to discount before tax. Args: is_discount_before_tax(bool): True to discount befroe tax else False. """ self.is_discount_before_tax = is_discount_before_tax def get_is_discount_before_tax(self): """Get whether to discount before tax. Returns: bool: True to discount before tax else False. """ return self.is_discount_before_tax def set_discount_type(self, discount_type): """Set how the discount is specified. Args: discount_type(str): Discount type. Allowed values are entity_level and item_level. """ self.discount_type = discount_type def get_discount_type(self): """Get discount type. Returns: str: Discount type. """ return self.discount_type def set_line_items(self, line_item): """Set line items for an invoice. Args: line_items(instance): Line items object. """ self.line_items.append(line_item) def get_line_items(self): """Get line items of an invoice. Returns: list: List of line items instance. """ return self.line_items def set_salesperson_name(self, salesperson_name): """Set name of the salesperson. Args: salesperson_name(str): Salesperson name. """ self.salesperson_name = salesperson_name def get_salesperson_name(self): """Get salesperson name. Returns: str: Salesperson name. """ return self.salesperson_name def set_shipping_charge(self, shipping_charge): """Set shipping charges applied to the invoice. Args: shipping_charge(float): Shipping charges applied to the invoice. """ self.shipping_charge = shipping_charge def get_shipping_charge(self): """Get shipping charges applied to invoice. Returns: float: Shipping charges applied to the invoice. """ return self.shipping_charge def set_adjustment(self, adjustment): """Set adjustments made to the invoice. Args: adjustment(float): Adjustments made to the invoice. """ self.adjustment = adjustment def get_adjustment(self): """Get adjustments made to the invoice. Returns: float: Adjustments made to the invoice. """ return self.adjustment def set_adjustment_description(self, adjustment_description): """Set the adjustment description. Args: adjustment_description(str): Adjustment description. """ self.adjustment_description = adjustment_description def get_adjustment_description(self): """Get adjustment description. Returns: str: Adjustment description. """ return self.adjustment_description def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def set_recurring_invoice_id(self, recurring_invoice_id): """Set recurring invoice id. Args: recurring_invoice_id(str): Recurring invoice id. """ self.recurring_invoice_id = recurring_invoice_id def get_recurring_invoice_id(self): """Get recurring invoice id. Returns: str: Recurring invoice id. """ return self.recurring_invoice_id def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_last_sent_date(self, last_sent_date): """Set last sent date. Args: last_sent_date(str): Last sent date. """ self.last_sent_date = last_sent_date def get_last_sent_date(self): """Get last sent date. Returns: str: Last sent date. """ return self.last_sent_date def set_next_invoice_date(self, next_invoice_date): """Set next invoice date. Args: next_invoice_date(str): Next invoice date. """ self.next_invoice_date = next_invoice_date def get_next_invoice_date(self): """Get next invoice date. Returns: str: Next invoice date. """ return self.next_invoice_date def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def set_price_precision(self, price_precision): """Set price precision. Args: price_precision(int): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: int: Price precision. """ return self.price_precision 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_late_fee(self, late_fee): """Set late fee. Args: late_fee(dict): Late fee. """ self.late_fee = late_fee def get_late_fee(self): """Get late fee. Returns: dict: LAte fee. """ return self.late_fee def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_tax_total(self, tax_total): """Set tax total. Args: tax_total(float): Tax total. """ self.tax_total = tax_total def get_tax_total(self): """Get tax total. Returns: float: Tax total. """ return self.tax_total def set_allow_partial_payments(self, allow_partial_payments): """Set whether to allow partial payments or not. Args: allow_partial_payments(bool): True to allow partial payments. """ self.allow_partial_payments = allow_partial_payments def get_allow_partial_payments(self): """Get whether partial payments are allowed or not. Returns: str: True if partial payments are allowed else False. """ return self.allow_partial_payments def set_taxes(self, taxes): """Set taxes. Args: taxes(instance): Tax object. """ self.taxes.append(taxes) def get_taxes(self): """Get taxes. Returns: list: List of taxes object. """ return self.taxes def set_billing_address(self, address): """Set billing address. Args: address(instance): Address object. """ self.billing_address = (address) def get_billing_address(self): """Get billing address. Returns: instance: Billing address object. """ return self.billing_address def set_shipping_address(self, address): """Set shipping address. Args: address(instance): Shipping address. """ self.shipping_address = address def get_shipping_address(slef): """Get shipping address. Returns: instance: Shipping address object. """ return self.shipping_address def set_template_name(self, template_name): """Set template name. Args: template_name(str): Template name. """ self.template_name = template_name def get_template_name(self): """Get template name. Returns: str: Template name. """ return self.template_name def set_salesperson_id(self, salesperson_id): """Set salesperson id. Args: salesperson_id(str): Salesperson id. """ self.salesperson_id = salesperson_id def get_salesperson_id(self): """Get salesperson id. Returns: str: Salesperson id. """ return self.salesperson_id def to_json(self): """This method is used to convert recurring invoice object to json object. Returns: dict: Dictionary containing json object for recurring invoice. """ data = {} if self.recurrence_name != '': data['recurrence_name'] = self.recurrence_name if self.customer_id != '': data['customer_id'] = self.customer_id if self.contact_persons: data['contact_persons'] = self.contact_persons if self.template_id != '': data['template_id'] = self.template_id if self.start_date != '': data['start_date'] = self.start_date if self.end_date != '': data['end_date'] = self.end_date if self.recurrence_frequency != '': data['recurrence_frequency'] = self.recurrence_frequency if self.repeat_every != '': data['repeat_every'] = self.repeat_every if self.payment_terms != '': data['payment_terms'] = self.payment_terms if self.payment_terms_label != '': data['payment_terms_label'] = self.payment_terms_label if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.payment_options['payment_gateways']: data['payment_options'] = { 'payment_gateways': [] } for value in self.payment_options['payment_gateways']: data['payment_options']['payment_gateways'].append(\ value.to_json()) if self.discount > 0: data['discount'] = self.discount if self.is_discount_before_tax is not None: data['is_discount_before_tax'] = self.is_discount_before_tax if self.discount_type != '': data['discount_type'] = self.discount_type if self.line_items: data['line_items'] = [] for value in self.line_items: line_item = value.to_json() data['line_items'].append(line_item) if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms if self.salesperson_name != '': data['salesperson_name'] = self.salesperson_name if self.shipping_charge > 0: data['shipping_charge'] = self.shipping_charge if self.adjustment != '': data['adjustment'] = self.adjustment if self.adjustment_description != '': data['adjustment_description'] = self.adjustment_description return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/RecurringInvoice.py
RecurringInvoice.py
class Item: """This class is used to create object for item.""" def __init__(self): """Initialize parameters for Item object.""" self.item_id = '' self.name = '' self.status = '' self.description = '' self.rate = 0.0 self.unit = '' self.account_id = '' self.account_name = '' self.tax_id = '' self.tax_name = '' self.tax_percentage = 0.0 self.tax_type = '' self.item_tax_preferences = [] def set_item_tax_preferences(self, item_tax_preference): """Set item_tax_preferences. Args: item_tax_preference(instance): item_tax_preference object. """ self.item_tax_preferences.append(item_tax_preference) def get_item_tax_preferences(self): """Get item_tax_preference. Returns: instance: item_tax_preference object. """ return self.item_tax_preferences def set_item_id(self, item_id): """Set item id. Args: item_id(str): Item id. """ self.item_id = item_id def get_item_id(self): """Get item id. Returns: str: Item id. """ return self.item_id 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_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_description(self,description): """Set description. Args: descritpion(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Descritpion. """ return self.description def set_rate(self, rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def set_unit(self, unit): """Set unit. Args: unit(float): Unit. """ self.unit = unit def get_unit(self): """Get unit. Returns: float: Unit. """ return self.unit def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_account_name(self, account_name): """Set account name. Args: str: Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_tax_id(self, tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str: Tax id. """ return self.tax_id def set_tax_name(self, tax_name): """Set tax name. Args: tax_name(str): Tax name. """ self.tax_name = tax_name def get_tax_name(self): """Get tax name. Returns: str: Tax name. """ return self.tax_name def set_tax_percentage(self, tax_percentage): """Set tax percentage. Args: tax_percentage(float): Tax percentage. """ self.tax_percentage = tax_percentage def get_tax_percentage(self): """Get tax percentage. Returns: float: Tax percentage. """ return self.tax_percentage 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 create json object for items. Returns: dict: Dictionary containing json object for items. """ data = {} if self.name != '': data['name'] = self.name if self.description != '': data['description'] = self.description if self.rate > 0: data['rate'] = self.rate if self.account_id != '': data['account_id'] = self.account_id if self.tax_id != '': data['tax_id'] = self.tax_id if self.item_tax_preferences: data['item_tax_preferences'] = self.item_tax_preferences return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Item.py
Item.py
class PageContext: """This class is used to create object for page context.""" def __init__(self): """Initialize parameters for page context.""" self.page = 0 self.per_page = 0 self.has_more_page = None self.applied_filter = '' self.sort_column = '' self.sort_order = '' self.report_name = '' self.search_criteria = [] self.from_date = '' self.to_date = '' def set_page(self, page): """Set page number for the list. Args: page(int): Page number for list. """ self.page = page def get_page(self): """Get page number for the list. Returns: int: Page number for the list. """ return self.page def set_per_page(self, per_page): """Set details per page. Args: per_page(int): Details per page. """ self.per_page = per_page def get_per_page(self): """Get details per page. Returns: int: Details per page. """ return self.per_page def set_has_more_page(self, has_more_page): """Set has more page. Args: has_more_page(bool): Has more page. """ self.has_more_page = has_more_page def get_has_more_page(self): """Get has more page. Returns: bool: Has more page. """ return self.has_more_page def set_applied_filter(self, applied_filter): """Set applied filter for the report. Args: applied_filter(str): Applied filter for the report. """ self.applied_filter = applied_filter def get_applied_filter(self): """Get applied filter for the report. Returns: str: Applied filter for the report. """ return self.applied_filter def set_sort_column(self, sort_column): """Set sort column. Args: sort_column(str): Sort column. """ self.sort_column = sort_column def get_sort_column(self): """Get sort column. Returns: str: Sort column. """ return self.sort_column def set_sort_order(self, sort_order): """Set sort order. Args: sort_order(str): Sort order. """ self.sort_order = sort_order def get_sort_order(self): """Get sort order. Returns: str: Sort order. """ return self.sort_order def set_report_name(self, report_name): """Set report name. Args: report_name(str): Report name. """ self.report_name = report_name def get_report_name(self): """Get report name. Returns: str: Report name. """ return self.report_name def set_search_criteria(self, search_criteria): """Set search criteria. Args: search_criteria(instance): Search criteria object. """ self.search_criteria.append(search_criteria) def get_search_criteria(self): """Get search criteria. Returns: list of instance: List of search criteria object. """ return self.search_criteria def set_from_date(self, from_date): """Set from date. Args: from_date(str): From date. """ self.from_date = from_date def get_from_date(self): """Get from date. Returns: str: From date. """ return self.from_date def set_to_date(self, to_date): """Set to date. Args: to_date(str): To date. """ self.to_date = to_date def get_to_date(self): """Get to date. Returns: to_date(str): To date. """ return self.to_date
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/PageContext.py
PageContext.py
class Email: """This class is used to create a Email object.""" def __init__(self): """Initialize the parameters for email object.""" self.to_mail_ids = [] self.cc_mail_ids = [] self.subject = '' self.body = '' self.send_from_org_email_id = None self.file_name = '' self.contact_id = '' self.customer_id = '' self.gateways_configured = None self.attachment_name = '' self.to_contacts = [] self.from_emails = [] self.error_list = [] self.email_templates = [] self.deprecated_placeholders_used = [] self.gateways_associated = None self.attach_pdf = None self.file_name_without_extension = None def set_to_mail_ids(self, to_mail_ids): """Set the list of email address of the recipients. Args: to_mail_ids(list): List of email address of the recipients. """ self.to_mail_ids.extend(to_mail_ids) def get_to_mail_ids(self): """Get the list of email address of the recipients. Returns: list: List of email address of recipients. """ return self.to_mail_ids def set_cc_mail_ids(self, cc_mail_ids): """Set the list of email address of the recipients to be cced. Args: cc_mail_ids(list): List of email address of the recipients to be cced. """ self.cc_mail_ids.extend(cc_mail_ids) def get_cc_mail_ids(self): """Get the list of email address of the recipients to be cced. Returns: list: List of email address of the recipients to be cced. """ return self.cc_mail_ids def set_subject(self, subject): """Set subject for the email. Args: subject(str): Subject for the email. """ self.subject = subject def get_subject(self): """Get subject of the email. Returns: str: Subject of the email. """ return self.subject def set_body(self, body): """Set body for the email. Args: body(str): Body for the mail. """ self.body = body def get_body(self): """Get body of the mail. Returns: str: Body of the mail. """ return self.body def set_send_from_org_email_id(self, send_from_org_email_id): """Set the boolean to trigger the email from the organization's email address. Args: send_from_org_email_id(bool): True to send email from the organization's email address else False. """ self.send_from_org_email_id = send_from_email_id def get_send_from_org_email_id(self): """Get whether to send email from organization's email adress or not. Returns: bool: True send email from organization's email address else False. """ return self.send_from_org_email_id def set_file_name(self, file_name): """Set file name that is attached with email. Args: file_name(str): Name of the file that is attached with mail. """ self.file_name = file_name def get_file_name(self): """Get file name that is attached with email. Returns: str: Name of the file that is attached. """ return self.file_name def set_contact_id(self, contact_id): """Set contact id. Args: contact_id(str): Contact id. """ self.contact_id = contact_id def get_contact_id(self): """Get contact id. Returns: str: Contact id. """ return self.contact_id def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_gateways_configured(self, gateways_configured): """Set gateways configured. Args: gateways_configured(str): Gateways configured. """ self.gateways_configured = gateways_configured def get_gateways_configure(self): """Get gateways configured. Returns: str: Gateways configured. """ return self.gateways_configured def set_attachment_name(self, attachment_name): """Set attachment name. Args: attachment_name(str): Attachment name. """ self.attachment_name = attachment_name def get_attachment_name(self): """Get attachment name. Returns: str: Attachment name. """ return self.attachment_name def set_to_contacts(self, to_contacts): """Set the details for the contacts for which mail has to be sent. Args: to_contacts(instance): To_contacts object. """ self.to_contacts.append(to_contacts) def get_to_contacts(self): """Get the details of the contacts for which mail has to be sent. Returns: list: List of to_contacts object. """ return self.to_contacts def set_from_emails(self, from_emails): """Set from email details. Args: from_emails(instance): From emails object. """ self.from_emails.append(from_emails) def get_from_emails(self): """Get from email details. Returns: list: lList of from_emails object. """ return self.from_emails def set_error_list(self, error_list): """Set error list. Args: error_list(list): List of errors. """ self.error_list.extend(error_list) def get_error_list(self): """Get error list. Returns: list: List of errors. """ return self.error_list def set_email_templates(self, email_template): """Set email templates. Args: email_template(instance): Email templates object. """ self.email_templates.append(email_template) def get_email_templates(self): """Get email templates. Returns: list: List of email templates object. """ return self.email_templates def set_deprecated_placeholders_used(self, deprecated_placeholders_used): """Set deprecated placeholders used. Args: set_deprecated_placeholders_used(list): List of deprecated placeholders. """ self.deprecated_placeholders_used.extend(deprecated_placeholders_used) def get_deprecated_placeholders_used(self): """Get deprecated placeholders used. Returns: list: List of deprecated placeholders. """ return self.deprecated_placeholders_used def set_gateways_associated(self, gateways_associated): """Set whether gateways are associated or not. Args: gateways_associated(bool): True if gateways are associated else False. """ self.set_gateways_associated = gateways_associated def get_gateways_associated(self): """Get whether gateways are associated or not. Returns: bool: True if gateways are associated else False. """ return self.gateways_associated def set_attach_pdf(self, attach_pdf): """Set whether pdf is attached or not. Args: attach_pdf(bool): True if pdf is attached else False. """ self.attach_pdf = attach_pdf def get_attach_pdf(self): """Get whether pdf is attached or not. Returns: bool: True if pdf is attached else False. """ return self.attach_pdf def set_file_name_without_extension(self, file_name_without_extension): """Set file name without extension. Args: file_name_without_extension(str): File name without extension. """ self.file_name_without_extension = file_name_without_extension def get_file_name_without_extension(self): """Get filename without extension. Returns: str: File name without extension. """ return self.file_name_without_extension def to_json(self): """This method is used to convert email object to Json object. Returns: dict: Dictionary containing json object for email object. """ email = {} email['subject'] = self.subject email['body'] = self.body email['to_mail_ids'] = self.to_mail_ids if not self.cc_mail_ids: email['cc_mail_ids'] = self.cc_mail_ids if self.send_from_org_email_id: email['send_from_org_email_id'] = self.sed_from_org_email_id return email
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Email.py
Email.py
class Tax: """This class is used to create an object for tax.""" def __init__(self): """Initialize parameters for tax.""" self.tax_name = '' self.tax_amount = 0.0 self.tax_id = '' self.tax_percentage = 0.0 self.tax_type = '' self.tax_specification = '' def set_tax_id(self, tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str: Tax id. """ return self.tax_id def set_tax_percentage(self, tax_percentage): """Set tax percentage. Args: tax_percentage(float): Tax percentage. """ self.tax_percentage = tax_percentage def get_tax_percentage(self): """Get tax percentage. Args: float: Tax percentage. """ return self.tax_percentage 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 set_tax_name(self, tax_name): """Set tax name. Args: tax_name(str): Tax name. """ self.tax_name = tax_name def get_tax_name(self): """Get tax name. Returns: str: Tax name. """ return self.tax_name def set_tax_amount(self, tax_amount): """Set tax amount. Args: tax_amount(float): Tax amount. """ self.tax_amount = tax_amount def get_tax_amount(self): """Get tax amount. Returns: float: Tax amount. """ return self.tax_amount def set_tax_specification(self, tax_specification): """Set tax Specification. Args: tax_specification(str): Tax Specification. """ self.tax_specification = tax_specification def get_tax_specification(self): """Get tax Specification. Returns: str: Tax Specification. """ return self.tax_specification def to_json(self): """This method is used to convert tax object to json format. Returns: dict: Dictionary containing json object for tax. """ data = {} if self.tax_name != '': data['tax_name'] = self.tax_name if self.tax_percentage > 0: data['tax_percentage'] = self.tax_percentage if self.tax_type != '': data['tax_type'] = self.tax_type return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Tax.py
Tax.py
class TimeEntry: """This class is used to create object for Time Entry.""" def __init__(self): """Initialize parameters for Time entry object.""" self.time_entry_id = '' self.project_id = '' self.project_name = '' self.task_id = '' self.task_name = '' self.user_id = '' self.user_name = '' self.is_current_user = None self.log_date = '' self.begin_time = '' self.end_time = '' self.log_time = '' self.billed_status = '' self.notes = '' self.time_started_at = '' self.timer_duration_in_minutes = 0 self.created_time = '' self.customer_id = '' self.customer_name = '' self.start_timer = None def set_start_timer(self, start_timer): """Set start timer. Args: start_timer(bool): Start timer. """ self.start_timer = start_timer def get_start_timer(self): """Get start timer. Returns: bool: Start timer. """ return self.start_timer def set_time_entry_id(self, time_entry_id): """Set time entry id. Args: time_entry_id(str): Time entry id. """ self.time_entry_id = time_entry_id def get_time_entry_id(self): """Get time entry id. Returns: str: Time entry id. """ return self.time_entry_id def set_project_id(self, project_id): """Set project id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id def set_project_name(self, project_name): """Set project name. Args: project_name(str):Project name. """ self.project_name = project_name def get_project_name(self): """Get project name. Returns: str: Project name. """ return self.project_name def set_task_id(self, task_id): """Set task id. Args: task_id(str): Task id. """ self.task_id = task_id def get_task_id(self): """Get task id. Returns: str: Task id. """ return self.task_id def set_task_name(self, task_name): """Set task name. Args: task_name(str): Task name. """ self.task_name = task_name def get_task_name(self): """Get task name. Returns: str: Task name. """ return self.task_name def set_user_id(self, user_id): """Set user id. Args: user_id(str): User id. """ self.user_id = user_id def get_user_id(self): """Get user id. Returns: str: User id. """ return self.user_id def set_user_name(self, user_name): """Set user name. Args: user_name(str): User name. """ self.user_name = user_name def get_user_name(self): """Get user name. Returns: str: User name. """ return self.user_name def set_is_current_user(self, is_current_user): """Set whether it is current user or not. Args: is_current_user(bool): True if it is a current user else false. """ self.is_current_user = is_current_user def get_is_current_user(self): """Get whether it is current user or not. Returns: bool: True if it is current user else False. """ return self.is_current_user def set_log_date(self, log_date): """Set log date. Args: log_date(str): Log date. """ self.log_date = log_date def get_log_date(self): """Get log date. Returns: str: Log date. """ return self.log_date def set_begin_time(self, begin_time): """Set begin time. Args: begin_time(str): Begin time. """ self.begin_time = begin_time def get_begin_time(self): """Get begin time. Returns: str: Begin time. """ return self.begin_time def set_end_time(self, end_time): """Set end time. Args: end_time(str): End time. """ self.end_time = end_time def get_end_time(self): """Get end time. Returns: str: End time """ return self.end_time def set_log_time(self, log_time): """Set log time. Args: log_time(str): Log time. """ self.log_time = log_time def get_log_time(self): """Get log time. Returns: str: Log time. """ return self.log_time def set_billed_status(self, billed_status): """Set billed status. Args: billed_status(str): Billed status. """ self.billed_status = billed_status def get_billed_status(self): """Get billed status. Returns: str: Billed status. """ return self.billed_status def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_timer_started_at(self, timer_started_at): """Set timer started at. Args: timer_started_at(str): Timer started at. """ self.timer_started_at = timer_started_at def get_timer_started_at(self): """Get timer started at. Returns: str: Timer started at. """ return self.timer_started_at def set_timer_duration_in_minutes(self, timer_duration_in_minutes): """Set timer duration in minutes. Args: timer_duration_in_minutes(int): Timer duration in minutes. """ self.timer_duration_in_minutes = timer_duration_in_minutes def get_timer_duration_in_minutes(self): """Get timer duration in minutes. Returns: str: Timer duration in minutes. """ return self.timer_duration_in_minutes def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def to_json(self): """This method is used to convert time entry object to json format. Returns: dict: Dictionary containing json object for time entry. """ data = {} if self.project_id != '': data['project_id'] = self.project_id if self.task_id != '': data['task_id'] = self.task_id if self.user_id != '': data['user_id'] = self.user_id if self.log_date != '': data['log_date'] = self.log_date if self.begin_time != '': data['begin_time'] = self.begin_time if self.end_time != '': data['end_time'] = self.end_time if self.log_time != '': data['log_time'] = self.log_time if self.notes != '': data['notes'] = self.notes if self.start_timer != '': data['start_timer'] = self.start_timer return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/TimeEntry.py
TimeEntry.py
from books.model.Address import Address 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
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Organization.py
Organization.py
class EmailHistory: """This class is used to create an object for Email history.""" def __init__(self): """Initialize the parameters for Email hstory object.""" self.mailhistory_id = '' self.from_mail_id = '' self.to_mail_ids = '' self.subject = '' self.date = '' self.type = 0 def set_mailhistory_id(self, mailhistory_id): """Set mail history id. Args: mailhistory_id(str): Mail history id. """ self.mailhistory_id = mailhistory_id def get_mailhistory_id(self): """Get mail history id. Returns: str: Mail history id. """ return self.mailhistory_id def set_from(self, from_mail_id): """Set from mail id. Args: from_mail_id(str): From mail id. """ self.from_mail_id = from_mail_id def get_from(self): """Get from mail id. Returns: str: From mail id. """ return self.from_mail_id def set_to_mail_ids(self, to_mail_ids): """Set to mail id. Args: to_mail_ids(str): To mail ids. """ self.to_mail_ids = to_mail_ids def get_to_mail_ids(self): """Get to mail ids. Returns: str: To mail ids. """ return self.to_mail_ids def set_subject(self, subject): """Set subject. Args: subjecct(str): Subject. """ self.subject = subject def get_subject(self): """Get subject. Returns: str: Subject. """ return self.subject def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_type(self, email_type): """Set type. Args: type(int): Type. """ self.type = email_type def get_type(self): """Get type. Returns: int: Type. """ return self.type
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/EmailHistory.py
EmailHistory.py
class CustomField: """This class is used to create custom field.""" def __init__(self): """Initialize the parameters for custom field object""" self.index = 0 self.show_on_pdf = None self.value = '' self.label = '' def set_index(self, index): """Set index for custom field. Args: index(int): Index for custom field. """ self.index = index def get_index(self): """Get index for custom field. Returns: int: Index for custom field. """ return self.index def set_show_on_pdf(self, show_on_pdf): """Set whether to show as pdf or not. Args: show_on_pdf(bool): True to show as pdf else False. """ self.show_on_pdf = show_on_pdf def get_show_on_pdf(self): """Get whether to show as pdf or not. Returns: bool: True to show as pdf else False. """ return self.show_on_pdf def set_value(self, value): """Set value for custom field. Args: value(str): Value for custom field. """ self.value = value def get_value(self): """Get value of custom field. Returns: str: Value for custom field. """ return self.value def set_label(self, label): """Set label for custom field. Args: label(str): Label for custom field. """ self.label = label def get_label(self): """Get label of custom field. Returns: str: Label of custom field. """ return self.label def set_invoice(self, invoice): """Set invoice. Args: invoice(instance): Invoice custom field. """ self.invoice.append(invoice) def get_invoice(self): """Get invoice. Returns: list of instance: List of Invoice custom field. """ return self.invoice def set_contact(self, contact): """Set cocntact. Args: contact(instance): Contact custom field. """ self.contact.append(contact) def get_contact(self): """Get contact. Returns: list of instance: List of Contact custom field. """ return self.custom_field def set_estimate(self, estimate): """Set estimate. Args: estimate(instance): Estimate custom field. """ self.estimate.append(estimate) def get_estimate(self): """Get estimate. Returns: list of instance: List of estimate custom field. """ return self.estimate def to_json(self): """This method is used to convert custom field object to json object. Returns: dict: Dictionary containing json object for custom field. """ data = {} #if self.index != None: #data['index'] = self.index if self.value != '': data['value'] = self.value data['api_name'] = self.label return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/CustomField.py
CustomField.py
class Expense(): """This class is used to create objecct for expenses.""" def __init__(self): """Initialize parameters for Expenses object.""" self.account_id = '' self.paid_through_account_id = '' self.date = '' self.amount = 0.0 self.tax_id = '' self.is_inclusive_tax = None self.is_billable = None self.customer_id = '' self.vendor_id = '' self.currency_id = '' self.exchange_rate = 0.0 self.project_id = '' self.expense_id = '' self.expense_item_id = '' self.account_name = '' self.paid_through_account_name = '' self.vendor_name = '' self.tax_name = '' self.tax_percentage = 0.0 self.currency_code = '' self.tax_amount = 0.0 self.sub_total = 0.0 self.total = 0.0 self.bcy_total = 0.0 self.reference_number = '' self.description = '' self.customer_name = '' self.expense_receipt_name = '' self.created_time = '' self.last_modified_time = '' self.status = '' self.invoice_id = '' self.invoice_number = '' self.project_name = '' self.recurring_expense_id = '' self.product_type = '' self.hsn_or_sac = 0 self.gst_no = '' self.gst_treatment = '' self.destination_of_supply = '' def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_paid_through_account_id(self, paid_through_account_id): """Set paid through account id. Args: paid_through_account_id(str): Paid through account id. """ self.paid_through_account_id = paid_through_account_id def get_paid_through_account_id(self): """Get paid through account id. Returns: str: Paid through account id. """ return self.paid_through_account_id def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount def set_tax_id(self, tax_id): """Set tax id. Args: tax_id(str): Tax id. """ self.tax_id = tax_id def get_tax_id(self): """Get tax id. Returns: str: Tax id. """ return self.tax_id def set_is_inclusive_tax(self, is_inclusive_tax): """Set whether tax is inclusive. Args: is_inclusive_tax(bool): True if tax is inclusive else False. """ self.is_inclusive_tax = is_inclusive_tax def get_is_inclusive_tax(self): """Get whether tax is inclusive. Returns: bool: True if tax is inclusive else False. """ return self.is_inclusive_tax def set_is_billable(self, is_billable): """Set whether expenses are billable. Args: is_billable(bool): True if billable else False. """ self.is_billable = is_billable def get_is_billable(self): """Get whether expenses are billable. Returns: bool: True if billable else False. """ return self.is_billable def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_vendor_id(self, vendor_id): """Set vendor id. Args: vendor_id(str): Vendor id. """ self.vendor_id = vendor_id def get_vendor_id(self): """Get vendor id. Returns: str: Vendor id. """ return self.vendor_id 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 idd. Returns: str: Currency id. """ return self.currency_id def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchangge rate. """ return self.exchange_rate def set_project_id(self, project_id): """Set project id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id def set_expense_id(self, expense_id): """Set expense id. Args: expense_id(str): Expense id. """ self.expense_id = expense_id def get_expense_id(self): """Get expense id. Returns: str: Expense id. """ return self.expense_id def set_expense_item_id(self, expense_item_id): """Set expense item id. Args: expense_item_id(str): Expense item id. """ self.expense_item_id = expense_item_id def get_expense_item_id(self): """Get expense item id. Returns: str: Expense item id. """ return self.expense_item_id def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_paid_through_account_name(self, paid_through_account_name): """Set paid through account name. Args: paid_through_account_name(str): Paid through account name. """ self.paid_through_account_name = paid_through_account_name def get_paid_through_account_name(self): """Get paid through account name. Returns: str: Paid through account name. """ return self.paidf_through_account_name def set_vendor_name(self, vendor_name): """Set vendor name. Args: vendor_name(str): Vendor name. """ self.vendor_name = vendor_name def get_vendor_name(self): """Get vendor name. Returns: str: Vendor name. """ return self.vendor_name def set_tax_name(self, tax_name): """Set tax name. Args: tax_name(str): Tax name. """ self.tax_name = tax_name def get_tax_name(self): """Get tax name. Returns: str: Tax name. """ return self.tax_name def set_tax_percentage(self, tax_percentage): """Set tax percentage. Args: tax_percentage(float): Tax percentage. """ self.tax_percentage = tax_percentage def get_tax_percentage(self): """Get tax percentage. Returns: float: Tax percentage. """ return self.tax_percentage 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_tax_amount(self, tax_amount): """Set tax amount. Args: tax_amount(float): Tax amount. """ self.tax_amount = tax_amount def get_tax_amount(self): """Get tax amount. Returns: float: Tax amount. """ return self.tax_amount def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_bcy_total(self, bcy_total): """Set bcy total. Args: bcy_total(float): Bcy total. """ self.bcy_total = bcy_total def get_bcy_total(self): """Get bcy total. Returns: float: Bcy total. """ return self.bcy_total def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference_number. Returns: str: Reference number. """ return self.reference_number def set_description(self, description): """Set description. Args: description(str): Description """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_expense_receipt_name(self, expense_receipt_name): """Set expense receipt name. Args: expense_receipt_name(str): Expense receipt name. """ self.expense_receipt_name = expense_receipt_name def get_expense_receipt_name(self): """Get expense receipt name. Returns: str: Expense receipt name. """ return self.expense_receipt_name def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return status def set_invoice_id(self, invoice_id): """Set invoice id. Args: invoice_id(str): Invoice id. """ self.invoice_id = invoice_id def get_invoice_id(self): """Get invoice id. Returns: str: Invoice id. """ def set_invoice_number(self, invoice_number): """Set invoice number. Args: invoice_number(str): Invoice number. """ self.invoice_number = invoice_number def get_invoice_number(self): """Get invoice number. Returns: str: Invoice number. """ return self.invoice_number def set_project_name(self, project_name): """Set project name. Args: project_name(str): Project name. """ self.project_name = project_name def get_project_name(self): """Get project name. Returns: str: Project name. """ return self.project_name def set_recurring_expense_id(self, recurring_expense_id): """Set recurring expense id. Args: recurring_expense_id(str): Recurring expense id. """ self.recurring_expense_id = recurring_expense_id def get_recurring_expense_id(self): """Get recurring expense id. Returns: str: Recurring expense id. """ return self.recurring_expense_id def to_json(self): """This method is used to convert expense object to json object. Returns: dict: Dictionary containing json object for expenses. """ data = {} if self.account_id != '': data['account_id'] = self.account_id if self.paid_through_account_id != '': data['paid_through_account_id'] = self.paid_through_account_id if self.date != '': data['date'] = self.date if self.amount > 0: data['amount'] = self.amount if self.tax_id != '': data['tax_id'] = self.tax_id if self.is_inclusive_tax is not None: data['is_inclusive_tax'] = self.is_inclusive_tax if self.reference_number != '': data['reference_number'] = self.reference_number if self.description != '': data['description'] = self.description if self.is_billable is not None: data['is_billable'] = self.is_billable if self.customer_id != '': data['customer_id'] = self.customer_id if self.vendor_id != '': data['vendor_id'] = self.vendor_id if self.currency_id != '': data['currency_id'] = self.currency_id if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.recurring_expense_id != '': data['recurring_expense_id'] = self.recurring_expense_id if self.project_id != '': data['project_id'] = self.project_id if self.product_type != '': data['product_type'] = self.product_type if self.hsn_or_sac != '': data['hsn_or_sac'] = self.hsn_or_sac if self.gst_no != '': data['gst_no'] = self.gst_no if self.gst_treatment != '': data['gst_treatment'] = self.gst_treatment if self.destination_of_supply != '': data['destination_of_supply'] = self.destination_of_supply return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Expense.py
Expense.py
class Invoice: """This class is used to create object for invoice.""" def __init__(self): """Initialize parameters for Invoice object.""" self.invoice_id = '' self.invoice_number = '' self.date = '' self.status = '' self.payment_terms = 0 self.payment_terms_label = '' self.due_date = '' self.payment_expected_date = '' self.last_payment_date = '' self.reference_number = '' self.customer_id = '' self.customer_name = '' self.contact_persons = [] self.currency_id = '' self.currency_code = '' self.exchange_rate = 0.00 self.discount = '' self.is_discount_before_tax = None self.discount_type = '' self.recurring_invoice_id = '' self.line_items = [] self.shipping_charge = 0.00 self.adjustment = 0.0 self.adjustment_description = '' self.sub_total = 0.0 self.tax_total = 0.0 self.total = 0.0 self.taxes = [] self.payment_reminder_enabled = None self.payment_made = 0.0 self.credits_applied = 0.0 self.tax_amount_withheld = 0.0 self.balance = 0.0 self.write_off_amount = 0.0 self.allow_partial_payments = None self.price_precision = 2 self.payment_options = { 'payment_gateways': [] } self.is_emailed = False self.reminders_sent = 0 self.last_reminder_sent_date = '' self.billing_address = '' self.shipping_address = '' self.notes = '' self.terms = '' self.custom_fields = [] self.template_id = '' self.template_name = '' self.created_time = '' self.last_modified_time = '' self.attachment_name = '' self.can_send_in_mail = None self.salesperson_id = '' self.salesperson_name = '' self.invoice_url = '' self.invoice_payment_id = '' self.due_days = '' self.custom_body = '' self.custom_subject = '' self.invoiced_estimate_id = '' self.amount_applied = '' self.name = '' self.value = '' self.gst_no = '' self.reason = '' 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_invoice_id(self, invoice_id): """Set invoice id. Args: invoice_id(str): Invoice id. """ self.invoice_id = invoice_id def get_invoice_id(self): """Get invoice id. Returns: str: Invoice id. """ return self.invoice_id def set_invoice_number(self, invoice_number): """Set invoice number. Args: invoice_numeber(str): Invoice number. """ self.invoice_number = invoice_number def get_invoice_number(self): """Get invoice number. Returns: str: Invoice number. """ return self.invoice_number def set_date(self, date): """Set date at which the invoice is created. Args: date(str): Date at which invoice is created. """ self.date = date def get_date(self): """Get date at which invoice is created. Returns: str: Date at which invoice is created. """ return self.date def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_payment_terms(self, payment_terms): """Set payment terms in days.Invoice due date will be calculated based on this. Args: payment_terms(int): Payment terms in days.Eg 15, 30, 60. """ self.payment_terms = payment_terms def get_payment_terms(self): """Get payment terms. Returns: int: Payment terms in days. """ return self.payment_terms def set_payment_terms_label(self, payment_terms_label): """Set Payments terms label. Args: payment_terms_label(str): Payment terms label. Default value for 15 days is "Net 15". """ self.payment_terms_label = payment_terms_label def get_payment_terms_label(self): """Get payment terms label. Returns: str: PAyment terms label. """ return self.payment_terms_label def set_due_date(self, due_date): """Set due date for invoice. Args: due_date(str): Due date for invoice. Format is yyyy-mm-dd. """ self.due_date = due_date def get_due_date(self): """Get due date of invoice. Returns: str: Due date dor invoice. """ return self.due_date def set_payment_expected_date(self, payment_expected_date): """Set payment expected date. Args: payment_expected_date(str): Payment expected date. """ self.payment_expected_date = payment_expected_date def get_payment_expected_date(self): """Get payment expected date. Returns: str: Payment expected date. """ return self.payment_expected_date def set_last_payment_date(self, last_payment_date): """Set last payment date. Args: last_payment_date(str): last_payment_date """ self.last_payment_date = last_payment_date def get_last_payment_date(self): """Get last payment date. Returns: str: last payment date. """ return self.last_payment_date def set_reference_number(self, reference_number): """Set reference number for the customer payment. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number for the customer payment. Returns: str: Reference number. """ return self.reference_number def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_contact_persons(self, contact_person): """Set the list of ID of contact persons for which thank you mail has to be sent. Args: contact_peson(list): Id of contact persons for which thank you mail has to be sent. """ self.contact_persons.extend(contact_person) def get_contact_persons(self): """Get the Id of contact persons for which thank you mail has to be sent. Returns: list: List of ID of contact persons. """ return self.contact_persons 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_exchange_rate(self, exchange_rate): """Set exchange rate for the currency. Args: exchange_rate(int): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate of the currency. Returns: int: Exchange rate. """ return self.exchange_rate def set_discount(self, discount): """Set discount applied to the invoice. Args: discount(str): Discount. It can be either in % or in amount. """ self.discount = discount def get_discount(self): """Get discount applied to the invoice. Returns: str: Discount. """ return self.discount def set_is_discount_before_tax(self, is_discount_before_tax): """Set whether to discount before tax or after tax. Args: is_discount_before_tax(bool): True to discount before tax else False to discount after tax. """ self.is_discount_before_tax = is_discount_before_tax def get_is_discount_before_tax(self): """Get whether to discount before tax or after tax. Returns: bool: True to discount before tax else False to discount after tax. """ return self.is_discount_before_tax def set_discount_type(self, discount_type): """Set how the discount should be specified. Args: discount_type: Discount type. Allowed values are entity_level or item_level """ self.discount_type = discount_type def get_discount_type(self): """Get discount type. Returns: str: Discount type. """ return self.discount_type def set_recurring_invoice_id(self, recurring_invoice_id): """Set id of the recurring invoice from which the invoice is created. Args: recurring_invoice_id(str): Recurring invoice id. """ self.recurring_invoice_id = recurring_invoice_id def get_recurring_invoice_id(self): """Get id of the recurring invoice from which the invoice is created. Returns: str: Recurring invoice id. """ return self.recurring_invoice_id def set_line_items(self, line_item): """Set line items for an invoice. Args: instance: Line item object. """ self.line_items.append(line_item) def get_line_items(self): """Get line items of an invoice. Returns: list: List of line items object """ return self.line_items def set_shipping_charge(self, shipping_charge): """Set shipping charge for the invoice. Args: shipping_charge(float): Shipping charge. """ self.shipping_charge = shipping_charge def get_shipping_charge(self): """Get shipping charge for the invoice. Returns: float: Shipping charge. """ return self.shipping_charge def set_adjustment(self, adjustment): """Set adjustments made to the invoice. Args: adjustment(float): Adjustments made. """ self.adjustment = adjustment def get_adjustment(self): """Get adjustments made to the invoice. Returns: float: Adjustments made. """ return self.adjustment def set_adjustment_description(self, adjustment_description): """Set to customize adjustment description. Args: adjustment_description(str): Adjustment description. """ self.adjustment_description = adjustment_description def get_adjustment_description(self): """Get adjustment description. Returns: str: Adjustment description. """ return self.adjustment_description def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_tax_total(self, tax_total): """Set tax total. Args: tax_total(float): Tax total. """ self.tax_total = tax_total def get_tax_total(self): """Get tax total. Returns: float: Tax total. """ return self.tax_total def set_total(self, total): """Set total. Args: total(float): Total amount. """ self.total = total def get_total(self): """Get total. Returns: float: Total amount. """ return self.total def set_taxes(self, tax): """Set taxes. Args: tax(instance): Tax. """ self.taxes.append(tax) def get_taxes(self): """Get taxes. Returns: list: List of tax objects. """ return self.taxes def set_payment_reminder_enabled(self, payment_reminder_enabled): """Set whether to enable payment reminder or not. Args: payment_reminder_enabled(bool): True to enable payment reminder else False. """ self.payment_reminder_enabled = payment_reminder_enabled def get_payment_reminder_enabled(self): """Get whether payment reminder is enabled or not. Returns: bool: True if payment reminder is enabled else False. """ return self.payment_reminder_enabled def set_payment_made(self, payment_made): """Set payment made. Args: payment_made(float): Payments made. """ self.payment_made = payment_made def get_payment_made(self): """Get payments made. Returns: float: Payments made. """ return self.payment_made def set_credits_applied(self, credits_applied): """Set credits applied. Args: credits_applied(float): Credits applied. """ self.credits_applied = credits_applied def get_credits_applied(self): """Get credits applied. Returns: float: Credits applied. """ return self.credits_applied def set_tax_amount_withheld(self, tax_amount_withheld): """Set tax amount withheld. Args: tax_amount_withheld(float): Tax amount withheld. """ self.tax_amount_withheld = tax_amount_withheld def get_tax_amount_withheld(self): """Get tax amount withheld. Returns: float: Tax amount withheld. """ return self.tax_amount_withheld def set_balance(self, balance): """Set balance. Args: balance(float): Balance. """ self.balance = balance def get_balance(self): """Get balance. Returns: float: Balance. """ return self.balance def set_write_off_amount(self, write_off_amount): """Set write off amount. Args: write_off_amount(float): Write off amount. """ self.write_off_amount = write_off_amount def get_write_off_amount(self): """Get write off amount. Returns: float: Write off amount. """ return self.write_off_amount def set_allow_partial_payments(self, allow_partial_payments): """Set whether to allow partial payments or not. Args: allow_partial_payments(bool): True to allow partial payments else False. """ self.allow_partial_payments = allow_partial_payments def get_allow_partial_payments(self): """Get whether to allow partial payments. Returns: bool: True if partial payments are allowed else False. """ return self.allow_partial_payments def set_price_precision(self, price_precision): """Set price precision. Args: price_precision(int): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: int: Price precision. """ return self.price_precision def set_payment_options(self, payment_gateways): """Set payment options. Args: payment_gateways(instance): Online payment gateways through which payment can be made. """ self.payment_options['payment_gateways'].append(payment_gateways) def get_payment_options(self): """Get payment options. Returns: dict: Payment options for the invoice. """ return self.payment_options def set_is_emailed(self, is_emailed): """Set whether to email or not. Args: is_emailed(bool): True to email else False. """ self.is_emailed = is_emailed def get_is_emailed(self): """Get whether to email. Returns: bool: True to email else False. """ return self.is_emailed def set_reminders_sent(self, reminders_sent): """Set reminders sent. Args: reminders_sent(int): Reminders sent. """ self.reminders_sent = reminders_sent def get_reminders_sent(self): """Get reminders sent. Returns: int: Reminders sent. """ return self.reminders_sent def set_last_reminder_sent_date(self, last_reminder_sent_date): """Set last reminder sent date. Args: last_reminder_sent_date(str): Last reminder sent date """ self.last_reminder_sent_date = last_reminder_sent_date def get_last_reminder_sent_date(self): """Get last reminder sent date. Returns: str: Last reminder sent date. """ return self.last_reminder_sent_date def set_billing_address(self, billing_address): """Set billing address. Args: billing_address(instance): Billing address object. """ self.billing_address = billing_address def get_billing_address(self): """Get billing address. Returns: instance: Billing address object. """ return self.billing_address def set_shipping_address(self, shipping_address): """Set shipping address. Args: shipping_address(instance): Shipping address object. """ self.shipping_address = shipping_address def get_shipping_address(self): """Get shipping address. Returns: instance: Shipping address object. """ return self.shipping_address def set_notes(self, notes): """Set notes. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms def set_custom_fields(self, custom_field): """Set custom fields. Args: custom_field(instance): custom field object. """ self.custom_fields.append(custom_field) def get_custom_fields(self): """Get custom field. Returns: instance: custom field object. """ return self.custom_fields def set_template_id(self, template_id): """Set template id. Args: template_id(str): Template id. """ self.template_id = template_id def get_template_id(self): """Get template id. Returns: str: Template id. """ return self.template_id def set_template_name(self, template_name): """Set template name. Args: template_name(str): Template name. """ self.template_name = template_name def get_template_name(self): """Get template name. Returns: str: Template name. """ return self.template_name def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: Last modified time. """ return self.last_modified_time def set_attachment_name(self, attachment_name): """Set attachment name. Args: attachment_name(str): Attachment name. """ self.attachment_name = attachment_name def get_attachment_name(self): """Get attachment name. Returns: str: Attachment name. """ return self.attachment_name def set_can_send_in_mail(self, can_send_in_mail): """Set whether the invoice can be sent in mail or not. Args: can_send_in_mail(bool): True if it can be sent in mail else False. """ self.can_send_in_mail = can_send_in_mail def get_can_send_in_mail(self): """Get whether the invoice can be sent in mail or not. Returns: bool: True if it can be sent in mail else False. """ return self.can_send_in_mail def set_salesperson_id(self, salesperson_id): """Set salesperson id. Args: salesperson_id(str): Salesperson id. """ self.salesperson_id = salesperson_id def get_salesperson_id(self): """Get salesperson id. Returns: str: Salesperson id. """ return self.salesperson_id def set_salesperson_name(self, salesperson_name): """Set salesperson name. Args: salesperson_name(str): Salesperson name. """ self.salesperson_name = salesperson_name def get_salesperson_name(self): """Get salesperson name. Returns: str: Salesperson name. """ return self.salesperson_name def set_invoice_url(self, invoice_url): """Set invoice url. Args: invoice_url(str): Invoice url. """ self.invoice_url = invoice_url def get_invoice_url(self): """Get invoice url. Returns: str: Invoice url. """ return self.invoice_url def set_due_days(self, due_days): """Set due days. Args: due_days(str): Due days. """ self.due_days = due_days def get_due_days(self): """Get due days. Returns: str: Due days. """ return self.due_days def set_custom_body(self, custom_body): """Set custom body. Args: custom_body(str): Custom body. """ self.custom_body = custom_body def get_custom_body(self): """Get custom body. Returns: str: Custom body. """ return self.custom_body def set_custom_subject(self, custom_subject): """Set custom subject. Args: custom_subject(str): Custom subject. """ self.custom_subjecct = custom_subject def get_custom_subject(self): """Get custom subject. Returns: str: Custom subject. """ return self.custom_subject def set_invoiced_estimate_id(self, invoiced_estimate_id): """Set invoiced estimate id. Args: invoiced_estimate_id(str): Invoiced estimate id. """ self.invoiced_estimate_id = invoiced_estimate_id def get_invoiced_estimate_id(self): """Get invoiced estimate id. Returns: str: Invoiced estimate id. """ return self.invoiced_estimate_id def set_amount_applied(self, amount_applied): """Set amount applied. Args: amount_applied(str): Amount applied. """ self.amount_applied = amount_applied def get_amount_applied(self): """Get amount applied. Returns: str: Amount applied. """ return self.amount_applied def set_invoice_payment_id(self, invoice_payment_id): """Set invoice payment id. Args: invoice_payment_id(str): Invoice payment id. """ self.invoice_payment_id = invoice_payment_id def get_invoice_payment_id(self): """Get invoice payment id. Returns: str: Invoice payment id. """ return self.invoice_payment_id def to_json(self): """This method is used to convert invoice object to json object. Returns: dict: Dictionary containing json object for invoices. """ data = {} if self.customer_id != '': data['customer_id'] = self.customer_id if self.contact_persons: data['contact_persons'] = self.contact_persons if self.reference_number != '': data['reference_number'] = self.reference_number if self.template_id != '': data['template_id'] = self.template_id if self.date != '': data['date'] = self.date if self.payment_terms > 0: data['payment_terms'] = self.payment_terms if self.payment_terms_label != '': data['payment_terms_label'] = self.payment_terms_label if self.due_date != '': data['due_date'] = self.due_date if self.discount != '': data['discount'] = self.discount if self.is_discount_before_tax is not None: data['is_discount_before_tax'] = self.is_discount_before_tax if self.discount_type != '': data['discount_type'] = self.discount_type if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.recurring_invoice_id != '': data['recurring_invoice_id'] = self.recurring_invoice_id if self.invoiced_estimate_id != '': data['invoiced_estimate_id'] = self.invoiced_estimate_id if self.salesperson_name != '': data['salesperson_name'] = self.salesperson_name if self.custom_fields: data['custom_fields'] = self.custom_fields if self.line_items: data['line_items'] = [] for value in self.line_items: line_item = value.to_json() data['line_items'].append(line_item) if self.payment_options['payment_gateways']: data['payment_options'] = {'payment_gateways':[]} for value in self.payment_options['payment_gateways']: payment_gateway = value.to_json() data['payment_options']['payment_gateways'].append(payment_gateway) if self.allow_partial_payments != None: data['allow_partial_payments'] = self.allow_partial_payments if self.custom_body != '': data['custom_body'] = self.custom_body if self.custom_subject != '': data['custom_subject'] = self.custom_subject if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms if self.shipping_charge > 0: data['shipping_charge'] = self.shipping_charge if self.adjustment > 0: data['adjustment'] = self.adjustment if self.adjustment_description != '': data['adjustment_description'] = self.adjustment_description if self.invoice_number != '': data['invoice_number'] = self.invoice_number if self.reason != '': data['reason'] = self.reason if self.invoice_id != '': data['invoice_id'] = self.invoice_id if self.amount_applied != '': data['amount_applied'] = self.amount_applied if self.total != '': data['total'] = self.total return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Invoice.py
Invoice.py
from books.model.Address import Address class Estimate: """This class is used to create object for estimates.""" 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 = '' def set_estimate_id(self, estimate_id): """Set estimate id. Args: estimate_id(str): Estimate id. """ self.estimate_id = estimate_id def get_estimate_id(self): """Get estimate id. Returns: str: Estimate id. """ return self.estimate_id def set_estimate_number(self, estimate_number): """Set estimate number. Args: estimate_number(str): Estimate number. """ self.estimate_number = estimate_number def get_estimate_number(self): """Get estimate number. Returns: str: Estimate number. """ return self.estimate_number def set_date(self, date): """Set the date for estimate. Args: date(str): Date for estimate. """ self.date = date def get_date(self): """Get the date of estimate. Returns: str: Date of estimate. """ return self.date def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_contact_persons(self, contact_person): """Set contact person. Args: contact_person(list of instance): List of contact person object. """ self.contact_persons.extend(contact_person) def get_contact_persons(self): """Get contact person. Returns: list: List of contact person object. """ return self.contact_persons 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_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_expiry_date(self, expiry_date): """Set expiry date. Args: expiry_date(str): Expiry date. """ self.expiry_date = expiry_date def get_expiry_date(self): """Get expiry date. Returns: str: Expiry date. """ return self.expiry_date def set_discount(self, discount): """Set discount. Args: discount(float): Discount. """ self.discount = discount def get_discount(self): """Get discount. Returns: str: Discount. """ return self.discount def set_is_discount_before_tax(self, is_discount_before_tax): """Set whether to discount before tax or not. Args: is_discount_before_tax(bool): True to discount before tax. """ self.is_discount_before_tax = is_discount_before_tax def get_is_discount_before_tax(self): """Get whether to discount before tax or not. Returns: bool: True to discount before tax. """ return self.is_discount_before_tax def set_discount_type(self, discount_type): """Set type of discount. Args: discount_type(str): Discount type. """ self.discount_type = discount_type def get_discount_type(self): """Get type of discount. Returns: str: Discount type. """ return self.discount_type def set_line_items(self, items): """Set line items. Args: items(instance): Line items object. """ self.line_items.append(items) def get_line_items(self): """Get line items. Returns: list of instance: List of line items object. """ return self.line_items def set_shipping_charge(self, shipping_charge): """Set shipping charge. Args: shipping_charge(float): Shipping charge. """ self.shipping_charge = shipping_charge def get_shipping_charge(self): """Get shipping charge. Returns: float: Shipping charge. """ return self.shipping_charge def set_adjustment(self, adjustment): """Set adjustment. Args: adjustment(float): Adjustment. """ self.adjustment = adjustment def get_adjustment(self): """Get adjustment. Returns: float: Adjustment. """ return self.adjustment def set_adjustment_description(self, adjustment_description): """Set adjustment description. Args: adjustment_description(str): Adjustment description. """ self.adjustment_description = adjustment_description def get_adjustment_description(self): """Get adjustment description. Returns: str: Adjustment description. """ return self.adjustment_description def set_sub_total(self, sub_total): """Set sub total. Args: sub_total(float): Sub total. """ self.sub_total = sub_total def get_sub_total(self): """Get sub total. Returns: float: Sub total. """ return self.sub_total def set_total(self, total): """Set total. Args: total(float): Total. """ self.total = total def get_total(self): """Get total. Returns: float: Total. """ return self.total def set_price_precision(self, price_precision): """Set price precision. Args: price_precision(int): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: int: Price precision. """ return self.price_precision def set_taxes(self, tax): """Set taxes. Args: taxes(instance): Tax object. """ self.taxes.extend(tax) def get_taxes(self): """Get taxes. Returns: list of instance: List of tax object. """ return self.taxes def set_billing_address(self, address): """Set billing address. Args: address(instance): Address object. """ self.billing_address = address def get_billing_address(self): """Get billing address. Returns: instance: Address object. """ return self.billing_address def set_shipping_address(self, address): """Set shipping address. Args: address(instance): Address object. """ self.shipping_address = address def get_shipping_address(self): """Get shipping address. Returns: instance: Address object. """ return self.shipping_address def set_notes(self, notes): """Set note. Args: notes(str): Notes. """ self.notes = notes def get_notes(self): """Get notes. Returns: str: Notes. """ return self.notes def set_terms(self, terms): """Set terms. Args: terms(str): Terms. """ self.terms = terms def get_terms(self): """Get terms. Returns: str: Terms. """ return self.terms 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 field. Returns: list of instance: List of custom field object. """ return self.custom_fields def set_template_id(self, template_id): """Set template id. Args: template_id(str): Template id. """ self.template_id = template_id def get_template_id(self): """Get template id. Returns: str: Template id. """ return self.template_id def set_template_name(self, template_name): """Set template name. Args: template_name(str): Template name. """ self.template_name = template_name def get_template_name(self): """Get template name. Returns: str: Template name. """ return self.template_name def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_last_modified_time(self, last_modified_time): """Set last modified time. Args: last_modified_time(str): Last modified time. """ self.last_modified_time = last_modified_time def get_last_modified_time(self): """Get last modified time. Returns: str: LAst modified time. """ return self.last_modified_time def set_salesperson_id(self, salesperson_id): """Set salesperson id. Args: salesperson_id(str): Salesperson id. """ self.salesperson_id = salesperson_id def get_salesperson_id(self): """Get salesperson id. Returns: str: Salesperson id. """ return self.salesperson_id def set_salesperson_name(self, salesperson_name): """Set salesperson_name. Args: salesperson_name(str): Salesperson name. """ self.salesperson_name = salesperson_name def get_salesperson_name(self): """Get salesperson name. Returns: str: Salesperson name. """ return self.salesperson_name def set_accepted_date(self, accepted_date): """Set accepted date. Args: accepted_date(str): Accepted date. """ self.accepted_date = accepted_date def get_accepted_date(self): """Get accepted date. Returns: str: Accepted date. """ return self.accepted_date def set_declined_date(self, declined_date): """Set declined date. Args: declined_date(str): Declined date. """ self.declined_date = declined_date def get_declined_date(self): """Get declined date. Returns: str: Declined date. """ return self.declined_date def set_tax_total(self, tax_total): """Set tax total. Args: tax_total(float): Tax total. """ self.tax_total = tax_total def get_tax_total(self): """Get tax total. Returns: float: Tax total. """ return self.tax_total def to_json(self): """This method is used to comnvert estimates object to json object. Returns: dict: Dictionary containing json object for estimates. """ data = {} if self.customer_id != '': data['customer_id'] = self.customer_id if self.estimate_number != '': data['estimate_number'] = self.estimate_number if self.contact_persons: data['contact_persons'] = self.contact_persons if self.template_id != '': data['template_id'] = self.template_id if self.reference_number != '': data['reference_number'] = self.reference_number if self.date != '': data['date'] = self.date if self.expiry_date != '': data['expiry_date'] = self.expiry_date if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.discount > 0: data['discount'] = self.discount if self.is_discount_before_tax is not None: data['is_discount_before_tax'] = self.is_discount_before_tax if self.discount_type != '': data['discount_type'] = self.discount_type if self.salesperson_name != '': data['salesperson_name'] = self.salesperson_name if self.custom_fields: data['custom_fields'] = [] for value in self.custom_fields: custom_field = value.to_json() data['custom_fields'].append(custom_field) if self.line_items: data['line_items'] = [] for value in self.line_items: line_item = value.to_json() data['line_items'].append(line_item) if self.notes != '': data['notes'] = self.notes if self.terms != '': data['terms'] = self.terms if self.shipping_charge > 0: data['shipping_charge'] = self.shipping_charge if self.adjustment != '': data['adjustment'] = self.adjustment if self.adjustment_description != '': data['adjustment_description'] = self.adjustment_description return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Estimate.py
Estimate.py
class BankAccount: """This class is used to create object for Bank accounts.""" def __init__(self): """Initialize parameters for Bank accounts object.""" self.account_id = '' self.account_name = '' self.currency_id = '' self.currency_code = '' self.account_type = '' self.account_number = '' self.uncategorized_transactions = '' self.is_active = None self.balance = 0.0 self.bank_name = '' self.routing_number = '' self.is_primary_account = None self.is_paypal_account = None self.paypal_email_address = '' self.description = '' self.paypal_type = '' def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name 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 currecny 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_account_type(self, account_type): """Set account type. Args: account_type(str): Account type. """ self.account_type = account_type def get_account_type(self): """Get account type. Returns: str: Account type. """ return self.account_type def set_account_number(self, account_number): """Set account number. Args: account_number(str): ACcount number. """ self.acccount_number = account_number def get_account_number(self): """Get account number. Returns: str: Account number. """ return self.account_number def set_uncategorized_transactions(self, uncategorized_transactions): """Set uncategorized transactions. Args: uncategorized_transactions(str): Uncategorized transactions. """ self.uncategorized_transactions = uncategorized_transactions def get_uncategorized_transactions(self): """Get uncategorized transactions. Returns: str: Uncategorized transactions. """ return self.uncategorized_transactions def set_is_active(self, is_active): """Set whether the account is active or not. Args: is_active(bool): True if it is active else False. """ self.is_active = is_active def get_is_active(self): """Get whether the bank account is active or not. Returns: bool: True if active else False. """ return self.is_active def set_balance(self, balance): """Set balance. Args: balance(float): Balance. """ self.balance = balance def get_balance(self): """Get balance. Returns: float: Balance. """ return self.balance def set_bank_name(self, bank_name): """Set bank name. Args: bank_name(str): Bank name. """ self.bank_name = bank_name def get_bank_name(self): """Get bank name. Returns: str: Bank name. """ return self.bank_name def set_routing_number(self, routing_number): """Set routing number. Args: routing_number(str): Routing number. """ self.routing_number = routing_number def get_routing_number(self): """Get routing number. Returns: str: Routing number. """ return self.routing_number def set_is_primary_account(self, is_primary_account): """Set whether the bank account is primary account or not. Args: is_primary_account(bool): True if it is primary account else False. """ self.is_primary_account = is_primary_account def get_is_primary_account(self): """Get whether the bank account is primary account or not. Returns: bool: True if it is primary account else False. """ return self.is_primary_account def set_is_paypal_account(self, is_paypal_account): """Set whether the account is paypal account. Args: is_paypal_account(bool): True if the account is paypal account. """ self.is_paypal_account = is_paypal_account def get_is_paypal_account(self): """Get whether the account is paypal account. Returns: bool: True if the account is paypal account else False. """ return self.is_paypal_account def set_paypal_email_address(self, paypal_email_address): """Set paypal email address. Args: paypal_email_Address(str): Paypal email address. """ self.paypal_email_address = paypal_email_address def get_paypal_email_address(self): """Get paypal email address. Returns: str: PAypal email address. """ return self.paypal_email_address def set_description(self, description): """Set description. Args: description(str): Description. """ self.descrition = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_paypal_type(self, paypal_type): """Set paypal type. Args: paypal_type(str): Paypal type. """ self.paypal_type = paypal_type def get_paypal_type(self): """Get paypal type. Returns: str: Paypal type. """ return self.paypal_type def to_json(self): """This method is used to create json object for bank acoounts. Returns: dict: Dictionary containing json object for bank accounts. """ data = {} if self.account_name != '': data['account_name'] = self.account_name if self.account_type != '': data['account_type'] = self.account_type if self.account_number != '': data['account_number'] = self.account_number if self.currency_id != '': data['currency_id'] = self.currency_id if self.description != '': data['description'] = self.description if self.bank_name != '': data['bank_name'] = self.bank_name if self.routing_number != '': data['routing_number'] = self.routing_number if self.is_primary_account is not None: data['is_primary_account'] = self.is_primary_account if self.is_paypal_account is not None: data['is_paypal_account'] = self.is_paypal_account if self.paypal_type != '': data['paypal_type'] = self.paypal_type if self.paypal_email_address != '': data['paypal_email_address'] = self.paypal_email_address return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/BankAccount.py
BankAccount.py
class Currency: """This class is used to create object for currency. """ def __init__(self): """Initialize parameters for currency object.""" self.currency_id = '' self.currency_code = '' self.currency_name = '' self.currency_symbol = '' self.price_precision = 0 self.currency_format = '' self.is_base_currency = None self.exchange_rate = 0.0 self.effective_date = '' 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_name(self, currency_name): """Set currency name. Args: currency_name(str): Currency name. """ self.currency_name = currency_name def get_currency_name(self): """Get currency name. Returns: str: Currency name. """ return self.currency_name 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_price_precision(self, price_precision): """Set price precision. Args: price_precision(int): Price precision. """ self.price_precision = price_precision def get_price_precision(self): """Get price precision. Returns: int: Price precision. """ return self.price_precision 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. Returns: str: Currency fromat. """ return self.currency_format def set_is_base_currency(self, is_base_currency): """Set whether the currency is base currency. Args: is_base_currency(bool): True if it is base currency else False. """ self.is_base_currency = is_base_currency def get_is_base_currency(self): """Get whether the currency is base currency. Returns: bool: True if it is base currency else false. """ return self.is_base_currency def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_effective_date(self, effective_date): """Set effective date. Args: effective_date(str): Effective date. """ self.effective_date = effective_date def get_effective_date(self): """Get effective date. Returns: str: Effective date. """ return self.effective_date def to_json(self): """This method is used to create json object for currency. Returns: dict: Dictionary containing json object for currency. """ data = {} if self.currency_code != '': data['currency_code'] = self.currency_code if self.currency_symbol != '': data['currency_symbol'] = self.currency_symbol if self.price_precision > 0: data['price_precision'] = self.price_precision if self.currency_format != '': data['currency_format'] = self.currency_format return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Currency.py
Currency.py
class ExchangeRate: """This class is used to create object for Exchange rate.""" def __init__(self): """Initialize parameters for exchange rate.""" self.exchange_rate_id = '' self.currency_id = '' self.currency_code = '' self.effective_date = '' self.rate = 0.0 def set_exchange_rate_id(self, exchange_rate_id): """Set exchange rate id. Args: exchange_rate_id(str): Exchange rate id. """ self.exchange_rate_id = exchange_rate_id def get_exchange_rate_id(self): """Get exchange rate id. Returns: str: Exchange rate id. """ return self.exchange_rate_id 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_effective_date(self, effective_date): """Set effective date. Args: effective_date(str): Effective date. """ self.effective_date = effective_date def get_effective_date(self): """Get effective date. Returns: str: Effective date. """ return self.effective_date def set_rate(self, rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def to_json(self): """This method is used to create json object for exchange rate. Returns: dict: Dictionary containing json object for exchange rate. """ data = {} if self.currency_id != '': data['currency_id'] = self.currency_id if self.currency_code != '': data['currency_code'] = self.currency_code if self.effective_date != '': data['effective_date'] = self.effective_date if self.rate > 0: data['rate'] = self.rate if self.effective_date != '': data['effective_date'] = self.effective_date return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/ExchangeRate.py
ExchangeRate.py
class VendorPayment: """This class is used to create object for Vendor payments.""" def __init__(self): """Initialize parameters for Vendor payments.""" self.payment_id = '' self.vendor_id = '' self.vendor_name = '' self.payment_mode = '' self.description = '' self.date = '' self.reference_number = '' self.exchange_rate = 0.0 self.amount = 0.0 self.currency_symbol = '' self.paid_through_account_id = '' self.paid_through_account_name = '' self.bills = [] self.balance = 0.0 def set_payment_id(self, payment_id): """Set payment id. Args: payment_id(str): Payment id. """ self.payment_id = payment_id def get_payment_id(self): """Get payment id. Returns: str: Payment id. """ return self.payment_id def set_vendor_id(self, vendor_id): """Set vendor id. Args: vendor_id(str): Vendor id. """ self.vendor_id = vendor_id def get_vendor_id(self): """Get vendor id. Returns: str: Vendor id. """ return self.vendor_id def set_vendor_name(self, vendor_name): """Set vendor name. Args: vendor_name(str): Vendor name. """ self.vendor_name = vendor_name def get_vendor_name(self): """Get vendor name. Returns: str: Vendor name. """ return self.vendor_name def set_payment_mode(self, payment_mode): """Set payment mode. Args: payment_mode(str): Payment mode. """ self.payment_mode = payment_mode def get_payment_mode(self): """Get payment mode. Returns: str: Payment mode. """ return self.payment_mode def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_date(self, date): """Set date. Args: date(str): Date. """ self.date = date def get_date(self): """Get date. Returns: str: Date. """ return self.date def set_reference_number(self, reference_number): """Set reference number. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number. Returns: str: Reference number. """ return self.reference_number def set_exchange_rate(self, exchange_rate): """Set exchange rate. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate. Returns: float: Exchange rate. """ return self.exchange_rate def set_amount(self, amount): """Set amount. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount. Returns: float: Amount. """ return self.amount 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_paid_through_account_id(self, paid_through_account_id): """Set paid through account id. Args: paid_through_account_id(str): Paid through account id. """ self.paid_through_account_id = paid_through_account_id def get_paid_through_account_id(self): """Get paid through account id. Returns: str: Paid through acount id. """ return self.paid_through_account_id def set_paid_through_account_name(self, paid_through_account_name): """Set paid through account name. Args: paid_through_account_name(str): Paid through account name. """ self.paid_through_account_name = paid_through_account_name def get_paid_through_account_name(self): """Get paid through account name. Returns: str: Paid through account name. """ return self.paid_through_account_name def set_bills(self, bill): """Set bills. Args: bills(instance): Bills object. """ self.bills.append(bill) def get_bills(self): """Get bills. Returns: list of instance: List of bills object. """ return self.bills def set_balance(self, balance): """Set balance. Args: balance(float): Balance. """ self.balance = balance def get_balance(self): """Get balance. Returns: float: Balance. """ return self.balance def to_json(self): """This method is used to convert vendor payments object to json object. Returns: dict: Dictionary containing json object for vendor payments. """ data = {} if self.vendor_id != '': data['vendor_id'] = self.vendor_id if self.bills: data['bills'] = [] for value in self.bills: bill = value.to_json() data['bills'].append(bill) if self.payment_mode != '': data['payment_mode'] = self.payment_mode if self.description != '': data['description'] = self.description if self.date != '': data['date'] = self.date if self.reference_number != '': data['reference_number'] = self.reference_number if self.exchange_rate > 0: data['exchange_rate'] = self.exchange_rate if self.amount > 0: data['amount'] = self.amount if self.paid_through_account_id != '': data['paid_through_account_id'] = self.paid_through_account_id return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/VendorPayment.py
VendorPayment.py
class Instrumentation: """This class is used tocreate object for instrumentation.""" def __init__(self): """Initialize parameters for Instrumentation object.""" self.query_execution_time = '' self.request_handling_time = '' self.response_write_time = '' self.page_context_write_time = '' def set_query_execution_time(self, query_execution_time): """Set query execution time. Args: query_execution_time(str): Query execution time. """ self.query_execution_time = query_execution_time def get_query_execution_time(self): """Get query execution time. Returns: str: Query execution time. """ return self.query_execution_time def set_request_handling_time(self, request_handling_time): """Set request handling time. Args: request_handling_time(str): Request handling time. """ self.request_handling_time = request_handling_time def get_request_handling_time(self): """Get request handling time. Returns: str: Request handling time. """ return self.request_handling_time def set_response_write_time(self, response_write_time): """Set response write time. Args: response_write_time(str): Response write time. """ self.response_write_time = response_write_time def get_response_write_time(self): """Get response write time. Returns: str: Response write time. """ return self.response_write_time def set_page_context_write_time(self, page_context_write_time): """Set page context write time. Args: page_context_write_time(str): Page context write time. """ self.page_context_write_time = page_context_write_time def get_page_context_write_time(self): """Get page context write time. Returns: str: Page context write time. """ return self.page_context_write_time
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Instrumentation.py
Instrumentation.py
class Task: """This class is used to create object for tasks.""" def __init__(self): """Initialize parameters for tasks object.""" self.task_id = '' self.task_name = '' self.description = '' self.rate = 0.0 self.budget_hours = 0 self.total_hours = '' self.billed_hours= '' self.unbilled_hours = '' self.project_id = '' self.project_name = '' self.currency_id = '' self.customer_id = '' self.customer_name = '' self.log_time = '' def set_task_id(self, task_id): """Set task id. Args: task_id(str): Task id. """ self.task_id = task_id def get_task_id(self): """Get task id. Returns: str: Task id. """ return self.task_id def set_task_name(self, task_name): """Set task name. Args: task_name(str): Task name. """ self.task_name = task_name def get_task_name(self): """Get task name. Returns: str: Task name. """ return self.task_name def set_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description Returns: str: Description. """ return self.description def set_rate(self, rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def set_budget_hours(self, budget_hours): """Set budget hours. Args: budget_hours(int): Budget hours. """ self.budget_hours = budget_hours def get_budget_hours(self): """Get budget_hours. Returns: int: Budget hours. """ return self.budget_hours def set_total_hours(self, total_hours): """Set total hours. Args: total_hours(str): Total hours. """ self.total_hours = total_hours def get_total_hours(self): """Get total hours. Returns: str: Total hours. """ return self.total_hours def set_billed_hours(self, billed_hours): """Set billed hours. Args: billed_hours(str): Billed hours. """ self.billed_hours = billed_hours def get_billed_hours(self): """Get billed hours. Args: str: billed hours. """ return self.billed_hours def set_un_billed_hours(self, un_billed_hours): """Set unbilled hours. Args: un_billed_hours(str): Unbilled hours. """ self.un_billed_hours = un_billed_hours def get_un_billed_hours(self): """Get unbilled hours. Returns: str: Unbilled hours. """ return self.un_billed_hours def set_project_id(self, project_id): """Set project_id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id def set_project_name(self, project_name): """Set project name. Args: project_name(str): Project name. """ self.project_name = project_name def get_project_name(self): """Get project name. Returns: str: Project name. """ return self.project_name 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_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_log_time(self, log_time): """Set log time. Args: log_time(str): Log time. """ self.log_time = log_time def get_log_time(self): """Get log time. Returns: str: Log time. """ return self.log_time def to_json(self): """This method is used to convert task object to jsno format. Returns: dict: Dictionary containing json object for task. """ data = {} if self.task_name != '': data['task_name'] = self.task_name if self.description != '': data['description'] = self.description if self.rate > 0: data['rate'] = self.rate if self.budget_hours > 0: data['budget_hours'] = self.budget_hours return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Task.py
Task.py
class ContactPerson: """This class is used to create model for contact person.""" def __init__(self): """Initialize the parameters for contact person.""" self.contact_person_id = '' self.salutation = '' self.first_name = '' self.last_name = '' self.email = '' self.phone = '' self.mobile = '' self.is_primary_contact = None self.contact_id = '' def set_contact_person_id(self, contact_person_id): """Set contact person id. Args: contact_person_id(str): Contact person id. """ self.contact_person_id = contact_person_id def get_contact_person_id(self): """Get contact person id. Returns: str: Contact person id. """ return self.contact_person_id def set_salutation(self, salutation): """Set salutation. Args: salutation(str): Salutation. """ self.salutation = salutation def get_salutation(self): """Get salutation. Returns: str: Salutation. """ return self.salutation def set_first_name(self, first_name): """Set first name. Args: first_name(str): First name. """ self.first_name = first_name def get_first_name(self): """Get first name. Returns: str: First name. """ return self.first_name def set_last_name(self, last_name): """Set last name. Args: last_name(str): Last name. """ self.last_name = last_name def get_last_name(self): """Get last name. Returns: str: Last name. """ return self.last_name 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_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_mobile(self, mobile): """Set mobile. Args: mobile(str): Mobile. """ self.mobile = mobile def get_mobile(self): """Get mobile. Args: mobile(str): Mobile. """ return self.mobile def set_is_primary_contact(self, is_primary_contact): """Set whether it is primary contact or not. Args: is_primary_contact(bool): True if it is primary contact. Allowed value is true only. """ self.is_primary_contact = is_primary_contact def get_is_primary_contact(self): """Get whether it is primary contact or not. Returns: bool: True if it os primary contact else False. """ return self.is_primary_contact def set_contact_id(self, contact_id): """Set contact id. Args: contact_id(str): Contact id. """ self.contact_id = contact_id def get_contact_id(self): """Get contact id. Returns: str: Contact id. """ return self.contact_id def to_json(self): """This method is used to convert the contact person object to JSON object. Returns: dict: Dictionary containing details of contact person object. """ contact_person = {} if self.salutation != '': contact_person['salutation'] = self.salutation if self.first_name != '': contact_person['first_name'] = self.first_name if self.last_name != '': contact_person['last_name'] = self.last_name if self.email != '': contact_person['email'] = self.email if self.phone != '': contact_person['phone'] = self.phone if self.mobile != '': contact_person['mobile'] = self.mobile if self.is_primary_contact != False: contact_person['is_primary_contact'] = str(\ self.is_primary_contact).lower() if self.contact_id != '': contact_person['contact_id'] = self.contact_id return contact_person
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/ContactPerson.py
ContactPerson.py
from books.model.PageContext import PageContext class Statement: """This class is used to create object for statement.""" def __init__(self): """Initialize parameters for Statement object.""" self.statement_id = '' self.from_date = '' self.to_date = '' self.source = '' self.transactions = [] self.page_context = PageContext() def set_statement_id(self, statement_id): """Set statement id. Args: statement_id(str): Statement id. """ self.statement_id = statement_id def get_statement_id(self): """Get statement id. Returns: str: Statement id. """ return self.statement_id def set_from_date(self, from_date): """Set from date. Args: from_date(str): From date. """ self.from_date = from_date def get_from_date(self): """Get from date. Returns: str: From date. """ return self.from_date def set_source(self, source): """Set source. Args: source(str): Source. """ self.source = source def get_source(self): """Get source. Returns: str: Source. """ return self.source def set_transactions(self, transactions): """Set transactions. Args: transactions(instance): Transactions object. """ self.transactions.append(transactions) def get_transactions(self): """Get transactions. Returns: list of instance: List of transactions object. """ return self.transaction def set_page_context(self, page_context): """Set page context. Args: page_context(instance): Page context object. """ self.page_context = page_context def get_page_context(self): """Get page context. Returns: instance: Page context object. """ return self.page_context def set_to_date(self, to_date): """Set to date. Args: to_date(str): To date. """ self.to_date = to_date def get_to_date(self): """Get to date. Returns: str: To date. """ return self.to_date
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Statement.py
Statement.py
class User: """This class is used to create object for Users.""" def __init__(self): """Initialize parameters for Users object.""" self.user_id = '' self.is_current_user = None self.user_name = '' self.email = '' self.user_role = '' self.status = '' self.rate = 0.0 self.budget_hours = 0 self.total_hours = '' self.billed_hours = '' self.un_billed_hours = '' self.project_id = '' self.created_time = '' self.email_ids = [] self.role_id = '' self.name = '' self.photo_url = '' def set_photo_url(self, photo_url): """Set photo url. Args: photo_url(str): Photo url. """ self.photo_url = photo_url def get_photo_url(self): """Get photo url. Returns: str: Photo url. """ return self.photo_url 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_project_id(self, project_id): """Set project id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id def set_user_id(self, user_id): """Set user id. Args: user_id(str): User id. """ self.user_id = user_id def get_user_id(self): """Get user id. Returns: str: User id. """ return self.user_id def set_is_current_user(self, is_current_user): """Set whether it is current user or not. Args: is_current_user(bool): True if it is current user else False. """ self.is_current_user = is_current_user def get_is_current_user(self): """Get whether it is current user. Returns: bool: True if it is a current user else False. """ return self.is_current_user def set_user_name(self, user_name): """Set user name. Args: user_name(str): User name. """ self.user_name = user_name def get_user_name(self): """Get user name. Returns: str: User name """ return self.user_name 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_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_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_rate(self, rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def set_budget_hours(self, budget_hours): """Set budget hours. Args: budget_hours(int): Budget hours. """ self.budget_hours = budget_hours def get_budget_hours(self): """Get budget hours. Returns: int: Budget hours. """ return self.budget_hours def set_total_hours(self, total_hours): """Set total hours. Args: total_hours(str): Total hours. """ self.total_hours = total_hours def get_total_hours(self): """Get total hours. Returns: str: Total hours. """ return self.total_hours def set_billed_hours(self, billed_hours): """Set billed hours. Args: billed_hours(str): Billed hours. """ self.billed_hours = billed_hours def get_billed_hours(self): """Get billed hours. Returns: str: Billed hours. """ return self.billed_hours def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_rate(self, rate): """Set rate. Args: rate(float): Rate """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def budget_hours(self, budget_hours): """Set budget hours. Args: budget_hours(str): Budget hours. """ self.budget_hours = budget_hours def get_budget_hours(self): """Get budget hours. Returns: str: Budget hours. """ return self.budget_hours def set_total_hours(self, total_hours): """Set total hours. Args: total_hours(str): Total hours. """ self.total_hours = total_hours def get_total_hours(self): """Get total hours. Returns: str: Total hours. """ return self.total_hours def set_billed_hours(self, billed_hours): """Set billed hours. Args: billed_hours(str): Billed hours. """ self.billed_hours = billed_hours def get_billed_hours(self): """Get billed hours. Returns: str: Billed hours. """ return self.billed_hours def set_un_billed_hours(self, un_billed_hours): """Set unbilled hours. Args: un_billed_hours(str): Un billed hours. """ self.un_billed_hours = un_billed_hours def get_un_billed_hours(self): """Get unbilled hours. Returns: str: Unbilled hours. """ return self.un_billed_hours def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_email_ids(self, email_ids): """Set email ids. Args: email_ids(instance): Email ids object. """ self.email_ids = email_ids def get_email_ids(self): """Get email ids. Returns: list of instance: list of Email ids object. """ return self.email_ids def set_role_id(self, role_id): """Set role id. Args: role_id(str): Role id. """ self.role_id = role_id def get_role_id(self): """Get role id. Returns: str: Role id. """ return self.role_id def to_json(self): """This method is used to convert user object to json format. Returns: dict: Dictionary containing json object for user. """ data = {} if self.user_id != '': data['user_id'] = self.user_id if self.rate > 0: data['rate'] = self.rate if self.budget_hours > 0: data['budget_hours'] = self.budget_hours if self.user_name != '': data['user_name'] = self.user_name if self.email != '': data['email'] = self.email if self.user_role != '': data['user_role'] = self.user_role if self.name != '': data['name'] = self.name return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/User.py
User.py
class CreditNoteRefund: """This class is used to create object for creditnotes refund.""" def __init__(self): """Initialize parameters for creditnotes refund object.""" self.date = '' self.refund_mode = '' self.reference_number = '' self.amount = 0.0 self.exchange_rate = 0.0 self.from_account_id = '' self.from_account_name = '' self.description = '' self.creditnote_refund_id = '' self.creditnote_id = '' self.creditnote_number = '' self.customer_name = '' self.amount_bcy = '' self.amount_fcy = '' def set_date(self, date): """Set the date at which the credit note is created. Args: date(str): Date. """ self.date = date def get_date(self): """Get date at which the credit note is created. Returns: str: Date. """ return self.date def set_refund_mode(self, refund_mode): """Set the mode of refund for the credit note refund amount. Args: refund_mode(str): Refund mode . """ self.refund_mode = refund_mode def get_refund_mode(self): """Get the mode of refund for the credit note refund amount. Returns: str: Refund mode. """ return self.refund_mode def set_reference_number(self, reference_number): """Set reference number for the refund recorded. Args: reference_number(str): Reference number. """ self.reference_number = reference_number def get_reference_number(self): """Get reference number for the refund recorded. Returns: str: Reference number. """ return self.reference_number def set_amount(self, amount): """Set amount refunded from the credit note. Args: amount(float): Amount. """ self.amount = amount def get_amount(self): """Get amount refunded from the credit note. Returns: float: Amount. """ return self.amount def set_exchange_rate(self, exchange_rate): """Set exchange rate of the currency. Args: exchange_rate(float): Exchange rate. """ self.exchange_rate = exchange_rate def get_exchange_rate(self): """Get exchange rate of the currency. Returns: float: Exchange rate. """ return self.exchange_rate def set_from_account_id(self, from_account_id): """Set the account id from which credit note is refunded. Args: from_account_id(str): The account id from which credit note is refunded. """ self.from_account_id = from_account_id def get_from_account_id(self): """Get the account id from which credit note is refunded. Returns: str: The account id from which credit note is refunded. """ return self.from_account_id def set_description(self, description): """Set description for the refund. Args: description(str): Description for the refund. """ self.description = description def get_description(self): """Get descriptioon for the refund. Returns: str: Description for the refund. """ return self.description def set_creditnote_refund_id(self, creditnote_refund_id): """Set creditnote refund id. Args: creditnote_refund(str): Id of the creditnote refund. """ self.creditnote_refund_id = creditnote_refund_id def get_creditnote_refund_id(self): """Get creditnote refund id. Returns: str: Id of the creditnote refund. """ return self.creditnote_refund_id def set_creditnote_id(self, creditnote_id): """Set credit note id. Args: creditnote_id(str): Id of the creditnote. """ self.creditnote_id = creditnote_id def get_creditnote_id(self): """Get Id of the credit note. Returns: str: Id of the creditnote. """ return self.creditnote_id def set_from_account_name(self, from_account_name): """Set account name from which credit note is refunded. Args: from_account_name(str): Account name from which credit note is refunded. """ self.from_account_name = from_account_name def get_from_account_name(self): """Get account name from which credit note is refunded. Returns: str: Account name from which credit note is refunded. """ return self.from_account_name def set_creditnote_number(self, creditnote_number): """Set creditnote number of the creditnote. Args: creditnote_number(str): Creditnote number of creditnote. """ self.creditnote_number = creditnote_number def get_creditnote_number(self): """Get creditnote number of the creditnote. Returns: str: Creditnote number of creditnote. """ return self.creditnote_number def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name def set_amount_bcy(self, amount_bcy): """Set amount bcy. Args: amount_bcy(str): Amount_bcy. """ self.amount_bcy = amount_bcy def get_amount_bcy(self): """Get amount bcy. Returns: str: Amount_bcy. """ return self.amount_bcy def set_amount_fcy(self, amount_fcy): """Set amount fcy. Args: amount_fcy(str): Amount fcy. """ self.amount_fcy = amount_fcy def get_amount_fcy(self): """Get amount fcy. Returns: str: Amount fcy. """ return self.amount_fcy def to_json(self): """This method is used to convert creditnote refund object to json object. Returns: dict: Dictionary containing json object for credit note refund. """ data = {} if self.date != '': data['date'] = self.date if self.refund_mode != '': data['refund_mode'] = self.refund_mode if self.reference_number != '': data['reference_number'] = self.reference_number if self.amount > 0: data['amount'] = self.amount if self.exchange_rate > 0 : data['exchange_rate'] = self.exchange_rate if self.from_account_id != '': data['from_account_id'] = self.from_account_id if self.description != '': data['description'] = self.description if self.creditnote_id != '': data['creditnote_id'] = self.creditnote_id return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/CreditNoteRefund.py
CreditNoteRefund.py
class Project: """This class is used to create object for Projects.""" def __init__(self): """Initialize the parameters for projects object.""" self.project_id = '' self.project_name = '' self.customer_id = '' self.customer_name = '' self.currency_code = '' self.description = '' self.status = '' self.billing_type = '' self.rate = 0.0 self.budget_type = '' self.budget_hours = 0 self.budget_amount = 0.0 self.total_hours = '' self.billed_hours = '' self.un_billed_hours = '' self.created_time = '' self.tasks = [] self.users = [] def set_project_id(self, project_id): """Set project_id. Args: project_id(str): Project id. """ self.project_id = project_id def get_project_id(self): """Get project id. Returns: str: Project id. """ return self.project_id def set_project_name(self, project_name): """Set project name. Args: project_name(str): Project name. """ self.project_name = project_name def get_project_name(self): """Get project name. Returns: str: Project name. """ return self.project_name def set_customer_id(self, customer_id): """Set customer id. Args: customer_id(str): Customer id. """ self.customer_id = customer_id def get_customer_id(self): """Get customer id. Returns: str: Customer id. """ return self.customer_id def set_customer_name(self, customer_name): """Set customer name. Args: customer_name(str): Customer name. """ self.customer_name = customer_name def get_customer_name(self): """Get customer name. Returns: str: Customer name. """ return self.customer_name 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_description(self, description): """Set description. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_status(self, status): """Set status. Args: status(str): Status. """ self.status = status def get_status(self): """Get status. Returns: str: Status. """ return self.status def set_billing_type(self, billing_type): """Set billing type. Args: billing_type(str): Billing type. """ self.billing_type = billing_type def get_billing_type(self): """Get billing type. Returns: str: Billing type. """ return self.billing_type def set_budget_type(self, budget_type): """Set budget type. Args: budget_type(str): Budget type. """ self.budget_type = budget_type def get_budget_type(self): """Get budget type. Returns: str: Budget type. """ return self.budget_type def set_total_hours(self, total_hours): """Set total hours. Args: total_hours(str): Total hours. """ self.total_hours = total_hours def get_total_hours(self): """Get total hours. Returns: str: Total hours. """ return self.total_hours def set_billed_hours(self, billed_hours): """Set billed hours. Args: billed_hours(str): Billed hours. """ self.billed_hours = billed_hours def get_billed_hours(self): """Get billed hours. Returns: str: Billed hours. """ return self.billed_hours def set_un_billed_hours(self, un_billed_hours): """Set unbilled hours. Args: un_billed_hours(str): Unbilled hours. """ self.un_billed_hours = un_billed_hours def get_un_billed_hours(self): """Get unbilled hours. Returns: str: Unbilled hours. """ return self.un_billed_hours def set_created_time(self, created_time): """Set created time. Args: created_time(str): Created time. """ self.created_time = created_time def get_created_time(self): """Get created time. Returns: str: Created time. """ return self.created_time def set_tasks(self, task): """Set task. Args: task(instance): Task object. """ self.tasks.append(task) def get_tasks(self): """Get tasks. Returns: list of instance: List of task object. """ return self.tasks def set_users(self, user): """Set User. Args: user(instance): User object. """ self.users.append(user) def get_users(self): """Get user. Returns: list of object: User object. """ return self.users def set_rate(self, rate): """Set rate. Args: rate(float): Rate. """ self.rate = rate def get_rate(self): """Get rate. Returns: float: Rate. """ return self.rate def set_budget_hours(self, budget_hours): """Set budget hours. Args: budget_hours(str): Budget hours. """ self.budget_hours = budget_hours def get_budget_hours(self): """Get budget hours. Returns: str: Budget hours. """ return self.budget_hours def set_budget_amount(self, budget_amount): """Set budget amount. Args: budget_amount(float): Budget amount. """ self.budget_amount = budget_amount def get_budget_amount(self): """Get budget amount. Returns: float: Budget amount. """ return self.budget_amount def to_json(self): """This method is used to convert projects object to json format. Returns: dict: Dictionary containing json for projects. """ data = {} if self.project_name != '': data['project_name'] = self.project_name if self.customer_id != '': data['customer_id'] = self.customer_id if self.description != '': data['description'] = self.description if self.billing_type != '': data['billing_type'] = self.billing_type if self.rate > 0: data['rate'] = self.rate if self.budget_type != '': data['budget_type'] = self.budget_type if self.budget_hours != '': data['budget_hours'] = self.budget_hours if self.budget_amount > 0: data['budget_amount'] = self.budget_amount if self.users: data['users'] = [] print(self.users) for value in self.users: print(value) user = value.to_json() data['users'].append(user) if self.tasks: data['tasks'] = [] for value in self.tasks: task = value.to_json() data['tasks'].append(task) return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/Project.py
Project.py
class ChartOfAccount: """Create object for Chart of Accounts.""" def __init__(self): """Initialize parameters for Chart of accounts.""" self.account_id = '' self.account_name = '' self.is_active = None self.account_type = '' self.account_type_formatted = '' self.currency_id = '' self.description = '' self.is_user_created = None self.is_involved_in_transaction = None self.is_system_account = None #self.current_balance = 0.0 #Not mentioned def set_account_id(self, account_id): """Set account id. Args: account_id(str): Account id. """ self.account_id = account_id def get_account_id(self): """Get account id. Returns: str: Account id. """ return self.account_id def set_account_name(self, account_name): """Set account name. Args: account_name(str): Account name. """ self.account_name = account_name def get_account_name(self): """Get account name. Returns: str: Account name. """ return self.account_name def set_is_active(self, is_active): """Set whether the account is active or not. Args: is_active(bool): True if active else False. """ self.is_active = is_active def get_is_active(self): """Get whether is active. Returns: bool: True if active else false. """ return self.is_active def set_account_type(self, account_type): """Set account type. Args: account_type(str): Account type. """ self.account_type = account_type def get_account_type(self): """Get account type. Returns: str: Account type. """ return self.account_type def set_account_type_formatted(self, account_type_formatted): """Set account type formatted. Args: account_type_formatted(str): Account type formatted. """ self.account_type_formatted = account_type_formatted def get_account_type_formatted(self): """Get acccount type formatted. Returns: str: Account type formatted. """ return self.account_type_formatted 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_description(self, description): """Set descripiton. Args: description(str): Description. """ self.description = description def get_description(self): """Get description. Returns: str: Description. """ return self.description def set_is_user_created(self, is_user_created): """Set whether the account is user created. Args: is_user_created(bool): True if user created else False. """ self.is_user_created = is_user_created def get_is_user_created(self): """Get whether the account is user created. Returns: bool: True if user created else False. """ return self.is_user_created def set_is_involved_in_transaction(self, is_involved_in_transaction): """Set Whether the account is involved in transactions. Args: is_involved_in_transaction(bool): True if the account is involved in transactions else False. """ self.is_involved_in_transaction = is_involved_in_transaction def get_is_involved_in_transaction(self): """Get whether the account is involved in transactions. Returns: bool: True if the account is involved in transaction. """ return self.is_involved_in_transaction def set_is_system_account(self, is_system_account): """Set whether the account is system account. Args: is_system_account(bool): True if system account else False. """ self.is_system_account = is_system_account def get_is_system_account(self): """Get whether the account is system account. Returns: bool: True if system account else False. """ return self.is_system_account '''def set_current_balance(self, current_balance): """Set current balance. Args: current_balance(float): Current balance. """ self.current_balance = current_balance def get_current_balance(self): """Get current balance. Returns: float: Current balance. """ return self.current_balance''' def to_json(self): """This method is used to convert chart of accounts object to json object. Returns: dict: Dictionary containing json object for chart of accounts. """ data = {} if self.account_name != '': data['account_name'] = self.account_name if self.account_type != '': data['account_type'] = self.account_type if self.currency_id != '': data['currency_id'] = self.currency_id if self.description != '': data['description'] = self.description return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/ChartOfAccount.py
ChartOfAccount.py
from books.model.PlaceHolder import PlaceHolder class ManualReminder: """This class is used to create object for manual reminders.""" def __init__(self): """Initilaize parameters for manual reminders.""" self.manualreminder_id = '' self.type = '' self.subject = '' self.body = '' self.cc_me = None self.placeholder = PlaceHolder() def set_manualreminder_id(self, manualreminder_id): """Set manual reminder id. Args: manualreminder_id(str): Manual reminder id. """ self.manualreminder_id = manualreminder_id def get_manualreminder_id(self): """Get manual reminder id. Returns: str: Manual reminder id. """ return self.manualreminder_id def set_type(self, type): """Set type. Args: type(str): Type. """ self.type = type def get_type(self): """Get type. Returns: str: Type. """ return self.type def set_subject(self, subject): """Set subject. Args: subject(str): Subject. """ self.subject = subject def get_subject(self): """Get subject. Returns: str: Subject. """ return self.subject def set_body(self, body): """Set body. Args: body(str): Body. """ self.body = body def get_body(self): """Get body. Returns: str: Body. """ return self.body def set_cc_me(self, cc_me): """Set cc me. Args: cc_me(bool): True to cc me else false. """ self.cc_me = cc_me def get_cc_me(self): """Get cc me. Returns: bool: True to cc me else false. """ return self.cc_me def set_placeholders(self, placeholders): """Set place holders. Args: place_holders: Palce holders object. """ self.placeholders = placeholders def get_placeholders(self): """Get place holders. Returns: instance: Place holders. """ return self.placeholders def to_json(self): """"This method is used to convert manual reminder object to json format. Returns: dict: Dictionary containing json object for manual reminders. """ data = {} if self.subject != '': data['subject'] = self.subject if self.body != '': data['body'] = self.body if self.cc_me is not None: data['cc_me'] = self.cc_me return data
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/model/ManualReminder.py
ManualReminder.py
from books.api.ContactsApi import ContactsApi from books.api.ContactPersonsApi import ContactPersonsApi from books.api.EstimatesApi import EstimatesApi from books.api.InvoicesApi import InvoicesApi from books.api.RecurringInvoicesApi import RecurringInvoicesApi from books.api.CreditNotesApi import CreditNotesApi from books.api.CustomerPaymentsApi import CustomerPaymentsApi from books.api.ExpensesApi import ExpensesApi from books.api.RecurringExpensesApi import RecurringExpensesApi from books.api.BillsApi import BillsApi from books.api.VendorPaymentsApi import VendorPaymentsApi from books.api.BankAccountsApi import BankAccountsApi from books.api.BankTransactionsApi import BankTransactionsApi from books.api.BankRulesApi import BankRulesApi from books.api.ChartOfAccountsApi import ChartOfAccountsApi from books.api.JournalsApi import JournalsApi from books.api.BaseCurrencyAdjustmentApi import BaseCurrencyAdjustmentApi from books.api.ProjectsApi import ProjectsApi from books.api.SettingsApi import SettingsApi from books.api.ItemsApi import ItemsApi from books.api.OrganizationsApi import OrganizationsApi from books.api.UsersApi import UsersApi class ZohoBooks: """ This class is used to create an object for books service and to provide instance for all APIs. """ def __init__(self, authtoken, organization_id): """Initialize the parameters for Zoho books. Args: authtoken(str): User's Authtoken. organization_id(str): User's Organization id. """ self.authtoken=authtoken self.organization_id=organization_id def get_contacts_api(self): """Get instance for contacts api. Returns: instance: Contacts api instance. """ contacts_api = ContactsApi(self.authtoken, self.organization_id) return contacts_api def get_contact_persons_api(self): """Get instance for contact persons api. Returns: instance: Contact persons api. """ contact_persons_api = ContactPersonsApi(self.authtoken, self.organization_id) return contact_persons_api def get_estimates_api(self): """Get instance for estimates api. Returns: instance: Estimates api. """ estimates_api = EstimatesApi(self.authtoken, self.organization_id) return estimates_api def get_invoices_api(self): """Get instance for invoice api. Returns: instance: Invoice api. """ invoices_api = InvoicesApi(self.authtoken, self.organization_id) return invoices_api def get_recurring_invoices_api(self): """Get instance for recurring invoices api. Returns: instance: Recurring invoice api. """ recurring_invoices_api = RecurringInvoicesApi(self.authtoken, \ self.organization_id) return recurring_invoices_api def get_creditnotes_api(self): """Get instance for creditnotes api. Returns: instance: Creditnotes api. """ creditnotes_api = CreditNotesApi(self.authtoken, self.organization_id) return creditnotes_api def get_customer_payments_api(self): """Get instance for customer payments api. Returns: instance: Customer payments api. """ customer_payments_api = CustomerPaymentsApi(self.authtoken, self.organization_id) return customer_payments_api def get_expenses_api(self): """Get instance for expenses api. Returns: instance: Expenses api. """ expenses_api = ExpensesApi(self.authtoken, self.organization_id) return expenses_api def get_recurring_expenses_api(self): """Get instance for recurring expenses api. Returns: instance: Recurring expenses api. """ recurring_expenses_api = RecurringExpensesApi(self.authtoken, self.organization_id) return recurring_expenses_api def get_bills_api(self): """Get instance for bills api. Returns: instance: Bills api """ bills_api = BillsApi(self.authtoken, self.organization_id) return bills_api def get_vendor_payments_api(self): """Get instance for vendor payments api. Returns: instance: vendor payments api """ vendor_payments_api = VendorPaymentsApi(self.authtoken, self.organization_id) return vendor_payments_api def get_bank_accounts_api(self): """Get instancce for bank accounts api. Returns: instance: Bank accounts api. """ bank_accounts_api = BankAccountsApi(self.authtoken, self.organization_id) return bank_accounts_api def get_bank_transactions_api(self): """Get instance for bank transactions api. Returns: instance: Bank Transactions api. """ bank_transactions_api = BankTransactionsApi(self.authtoken, self.organization_id) return bank_transactions_api def get_bank_rules_api(self): """Get instance for bank rules api. Returns: instance: Bank rules api. """ bank_rules_api = BankRulesApi(self.authtoken, self.organization_id) return bank_rules_api def get_chart_of_accounts_api(self): """Get instancce for chart of accounts api Returns: instance: Chart of accounts api. """ chart_of_accounts_api = ChartOfAccountsApi(self.authtoken, self.organization_id) return chart_of_accounts_api def get_journals_api(self): """Get instance for journals api. Returns: instance: Journals api. """ journals_api = JournalsApi(self.authtoken, self.organization_id) return journals_api def get_base_currency_adjustment_api(self): """Get instance for base currency adjustment api Returns: instance: Base currency adjustments api. """ base_currency_adjustment_api = BaseCurrencyAdjustmentApi(\ self.authtoken, self.organization_id) return base_currency_adjustment_api def get_projects_api(self): """Get instance for projects api. Returns: instance: Projects api. """ projects_api = ProjectsApi(self.authtoken, self.organization_id) return projects_api def get_settings_api(self): """Get instance for settings api. Returns: instance: Settings api. """ settings_api = SettingsApi(self.authtoken, self.organization_id) return settings_api def get_items_api(self): """Get instance for items api. Returns: instance: Items api. """ items_api = ItemsApi(self.authtoken, self.organization_id) return items_api def get_users_api(self): """Get instance for users api. Returns: instance: Users api. """ users_api = UsersApi(self.authtoken, self.organization_id) return users_api def get_organizations_api(self): """Get instance for organizations api. Returns: instance: Organizations api. """ organizations_api = OrganizationsApi(self.authtoken, self.organization_id) return organizations_api
zohobooks-api
/zohobooks-api-1.4.tar.gz/zohobooks-api-1.4/books/service/ZohoBooks.py
ZohoBooks.py