Created
April 24, 2017 10:54
-
-
Save MattiSG/1fba8cec45fa7d01673adb3954971495 to your computer and use it in GitHub Desktop.
Evaluate valid OpenFisca names from a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ressourceTypes = [ | |
'aah', | |
'aeeh', | |
'af', | |
'aide_logement', | |
'allocationsChomage', | |
'allocationSecurisationPro', | |
'asf', | |
'asi', | |
'aspa', | |
'ass', | |
'autresRevenusTns', | |
'bourseEnseignementSup', | |
'bourseRecherche', | |
'caAutoEntrepreneur', | |
'caMicroEntreprise', | |
'cf', | |
'complementAAH', | |
'dedommagementAmiante', | |
'gainsExceptionnels', | |
'indChomagePartiel', | |
'indJourAccidentDuTravail', | |
'indJourMaladie', | |
'indJourMaladieProf', | |
'indJourMaternite', | |
'indVolontariat', | |
'mva', | |
'paje_base', | |
'paje_clca', | |
'paje_prepare', | |
'pch', | |
'pensionsAlimentaires', | |
'pensionsAlimentairesVersees', | |
'pensionsInvalidite', | |
'pensionsRetraitesRentes', | |
'ppa', | |
'prestationCompensatoire', | |
'primeRepriseActivite', | |
'retraiteCombattant', | |
'revenusAgricolesTns', | |
'revenusDuCapital', | |
'revenusLocatifs', | |
'revenusSalarie', | |
'revenusStageFormationPro', | |
'rsa', | |
'stage', | |
'primes', | |
'indFinDeContrat', | |
// rnc | |
'rncRevenusActivite', | |
'rncAutresRevenus', | |
'rncPensionsRetraitesRentes', | |
'fraisReelsDeductibles', | |
'rncPensionsAlimentaires', | |
'rncPensionsAlimentairesVersees' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Once https://github.com/openfisca/openfisca-web-api/issues/125 is fixed. | |
var valid = [], | |
invalid = []; | |
ressourceTypes.forEach(id => { | |
require('https').get(`https://api-test.openfisca.fr/variable/${id}`, res => { | |
(res.statusCode == 200 ? valid : invalid).push(id); | |
}); | |
console.log('\nVALID OPENFISCA NAMES (total', valid.length, ')'); | |
console.log(valid.join('\n')); | |
console.log('\nINVALID OPENFISCA NAMES (total', invalid.length, ')'); | |
console.log(invalid.join('\n')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const VARIABLES = require('./variables.json').variables; // download this file from https://api.openfisca.fr/api/1/variables/ | |
var valid = [], | |
invalid = []; | |
ressourceTypes.forEach(id => { | |
(VARIABLES.some(variable => variable.name == id) ? valid : invalid).push(id); | |
}); | |
console.log('\nVALID OPENFISCA NAMES (total', valid.length, ')'); | |
console.log(valid.join('\n')); | |
console.log('\nINVALID OPENFISCA NAMES (total', invalid.length, ')'); | |
console.log(invalid.join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment