diff --git a/src/3.1_b.js b/src/3.1_b.js index cd6e6b8..9332008 100644 --- a/src/3.1_b.js +++ b/src/3.1_b.js @@ -39,7 +39,7 @@ export default function b(di, de, du, zc_id) { /* du.enum_cfg_isolation_lnc_id = ['6', '7', '8', '9', '10', '11'] */ } else if ( ['8', '9', '11', '12', '13', '14', '15', '16', '17', '18', '19', '21'].includes( - de.enum_type_adjacence_id + de.enum_type_adjacence_id.toString() ) ) { if (de.surface_aue === 0) { diff --git a/src/3.2.1_mur.js b/src/3.2.1_mur.js index 05078ae..098b0b9 100644 --- a/src/3.2.1_mur.js +++ b/src/3.2.1_mur.js @@ -12,7 +12,7 @@ function tv_umur0(di, de, du) { const matcher = { enum_materiaux_structure_mur_id: de.enum_materiaux_structure_mur_id }; - if (!['1', '20'].includes(de.enum_materiaux_structure_mur_id)) { + if (!['1', '20'].includes(de.enum_materiaux_structure_mur_id.toString())) { // 1: inconnu, 20: cloison de platree, pas concerné par les epaisseurs // TODO not float, get from csv matcher.epaisseur_structure = requestInput(de, du, 'epaisseur_structure', 'float'); diff --git a/src/3.3_baie_vitree.js b/src/3.3_baie_vitree.js index 5c25bcf..f3157df 100644 --- a/src/3.3_baie_vitree.js +++ b/src/3.3_baie_vitree.js @@ -27,7 +27,10 @@ function tv_uw(di, de, du) { enum_type_baie_id: requestInputID(de, du, 'type_baie') }; - if (matcher.enum_type_baie_id && !['1', '2', '3'].includes(matcher.enum_type_baie_id)) { + if ( + matcher.enum_type_baie_id && + !['1', '2', '3'].includes(matcher.enum_type_baie_id.toString()) + ) { matcher.enum_type_materiaux_menuiserie_id = requestInputID(de, du, 'type_materiaux_menuiserie'); matcher.ug = `^${di.ug}$`; } diff --git a/src/5_conso_ventilation.js b/src/5_conso_ventilation.js index 7e835a2..966df7e 100644 --- a/src/5_conso_ventilation.js +++ b/src/5_conso_ventilation.js @@ -1,4 +1,5 @@ import { requestInput } from './utils.js'; +import { DECIMAL_PRECISION } from './constants.js'; const pvent_moy_maison = { 'simple flux auto': { @@ -42,7 +43,7 @@ function getCoefficient(th, hybride) { return 1; } const ratio = th === 'maison' ? 14 : 28; - return +parseFloat(ratio / (24 * 7)).toFixed(3); + return +parseFloat(ratio / (24 * 7)).toFixed(DECIMAL_PRECISION); } export default function calc_pvent(di, de, du, th) { @@ -116,11 +117,11 @@ export default function calc_pvent(di, de, du, th) { const coef = getCoefficient(th, hybride); if (th === 'maison') { - di.pvent_moy = parseFloat(pvent_moy_maison[type][post_2012] * coef).toFixed(3); + di.pvent_moy = parseFloat(pvent_moy_maison[type][post_2012] * coef).toFixed(DECIMAL_PRECISION); } else { const pvent = pvent_immeuble[type][post_2012]; const sv = requestInput(de, du, 'surface_ventile', 'float'); - di.pvent_moy = parseFloat(pvent * di.qvarep_conv * sv * coef).toFixed(3); + di.pvent_moy = parseFloat(pvent * di.qvarep_conv * sv * coef).toFixed(DECIMAL_PRECISION); } di.conso_auxiliaire_ventilation = 8.76 * di.pvent_moy; } diff --git a/src/constants.js b/src/constants.js new file mode 100644 index 0000000..75d5dee --- /dev/null +++ b/src/constants.js @@ -0,0 +1 @@ +export const DECIMAL_PRECISION = 8;