diff --git a/src/client/components/Teleinfo/Teleinfo.spec.tsx b/src/client/components/Teleinfo/Teleinfo.spec.tsx index 084f4f1..5f5ee0d 100644 --- a/src/client/components/Teleinfo/Teleinfo.spec.tsx +++ b/src/client/components/Teleinfo/Teleinfo.spec.tsx @@ -30,6 +30,7 @@ describe('Teleinfo component', () => { estimatedPrices:{ currentDay: 5.567, currentMonth: 55, + currentYear: 475, total: 500 }, instantIntensity: 1, @@ -40,6 +41,7 @@ describe('Teleinfo component', () => { suppliedPower: { currentDay: [1, 2], currentMonth: [10, 20], + currentYear: [90, 150], total: [100, 200], }, }, diff --git a/src/client/components/Teleinfo/Teleinfo.tsx b/src/client/components/Teleinfo/Teleinfo.tsx index 43337e0..879bac0 100644 --- a/src/client/components/Teleinfo/Teleinfo.tsx +++ b/src/client/components/Teleinfo/Teleinfo.tsx @@ -56,7 +56,7 @@ const Teleinfo: FunctionComponent> = () => { W

- {renderPowerStats('min', 'Min (today/month/overall):')} + {renderPowerStats('min', 'Min (d/m/y/o):')} {renderPowerStats('max', 'Max:')}

@@ -79,6 +79,10 @@ const Teleinfo: FunctionComponent> = () => { {(data_TELEINFO.statistics.instantPower?.currentMonth && data_TELEINFO.statistics.instantPower?.currentMonth[statItemKey]) || '...'} / + + {(data_TELEINFO.statistics.instantPower?.currentYear && data_TELEINFO.statistics.instantPower?.currentYear[statItemKey]) || '...'} + + / {(data_TELEINFO.statistics.instantPower?.overall && data_TELEINFO.statistics.instantPower?.overall[statItemKey]) || '...'} @@ -125,12 +129,14 @@ const Teleinfo: FunctionComponent> = () => { <>

- Supplied (today/month/total): + Supplied (d/m/y/t): {renderSuppliedValue('currentDay')} / {renderSuppliedValue('currentMonth')} / + {renderSuppliedValue('currentYear')} + / {renderSuppliedValue('total')} Wh

@@ -173,6 +179,12 @@ const Teleinfo: FunctionComponent> = () => { '...'} / + + {(data_TELEINFO.suppliedPower?.currentYear && + data_TELEINFO.suppliedPower?.currentYear[rank]) || + '...'} + + / {(data_TELEINFO.suppliedPower?.total && data_TELEINFO.suppliedPower?.total[rank]) || @@ -224,7 +236,7 @@ const Teleinfo: FunctionComponent> = () => {

- Costs (today/month/total): + Costs (d/m/y/t): ~{displayPriceWithTwoDecimals(data_TELEINFO.estimatedPrices?.currentDay)} @@ -234,6 +246,10 @@ const Teleinfo: FunctionComponent> = () => { {data_TELEINFO.estimatedPrices?.currentMonth || '...'} / + + {data_TELEINFO.estimatedPrices?.currentYear || '...'} + + / {data_TELEINFO.estimatedPrices?.total || '...'} diff --git a/src/client/components/Teleinfo/__snapshots__/Teleinfo.spec.tsx.snap b/src/client/components/Teleinfo/__snapshots__/Teleinfo.spec.tsx.snap index 43177f8..9a6ff59 100644 --- a/src/client/components/Teleinfo/__snapshots__/Teleinfo.spec.tsx.snap +++ b/src/client/components/Teleinfo/__snapshots__/Teleinfo.spec.tsx.snap @@ -16,6 +16,7 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` "estimatedPrices": { "currentDay": 5.567, "currentMonth": 55, + "currentYear": 475, "total": 500, }, "instantIntensity": 1, @@ -37,6 +38,10 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` 10, 20, ], + "currentYear": [ + 90, + 150, + ], "total": [ 100, 200, @@ -86,8 +91,14 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` - Min (today/month/overall): + Min (d/m/y/o): + + + ... + / @@ -136,6 +147,12 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` > ... + / + + ... + @@ -168,7 +185,7 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` - Supplied (today/month/total): + Supplied (d/m/y/t): / + + 240 + + / @@ -220,6 +243,12 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` 10 / + + 90 + + / @@ -251,6 +280,12 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` 20 / + + 150 + + / @@ -274,7 +309,7 @@ exports[`Teleinfo component should render correctly with notif data 1`] = ` - Costs (today/month/total): + Costs (d/m/y/t): / + + 475 + + / @@ -347,6 +388,7 @@ exports[`Teleinfo component should render correctly with notif data and power ov "estimatedPrices": { "currentDay": 5.567, "currentMonth": 55, + "currentYear": 475, "total": 500, }, "instantIntensity": 1, @@ -369,6 +411,10 @@ exports[`Teleinfo component should render correctly with notif data and power ov 10, 20, ], + "currentYear": [ + 90, + 150, + ], "total": [ 100, 200, @@ -418,7 +464,7 @@ exports[`Teleinfo component should render correctly with notif data and power ov - Min (today/month/overall): + Min (d/m/y/o): ... + / + + ... + @@ -468,6 +520,12 @@ exports[`Teleinfo component should render correctly with notif data and power ov > ... + / + + ... + @@ -519,7 +577,7 @@ exports[`Teleinfo component should render correctly with notif data and power ov - Supplied (today/month/total): + Supplied (d/m/y/t): / + + 240 + + / @@ -571,6 +635,12 @@ exports[`Teleinfo component should render correctly with notif data and power ov 10 / + + 90 + + / @@ -602,6 +672,12 @@ exports[`Teleinfo component should render correctly with notif data and power ov 20 / + + 150 + + / @@ -625,7 +701,7 @@ exports[`Teleinfo component should render correctly with notif data and power ov - Costs (today/month/total): + Costs (d/m/y/t): / + + 475 + + / @@ -698,6 +780,7 @@ exports[`Teleinfo component should render correctly with notif data and power st "estimatedPrices": { "currentDay": 5.567, "currentMonth": 55, + "currentYear": 475, "total": 500, }, "instantIntensity": 1, @@ -732,6 +815,10 @@ exports[`Teleinfo component should render correctly with notif data and power st 10, 20, ], + "currentYear": [ + 90, + 150, + ], "total": [ 100, 200, @@ -781,7 +868,7 @@ exports[`Teleinfo component should render correctly with notif data and power st - Min (today/month/overall): + Min (d/m/y/o): / + + ... + + / @@ -826,6 +919,12 @@ exports[`Teleinfo component should render correctly with notif data and power st 200 / + + ... + + / @@ -882,7 +981,7 @@ exports[`Teleinfo component should render correctly with notif data and power st - Supplied (today/month/total): + Supplied (d/m/y/t): / + + 240 + + / @@ -934,6 +1039,12 @@ exports[`Teleinfo component should render correctly with notif data and power st 10 / + + 90 + + / @@ -965,6 +1076,12 @@ exports[`Teleinfo component should render correctly with notif data and power st 20 / + + 150 + + / @@ -988,7 +1105,7 @@ exports[`Teleinfo component should render correctly with notif data and power st - Costs (today/month/total): + Costs (d/m/y/t): / + + 475 + + / @@ -1061,6 +1184,7 @@ exports[`Teleinfo component should render correctly with notif data but without "estimatedPrices": { "currentDay": 5.567, "currentMonth": 55, + "currentYear": 475, "total": 500, }, "instantIntensity": 1, @@ -1118,7 +1242,7 @@ exports[`Teleinfo component should render correctly with notif data but without - Min (today/month/overall): + Min (d/m/y/o): ... + / + + ... + @@ -1168,6 +1298,12 @@ exports[`Teleinfo component should render correctly with notif data but without > ... + / + + ... + @@ -1200,7 +1336,7 @@ exports[`Teleinfo component should render correctly with notif data but without - Supplied (today/month/total): + Supplied (d/m/y/t): ... + / + + ... + @@ -1242,7 +1384,7 @@ exports[`Teleinfo component should render correctly with notif data but without - Costs (today/month/total): + Costs (d/m/y/t): / + + 475 + + / diff --git a/src/server/processing/teleinfo/fare-manager.ts b/src/server/processing/teleinfo/fare-manager.ts index bb66fd5..be0bdb5 100644 --- a/src/server/processing/teleinfo/fare-manager.ts +++ b/src/server/processing/teleinfo/fare-manager.ts @@ -7,6 +7,7 @@ import { PER_DAY_INDEXES_IS_KEY_PREFIX, PER_MONTH_COSTS_IS_KEY_PREFIX, PER_MONTH_INDEXES_IS_KEY_PREFIX, + PER_YEAR_COSTS_IS_KEY_PREFIX, PER_YEAR_INDEXES_IS_KEY_PREFIX, TOTAL_COSTS_IS_KEY, } from './helpers/store-constants'; @@ -112,7 +113,7 @@ export function computeEstimatedPrices( currentPriceKeys, fareDetails ); - const totalYearhPrice = computePrice( + const totalYearPrice = computePrice( initialYearIndexes, indexes, currentPriceKeys, @@ -134,7 +135,7 @@ export function computeEstimatedPrices( const currentYearCostsISKey = generateCurrentYearISKey( PER_YEAR_COSTS_IS_KEY_PREFIX ); - storeInstance.put(currentMonthCostsISKey, totalMonthPrice); + storeInstance.put(currentYearCostsISKey, totalYearPrice); // console.log({ totalPrice, totalDayPrice }); @@ -143,6 +144,7 @@ export function computeEstimatedPrices( currentDay: totalDayPrice, currentMonth: totalMonthPrice && Math.round(totalMonthPrice), + currentYear: totalYearPrice && Math.round(totalYearPrice), }; }