Skip to content
Snippets Groups Projects
Commit 803e69ec authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'fix/issue-contract-less-than-6-month' into 'main'

fix: issue-contract-less-than-6-month

See merge request !26
parents f21c9950 13c1f210
No related branches found
No related tags found
1 merge request!26fix: issue-contract-less-than-6-month
Pipeline #47814 passed
...@@ -9,7 +9,7 @@ const { ...@@ -9,7 +9,7 @@ const {
} = require('../helpers/parsing') } = require('../helpers/parsing')
const { rechercherServicesSouscritsMesures } = require('../requests/sge') const { rechercherServicesSouscritsMesures } = require('../requests/sge')
const xml2js = require('xml2js') const xml2js = require('xml2js')
const { contractState, contractLibelle } = require('./types/enum') const { contractState } = require('./types/enum')
/** /**
* @param {string} url * @param {string} url
...@@ -55,9 +55,8 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) { ...@@ -55,9 +55,8 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
currentContract = currentContracts currentContract = currentContracts
} }
if ( if (
(currentContract.etatCode === contractState.ACTIF || currentContract.etatCode === contractState.ACTIF ||
currentContract.etatCode === contractState.DEMANDE) && currentContract.etatCode === contractState.DEMANDE
currentContract.serviceSouscritLibelle === contractLibelle.ACTIF
) )
return currentContract.serviceSouscritId return currentContract.serviceSouscritId
return null return null
...@@ -71,7 +70,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) { ...@@ -71,7 +70,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
} }
log( log(
'error', '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 throw errors.LOGIN_FAILED
} }
......
...@@ -9,14 +9,4 @@ const contractState = { ...@@ -9,14 +9,4 @@ const contractState = {
DEMANDE: 'DEMANDE', DEMANDE: 'DEMANDE',
} }
/** module.exports = { contractState }
* 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 }
...@@ -277,7 +277,16 @@ async function deleteConsent( ...@@ -277,7 +277,16 @@ async function deleteConsent(
*/ */
async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) { async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) {
log('info', 'Querying data...') 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( await getData(
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`,
apiAuthKey, apiAuthKey,
...@@ -482,9 +491,9 @@ function processData(doctype = 'com.grandlyon.enedis.day') { ...@@ -482,9 +491,9 @@ function processData(doctype = 'com.grandlyon.enedis.day') {
['year', 'month', 'day', 'hour', 'minute'] ['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') { if (doctype === 'com.grandlyon.enedis.day') {
log('info', 'Agregating...') log('info', 'Aggregating...')
await agregateMonthAndYearData(processedDailyData) await agregateMonthAndYearData(processedDailyData)
} }
} catch (e) { } catch (e) {
......
...@@ -39,7 +39,6 @@ async function saveAccountData(accountId, accountData) { ...@@ -39,7 +39,6 @@ async function saveAccountData(accountId, accountData) {
async function getAccount(accountId) { async function getAccount(accountId) {
log('info', `getAccount: ${accountId}`) log('info', `getAccount: ${accountId}`)
const accounts = await cozyClient.data.findAll('io.cozy.accounts') const accounts = await cozyClient.data.findAll('io.cozy.accounts')
log('info', `getAccount data: ${JSON.stringify(accounts)}`)
return accounts.filter(account => return accounts.filter(account =>
isLocal() ? account._id === accountId : account.account_type === accountId isLocal() ? account._id === accountId : account.account_type === accountId
)[0] )[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment