diff --git a/src/core/contractVerification.js b/src/core/contractVerification.js index 7b559ce862dc7d193b5efb1ef3f1c86116dde81c..d1a26069457f4fc3e8d5c1102ddc1601cd39340b 100644 --- a/src/core/contractVerification.js +++ b/src/core/contractVerification.js @@ -9,7 +9,7 @@ const { } = require('../helpers/parsing') const { rechercherServicesSouscritsMesures } = require('../requests/sge') const xml2js = require('xml2js') -const { contractState, contractLibelle } = require('./types/enum') +const { contractState } = require('./types/enum') /** * @param {string} url @@ -55,9 +55,8 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) { currentContract = currentContracts } if ( - (currentContract.etatCode === contractState.ACTIF || - currentContract.etatCode === contractState.DEMANDE) && - currentContract.serviceSouscritLibelle === contractLibelle.ACTIF + currentContract.etatCode === contractState.ACTIF || + currentContract.etatCode === contractState.DEMANDE ) return currentContract.serviceSouscritId return null @@ -71,7 +70,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) { } log( 'error', - 'if an erorr is thrown here, it probably means that the contract has already been open today and that enedis cannot open a second one. Wait until tomorow to try again' + 'if an error is thrown here, it probably means that the contract has already been open today and that enedis cannot open a second one. Wait until tomorow to try again' ) throw errors.LOGIN_FAILED } diff --git a/src/core/types/enum.js b/src/core/types/enum.js index 485c3f76c0769b016cb906053566b47fd965a1ca..8bcc6f3f7a0c876c6bee873cfe354934b5bc23ad 100644 --- a/src/core/types/enum.js +++ b/src/core/types/enum.js @@ -9,14 +9,4 @@ const contractState = { DEMANDE: 'DEMANDE', } -/** - * Enum for contractLibelle values. - * @readonly - * @enum {number} - */ -const contractLibelle = { - ACTIF: - 'Collecte de la courbe de charge au pas 30 min avec transmission quotidienne des données brutes en soutirage', -} - -module.exports = { contractState, contractLibelle } +module.exports = { contractState } diff --git a/src/index.js b/src/index.js index a3a93d5d9392c10762130c7e6686d1d119239227..7d1c7c2873073c263ce28f34670dd8a54fae2a9e 100644 --- a/src/index.js +++ b/src/index.js @@ -277,7 +277,16 @@ async function deleteConsent( */ async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) { log('info', 'Querying data...') - await getContractStartDate(baseUrl, apiAuthKey, sgeLogin, pointId) + const userContractstartDate = await getContractStartDate( + baseUrl, + apiAuthKey, + sgeLogin, + pointId + ) + + startDailyDate = moment(userContractstartDate, 'YYYY-MM-DD') + startDailyDateString = startDailyDate.format('YYYY-MM-DD') + await getData( `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, apiAuthKey, @@ -482,9 +491,9 @@ function processData(doctype = 'com.grandlyon.enedis.day') { ['year', 'month', 'day', 'hour', 'minute'] ) - log('info', 'Agregate enedis daily data for month and year') + log('info', 'Aggregate enedis daily data for month and year') if (doctype === 'com.grandlyon.enedis.day') { - log('info', 'Agregating...') + log('info', 'Aggregating...') await agregateMonthAndYearData(processedDailyData) } } catch (e) { diff --git a/src/requests/cozy.js b/src/requests/cozy.js index 2e22ceba07e45a2b0d553abd7caa95736f23d65b..71bc1f76dd819846af47b2a97a6858eb2a930dc1 100644 --- a/src/requests/cozy.js +++ b/src/requests/cozy.js @@ -39,7 +39,6 @@ async function saveAccountData(accountId, accountData) { async function getAccount(accountId) { log('info', `getAccount: ${accountId}`) const accounts = await cozyClient.data.findAll('io.cozy.accounts') - log('info', `getAccount data: ${JSON.stringify(accounts)}`) return accounts.filter(account => isLocal() ? account._id === accountId : account.account_type === accountId )[0]