Skip to content

Calculate contracts in first billing cycle #4297

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

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

fatmaebrahim
Copy link
Collaborator

Description

Calculated the contract cost to be used as the billing rate instead of the consumption in the first billing cycle

Changes

  • Used contract cost instead of 0 value as the billing rate for the contracts at their first billing cycle
  • Used getContractCost method to calculate the contract cost
  • Used '0 TFT/hour' instead of 'No data available' for zero consumption values
  • Discounts are not applied, since discount package for the first billing cycle is 'None'

Related Issues

Tested Scenarios

  • for first billing cycle consumption (221035 is a name contract in its first billing cycle)
image
  • for zero consumption values
image

Documentation PR

For UI changes, Please provide the Documentation PR on info_grid

To consider

Preliminary Checks:

  • Preliminary Checks
    • Does it completely address the issue linked?
    • What about edge cases?
    • Does it meet the specified acceptance criteria?
    • Are there any unintended side effects?
    • Does the PR adhere to the team's coding conventions, style guides, and best practices?
    • Does it integrate well with existing features?
    • Does it impact the overall performance of the application?
    • Are there any bottlenecks or slowdowns?
    • Has it been optimized for efficiency?
    • Has it been adequately tested with unit, integration, and end-to-end tests?
    • Are there any known defects or issues?
    • Is the code well-documented?
    • Are changes to documentation reflected in the code?

UI Checks:

  • UI Checks
    • If a UI design is provided/ does it follow it?
    • Does every button work?
    • Is the data displayed logical? Is it what you expected?
    • Does every validation work?
    • Does this interface feel intuitive?
    • What about slow network? Offline?
    • What if the gridproxy/graphql/chain is failing?
    • What would a first time user have a hard time navigating here?

Code Quality Checks:

  • Code Quality Checks
    • Code formatted/linted? Are there unused imports? .. etc
    • Is there redundant/repeated code?
    • Are there conditionals that are always true or always false?
    • Can we write this more concisely?
    • Can we reuse this code? If yes, where?
    • Will the changes be easy to maintain and update in the future?
    • Can this code become too complex to understand for other devs?
    • Can this code cause future integration problems?

Testing Checklist

  • Does it Meet the specified acceptance criteria.
  • Test if changes can affect any other functionality.
  • Tested with unit, integration, and end-to-end tests.
  • Tested the un-happy path and rollback scenarios.
  • Documentation updated to meet the latest changes.
  • Check automated tests working successfully with the changes.
  • Can be covered by automated tests.

General Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring
  • Screenshots/Video attached (needed for UI changes)

@0oM4R
Copy link
Contributor

0oM4R commented Jul 20, 2025

Discounts are not applied, since the discount package for the first billing cycle is 'None'

why? If you have enough balance, you will get the discount no matter the billing cycle number

@@ -305,8 +309,10 @@ class TFContracts extends Contracts {
const gqlConsumption: GqlConsumption = response["data"] as GqlConsumption;
const billReports = gqlConsumption.contractBillReports;
if (billReports.length === 0) {
const contractCostUSD = await this.getContractCost(contract, proxy);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to pass the contract only proxy client can handle that
const contract = (await proxy.contracts.list({ contractId: options.id }))[0];

async getConsumption(
options: GetConsumptionOptions,
contract: Contract,
proxy: GridProxyClient,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have a new function called, for example, getConsumptionWithEstimation,
As these changes will break the current usage of this function in other places, and maybe in other clients

@ramezsaeed
Copy link
Contributor

Test scenarios:

  • Test name contract too for the first billing cycle, create domain to test this name contract.

@fatmaebrahim fatmaebrahim marked this pull request as draft July 21, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants