@getsoren/shared-module 2.68.0 → 2.69.1
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/README.md +15 -0
- package/dist/documentImport.js +202 -0
- package/dist/events.js +1 -1
- package/dist/hourSheets.js +58 -0
- package/dist/main.d.ts +6 -6
- package/dist/main.js +512 -548
- package/dist/{context → modules/chat/context}/ChatProvider.d.ts +1 -1
- package/dist/{hooks → modules/chat/hooks}/useChat.d.ts +1 -1
- package/dist/modules/documentImport/index.d.ts +9 -0
- package/dist/modules/documentImport/types.d.ts +127 -0
- package/dist/modules/documentImport/utils/matching/matching.d.ts +144 -0
- package/dist/modules/documentImport/utils/proposals/proposals.d.ts +10 -0
- package/dist/modules/documentImport/utils/reading/reading.d.ts +26 -0
- package/dist/modules/events/utils/payload/payload.test.d.ts +1 -0
- package/dist/modules/events/utils/readEvent/readEvent.test.d.ts +1 -0
- package/dist/modules/events/utils/steps/steps.test.d.ts +1 -0
- package/dist/modules/hourSheets/constants.d.ts +33 -0
- package/dist/modules/hourSheets/index.d.ts +13 -0
- package/dist/modules/hourSheets/types.d.ts +143 -0
- package/dist/modules/hourSheets/utils/billingReferences/billingReferences.d.ts +35 -0
- package/dist/modules/hourSheets/utils/billingReferences/billingReferences.test.d.ts +1 -0
- package/dist/modules/hourSheets/utils/imputation/imputation.d.ts +44 -0
- package/dist/modules/hourSheets/utils/imputation/imputation.test.d.ts +1 -0
- package/dist/modules/hourSheets/utils/readCostCentres/readCostCentres.d.ts +42 -0
- package/dist/modules/hourSheets/utils/readCostCentres/readCostCentres.test.d.ts +1 -0
- package/dist/modules/hourSheets/utils/sheetBlocker/sheetBlocker.d.ts +53 -0
- package/dist/modules/hourSheets/utils/sheetBlocker/sheetBlocker.test.d.ts +1 -0
- package/dist/modules/hourSheets/utils/sheetDays/sheetDays.d.ts +68 -0
- package/dist/modules/hourSheets/utils/sheetDays/sheetDays.test.d.ts +1 -0
- package/dist/modules/hourSheets/utils/sheetLines/sheetLines.d.ts +103 -0
- package/dist/modules/hourSheets/utils/sheetLines/sheetLines.test.d.ts +1 -0
- package/dist/operator-Cj1X_Zg5.js +41 -0
- package/dist/orval.js +1 -1
- package/dist/sheetLines-DECsEz55.js +123 -0
- package/package.json +17 -2
- /package/dist/{chat → modules/chat}/ChatClient.d.ts +0 -0
- /package/dist/{chat → modules/chat}/tests/ChatClient.test.d.ts +0 -0
- /package/dist/{chat → modules/chat}/types.d.ts +0 -0
- /package/dist/{events/hooks/useEventDeclaration/useEventDeclaration.test.d.ts → modules/documentImport/utils/matching/matching.test.d.ts} +0 -0
- /package/dist/{events/tenants/tenants.test.d.ts → modules/documentImport/utils/proposals/proposals.test.d.ts} +0 -0
- /package/dist/{events/utils/amounts/amounts.test.d.ts → modules/documentImport/utils/reading/reading.test.d.ts} +0 -0
- /package/dist/{events → modules/events}/catalog/clientEvents.d.ts +0 -0
- /package/dist/{events → modules/events}/catalog/supplierEvents.d.ts +0 -0
- /package/dist/{events → modules/events}/constants.d.ts +0 -0
- /package/dist/{events → modules/events}/hooks/useEventDeclaration/useEventDeclaration.d.ts +0 -0
- /package/dist/{events/utils/credits/credits.test.d.ts → modules/events/hooks/useEventDeclaration/useEventDeclaration.test.d.ts} +0 -0
- /package/dist/{events → modules/events}/index.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/ar.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/de.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/en.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/es.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/fr.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/it.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/locales.d.ts +0 -0
- /package/dist/{events → modules/events}/locales/pt.d.ts +0 -0
- /package/dist/{events → modules/events}/tenants/bouygues/bouygues.d.ts +0 -0
- /package/dist/{events → modules/events}/tenants/index.d.ts +0 -0
- /package/dist/{events/utils/lineFunnel/lineFunnel.test.d.ts → modules/events/tenants/tenants.test.d.ts} +0 -0
- /package/dist/{events → modules/events}/types.d.ts +0 -0
- /package/dist/{events → modules/events}/utils/amounts/amounts.d.ts +0 -0
- /package/dist/{events/utils/payload/payload.test.d.ts → modules/events/utils/amounts/amounts.test.d.ts} +0 -0
- /package/dist/{events → modules/events}/utils/credits/credits.d.ts +0 -0
- /package/dist/{events/utils/readEvent/readEvent.test.d.ts → modules/events/utils/credits/credits.test.d.ts} +0 -0
- /package/dist/{events → modules/events}/utils/lineFunnel/lineFunnel.d.ts +0 -0
- /package/dist/{events/utils/steps/steps.test.d.ts → modules/events/utils/lineFunnel/lineFunnel.test.d.ts} +0 -0
- /package/dist/{events → modules/events}/utils/payload/payload.d.ts +0 -0
- /package/dist/{events → modules/events}/utils/readEvent/readEvent.d.ts +0 -0
- /package/dist/{events → modules/events}/utils/steps/steps.d.ts +0 -0
- /package/dist/{orval-Bf_zcxLE.js → orval-BSFwOlVR.js} +0 -0
package/README.md
CHANGED
|
@@ -210,6 +210,21 @@ input: "./openapi.json"
|
|
|
210
210
|
| getOrvalConfig | Build the orval config (input resolution included) |
|
|
211
211
|
| resolveOrvalInput | Standalone schema target resolution (local file → local → upstream) |
|
|
212
212
|
|
|
213
|
+
## Hour sheets and document import
|
|
214
|
+
|
|
215
|
+
Two entry points hold the rules the back office and the mobile app share, as pure functions with their tests; each app
|
|
216
|
+
keeps only its screens. They need `@getsoren/react-utils` and `dayjs`.
|
|
217
|
+
|
|
218
|
+
| Entry point | Holds |
|
|
219
|
+
|------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
|
|
220
|
+
| `@getsoren/shared-module/hourSheets` | A driver's hour sheet: its days and overtime, the document lines they state, their imputation, what blocks a save |
|
|
221
|
+
| `@getsoren/shared-module/documentImport` | What the assistant read on a document (facts, an hour sheet's days) and the order the document is matched to |
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { extendedRentalOf, sheetLinesOf } from "@getsoren/shared-module/hourSheets";
|
|
225
|
+
import { candidateOf, factsOfAnalysis, matchesOf } from "@getsoren/shared-module/documentImport";
|
|
226
|
+
```
|
|
227
|
+
|
|
213
228
|
## Utils function
|
|
214
229
|
| Module | Description |
|
|
215
230
|
|---------------------|----------------------------------------------------------------------------------------|
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { s as e } from "./operator-Cj1X_Zg5.js";
|
|
2
|
+
import { s as t } from "./sheetLines-DECsEz55.js";
|
|
3
|
+
import { normalizeSearch as n, roundToHundredths as r, toNumberOrNull as i } from "@getsoren/react-utils";
|
|
4
|
+
import a from "dayjs";
|
|
5
|
+
//#region src/modules/documentImport/utils/matching/matching.ts
|
|
6
|
+
var o = {
|
|
7
|
+
dateMet: 2,
|
|
8
|
+
machineFamily: 1,
|
|
9
|
+
machineMet: 3,
|
|
10
|
+
machineMismatch: -3,
|
|
11
|
+
periodMismatch: -3,
|
|
12
|
+
supplierMet: 3,
|
|
13
|
+
supplierMismatch: -4,
|
|
14
|
+
worksiteMet: 2,
|
|
15
|
+
worksiteMismatch: -3
|
|
16
|
+
}, s = 6, ee = /^(livraison|reprise|transport|enlevement)\b/, c = [
|
|
17
|
+
"acces industrie",
|
|
18
|
+
"boels",
|
|
19
|
+
"hertz",
|
|
20
|
+
"kiloutou",
|
|
21
|
+
"loxam",
|
|
22
|
+
"mediaco",
|
|
23
|
+
"ramirent",
|
|
24
|
+
"salti"
|
|
25
|
+
], l = [
|
|
26
|
+
["miniExcavator", /\b(mini ?pelles?|minipelles?)\b/],
|
|
27
|
+
["backhoeLoader", /\btractopelles?\b/],
|
|
28
|
+
["excavator", /\bpelles?\b/],
|
|
29
|
+
["aerialPlatform", /\bnacelles?\b/],
|
|
30
|
+
["forklift", /\b(chariots?|telescopiques?|manitou)\b/],
|
|
31
|
+
["compactor", /\b(compacteurs?|cylindres?|plaques? vibrantes?)\b/],
|
|
32
|
+
["loader", /\bchargeuses?\b/],
|
|
33
|
+
["dumper", /\b(dumpers?|tombereaux?)\b/],
|
|
34
|
+
["crane", /\bgrues?\b/],
|
|
35
|
+
["truck", /\b(camions?|porteurs?)\b/],
|
|
36
|
+
["generator", /\bgroupes? electrogenes?\b/]
|
|
37
|
+
], u = (e) => n(e ?? "").replace(/[^a-z0-9]+/g, " ").trim(), d = (e) => e?.slice(0, 10) || void 0, f = (e) => {
|
|
38
|
+
let t = e.items.find(({ articleName: e }) => !ee.test(u(e))) ?? e.items[0];
|
|
39
|
+
return {
|
|
40
|
+
articleImage: t?.image,
|
|
41
|
+
articleName: t?.articleName,
|
|
42
|
+
fromDate: d(e.fromDate ?? t?.fromDate),
|
|
43
|
+
id: e.id,
|
|
44
|
+
supplierLogo: t?.supplier?.logo,
|
|
45
|
+
supplierName: t?.supplier?.name,
|
|
46
|
+
toDate: d(e.toDate ?? t?.toDate),
|
|
47
|
+
worksiteName: e.worksite?.name
|
|
48
|
+
};
|
|
49
|
+
}, te = ({ fromDate: e, id: t, items: n, toDate: r }) => ({
|
|
50
|
+
articleImage: n[0]?.image,
|
|
51
|
+
articleName: n[0]?.name ?? void 0,
|
|
52
|
+
fromDate: d(e),
|
|
53
|
+
id: t,
|
|
54
|
+
toDate: d(r)
|
|
55
|
+
}), p = (e) => e.split(/\s[-–]\s/)[0], m = (e) => {
|
|
56
|
+
let t = u(p(e ?? ""));
|
|
57
|
+
if (t) return c.find((e) => t === e || t.startsWith(`${e} `)) ?? t.split(" ")[0];
|
|
58
|
+
}, h = (e) => [...new Set([e.trim(), e.split(/\s[-–]\s/)[0].trim()])].filter(Boolean), g = (e, t) => {
|
|
59
|
+
let n = t.filter((e, n) => t.findIndex(({ id: t }) => t === e.id) === n);
|
|
60
|
+
return h(e).flatMap((e) => n.filter((t) => u(t.name) === u(e)))[0] ?? (n.length === 1 ? n[0] : void 0);
|
|
61
|
+
}, _ = /\b(s a r l|sarl|s a s u|sasu|s a s|sas|e u r l|eurl|s c i|sci|s n c|snc|soc(?:iete)?(?: a responsabilite limitee| anonyme| par actions simplifiee)?|ste|ets|etablissements?)\b/g, v = [
|
|
62
|
+
"btp",
|
|
63
|
+
"groupe",
|
|
64
|
+
"loc",
|
|
65
|
+
"location",
|
|
66
|
+
"locations",
|
|
67
|
+
"publics",
|
|
68
|
+
"services",
|
|
69
|
+
"tp",
|
|
70
|
+
"transport",
|
|
71
|
+
"transports",
|
|
72
|
+
"travaux"
|
|
73
|
+
], y = (e) => u(p(e ?? "")).replace(_, " ").split(" ").filter(Boolean), ne = (e) => [...y(e)].filter((e) => !v.includes(e)).sort((e, t) => t.length - e.length)[0] ?? e.trim(), b = (e, t) => {
|
|
74
|
+
let n = y(e), r = y(t);
|
|
75
|
+
if (n.length === 0 || r.length === 0) return;
|
|
76
|
+
let i = [n, r].map((e) => c.find((t) => e.join(" ").startsWith(t)));
|
|
77
|
+
if (i[0] || i[1]) return i[0] === i[1];
|
|
78
|
+
let [a, o] = n.length <= r.length ? [n, r] : [r, n];
|
|
79
|
+
return a.every((e) => o.includes(e)) && a.some((e) => !v.includes(e));
|
|
80
|
+
}, x = (e) => l.find(([, t]) => t.test(u(e)))?.[0], S = (e) => i((e ?? "").toLowerCase().replace(/(\d),(\d)/g, "$1.$2").match(/(\d+(?:\.\d+)?)\s*(?:t|tonnes?)\b/)?.[1]) ?? void 0, C = (e, t) => {
|
|
81
|
+
let n = x(e), r = x(t);
|
|
82
|
+
if (!(n && r)) return "unknown";
|
|
83
|
+
if (n !== r) return "different";
|
|
84
|
+
let i = S(e), a = S(t);
|
|
85
|
+
return i !== void 0 && a !== void 0 && Math.abs(i - a) > 1 ? "family" : "same";
|
|
86
|
+
}, w = (e, t) => {
|
|
87
|
+
let n = u(e).split(" ").filter(Boolean), r = t.flatMap((e) => u(e).split(" ")).filter((e) => e.length > 2);
|
|
88
|
+
return n.length > 0 && r.length > 0 && !n.some((e) => r.includes(e));
|
|
89
|
+
}, T = (e, t) => {
|
|
90
|
+
let n = C(e, t);
|
|
91
|
+
return n === "same" || n === "unknown" && !!u(e) && u(e) === u(t);
|
|
92
|
+
}, E = (e, t) => {
|
|
93
|
+
let n = u(e.clientName), r = u(t.clientName);
|
|
94
|
+
return b(O(e), O(t)) === !0 && T(e.machine, t.machine) && !(n && r && n !== r);
|
|
95
|
+
}, D = (e, t) => {
|
|
96
|
+
let n = new Set(u(e).split(" ").filter(Boolean)), r = new Set(u(t).split(" ").filter(Boolean));
|
|
97
|
+
return [...n].filter((e) => r.has(e)).length / Math.max(1, new Set([...n, ...r]).size);
|
|
98
|
+
}, re = ({ from: e, to: t }, n) => {
|
|
99
|
+
if (!(e && t && n.fromDate)) return;
|
|
100
|
+
let r = n.toDate ?? n.fromDate;
|
|
101
|
+
return t < n.fromDate ? a(n.fromDate).diff(t, "day") : e > r ? a(e).diff(r, "day") : 0;
|
|
102
|
+
}, ie = {
|
|
103
|
+
different: o.machineMismatch,
|
|
104
|
+
family: o.machineFamily,
|
|
105
|
+
same: o.machineMet,
|
|
106
|
+
unknown: 0
|
|
107
|
+
}, ae = ({ worksiteName: e }, t, n) => {
|
|
108
|
+
let r = u(e), i = u(t.worksiteName);
|
|
109
|
+
return n || r && r === i ? o.worksiteMet : r && i ? o.worksiteMismatch : 0;
|
|
110
|
+
}, O = ({ supplierName: e, orderSupplier: t }) => t?.name || e?.trim(), oe = (e, t) => {
|
|
111
|
+
let n = b(O(e), t.supplierName);
|
|
112
|
+
return n === void 0 ? 0 : n ? o.supplierMet : o.supplierMismatch;
|
|
113
|
+
}, k = 7, A = (e) => e === 0 ? o.dateMet : e === void 0 || e <= k ? 0 : o.periodMismatch, j = (e, t, { worksiteId: n }) => {
|
|
114
|
+
let r = re(e, t);
|
|
115
|
+
return {
|
|
116
|
+
candidate: t,
|
|
117
|
+
distanceDays: r ?? Infinity,
|
|
118
|
+
machineLikeness: e.machine && t.articleName ? D(e.machine, t.articleName) : 0,
|
|
119
|
+
score: ae(e, t, n) + oe(e, t) + ie[C(e.machine, t.articleName)] + A(r)
|
|
120
|
+
};
|
|
121
|
+
}, M = (e, t, n) => t.map((t) => j(e, t, n)).filter(({ score: e }) => e >= 6).sort((e, t) => t.score - e.score || t.machineLikeness - e.machineLikeness || e.distanceDays - t.distanceDays || (t.candidate.fromDate ?? "").localeCompare(e.candidate.fromDate ?? "")), N = (e, t) => {
|
|
122
|
+
let n = e.find(({ candidate: e }) => e.id === t?.candidate.id);
|
|
123
|
+
return n ? e.filter((e) => e.candidate.id !== n.candidate.id && e.score === n.score && e.machineLikeness === n.machineLikeness && e.distanceDays === n.distanceDays) : [];
|
|
124
|
+
}, P = (e, t, n) => M(e, t, n)[0], F = (e) => u(e).replace(/\b\d+(?:[ .]\d+)?\s*(?:t|tonnes?)\b/g, "").replace(/\s+/g, " ").trim(), I = (t, n, r) => {
|
|
125
|
+
let i = S(t), a = (r) => {
|
|
126
|
+
let a = e(r), o = i !== void 0 && S(r.name) === i;
|
|
127
|
+
return (a === n ? 4 : 0) + (o ? 2 : 0) + D(t, r.name);
|
|
128
|
+
};
|
|
129
|
+
return [...r].sort((e, t) => a(t) - a(e))[0];
|
|
130
|
+
}, L = (e, t) => t && !e.some(({ candidate: e }) => e.id === t.id) ? [...e, { candidate: t }] : e, R = "YYYY-MM-DD", z = /^\d{4}-\d{2}-\d{2}$/, B = (e) => typeof e == "string" && z.test(e) && a(e).format(R) === e, V = ["machine_delivery", "machine_retrieval"], H = "lines", U = (e) => e?.trim() || void 0, W = (e) => i(/^(\d+(?:\.\d+)?) hour$/.exec(e?.trim() ?? "")?.[1]) ?? void 0, G = (e) => {
|
|
131
|
+
let t = e?.trim();
|
|
132
|
+
return B(t) ? t : void 0;
|
|
133
|
+
}, K = (e) => {
|
|
134
|
+
let [t, n, ...r] = e?.split("/").map((e) => G(e)) ?? [];
|
|
135
|
+
return t && n && r.length === 0 && t <= n ? {
|
|
136
|
+
from: t,
|
|
137
|
+
to: n
|
|
138
|
+
} : void 0;
|
|
139
|
+
}, q = ({ tables: e }) => e?.[H] ?? [], J = (e) => {
|
|
140
|
+
let n = q(e).flatMap((e) => {
|
|
141
|
+
let t = G(e.date), n = W(e.quantity);
|
|
142
|
+
return t && n !== void 0 && n <= 24 ? [{
|
|
143
|
+
costCentre: U(e.cost_centre),
|
|
144
|
+
date: t,
|
|
145
|
+
hours: n
|
|
146
|
+
}] : [];
|
|
147
|
+
}), i = (e, t) => e.date === t.date && e.costCentre === t.costCentre;
|
|
148
|
+
return n.filter((e, t) => n.findIndex((t) => i(t, e)) === t).map((e) => ({
|
|
149
|
+
...e,
|
|
150
|
+
hours: r(t(n.filter((t) => i(t, e))))
|
|
151
|
+
})).sort((e, t) => e.date.localeCompare(t.date));
|
|
152
|
+
}, Y = (e) => q(e).flatMap((e) => {
|
|
153
|
+
let t = W(e.quantity);
|
|
154
|
+
return U(e.date) || t === void 0 ? [] : [{
|
|
155
|
+
costCentre: U(e.cost_centre),
|
|
156
|
+
equipment: U(e.equipment),
|
|
157
|
+
hours: t,
|
|
158
|
+
orderNumber: U(e.order_number),
|
|
159
|
+
period: K(e.period),
|
|
160
|
+
place: U(e.place),
|
|
161
|
+
taskCode: U(e.task_code)
|
|
162
|
+
}];
|
|
163
|
+
}), se = (e) => {
|
|
164
|
+
let n = W(e.fields?.written_total), r = [...J(e), ...Y(e)];
|
|
165
|
+
return n === void 0 ? r.length > 0 ? t(r) : void 0 : n;
|
|
166
|
+
}, X = (e) => e.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim(), Z = (e, t) => {
|
|
167
|
+
let n = X(e), r = X(t);
|
|
168
|
+
return n.includes(r) || r.includes(n);
|
|
169
|
+
}, ce = /\b(livraison|amenee|aller|acheminement|delivery)\b/, le = /\b(reprise|repli|retour|enlevement|pickup|pick up|collection)\b/, ue = /\b(transport|transports|transfert)\b/, Q = (e) => {
|
|
170
|
+
let t = X(e), n = ce.test(t), r = le.test(t), i = !(n || r) && ue.test(t);
|
|
171
|
+
return V.filter((e) => e === "machine_delivery" ? n || i : r || i);
|
|
172
|
+
}, $ = (e) => [e.fields?.equipment, ...q(e).map((e) => e.equipment)].flatMap((e) => U(e) ?? []), de = (e) => {
|
|
173
|
+
let t = $(e).filter((e) => Q(e).length === 0), n = t.filter((e, n) => t.findIndex((t) => Z(t, e)) === n), r = U([e.fields?.machine_brand, e.fields?.model].filter(Boolean).join(" "));
|
|
174
|
+
return n.length > 0 ? n : r ? [r] : [];
|
|
175
|
+
}, fe = (e) => {
|
|
176
|
+
let t = e.fields ?? {}, n = q(e).flatMap((e) => {
|
|
177
|
+
let t = K(e.period);
|
|
178
|
+
return [
|
|
179
|
+
G(e.date),
|
|
180
|
+
t?.from,
|
|
181
|
+
t?.to
|
|
182
|
+
].flatMap((e) => e ?? []);
|
|
183
|
+
}).sort(), r = K(t.period), i = G(t.issue_date), [a, ...o] = de(e), s = V.filter((t) => $(e).some((e) => Q(e).includes(t)));
|
|
184
|
+
return {
|
|
185
|
+
clientName: U(t.client),
|
|
186
|
+
from: n[0] ?? r?.from ?? i,
|
|
187
|
+
hours: se(e),
|
|
188
|
+
machine: a,
|
|
189
|
+
operatorName: U(t.driver),
|
|
190
|
+
otherLines: o.length > 0 ? o.map((e, t) => ({
|
|
191
|
+
id: `read-${t + 1}`,
|
|
192
|
+
machine: e
|
|
193
|
+
})) : void 0,
|
|
194
|
+
supplierName: U(t.supplier),
|
|
195
|
+
to: n.at(-1) ?? r?.to ?? i,
|
|
196
|
+
transports: s.length > 0 ? s : void 0,
|
|
197
|
+
worksiteName: U(t.worksite),
|
|
198
|
+
writtenHours: W(t.written_total)
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
//#endregion
|
|
202
|
+
export { s as MIN_MATCH_SCORE, V as TRANSPORT_TYPES, P as bestMatchOf, m as brandOf, f as candidateOf, te as candidateOfSearch, p as companyNameOf, J as daysOfAnalysis, fe as factsOfAnalysis, w as isAddressedElsewhere, E as isSameRental, b as isSameSupplier, F as machineSearchOf, M as matchesOf, L as proposalsOf, I as rentalArticleFor, N as rivalsOf, j as scoreOf, ne as supplierSearchOf, y as supplierWordsOf, S as tonnageOf, Q as transportTypesOf, Y as undatedHoursOfAnalysis, g as worksiteOfName, h as worksiteSearchesOf };
|
package/dist/events.js
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { C as e, D as t, E as n, S as r, T as i, _ as a, a as o, b as s, c, d as l, f as u, g as d, h as f, i as p, l as m, m as h, n as g, o as _, p as v, r as y, s as b, t as x, u as S, v as C, w, x as T, y as E } from "./sheetLines-DECsEz55.js";
|
|
2
|
+
import D from "dayjs";
|
|
3
|
+
//#region src/modules/hourSheets/utils/billingReferences/billingReferences.ts
|
|
4
|
+
var O = "active", k = (e) => e.filter(({ status: e }) => e === O).map(({ id: e, reference: t }) => ({
|
|
5
|
+
label: t,
|
|
6
|
+
value: e
|
|
7
|
+
})), A = (e) => e.length > 1, j = (e, t) => A(e) && !e.some(({ value: e }) => e === t?.value), M = ({ days: e, overtimes: t }, n, i) => [...e.filter(({ hours: e }) => e > 0), ...t].some((e) => {
|
|
8
|
+
let { [s]: t, [r]: a } = v(e.imputation, n);
|
|
9
|
+
return !!a?.value && j(i(a.value), t);
|
|
10
|
+
}), N = ({ days: e, overtimes: t }, n, i) => [...e, ...t].some((e) => {
|
|
11
|
+
let t = v(e.imputation, n)[r]?.value;
|
|
12
|
+
return !!t && A(i(t));
|
|
13
|
+
}), P = (e) => [...new Set(e.flatMap(({ costCentre: e }) => e ?? []))], F = (e) => e.match(/\d{5,}/)?.[0] ?? e.normalize("NFD").replace(/\p{Diacritic}/gu, "").trim(), I = (e, t, n) => {
|
|
14
|
+
let r = t.filter(({ found: e }) => e.length === 1), i = r.map(({ chart: e }) => e).filter((e, t, n) => n.findIndex(({ value: t }) => t === e.value) === t), a = (e) => r.filter(({ chart: t }) => t.value === e).length, o = i.find(({ value: e }) => e === n) ?? [...i].sort((e, t) => a(t.value) - a(e.value))[0] ?? null, s = Object.fromEntries(r.filter((e) => e.chart.value === o?.value).map(({ text: e, found: t }) => [e, t[0]]));
|
|
15
|
+
return {
|
|
16
|
+
chart: o,
|
|
17
|
+
costCentres: s,
|
|
18
|
+
unrecognized: e.filter((e) => !s[e])
|
|
19
|
+
};
|
|
20
|
+
}, L = ({ isRateMissing: e, hasRefusedDate: t, isExtensionTooLong: n = !1, isCheckingTakenDays: r, isTakenDaysError: i, hasTakenDay: a, isBillingReferenceMissing: o, isCostCentreMissing: s = !1, hasIncompleteOvertime: c = !1, isValid: l }) => e ? "rateMissing" : t ? "dateRefused" : n ? "extensionTooLong" : r ? "takenDaysChecking" : i ? "takenDaysError" : a ? "dayTaken" : s ? "costCentreMissing" : o ? "billingReferenceMissing" : c ? "overtimeIncomplete" : l ? void 0 : "incomplete", R = "YYYY-MM-DD", z = (e) => D(e).subtract((D(e).day() + 6) % 7, "day"), B = (e, { from: t, to: n }) => (!t || e >= t) && (!n || e <= n), V = ({ days: e, overtimes: t }, n) => [...e.filter(({ hours: e }) => e > 0), ...t].every(({ date: e }) => B(e, n)), H = ({ days: e, overtimes: t }, n) => {
|
|
21
|
+
let r = [...e.filter(({ hours: e }) => e > 0), ...t].map(({ date: e }) => e).sort(), i = r[0], a = r.at(-1);
|
|
22
|
+
if (!(!(i && a) || r.every((e) => B(e, n)))) return {
|
|
23
|
+
from: n.from && n.from < i ? n.from : i,
|
|
24
|
+
to: n.to && n.to > a ? n.to : a
|
|
25
|
+
};
|
|
26
|
+
}, U = (e, t) => {
|
|
27
|
+
let n = (e, t) => e && t ? D(t).diff(D(e), "day") : 0;
|
|
28
|
+
return !!t && (n(t.from, e.from) > 31 || n(e.to, t.to) > 31);
|
|
29
|
+
}, W = (e, t) => ({
|
|
30
|
+
from: e.from,
|
|
31
|
+
to: e.to && e.to < t ? e.to : t
|
|
32
|
+
}), G = (e, t, n = {}) => {
|
|
33
|
+
let r = [...e].sort(), i = z(r[0] ?? t), a = Array.from({ length: 7 }, (e, t) => i.add(t, "day").format(R)).find((t) => B(t, n) && !e.includes(t)), o = r.at(-1);
|
|
34
|
+
return a ?? (o ? D(o).add(1, "day").format(R) : t);
|
|
35
|
+
}, K = (e, t) => e.some(({ date: e }) => e === t.date) ? e : [...e, t].sort((e, t) => e.date.localeCompare(t.date)), q = (e, t, n) => {
|
|
36
|
+
let r = e.findLastIndex((e) => e.date === t);
|
|
37
|
+
return r < 0 ? e : [
|
|
38
|
+
...e.slice(0, r + 1),
|
|
39
|
+
{
|
|
40
|
+
date: t,
|
|
41
|
+
hours: 0,
|
|
42
|
+
id: n,
|
|
43
|
+
imputation: e[r].imputation,
|
|
44
|
+
source: "typed"
|
|
45
|
+
},
|
|
46
|
+
...e.slice(r + 1)
|
|
47
|
+
];
|
|
48
|
+
}, J = (e) => e.map(({ date: t }, n) => ({
|
|
49
|
+
dayHours: b(e.filter((e) => e.date === t)),
|
|
50
|
+
isFollowed: e[n + 1]?.date === t,
|
|
51
|
+
rank: e.slice(0, n).filter((e) => e.date === t).length
|
|
52
|
+
})), Y = (e, t, n) => e.some(({ date: e }) => e === n) ? e : e.map((e) => e.date === t ? {
|
|
53
|
+
...e,
|
|
54
|
+
date: n,
|
|
55
|
+
source: "typed"
|
|
56
|
+
} : e).sort((e, t) => e.date.localeCompare(t.date));
|
|
57
|
+
//#endregion
|
|
58
|
+
export { s as BILLING_REFERENCE_FIELD, T as CHART_OF_ACCOUNTS_FIELD, r as COST_CENTRE_FIELD, e as HOUR_SHEET_DOCUMENT_TYPE, w as IMPUTATION_FIELDS, i as MAX_HOURS_PER_DAY, n as MAX_RENTAL_EXTENSION_DAYS, t as OVERTIME_LABEL, k as activeBillingReferencesOf, V as areBilledDaysWithin, F as costCentreSearchOf, J as dayLinePlacesOf, H as extendedRentalOf, N as hasBillingReferenceChoice, M as hasMissingBillingReference, v as imputationOn, h as imputationValuesOf, A as isBillingReferenceChoice, j as isBillingReferenceMissing, U as isExtensionTooLong, x as isOvertimeIncomplete, g as isOvertimePriced, y as isOvertimeStated, f as isSameImputation, B as isWithin, d as lineImputationOn, G as nextFreeDayOf, a as orderImputationOf, p as overtimeAmountOf, o as overtimeHoursOf, _ as overtimeImputationOf, I as readCostCentresOf, L as sheetBlockerOf, W as sheetDayRangeOf, b as sheetHoursOf, c as sheetLinesOf, m as sheetOfLines, S as sheetOfReadDays, K as withDay, C as withDayImputation, q as withDayLine, Y as withDayMoved, E as withoutBillingReference, l as withoutCostCentres, u as withoutOrderBillingReferences, P as writtenCostCentresOf };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { default as ChatClient } from './chat/ChatClient';
|
|
2
|
-
export * from './chat/types';
|
|
3
1
|
export * from './components/Inputs/MaskTextField';
|
|
4
2
|
export { default as MaskTextField } from './components/Inputs/MaskTextField';
|
|
5
3
|
export * from './components/Utils/AutoReloadOnNewVersion';
|
|
@@ -23,8 +21,6 @@ export { default as RequireAuth } from './components/Utils/RequireAuth';
|
|
|
23
21
|
export * from './components/Utils/ShowHubSpotBubble';
|
|
24
22
|
export { default as ShowHubSpotBubble } from './components/Utils/ShowHubSpotBubble';
|
|
25
23
|
export * from './constants/sentry';
|
|
26
|
-
export * from './context/ChatProvider';
|
|
27
|
-
export { default as ChatProvider } from './context/ChatProvider';
|
|
28
24
|
export * from './context/InjectDependenciesProvider';
|
|
29
25
|
export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
|
|
30
26
|
export { default as QueryProvider } from './context/QueryProvider';
|
|
@@ -34,8 +30,6 @@ export * from './hooks/useAmplitude';
|
|
|
34
30
|
export { default as useAmplitude } from './hooks/useAmplitude';
|
|
35
31
|
export * from './hooks/useAuth';
|
|
36
32
|
export { default as useAuth } from './hooks/useAuth';
|
|
37
|
-
export * from './hooks/useChat';
|
|
38
|
-
export { default as useChat } from './hooks/useChat';
|
|
39
33
|
export * from './hooks/useCurrentLanguage/useCurrentLanguage';
|
|
40
34
|
export { default as useCurrentLanguage } from './hooks/useCurrentLanguage/useCurrentLanguage';
|
|
41
35
|
export * from './hooks/useFilters';
|
|
@@ -46,6 +40,12 @@ export * from './hooks/useInfiniteDataGrid';
|
|
|
46
40
|
export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
|
|
47
41
|
export * from './hooks/useResponseError/useResponseError';
|
|
48
42
|
export { default as useResponseError } from './hooks/useResponseError/useResponseError';
|
|
43
|
+
export { default as ChatClient } from './modules/chat/ChatClient';
|
|
44
|
+
export * from './modules/chat/context/ChatProvider';
|
|
45
|
+
export { default as ChatProvider } from './modules/chat/context/ChatProvider';
|
|
46
|
+
export * from './modules/chat/hooks/useChat';
|
|
47
|
+
export { default as useChat } from './modules/chat/hooks/useChat';
|
|
48
|
+
export * from './modules/chat/types';
|
|
49
49
|
export { default as getOrvalConfig } from './orval/orval';
|
|
50
50
|
export * from './utils/adapter/articleNameAdapter/articleNameAdapter';
|
|
51
51
|
export { default as articleNameAdapter } from './utils/adapter/articleNameAdapter/articleNameAdapter';
|