Ejemplo n.º 1
0
 def edit_billable_time(self, job):
     print("Estimated Time: " + job['estimated_time'])
     print("Actual Time: " + job['actual_time'])
     billable_time = input("Billable Time: ")
     self.repository.update_billable_time(job['id'], billable_time)
     self.repository.save()
     self.repository.check_rows_updated('Job Updated')
     Menu.wait_for_input()
Ejemplo n.º 2
0
 def log_time(self, job_id):
     logged_time = ''
     while not Validation.isFloat(logged_time):
         logged_time = input('Log Time: ')
     self.repository.update_actual_time(job_id, logged_time)
     self.repository.save()
     self.repository.check_rows_updated('Job Updated')
     Menu.wait_for_input()
Ejemplo n.º 3
0
 def add(self):
     print(Style.create_title('Add %s' % self.table_name))
     data = self.input_add_data()
     self.validate_model_data(data['own'])
     if self.model.is_valid():
         self.save_data(data)
     else:
         self.display_errors('%s not added' % self.table_name)
     Menu.wait_for_input()
Ejemplo n.º 4
0
 def update_status(self, job_id):
     statusRepository = StatusRepository()
     paginated_menu = Pagination(statusRepository)
     status = paginated_menu(find=statusRepository.find_paginated,
                             find_by_id=statusRepository.find_by_id)
     self.repository.update(job_id, {
         'status_id': status['id'],
     })
     self.repository.save()
     self.repository.check_rows_updated('Status Updated')
     Menu.wait_for_input()
Ejemplo n.º 5
0
 def generate(self):
     print(Style.create_title('Generate Invoice'))
     invoice = self.make_paginated_menu()
     if invoice:
         jobRepository = JobRepository()
         jobs = jobRepository.find_jobs_by_invoice_id(invoice['id'])
         self.enter_billable_time(jobRepository, jobs)
         jobs = jobRepository.find_jobs_by_invoice_id(invoice['id'])
         invoice_data = self.make_invoice_dictionary(invoice, jobs)
         LatexInvoice().generate(**invoice_data)
         self.mark_invoiced_jobs_as_complete(jobRepository, jobs)
         Menu.wait_for_input()
Ejemplo n.º 6
0
 def edit(self):
     print(Style.create_title('Edit %s' % self.table_name))
     item = self.make_paginated_menu()
     if item:
         data = self.input_edit_data(item)
         data['own'] = self.validate_model_data(data['own'])
         if self.model.is_valid:
             self.save_update(data, item)
         else:
             self.display_errors('%s not updated' % self.table_name)
     else:
         print('No changes made')
     Menu.wait_for_input()
Ejemplo n.º 7
0
 def delete(self):
     print(Style.create_title('Delete %s' % self.table_name))
     item = self.make_paginated_menu()
     if item:
         user_action = False
         while not user_action == 'delete':
             user_action = input(
                 'Type \'%s\' to remove this item or %s to cancel: ' %
                 (Colour.red('delete'), Colour.green('c')))
             if user_action == 'c':
                 return
         self.save_remove(item)
         Menu.wait_for_input()
Ejemplo n.º 8
0
 def menu(self):
     result = False
     while not result:
         self.paginated_table()
         self.pagination_text()
         user_input = input('\nEnter an %s, use %s and %s to navigate, or %s to go back: ' % (
             Colour.green("'id'"),
             Colour.green("<"),
             Colour.green(">"),
             Colour.green("b")
         ))
         if (user_input == 'b'):
             break
         if self.should_change_page(user_input):
             self.change_page(user_input)
             continue
         if not Validation.is_number(user_input):
             print('Command not recognised')
             continue
         result = self.find_by_id(user_input)
         if not result:
             Menu.wait_for_input('An item with that ID was not found. Press any key to continue.')
     return result