fix: list index out of range on incilding uom
This commit is contained in:
parent
2f71927af8
commit
09b8ca0ddb
@ -288,7 +288,6 @@ def update_included_uom_in_report(columns, result, include_uom, conversion_facto
|
|||||||
return
|
return
|
||||||
|
|
||||||
convertible_cols = {}
|
convertible_cols = {}
|
||||||
|
|
||||||
is_dict_obj = False
|
is_dict_obj = False
|
||||||
if isinstance(result[0], dict):
|
if isinstance(result[0], dict):
|
||||||
is_dict_obj = True
|
is_dict_obj = True
|
||||||
@ -310,13 +309,13 @@ def update_included_uom_in_report(columns, result, include_uom, conversion_facto
|
|||||||
for row_idx, row in enumerate(result):
|
for row_idx, row in enumerate(result):
|
||||||
data = row.items() if is_dict_obj else enumerate(row)
|
data = row.items() if is_dict_obj else enumerate(row)
|
||||||
for key, value in data:
|
for key, value in data:
|
||||||
if not key in convertible_columns or not conversion_factors[row_idx]:
|
if key not in convertible_columns or not conversion_factors[row_idx-1]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if convertible_columns.get(key) == 'rate':
|
if convertible_columns.get(key) == 'rate':
|
||||||
new_value = flt(value) * conversion_factors[row_idx]
|
new_value = flt(value) * conversion_factors[row_idx-1]
|
||||||
else:
|
else:
|
||||||
new_value = flt(value) / conversion_factors[row_idx]
|
new_value = flt(value) / conversion_factors[row_idx-1]
|
||||||
|
|
||||||
if not is_dict_obj:
|
if not is_dict_obj:
|
||||||
row.insert(key+1, new_value)
|
row.insert(key+1, new_value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user