@open3cl/engine 1.8.40 → 1.8.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/9_conso_ch.js +8 -0
- package/9_conso_ch.spec.js +29 -0
- package/README.md +18 -18
- package/conso.js +69 -1
- package/conso.spec.js +173 -1
- package/engine.js +1 -1
- package/package.json +1 -1
package/9_conso_ch.js
CHANGED
|
@@ -140,6 +140,14 @@ export function conso_ch(
|
|
|
140
140
|
di.conso_ch = consoInd.conso_ch + consoColl.conso_ch;
|
|
141
141
|
di.conso_ch_depensier = consoInd.conso_ch_dep + consoColl.conso_ch_dep;
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Part d'appoint individuel (40 %) conservée pour le coût : la base (60 %) est facturée en
|
|
145
|
+
* électricité collective, l'appoint en électricité individuelle (voir conso.js,
|
|
146
|
+
* coutBijonction).
|
|
147
|
+
*/
|
|
148
|
+
du.conso_ch_appoint_bijonction = consoInd.conso_ch;
|
|
149
|
+
du.conso_ch_appoint_bijonction_depensier = consoInd.conso_ch_dep;
|
|
150
|
+
|
|
143
151
|
return bch;
|
|
144
152
|
}
|
|
145
153
|
default: {
|
package/9_conso_ch.spec.js
CHANGED
|
@@ -291,6 +291,35 @@ describe('conso_ch - convecteurs bi-jonction (individuel + collectif)', () => {
|
|
|
291
291
|
// l'intermittence collective est calculée avec I0 = 1.03
|
|
292
292
|
expect(calc_intermittence).toHaveBeenCalledWith(150, 100, 2.5, 1.03);
|
|
293
293
|
});
|
|
294
|
+
|
|
295
|
+
test("part d'appoint individuel mémorisée pour le coût (base collective / appoint individuel)", () => {
|
|
296
|
+
const di = { rg: 1, rg_dep: 1 };
|
|
297
|
+
const du = {};
|
|
298
|
+
const de = { enum_type_generateur_ch_id: '10', surface_chauffee: 100, fch: 0.5 };
|
|
299
|
+
|
|
300
|
+
conso_ch(
|
|
301
|
+
di,
|
|
302
|
+
de,
|
|
303
|
+
du,
|
|
304
|
+
0,
|
|
305
|
+
'convecteurs bi-jonction',
|
|
306
|
+
[emetteur(0.5)],
|
|
307
|
+
150,
|
|
308
|
+
100,
|
|
309
|
+
2.5,
|
|
310
|
+
1000,
|
|
311
|
+
2000,
|
|
312
|
+
-9.5,
|
|
313
|
+
0,
|
|
314
|
+
1,
|
|
315
|
+
1
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
// appoint individuel seul : 0.4 * (0.5 / 0.8) * 1000 = 250 (dépensier : × 2)
|
|
319
|
+
expect(du.conso_ch_appoint_bijonction).toBeCloseTo(250, 9);
|
|
320
|
+
expect(du.conso_ch_appoint_bijonction_depensier).toBeCloseTo(500, 9);
|
|
321
|
+
expect(di.conso_ch - du.conso_ch_appoint_bijonction).toBeCloseTo(772.5, 9);
|
|
322
|
+
});
|
|
294
323
|
});
|
|
295
324
|
|
|
296
325
|
describe('conso_ch - installation collective base + appoint', () => {
|
package/README.md
CHANGED
|
@@ -370,14 +370,14 @@ Ces résultats sont **générés automatiquement** à la fin de `npm run test:co
|
|
|
370
370
|
|
|
371
371
|
<!-- CORPUS:START -->
|
|
372
372
|
|
|
373
|
-
> **Version `1.8.
|
|
373
|
+
> **Version `1.8.40`** · branche `main` · généré le 2026-10-10
|
|
374
374
|
> Seuil de tolérance **5%**
|
|
375
375
|
|
|
376
376
|
<table>
|
|
377
377
|
<tr>
|
|
378
378
|
<td align="center"><strong>9</strong><br/><sub>corpus</sub></td>
|
|
379
379
|
<td align="center"><strong>89 984</strong><br/><sub>DPE analysés</sub></td>
|
|
380
|
-
<td align="center"><strong>61
|
|
380
|
+
<td align="center"><strong>61 956</strong><br/><sub>DPE conformes</sub></td>
|
|
381
381
|
<td align="center"><strong>68,85 %</strong><br/><sub>réussite globale</sub></td>
|
|
382
382
|
</tr>
|
|
383
383
|
</table>
|
|
@@ -385,13 +385,13 @@ Ces résultats sont **générés automatiquement** à la fin de `npm run test:co
|
|
|
385
385
|
| | Corpus | Réussite | | DPE conformes |
|
|
386
386
|
| :-: | :---------------------------------------------------------------------------------------------------------------------- | ----------: | :--------------------- | -------------: |
|
|
387
387
|
| 🔴 | **Généraliste**<br/><sub>`corpus_dpe.csv`</sub> | **46,18 %** | `█████████░░░░░░░░░░░` | 4 618 / 9 999 |
|
|
388
|
-
| 🟢 | **Appartement · chauffage individuel (2025)**<br/><sub>`dpe_appartement_individuel_chauffage_individuel_2025.csv`</sub> | **92,
|
|
389
|
-
| 🟢 | **Logement individuel (2025)**<br/><sub>`dpe_logement_individuel_2025.csv`</sub> | **89,
|
|
388
|
+
| 🟢 | **Appartement · chauffage individuel (2025)**<br/><sub>`dpe_appartement_individuel_chauffage_individuel_2025.csv`</sub> | **92,54 %** | `███████████████████░` | 9 254 / 10 000 |
|
|
389
|
+
| 🟢 | **Logement individuel (2025)**<br/><sub>`dpe_logement_individuel_2025.csv`</sub> | **89,55 %** | `██████████████████░░` | 8 948 / 9 992 |
|
|
390
390
|
| 🟢 | **Maison individuelle (2025)**<br/><sub>`dpe_maison_individuelle_2025.csv`</sub> | **88,61 %** | `██████████████████░░` | 8 860 / 9 999 |
|
|
391
391
|
| 🟡 | **Immeuble · chauffage individuel**<br/><sub>`dpe_immeuble_chauffage_individuel.csv`</sub> | **84,22 %** | `█████████████████░░░` | 8 420 / 9 998 |
|
|
392
392
|
| 🟡 | **Appartement · chauffage collectif (2025)**<br/><sub>`dpe_appartement_individuel_chauffage_collectif_2025.csv`</sub> | **71,60 %** | `██████████████░░░░░░` | 7 160 / 10 000 |
|
|
393
393
|
| 🟡 | **Immeuble · chauffage collectif**<br/><sub>`dpe_immeuble_chauffage_collectif.csv`</sub> | **66,19 %** | `█████████████░░░░░░░` | 6 618 / 9 999 |
|
|
394
|
-
| 🔴 | **Immeuble · chauffage mixte**<br/><sub>`dpe_immeuble_chauffage_mixte.csv`</sub> | **53,
|
|
394
|
+
| 🔴 | **Immeuble · chauffage mixte**<br/><sub>`dpe_immeuble_chauffage_mixte.csv`</sub> | **53,74 %** | `███████████░░░░░░░░░` | 5 372 / 9 997 |
|
|
395
395
|
| 🔴 | **Individuel généré depuis l'immeuble (2026)**<br/><sub>`dpe_individuel_a_partir_dpe_immeuble_2026.csv`</sub> | **27,06 %** | `█████░░░░░░░░░░░░░░░` | 2 706 / 10 000 |
|
|
396
396
|
|
|
397
397
|
<sub>🟢 ≥ 85 % · 🟡 ≥ 60 % · 🔴 < 60 %</sub>
|
|
@@ -403,24 +403,24 @@ Ces résultats sont **générés automatiquement** à la fin de `npm run test:co
|
|
|
403
403
|
|
|
404
404
|
<table>
|
|
405
405
|
<tr>
|
|
406
|
-
<td align="center"><strong>4,
|
|
407
|
-
<td align="center"><strong>4,
|
|
408
|
-
<td align="center"><strong>0,
|
|
409
|
-
<td align="center"><strong>
|
|
406
|
+
<td align="center"><strong>4,76 ms</strong><br/><sub>moyenne</sub></td>
|
|
407
|
+
<td align="center"><strong>4,15 ms</strong><br/><sub>médiane</sub></td>
|
|
408
|
+
<td align="center"><strong>0,12 ms</strong><br/><sub>min</sub></td>
|
|
409
|
+
<td align="center"><strong>705,6 ms</strong><br/><sub>max</sub></td>
|
|
410
410
|
</tr>
|
|
411
411
|
</table>
|
|
412
412
|
|
|
413
413
|
| Corpus | Moyenne | Médiane | Min | Max | p95 | p99 |
|
|
414
414
|
| :--------------------------------------------- | ------: | ------: | ------: | -------: | ------: | ------: |
|
|
415
|
-
| **Généraliste** | 4,
|
|
416
|
-
| **Appartement · chauffage individuel (2025)** | 3,
|
|
417
|
-
| **Logement individuel (2025)** | 4,
|
|
418
|
-
| **Maison individuelle (2025)** | 5,
|
|
419
|
-
| **Immeuble · chauffage individuel** | 5,
|
|
420
|
-
| **Appartement · chauffage collectif (2025)** | 4,
|
|
421
|
-
| **Immeuble · chauffage collectif** | 5,
|
|
422
|
-
| **Immeuble · chauffage mixte** | 4,
|
|
423
|
-
| **Individuel généré depuis l'immeuble (2026)** | 5,
|
|
415
|
+
| **Généraliste** | 4,07 ms | 3,65 ms | 0,22 ms | 28,8 ms | 7,49 ms | 10,1 ms |
|
|
416
|
+
| **Appartement · chauffage individuel (2025)** | 3,71 ms | 3,38 ms | 1,40 ms | 27,1 ms | 6,41 ms | 8,18 ms |
|
|
417
|
+
| **Logement individuel (2025)** | 4,46 ms | 3,95 ms | 1,65 ms | 39,9 ms | 8,31 ms | 11,3 ms |
|
|
418
|
+
| **Maison individuelle (2025)** | 5,46 ms | 4,87 ms | 1,84 ms | 39,8 ms | 9,77 ms | 12,9 ms |
|
|
419
|
+
| **Immeuble · chauffage individuel** | 5,80 ms | 4,92 ms | 0,12 ms | 83,3 ms | 11,6 ms | 19,0 ms |
|
|
420
|
+
| **Appartement · chauffage collectif (2025)** | 4,27 ms | 3,90 ms | 1,50 ms | 35,0 ms | 7,03 ms | 9,07 ms |
|
|
421
|
+
| **Immeuble · chauffage collectif** | 5,12 ms | 4,32 ms | 0,12 ms | 92,3 ms | 9,55 ms | 16,6 ms |
|
|
422
|
+
| **Immeuble · chauffage mixte** | 4,62 ms | 3,78 ms | 0,17 ms | 705,6 ms | 9,38 ms | 15,3 ms |
|
|
423
|
+
| **Individuel généré depuis l'immeuble (2026)** | 5,29 ms | 4,53 ms | 1,68 ms | 45,3 ms | 9,97 ms | 15,4 ms |
|
|
424
424
|
|
|
425
425
|
<sub>La moyenne est tirée vers le haut par les DPE collectifs, dont le coût atteint plusieurs
|
|
426
426
|
dizaines de fois la médiane : c’est la médiane qui décrit le cas courant, et p95/p99 le cas
|
package/conso.js
CHANGED
|
@@ -258,6 +258,47 @@ function coefPourGenerateur(coef, gen) {
|
|
|
258
258
|
return collectif?.generateurs.has(gen) ? collectif.coef : coef;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Part d'appoint individuel (40 % du besoin, §9.1.6) de la consommation d'un convecteur
|
|
263
|
+
* bi-jonction, mémorisée par conso_ch (9_conso_ch.js) ; 0 pour les autres générateurs.
|
|
264
|
+
* @param gen {GenerateurChauffageItem}
|
|
265
|
+
* @param field {'conso_ch'|'conso_ch_depensier'}
|
|
266
|
+
* @returns {number}
|
|
267
|
+
*/
|
|
268
|
+
export function appointBijonction(gen, field) {
|
|
269
|
+
const du = gen.donnee_utilisateur || {};
|
|
270
|
+
const appoint =
|
|
271
|
+
field === 'conso_ch_depensier'
|
|
272
|
+
? du.conso_ch_appoint_bijonction_depensier
|
|
273
|
+
: du.conso_ch_appoint_bijonction;
|
|
274
|
+
return appoint || 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Coût du chauffage d'un convecteur bi-jonction d'une installation collective : la base est
|
|
279
|
+
* facturée en électricité collective (tranche de l'installation collective), l'appoint
|
|
280
|
+
* individuel en électricité individuelle (tranche du logement).
|
|
281
|
+
* Moteur de référence CSTB : DPE.Core Calcul_batiment.cs l.861-872 (base Cch1 → conso_elec_coll_ch
|
|
282
|
+
* si l'installation n'est pas individuelle) et l.912-915 (Cch_appoint_elec → conso_elec_indiv_ch),
|
|
283
|
+
* Calcul_cout.cs l.149-172 (tarification séparée collectif / individuel).
|
|
284
|
+
* @see : Methode_de_calcul_3CL_DPE_2021-338.pdf - §9.1.6 (convecteurs bi-jonction)
|
|
285
|
+
*
|
|
286
|
+
* @param coef {object} barème issu de coefCoutProrata
|
|
287
|
+
* @param gen {GenerateurChauffageItem}
|
|
288
|
+
* @param typeEnergie {string}
|
|
289
|
+
* @param conso {number} consommation du générateur (base + appoint)
|
|
290
|
+
* @param field {'conso_ch'|'conso_ch_depensier'}
|
|
291
|
+
* @returns {number|null} coût, ou null si la règle ne s'applique pas
|
|
292
|
+
*/
|
|
293
|
+
export function coutBijonction(coef, gen, typeEnergie, conso, field) {
|
|
294
|
+
const collectif = coef?.[COUT_COLLECTIF];
|
|
295
|
+
const appoint = appointBijonction(gen, field);
|
|
296
|
+
if (!collectif?.generateurs.has(gen) || appoint <= 0) return null;
|
|
297
|
+
return (
|
|
298
|
+
getConso(collectif.coef, typeEnergie, conso - appoint) + getConso(coef, typeEnergie, appoint)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
261
302
|
function getConso(coef, type_energie, conso) {
|
|
262
303
|
// is coef is a function, execute it
|
|
263
304
|
if (!coef) return conso;
|
|
@@ -393,6 +434,16 @@ export default function calc_conso(
|
|
|
393
434
|
inst.generateur_ecs_collection.generateur_ecs.forEach((g) => genCollectifs.add(g))
|
|
394
435
|
);
|
|
395
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Convecteurs bi-jonction d'une installation non individuelle : base toujours facturée en
|
|
439
|
+
* électricité collective, même sans extrapolation à l'immeuble (Tribu : SH_total = SH).
|
|
440
|
+
*/
|
|
441
|
+
gen_ch
|
|
442
|
+
.filter(
|
|
443
|
+
(g) =>
|
|
444
|
+
g.donnee_entree.enum_type_installation_id !== '1' && appointBijonction(g, 'conso_ch') > 0
|
|
445
|
+
)
|
|
446
|
+
.forEach((g) => genCollectifs.add(g));
|
|
396
447
|
const consoGroupe = (masque) => {
|
|
397
448
|
const tot = calc_conso_pond(
|
|
398
449
|
Sh,
|
|
@@ -420,7 +471,21 @@ export default function calc_conso(
|
|
|
420
471
|
prorataChauffage,
|
|
421
472
|
[]
|
|
422
473
|
);
|
|
423
|
-
|
|
474
|
+
// Appoint individuel des convecteurs bi-jonction : tarifé en individuel (voir coutBijonction)
|
|
475
|
+
const appointIndividuel = gen_ch
|
|
476
|
+
.filter((g) => genCollectifs.has(g))
|
|
477
|
+
.reduce(
|
|
478
|
+
(acc, g) =>
|
|
479
|
+
acc +
|
|
480
|
+
getConso(
|
|
481
|
+
masque,
|
|
482
|
+
getTypeEnergie(g.donnee_entree, 'ch'),
|
|
483
|
+
appointBijonction(g, 'conso_ch')
|
|
484
|
+
) *
|
|
485
|
+
g.donnee_entree.cle_repartition_ch,
|
|
486
|
+
0
|
|
487
|
+
);
|
|
488
|
+
return { total: tot.c_5_usages, collectif: coll.c_ch + coll.c_ecs - appointIndividuel };
|
|
424
489
|
};
|
|
425
490
|
return coefCoutProrata(base, consoGroupe, nbLogements, genCollectifs, ratioSurfaceCollectif);
|
|
426
491
|
};
|
|
@@ -668,6 +733,9 @@ function getChauffageConso(gen_ch, field, coef, prorataChauffage, prefix) {
|
|
|
668
733
|
? gen_ch.donnee_entree.cle_repartition_ch || prorataChauffage
|
|
669
734
|
: prorataChauffage;
|
|
670
735
|
|
|
736
|
+
const coutBij = coutBijonction(coef, gen_ch, typeEnergie, conso, field);
|
|
737
|
+
if (coutBij !== null) return acc + coutBij * repartition;
|
|
738
|
+
|
|
671
739
|
let coeffConsoChauffage = { ...coefPourGenerateur(coef, gen_ch) };
|
|
672
740
|
|
|
673
741
|
if (prefix === 'emission_ges') {
|
package/conso.spec.js
CHANGED
|
@@ -56,7 +56,9 @@ const {
|
|
|
56
56
|
coefCoutProrata,
|
|
57
57
|
masqueEnergie,
|
|
58
58
|
getAuxGenerationEcs,
|
|
59
|
-
DATE_BAREME_COUT_2024
|
|
59
|
+
DATE_BAREME_COUT_2024,
|
|
60
|
+
appointBijonction,
|
|
61
|
+
coutBijonction
|
|
60
62
|
} = await import('./conso.js');
|
|
61
63
|
|
|
62
64
|
/**
|
|
@@ -797,3 +799,173 @@ describe('getAuxGenerationEcs - auxiliaires de génération ECS et rdim', () =>
|
|
|
797
799
|
expect(res.ef_conso.conso_auxiliaire_generation_ecs).toBeGreaterThan(0);
|
|
798
800
|
});
|
|
799
801
|
});
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Convecteurs bi-jonction (§9.1.6) : base (60 %) facturée en électricité collective, appoint
|
|
805
|
+
* individuel (40 %) en électricité individuelle.
|
|
806
|
+
* @see Moteur_DPE.dll (CSTB) Calcul_batiment.cs l.861-872 / l.912-915, Calcul_cout.cs l.149-172 ;
|
|
807
|
+
* autotests APP3-0-1 (base 1541 kWh → 311 €, appoint 858 kWh → 197 €) et IC1-0-5.
|
|
808
|
+
*/
|
|
809
|
+
describe('calc_conso - coût des convecteurs bi-jonction (base collective + appoint individuel)', () => {
|
|
810
|
+
const DATE_DPE_2026 = '2026-01-15';
|
|
811
|
+
let errorSpy;
|
|
812
|
+
|
|
813
|
+
beforeEach(() => {
|
|
814
|
+
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
afterEach(() => {
|
|
818
|
+
errorSpy.mockRestore();
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
/** Installation bi-jonction (type 4) : conso totale 2400 kWh dont 900 kWh d'appoint. */
|
|
822
|
+
const bijonction = (typeInstallation = '4') => [
|
|
823
|
+
installCh({ enum_type_installation_id: typeInstallation }, [
|
|
824
|
+
{
|
|
825
|
+
...genCh('1', { conso_ch: 2400, conso_ch_depensier: 4800 }),
|
|
826
|
+
donnee_utilisateur: {
|
|
827
|
+
conso_ch_appoint_bijonction: 900,
|
|
828
|
+
conso_ch_appoint_bijonction_depensier: 1800
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
])
|
|
832
|
+
];
|
|
833
|
+
|
|
834
|
+
test('appartement : base tarifée sur la tranche de l’immeuble, appoint avec les usages individuels', () => {
|
|
835
|
+
const res = calc_conso(
|
|
836
|
+
100,
|
|
837
|
+
1,
|
|
838
|
+
1,
|
|
839
|
+
[],
|
|
840
|
+
bijonction(),
|
|
841
|
+
[],
|
|
842
|
+
[],
|
|
843
|
+
1,
|
|
844
|
+
1,
|
|
845
|
+
DATE_DPE_2026,
|
|
846
|
+
coef_ep,
|
|
847
|
+
1,
|
|
848
|
+
20
|
|
849
|
+
);
|
|
850
|
+
// Base 1500 kWh × 20 = 30000 kWh (≥ 15000) => (78 + 0,20001 × 30000) / 20
|
|
851
|
+
const base = (78 + 0.20001 * 30000) / 20;
|
|
852
|
+
// Individuel : appoint 900 + éclairage 100 = 1000 kWh (tranche 1000-2500) au prorata
|
|
853
|
+
const indiv = 158 + 0.18954 * 1000;
|
|
854
|
+
expect(res.cout.cout_ch).toBeCloseTo(base + (indiv * 900) / 1000, 9);
|
|
855
|
+
expect(res.cout.cout_eclairage).toBeCloseTo((indiv * 100) / 1000, 9);
|
|
856
|
+
expect(res.cout.cout_5_usages).toBeCloseTo(base + indiv, 9);
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
test('immeuble : base sur le total collectif, appoint rapporté au logement (N × f(C / N))', () => {
|
|
860
|
+
const res = calc_conso(100, 1, 1, [], bijonction(), [], [], 1, 1, DATE_DPE_2026, coef_ep, 4);
|
|
861
|
+
// Base 1500 kWh (tranche 1000-2500) ; individuel (900 + 100) / 4 logements = 250 kWh
|
|
862
|
+
const base = 158 + 0.18954 * 1500;
|
|
863
|
+
const indiv = 4 * 0.34721 * 250;
|
|
864
|
+
expect(res.cout.cout_ch).toBeCloseTo(base + (indiv * 900) / 1000, 9);
|
|
865
|
+
expect(res.cout.cout_5_usages).toBeCloseTo(base + indiv, 9);
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
test('scénario dépensier : part d’appoint dépensière utilisée', () => {
|
|
869
|
+
const res = calc_conso(
|
|
870
|
+
100,
|
|
871
|
+
1,
|
|
872
|
+
1,
|
|
873
|
+
[],
|
|
874
|
+
bijonction(),
|
|
875
|
+
[],
|
|
876
|
+
[],
|
|
877
|
+
1,
|
|
878
|
+
1,
|
|
879
|
+
DATE_DPE_2026,
|
|
880
|
+
coef_ep,
|
|
881
|
+
1,
|
|
882
|
+
20
|
|
883
|
+
);
|
|
884
|
+
const coef = (c) => ((78 + 0.20001 * 30000) / 30000) * c;
|
|
885
|
+
const prixIndiv = (158 + 0.18954 * 1000) / 1000;
|
|
886
|
+
expect(res.cout.cout_ch_depensier).toBeCloseTo(coef(3000) + prixIndiv * 1800, 9);
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
test('installation individuelle : un seul barème (individuel) pour tout le générateur', () => {
|
|
890
|
+
const res = calc_conso(
|
|
891
|
+
100,
|
|
892
|
+
1,
|
|
893
|
+
1,
|
|
894
|
+
[],
|
|
895
|
+
bijonction('1'),
|
|
896
|
+
[],
|
|
897
|
+
[],
|
|
898
|
+
1,
|
|
899
|
+
1,
|
|
900
|
+
DATE_DPE_2026,
|
|
901
|
+
coef_ep,
|
|
902
|
+
1,
|
|
903
|
+
20
|
|
904
|
+
);
|
|
905
|
+
// Élec totale 2400 + 100 = 2500 kWh (tranche 2500-5000) au prorata
|
|
906
|
+
expect(res.cout.cout_ch).toBeCloseTo(((158 + 0.18949 * 2500) * 2400) / 2500, 9);
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
test('sans surface d’immeuble (ratio 1, 1 logement) : base et appoint tarifés séparément', () => {
|
|
910
|
+
const res = calc_conso(100, 1, 1, [], bijonction(), [], [], 1, 1, DATE_DPE_2026, coef_ep);
|
|
911
|
+
// Base 1500 kWh seule (tranche 1000-2500) ; individuel 900 + 100 = 1000 kWh
|
|
912
|
+
const base = 158 + 0.18954 * 1500;
|
|
913
|
+
const indiv = 158 + 0.18954 * 1000;
|
|
914
|
+
expect(res.cout.cout_ch).toBeCloseTo(base + (indiv * 900) / 1000, 9);
|
|
915
|
+
expect(res.cout.cout_5_usages).toBeCloseTo(base + indiv, 9);
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
test('DPE antérieur au 01/07/2024 : barème 2021 par poste, sans scission', () => {
|
|
919
|
+
const res = calc_conso(100, 1, 1, [], bijonction(), [], [], 1, 1, '2024-06-30', coef_ep, 1, 20);
|
|
920
|
+
expect(res.cout.cout_ch).toBeCloseTo(149 + 0.14066 * 2400, 9);
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
test('consommations EF / EP inchangées par la scission', () => {
|
|
924
|
+
const res = calc_conso(
|
|
925
|
+
100,
|
|
926
|
+
1,
|
|
927
|
+
1,
|
|
928
|
+
[],
|
|
929
|
+
bijonction(),
|
|
930
|
+
[],
|
|
931
|
+
[],
|
|
932
|
+
1,
|
|
933
|
+
1,
|
|
934
|
+
DATE_DPE_2026,
|
|
935
|
+
coef_ep,
|
|
936
|
+
1,
|
|
937
|
+
20
|
|
938
|
+
);
|
|
939
|
+
expect(res.ef_conso.conso_ch).toBeCloseTo(2400, 9);
|
|
940
|
+
expect(res.ep_conso.ep_conso_ch).toBeCloseTo(2400 * 1.9, 9);
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
describe('appointBijonction / coutBijonction', () => {
|
|
945
|
+
test('appointBijonction : part mémorisée selon le scénario, 0 sinon', () => {
|
|
946
|
+
const gen = {
|
|
947
|
+
donnee_utilisateur: {
|
|
948
|
+
conso_ch_appoint_bijonction: 9,
|
|
949
|
+
conso_ch_appoint_bijonction_depensier: 18
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
expect(appointBijonction(gen, 'conso_ch')).toBe(9);
|
|
953
|
+
expect(appointBijonction(gen, 'conso_ch_depensier')).toBe(18);
|
|
954
|
+
expect(appointBijonction({}, 'conso_ch')).toBe(0);
|
|
955
|
+
expect(appointBijonction({ donnee_utilisateur: {} }, 'conso_ch_depensier')).toBe(0);
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
test('coutBijonction : null hors barème collectif ou sans appoint', () => {
|
|
959
|
+
const gen = { donnee_utilisateur: { conso_ch_appoint_bijonction: 10 } };
|
|
960
|
+
const base = getCoefCout('2026-01-15');
|
|
961
|
+
expect(coutBijonction(base, gen, 'électricité ch', 30, 'conso_ch')).toBeNull();
|
|
962
|
+
expect(coutBijonction(null, gen, 'électricité ch', 30, 'conso_ch')).toBeNull();
|
|
963
|
+
const coef = coefCoutProrata(base, () => ({ total: 100, collectif: 50 }), 1, new Set([gen]));
|
|
964
|
+
expect(coutBijonction(coef, {}, 'électricité ch', 30, 'conso_ch')).toBeNull();
|
|
965
|
+
// base 20 kWh au prix collectif f(50)/50, appoint 10 kWh au prix individuel f(50)/50
|
|
966
|
+
expect(coutBijonction(coef, gen, 'électricité ch', 30, 'conso_ch')).toBeCloseTo(
|
|
967
|
+
0.34721 * 30,
|
|
968
|
+
9
|
|
969
|
+
);
|
|
970
|
+
});
|
|
971
|
+
});
|
package/engine.js
CHANGED
|
@@ -33,7 +33,7 @@ import getFicheTechnique from './ficheTechnique.js';
|
|
|
33
33
|
import { ProductionENR, ratioProrataPvLogement } from './16.2_production_enr.js';
|
|
34
34
|
import DpeSanitizerService from './dpe-sanitizer.service.js';
|
|
35
35
|
|
|
36
|
-
const LIB_VERSION = '1.8.
|
|
36
|
+
const LIB_VERSION = '1.8.41';
|
|
37
37
|
|
|
38
38
|
const dpeSanitizerService = new DpeSanitizerService();
|
|
39
39
|
|