@socialgouv/cdtn-utils 4.228.2 → 4.229.0

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.
@@ -0,0 +1,10 @@
1
+ export declare const HOURS_PER_MONTH: number;
2
+ export type ChallengerFormula = "smic_hourly" | "smic_monthly_35h" | "smic_monthly_custom" | "smic_annual" | "smic_monthly_percent" | "smic_monthly_multiple";
3
+ export declare const CHALLENGER_FORMULAS: {
4
+ value: ChallengerFormula;
5
+ label: string;
6
+ paramLabel?: string;
7
+ }[];
8
+ export declare const isChallengerFormula: (value: string | undefined) => value is ChallengerFormula;
9
+ export declare function computeChallengerReference(formula: ChallengerFormula, parameter: string | null | undefined, smicHourly: number): number;
10
+ export declare function formatChallengerEur(value: number): string;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isChallengerFormula = exports.CHALLENGER_FORMULAS = exports.HOURS_PER_MONTH = void 0;
4
+ exports.computeChallengerReference = computeChallengerReference;
5
+ exports.formatChallengerEur = formatChallengerEur;
6
+ exports.HOURS_PER_MONTH = (35 * 52) / 12;
7
+ exports.CHALLENGER_FORMULAS = [
8
+ { value: "smic_hourly", label: "SMIC horaire" },
9
+ {
10
+ value: "smic_monthly_35h",
11
+ label: "SMIC mensuel — 35h (151,67 h × SMIC horaire)",
12
+ },
13
+ {
14
+ value: "smic_monthly_custom",
15
+ label: "SMIC mensuel personnalisé",
16
+ paramLabel: "Nombre d'heures / semaine",
17
+ },
18
+ { value: "smic_annual", label: "SMIC annuel" },
19
+ {
20
+ value: "smic_monthly_percent",
21
+ label: "% du SMIC mensuel",
22
+ paramLabel: "Pourcentage (%)",
23
+ },
24
+ {
25
+ value: "smic_monthly_multiple",
26
+ label: "Multiple du SMIC mensuel",
27
+ paramLabel: "Facteur (multiplicateur)",
28
+ },
29
+ ];
30
+ const CHALLENGER_FORMULA_VALUES = exports.CHALLENGER_FORMULAS.map(({ value }) => value);
31
+ const isChallengerFormula = (value) => !!value && CHALLENGER_FORMULA_VALUES.includes(value);
32
+ exports.isChallengerFormula = isChallengerFormula;
33
+ function computeChallengerReference(formula, parameter, smicHourly) {
34
+ const param = parameter ? parseFloat(parameter) : NaN;
35
+ switch (formula) {
36
+ case "smic_hourly":
37
+ return smicHourly;
38
+ case "smic_monthly_35h":
39
+ return smicHourly * exports.HOURS_PER_MONTH;
40
+ case "smic_monthly_custom":
41
+ return isNaN(param) ? 0 : smicHourly * ((param * 52) / 12);
42
+ case "smic_annual":
43
+ return smicHourly * exports.HOURS_PER_MONTH * 12;
44
+ case "smic_monthly_percent":
45
+ return isNaN(param) ? 0 : smicHourly * exports.HOURS_PER_MONTH * (param / 100);
46
+ case "smic_monthly_multiple":
47
+ return isNaN(param) ? 0 : smicHourly * exports.HOURS_PER_MONTH * param;
48
+ }
49
+ }
50
+ function formatChallengerEur(value) {
51
+ return (new Intl.NumberFormat("fr-FR", {
52
+ minimumFractionDigits: 2,
53
+ maximumFractionDigits: 2,
54
+ }).format(value) + " €");
55
+ }
package/build/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from "./icons/themes";
4
4
  export * from "./icons/ThemeIcons";
5
5
  export * from "./idcc";
6
6
  export * from "./naf";
7
+ export * from "./challenger.utils";
package/build/index.js CHANGED
@@ -20,3 +20,4 @@ __exportStar(require("./icons/themes"), exports);
20
20
  __exportStar(require("./icons/ThemeIcons"), exports);
21
21
  __exportStar(require("./idcc"), exports);
22
22
  __exportStar(require("./naf"), exports);
23
+ __exportStar(require("./challenger.utils"), exports);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
7
- "version": "4.228.2",
7
+ "version": "4.229.0",
8
8
  "main": "build/index.js",
9
9
  "module": "build/index.js",
10
10
  "types": "build/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "pnpm format"
56
56
  ]
57
57
  },
58
- "gitHead": "9b2ff47373827bf9af7a16c6e3553294d8e352e5"
58
+ "gitHead": "0454f6d91d5c490d5822366a286e5a9176597d50"
59
59
  }