def __init__(self, company_name, project_name, invoice_code, invoice_name=''): company_dict = json_load('json/company_dict.json') project_dict = json_load('json/project_dict.json') if project_name in company_dict[company_name]['projects']: self.dict = project_dict[project_name] else: self.dict = {} self.dict['company_name'] = company_name self.dict['project_name'] = project_name self.dict['invoice_code'] = invoice_code if invoice_name: self.dict['invoice_name'] = invoice_name else: self.dict['invoice_name'] = company_name self.dict[ 'last_invoice'] = -1 #Latest invoice number. Starts at -1 on creation (never invoiced with this project). self.dict['rates'] = [ ] # List of all rates. Added to when creating a new Rate object. project_dict[project_name] = self.dict print(self.dict) json_dump( project_dict, 'json/project_dict.json') #Updates the project JSON file.
def get_last_invoice_name(self): company_dict = json_load('json/company_dict.json') project_dict = json_load('json/project_dict.json') project_name = self.dict['project_name'] company_name = project_dict[project_name]['company_name'] invoice_name = company_dict[company_name]['invoice_name'] last_invoice_name = invoice_name + '_JM_Facture_' + str( self.dict['last_invoice']) return (last_invoice_name)
def update_invoice_number(self, invoice_number): company_dict = json_load( 'json/company_dict.json') #Loads the latest company JSON file. company_dict[ self.dict['company_name']]['last_invoice'] = invoice_number json_dump(company_dict, 'json/company_dict.json') #Updates the company JSON file.
def __init__(self, company_name, address='', city='', post_code='', invoice_name=''): company_dict = json_load( 'json/company_dict.json') #Loads the latest general JSON file. if company_name in company_dict: self.dict = company_dict[company_name] else: self.dict = {} self.dict['projects'] = [ ] # List of all projects. Added to when creating a new Project object. self.dict['company_name'] = company_name self.dict['address'] = address self.dict['city'] = city self.dict['post_code'] = post_code self.dict['invoice_name'] = invoice_name self.dict[ 'last_invoice'] = -1 #Latest invoice number. Starts at -1 on creation (never invoiced with this company). company_dict[company_name] = self.dict json_dump( company_dict, 'json/company_dict.json') #Updates the company JSON file.
def update_invoice_number(self, invoice_number): project_dict = json_load( 'json/project_dict.json') #Loads the latest project JSON file. project_dict[ self.dict['project_name']]['last_invoice'] = invoice_number json_dump(project_dict, 'json/project_dict.json') #Updates the project JSON file.
def add_rate(self, dollar_rate, float_bool): new_rate = Rate(self.dict['project_name'], dollar_rate, float_bool) project_dict = json_load( 'json/project_dict.json') #Loads the latest project JSON file. project_dict[self.dict['project_name']]['rates'].append(dollar_rate) json_dump(project_dict, 'json/project_dict.json') #Updates the project JSON file. return new_rate
def __init__(self, project_name, dollar_rate, float_bool): project_dict = json_load('json/project_dict.json') rate_dict = json_load('json/rate_dict.json') if dollar_rate in project_dict[project_name]['rates']: self.dict = rate_dict[project_name + '_' + dollar_rate] else: self.dict = {} self.dict['rate_name'] = dollar_rate #identical to "taux". if float_bool: self.dict['unit_cost'] = float(dollar_rate) else: self.dict['unit_cost'] = int(dollar_rate) self.dict['project_name'] = project_name def get_profession(): def get_input(): number = input( 'Tapez 1 pour du montage ou 2 pour de la traduction.\n' ) if number not in ('1', '2'): print('Entrez invalide, veuillez recommencer') return get_input() else: return number answer = get_input() if answer == '1': return 'MONT' else: return 'TRAD' self.dict['profession'] = get_profession() self.dict[ 'last_invoice'] = -1 #Latest invoice number. Starts at -1 on creation (never invoiced with this project). self.dict['début'] = 'Total: ' self.dict['type'] = input( 'Entrez le type d\'unité. Ex: Forfait, journée, mot...\n' ).lower() self.dict['milieu'] = ' à ' self.dict['taux'] = str(self.dict['unit_cost']) + '$' self.dict['fin'] = ' ' + input( 'Tapez la fin désirée. Ex: par animatique de 27 minutes.\n') rate_dict[project_name + '_' + dollar_rate] = self.dict json_dump(rate_dict, 'json/rate_dict.json') #Updates the rate JSON file.
def update_invoice_number(self, invoice_number): rate_dict = json_load( 'json/rate_dict.json') #Loads the latest rate JSON file. project_name = self.dict['project_name'] dollar_rate = self.dict['rate_name'] rate_dict[project_name + '_' + dollar_rate]['last_invoice'] = invoice_number json_dump(rate_dict, 'json/rate_dict.json') #Updates the project JSON file.
def add_project(self, project_name, invoice_name, invoice_code): new_project = Project(self.dict['company_name'], project_name, invoice_code, invoice_name) company_dict = json_load( 'json/company_dict.json') #Loads the latest company JSON file. company_dict[self.dict['company_name']]['projects'].append( project_name) json_dump(company_dict, 'json/company_dict.json') #Updates the company JSON file. return new_project
def get_project(): print('\r') order_list = {} #temporarily associate project name with printed number count = 1 project_dict = json_load('json/project_dict.json') for project in sorted( project_dict, key=lambda project: project_dict[project]['last_invoice'], reverse=True): #Sort by latest invoice number if project_dict[project]['company_name'] == active_company.dict[ 'company_name']: print(str(count) + '. ' + project) order_list[str(count)] = project count += 1 print('\r') project_input = input( 'Choisissez un projet de la liste ou tapez 0 pour créer un nouveau projet.\n' ) if project_input is "0": # Create new project entry in project_dict.json and return the object name = input('Entrez le nom du projet\n') if name in project_dict.keys(): print('Name already exists, please pick another') return get_project() code = input( 'Entrez un code de facturation pour la comptabilité générale. Ex: AVRP - CHUCK\n' ) invoice = input( 'Entrez le nom de facturation ou laissez blanc pour mettre le nom de compagnie. \n' ) return active_company.add_project(name, invoice, code) else: try: # Create existing project object from project_dict.json and return it int(project_input) return invoice_info.Project(active_company.dict['company_name'], order_list[project_input], invoice_code='') except (ValueError, KeyError): print('Entrée invalide, recommencez SVP.\n') return get_project( ) #Recursively call function until proper input is received
def get_company(): order_list = { } #temporarily associate company name with printed number to access dictionary by number. count = 1 company_dict = json_load('json/company_dict.json') for company in sorted( company_dict, key=lambda company: company_dict[company]['last_invoice'], reverse=True): #Sort by latest invoice number print(str(count) + '. ' + company) #DEBUG TRY -company_dict[company]['company_name']) order_list[str(count)] = company count += 1 print('\r') company_input = input( 'Choisissez une compagnie de la liste ou tapez 0 pour créer une nouvelle compagnie.\n' ) if company_input is "0": # Create new company entry in company_dict.json and return the object name = input('Entrez le nom de la compagnie.\n') invoice_name = input( 'Entrez une abbréviation pour le nom de facture ou laissez blanc pour mettre le nom de compagnie. \n' ) if not invoice_name: invoice_name = name address = input('Entrez le numéro et la rue.\n') city = input('Entrez la ville et la province.\n') post_code = input('Entrez le code postal.\n') return invoice_info.Company(name, address, city, post_code, invoice_name) else: try: # Create company object from existing company info in company_dict.json and return it int(company_input) return invoice_info.Company(order_list[company_input]) except (ValueError, KeyError): print('Entrée invalide, recommencez SVP.\n') return get_company( ) #Recursively calls the function again until proper input is received
def remove_last_rate(self): project_dict = json_load( 'json/project_dict.json') #Loads the latest project JSON file. project_dict[self.dict['project_name']]['rates'].pop() json_dump(project_dict, 'json/project_dict.json') #Updates the project JSON file.
from utilities import value_changes, get_final_row, json_load, json_dump, dollar_to_float """ Used when check received. Checks in general accounting Google Sheets document to see which invoices check was for and marks them as paid. Required Arguments: None. Optional Arguments: Use parameter 'cancel' to restore values modified by previous execution. All other necessary information is input at runtime. """ cancel = False try: if sys.argv[1] == 'cancel': last_change_list = json_load('json/last_change_list.json') for row in last_change_list: set_range('G' + row, [['=FALSE']]) sys.exit(0) except IndexError: pass company_dict = json_load('json/company_dict.json') for company in company_dict: print(company_dict[company]['invoice_name']) #general accounting ID - NOTE: Test version - Change for production general_accounting = '1GhovgewjuCoqJRdN-PrJvXv9Tq9INeKqgBH_s__xi2M' last_invoice_row = str(get_final_row())
from itertools import combinations from oauth2client.service_account import ServiceAccountCredentials from google_methods import update_spreadsheet, get_range, set_range, get_file_id from utilities import value_changes, get_final_row, json_load, json_dump, dollar_to_float """ Lists unpaid invoices by company. Required Arguments: None. Optional Arguments: "add_wip" to add an item to work in progress. "list_wip" to see and-or remove work in progress """ #company_dict = json_load('json/company_dict.json') #for company in company_dict: #print (company_dict[company]['invoice_name']) work_in_progress = json_load('json/work_in_progress.json') try: wip_input = sys.argv[1] if wip_input == 'add_wip': new_wip = input( 'Type description of project to add to work in progress:\n') if new_wip: work_in_progress.append(new_wip) print('Current work in progress:\n') for index, item in enumerate(work_in_progress): print(str(index + 1) + '. ' + item) json_dump(work_in_progress, 'json/work_in_progress.json') sys.exit(0) elif wip_input == 'list_wip': print('Current work in progress:\n')
def get_rate(project): print('\r') order_list = {} #temporarily associate rate name with printed number count = 1 rate_dict = json_load('json/rate_dict.json') for rate in sorted(rate_dict, key=lambda rate: rate_dict[rate]['last_invoice'], reverse=True): #Sort by latest invoice number if rate_dict[rate]['project_name'] == active_project.dict[ 'project_name']: print(str(count) + '. ' + rate_dict[rate]['taux']) order_list[str(count)] = rate_dict[rate]['taux'][:-1] count += 1 print('\r') #print(order_list) rate_input = input( 'Choisissez un taux de la liste ou tapez 0 pour créer un nouveau taux.\n' ) if rate_input is "0": # Create new rate entry in rate_dict.json and return the object dollar_rate = input('Entrez le taux de facturation en dollars.\n') float_bool = False try: int(dollar_rate) except (ValueError): try: dollar_rate = dollar_rate.replace(',', '.') float(dollar_rate) float_bool = True dollar_rate = str(float(dollar_rate)) except (ValueError): print('Entrée invalide. Veuillez recommencer.') return get_rate(project) new_rate = active_project.add_rate(dollar_rate, float_bool) print('Voici la description de ce taux:\n') print(new_rate.rate_sentence(1)) def get_answer( ): #Temporary function to allow recursion if invalid answer. answer = input( 'Tapez Y si vous êtes satisfaits, ou N pour recommencer.\n') if answer.lower() not in ('y', 'n'): print('Entrée invalide. Veuillez recommencer.') return get_answer() else: return answer if get_answer().lower() == 'y': return new_rate else: rate_dict = json_load('json/rate_dict.json') rate_key_name = active_project.dict[ 'project_name'] + '_' + dollar_rate rate_dict.pop(rate_key_name, None) #Remove unwanted new rate from rate_dict. json_dump(rate_dict, 'json/rate_dict.json') #Updates the rate JSON file. project.remove_last_rate() return get_rate(project) else: try: # Create existing rate object from project_dict.json and return it try: int(rate_input) #print('int_' + order_list[rate_input]) return invoice_info.Rate(active_project.dict['project_name'], order_list[rate_input], False) except (ValueError): #print('check_value') float(rate_input) #print('float_' + order_list[rate_input]) return invoice_info.Rate(active_project.dict['project_name'], order_list[rate_input], True) except (ValueError, KeyError): #print('check_key') print('Entrée invalide, recommencez SVP.\n') return get_rate(project)
print('\r') description_date = input( 'Entrez la description du mois où le travail a été effectué, ou laissez vide pour le mois courant.\n' ) if description_date: return description_date else: description_date = get_month(datetime.date.today().month) + ' ' + str( datetime.date.today().year) return description_date active_description_date = get_description_date() invoice_number = int( json_load('json/invoice_number.json') ) # TODO - validate compare to max of company_dict - project_dict - rate_dict title = active_company.dict['invoice_name'] + '_JM_Facture_' + str( invoice_number) date_string = get_date_string( ) #Defaults to current day - add datetime object as parameter to change invo_name = active_project.dict['invoice_name'] invo_code = active_project.dict['invoice_code'] comp_addr = active_company.dict['address'] comp_city = active_company.dict['city'] comp_post_code = active_company.dict['post_code'] unit_quan = float( input('Combien de ' + active_rate.dict['type'] + '(s) voulez-vous facturer?')) desc_cost = active_rate.rate_sentence(unit_quan) unit_cost = active_rate.dict['unit_cost']