@getsoren/shared-module 2.69.0 → 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.
Files changed (66) hide show
  1. package/README.md +10 -0
  2. package/dist/documentImport.js +102 -98
  3. package/dist/events.js +1 -1
  4. package/dist/hourSheets.js +2 -2
  5. package/dist/main.d.ts +6 -6
  6. package/dist/main.js +371 -371
  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/{documentImport → modules/documentImport}/types.d.ts +14 -0
  10. package/dist/{documentImport → modules/documentImport}/utils/reading/reading.d.ts +7 -2
  11. package/dist/{hourSheets → modules/hourSheets}/types.d.ts +5 -0
  12. package/dist/{hourSheets → modules/hourSheets}/utils/sheetLines/sheetLines.d.ts +5 -1
  13. package/dist/{sheetLines-DzQEyJOO.js → sheetLines-BP86eHw_.js} +26 -9
  14. package/package.json +4 -4
  15. /package/dist/{chat → modules/chat}/ChatClient.d.ts +0 -0
  16. /package/dist/{chat → modules/chat}/tests/ChatClient.test.d.ts +0 -0
  17. /package/dist/{chat → modules/chat}/types.d.ts +0 -0
  18. /package/dist/{documentImport → modules/documentImport}/index.d.ts +0 -0
  19. /package/dist/{documentImport → modules/documentImport}/utils/matching/matching.d.ts +0 -0
  20. /package/dist/{documentImport → modules/documentImport}/utils/matching/matching.test.d.ts +0 -0
  21. /package/dist/{documentImport → modules/documentImport}/utils/proposals/proposals.d.ts +0 -0
  22. /package/dist/{documentImport → modules/documentImport}/utils/proposals/proposals.test.d.ts +0 -0
  23. /package/dist/{documentImport → modules/documentImport}/utils/reading/reading.test.d.ts +0 -0
  24. /package/dist/{events → modules/events}/catalog/clientEvents.d.ts +0 -0
  25. /package/dist/{events → modules/events}/catalog/supplierEvents.d.ts +0 -0
  26. /package/dist/{events → modules/events}/constants.d.ts +0 -0
  27. /package/dist/{events → modules/events}/hooks/useEventDeclaration/useEventDeclaration.d.ts +0 -0
  28. /package/dist/{events → modules/events}/hooks/useEventDeclaration/useEventDeclaration.test.d.ts +0 -0
  29. /package/dist/{events → modules/events}/index.d.ts +0 -0
  30. /package/dist/{events → modules/events}/locales/ar.d.ts +0 -0
  31. /package/dist/{events → modules/events}/locales/de.d.ts +0 -0
  32. /package/dist/{events → modules/events}/locales/en.d.ts +0 -0
  33. /package/dist/{events → modules/events}/locales/es.d.ts +0 -0
  34. /package/dist/{events → modules/events}/locales/fr.d.ts +0 -0
  35. /package/dist/{events → modules/events}/locales/it.d.ts +0 -0
  36. /package/dist/{events → modules/events}/locales/locales.d.ts +0 -0
  37. /package/dist/{events → modules/events}/locales/pt.d.ts +0 -0
  38. /package/dist/{events → modules/events}/tenants/bouygues/bouygues.d.ts +0 -0
  39. /package/dist/{events → modules/events}/tenants/index.d.ts +0 -0
  40. /package/dist/{events → modules/events}/tenants/tenants.test.d.ts +0 -0
  41. /package/dist/{events → modules/events}/types.d.ts +0 -0
  42. /package/dist/{events → modules/events}/utils/amounts/amounts.d.ts +0 -0
  43. /package/dist/{events → modules/events}/utils/amounts/amounts.test.d.ts +0 -0
  44. /package/dist/{events → modules/events}/utils/credits/credits.d.ts +0 -0
  45. /package/dist/{events → modules/events}/utils/credits/credits.test.d.ts +0 -0
  46. /package/dist/{events → modules/events}/utils/lineFunnel/lineFunnel.d.ts +0 -0
  47. /package/dist/{events → modules/events}/utils/lineFunnel/lineFunnel.test.d.ts +0 -0
  48. /package/dist/{events → modules/events}/utils/payload/payload.d.ts +0 -0
  49. /package/dist/{events → modules/events}/utils/payload/payload.test.d.ts +0 -0
  50. /package/dist/{events → modules/events}/utils/readEvent/readEvent.d.ts +0 -0
  51. /package/dist/{events → modules/events}/utils/readEvent/readEvent.test.d.ts +0 -0
  52. /package/dist/{events → modules/events}/utils/steps/steps.d.ts +0 -0
  53. /package/dist/{events → modules/events}/utils/steps/steps.test.d.ts +0 -0
  54. /package/dist/{hourSheets → modules/hourSheets}/constants.d.ts +0 -0
  55. /package/dist/{hourSheets → modules/hourSheets}/index.d.ts +0 -0
  56. /package/dist/{hourSheets → modules/hourSheets}/utils/billingReferences/billingReferences.d.ts +0 -0
  57. /package/dist/{hourSheets → modules/hourSheets}/utils/billingReferences/billingReferences.test.d.ts +0 -0
  58. /package/dist/{hourSheets → modules/hourSheets}/utils/imputation/imputation.d.ts +0 -0
  59. /package/dist/{hourSheets → modules/hourSheets}/utils/imputation/imputation.test.d.ts +0 -0
  60. /package/dist/{hourSheets → modules/hourSheets}/utils/readCostCentres/readCostCentres.d.ts +0 -0
  61. /package/dist/{hourSheets → modules/hourSheets}/utils/readCostCentres/readCostCentres.test.d.ts +0 -0
  62. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetBlocker/sheetBlocker.d.ts +0 -0
  63. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetBlocker/sheetBlocker.test.d.ts +0 -0
  64. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetDays/sheetDays.d.ts +0 -0
  65. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetDays/sheetDays.test.d.ts +0 -0
  66. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetLines/sheetLines.test.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { ServerEvent } from '../chat/types';
2
+ import { ServerEvent } from '../types';
3
3
  type EventListener = (event: ServerEvent) => void;
4
4
  type ChatContext = "client" | "supplier";
5
5
  export interface ChatProviderProps {
@@ -1,5 +1,5 @@
1
- import { UseChatParams } from '../chat/types';
2
1
  import { ChatContextValue } from '../context/ChatProvider';
2
+ import { UseChatParams } from '../types';
3
3
  type UseChatReturn = Omit<ChatContextValue, "subscribe" | "setEnabled">;
4
4
  /**
5
5
  * Hook to access the shared WebSocket chat connection.
@@ -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">) => 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
@@ -1,5 +1,5 @@
1
1
  import { roundToHundredths as e, toNumberOrNull as t } from "@getsoren/react-utils";
2
- //#region src/hourSheets/constants.ts
2
+ //#region src/modules/hourSheets/constants.ts
3
3
  var n = "HOUR_SHEET", r = "plan_de_compte", i = "centre_de_cout", a = "billing_reference", o = [
4
4
  i,
5
5
  "code_tache",
@@ -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.0",
3
+ "version": "2.71.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",
@@ -15,17 +15,17 @@
15
15
  "default": "./dist/main.js"
16
16
  },
17
17
  "./documentImport": {
18
- "types": "./dist/documentImport/index.d.ts",
18
+ "types": "./dist/modules/documentImport/index.d.ts",
19
19
  "import": "./dist/documentImport.js",
20
20
  "default": "./dist/documentImport.js"
21
21
  },
22
22
  "./events": {
23
- "types": "./dist/events/index.d.ts",
23
+ "types": "./dist/modules/events/index.d.ts",
24
24
  "import": "./dist/events.js",
25
25
  "default": "./dist/events.js"
26
26
  },
27
27
  "./hourSheets": {
28
- "types": "./dist/hourSheets/index.d.ts",
28
+ "types": "./dist/modules/hourSheets/index.d.ts",
29
29
  "import": "./dist/hourSheets.js",
30
30
  "default": "./dist/hourSheets.js"
31
31
  },
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