Skip to content

Commit

Permalink
Fixed the yearly_savings item (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
athiruma authored Jul 23, 2024
1 parent 9ef15e2 commit 6e6b566
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cloud_governance/policy/helpers/abstract_policy_operations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from datetime import datetime
from datetime import datetime, timezone
from typing import Union

from cloud_governance.common.elasticsearch.elastic_upload import ElasticUpload
Expand Down Expand Up @@ -185,8 +185,8 @@ def __current_savings_year(self, unit_price: float):
:return:
:rtype:
"""
year_end_date = datetime.utcnow().date().replace(month=12, day=31)
total_days = (year_end_date - datetime.utcnow().date()).days + 1
year_end_date = datetime.now(timezone.utc).date().replace(month=12, day=31)
total_days = (year_end_date - datetime.now(timezone.utc).date()).days + 1
return total_days * 24 * unit_price

# ES Schema format
Expand All @@ -198,6 +198,7 @@ def _get_es_schema(self, **kwargs):
kwargs['clean_up_days'] = kwargs.get('cleanup_days', 0)
kwargs['days_count'] = kwargs.pop('cleanup_days', 0)
kwargs['account'] = self.account
kwargs['total_yearly_savings'] = self.__current_savings_year(unit_price=kwargs.get('unit_price', 0))
policy_es_data = PolicyEsMetaData(**kwargs)
resource_data = policy_es_data.get_as_dict_title_case()
return resource_data
Expand Down

0 comments on commit 6e6b566

Please sign in to comment.