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, 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 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 __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 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 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 __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 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.
payable_row = input( "To mark an invoice as paid, please enter the corresponding row. ENTER to exit" ) if payable_row: manual_payment(payable_row) elif len(possibilities) == 1: for row in possibilities[0]: last_change_list.append(row) pay_invoice(row) else: print( 'Different combinations are possible. Please change values manually in Google Sheets or select rows to pay.\n' ) print('The following row combinations are valid:\n') for possibility in enumerate(possibilities, start=1): print("OPTION " + str(possibility[0])) for row in possibility[1]: print("Row :" + str(row)) print_description(row) print('\n') selection = input("Please select an option or RETURN to exit.\n") if selection: rows = possibilities[int(selection) - 1] for row in rows: pay_invoice(row) json_dump(last_change_list, 'json/last_change_list.json') input("Don't forget to deposit check if necessary. Press RETURN to confirm.")
#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') for index, item in enumerate(work_in_progress): print(str(index + 1) + '. ' + item) index = input( 'Do you want to invoice an item now?' + '\n' + 'If so, please type the corresponding number to delete from list' + ' and run new_invoice.py\n' + 'Use argument add_wip to add work in progress\n') if index: try: del work_in_progress[int(index) - 1] json_dump(work_in_progress, 'json/work_in_progress.json') except IndexError:
from utilities import json_dump company_dict = {} project_dict = {} rate_dict = {} invoice_number = "1000" #dict is actually a string - DOESN'T MAKE SENSE json_dump(company_dict, 'json/company_dict.json') json_dump(project_dict, 'json/project_dict.json') json_dump(rate_dict, 'json/rate_dict.json') json_dump(invoice_number, 'json_invoice_dict.json') answer = input('Delete dropbox dicts? Type y to delete') if answer == 'y': json_dump(company_dict, '/Users/jimmy/Dropbox/Accounting_Backup/company_dict.json') json_dump(project_dict, '/Users/jimmy/Dropbox/Accounting_Backup/project_dict.json') json_dump(rate_dict, '/Users/jimmy/Dropbox/Accounting_Backup/rate_dict.json') json_dump(invoice_number, '/Users/jimmy/Dropbox/Accounting_Backup/invoice_dict.json') print('Local and Dropbox dicts deleted') else: print('Local dicts deleted')
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)
total_salary = dollar_to_float(dollar_amounts['values'][3][0]) new_values = [[ title, date_string, base_salary, tax_federal, tax_provincial, total_salary, '=FAUX', prof_type, invo_code ]] set_range(new_range, new_values) #download PDF download_pdf(new_id, '/Users/jimmy/Documents/Factures/' + title) download_pdf(general_accounting, '/Users/jimmy/Documents/Bilans/' + str(invoice_number)) #increment invoice number ONLY AT END WHEN EVERYTHING HAS WORKED active_company.update_invoice_number(invoice_number) active_project.update_invoice_number(invoice_number) active_rate.update_invoice_number(invoice_number) json_dump(str(invoice_number + 1), 'json/invoice_number.json') #Backup all dicts to Dropbox if not in test mode if dropbox: dropbox_backup() print('\nAll dicts backed up to Dropbox.') else: print('\nTest mode enabled, dicts not saved to Dropbox.') #Backup all dicts to directory with date and time - Keep all versions for now backup_dicts()