Code Duplication    Length = 66-66 lines in 2 locations

myems-api/excelexporters/equipmentoutput.py 1 location

@@ 191-256 (lines=66) @@
188
189
    current_row_number = 7
190
    reporting_period_data = report['reporting_period']
191
    if "names" not in reporting_period_data.keys() or \
192
            reporting_period_data['names'] is None or \
193
            len(reporting_period_data['names']) == 0:
194
        pass
195
    else:
196
        ws['B' + str(current_row_number)].font = title_font
197
        ws['B' + str(current_row_number)] = name + ' ' + _('Reporting Period Output')
198
199
        current_row_number += 1
200
201
        category = reporting_period_data['names']
202
        ca_len = len(category)
203
204
        ws.row_dimensions[current_row_number].height = 60
205
        ws['B' + str(current_row_number)].fill = table_fill
206
        ws['B' + str(current_row_number)].border = f_border
207
208
        col = 'C'
209
210
        for i in range(0, ca_len):
211
            ws[col + str(current_row_number)].fill = table_fill
212
            ws[col + str(current_row_number)].font = name_font
213
            ws[col + str(current_row_number)].alignment = c_c_alignment
214
            ws[col + str(current_row_number)].border = f_border
215
            ws[col + str(current_row_number)] = \
216
                reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")"
217
218
            col = chr(ord(col) + 1)
219
220
        current_row_number += 1
221
222
        ws['B' + str(current_row_number)].font = title_font
223
        ws['B' + str(current_row_number)].alignment = c_c_alignment
224
        ws['B' + str(current_row_number)].border = f_border
225
        ws['B' + str(current_row_number)] = _('Output')
226
227
        col = 'C'
228
229
        for i in range(0, ca_len):
230
            ws[col + str(current_row_number)].font = name_font
231
            ws[col + str(current_row_number)].alignment = c_c_alignment
232
            ws[col + str(current_row_number)].border = f_border
233
            ws[col + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2)
234
235
            col = chr(ord(col) + 1)
236
237
        current_row_number += 1
238
239
        ws['B' + str(current_row_number)].font = title_font
240
        ws['B' + str(current_row_number)].alignment = c_c_alignment
241
        ws['B' + str(current_row_number)].border = f_border
242
        ws['B' + str(current_row_number)] = _('Increment Rate')
243
244
        col = 'C'
245
246
        for i in range(0, ca_len):
247
            ws[col + str(current_row_number)].font = name_font
248
            ws[col + str(current_row_number)].alignment = c_c_alignment
249
            ws[col + str(current_row_number)].border = f_border
250
            ws[col + str(current_row_number)] = str(
251
                round(reporting_period_data['increment_rates'][i] * 100, 2)) + '%' \
252
                if reporting_period_data['increment_rates'][i] is not None else '-'
253
254
            col = chr(ord(col) + 1)
255
256
        current_row_number += 2
257
258
    ####################################################################################################################
259
    table_start_draw_flag = current_row_number + 1

myems-api/excelexporters/combinedequipmentoutput.py 1 location

@@ 198-263 (lines=66) @@
195
196
    reporting_period_data = report['reporting_period']
197
198
    if "names" not in reporting_period_data.keys() or \
199
            reporting_period_data['names'] is None or \
200
            len(reporting_period_data['names']) == 0:
201
        pass
202
    else:
203
        ws['B' + str(current_row_number)].font = title_font
204
        ws['B' + str(current_row_number)] = name + ' ' + _('Reporting Period Output')
205
206
        current_row_number += 1
207
208
        category = reporting_period_data['names']
209
        ca_len = len(category)
210
211
        ws.row_dimensions[current_row_number].height = 60
212
        ws['B' + str(current_row_number)].fill = table_fill
213
        ws['B' + str(current_row_number)].border = f_border
214
215
        col = 'C'
216
217
        for i in range(0, ca_len):
218
            ws[col + str(current_row_number)].fill = table_fill
219
            ws[col + str(current_row_number)].font = name_font
220
            ws[col + str(current_row_number)].alignment = c_c_alignment
221
            ws[col + str(current_row_number)].border = f_border
222
            ws[col + str(current_row_number)] = \
223
                reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")"
224
225
            col = chr(ord(col) + 1)
226
227
        current_row_number += 1
228
229
        ws['B' + str(current_row_number)].font = title_font
230
        ws['B' + str(current_row_number)].alignment = c_c_alignment
231
        ws['B' + str(current_row_number)].border = f_border
232
        ws['B' + str(current_row_number)] = _('Output')
233
234
        col = 'C'
235
236
        for i in range(0, ca_len):
237
            ws[col + str(current_row_number)].font = name_font
238
            ws[col + str(current_row_number)].alignment = c_c_alignment
239
            ws[col + str(current_row_number)].border = f_border
240
            ws[col + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2)
241
242
            col = chr(ord(col) + 1)
243
244
        current_row_number += 1
245
246
        ws['B' + str(current_row_number)].font = title_font
247
        ws['B' + str(current_row_number)].alignment = c_c_alignment
248
        ws['B' + str(current_row_number)].border = f_border
249
        ws['B' + str(current_row_number)] = _('Increment Rate')
250
251
        col = 'C'
252
253
        for i in range(0, ca_len):
254
            ws[col + str(current_row_number)].font = name_font
255
            ws[col + str(current_row_number)].alignment = c_c_alignment
256
            ws[col + str(current_row_number)].border = f_border
257
            ws[col + str(current_row_number)] = str(
258
                round(reporting_period_data['increment_rates'][i] * 100, 2)) + '%' \
259
                if reporting_period_data['increment_rates'][i] is not None else '-'
260
261
            col = chr(ord(col) + 1)
262
263
        current_row_number += 2
264
265
    ####################################################################################################################
266
    table_start_draw_flag = current_row_number + 1