From f38d7e3691ae1d0e1cd061dc9cc6e9ab57dbc5ea Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Tue, 23 Mar 2021 15:20:32 +0800 Subject: [PATCH] fixed NoneType issue in SpaceEfficiency Report API --- myems-api/reports/spaceefficiency.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/myems-api/reports/spaceefficiency.py b/myems-api/reports/spaceefficiency.py index b39314e6..afdd3e2f 100644 --- a/myems-api/reports/spaceefficiency.py +++ b/myems-api/reports/spaceefficiency.py @@ -652,7 +652,7 @@ class Reporting: (reporting_input[energy_category_id]['subtotal'] - base_input[energy_category_id]['subtotal']) / base_input[energy_category_id]['subtotal'] - if base_input[energy_category_id]['subtotal'] > 0.0 else None) + if base_input[energy_category_id]['subtotal'] > Decimal(0.0) else None) result['reporting_period_output'] = dict() result['reporting_period_output']['names'] = list() @@ -717,7 +717,10 @@ class Reporting: result['reporting_period_efficiency']['cumulations'].append(reporting_cumulation) result['reporting_period_efficiency']['increment_rates'].append( - ((reporting_cumulation - base_cumulation) / base_cumulation if (base_cumulation > Decimal(0.0)) + ((reporting_cumulation - base_cumulation) / base_cumulation + if (reporting_cumulation is not None and + base_cumulation is not None and + base_cumulation > Decimal(0.0)) else None) )