Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Evaluate valid OpenFisca names from a list
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'
];
// 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'));
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