def add_statistics_worksheet(self, teams_list, timesheet_date, man_days_hours): TimesheetLogger().log_on_console("*" * 50) TimesheetLogger().log_on_console("Creating statistics worksheet.") statistics_worksheet = self._workbook.add_worksheet( self._statistics_worksheet_name) self._statistics_worksheet.prepare_statistics_worksheet( statistics_worksheet, teams_list, timesheet_date, man_days_hours)
def create_timesheets(self): TimesheetLogger().log_on_console("Started creating timesheets set.") reports_set_folder = self._names_generator.generate_timesheets_set_folder_name( ) for project in self._timesheet_report_configuration['timesheets']: self.create_timesheet( self._timesheet_report_configuration['timesheets'][project], reports_set_folder, project) TimesheetLogger().log_on_console("Timesheets set created.")
def add_summary_worksheet(self, teams_list, timesheet_date, national_holidays_days_list, po_number, man_days_costs): TimesheetLogger().log_on_console("*" * 50) TimesheetLogger().log_on_console("Creating summary worksheet.") summary_worksheet = self._workbook.add_worksheet( self._summary_worksheet_name) self._summary_worksheet.prepare_summary_worksheet( summary_worksheet, teams_list, timesheet_date, national_holidays_days_list, po_number, man_days_costs)
def _add_employee_worksheet(self, employee, timesheet_date, man_days_hours): employee_jira_name = employee.get_emplyee_jira_name() TimesheetLogger().log_on_console("*" * 50) TimesheetLogger().log_on_console( "Creating worksheet for employee: {}.".format(employee_jira_name)) employee_name = employee.get_employee_name() employee_timesheet_issues = employee.get_employee_timesheet_issues() employee_worksheet = self._workbook.add_worksheet(employee_name) employee_worklog_data = employee.get_employee_timesheet_worklog_data() self._employee_worksheet.prepare_worksheet_for_employee( employee_worksheet, employee_timesheet_issues, employee_worklog_data, timesheet_date, man_days_hours)
def get_timesheet_data_for_employee(self, employee_jira_name): TimesheetLogger().log_on_console("Getting employee: {}, timesheet data.".format(employee_jira_name)) timesheet_year = Date().get_timesheet_year(self._timesheet_date['year']) params = self._jira_rest.prepare_search_parameters_for_timesheet_data( employee_jira_name, timesheet_year, self._timesheet_date['month']) response = self._jira_rest.search_for_data(params) return response.json()
def get_timesheet_worklog_data(self, employee_timesheet_issues, employee_jira_name): TimesheetLogger().log_on_console("Getting employee: {}, worklog data.".format(employee_jira_name)) employee_worklog_data = dict() for issue in employee_timesheet_issues: issue_key = issue['key'] issue_id = issue['issue_id'] response = self._jira_rest.get_issue_worklog(issue_id) employee_worklog_data[issue_key] = list() issue_worklog_data = self._employee_jira_data_parser.parse_employe_worklog_data_2( employee_worklog_data[issue_key], employee_jira_name, response.json()) employee_worklog_data[issue_key] = issue_worklog_data return employee_worklog_data
def create_timesheet(self, project_configuration, reports_set_folder, timesheet_name_prefix): TimesheetLogger().log_on_console("=" * 50) TimesheetLogger().log_on_console( "Started creating timesheet: {}.".format(timesheet_name_prefix)) report_name = self._names_generator.generate_report_name( timesheet_name_prefix) if not os.path.exists( os.path.join(self._timesheet_reports_folder, reports_set_folder)): os.makedirs( os.path.join(self._timesheet_reports_folder, reports_set_folder)) workbook = xlsxwriter.Workbook( os.path.join(self._timesheet_reports_folder, reports_set_folder, report_name)) timesheet = Timesheet(workbook) self._project_teams_builder.clean_teams_container() self._teams_container = self._project_teams_builder.build_project_team( project_configuration['teams'], self._timesheet_data) teams_list = self._teams_container.get_teams_list() timesheet.add_summary_worksheet( teams_list, self._timesheet_date, self._national_holidays_list, project_configuration['po_number'], project_configuration['man_days_costs']) timesheet.add_statistics_worksheet( teams_list, self._timesheet_date, project_configuration['man_day_hours']) timesheet.add_worksheets_for_employees( teams_list, self._timesheet_date, project_configuration['man_day_hours']) timesheet.save_timesheet() TimesheetLogger().log_on_console("*" * 50) TimesheetLogger().log_on_console( "Timesheet: {} created.".format(timesheet_name_prefix)) TimesheetLogger().log_on_console("=" * 50)
def get_employee_display_name(self, employee_jira_name): TimesheetLogger().log_on_console("Getting employee: {}, display name.".format(employee_jira_name)) params = self._jira_rest.perapare_params_for_user_rest(employee_jira_name) response = self._jira_rest.get_user_data(params) employee_display_name = response.json()['displayName'] return employee_display_name