@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.
Files changed (69) hide show
  1. package/README.md +15 -0
  2. package/dist/documentImport.js +202 -0
  3. package/dist/events.js +1 -1
  4. package/dist/hourSheets.js +58 -0
  5. package/dist/main.d.ts +6 -6
  6. package/dist/main.js +512 -548
  7. package/dist/{context → modules/chat/context}/ChatProvider.d.ts +1 -1
  8. package/dist/{hooks → modules/chat/hooks}/useChat.d.ts +1 -1
  9. package/dist/modules/documentImport/index.d.ts +9 -0
  10. package/dist/modules/documentImport/types.d.ts +127 -0
  11. package/dist/modules/documentImport/utils/matching/matching.d.ts +144 -0
  12. package/dist/modules/documentImport/utils/proposals/proposals.d.ts +10 -0
  13. package/dist/modules/documentImport/utils/reading/reading.d.ts +26 -0
  14. package/dist/modules/events/utils/payload/payload.test.d.ts +1 -0
  15. package/dist/modules/events/utils/readEvent/readEvent.test.d.ts +1 -0
  16. package/dist/modules/events/utils/steps/steps.test.d.ts +1 -0
  17. package/dist/modules/hourSheets/constants.d.ts +33 -0
  18. package/dist/modules/hourSheets/index.d.ts +13 -0
  19. package/dist/modules/hourSheets/types.d.ts +143 -0
  20. package/dist/modules/hourSheets/utils/billingReferences/billingReferences.d.ts +35 -0
  21. package/dist/modules/hourSheets/utils/billingReferences/billingReferences.test.d.ts +1 -0
  22. package/dist/modules/hourSheets/utils/imputation/imputation.d.ts +44 -0
  23. package/dist/modules/hourSheets/utils/imputation/imputation.test.d.ts +1 -0
  24. package/dist/modules/hourSheets/utils/readCostCentres/readCostCentres.d.ts +42 -0
  25. package/dist/modules/hourSheets/utils/readCostCentres/readCostCentres.test.d.ts +1 -0
  26. package/dist/modules/hourSheets/utils/sheetBlocker/sheetBlocker.d.ts +53 -0
  27. package/dist/modules/hourSheets/utils/sheetBlocker/sheetBlocker.test.d.ts +1 -0
  28. package/dist/modules/hourSheets/utils/sheetDays/sheetDays.d.ts +68 -0
  29. package/dist/modules/hourSheets/utils/sheetDays/sheetDays.test.d.ts +1 -0
  30. package/dist/modules/hourSheets/utils/sheetLines/sheetLines.d.ts +103 -0
  31. package/dist/modules/hourSheets/utils/sheetLines/sheetLines.test.d.ts +1 -0
  32. package/dist/operator-Cj1X_Zg5.js +41 -0
  33. package/dist/orval.js +1 -1
  34. package/dist/sheetLines-DECsEz55.js +123 -0
  35. package/package.json +17 -2
  36. /package/dist/{chat → modules/chat}/ChatClient.d.ts +0 -0
  37. /package/dist/{chat → modules/chat}/tests/ChatClient.test.d.ts +0 -0
  38. /package/dist/{chat → modules/chat}/types.d.ts +0 -0
  39. /package/dist/{events/hooks/useEventDeclaration/useEventDeclaration.test.d.ts → modules/documentImport/utils/matching/matching.test.d.ts} +0 -0
  40. /package/dist/{events/tenants/tenants.test.d.ts → modules/documentImport/utils/proposals/proposals.test.d.ts} +0 -0
  41. /package/dist/{events/utils/amounts/amounts.test.d.ts → modules/documentImport/utils/reading/reading.test.d.ts} +0 -0
  42. /package/dist/{events → modules/events}/catalog/clientEvents.d.ts +0 -0
  43. /package/dist/{events → modules/events}/catalog/supplierEvents.d.ts +0 -0
  44. /package/dist/{events → modules/events}/constants.d.ts +0 -0
  45. /package/dist/{events → modules/events}/hooks/useEventDeclaration/useEventDeclaration.d.ts +0 -0
  46. /package/dist/{events/utils/credits/credits.test.d.ts → modules/events/hooks/useEventDeclaration/useEventDeclaration.test.d.ts} +0 -0
  47. /package/dist/{events → modules/events}/index.d.ts +0 -0
  48. /package/dist/{events → modules/events}/locales/ar.d.ts +0 -0
  49. /package/dist/{events → modules/events}/locales/de.d.ts +0 -0
  50. /package/dist/{events → modules/events}/locales/en.d.ts +0 -0
  51. /package/dist/{events → modules/events}/locales/es.d.ts +0 -0
  52. /package/dist/{events → modules/events}/locales/fr.d.ts +0 -0
  53. /package/dist/{events → modules/events}/locales/it.d.ts +0 -0
  54. /package/dist/{events → modules/events}/locales/locales.d.ts +0 -0
  55. /package/dist/{events → modules/events}/locales/pt.d.ts +0 -0
  56. /package/dist/{events → modules/events}/tenants/bouygues/bouygues.d.ts +0 -0
  57. /package/dist/{events → modules/events}/tenants/index.d.ts +0 -0
  58. /package/dist/{events/utils/lineFunnel/lineFunnel.test.d.ts → modules/events/tenants/tenants.test.d.ts} +0 -0
  59. /package/dist/{events → modules/events}/types.d.ts +0 -0
  60. /package/dist/{events → modules/events}/utils/amounts/amounts.d.ts +0 -0
  61. /package/dist/{events/utils/payload/payload.test.d.ts → modules/events/utils/amounts/amounts.test.d.ts} +0 -0
  62. /package/dist/{events → modules/events}/utils/credits/credits.d.ts +0 -0
  63. /package/dist/{events/utils/readEvent/readEvent.test.d.ts → modules/events/utils/credits/credits.test.d.ts} +0 -0
  64. /package/dist/{events → modules/events}/utils/lineFunnel/lineFunnel.d.ts +0 -0
  65. /package/dist/{events/utils/steps/steps.test.d.ts → modules/events/utils/lineFunnel/lineFunnel.test.d.ts} +0 -0
  66. /package/dist/{events → modules/events}/utils/payload/payload.d.ts +0 -0
  67. /package/dist/{events → modules/events}/utils/readEvent/readEvent.d.ts +0 -0
  68. /package/dist/{events → modules/events}/utils/steps/steps.d.ts +0 -0
  69. /package/dist/{orval-Bf_zcxLE.js → orval-BSFwOlVR.js} +0 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Why an hour sheet cannot be saved, in the order a user settles them: its order first, then its lines.
