From 7e488a3aaa8c985bb8b3612af74b51196f2ba015 Mon Sep 17 00:00:00 2001 From: build-token <build-token> Date: Thu, 1 Dec 2022 12:38:12 +0000 Subject: [PATCH] publish: Merge branch 'fix/issue-contract-less-than-6-month' into 'main' generated from commit 803e69ec16b806652f7155fb2279d14ee540cb84 --- index.js | 37 +++++++++++++++++-------------------- onDeleteAccount.js | 1 - 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index a748668..ff91813 100644 --- a/index.js +++ b/index.js @@ -282,7 +282,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, @@ -487,9 +496,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) { @@ -228464,7 +228473,7 @@ const { } = __webpack_require__(1561) const { rechercherServicesSouscritsMesures } = __webpack_require__(1562) const xml2js = __webpack_require__(1519) -const { contractState, contractLibelle } = __webpack_require__(1606) +const { contractState } = __webpack_require__(1606) /** * @param {string} url @@ -228510,9 +228519,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 @@ -228526,7 +228534,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 } @@ -228550,17 +228558,7 @@ 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 } /***/ }), @@ -228922,7 +228920,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] diff --git a/onDeleteAccount.js b/onDeleteAccount.js index 8bb3ac2..820b7df 100644 --- a/onDeleteAccount.js +++ b/onDeleteAccount.js @@ -227664,7 +227664,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] -- GitLab