@@ 250-327 (lines=78) @@ | ||
247 | ||
248 | #################################################################################################################### |
|
249 | current_row_number = 12 |
|
250 | if "subtotals" not in reporting_period_data.keys() or \ |
|
251 | reporting_period_data['subtotals'] is None or \ |
|
252 | len(reporting_period_data['subtotals']) == 0: |
|
253 | pass |
|
254 | else: |
|
255 | ws['B' + str(current_row_number)].font = title_font |
|
256 | ws['B' + str(current_row_number)] = name + ' ' + _('Incomes by Energy Category') |
|
257 | ||
258 | current_row_number += 1 |
|
259 | ||
260 | table_start_row_number = current_row_number |
|
261 | ||
262 | ws['B' + str(current_row_number)].fill = table_fill |
|
263 | ws['B' + str(current_row_number)].font = name_font |
|
264 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
265 | ws['B' + str(current_row_number)].border = f_border |
|
266 | ||
267 | ws['C' + str(current_row_number)].fill = table_fill |
|
268 | ws['C' + str(current_row_number)].font = name_font |
|
269 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
270 | ws['C' + str(current_row_number)].border = f_border |
|
271 | ws['C' + str(current_row_number)] = _('Incomes') |
|
272 | ||
273 | ws['D' + str(current_row_number)].fill = table_fill |
|
274 | ws['D' + str(current_row_number)].font = name_font |
|
275 | ws['D' + str(current_row_number)].alignment = c_c_alignment |
|
276 | ws['D' + str(current_row_number)].border = f_border |
|
277 | ws['D' + str(current_row_number)] = _('Proportion') |
|
278 | ||
279 | current_row_number += 1 |
|
280 | ||
281 | ca_len = len(reporting_period_data['names']) |
|
282 | income_sum = Decimal(0.0) |
|
283 | for i in range(0, ca_len): |
|
284 | income_sum = round(reporting_period_data['subtotals'][i], 2) + income_sum |
|
285 | for i in range(0, ca_len): |
|
286 | ws['B' + str(current_row_number)].font = title_font |
|
287 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
288 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
289 | ws['B' + str(current_row_number)].border = f_border |
|
290 | ||
291 | ws['C' + str(current_row_number)].font = title_font |
|
292 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
293 | ws['C' + str(current_row_number)].border = f_border |
|
294 | ws['C' + str(current_row_number)] = round2(reporting_period_data['subtotals'][i], 2) |
|
295 | ||
296 | ws['D' + str(current_row_number)].font = title_font |
|
297 | ws['D' + str(current_row_number)].alignment = c_c_alignment |
|
298 | ws['D' + str(current_row_number)].border = f_border |
|
299 | ws['D' + str(current_row_number)] = '{:.2%}'.format(round2( |
|
300 | reporting_period_data['subtotals'][i], 2) / income_sum) \ |
|
301 | if income_sum is not None and income_sum != Decimal(0.0) \ |
|
302 | else '' |
|
303 | ||
304 | current_row_number += 1 |
|
305 | ||
306 | table_end_row_number = current_row_number - 1 |
|
307 | ||
308 | pie = PieChart() |
|
309 | pie.title = name + ' ' + _('Incomes by Energy Category') |
|
310 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
311 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
312 | pie.add_data(pie_data, titles_from_data=True) |
|
313 | pie.set_categories(labels) |
|
314 | pie.height = 6.6 |
|
315 | pie.width = 9 |
|
316 | s1 = pie.series[0] |
|
317 | s1.dLbls = DataLabelList() |
|
318 | s1.dLbls.showCatName = False |
|
319 | s1.dLbls.showVal = False |
|
320 | s1.dLbls.showPercent = True |
|
321 | table_cell = 'D' + str(table_start_row_number) |
|
322 | ws.add_chart(pie, table_cell) |
|
323 | ||
324 | if ca_len < 4: |
|
325 | current_row_number = current_row_number - ca_len + 4 |
|
326 | ||
327 | current_row_number += 1 |
|
328 | #################################################################################################################### |
|
329 | table_start_draw_flag = current_row_number + 1 |
|
330 |
@@ 256-332 (lines=77) @@ | ||
253 | ||
254 | #################################################################################################################### |
|
255 | current_row_number = 12 |
|
256 | if "subtotals" not in reporting_period_data.keys() or \ |
|
257 | reporting_period_data['subtotals'] is None or \ |
|
258 | len(reporting_period_data['subtotals']) == 0: |
|
259 | pass |
|
260 | else: |
|
261 | ws['B' + str(current_row_number)].font = title_font |
|
262 | ws['B' + str(current_row_number)] = name + ' ' + _('Incomes by Energy Category') |
|
263 | ||
264 | current_row_number += 1 |
|
265 | ||
266 | table_start_row_number = current_row_number |
|
267 | ||
268 | ws['B' + str(current_row_number)].fill = table_fill |
|
269 | ws['B' + str(current_row_number)].font = name_font |
|
270 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
271 | ws['B' + str(current_row_number)].border = f_border |
|
272 | ||
273 | ws['C' + str(current_row_number)].fill = table_fill |
|
274 | ws['C' + str(current_row_number)].font = name_font |
|
275 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
276 | ws['C' + str(current_row_number)].border = f_border |
|
277 | ws['C' + str(current_row_number)] = _('Incomes') |
|
278 | ||
279 | ws['D' + str(current_row_number)].fill = table_fill |
|
280 | ws['D' + str(current_row_number)].font = name_font |
|
281 | ws['D' + str(current_row_number)].alignment = c_c_alignment |
|
282 | ws['D' + str(current_row_number)].border = f_border |
|
283 | ws['D' + str(current_row_number)] = _('Proportion') |
|
284 | ||
285 | current_row_number += 1 |
|
286 | ||
287 | ca_len = len(reporting_period_data['names']) |
|
288 | income_sum = Decimal(0.0) |
|
289 | for i in range(0, ca_len): |
|
290 | income_sum = round(reporting_period_data['subtotals'][i], 2) + income_sum |
|
291 | for i in range(0, ca_len): |
|
292 | ws['B' + str(current_row_number)].font = title_font |
|
293 | ws['B' + str(current_row_number)].alignment = c_c_alignment |
|
294 | ws['B' + str(current_row_number)] = reporting_period_data['names'][i] |
|
295 | ws['B' + str(current_row_number)].border = f_border |
|
296 | ||
297 | ws['C' + str(current_row_number)].font = title_font |
|
298 | ws['C' + str(current_row_number)].alignment = c_c_alignment |
|
299 | ws['C' + str(current_row_number)].border = f_border |
|
300 | ws['C' + str(current_row_number)] = round2(reporting_period_data['subtotals'][i], 2) |
|
301 | ||
302 | ws['D' + str(current_row_number)].font = title_font |
|
303 | ws['D' + str(current_row_number)].alignment = c_c_alignment |
|
304 | ws['D' + str(current_row_number)].border = f_border |
|
305 | ws['D' + str(current_row_number)] = '{:.2%}'.format(round2( |
|
306 | reporting_period_data['subtotals'][i], 2) / income_sum) if income_sum is not None and \ |
|
307 | income_sum != Decimal(0.0) else " " |
|
308 | ||
309 | current_row_number += 1 |
|
310 | ||
311 | table_end_row_number = current_row_number - 1 |
|
312 | ||
313 | pie = PieChart() |
|
314 | pie.title = name + ' ' + _('Incomes by Energy Category') |
|
315 | labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number) |
|
316 | pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number) |
|
317 | pie.add_data(pie_data, titles_from_data=True) |
|
318 | pie.set_categories(labels) |
|
319 | pie.height = 6.6 |
|
320 | pie.width = 9 |
|
321 | s1 = pie.series[0] |
|
322 | s1.dLbls = DataLabelList() |
|
323 | s1.dLbls.showCatName = False |
|
324 | s1.dLbls.showVal = False |
|
325 | s1.dLbls.showPercent = True |
|
326 | table_cell = 'E' + str(table_start_row_number) |
|
327 | ws.add_chart(pie, table_cell) |
|
328 | ||
329 | if ca_len < 4: |
|
330 | current_row_number = current_row_number - ca_len + 4 |
|
331 | ||
332 | current_row_number += 1 |
|
333 | ||
334 | #################################################################################################################### |
|
335 | table_start_draw_flag = current_row_number + 1 |