@getsoren/shared-module 2.69.1 → 2.71.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 CHANGED
@@ -225,6 +225,16 @@ import { extendedRentalOf, sheetLinesOf } from "@getsoren/shared-module/hourShee
225
225
  import { candidateOf, factsOfAnalysis, matchesOf } from "@getsoren/shared-module/documentImport";
226
226
  ```
227
227
 
228
+ A sheet's overtime is read apart from its day's hours, never added to them: the reading sends it as a line of the same
229
+ day labelled `overtime`, and it is billed at a rate of its own.
230
+
231
+ ```typescript
232
+ import { daysOfAnalysis, overtimesOfAnalysis } from "@getsoren/shared-module/documentImport";
233
+ import { sheetOfReadDays } from "@getsoren/shared-module/hourSheets";
234
+
235
+ const sheet = sheetOfReadDays(daysOfAnalysis(analysis), readCostCentres, overtimesOfAnalysis(analysis));
236
+ ```
237
+
228
238
  ## Utils function
229
239
  | Module | Description |
230
240
  |---------------------|----------------------------------------------------------------------------------------|
@@ -1,9 +1,9 @@
1
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";
2
+ import { D as t, s as n } from "./sheetLines-BP86eHw_.js";
3
+ import { normalizeSearch as r, roundToHundredths as i, toNumberOrNull as a } from "@getsoren/react-utils";
4
+ import o from "dayjs";
5
5
  //#region src/modules/documentImport/utils/matching/matching.ts
6
- var o = {
6
+ var s = {
7
7
  dateMet: 2,
8
8
  machineFamily: 1,
9
9
  machineMet: 3,
@@ -13,7 +13,7 @@ var o = {
13
13
  supplierMismatch: -4,
14
14
  worksiteMet: 2,
15
15
  worksiteMismatch: -3
16
- }, s = 6, ee = /^(livraison|reprise|transport|enlevement)\b/, c = [
16
+ }, c = 6, l = /^(livraison|reprise|transport|enlevement)\b/, u = [
17
17
  "acces industrie",
18
18
  "boels",
19
19
  "hertz",
@@ -22,7 +22,7 @@ var o = {
22
22
  "mediaco",
23
23
  "ramirent",
24
24
  "salti"
25
- ], l = [
25
+ ], ee = [
26
26
  ["miniExcavator", /\b(mini ?pelles?|minipelles?)\b/],
27
27
  ["backhoeLoader", /\btractopelles?\b/],
28
28
  ["excavator", /\bpelles?\b/],
@@ -34,31 +34,31 @@ var o = {
34
34
  ["crane", /\bgrues?\b/],
35
35
  ["truck", /\b(camions?|porteurs?)\b/],
36
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];
37
+ ], d = (e) => r(e ?? "").replace(/[^a-z0-9]+/g, " ").trim(), f = (e) => e?.slice(0, 10) || void 0, te = (e) => {
38
+ let t = e.items.find(({ articleName: e }) => !l.test(d(e))) ?? e.items[0];
39
39
  return {
40
40
  articleImage: t?.image,
41
41
  articleName: t?.articleName,
42
- fromDate: d(e.fromDate ?? t?.fromDate),
42
+ fromDate: f(e.fromDate ?? t?.fromDate),
43
43
  id: e.id,
44
44
  supplierLogo: t?.supplier?.logo,
45
45
  supplierName: t?.supplier?.name,
46
- toDate: d(e.toDate ?? t?.toDate),
46
+ toDate: f(e.toDate ?? t?.toDate),
47
47
  worksiteName: e.worksite?.name
48
48
  };
49
- }, te = ({ fromDate: e, id: t, items: n, toDate: r }) => ({
49
+ }, p = ({ fromDate: e, id: t, items: n, toDate: r }) => ({
50
50
  articleImage: n[0]?.image,
51
51
  articleName: n[0]?.name ?? void 0,
52
- fromDate: d(e),
52
+ fromDate: f(e),
53
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) => {
54
+ toDate: f(r)
55
+ }), m = (e) => e.split(/\s[-–]\s/)[0], h = (e) => {
56
+ let t = d(m(e ?? ""));
57
+ if (t) return u.find((e) => t === e || t.startsWith(`${e} `)) ?? t.split(" ")[0];
58
+ }, g = (e) => [...new Set([e.trim(), e.split(/\s[-–]\s/)[0].trim()])].filter(Boolean), ne = (e, t) => {
59
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 = [
60
+ return g(e).flatMap((e) => n.filter((t) => d(t.name) === d(e)))[0] ?? (n.length === 1 ? n[0] : void 0);
61
+ }, re = /\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, _ = [
62
62
  "btp",
63
63
  "groupe",
64
64
  "loc",
@@ -70,133 +70,137 @@ var o = {
70
70
  "transport",
71
71
  "transports",
72
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);
73
+ ], v = (e) => d(m(e ?? "")).replace(re, " ").split(" ").filter(Boolean), ie = (e) => [...v(e)].filter((e) => !_.includes(e)).sort((e, t) => t.length - e.length)[0] ?? e.trim(), y = (e, t) => {
74
+ let n = v(e), r = v(t);
75
75
  if (n.length === 0 || r.length === 0) return;
76
- let i = [n, r].map((e) => c.find((t) => e.join(" ").startsWith(t)));
76
+ let i = [n, r].map((e) => u.find((t) => e.join(" ").startsWith(t)));
77
77
  if (i[0] || i[1]) return i[0] === i[1];
78
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);
79
+ return a.every((e) => o.includes(e)) && a.some((e) => !_.includes(e));
80
+ }, b = (e) => ee.find(([, t]) => t.test(d(e)))?.[0], x = (e) => a((e ?? "").toLowerCase().replace(/(\d),(\d)/g, "$1.$2").match(/(\d+(?:\.\d+)?)\s*(?:t|tonnes?)\b/)?.[1]) ?? void 0, S = (e, t) => {
81
+ let n = b(e), r = b(t);
82
82
  if (!(n && r)) return "unknown";
83
83
  if (n !== r) return "different";
84
- let i = S(e), a = S(t);
84
+ let i = x(e), a = x(t);
85
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);
86
+ }, C = (e, t) => {
87
+ let n = d(e).split(" ").filter(Boolean), r = t.flatMap((e) => d(e).split(" ")).filter((e) => e.length > 2);
88
88
  return n.length > 0 && r.length > 0 && !n.some((e) => r.includes(e));
89
+ }, w = (e, t) => {
90
+ let n = S(e, t);
91
+ return n === "same" || n === "unknown" && !!d(e) && d(e) === d(t);
89
92
  }, T = (e, t) => {
90
- let n = C(e, t);
91
- return n === "same" || n === "unknown" && !!u(e) && u(e) === u(t);
93
+ let n = d(e.clientName), r = d(t.clientName);
94
+ return y(D(e), D(t)) === !0 && w(e.machine, t.machine) && !(n && r && n !== r);
92
95
  }, 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));
96
+ let n = new Set(d(e).split(" ").filter(Boolean)), r = new Set(d(t).split(" ").filter(Boolean));
97
97
  return [...n].filter((e) => r.has(e)).length / Math.max(1, new Set([...n, ...r]).size);
98
- }, re = ({ from: e, to: t }, n) => {
98
+ }, ae = ({ from: e, to: t }, n) => {
99
99
  if (!(e && t && n.fromDate)) return;
100
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,
101
+ return t < n.fromDate ? o(n.fromDate).diff(t, "day") : e > r ? o(e).diff(r, "day") : 0;
102
+ }, oe = {
103
+ different: s.machineMismatch,
104
+ family: s.machineFamily,
105
+ same: s.machineMet,
106
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);
107
+ }, se = ({ worksiteName: e }, t, n) => {
108
+ let r = d(e), i = d(t.worksiteName);
109
+ return n || r && r === i ? s.worksiteMet : r && i ? s.worksiteMismatch : 0;
110
+ }, D = ({ supplierName: e, orderSupplier: t }) => t?.name || e?.trim(), ce = (e, t) => {
111
+ let n = y(D(e), t.supplierName);
112
+ return n === void 0 ? 0 : n ? s.supplierMet : s.supplierMismatch;
113
+ }, le = 7, O = (e) => e === 0 ? s.dateMet : e === void 0 || e <= le ? 0 : s.periodMismatch, k = (e, t, { worksiteId: n }) => {
114
+ let r = ae(e, t);
115
115
  return {
116
116
  candidate: t,
117
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)
118
+ machineLikeness: e.machine && t.articleName ? E(e.machine, t.articleName) : 0,
119
+ score: se(e, t, n) + ce(e, t) + oe[S(e.machine, t.articleName)] + O(r)
120
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) => {
121
+ }, A = (e, t, n) => t.map((t) => k(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 ?? "")), j = (e, t) => {
122
122
  let n = e.find(({ candidate: e }) => e.id === t?.candidate.id);
123
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);
124
+ }, M = (e, t, n) => A(e, t, n)[0], N = (e) => d(e).replace(/\b\d+(?:[ .]\d+)?\s*(?:t|tonnes?)\b/g, "").replace(/\s+/g, " ").trim(), P = (t, n, r) => {
125
+ let i = x(t), a = (r) => {
126
+ let a = e(r), o = i !== void 0 && x(r.name) === i;
127
+ return (a === n ? 4 : 0) + (o ? 2 : 0) + E(t, r.name);
128
128
  };
129
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) => {
130
+ }, F = (e, t) => t && !e.some(({ candidate: e }) => e.id === t.id) ? [...e, { candidate: t }] : e, I = "YYYY-MM-DD", L = /^\d{4}-\d{2}-\d{2}$/, R = (e) => typeof e == "string" && L.test(e) && o(e).format(I) === e, z = ["machine_delivery", "machine_retrieval"], B = "lines", V = (e) => e?.trim() || void 0, H = (e) => a(/^(\d+(?:\.\d+)?) hour$/.exec(e?.trim() ?? "")?.[1]) ?? void 0, U = (e) => {
131
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)) ?? [];
132
+ return R(t) ? t : void 0;
133
+ }, W = (e) => {
134
+ let [t, n, ...r] = e?.split("/").map((e) => U(e)) ?? [];
135
135
  return t && n && r.length === 0 && t <= n ? {
136
136
  from: t,
137
137
  to: n
138
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);
139
+ }, G = ({ tables: e }) => e?.[B] ?? [], K = (e) => V(e.label) === t, q = (e) => {
140
+ let t = e.flatMap((e) => {
141
+ let t = U(e.date), n = H(e.quantity);
142
142
  return t && n !== void 0 && n <= 24 ? [{
143
- costCentre: U(e.cost_centre),
143
+ costCentre: V(e.cost_centre),
144
144
  date: t,
145
145
  hours: n
146
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) => ({
147
+ }), r = (e, t) => e.date === t.date && e.costCentre === t.costCentre;
148
+ return t.filter((e, n) => t.findIndex((t) => r(t, e)) === n).map((e) => ({
149
149
  ...e,
150
- hours: r(t(n.filter((t) => i(t, e))))
150
+ hours: i(n(t.filter((t) => r(t, e))))
151
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),
152
+ }, J = (e) => q(G(e).filter((e) => !K(e))), Y = (e) => q(G(e).filter(K)).filter(({ hours: e }) => e > 0), X = (e) => G(e).flatMap((e) => {
153
+ let t = H(e.quantity);
154
+ return V(e.date) || t === void 0 ? [] : [{
155
+ costCentre: V(e.cost_centre),
156
+ equipment: V(e.equipment),
157
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)
158
+ orderNumber: V(e.order_number),
159
+ period: W(e.period),
160
+ place: V(e.place),
161
+ taskCode: V(e.task_code)
162
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);
163
+ }), ue = (e) => {
164
+ let t = H(e.fields?.written_total), r = [
165
+ ...J(e),
166
+ ...Y(e),
167
+ ...X(e)
168
+ ];
169
+ return t === void 0 ? r.length > 0 ? n(r) : void 0 : t;
170
+ }, Z = (e) => e.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim(), de = (e, t) => {
171
+ let n = Z(e), r = Z(t);
168
172
  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(" "));
173
+ }, fe = /\b(livraison|amenee|aller|acheminement|delivery)\b/, pe = /\b(reprise|repli|retour|enlevement|pickup|pick up|collection)\b/, me = /\b(transport|transports|transfert)\b/, Q = (e) => {
174
+ let t = Z(e), n = fe.test(t), r = pe.test(t), i = !(n || r) && me.test(t);
175
+ return z.filter((e) => e === "machine_delivery" ? n || i : r || i);
176
+ }, $ = (e) => [e.fields?.equipment, ...G(e).map((e) => e.equipment)].flatMap((e) => V(e) ?? []), he = (e) => {
177
+ let t = $(e).filter((e) => Q(e).length === 0), n = t.filter((e, n) => t.findIndex((t) => de(t, e)) === n), r = V([e.fields?.machine_brand, e.fields?.model].filter(Boolean).join(" "));
174
178
  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);
179
+ }, ge = (e) => {
180
+ let t = e.fields ?? {}, n = G(e).flatMap((e) => {
181
+ let t = W(e.period);
178
182
  return [
179
- G(e.date),
183
+ U(e.date),
180
184
  t?.from,
181
185
  t?.to
182
186
  ].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)));
187
+ }).sort(), r = W(t.period), i = U(t.issue_date), [a, ...o] = he(e), s = z.filter((t) => $(e).some((e) => Q(e).includes(t)));
184
188
  return {
185
- clientName: U(t.client),
189
+ clientName: V(t.client),
186
190
  from: n[0] ?? r?.from ?? i,
187
- hours: se(e),
191
+ hours: ue(e),
188
192
  machine: a,
189
- operatorName: U(t.driver),
193
+ operatorName: V(t.driver),
190
194
  otherLines: o.length > 0 ? o.map((e, t) => ({
191
195
  id: `read-${t + 1}`,
192
196
  machine: e
193
197
  })) : void 0,
194
- supplierName: U(t.supplier),
198
+ supplierName: V(t.supplier),
195
199
  to: n.at(-1) ?? r?.to ?? i,
196
200
  transports: s.length > 0 ? s : void 0,
197
- worksiteName: U(t.worksite),
198
- writtenHours: W(t.written_total)
201
+ worksiteName: V(t.worksite),
202
+ writtenHours: H(t.written_total)
199
203
  };
200
204
  };
201
205
  //#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 };
206
+ export { c as MIN_MATCH_SCORE, z as TRANSPORT_TYPES, M as bestMatchOf, h as brandOf, te as candidateOf, p as candidateOfSearch, m as companyNameOf, J as daysOfAnalysis, ge as factsOfAnalysis, C as isAddressedElsewhere, T as isSameRental, y as isSameSupplier, N as machineSearchOf, A as matchesOf, Y as overtimesOfAnalysis, F as proposalsOf, P as rentalArticleFor, j as rivalsOf, k as scoreOf, ie as supplierSearchOf, v as supplierWordsOf, x as tonnageOf, Q as transportTypesOf, X as undatedHoursOfAnalysis, ne as worksiteOfName, g as worksiteSearchesOf };
package/dist/events.js CHANGED
@@ -438,7 +438,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
438
438
  return d.test(t) ? Number(t) : null;
439
439
  }, p = (e, t) => {
440
440
  let n = f(t.amount);
441
- return !e.price || e.amountGate && !t.amountGate || !n ? null : e.hasCreditNoteChoice ? t.isCreditNote ? -Math.abs(n) : Math.abs(n) : e.price === "credit" ? -Math.abs(n) : n;
441
+ return !e.price || e.amountGate && !t.amountGate || n === null ? null : n === 0 ? e.suggestsDailyShare ? 0 : null : e.hasCreditNoteChoice ? t.isCreditNote ? -Math.abs(n) : Math.abs(n) : e.price === "credit" ? -Math.abs(n) : n;
442
442
  }, m = (e, t, n) => {
443
443
  let { fromDate: r, toDate: i } = t.dates, a = e ? p(e, t) : null, o = e?.dates === "range" && r !== i ? n : 1;
444
444
  return {
@@ -1,4 +1,4 @@
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";
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-BP86eHw_.js";
2
2
  import D from "dayjs";
3
3
  //#region src/modules/hourSheets/utils/billingReferences/billingReferences.ts
4
4
  var O = "active", k = (e) => e.filter(({ status: e }) => e === O).map(({ id: e, reference: t }) => ({
@@ -19,6 +19,20 @@ export interface ReadDay {
19
19
  */
20
20
  costCentre?: string;
21
21
  }
22
+ /**
23
+ * Overtime read on an hour sheet: the hours a column of their own writes for a day, beyond the day's own.
24
+ */
25
+ export interface ReadOvertime {
26
+ /**
27
+ * YYYY-MM-DD
28
+ */
29
+ date: string;
30
+ hours: number;
31
+ /**
32
+ * The cost centre the sheet writes for these hours, as written.
33
+ */
34
+ costCentre?: string;
35
+ }
22
36
  /**
23
37
  * Hours a sheet writes without the day they were worked: a subtotal by week, machine or imputation.
24
38
  */
@@ -1,4 +1,4 @@
1
- import { DocumentAnalysis, ReadDay, ReadFacts, TransportType, UndatedHours } from '../../types';
1
+ import { DocumentAnalysis, ReadDay, ReadFacts, ReadOvertime, TransportType, UndatedHours } from '../../types';
2
2
  /**
3
3
  * The machine's transports, in their order on screen: its delivery, then its pick-up.
4
4
  */
@@ -6,9 +6,14 @@ export declare const TRANSPORT_TYPES: TransportType[];
6
6
  /**
7
7
  * An hour sheet's days with their hours, sorted. Lines in days or over a full day are dropped; lines of the same day
8
8
  * charged alike (morning and afternoon) are summed. A day the sheet charges to several cost centres keeps a line for
9
- * each, with the cost centre as written.
9
+ * each, with the cost centre as written. Its overtime is not a day's hours: it is read apart (`overtimesOfAnalysis`).
10
10
  */
11
11
  export declare const daysOfAnalysis: (analysis: DocumentAnalysis) => ReadDay[];
12
+ /**
13
+ * An hour sheet's overtime, sorted: the hours it writes for a day beyond the day's own, in a column of their own. Read
14
+ * as the days are, and never added to them: they are billed at their own rate.
15
+ */
16
+ export declare const overtimesOfAnalysis: (analysis: DocumentAnalysis) => ReadOvertime[];
12
17
  /**
13
18
  * The hours a sheet writes without their day (a week's, a machine's or an imputation's subtotal), in its order. A line
14
19
  * whose day is misread rather than missing is dropped, as in `daysOfAnalysis`.
@@ -11,7 +11,8 @@ export interface EventAmounts {
11
11
  export declare const toDecimal: (text: string) => number | null;
12
12
  /**
13
13
  * Null without a price, behind a gate answered no, or while no amount is typed, zero being none; a credit, typed
14
- * positive, is sent negative, and so is a sum the user says is taken off.
14
+ * positive, is sent negative, and so is a sum the user says is taken off. Zero is an amount where the credit is a share
15
+ * of the daily price: a supplier who bills the days in full takes nothing off, which is an answer and not a blank.
15
16
  */
16
17
  export declare const getUnitPrice: (event: EventDefinition, answers: Pick<EventAnswers, "amount" | "amountGate" | "isCreditNote">) => number | null;
17
18
  /**
@@ -65,6 +65,11 @@ export interface SheetOvertime {
65
65
  * What the overtime is charged to apart from its order, as a day's.
66
66
  */
67
67
  imputation: DayImputation;
68
+ /**
69
+ * The cost centre the sheet writes for the overtime when none of the client's is told from it: as a day's, it is
70
+ * then charged to no cost centre until the user picks one.
71
+ */
72
+ unreadCostCentre?: string;
68
73
  source: DocumentLineSource;
69
74
  }
70
75
  /**
@@ -90,8 +90,12 @@ interface ReadSheetDay extends Pick<SheetDay, "date" | "hours"> {
90
90
  * cost centre for it: one of the client's is then stated, and the sheet the chart of accounts it is in; one told among
91
91
  * none is kept as written, the day charged to no cost centre until the user picks one.
92
92
  * A day read without hours is not a worked day.
93
+ *
94
+ * The overtime read beside the days is kept apart from them, on the day it was worked: charged to the cost centre the
95
+ * sheet writes for it as a day is, else as its day, and its rate left to type, since no sheet says what an extra hour
96
+ * costs.
93
97
  */
94
- export declare const sheetOfReadDays: (days: ReadSheetDay[], { chart, costCentres }?: Pick<ReadCostCentres, "chart" | "costCentres">) => HourSheet;
98
+ export declare const sheetOfReadDays: (days: ReadSheetDay[], { chart, costCentres }?: Pick<ReadCostCentres, "chart" | "costCentres">, overtimes?: ReadSheetDay[]) => HourSheet;
95
99
  /**
96
100
  * Reads a sheet back from its lines: its days, its overtime, and its chart of accounts. A line states what it is charged
97
101
  * to, or nothing when charged as its order is. The API writes quantities and amounts as decimal strings. A line that is
@@ -55,7 +55,7 @@ var n = "HOUR_SHEET", r = "plan_de_compte", i = "centre_de_cout", a = "billing_r
55
55
  qtyUnit: "HOURS",
56
56
  quantity: t,
57
57
  source: a
58
- })), ...n.filter((e) => S(e, c)).map(({ date: e, hours: t, id: n, imputation: r, rate: a, source: o }) => ({
58
+ })), ...n.filter((e) => S(e, c)).map(({ date: e, hours: t, id: n, imputation: r, rate: a, source: o, unreadCostCentre: l }) => ({
59
59
  ...c && {
60
60
  amount: w({
61
61
  hours: t,
@@ -66,7 +66,10 @@ var n = "HOUR_SHEET", r = "plan_de_compte", i = "centre_de_cout", a = "billing_r
66
66
  bookingItemId: i,
67
67
  date: e,
68
68
  id: h(n),
69
- imputation: p({ imputation: r }),
69
+ imputation: p({
70
+ imputation: r,
71
+ unreadCostCentre: l
72
+ }),
70
73
  label: s,
71
74
  qtyUnit: "HOURS",
72
75
  quantity: t,
@@ -84,9 +87,8 @@ var n = "HOUR_SHEET", r = "plan_de_compte", i = "centre_de_cout", a = "billing_r
84
87
  }), k = (e, { chart: t, costCentres: n } = {
85
88
  chart: null,
86
89
  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
+ }, r = []) => {
91
+ let a = e.filter(({ hours: e }) => e > 0).map(({ costCentre: e, date: t, hours: r }, a) => {
90
92
  let o = e ? n[e] : void 0;
91
93
  return {
92
94
  date: t,
@@ -96,9 +98,24 @@ var n = "HOUR_SHEET", r = "plan_de_compte", i = "centre_de_cout", a = "billing_r
96
98
  source: "read",
97
99
  ...e && !o && { unreadCostCentre: e }
98
100
  };
99
- }),
100
- overtimes: []
101
- }), A = (e) => ({
101
+ });
102
+ return {
103
+ chart: [...e, ...r].some(({ costCentre: e }) => e && n[e]) ? t : null,
104
+ days: a,
105
+ overtimes: r.filter(({ hours: e }) => e > 0).map(({ costCentre: e, date: t, hours: r }, o) => {
106
+ let s = e ? n[e] : void 0, c = e ? s ? { [i]: s } : {} : y(a, t);
107
+ return {
108
+ date: t,
109
+ hours: r,
110
+ id: `read-overtime-${o}`,
111
+ imputation: c,
112
+ rate: null,
113
+ source: "read",
114
+ ...e && !s && { unreadCostCentre: e }
115
+ };
116
+ })
117
+ };
118
+ }, A = (e) => ({
102
119
  chart: e.map(({ imputation: e }) => e.plan_de_compte).find(Boolean) ?? null,
103
120
  days: e.flatMap(({ date: e, id: n, imputation: r, label: i, qtyUnit: a, quantity: o, source: s }) => {
104
121
  let c = t(o);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.69.1",
3
+ "version": "2.71.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",