def handle(self, *args, **options):
     excel = ProjectAdminExcel()
     filename = filename_with_datetime(
         TEST_OUTPUT_PATH, '%s_supports.xlsx' % (options['fiscal_year']))
     supports = ProjectSupport.objects.all()
     excel.export_supports(filename, supports)
     self.stdout.write('Wrote %s' % filename)
Example #2
0
    def handle(self, *args, **options):

        if options['load_time']:
            extension = os.path.splitext(options['filename'])[1]
            if extension == '.xlsx' or extension == '.xls':
                excel_data = MaximoExcelData(stdout=self.stdout)
                results = excel_data.load(options['filename'],
                                          action=MaximoExcelData.LOAD_TIME)
                self.stdout.write('Parsed: %s' % options['filename'])
                self.stdout.write('Created Registers: %d of %d' %
                                  (results['time_results']['created'],
                                   results['time_results']['rows_parsed']))
            elif extension == '.csv':
                excel_data = MaximoCSVData(stdout=self.stdout)
                results = excel_data.load_time_registers(options['filename'])
                self.stdout.write('Parsed: %s' % options['filename'])
                self.stdout.write('Created Registers: %d of %d' %
                                  (results['created'], results['rows_parsed']))
        elif options['export_time']:
            excel_data = MaximoExcelData(stdout=self.stdout)
            registers = MaximoTimeRegister.objects.all()
            if options['filename']:
                filename = options['filename']
            else:
                filename = filename_with_datetime(
                    TEST_OUTPUT_PATH, 'Export_Times_%s.xlsx' % ('TINO'))
            excel_data.export_time_registers(filename, registers)
            self.stdout.write('Wrote: %s' % filename)
        elif options['update_projects']:
            self.update_projects()
Example #3
0
    def handle(self, *args, **options):

        if options['load_time']:
            extension = os.path.splitext(options['filename'])[1]
            if extension == '.xlsx' or extension == '.xls':
                excel_data = MaximoExcelData(stdout=self.stdout)
                results = excel_data.load(options['filename'], action=MaximoExcelData.LOAD_TIME)
                self.stdout.write('Parsed: %s' % options['filename'])
                self.stdout.write('Created Registers: %d of %d' % (results['time_results']['created'], results['time_results']['rows_parsed']))
            elif extension == '.csv':
                excel_data = MaximoCSVData(stdout=self.stdout)
                results = excel_data.load_time_registers(options['filename'])
                self.stdout.write('Parsed: %s' % options['filename'])
                self.stdout.write('Created Registers: %d of %d' % (results['created'], results['rows_parsed']))
        elif options['export_time']:
            excel_data = MaximoExcelData(stdout=self.stdout)
            registers = MaximoTimeRegister.objects.all()
            if options['filename']:
                filename = options['filename']
            else:
                filename = filename_with_datetime(TEST_OUTPUT_PATH, 'Export_Times_%s.xlsx' % ('TINO'))
            excel_data.export_time_registers(filename, registers)
            self.stdout.write('Wrote: %s' % filename)
        elif options['update_projects']:
            self.update_projects()
Example #4
0
 def test_export(self):
     excel = ProjectAdminExcel()
     filename = filename_with_datetime(TEST_OUTPUT_PATH,'support_export.xlsx')
     supports = ProjectSupportFactory.create_batch(20)
     excel.export_supports(filename, supports)
     self.assertTrue(os.path.exists(filename))
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
Example #5
0
 def test_export(self):
     excel = ProjectAdminExcel()
     filename = filename_with_datetime(TEST_OUTPUT_PATH,
                                       'support_export.xlsx')
     supports = ProjectSupportFactory.create_batch(20)
     excel.export_supports(filename, supports)
     self.assertTrue(os.path.exists(filename))
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
Example #6
0
 def test_export_time_registers(self):
     filename = filename_with_datetime(TEST_OUTPUT_PATH,'maximo_time_data_export.xlsx')
     #os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % ('maximo_time_data_export', timezone.now().strftime('%Y%m%d_%H%M')))
     excel_data = MaximoExcelData()
     self.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     registers = MaximoTimeRegister.objects.all()
     excel_data.export_time_registers(filename, registers)
     self.assertTrue(os.path.exists(filename))
     logger.debug('Wrote: %s' % filename)
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
Example #7
0
 def test_export_time_registers(self):
     filename = filename_with_datetime(TEST_OUTPUT_PATH,
                                       'maximo_time_data_export.xlsx')
     #os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % ('maximo_time_data_export', timezone.now().strftime('%Y%m%d_%H%M')))
     excel_data = MaximoExcelData()
     self.create_time_registers(date(2015, 9, 1), date(2015, 9, 30))
     registers = MaximoTimeRegister.objects.all()
     excel_data.export_time_registers(filename, registers)
     self.assertTrue(os.path.exists(filename))
     logger.debug('Wrote: %s' % filename)
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
    def handle(self, *args, **options):
        self.stdout.write('filename: %s' % options['filename'])
        if options['filename']:
            filename = options['filename']
        else:
            name = options['number'].replace('.', '-')
            filename = filename_with_datetime(TEST_OUTPUT_PATH, 'Certificate_Results_%s.xlsx' % (name))

        excel = ExcelCertificateResults()
        certificate = ElegibilityCertificate.objects.get(number=options['number'])
        excel.export(filename, certificate)
        self.stdout.write('Wrote %s' % filename)
Example #9
0
 def test_write_tickets(self):
     filename = filename_with_datetime(TEST_OUTPUT_PATH,'maximo_tickets.xlsx')
     #os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % ('maximo_tickets', timezone.now().strftime('%Y%m%d_%H%M')))
     excel_data = MaximoExcelData()
     tickets = MaximoTicketFactory.create_batch(10)
     excel_data.save_tickets(filename, tickets)
     self.assertTrue(os.path.exists(filename))
     row_data, row_count = TestExcel.get_list_from_workbook(filename, excel_data.ticket_sheet)
     self.assertEqual(row_count, 10)
     self.assertEqual(3, len(row_data[0]))
     logger.debug('Wrote: %s' % filename)
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
    def handle(self, *args, **options):
        self.stdout.write('filename: %s' % options['filename'])
        if options['filename']:
            filename = options['filename']
        else:
            name = options['number'].replace('.', '-')
            filename = filename_with_datetime(
                TEST_OUTPUT_PATH, 'Certificate_Results_%s.xlsx' % (name))

        excel = ExcelCertificateResults()
        certificate = ElegibilityCertificate.objects.get(
            number=options['number'])
        excel.export(filename, certificate)
        self.stdout.write('Wrote %s' % filename)
Example #11
0
 def test_write_tickets(self):
     filename = filename_with_datetime(TEST_OUTPUT_PATH,
                                       'maximo_tickets.xlsx')
     #os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % ('maximo_tickets', timezone.now().strftime('%Y%m%d_%H%M')))
     excel_data = MaximoExcelData()
     tickets = MaximoTicketFactory.create_batch(10)
     excel_data.save_tickets(filename, tickets)
     self.assertTrue(os.path.exists(filename))
     row_data, row_count = TestExcel.get_list_from_workbook(
         filename, excel_data.ticket_sheet)
     self.assertEqual(row_count, 10)
     self.assertEqual(3, len(row_data[0]))
     logger.debug('Wrote: %s' % filename)
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
    def handle(self, *args, **options):
        from maximo.models import MaximoTimeRegister

        company_group = options["company_group"]
        self.stdout.write("company_group: %s" % company_group)
        filename = filename_with_datetime(TEST_OUTPUT_PATH, "Export_Employees_%s.xlsx" % (company_group))
        employees = Employee.objects.from_group(company_group)
        wb = Workbook()
        sheet = wb.create_sheet(title="Employees")
        row = 1
        headers = [
            "Company Id",
            "Username",
            "Grade",
            "Position Owner",
            "Position Number",
            "Position Tenure",
            "Pay Rate",
        ]
        column = 1
        for header in headers:
            sheet.cell(column=column, row=row, value=header)
            column += 1
        for employee in employees:
            row += 1
            column = 1
            sheet.cell(column=column, row=row, value=employee.company_id)
            column += 1
            sheet.cell(column=column, row=row, value=employee.user.username)
            column += 1
            sheet.cell(column=column, row=row, value=employee.position.grade)
            column += 1
            if employee.position.owner:
                sheet.cell(column=column, row=row, value=employee.position.owner.user.username)
            else:
                sheet.cell(column=column, row=row, value="NA")
            column += 1
            sheet.cell(column=column, row=row, value=employee.position.number)
            column += 1
            sheet.cell(column=column, row=row, value=employee.position.type)
            ticket = MaximoTimeRegister.objects.filter(employee=employee).order_by("date")[1:]
            column += 1
            sheet.cell(column=column, row=row, value=ticket[0].pay_rate)
        wb.save(filename)
        self.stdout.write("File export %s" % filename)
 def handle(self, *args, **options):
     from maximo.models import MaximoTimeRegister
     company_group = options['company_group']
     self.stdout.write('company_group: %s' % company_group)
     filename = filename_with_datetime(
         TEST_OUTPUT_PATH, 'Export_Employees_%s.xlsx' % (company_group))
     employees = Employee.objects.from_group(company_group)
     wb = Workbook()
     sheet = wb.create_sheet(title='Employees')
     row = 1
     headers = [
         'Company Id', 'Username', 'Grade', 'Position Owner',
         'Position Number', 'Position Tenure', 'Pay Rate'
     ]
     column = 1
     for header in headers:
         sheet.cell(column=column, row=row, value=header)
         column += 1
     for employee in employees:
         row += 1
         column = 1
         sheet.cell(column=column, row=row, value=employee.company_id)
         column += 1
         sheet.cell(column=column, row=row, value=employee.user.username)
         column += 1
         sheet.cell(column=column, row=row, value=employee.position.grade)
         column += 1
         if employee.position.owner:
             sheet.cell(column=column,
                        row=row,
                        value=employee.position.owner.user.username)
         else:
             sheet.cell(column=column, row=row, value='NA')
         column += 1
         sheet.cell(column=column, row=row, value=employee.position.number)
         column += 1
         sheet.cell(column=column, row=row, value=employee.position.type)
         ticket = MaximoTimeRegister.objects.filter(
             employee=employee).order_by('date')[1:]
         column += 1
         sheet.cell(column=column, row=row, value=ticket[0].pay_rate)
     wb.save(filename)
     self.stdout.write('File export %s' % filename)
 def handle(self, *args, **options):
     excel = ProjectAdminExcel()
     filename = filename_with_datetime(TEST_OUTPUT_PATH, '%s_supports.xlsx' % (options['fiscal_year']))
     supports = ProjectSupport.objects.all()
     excel.export_supports(filename, supports)
     self.stdout.write('Wrote %s' % filename)
Example #15
0
    def handle(self, *args, **options):
        group = CompanyGroup.objects.get(name=options['group'])
        employees = group.members()
        filename = filename_with_datetime(TEST_OUTPUT_PATH, 'Individual_Goals_%s.xlsx' % (options['group']))
        #os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % (options['group'], timezone.now().strftime('%Y%m%d_%H%M')))
        wb = Workbook()
        goals = IndividualGoal.objects.filter(employee__in=employees).order_by('employee', 'priority')
        pos = 1
        current_username = None
        headers = ['No', 'Meta', 'DescripciĆ³n', 'Totalmente Satifactorio', 'Peso', 'Entregables']
        for goal in goals:
            if goal.employee.user.username != current_username:
                current_username = goal.employee.user.username
                pos = 1
                sheet = wb.create_sheet(title=current_username)
                sheet['A1'] = '%s  IP: %s' % (goal.employee, goal.employee.company_id)
                self._title_font(sheet['A1'])
                col = 1
                for title in headers:
                    cell = sheet.cell(column=col, row=3, value=title)
                    cell.border = self.border
                    cell.alignment = self.alignment
                    self._format_header(cell)
                    col += 1
                row = 4
            ## No Proyecto A
            col = 1
            cell = sheet.cell(column=col, row=row, value=pos)
            cell.border = self.border
            cell.alignment = Alignment(horizontal='center', vertical='center')
            ## Proyecto B
            col += 1
            cell = sheet.cell(column=col, row=row, value=str(goal.name))
            cell.border = self.border
            self._wrap_cell(cell)
            ## Description C
            col += 1
            cell = sheet.cell(column=col, row=row, value=str(goal.description))
            self._wrap_cell(cell)
            cell.border = self.border
            ## Satifactory D
            col += 1
            cell = sheet.cell(column=col, row=row, value=goal.expectations)
            self._wrap_cell(cell)
            cell.border = self.border
            ## Weight E
            col += 1
            cell = sheet.cell(column=col, row=row, value=goal.weight)
            cell.number_format = '0%'
            cell.alignment = Alignment(horizontal='general', vertical='top')
            cell.border = self.border
            ## Deliverbales F
            col += 1
            deliverables = ''
            if goal.project:
                for deliverable in goal.project.deliverables.all():
                    deliverables += deliverable.name
                    deliverables += '\n'
            else:
                deliverables = 'No Aplica'
            cell = sheet.cell(column=col, row=row, value=deliverables)
            self._wrap_cell(cell)
            cell.border = self.border

            row += 1

            self._set_column_widths(sheet)
            self._page_setup(sheet)
            print('%d %-50s %s' % (pos, goal.name, goal.employee))
            pos += 1

        wb.save(filename)
        self.stdout.write('Wrote %s'  % filename)
Example #16
0
    def handle(self, *args, **options):
        group = CompanyGroup.objects.get(name=options['group'])
        employees = group.members()
        filename = filename_with_datetime(
            TEST_OUTPUT_PATH, 'Individual_Goals_%s.xlsx' % (options['group']))
        #os.path.join(TEST_OUTPUT_PATH, '%s_%s.xlsx' % (options['group'], timezone.now().strftime('%Y%m%d_%H%M')))
        wb = Workbook()
        goals = IndividualGoal.objects.filter(employee__in=employees).order_by(
            'employee', 'priority')
        pos = 1
        current_username = None
        headers = [
            'No', 'Meta', 'DescripciĆ³n', 'Totalmente Satifactorio', 'Peso',
            'Entregables'
        ]
        for goal in goals:
            if goal.employee.user.username != current_username:
                current_username = goal.employee.user.username
                pos = 1
                sheet = wb.create_sheet(title=current_username)
                sheet['A1'] = '%s  IP: %s' % (goal.employee,
                                              goal.employee.company_id)
                self._title_font(sheet['A1'])
                col = 1
                for title in headers:
                    cell = sheet.cell(column=col, row=3, value=title)
                    cell.border = self.border
                    cell.alignment = self.alignment
                    self._format_header(cell)
                    col += 1
                row = 4
            ## No Proyecto A
            col = 1
            cell = sheet.cell(column=col, row=row, value=pos)
            cell.border = self.border
            cell.alignment = Alignment(horizontal='center', vertical='center')
            ## Proyecto B
            col += 1
            cell = sheet.cell(column=col, row=row, value=str(goal.name))
            cell.border = self.border
            self._wrap_cell(cell)
            ## Description C
            col += 1
            cell = sheet.cell(column=col, row=row, value=str(goal.description))
            self._wrap_cell(cell)
            cell.border = self.border
            ## Satifactory D
            col += 1
            cell = sheet.cell(column=col, row=row, value=goal.expectations)
            self._wrap_cell(cell)
            cell.border = self.border
            ## Weight E
            col += 1
            cell = sheet.cell(column=col, row=row, value=goal.weight)
            cell.number_format = '0%'
            cell.alignment = Alignment(horizontal='general', vertical='top')
            cell.border = self.border
            ## Deliverbales F
            col += 1
            deliverables = ''
            if goal.project:
                for deliverable in goal.project.deliverables.all():
                    deliverables += deliverable.name
                    deliverables += '\n'
            else:
                deliverables = 'No Aplica'
            cell = sheet.cell(column=col, row=row, value=deliverables)
            self._wrap_cell(cell)
            cell.border = self.border

            row += 1

            self._set_column_widths(sheet)
            self._page_setup(sheet)
            print('%d %-50s %s' % (pos, goal.name, goal.employee))
            pos += 1

        wb.save(filename)
        self.stdout.write('Wrote %s' % filename)