@getsoren/shared-module 2.68.0 → 2.69.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.
Files changed (32) hide show
  1. package/README.md +15 -0
  2. package/dist/documentImport/index.d.ts +9 -0
  3. package/dist/documentImport/types.d.ts +127 -0
  4. package/dist/documentImport/utils/matching/matching.d.ts +144 -0
  5. package/dist/documentImport/utils/matching/matching.test.d.ts +1 -0
  6. package/dist/documentImport/utils/proposals/proposals.d.ts +10 -0
  7. package/dist/documentImport/utils/proposals/proposals.test.d.ts +1 -0
  8. package/dist/documentImport/utils/reading/reading.d.ts +26 -0
  9. package/dist/documentImport/utils/reading/reading.test.d.ts +1 -0
  10. package/dist/documentImport.js +202 -0
  11. package/dist/hourSheets/constants.d.ts +33 -0
  12. package/dist/hourSheets/index.d.ts +13 -0
  13. package/dist/hourSheets/types.d.ts +143 -0
  14. package/dist/hourSheets/utils/billingReferences/billingReferences.d.ts +35 -0
  15. package/dist/hourSheets/utils/billingReferences/billingReferences.test.d.ts +1 -0
  16. package/dist/hourSheets/utils/imputation/imputation.d.ts +44 -0
  17. package/dist/hourSheets/utils/imputation/imputation.test.d.ts +1 -0
  18. package/dist/hourSheets/utils/readCostCentres/readCostCentres.d.ts +42 -0
  19. package/dist/hourSheets/utils/readCostCentres/readCostCentres.test.d.ts +1 -0
  20. package/dist/hourSheets/utils/sheetBlocker/sheetBlocker.d.ts +53 -0
  21. package/dist/hourSheets/utils/sheetBlocker/sheetBlocker.test.d.ts +1 -0
  22. package/dist/hourSheets/utils/sheetDays/sheetDays.d.ts +68 -0
  23. package/dist/hourSheets/utils/sheetDays/sheetDays.test.d.ts +1 -0
  24. package/dist/hourSheets/utils/sheetLines/sheetLines.d.ts +103 -0
  25. package/dist/hourSheets/utils/sheetLines/sheetLines.test.d.ts +1 -0
  26. package/dist/hourSheets.js +58 -0
  27. package/dist/main.js +339 -375
  28. package/dist/operator-Cj1X_Zg5.js +41 -0
  29. package/dist/orval.js +1 -1
  30. package/dist/sheetLines-DzQEyJOO.js +123 -0
  31. package/package.json +16 -1
  32. /package/dist/{orval-Bf_zcxLE.js → orval-BSFwOlVR.js} +0 -0
@@ -0,0 +1,41 @@
1
+ //#region src/utils/adapter/articleNameAdapter/articleNameAdapter.ts
2
+ var e = String.raw`(?:chauffeur|conducteur|op[ée]rateur|machiniste|driver|operator)`, t = String.raw`(?:(?:avec|with|incl(?:\.|uding|us)?|y\s+compris)\s+|\+\s*)(?:(?:un|une|le|la|son|sa|an?|the|its)\s+)?`, n = String.raw`(?:\s+(?:inclus|compris|included))?`, r = String.raw`(?:(?:(?:à\s+la|par|per|by\s+the|tarif)\s+)?(jours?|journ[ée]es?|journalier|days?)|(?:(?:à\s+l['’]\s*|(?:par|per|by\s+the|tarif)\s+))?(heures?|horaire|hours?))`, i = String.raw`(?:\s*[-–—,/·:]?\s*${r}|\s*\(\s*${r}\s*\))?`, a = String.raw`(?:(?:location|rental|rented)\s+)?(?:${t}${e}${n}|${e}\s+(?:inclus|compris|included))${i}`, o = new RegExp(String.raw`\s*[[(]\s*${a}\s*[\])]`, "giu"), s = new RegExp(String.raw`(?:^|[\s,;:/|–—-])\s*${a}\s*$`, "iu"), c = /[\s,;:/|–—-]+$/u, l = ([e]) => {
3
+ let t = e.replace(/^[\s,;:/|–—-]+/u, "").trim(), n = (/^[[(]/u.test(t) ? t.slice(1, -1) : t).trim().replace(/\s+/g, " ");
4
+ return n.charAt(0).toLocaleUpperCase() + n.slice(1);
5
+ }, u = (e) => e[1] || e[3] ? "days" : e[2] || e[4] ? "hours" : void 0, d = (e, { readDriver: t = !0 } = {}) => {
6
+ if (typeof e != "string") return {
7
+ label: "",
8
+ withDriver: !1
9
+ };
10
+ if (!t) return {
11
+ label: e.trim(),
12
+ withDriver: !1
13
+ };
14
+ let n = e.normalize("NFC"), r = [...n.matchAll(o)], i = n.replace(o, ""), a = i.match(s), d = a ? i.slice(0, a.index) : i;
15
+ if (d === n) return {
16
+ label: e.trim(),
17
+ withDriver: !1
18
+ };
19
+ let f = d.replace(c, "").replace(/\s{2,}/g, " ").trim(), p = [...r, ...a ? [a] : []], m = p.map(u).find(Boolean), h = l(p[0]);
20
+ return f ? m ? {
21
+ driverMention: h,
22
+ driverUnit: m,
23
+ label: f,
24
+ withDriver: !0
25
+ } : {
26
+ driverMention: h,
27
+ label: f,
28
+ withDriver: !0
29
+ } : {
30
+ label: e.trim(),
31
+ withDriver: !1
32
+ };
33
+ }, f = "machine+operator", p = "HOURS", m = 8, h = 24, g = (e) => e?.withOperator ?? e?.type === f, _ = (e) => g(e) && d(e?.name).driverUnit !== "days", v = (e = []) => e.find((e) => y(e) || g(e.article)), y = ({ qtyUnit: e }) => e === p, b = ({ qtyUnit: e, quantity: t }) => y({ qtyUnit: e }) ? 1 : t || 1, x = (e) => {
34
+ let t = v(e?.items);
35
+ return t && y(t) && t.quantity ? t.quantity : void 0;
36
+ }, S = (e) => {
37
+ let t = v(e?.items);
38
+ return !!t && y(t) && t.unitPrice == null;
39
+ };
40
+ //#endregion
41
+ export { b as a, S as c, x as i, _ as l, h as n, y as o, v as r, g as s, m as t, d as u };
package/dist/orval.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./orval-Bf_zcxLE.js";
1
+ import { t as e } from "./orval-BSFwOlVR.js";
2
2
  import { execSync as t } from "child_process";
3
3
  import { existsSync as n } from "fs";
4
4
  //#region src/orval/resolveOrvalInput.ts
@@ -0,0 +1,123 @@
1
+ import { roundToHundredths as e, toNumberOrNull as t } from "@getsoren/react-utils";
2
+ //#region src/hourSheets/constants.ts
3
+ var n = "HOUR_SHEET", r = "plan_de_compte", i = "centre_de_cout", a = "billing_reference", o = [
4
+ i,
5
+ "code_tache",
6
+ "sous_livre",
7
+ "divers"
8
+ ], s = "overtime", c = 24, l = 31, u = (e, t) => Object.fromEntries(t.flatMap((t) => {
9
+ let n = e?.[t], r = e?.[`${t}_display`];
10
+ return !(typeof n == "string" || typeof n == "number") || n === "" ? [] : [[t, {
11
+ label: typeof r == "string" && r ? r : String(n),
12
+ value: String(n)
13
+ }]];
14
+ })), d = (e) => Object.fromEntries(Object.entries(e).flatMap(([e, { value: t }]) => t ? [[e, t]] : [])), f = (e, t) => {
15
+ let n = d(e), r = d(t);
16
+ return Object.keys({
17
+ ...n,
18
+ ...r
19
+ }).every((e) => n[e] === r[e]);
20
+ }, p = (e, t) => ({
21
+ ...t,
22
+ ...e
23
+ }), m = ({ imputation: e, unreadCostCentre: t }, n) => {
24
+ let { [i]: r, [a]: o, ...s } = n;
25
+ return p(e, t && !e.centre_de_cout ? s : n);
26
+ }, h = ({ [a]: e, ...t }) => t, g = (e, { index: t, field: n, value: r }, a = {}) => {
27
+ let o = (e) => p(e.imputation, a)[i]?.value, s = e[t] ? o(e[t]) : void 0, c = (e) => n !== "billing_reference" || o(e) === s;
28
+ return e.map((e, i) => {
29
+ if (i !== t && !(c(e) && !p(e.imputation, a)[n]?.value)) return e;
30
+ let o = n === "centre_de_cout" ? h(e.imputation) : e.imputation;
31
+ return {
32
+ ...e,
33
+ imputation: {
34
+ ...o,
35
+ [n]: r
36
+ }
37
+ };
38
+ });
39
+ }, _ = (t) => e(t.reduce((e, { hours: t }) => e + t, 0)), v = (t) => e(t.reduce((e, { hours: t }) => e + (t ?? 0), 0)), y = (e, t) => e.find((e) => e.date === t)?.imputation ?? {}, b = (e) => e != null && e > 0, x = ({ hours: e, rate: t }) => b(e) && b(t), S = (e, t = !0) => t ? x(e) : b(e.hours), C = (e, t = !0) => !S(e, t), w = (t) => x(t) ? e(Number(t.hours) * Number(t.rate)) : null, T = ({ [r]: e, ...t }) => t, E = ({ chart: e, days: t, overtimes: n }, { bookingItemId: i, orderImputation: a, storedLineIds: o = [], isOvertimeBilled: c = !0 }) => {
40
+ let { [r]: l, ...u } = a, d = e ?? l, p = (e) => {
41
+ let t = {
42
+ ...m(e, u),
43
+ ...d && { plan_de_compte: d }
44
+ };
45
+ return f(t, a) ? {} : t;
46
+ }, h = (e) => o.includes(e) ? e : void 0;
47
+ return [...t.filter(({ hours: e }) => e > 0).map(({ date: e, hours: t, id: n, imputation: r, source: a, unreadCostCentre: o }) => ({
48
+ bookingItemId: i,
49
+ date: e,
50
+ id: h(n),
51
+ imputation: p({
52
+ imputation: r,
53
+ unreadCostCentre: o
54
+ }),
55
+ qtyUnit: "HOURS",
56
+ quantity: t,
57
+ source: a
58
+ })), ...n.filter((e) => S(e, c)).map(({ date: e, hours: t, id: n, imputation: r, rate: a, source: o }) => ({
59
+ ...c && {
60
+ amount: w({
61
+ hours: t,
62
+ rate: a
63
+ }),
64
+ unitPrice: a
65
+ },
66
+ bookingItemId: i,
67
+ date: e,
68
+ id: h(n),
69
+ imputation: p({ imputation: r }),
70
+ label: s,
71
+ qtyUnit: "HOURS",
72
+ quantity: t,
73
+ source: o
74
+ }))];
75
+ }, D = (e) => e.map((e) => e.imputation.centre_de_cout ? e : {
76
+ ...e,
77
+ imputation: h(e.imputation)
78
+ }), O = (e) => e.map((e) => {
79
+ let { [i]: t, ...n } = e.imputation;
80
+ return {
81
+ ...e,
82
+ imputation: h(n)
83
+ };
84
+ }), k = (e, { chart: t, costCentres: n } = {
85
+ chart: null,
86
+ costCentres: {}
87
+ }) => ({
88
+ chart: e.some(({ costCentre: e }) => e && n[e]) ? t : null,
89
+ days: e.filter(({ hours: e }) => e > 0).map(({ costCentre: e, date: t, hours: r }, a) => {
90
+ let o = e ? n[e] : void 0;
91
+ return {
92
+ date: t,
93
+ hours: r,
94
+ id: `read-${a}`,
95
+ imputation: o ? { [i]: o } : {},
96
+ source: "read",
97
+ ...e && !o && { unreadCostCentre: e }
98
+ };
99
+ }),
100
+ overtimes: []
101
+ }), A = (e) => ({
102
+ chart: e.map(({ imputation: e }) => e.plan_de_compte).find(Boolean) ?? null,
103
+ days: e.flatMap(({ date: e, id: n, imputation: r, label: i, qtyUnit: a, quantity: o, source: s }) => {
104
+ let c = t(o);
105
+ return e && c != null && a === "HOURS" && !i ? [{
106
+ date: e,
107
+ hours: c,
108
+ id: n,
109
+ imputation: T(r),
110
+ source: s
111
+ }] : [];
112
+ }).sort((e, t) => e.date.localeCompare(t.date)),
113
+ overtimes: e.flatMap(({ amount: e, date: n, id: r, imputation: i, label: a, qtyUnit: o, quantity: s, source: c, unitPrice: l }) => n && a === "overtime" ? [{
114
+ date: n,
115
+ hours: o === "HOURS" ? t(s) : null,
116
+ id: r,
117
+ imputation: T(i),
118
+ rate: t(l) ?? t(e),
119
+ source: c
120
+ }] : [])
121
+ });
122
+ //#endregion
123
+ export { n as C, s as D, l as E, i as S, c as T, u as _, v as a, a as b, E as c, O as d, D as f, m as g, f as h, w as i, A as l, d as m, x as n, y as o, p, S as r, _ as s, C as t, k as u, g as v, o as w, r as x, h as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.68.0",
3
+ "version": "2.69.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",
@@ -14,11 +14,21 @@
14
14
  "import": "./dist/main.js",
15
15
  "default": "./dist/main.js"
16
16
  },
17
+ "./documentImport": {
18
+ "types": "./dist/documentImport/index.d.ts",
19
+ "import": "./dist/documentImport.js",
20
+ "default": "./dist/documentImport.js"
21
+ },
17
22
  "./events": {
18
23
  "types": "./dist/events/index.d.ts",
19
24
  "import": "./dist/events.js",
20
25
  "default": "./dist/events.js"
21
26
  },
27
+ "./hourSheets": {
28
+ "types": "./dist/hourSheets/index.d.ts",
29
+ "import": "./dist/hourSheets.js",
30
+ "default": "./dist/hourSheets.js"
31
+ },
22
32
  "./orval": {
23
33
  "types": "./dist/orval/index.d.ts",
24
34
  "import": "./dist/orval.js",
@@ -49,6 +59,7 @@
49
59
  "@amplitude/plugin-session-replay-browser": "^1.8.0",
50
60
  "@getsoren/biome-config-react": "^1.4.0",
51
61
  "@getsoren/react-google-tag-manager": "^1.4.6",
62
+ "@getsoren/react-utils": "^1.40.0",
52
63
  "@sentry/react": "^10.49.0",
53
64
  "@tanstack/react-query": "^5.99.2",
54
65
  "@testing-library/jest-dom": "^5.17.0",
@@ -74,6 +85,7 @@
74
85
  },
75
86
  "peerDependencies": {
76
87
  "axios": "*",
88
+ "@getsoren/react-utils": "^1.40.0",
77
89
  "@amplitude/analytics-browser": "*",
78
90
  "@amplitude/plugin-session-replay-browser": "*",
79
91
  "@sentry/react": "*",
@@ -88,6 +100,9 @@
88
100
  "react-router": "^7.0.0"
89
101
  },
90
102
  "peerDependenciesMeta": {
103
+ "@getsoren/react-utils": {
104
+ "optional": true
105
+ },
91
106
  "@amplitude/analytics-browser": {
92
107
  "optional": true
93
108
  },
File without changes