Met à jour les taux versement transport
Ajoute un script pour le faire automatiquement (vu que l'Urssaf n'a pas l'air de vouloir fournir les taux en opendata :p) fix #1853pull/1906/head
parent
dd9a864e8e
commit
fa11d87f5d
|
@ -1,6 +1,6 @@
|
|||
.env
|
||||
source/data/*
|
||||
!source/data/versement-transport.json
|
||||
!source/data/versement-mobilité.json
|
||||
cypress/videos
|
||||
cypress/screenshots
|
||||
cypress/downloads
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"build:stats": "webpack --config webpack.prod.js --profile --json > stats.json",
|
||||
"build:analyze-bundle": "ANALYZE_BUNDLE=1 yarn run build",
|
||||
"build:dev": "FR_BASE_URL='http://localhost:5000${path}' EN_BASE_URL='http://localhost:5001${path}' yarn run build",
|
||||
"clean": "rimraf dist node_modules 'source/data/!(versement-transport.json)'",
|
||||
"clean": "rimraf dist node_modules 'source/data/!(versement-mobilité.json)'",
|
||||
"typecheck:watch": "tsc --skipLibCheck --noEmit --watch",
|
||||
"test": "yarn test:file \"./{,!(node_modules)/**/}!(webpack).test.{js,ts}\"",
|
||||
"test:file": "yarn mocha-webpack --webpack-config ./webpack.dev.js --require mock-local-storage --require test/helpers/browser.js",
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
require('isomorphic-fetch')
|
||||
const { writeInDataDir } = require('./utils')
|
||||
|
||||
const CSV_URL =
|
||||
'https://fichierdirect.declaration.urssaf.fr/static/tauxTransport.20220103.csv'
|
||||
|
||||
const INDEX = {
|
||||
TAUX: 2,
|
||||
CODE_COMMUNE: 0,
|
||||
DATE_EFFET: 4,
|
||||
}
|
||||
|
||||
;(async function main() {
|
||||
const response = await fetch(CSV_URL)
|
||||
const rawCSV = await response.text()
|
||||
const data = rawCSV
|
||||
.split('\n')
|
||||
.slice(1, -1)
|
||||
.map((row) => row.split(';'))
|
||||
.filter((r) => r[INDEX.TAUX] !== '0')
|
||||
.filter((r) => !r[INDEX.DATE_EFFET].startsWith('2023'))
|
||||
.map((r) => {
|
||||
r[INDEX.CODE_COMMUNE] = r[INDEX.CODE_COMMUNE].slice(1, -1) // Remove single quote ''
|
||||
return r
|
||||
})
|
||||
.sort((a, b) =>
|
||||
+a[INDEX.CODE_COMMUNE] < +b[INDEX.CODE_COMMUNE]
|
||||
? -1
|
||||
: +a[INDEX.CODE_COMMUNE] > +b[INDEX.CODE_COMMUNE]
|
||||
? 1
|
||||
: a[INDEX.DATE_EFFET] > b[INDEX.DATE_EFFET]
|
||||
? -1
|
||||
: 1
|
||||
)
|
||||
.reduce(
|
||||
(acc, r) => ({
|
||||
[r[INDEX.CODE_COMMUNE]]: +r[INDEX.TAUX],
|
||||
...acc,
|
||||
}),
|
||||
{}
|
||||
)
|
||||
|
||||
writeInDataDir('versement-mobilité.json', data)
|
||||
})()
|
|
@ -47,7 +47,7 @@ async function tauxVersementTransport(
|
|||
codeCommune = '132' + commune.codePostal.slice(-2)
|
||||
}
|
||||
// 2. On récupère le versement transport associé
|
||||
const response = await fetch('/data/versement-transport.json')
|
||||
const response = await fetch('/data/versement-mobilité.json')
|
||||
const json = await response.json()
|
||||
|
||||
return json[codeCommune] ?? 0
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue