JoaoJandre commented on code in PR #8347:
URL: https://github.com/apache/cloudstack/pull/8347#discussion_r1562910276


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -367,9 +369,22 @@ protected BigDecimal aggregateQuotaTariffsValues(UsageVO 
usageRecord, List<Quota
         PresetVariables presetVariables = 
getPresetVariables(hasAnyQuotaTariffWithActivationRule, usageRecord);
         BigDecimal aggregatedQuotaTariffsValue = BigDecimal.ZERO;
 
+        quotaTariffs.sort(Comparator.comparing(QuotaTariffVO::getPosition));
+
+        List<Tariff> lastTariffs = new ArrayList<>();
+
+
         for (QuotaTariffVO quotaTariff : quotaTariffs) {
             if (isQuotaTariffInPeriodToBeApplied(usageRecord, quotaTariff, 
accountToString)) {
-                aggregatedQuotaTariffsValue = 
aggregatedQuotaTariffsValue.add(getQuotaTariffValueToBeApplied(quotaTariff, 
jsInterpreter, presetVariables));
+
+                BigDecimal tariffValue = 
getQuotaTariffValueToBeApplied(quotaTariff, jsInterpreter, presetVariables, 
lastTariffs);
+
+                aggregatedQuotaTariffsValue = 
aggregatedQuotaTariffsValue.add(tariffValue);
+
+                Tariff tariffPresetVariable = new Tariff();
+                tariffPresetVariable.setId(quotaTariff.getUuid());
+                tariffPresetVariable.setValue(tariffValue);
+                lastTariffs.add(tariffPresetVariable);

Review Comment:
   Yes, the `tariffPresetVariable` holds the value of the tariff being 
processed now, and it is added to the `lastTariffs` list, so that it can be 
processed in a future activation rule.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to