diff --git a/nise/__init__.py b/nise/__init__.py index 79e34c47..5e6604d0 100644 --- a/nise/__init__.py +++ b/nise/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.6.8" +__version__ = "4.6.9" VERSION = __version__.split(".") diff --git a/nise/generators/aws/data_transfer_generator.py b/nise/generators/aws/data_transfer_generator.py index 713fde75..5477eeaa 100644 --- a/nise/generators/aws/data_transfer_generator.py +++ b/nise/generators/aws/data_transfer_generator.py @@ -116,6 +116,7 @@ def _update_data(self, row, start, end, **kwargs): row["pricing/term"] = "OnDemand" row["pricing/unit"] = "GB" row["savingsPlan/SavingsPlanEffectiveCost"] = str(saving) + row["savingsPlan/SavingsPlanRate"] = str(saving) # Overwrite lineItem/LineItemType for items with applied Savings plan if saving is not None: @@ -124,11 +125,16 @@ def _update_data(self, row, start, end, **kwargs): if negation: row["lineItem/LineItemType"] = "SavingsPlanNegation" row["lineItem/UnblendedCost"] = -abs(cost) - row["lineItem/LineItemDescription"] = f"SavingsPlanNegation used by AccountId : {self.payer_account}" - row["lineItem/ResourceId"] = None + row["lineItem/UnblendedRate"] = -abs(rate) row["lineItem/BlendedCost"] = -abs(cost) - - if not negation: + row["lineItem/BlendedRate"] = -abs(rate) + row[ + "lineItem/LineItemDescription" + ] = f"SavingsPlanNegation used by AccountId : {self.payer_account} and UsageSku : {self._product_sku}" + row["lineItem/ResourceId"] = None + row["savingsPlan/SavingsPlanEffectiveCost"] = None + row["savingsPlan/SavingsPlanRate"] = None + else: self._add_tag_data(row) self._add_category_data(row) return row diff --git a/nise/generators/aws/ec2_generator.py b/nise/generators/aws/ec2_generator.py index e22423f0..a8b60e42 100644 --- a/nise/generators/aws/ec2_generator.py +++ b/nise/generators/aws/ec2_generator.py @@ -198,20 +198,29 @@ def _update_data(self, row, start, end, **kwargs): row["pricing/term"] = "OnDemand" row["pricing/unit"] = "Hrs" row["savingsPlan/SavingsPlanEffectiveCost"] = saving + row["savingsPlan/SavingsPlanRate"] = saving # Overwrite lineItem/LineItemType for items with applied Savings plan if saving is not None: row["lineItem/LineItemType"] = "SavingsPlanCoveredUsage" + if negation: row["lineItem/LineItemType"] = "SavingsPlanNegation" row["lineItem/UnblendedCost"] = -abs(cost) - row["lineItem/LineItemDescription"] = f"SavingsPlanNegation used by AccountId : {self.payer_account}" - row["lineItem/ResourceId"] = None + row["lineItem/UnblendedRate"] = -abs(rate) row["lineItem/BlendedCost"] = -abs(cost) + row["lineItem/BlendedRate"] = -abs(rate) + row[ + "lineItem/LineItemDescription" + ] = f"SavingsPlanNegation used by AccountId : {self.payer_account} and UsageSku : {self._product_sku}" + row["lineItem/ResourceId"] = None + row["savingsPlan/SavingsPlanEffectiveCost"] = None + row["savingsPlan/SavingsPlanRate"] = None - if not negation: + else: self._add_tag_data(row) self._add_category_data(row) + return row def generate_data(self, report_type=None): diff --git a/tests/test_aws_generator.py b/tests/test_aws_generator.py index fbc5f105..296c5c96 100644 --- a/tests/test_aws_generator.py +++ b/tests/test_aws_generator.py @@ -409,7 +409,7 @@ def test_init_with_attributes(self): def test_update_data_ec2_negation(self): """Test EC2 specific update data with negation costs.""" - self.instance_type = {"negation": True, "cost": 10} + self.instance_type = {"negation": True, "cost": 10, "rate": 1} self.attributes["instance_type"] = self.instance_type generator = EC2Generator( self.two_hours_ago, self.now, self.currency, self.payer_account, self.usage_accounts, self.attributes