@getsoren/shared-module 2.69.1 → 2.71.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.
- package/README.md +10 -0
- package/dist/documentImport.js +101 -97
- package/dist/hourSheets.js +1 -1
- package/dist/modules/documentImport/types.d.ts +14 -0
- package/dist/modules/documentImport/utils/reading/reading.d.ts +7 -2
- package/dist/modules/hourSheets/types.d.ts +5 -0
- package/dist/modules/hourSheets/utils/sheetLines/sheetLines.d.ts +5 -1
- package/dist/{sheetLines-DECsEz55.js → sheetLines-BP86eHw_.js} +25 -8
- package/package.json +1 -1
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
|
|---------------------|----------------------------------------------------------------------------------------|
|
package/dist/documentImport.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { s as e } from "./operator-Cj1X_Zg5.js";
|
|
2
|
-
import {
|
|
3
|
-
import { normalizeSearch as
|
|
4
|
-
import
|
|
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
|
|
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
|
-
},
|
|
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
|
-
],
|
|
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
|
-
],
|
|
38
|
-
let t = e.items.find(({ articleName: e }) => !
|
|
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:
|
|
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:
|
|
46
|
+
toDate: f(e.toDate ?? t?.toDate),
|
|
47
47
|
worksiteName: e.worksite?.name
|
|
48
48
|
};
|
|
49
|
-
},
|
|
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:
|
|
52
|
+
fromDate: f(e),
|
|
53
53
|
id: t,
|
|
54
|
-
toDate:
|
|
55
|
-
}),
|
|
56
|
-
let t =
|
|
57
|
-
if (t) return
|
|
58
|
-
},
|
|
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
|
|
61
|
-
},
|
|
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
|
-
],
|
|
74
|
-
let n =
|
|
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) =>
|
|
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) => !
|
|
80
|
-
},
|
|
81
|
-
let n =
|
|
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 =
|
|
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
|
-
},
|
|
87
|
-
let n =
|
|
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 =
|
|
91
|
-
return
|
|
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 =
|
|
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
|
-
},
|
|
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 ?
|
|
102
|
-
},
|
|
103
|
-
different:
|
|
104
|
-
family:
|
|
105
|
-
same:
|
|
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
|
-
},
|
|
108
|
-
let r =
|
|
109
|
-
return n || r && r === i ?
|
|
110
|
-
},
|
|
111
|
-
let n =
|
|
112
|
-
return n === void 0 ? 0 : n ?
|
|
113
|
-
},
|
|
114
|
-
let r =
|
|
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 ?
|
|
119
|
-
score:
|
|
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
|
-
},
|
|
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
|
-
},
|
|
125
|
-
let i =
|
|
126
|
-
let a = e(r), o = i !== void 0 &&
|
|
127
|
-
return (a === n ? 4 : 0) + (o ? 2 : 0) +
|
|
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
|
-
},
|
|
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
|
|
133
|
-
},
|
|
134
|
-
let [t, n, ...r] = e?.split("/").map((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
|
-
},
|
|
140
|
-
let
|
|
141
|
-
let t =
|
|
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:
|
|
143
|
+
costCentre: V(e.cost_centre),
|
|
144
144
|
date: t,
|
|
145
145
|
hours: n
|
|
146
146
|
}] : [];
|
|
147
|
-
}),
|
|
148
|
-
return
|
|
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:
|
|
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 =
|
|
154
|
-
return
|
|
155
|
-
costCentre:
|
|
156
|
-
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:
|
|
159
|
-
period:
|
|
160
|
-
place:
|
|
161
|
-
taskCode:
|
|
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
|
-
}),
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
},
|
|
170
|
-
let t =
|
|
171
|
-
return
|
|
172
|
-
}, $ = (e) => [e.fields?.equipment, ...
|
|
173
|
-
let t = $(e).filter((e) => Q(e).length === 0), n = t.filter((e, n) => t.findIndex((t) =>
|
|
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
|
-
},
|
|
176
|
-
let t = e.fields ?? {}, n =
|
|
177
|
-
let t =
|
|
179
|
+
}, ge = (e) => {
|
|
180
|
+
let t = e.fields ?? {}, n = G(e).flatMap((e) => {
|
|
181
|
+
let t = W(e.period);
|
|
178
182
|
return [
|
|
179
|
-
|
|
183
|
+
U(e.date),
|
|
180
184
|
t?.from,
|
|
181
185
|
t?.to
|
|
182
186
|
].flatMap((e) => e ?? []);
|
|
183
|
-
}).sort(), r =
|
|
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:
|
|
189
|
+
clientName: V(t.client),
|
|
186
190
|
from: n[0] ?? r?.from ?? i,
|
|
187
|
-
hours:
|
|
191
|
+
hours: ue(e),
|
|
188
192
|
machine: a,
|
|
189
|
-
operatorName:
|
|
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:
|
|
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:
|
|
198
|
-
writtenHours:
|
|
201
|
+
worksiteName: V(t.worksite),
|
|
202
|
+
writtenHours: H(t.written_total)
|
|
199
203
|
};
|
|
200
204
|
};
|
|
201
205
|
//#endregion
|
|
202
|
-
export {
|
|
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/hourSheets.js
CHANGED
|
@@ -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-
|
|
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`.
|
|
@@ -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"
|
|
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({
|
|
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
|
-
|
|
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
|
-
|
|
101
|
-
|
|
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);
|