@getsoren/shared-module 2.57.0 → 2.59.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.
@@ -8,6 +8,7 @@ export declare const CLIENT_EVENTS: {
8
8
  amountGate: "known";
9
9
  dates: "single";
10
10
  dayHint: "breakage";
11
+ defaultsToToday: true;
11
12
  hasIntervention: true;
12
13
  id: string;
13
14
  price: "amount";
@@ -17,9 +18,10 @@ export declare const CLIENT_EVENTS: {
17
18
  reason: string;
18
19
  };
19
20
  breakdown: {
20
- amountGate: "known";
21
21
  dates: "range";
22
+ defaultsToToday: true;
22
23
  hasIntervention: true;
24
+ hasOptionalAmount: true;
23
25
  id: string;
24
26
  price: "credit";
25
27
  questions: {
@@ -74,6 +76,7 @@ export declare const CLIENT_EVENTS: {
74
76
  inventory: {
75
77
  closesOnSubmit: true;
76
78
  id: string;
79
+ isProof: true;
77
80
  photos: "focus";
78
81
  reason: string;
79
82
  };
@@ -10,9 +10,13 @@ export interface UseEventDeclarationParams {
10
10
  lastReBillRatio?: string;
11
11
  /** An edit asks every question again, the reason included. */
12
12
  isEditing?: boolean;
13
+ /**
14
+ * Today (YYYY-MM-DD) when the order's calendar offers it: an event declared the day it happens starts on it.
15
+ */
16
+ today?: string;
13
17
  }
14
18
  /** The declaration of an event, step by step, whatever renders it. */
15
- declare const useEventDeclaration: ({ funnel, countBillableDays, dailyPrice, lastReBillRatio, isEditing, }: UseEventDeclarationParams) => {
19
+ declare const useEventDeclaration: ({ funnel, countBillableDays, dailyPrice, lastReBillRatio, isEditing, today, }: UseEventDeclarationParams) => {
16
20
  amounts: import('../../utils/amounts/amounts').EventAmounts;
17
21
  answers: EventAnswers;
18
22
  asksAmount: boolean;
@@ -61,7 +61,7 @@ declare const EVENTS_FR: {
61
61
  readonly quantity: "Nombre d'heures effectuées";
62
62
  readonly serial_number: "Numéro de série";
63
63
  readonly site_escort: "Accompagnateur chantier";
64
- readonly supplier_reference: "Référence interne du loueur";
64
+ readonly supplier_reference: "Référence interne du fournisseur";
65
65
  };
66
66
  readonly groupQuestions: {
67
67
  readonly controls: "Quel contrôle ?";
@@ -105,7 +105,7 @@ declare const EVENTS_FR: {
105
105
  readonly newEnd: "Jusqu'à quand prolonger ?";
106
106
  readonly period: "Sur quels jours ?";
107
107
  readonly photos: "Quelles photos joindre ?";
108
- readonly priceKnown: "Avez-vous déjà le montant du loueur ?";
108
+ readonly priceKnown: "Avez-vous déjà le montant du fournisseur ?";
109
109
  readonly robberyDay: "Quand avez-vous constaté le vol ?";
110
110
  readonly robberyKind: "Qu'est-ce qui a été volé ?";
111
111
  readonly stoppageKind: "Pourquoi la machine est-elle arrêtée ?";
@@ -151,7 +151,7 @@ declare const EVENTS_FR: {
151
151
  readonly description: "Commentaire";
152
152
  readonly document_type: "Type de document";
153
153
  readonly final_toDate: "Dernier jour d'utilisation";
154
- readonly intervention: "Le loueur doit intervenir sur place";
154
+ readonly intervention: "Le fournisseur doit intervenir sur place";
155
155
  readonly inventory_type: "Type d'état des lieux";
156
156
  readonly new_toDate: "Nouvelle date de fin";
157
157
  readonly re_bill_ratio: "Refacturation";
@@ -50,12 +50,18 @@ export interface EventDefinition {
50
50
  amountGate?: EventAmountGate;
51
51
  /** The amount asked can be left empty: the event is then declared without one. */
52
52
  hasOptionalAmount?: boolean;
53
+ /**
54
+ * Most often declared the day it happens: its dates start on today, when the app proposes it.
55
+ */
56
+ defaultsToToday?: boolean;
53
57
  /** Bills hours over the period instead of days. */
54
58
  billingType?: "DELTA";
55
59
  /** Photos are the point of the event (`focus`), asked first (`first`) or not asked (`none`); optional otherwise. */
56
60
  photos?: "first" | "focus" | "none";
57
61
  /** Closed on submit for the users allowed to close events. */
58
62
  closesOnSubmit?: boolean;
63
+ /** A dated proof: the other side only reads it, and never corrects what may be held against it. */
64
+ isProof?: boolean;
59
65
  questions?: Partial<Record<EventQuestionStep, EventQuestionKey>>;
60
66
  /** Shown on the hovered and picked day of a one-day event. */
61
67
  dayHint?: EventDayHintKey;
@@ -13,7 +13,7 @@ interface StoredEvent {
13
13
  * An event declared with this engine, read with the definition it was declared with: a tenant whose funnel changes
14
14
  * keeps reading its older events right. The reader edits it with its own definition when that one asks the same
15
15
  * answers, a client edits a supplier's with the supplier's questions, and the event is only shown otherwise (another
16
- * team's, a client's read by a supplier). Undefined for a Treege event.
16
+ * team's, a client's read by a supplier, a proof read by the other side). Undefined for a Treege event.
17
17
  */
18
18
  declare const readEvent: ({ workflow, workflowValues }: StoredEvent, readerFunnel: EventFunnel) => DeclaredEvent | undefined;
19
19
  export default readEvent;
package/dist/events.js CHANGED
@@ -13,6 +13,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
13
13
  amountGate: "known",
14
14
  dates: "single",
15
15
  dayHint: "breakage",
16
+ defaultsToToday: !0,
16
17
  hasIntervention: !0,
17
18
  id: "breakage",
18
19
  price: "amount",
@@ -20,9 +21,10 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
20
21
  reason: "break_repair"
21
22
  },
22
23
  breakdown: {
23
- amountGate: "known",
24
24
  dates: "range",
25
+ defaultsToToday: !0,
25
26
  hasIntervention: !0,
27
+ hasOptionalAmount: !0,
26
28
  id: "breakdown",
27
29
  price: "credit",
28
30
  questions: {
@@ -77,6 +79,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
77
79
  [o]: {
78
80
  closesOnSubmit: !0,
79
81
  id: o,
82
+ isProof: !0,
80
83
  photos: "focus",
81
84
  reason: o
82
85
  },
@@ -348,7 +351,9 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
348
351
  reasons: ["booking_end", "booking_extension"]
349
352
  },
350
353
  {
354
+ closesOnSubmit: !0,
351
355
  id: o,
356
+ isProof: !0,
352
357
  photos: "first",
353
358
  questions: {
354
359
  details: "photos",
@@ -594,93 +599,97 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
594
599
  reason: "",
595
600
  reBillRatio: "",
596
601
  title: ""
597
- }, k = ({ funnel: n, countBillableDays: r, dailyPrice: i, lastReBillRatio: a = "", isEditing: o = !1 }) => {
598
- let [s, c] = t(), [l, u] = t(), [d, f] = t("kind"), [p, g] = t(O), [b, x] = t(!1), S = e(() => h(n), [n]), C = S.find(({ id: e }) => e === s), w = C?.events.find(({ id: e }) => e === l), { showsPrice: T, asksReBillRatio: E } = n.pricing, k = m(w, p, w?.dates === "range" ? r(p.dates) : 1), A = T && !!w?.price, j = A && !k.hasNothingToBill, M = _(C, w, p, j), N = M[M.indexOf(d) - 1], P = (e) => g((t) => ({
602
+ }, k = ({ funnel: n, countBillableDays: r, dailyPrice: i, lastReBillRatio: a = "", isEditing: o = !1, today: s }) => {
603
+ let [c, l] = t(), [u, d] = t(), [f, p] = t("kind"), [g, b] = t(O), [x, S] = t(!1), C = e(() => h(n), [n]), w = C.find(({ id: e }) => e === c), T = w?.events.find(({ id: e }) => e === u), { showsPrice: E, asksReBillRatio: k } = n.pricing, A = m(T, g, T?.dates === "range" ? r(g.dates) : 1), j = E && !!T?.price, M = j && !A.hasNothingToBill, N = _(w, T, g, M), P = N[N.indexOf(f) - 1], F = (e) => b((t) => ({
599
604
  ...t,
600
605
  ...e
601
- })), F = (e) => e.price === "credit" && i ? String(Math.abs(i)) : "", I = (e, t) => {
602
- let n = _(C, w, t, j);
606
+ })), I = (e) => e.price === "credit" && i ? String(Math.abs(i)) : "", L = (e, t) => {
607
+ let n = _(w, T, t, M);
603
608
  return n[n.indexOf(e) + 1] ?? "details";
604
- }, L = () => {
605
- c(void 0), u(void 0), f("kind"), g(O), x(!1);
606
- }, R = (e, t, n = {}) => {
609
+ }, R = () => {
610
+ l(void 0), d(void 0), p("kind"), b(O), S(!1);
611
+ }, z = (e, t, n = {}) => {
607
612
  let r = {
608
613
  ...O,
609
- amount: F(t),
614
+ amount: I(t),
615
+ dates: t.defaultsToToday && s ? {
616
+ fromDate: s,
617
+ toDate: s
618
+ } : O.dates,
610
619
  reason: t.reasons?.length ? "" : t.reason ?? "",
611
- reBillRatio: E ? a : "",
620
+ reBillRatio: k ? a : "",
612
621
  ...n
613
622
  };
614
- c(e.id), u(t.id), g(r), f(v(_(e, t, r, T && !!t.price), r, o));
615
- }, z = ({ eventId: e, answers: t }) => {
616
- let n = S.find(({ events: t }) => t.some(({ id: t }) => t === e)), r = n?.events.find(({ id: t }) => t === e);
617
- return n && r ? (R(n, r, t), x(!0), !0) : !1;
618
- }, B = (e, t) => {
623
+ l(e.id), d(t.id), b(r), p(v(_(e, t, r, E && !!t.price), r, o));
624
+ }, B = ({ eventId: e, answers: t }) => {
625
+ let n = C.find(({ events: t }) => t.some(({ id: t }) => t === e)), r = n?.events.find(({ id: t }) => t === e);
626
+ return n && r ? (z(n, r, t), S(!0), !0) : !1;
627
+ }, V = (e, t) => {
619
628
  if (e.events.length === 1) {
620
- R(e, e.events[0], t);
629
+ z(e, e.events[0], t);
621
630
  return;
622
631
  }
623
- c(e.id), u(void 0), f("event");
624
- }, V = (e) => {
625
- C && R(C, e);
626
- }, H = () => f(I(d, p)), U = (e) => {
627
- let t = w?.endDates && e !== p.reason ? {
632
+ l(e.id), d(void 0), p("event");
633
+ }, H = (e) => {
634
+ w && z(w, e);
635
+ }, U = () => p(L(f, g)), W = (e) => {
636
+ let t = T?.endDates && e !== g.reason ? {
628
637
  dates: O.dates,
629
638
  reason: e
630
639
  } : { reason: e }, n = {
631
- ...p,
640
+ ...g,
632
641
  ...t
633
642
  };
634
- P(t), f(I("reason", n));
635
- }, W = (e) => {
643
+ F(t), p(L("reason", n));
644
+ }, G = (e) => {
636
645
  let t = {
637
- amount: e && w ? p.amount || F(w) : "",
646
+ amount: e && T ? g.amount || I(T) : "",
638
647
  amountGate: e
639
648
  };
640
- P(t), f(I("amountGate", {
641
- ...p,
649
+ F(t), p(L("amountGate", {
650
+ ...g,
642
651
  ...t
643
652
  }));
644
- }, G = () => {
645
- if (!N || N === "kind") {
646
- L();
653
+ }, K = () => {
654
+ if (!P || P === "kind") {
655
+ R();
647
656
  return;
648
657
  }
649
- f(N);
650
- }, K = !!w && M.every((e) => y(e, w, p)), q = o && !T && !k.hasNothingToBill;
658
+ p(P);
659
+ }, q = !!T && N.every((e) => y(e, T, g)), J = o && !E && !A.hasNothingToBill;
651
660
  return {
652
- amounts: k,
653
- answers: p,
654
- asksAmount: j,
655
- buildPayload: (e, t) => w && K ? D({
656
- answers: p,
657
- billableDays: k.billableDays,
661
+ amounts: A,
662
+ answers: g,
663
+ asksAmount: M,
664
+ buildPayload: (e, t) => T && q ? D({
665
+ answers: g,
666
+ billableDays: A.billableDays,
658
667
  bookingItemId: t,
659
- event: w,
668
+ event: T,
660
669
  funnel: n,
661
670
  translate: e,
662
- withPrice: j || q,
663
- withReBillRatio: E || o
671
+ withPrice: M || J,
672
+ withReBillRatio: k || o
664
673
  }) : void 0,
665
- canGoBack: d !== "kind" && !(b && (N === "kind" || N === "event")),
666
- canGoNext: !!w && y(d, w, p),
667
- event: w,
668
- goBack: G,
669
- goNext: H,
670
- group: C,
671
- groups: S,
672
- isComplete: K,
673
- isPriced: A,
674
- reset: L,
675
- selectAmountGate: W,
676
- selectEvent: V,
677
- selectGroup: B,
678
- selectReason: U,
679
- setAnswers: P,
680
- showsReBillRatio: E && A,
681
- startPrefill: z,
682
- step: d,
683
- steps: M
674
+ canGoBack: f !== "kind" && !(x && (P === "kind" || P === "event")),
675
+ canGoNext: !!T && y(f, T, g),
676
+ event: T,
677
+ goBack: K,
678
+ goNext: U,
679
+ group: w,
680
+ groups: C,
681
+ isComplete: q,
682
+ isPriced: j,
683
+ reset: R,
684
+ selectAmountGate: G,
685
+ selectEvent: H,
686
+ selectGroup: V,
687
+ selectReason: W,
688
+ setAnswers: F,
689
+ showsReBillRatio: k && j,
690
+ startPrefill: B,
691
+ step: f,
692
+ steps: N
684
693
  };
685
694
  }, A = {
686
695
  ar: {
@@ -746,7 +755,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
746
755
  quantity: "عدد الساعات المنجزة",
747
756
  serial_number: "الرقم التسلسلي",
748
757
  site_escort: "مرافق الموقع",
749
- supplier_reference: "المرجع الداخلي للمؤجر"
758
+ supplier_reference: "المرجع الداخلي للمورد"
750
759
  },
751
760
  groupQuestions: {
752
761
  controls: "أي فحص؟",
@@ -790,7 +799,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
790
799
  newEnd: "حتى متى التمديد؟",
791
800
  period: "أي أيام؟",
792
801
  photos: "ما الصور التي تريد إرفاقها؟",
793
- priceKnown: "هل لديك مبلغ المؤجر بالفعل؟",
802
+ priceKnown: "هل لديك مبلغ المورد بالفعل؟",
794
803
  robberyDay: "متى لاحظت السرقة؟",
795
804
  robberyKind: "ما الذي سُرق؟",
796
805
  stoppageKind: "لماذا توقفت الآلة؟",
@@ -836,7 +845,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
836
845
  description: "تعليق",
837
846
  document_type: "نوع المستند",
838
847
  final_toDate: "آخر يوم استخدام",
839
- intervention: "يجب أن يتدخل المؤجر في الموقع",
848
+ intervention: "يجب أن يتدخل المورد في الموقع",
840
849
  inventory_type: "نوع محضر الحالة",
841
850
  new_toDate: "تاريخ النهاية الجديد",
842
851
  re_bill_ratio: "إعادة الفوترة",
@@ -907,7 +916,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
907
916
  quantity: "Geleistete Stunden",
908
917
  serial_number: "Seriennummer",
909
918
  site_escort: "Begleitung auf der Baustelle",
910
- supplier_reference: "Interne Referenz des Vermieters"
919
+ supplier_reference: "Interne Referenz des Lieferanten"
911
920
  },
912
921
  groupQuestions: {
913
922
  controls: "Welche Prüfung?",
@@ -951,7 +960,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
951
960
  newEnd: "Bis wann verlängern?",
952
961
  period: "An welchen Tagen?",
953
962
  photos: "Welche Fotos anhängen?",
954
- priceKnown: "Haben Sie den Betrag des Vermieters schon?",
963
+ priceKnown: "Haben Sie den Betrag des Lieferanten schon?",
955
964
  robberyDay: "Wann haben Sie den Diebstahl bemerkt?",
956
965
  robberyKind: "Was wurde gestohlen?",
957
966
  stoppageKind: "Warum steht die Maschine still?",
@@ -997,7 +1006,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
997
1006
  description: "Kommentar",
998
1007
  document_type: "Dokumententyp",
999
1008
  final_toDate: "Letzter Nutzungstag",
1000
- intervention: "Der Vermieter muss vor Ort eingreifen",
1009
+ intervention: "Der Lieferant muss vor Ort eingreifen",
1001
1010
  inventory_type: "Art des Zustandsprotokolls",
1002
1011
  new_toDate: "Neues Enddatum",
1003
1012
  re_bill_ratio: "Weiterberechnung",
@@ -1390,7 +1399,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1390
1399
  quantity: "Nombre d'heures effectuées",
1391
1400
  serial_number: "Numéro de série",
1392
1401
  site_escort: "Accompagnateur chantier",
1393
- supplier_reference: "Référence interne du loueur"
1402
+ supplier_reference: "Référence interne du fournisseur"
1394
1403
  },
1395
1404
  groupQuestions: {
1396
1405
  controls: "Quel contrôle ?",
@@ -1434,7 +1443,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1434
1443
  newEnd: "Jusqu'à quand prolonger ?",
1435
1444
  period: "Sur quels jours ?",
1436
1445
  photos: "Quelles photos joindre ?",
1437
- priceKnown: "Avez-vous déjà le montant du loueur ?",
1446
+ priceKnown: "Avez-vous déjà le montant du fournisseur ?",
1438
1447
  robberyDay: "Quand avez-vous constaté le vol ?",
1439
1448
  robberyKind: "Qu'est-ce qui a été volé ?",
1440
1449
  stoppageKind: "Pourquoi la machine est-elle arrêtée ?",
@@ -1480,7 +1489,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1480
1489
  description: "Commentaire",
1481
1490
  document_type: "Type de document",
1482
1491
  final_toDate: "Dernier jour d'utilisation",
1483
- intervention: "Le loueur doit intervenir sur place",
1492
+ intervention: "Le fournisseur doit intervenir sur place",
1484
1493
  inventory_type: "Type d'état des lieux",
1485
1494
  new_toDate: "Nouvelle date de fin",
1486
1495
  re_bill_ratio: "Refacturation",
@@ -1551,7 +1560,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1551
1560
  quantity: "Ore lavorate",
1552
1561
  serial_number: "Numero di serie",
1553
1562
  site_escort: "Accompagnatore in cantiere",
1554
- supplier_reference: "Riferimento interno del noleggiatore"
1563
+ supplier_reference: "Riferimento interno del fornitore"
1555
1564
  },
1556
1565
  groupQuestions: {
1557
1566
  controls: "Quale controllo?",
@@ -1595,7 +1604,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1595
1604
  newEnd: "Fino a quando prolungare?",
1596
1605
  period: "Quali giorni?",
1597
1606
  photos: "Quali foto allegare?",
1598
- priceKnown: "Ha già l'importo del noleggiatore?",
1607
+ priceKnown: "Ha già l'importo del fornitore?",
1599
1608
  robberyDay: "Quando ha notato il furto?",
1600
1609
  robberyKind: "Che cosa è stato rubato?",
1601
1610
  stoppageKind: "Perché la macchina è ferma?",
@@ -1641,7 +1650,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1641
1650
  description: "Commento",
1642
1651
  document_type: "Tipo di documento",
1643
1652
  final_toDate: "Ultimo giorno di utilizzo",
1644
- intervention: "Il noleggiatore deve intervenire in cantiere",
1653
+ intervention: "Il fornitore deve intervenire in cantiere",
1645
1654
  inventory_type: "Tipo di verbale di stato",
1646
1655
  new_toDate: "Nuova data di fine",
1647
1656
  re_bill_ratio: "Rifatturazione",
@@ -1936,7 +1945,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1936
1945
  side: e.side
1937
1946
  } : {
1938
1947
  answers: o,
1939
- editFunnel: r && q(n.side, e.side) ? {
1948
+ editFunnel: r && !a.isProof && q(n.side, e.side) ? {
1940
1949
  ...r,
1941
1950
  pricing: n.pricing
1942
1951
  } : void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.57.0",
3
+ "version": "2.59.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",