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