Skip to content

Commit

Permalink
fix: fix type convert bug about usage_unit
Browse files Browse the repository at this point in the history
Signed-off-by: ImMin5 <[email protected]>
  • Loading branch information
ImMin5 committed Oct 20, 2023
1 parent 7c68950 commit 490bd0d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/cloudforet/cost_analysis/manager/cost_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _make_data_info(self, result, billed_date, options, tenant_id=None):
cost = self._convert_str_to_float_format(result.get('costinbillingcurrency', 0))
usage_quantity = self._convert_str_to_float_format(result.get('quantity', 0))
usage_type = result.get('metername', '')
usage_unit = result.get('unitofmeasure', '')
usage_unit = str(result.get('unitofmeasure', ''))
region_code = self._get_region_code(result.get('resourcelocation', ''))
product = result.get('metercategory', '')
tags = self._convert_tags_str_to_dict(result.get('tags', {}))
Expand Down Expand Up @@ -130,10 +130,14 @@ def _get_additional_info(self, result, options, tenant_id=None):
if result.get('pricingmodel') == 'OnDemand' and result.get('metercategory') == '':
result['metercategory'] = result.get('metercategory')

if result.get('departmentname') != '' and result.get('departmentname'):
if result.get('invoicesectionname') != '' and result.get('invoicesectionname'):
additional_info['Department Name'] = result.get('invoicesectionname')
elif result.get('departmentname') != '' and result.get('departmentname'):
additional_info['Department Name'] = result['departmentname']

if result.get('enrollmentaccountname') != '' and result.get('enrollmentaccountname'):
if result.get('accountname') != '' and result.get('accountname'):
additional_info['Enrollment Account Name'] = result['accountname']
elif result.get('enrollmentaccountname') != '' and result.get('enrollmentaccountname'):
additional_info['Enrollment Account Name'] = result['enrollmentaccountname']

collect_resource_id = options.get('collect_resource_id', False)
Expand Down

0 comments on commit 490bd0d

Please sign in to comment.