Skip to content

Quota tariff order#8347

Merged
DaanHoogland merged 19 commits intoapache:mainfrom
scclouds:quota-tariff-order
Jul 14, 2024
Merged

Quota tariff order#8347
DaanHoogland merged 19 commits intoapache:mainfrom
scclouds:quota-tariff-order

Conversation

@JoaoJandre
Copy link
Copy Markdown
Contributor

@JoaoJandre JoaoJandre commented Dec 12, 2023

Description

Quota tariffs have been extended to make it possible to define the order of their execution. To achieve this, the position parameter was added to the quotaTariffCreate and quotaTariffUpdate APIs. This parameter is used to define the tariff execution sequence of tariffs with the same usage type. This order is ascending, that is, a tariff with position equal to 1 will be executed before a tariff with position equal to 2. If two tariffs of the same usage type have equal positions, the most recent one will be executed first.

During the processing of Quota tariffs, ACS will execute them in the defined order and inject the values ​​into subsequent rates. To enable tariff injection, the preset variable lastTariffs was created. It will have a list of objects containing the id and value attributes of the tariffs executed before it. Below is an example of the variable value when executing 3 tariffs (A, B and C) of the same usage type:

  • When executing tariff A, the value of lastTariffs will be:
[ ]
  • When executing rule B, lastTariffs will have the value:
[
  {
    "id": <A_uuid>,
    "value": <A_result>
  }
]
  • When executing rule C, lastTariffs will have the values:
[
  {
    "id": <A_uuid>,
    "value": <A_result>
  },
  {
    "id": <B_uuid>,
    "value": <B_result>
  }
]

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

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

How Has This Been Tested?

About the quotaTariffCreate and quotaTariffUpdate APIs

Num Test Result Expected result?
1 Create a tariff informing the position Tariff was created with the position informed Y
2 Create a tariff without informing the position Tariff was created with default position 1 Y
3 Edit a tariff by entering a new position Tariff was edited with the position given Y
4 Edit a tariff without entering a new position Tariff was edited maintaining the previous position Y

About the lastTariffs preset variable:
I created three tariffs with activation rules:

  • the first with position 1 and always returning 10
  • the second with position 2 and the rule: lastTariffs[0].value + 7
  • the third with position 3 and the rule: lastTariffs[0].value + lastTariffs[1].value.

When running quotaUpdate, I looked in the logs for which values were calculated according to the tariffs, the first returned 10, the second 17 and the third 27.

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

8 participants