Skip to content

Commit

Permalink
fix(issue-13): cast value before compare
Browse files Browse the repository at this point in the history
  • Loading branch information
fperinel committed Apr 8, 2024
1 parent c75067e commit 06bbc21
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/3.1_b.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/3.2.1_mur.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 4 additions & 1 deletion src/3.3_baie_vitree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}$`;
}
Expand Down
7 changes: 4 additions & 3 deletions src/5_conso_ventilation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { requestInput } from './utils.js';
import { DECIMAL_PRECISION } from './constants.js';

const pvent_moy_maison = {
'simple flux auto': {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DECIMAL_PRECISION = 8;

0 comments on commit 06bbc21

Please sign in to comment.