3
+ */
4
+ export type SheetBlocker = "rateMissing" | "dateRefused" | "extensionTooLong" | "takenDaysChecking" | "takenDaysError" | "dayTaken" | "billingReferenceMissing" | "costCentreMissing" | "overtimeIncomplete" | "incomplete";
5
+ interface SheetState {
6
+ /**
7
+ * The driver's line, ordered by the hour, has no hourly rate yet.
8
+ */
9
+ isRateMissing: boolean;
10
+ /**
11
+ * A billed day falls outside the rental, or is still to come.
12
+ */
13
+ hasRefusedDate: boolean;
14
+ /**
15
+ * The sheet would extend the order by more than the days a sheet extends one by: a date was likely misread.
16
+ */
17
+ isExtensionTooLong?: boolean;
18
+ /**
19
+ * The order's other sheets still load: the days they hold are not known yet.
20
+ */
21
+ isCheckingTakenDays: boolean;
22
+ /**
23
+ * The order's other sheets could not be loaded: the days they hold are unknown.
24
+ */
25
+ isTakenDaysError: boolean;
26
+ /**
27
+ * A worked day is already on another sheet of the order: saved again, it would be billed twice.
28
+ */
29
+ hasTakenDay: boolean;
30
+ /**
31
+ * A line still has its OM to choose.
32
+ */
33
+ isBillingReferenceMissing: boolean;
34
+ /**
35
+ * A line still has its cost centre to choose, which the procurement platform asks of each.
36
+ */
37
+ isCostCentreMissing?: boolean;
38
+ /**
39
+ * An overtime still has its hours or its rate to type.
40
+ */
41
+ hasIncompleteOvertime?: boolean;
42
+ /**
43
+ * The form takes the sheet: a worked day at least, no day longer than a day, no overtime left half typed.
44
+ */
45
+ isValid: boolean;
46
+ }
47
+ /**
48
+ * What keeps an hour sheet from being saved, the first to settle; none once it can be: what the API refuses, a day it
49
+ * would bill twice, or what is not known yet (the order's other sheets). Said over the button it greys, so that a greyed
50
+ * button always tells why.
51
+ */
52
+ export declare const sheetBlockerOf: ({ isRateMissing, hasRefusedDate, isExtensionTooLong, isCheckingTakenDays, isTakenDaysError, hasTakenDay, isBillingReferenceMissing, isCostCentreMissing, hasIncompleteOvertime, isValid, }: SheetState) => SheetBlocker | undefined;
53
+ export {};
@@ -0,0 +1,68 @@
1
+ import { DayRange, HourSheet, SheetDay } from '../../types';
2
+ /**
3
+ * Whether a day (YYYY-MM-DD) falls within the range, an open end taking any day.
4
+ */
5
+ export declare const isWithin: (date: string, { from, to }: DayRange) => boolean;
6
+ /**
7
+ * Whether every day the sheet bills falls within the range: its days with hours, and its overtime. The API refuses a
8
+ * sheet stating hours on a day outside the rental on a line by the hour and checks nothing on a line by the day, where the
9
+ * day would be kept on a rental that does not cover it: a reading that took a date for another gives one. A day without
10
+ * hours states no line and is not checked.
11
+ */
12
+ export declare const areBilledDaysWithin: ({ days, overtimes }: Pick<HourSheet, "days" | "overtimes">, range: DayRange) => boolean;
13
+ /**
14
+ * The rental stretched over the days the sheet bills outside it, before as after, which saving the sheet extends the
15
+ * order to; none while every day falls within it. A day still to come is refused before: the sheet is not saved.
16
+ */
17
+ export declare const extendedRentalOf: ({ days, overtimes }: Pick<HourSheet, "days" | "overtimes">, rental: DayRange) => DayRange | undefined;
18
+ /**
19
+ * Whether extending the rental to `extended` moves either of its ends by more than the days a sheet extends one by.
20
+ */
21
+ export declare const isExtensionTooLong: (rental: DayRange, extended?: DayRange) => boolean;
22
+ /**
23
+ * The days a sheet can hold, which its calendar proposes and its save checks: the rental's, none still to come.
24
+ */
25
+ export declare const sheetDayRangeOf: (rental: DayRange, today: string) => DayRange;
26
+ /**
27
+ * The day proposed when adding one to a sheet: the first day of its week (Monday to Sunday) it does not hold yet, kept
28
+ * within the given dates; once the week holds every day it can, the day after its last, wherever it falls (a day of
29
+ * the sheet already would add nothing). An empty sheet takes the week of `anchor`.
30
+ */
31
+ export declare const nextFreeDayOf: (dates: string[], anchor: string, within?: DayRange) => string;
32
+ /**
33
+ * The sheet's days with one more, kept in date order; a day the sheet already holds is left as it is.
34
+ */
35
+ export declare const withDay: (days: SheetDay[], day: SheetDay) => SheetDay[];
36
+ /**
37
+ * The sheet's days with one more line on a day it holds, after that day's last: hours of the same day charged to
38
+ * something else. The line starts without hours, on the imputation of the line before it, where only what differs is
39
+ * left to change. A day the sheet does not hold gets none.
40
+ */
41
+ export declare const withDayLine: (days: SheetDay[], date: string, id: string) => SheetDay[];
42
+ /**
43
+ * Where a line stands among the lines of its day, which the sheet shows together.
44
+ */
45
+ export interface DayLinePlace {
46
+ /**
47
+ * Hours of the line's whole day, across its lines.
48
+ */
49
+ dayHours: number;
50
+ /**
51
+ * Another line of the same day comes right after it.
52
+ */
53
+ isFollowed: boolean;
54
+ /**
55
+ * Its place among the lines of its day, from 0: the first one names the day.
56
+ */
57
+ rank: number;
58
+ }
59
+ /**
60
+ * The place of each of the sheet's lines among the lines of its day, the lines of a day following each other.
61
+ */
62
+ export declare const dayLinePlacesOf: (days: Pick<SheetDay, "date" | "hours">[]) => DayLinePlace[];
63
+ /**
64
+ * The sheet's days with one of them moved to another date, as when the reading took a date for another: its lines keep
65
+ * their hours and their imputation, and the days stay in date order. Moved onto a day the sheet already holds, nothing
66
+ * changes.
67
+ */
68
+ export declare const withDayMoved: (days: SheetDay[], from: string, to: string) => SheetDay[];
@@ -0,0 +1,103 @@
1
+ import { DayImputation, HourSheet, SheetDay, SheetLineInput, SheetOvertime, StoredSheetLine } from '../../types';
2
+ import { ReadCostCentres } from '../readCostCentres/readCostCentres';
3
+ /**
4
+ * A sheet's total hours, rounded to the hundredth.
5
+ */
6
+ export declare const sheetHoursOf: (days: Pick<SheetDay, "hours">[]) => number;
7
+ /**
8
+ * The hours a sheet's overtime adds, those typed: an overtime still without its hours adds none.
9
+ */
10
+ export declare const overtimeHoursOf: (overtimes: Pick<SheetOvertime, "hours">[]) => number;
11
+ /**
12
+ * What an overtime added on a day is charged to: what the day's first line says, as the overtime is worked on that day;
13
+ * nothing for a day the sheet does not hold, or one charged as the order is.
14
+ */
15
+ export declare const overtimeImputationOf: (days: Pick<SheetDay, "date" | "imputation">[], date: string) => DayImputation;
16
+ /**
17
+ * An overtime with its hours and its rate: the one the sheet states.
18
+ */
19
+ export declare const isOvertimePriced: ({ hours, rate }: Pick<SheetOvertime, "hours" | "rate">) => boolean;
20
+ /**
21
+ * An overtime the sheet states: with its hours and its rate where the driver's line bills it (by the hour), with its
22
+ * hours alone where it does not (by the day): no rate is asked that nothing bills.
23
+ */
24
+ export declare const isOvertimeStated: (overtime: Pick<SheetOvertime, "hours" | "rate">, isBilled?: boolean) => boolean;
25
+ /**
26
+ * An overtime not stated yet (see `isOvertimeStated`): added to the sheet, it is completed or taken out, never left empty.
27
+ */
28
+ export declare const isOvertimeIncomplete: (overtime: Pick<SheetOvertime, "hours" | "rate">, isBilled?: boolean) => boolean;
29
+ /**
30
+ * What an overtime comes to, excluding tax: its hours at its rate, to the cent; none until it has both.
31
+ */
32
+ export declare const overtimeAmountOf: (overtime: Pick<SheetOvertime, "hours" | "rate">) => number | null;
33
+ interface SheetLinesContext {
34
+ /**
35
+ * Order line the sheet's hours apply to: the driver's.
36
+ */
37
+ bookingItemId: string | null;
38
+ /**
39
+ * The order's own imputation, its chart of accounts included: what a day leaves out is charged to.
40
+ */
41
+ orderImputation: DayImputation;
42
+ /**
43
+ * Ids of the lines the sheet's file already holds; none for a sheet whose lines are all new.
44
+ */
45
+ storedLineIds?: readonly string[];
46
+ /**
47
+ * The driver's line bills the sheet's overtime (by the hour): its lines say their rate and amount. Off (by the day),
48
+ * they say their hours alone.
49
+ */
50
+ isOvertimeBilled?: boolean;
51
+ }
52
+ /**
53
+ * A sheet's document lines: one per line of a worked day, in hours, then one per overtime stated, with its hours, and
54
+ * where the driver's line bills it (by the hour) its rate and the amount they come to, which is what the API bills. A
55
+ * day's line without hours states nothing: it is left out, as an overtime not stated yet is.
56
+ *
57
+ * A line charged as the order is states no imputation: the API then bills it on the order's own, where stating the same
58
+ * values would bill it as a line charged elsewhere. Any other line states its whole imputation: what it says, the
59
+ * order's for what it leaves out, and the sheet's chart of accounts.
60
+ *
61
+ * A line the sheet's file already holds says its id: the API then keeps it the same line wherever it now stands, so
62
+ * that a line added or removed before it does not pass for a change of it. A new line has none.
63
+ */
64
+ export declare const sheetLinesOf: ({ chart, days, overtimes }: HourSheet, { bookingItemId, orderImputation, storedLineIds, isOvertimeBilled }: SheetLinesContext) => SheetLineInput[];
65
+ /**
66
+ * A day's line or an overtime: what it is charged to.
67
+ */
68
+ interface ImputedLine {
69
+ imputation: DayImputation;
70
+ }
71
+ /**
72
+ * Lines once the sheet goes on another order: an OM stated on a line charged to the previous order's cost centre is
73
+ * dropped, since it belongs to that cost centre. A line stating its own cost centre keeps its OM.
74
+ */
75
+ export declare const withoutOrderBillingReferences: <T extends ImputedLine>(lines: T[]) => T[];
76
+ /**
77
+ * Lines once the sheet's chart of accounts changes: their cost centres, entities of the previous chart, are dropped with
78
+ * their OMs.
79
+ */
80
+ export declare const withoutCostCentres: <T extends ImputedLine>(lines: T[]) => T[];
81
+ /**
82
+ * A worked day as read on a sheet, with the cost centre the sheet writes for it.
83
+ */
84
+ interface ReadSheetDay extends Pick<SheetDay, "date" | "hours"> {
85
+ costCentre?: string;
86
+ }
87
+ /**
88
+ * The sheet a review starts from when its days were only read: each worked day on a line named after its place among
89
+ * them, the same from one reading of the sheet to the next. A day is charged as its order is, unless the sheet writes a
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
+ * none is kept as written, the day charged to no cost centre until the user picks one.
92
+ * A day read without hours is not a worked day.
93
+ */
94
+ export declare const sheetOfReadDays: (days: ReadSheetDay[], { chart, costCentres }?: Pick<ReadCostCentres, "chart" | "costCentres">) => HourSheet;
95
+ /**
96
+ * Reads a sheet back from its lines: its days, its overtime, and its chart of accounts. A line states what it is charged
97
+ * to, or nothing when charged as its order is. The API writes quantities and amounts as decimal strings. A line that is
98
+ * neither a dated day in hours nor a dated overtime is not part of the sheet. The lines of a day are read together,
99
+ * in date order, wherever they stand on the document. An overtime saved as an amount alone, before it had hours, shows
100
+ * that amount as its rate: its hours are still to type.
101
+ */
102
+ export declare const sheetOfLines: (lines: StoredSheetLine[]) => HourSheet;
103
+ export {};
@@ -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/modules/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.1",
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/modules/documentImport/index.d.ts",
19
+ "import": "./dist/documentImport.js",
20
+ "default": "./dist/documentImport.js"
21
+ },
17
22
  "./events": {
18
- "types": "./dist/events/index.d.ts",
23
+ "types": "./dist/modules/events/index.d.ts",
19
24
  "import": "./dist/events.js",
20
25
  "default": "./dist/events.js"
21
26
  },
27
+ "./hourSheets": {
28
+ "types": "./dist/modules/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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes