stephankruggg opened a new pull request, #7210:
URL: https://github.com/apache/cloudstack/pull/7210

   ### Description
   
   The Quota usage value for monthly usage types uses the cost per hour to 
calculate the total tariff value in a particular period. In order to define the 
cost per hour, it takes into account the total number of hours in each month. 
However, this value is currently fixed at 720 hours for every month. 
   
   This causes incorrect values when calculating the cost per hour, resulting 
in costs being higher than expected. Therefore, this PR aims to calculate the 
number of hours in each month based on the actual number of days of each month.
   
   For example, if the tariff value is 100 per month, the current cost per hour 
is 0.138888889 for every month. For 1 hour per month the total cost in a year 
would be 1.666666668.
   With the adjustments to the cost per hour of this PR, the costs per hour 
would be: 0.134408602 (January, March, May, July, August, October, December), 
0.148809524 (February of a non-leap year), 0.143678161 (February of a leap 
year), and 0.138888889 (April, June, September, November). This results in 
1.645225294 for a non-leap year and 1.640093931 for a leap year at 1 hour per 
month, which is a difference of about 1.3% in costs to the current method.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [X] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [X] Minor
   
   ### How Has This Been Tested?
   
   In a local lab I applied the changes, and manually changed the current month 
of the MS to every month in a year (including February of a leap year) and 
verified if the cost per hour was calculated correctly using the number of 
hours of each month when the `quotaUpdate` API was called. 
   


-- 
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