Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add account.created preset variable to Quota tariffs #10200

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicoschmdt
Copy link

Description

This PR adds the account.created preset variable to Quota tariffs, allowing users to consider an account's creation date when defining values to, for instance, grant a discount on the first month.

This variable is injected as a String. Therefore, users need to parse it first: Date.parse(account.created).

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)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

How Has This Been Tested?

In a local lab, the billing of two accounts was compared in relation to the amount of VM snapshots each one has.

  • User Account: created on 17 Oct 2024 17:36:46, with 3 VM snapshots
  • Root Account: created on 24 Oct 2024 13:51:35, with 1 VM snapshot

The base script for the activation rule used was:

today = new Date(); // current date was 24 Oct 2024
daysDiff = (today-Date.parse(account.created))/(1000*60*60*24);

if (daysDiff <= 5 && daysDiff >= 0) {
  20
} else {
  0
}

When daysDiff is less than or equal to 15 both accounts were charged. When daysDiff is less than or equal to 5 only the Root Account was charged.

It was noted that the first Root Account created by ACS doesn't have a creation date so the script was changed to:

today = new Date();
daysDiff = (today-Date.parse(account.created))/(1000*60*60*24);

if (daysDiff <= 30 && daysDiff >= 0) {
  0
} else {
  20
}

In this condition, it was observed that the first Root Account was charged while the others weren't.

Copy link

boring-cyborg bot commented Jan 16, 2025

Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
Here are some useful points:

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 17.01%. Comparing base (0c13ded) to head (b68e97a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10200      +/-   ##
============================================
+ Coverage     16.16%   17.01%   +0.85%     
- Complexity    13015    13017       +2     
============================================
  Files          5644     5250     -394     
  Lines        494640   462242   -32398     
  Branches      59937    54211    -5726     
============================================
- Hits          79955    78661    -1294     
+ Misses       405858   374901   -30957     
+ Partials       8827     8680     -147     
Flag Coverage Δ
uitests ?
unittests 17.01% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant