Skip to content
Snippets Groups Projects
prices.md 4.25 KiB

Price Calculation

This section explains the price calculation process.

Description

Since version 1.6.0 of the app, we have a database storing fluid prices evolution since 2012 for the following fluids :

  • Electricity
  • Gas

Before this version, the app was applying a hard coded price for each fluid without taking care of the time period. Now, there is a service that processes fresh data in order to apply the current price to this data, but also apply the most relevant price for a fluid doctype.

Service

Process

The Cozy service responsible for price calculation is fluidsPrices. You can find the full logic in the following diagram :

This service is running every night at 02:00 AM and during splash screen.

:::warning

You might observe some price miscalculation because the service is triggered asynchronously during splash root, but because of the default price in constants/config.json, the user should not see a big difference.

:::

Init

A migration job has been setup to init the database with json data store inside the app. This job should be run once and will init electricity and gas prices.

New price

In case of price update the following procedure must be done :

  • Create a migration for adding new prices
  • Update hard coded price inside app in order to maintain fallback calculation
  • Verify full service calculation with new data
  • Verify calculation with existing data

:::warning The service does not handle change during a month because the case does not exist anymore for Enedis and Grdf. :::

Prices Data

We store in database a collection of prices with the following info :

  • StartDate
  • EndDate
  • fluidType
  • Price

The EndDate is set to null if it's the current fluid price.

App Price display

The app can handle the new price calculation and also keep the old calculation system.

Regular display

If there is a price on the doctype we want to process, it will be use for display and calculation ( see analysis functionality).

Fallback

The app take the hard code price for a given fluid and apply it to a load. This allow the app to handle prices in any case.