@getsoren/shared-module 2.62.0 → 2.63.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.
@@ -5,11 +5,11 @@ import { EventFunnel } from '../types';
5
5
  */
6
6
  export declare const CLIENT_EVENTS: {
7
7
  breakage: {
8
- amountGate: "known";
9
8
  dates: "single";
10
9
  dayHint: "breakage";
11
10
  defaultsToToday: true;
12
11
  hasIntervention: true;
12
+ hasOptionalAmount: true;
13
13
  id: string;
14
14
  price: "amount";
15
15
  questions: {
@@ -31,9 +31,9 @@ export declare const CLIENT_EVENTS: {
31
31
  reason: string;
32
32
  };
33
33
  delivery_problem: {
34
- amountGate: "known";
35
34
  dates: "single";
36
35
  dayHint: "deliveryProblem";
36
+ hasOptionalAmount: true;
37
37
  id: string;
38
38
  price: "amount";
39
39
  questions: {
@@ -72,6 +72,7 @@ export declare const CLIENT_EVENTS: {
72
72
  id: string;
73
73
  price: "credit";
74
74
  reason: string;
75
+ suggestsDailyShare: true;
75
76
  };
76
77
  inventory: {
77
78
  closesOnSubmit: true;
@@ -102,9 +103,9 @@ export declare const CLIENT_EVENTS: {
102
103
  reason: string;
103
104
  };
104
105
  material_usage: {
105
- amountGate: "known";
106
106
  dates: "single";
107
107
  dayHint: "problem";
108
+ hasOptionalAmount: true;
108
109
  id: string;
109
110
  price: "amount";
110
111
  questions: {
@@ -160,17 +161,17 @@ export declare const CLIENT_EVENTS: {
160
161
  reason: string;
161
162
  };
162
163
  other: {
163
- amountGate: "known";
164
164
  dates: "single";
165
165
  dayHint: "event";
166
+ hasOptionalAmount: true;
166
167
  hasTitle: true;
167
168
  id: string;
168
169
  price: "amount";
169
170
  };
170
171
  other_material: {
171
- amountGate: "known";
172
172
  dates: "single";
173
173
  dayHint: "problem";
174
+ hasOptionalAmount: true;
174
175
  hasTitle: true;
175
176
  id: string;
176
177
  price: "amount";
@@ -186,9 +187,9 @@ export declare const CLIENT_EVENTS: {
186
187
  price: "amount";
187
188
  };
188
189
  robbery: {
189
- amountGate: "known";
190
190
  dates: "single";
191
191
  dayHint: "robbery";
192
+ hasOptionalAmount: true;
192
193
  id: string;
193
194
  price: "amount";
194
195
  questions: {
@@ -206,6 +207,7 @@ export declare const CLIENT_EVENTS: {
206
207
  dates: "weatherDays";
207
208
  };
208
209
  reason: string;
210
+ suggestsDailyShare: true;
209
211
  };
210
212
  };
211
213
  export type ClientEventId = keyof typeof CLIENT_EVENTS;
@@ -14,9 +14,13 @@ export interface UseEventDeclarationParams {
14
14
  * Today (YYYY-MM-DD) when the order's calendar offers it: an event declared the day it happens starts on it.
15
15
  */
16
16
  today?: string;
17
+ /**
18
+ * The one day (YYYY-MM-DD) of an order of one day: its events happen that day, their dates step is not asked.
19
+ */
20
+ onlyDay?: string;
17
21
  }
18
22
  /** The declaration of an event, step by step, whatever renders it. */
19
- declare const useEventDeclaration: ({ funnel, countBillableDays, dailyPrice, lastReBillRatio, isEditing, today, }: UseEventDeclarationParams) => {
23
+ declare const useEventDeclaration: ({ funnel, countBillableDays, dailyPrice, lastReBillRatio, isEditing, today, onlyDay, }: UseEventDeclarationParams) => {
20
24
  amounts: import('../../utils/amounts/amounts').EventAmounts;
21
25
  answers: EventAnswers;
22
26
  asksAmount: boolean;
@@ -53,6 +53,11 @@ export interface EventDefinition {
53
53
  amountGate?: EventAmountGate;
54
54
  /** The amount asked can be left empty: the event is then declared without one. */
55
55
  hasOptionalAmount?: boolean;
56
+ /**
57
+ * A credit a supplier settles as a share of the daily price over the days hit (half of it for these two days), the
58
+ * shares of `DAILY_PRICE_SHARES` offered before an amount per day.
59
+ */
60
+ suggestsDailyShare?: boolean;
56
61
  /**
57
62
  * The sum is billed or taken off the invoice, the user saying which (`answers.isCreditNote`): a credit note is
58
63
  * declared like an extra.
@@ -19,6 +19,18 @@ export declare const getUnitPrice: (event: EventDefinition, answers: Pick<EventA
19
19
  * A period of one day counts one whatever the calendar, as the backend bills it, and so does an event without a period.
20
20
  */
21
21
  export declare const getEventAmounts: (event: EventDefinition | undefined, answers: EventAnswers, billableDays: number) => EventAmounts;
22
+ /**
23
+ * The shares of the daily price a supplier usually deducts, in percent, the whole of it first.
24
+ */
25
+ export declare const DAILY_PRICE_SHARES: number[];
26
+ /**
27
+ * A share of the daily price, to the cent: 75 % of 36,50 € is 27,38 €.
28
+ */
29
+ export declare const getShareAmount: (dailyPrice: number, percent: number) => number;
30
+ /**
31
+ * The share an amount matches, if any: another amount is no share.
32
+ */
33
+ export declare const findShare: (dailyPrice: number, amount: number | null) => number | undefined;
22
34
  /**
23
35
  * Whether an event still waits for its amount: it has a price and none goes with it, though its days are billed and
24
36
  * nobody answered that there was nothing to bill. `isSent` is false for a user who sees no price, whose amount on
@@ -7,8 +7,11 @@ export interface FunnelGroup extends Omit<EventGroup, "events"> {
7
7
  export declare const getFunnelGroups: ({ groups, events }: EventFunnel) => FunnelGroup[];
8
8
  /** The one date of an end of rental, which depends on the end picked. */
9
9
  export declare const getEndDate: (event: EventDefinition, reason: string) => import('../../types').EventEndDate | undefined;
10
- /** `asksAmount` is false for a user who sees no price, or a credit that falls on no billed day. */
11
- export declare const getSteps: (group: FunnelGroup | undefined, event: EventDefinition | undefined, answers: EventAnswers, asksAmount: boolean) => EventStep[];
10
+ /**
11
+ * `asksAmount` is false for a user who sees no price, or a credit that falls on no billed day. `hasOnlyDay` is true on
12
+ * an order of one day, whose events happen that day: their dates are not asked (an end of rental still asks its own).
13
+ */
14
+ export declare const getSteps: (group: FunnelGroup | undefined, event: EventDefinition | undefined, answers: EventAnswers, asksAmount: boolean, hasOnlyDay?: boolean) => EventStep[];
12
15
  /** First question after the family and the event, skipping a reason already given unless asked again. */
13
16
  export declare const getFirstQuestion: (steps: EventStep[], answers: EventAnswers, asksAgain?: boolean) => EventStep;
14
17
  export declare const isStepAnswered: (step: EventStep, event: EventDefinition, answers: EventAnswers) => boolean;
package/dist/events.js CHANGED
@@ -10,11 +10,11 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
10
10
  unitPrice: "unitPrice"
11
11
  }, o = "inventory", s = {
12
12
  breakage: {
13
- amountGate: "known",
14
13
  dates: "single",
15
14
  dayHint: "breakage",
16
15
  defaultsToToday: !0,
17
16
  hasIntervention: !0,
17
+ hasOptionalAmount: !0,
18
18
  id: "breakage",
19
19
  price: "amount",
20
20
  questions: { reason: "breakageKind" },
@@ -34,9 +34,9 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
34
34
  reason: "breakdown"
35
35
  },
36
36
  delivery_problem: {
37
- amountGate: "known",
38
37
  dates: "single",
39
38
  dayHint: "deliveryProblem",
39
+ hasOptionalAmount: !0,
40
40
  id: "delivery_problem",
41
41
  price: "amount",
42
42
  questions: { reason: "deliveryProblemKind" },
@@ -74,7 +74,8 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
74
74
  hasOptionalAmount: !0,
75
75
  id: "immobilisation",
76
76
  price: "credit",
77
- reason: "immobilisation"
77
+ reason: "immobilisation",
78
+ suggestsDailyShare: !0
78
79
  },
79
80
  [o]: {
80
81
  closesOnSubmit: !0,
@@ -111,9 +112,9 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
111
112
  reason: "Affectation machine"
112
113
  },
113
114
  material_usage: {
114
- amountGate: "known",
115
115
  dates: "single",
116
116
  dayHint: "problem",
117
+ hasOptionalAmount: !0,
117
118
  id: "material_usage",
118
119
  price: "amount",
119
120
  questions: { reason: "materialUsageKind" },
@@ -188,17 +189,17 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
188
189
  reason: "operator_change"
189
190
  },
190
191
  other: {
191
- amountGate: "known",
192
192
  dates: "single",
193
193
  dayHint: "event",
194
+ hasOptionalAmount: !0,
194
195
  hasTitle: !0,
195
196
  id: "other",
196
197
  price: "amount"
197
198
  },
198
199
  other_material: {
199
- amountGate: "known",
200
200
  dates: "single",
201
201
  dayHint: "problem",
202
+ hasOptionalAmount: !0,
202
203
  hasTitle: !0,
203
204
  id: "other_material",
204
205
  price: "amount"
@@ -214,9 +215,9 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
214
215
  price: "amount"
215
216
  },
216
217
  robbery: {
217
- amountGate: "known",
218
218
  dates: "single",
219
219
  dayHint: "robbery",
220
+ hasOptionalAmount: !0,
220
221
  id: "robbery",
221
222
  price: "amount",
222
223
  questions: {
@@ -231,7 +232,8 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
231
232
  id: "weather",
232
233
  price: "credit",
233
234
  questions: { dates: "weatherDays" },
234
- reason: "weather"
235
+ reason: "weather",
236
+ suggestsDailyShare: !0
235
237
  }
236
238
  }, c = {
237
239
  admin_request: {
@@ -445,36 +447,41 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
445
447
  total: a === null ? null : a * o,
446
448
  unitPrice: a
447
449
  };
448
- }, h = (e, { hasNothingToBill: t, unitPrice: n }, r = !0) => !!e.price && !(r && n !== null) && !t && e.amountGate !== "billed", g = ({ groups: e, events: t }) => e.flatMap((e) => {
450
+ }, h = [
451
+ 100,
452
+ 75,
453
+ 50,
454
+ 25
455
+ ], g = (e, t) => Math.round(e * t) / 100, _ = (e, t) => h.find((n) => t === g(e, n)), v = (e, { hasNothingToBill: t, unitPrice: n }, r = !0) => !!e.price && !(r && n !== null) && !t && e.amountGate !== "billed", y = ({ groups: e, events: t }) => e.flatMap((e) => {
449
456
  let n = t.filter(({ id: t }) => e.events.includes(t));
450
457
  return n.length ? [{
451
458
  ...e,
452
459
  events: n
453
460
  }] : [];
454
- }), _ = (e, t) => e.endDates?.[t], v = (e, t, n, r) => [
461
+ }), b = (e, t) => e.endDates?.[t], x = (e, t, n, r, i = !1) => [
455
462
  "kind",
456
463
  ...(e?.events.length ?? 0) > 1 ? ["event"] : [],
457
464
  ...t?.reasons?.length ? ["reason"] : [],
458
- ...t?.dates || t && _(t, n.reason) ? ["dates"] : [],
465
+ ...t?.dates && !i || t && b(t, n.reason) ? ["dates"] : [],
459
466
  ...t?.checks?.length ? ["checks"] : [],
460
467
  ...t?.hasTitle || t?.fields?.length ? ["fields"] : [],
461
468
  ...r && t?.price && t.amountGate ? ["amountGate"] : [],
462
469
  ...r && t?.price && (!t.amountGate || n.amountGate) ? ["amount"] : [],
463
470
  ...t ? ["details"] : []
464
- ], y = (e, t, n = !1) => e.find((e) => e !== "kind" && e !== "event" && (n || e !== "reason" || !t.reason)) ?? "details", b = ({ name: e, required: t, type: n }, { fields: r }) => {
471
+ ], S = (e, t, n = !1) => e.find((e) => e !== "kind" && e !== "event" && (n || e !== "reason" || !t.reason)) ?? "details", C = ({ name: e, required: t, type: n }, { fields: r }) => {
465
472
  let i = r[e]?.trim() ?? "";
466
473
  return i ? n !== "number" || f(i) !== null : !t;
467
- }, x = (e, t, n) => {
474
+ }, w = (e, t, n) => {
468
475
  switch (e) {
469
476
  case "reason": return !!n.reason;
470
477
  case "dates": return !!(n.dates.fromDate && n.dates.toDate);
471
- case "fields": return (!t.hasTitle || !!n.title.trim()) && (t.fields ?? []).every((e) => b(e, n));
478
+ case "fields": return (!t.hasTitle || !!n.title.trim()) && (t.fields ?? []).every((e) => C(e, n));
472
479
  case "amountGate": return n.amountGate !== void 0;
473
480
  case "amount": return !!t.hasOptionalAmount && !n.isCreditNote || p(t, n) !== null;
474
481
  default: return !0;
475
482
  }
476
- }, S = (e, t) => e.hasTitle ? t.title.trim() : e.reasonDetail ? e.reason ?? "" : t.reason || (e.reason ?? ""), C = (e, t, n) => {
477
- let r = S(e, t);
483
+ }, T = (e, t) => e.hasTitle ? t.title.trim() : e.reasonDetail ? e.reason ?? "" : t.reason || (e.reason ?? ""), E = (e, t, n) => {
484
+ let r = T(e, t);
478
485
  if (e.hasTitle) return {
479
486
  label: n("values.title"),
480
487
  name: a.reason,
@@ -493,8 +500,8 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
493
500
  value: r
494
501
  }
495
502
  };
496
- }, w = (e, { dates: { fromDate: t, toDate: n }, reason: r }, i) => {
497
- let o = _(e, r);
503
+ }, D = (e, { dates: { fromDate: t, toDate: n }, reason: r }, i) => {
504
+ let o = b(e, r);
498
505
  return t && n ? o ? [{
499
506
  label: i(`values.${o.name}`),
500
507
  name: o.name,
@@ -511,18 +518,18 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
511
518
  type: "date",
512
519
  value: t
513
520
  }] : [] : [];
514
- }, T = (e, t) => {
521
+ }, O = (e, t) => {
515
522
  let n = e === "number" ? f(t) : null;
516
523
  return n === null ? t.trim() : String(n);
517
- }, E = "dedicated", D = (e, t) => ({
524
+ }, k = "dedicated", A = (e, t) => ({
518
525
  eventId: t,
519
- funnel: E,
526
+ funnel: k,
520
527
  side: e,
521
528
  source: r,
522
529
  version: 2
523
- }), O = (e) => typeof e == "object" && !!e && "source" in e && e.source === "soren-event" && "eventId" in e && typeof e.eventId == "string", k = ({ funnel: e, event: t, answers: n, translate: i, bookingItemId: o, withPrice: s, billableDays: c, withReBillRatio: l = e.pricing.asksReBillRatio }) => {
530
+ }), j = (e) => typeof e == "object" && !!e && "source" in e && e.source === "soren-event" && "eventId" in e && typeof e.eventId == "string", M = ({ funnel: e, event: t, answers: n, translate: i, bookingItemId: o, withPrice: s, billableDays: c, withReBillRatio: l = e.pricing.asksReBillRatio }) => {
524
531
  let { fromDate: u, toDate: d } = n.dates, m = !!(t.dates && u && d) && c !== 0, h = s ? p(t, n) : null, g = f(n.reBillRatio), _ = n.description.trim(), v = t.billingType === "DELTA", y = f(n.fields.quantity ?? ""), b = [
525
- C(t, n, i),
532
+ E(t, n, i),
526
533
  ...t.reasonDetail && n.reason ? [{
527
534
  label: i(`values.${t.reasonDetail}`),
528
535
  name: t.reasonDetail,
@@ -532,7 +539,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
532
539
  value: n.reason
533
540
  }
534
541
  }] : [],
535
- ...w(t, n, i),
542
+ ...D(t, n, i),
536
543
  ..._ ? [{
537
544
  label: i("values.description"),
538
545
  name: a.description,
@@ -550,7 +557,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
550
557
  label: i(`fields.${e}`),
551
558
  name: e,
552
559
  type: t,
553
- value: T(t, n.fields[e])
560
+ value: O(t, n.fields[e])
554
561
  })),
555
562
  ...t.hasIntervention ? [{
556
563
  label: i("values.intervention"),
@@ -590,7 +597,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
590
597
  quantity: y
591
598
  }
592
599
  };
593
- }, A = {
600
+ }, N = {
594
601
  amount: "",
595
602
  checks: {},
596
603
  dates: {
@@ -603,99 +610,102 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
603
610
  reason: "",
604
611
  reBillRatio: "",
605
612
  title: ""
606
- }, j = ({ funnel: n, countBillableDays: r, dailyPrice: i, lastReBillRatio: a = "", isEditing: o = !1, today: s }) => {
607
- let [c, l] = t(), [u, d] = t(), [f, p] = t("kind"), [h, _] = t(A), [b, S] = t(!1), C = e(() => g(n), [n]), w = C.find(({ id: e }) => e === c), T = w?.events.find(({ id: e }) => e === u), { showsPrice: E, asksReBillRatio: D } = n.pricing, O = m(T, h, T?.dates === "range" ? r(h.dates) : 1), j = E && !!T?.price, M = j && !O.hasNothingToBill, N = v(w, T, h, M), P = N[N.indexOf(f) - 1], F = (e) => _((t) => ({
613
+ }, P = ({ funnel: n, countBillableDays: r, dailyPrice: i, lastReBillRatio: a = "", isEditing: o = !1, today: s, onlyDay: c }) => {
614
+ let [l, u] = t(), [d, f] = t(), [p, h] = t("kind"), [g, _] = t(N), [v, b] = t(!1), C = e(() => y(n), [n]), T = C.find(({ id: e }) => e === l), E = T?.events.find(({ id: e }) => e === d), { showsPrice: D, asksReBillRatio: O } = n.pricing, k = m(E, g, E?.dates === "range" ? r(g.dates) : 1), A = D && !!E?.price, j = A && !k.hasNothingToBill, P = x(T, E, g, j, !!c), F = P[P.indexOf(p) - 1], I = (e) => _((t) => ({
608
615
  ...t,
609
616
  ...e
610
- })), I = (e) => e.price === "credit" && i ? String(Math.abs(i)) : "", L = (e, t) => {
611
- let n = v(w, T, t, M);
617
+ })), L = (e) => c && e.dates ? {
618
+ fromDate: c,
619
+ toDate: c
620
+ } : e.defaultsToToday && s ? {
621
+ fromDate: s,
622
+ toDate: s
623
+ } : N.dates, R = (e) => e.price === "credit" && i ? String(Math.abs(i)) : "", z = (e, t) => {
624
+ let n = x(T, E, t, j, !!c);
612
625
  return n[n.indexOf(e) + 1] ?? "details";
613
- }, R = () => {
614
- l(void 0), d(void 0), p("kind"), _(A), S(!1);
615
- }, z = (e, t, n = {}) => {
626
+ }, B = () => {
627
+ u(void 0), f(void 0), h("kind"), _(N), b(!1);
628
+ }, V = (e, t, n = {}) => {
616
629
  let r = {
617
- ...A,
618
- amount: I(t),
619
- dates: t.defaultsToToday && s ? {
620
- fromDate: s,
621
- toDate: s
622
- } : A.dates,
630
+ ...N,
631
+ amount: R(t),
632
+ dates: L(t),
623
633
  reason: t.reasons?.length ? "" : t.reason ?? "",
624
- reBillRatio: D ? a : "",
634
+ reBillRatio: O ? a : "",
625
635
  ...n
626
636
  };
627
- l(e.id), d(t.id), _(r), p(y(v(e, t, r, E && !!t.price), r, o));
628
- }, B = ({ eventId: e, answers: t }) => {
637
+ u(e.id), f(t.id), _(r), h(S(x(e, t, r, D && !!t.price, !!c), r, o));
638
+ }, H = ({ eventId: e, answers: t }) => {
629
639
  let n = C.find(({ events: t }) => t.some(({ id: t }) => t === e)), r = n?.events.find(({ id: t }) => t === e);
630
- return n && r ? (z(n, r, t), S(!0), !0) : !1;
631
- }, V = (e, t) => {
640
+ return n && r ? (V(n, r, t), b(!0), !0) : !1;
641
+ }, U = (e, t) => {
632
642
  if (e.events.length === 1) {
633
- z(e, e.events[0], t);
643
+ V(e, e.events[0], t);
634
644
  return;
635
645
  }
636
- l(e.id), d(void 0), p("event");
637
- }, H = (e) => {
638
- w && z(w, e);
639
- }, U = () => p(L(f, h)), W = (e) => {
640
- let t = T?.endDates && e !== h.reason ? {
641
- dates: A.dates,
646
+ u(e.id), f(void 0), h("event");
647
+ }, W = (e) => {
648
+ T && V(T, e);
649
+ }, G = () => h(z(p, g)), K = (e) => {
650
+ let t = E?.endDates && e !== g.reason ? {
651
+ dates: N.dates,
642
652
  reason: e
643
653
  } : { reason: e }, n = {
644
- ...h,
654
+ ...g,
645
655
  ...t
646
656
  };
647
- F(t), p(L("reason", n));
648
- }, G = (e) => {
657
+ I(t), h(z("reason", n));
658
+ }, q = (e) => {
649
659
  let t = {
650
- amount: e && T ? h.amount || I(T) : "",
660
+ amount: e && E ? g.amount || R(E) : "",
651
661
  amountGate: e
652
662
  };
653
- F(t), p(L("amountGate", {
654
- ...h,
663
+ I(t), h(z("amountGate", {
664
+ ...g,
655
665
  ...t
656
666
  }));
657
- }, K = () => {
658
- if (!P || P === "kind") {
659
- R();
667
+ }, J = () => {
668
+ if (!F || F === "kind") {
669
+ B();
660
670
  return;
661
671
  }
662
- p(P);
663
- }, q = !!T && N.every((e) => x(e, T, h)), J = o && !E && !O.hasNothingToBill;
672
+ h(F);
673
+ }, Y = !!E && P.every((e) => w(e, E, g)), X = o && !D && !k.hasNothingToBill;
664
674
  return {
665
- amounts: O,
666
- answers: h,
667
- asksAmount: M,
668
- buildPayload: (e, t) => T && q ? k({
669
- answers: h,
670
- billableDays: O.billableDays,
675
+ amounts: k,
676
+ answers: g,
677
+ asksAmount: j,
678
+ buildPayload: (e, t) => E && Y ? M({
679
+ answers: g,
680
+ billableDays: k.billableDays,
671
681
  bookingItemId: t,
672
- event: T,
682
+ event: E,
673
683
  funnel: n,
674
684
  translate: e,
675
- withPrice: M || J,
676
- withReBillRatio: D || o
685
+ withPrice: j || X,
686
+ withReBillRatio: O || o
677
687
  }) : void 0,
678
- canGoBack: f !== "kind" && !(b && (P === "kind" || P === "event")),
679
- canGoNext: !!T && x(f, T, h),
680
- event: T,
681
- goBack: K,
682
- goNext: U,
683
- group: w,
688
+ canGoBack: p !== "kind" && !(v && (F === "kind" || F === "event")),
689
+ canGoNext: !!E && w(p, E, g),
690
+ event: E,
691
+ goBack: J,
692
+ goNext: G,
693
+ group: T,
684
694
  groups: C,
685
- isComplete: q,
686
- isPriced: j,
687
- reset: R,
688
- selectAmountGate: G,
689
- selectEvent: H,
690
- selectGroup: V,
691
- selectReason: W,
692
- setAnswers: F,
693
- showsReBillRatio: D && j,
694
- startPrefill: B,
695
- step: f,
696
- steps: N
695
+ isComplete: Y,
696
+ isPriced: A,
697
+ reset: B,
698
+ selectAmountGate: q,
699
+ selectEvent: W,
700
+ selectGroup: U,
701
+ selectReason: K,
702
+ setAnswers: I,
703
+ showsReBillRatio: O && A,
704
+ startPrefill: H,
705
+ step: p,
706
+ steps: P
697
707
  };
698
- }, M = {
708
+ }, F = {
699
709
  ar: {
700
710
  checks: {
701
711
  ce_conformity: "تم التحقق من شهادة أو إقرار CE",
@@ -1823,7 +1833,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1823
1833
  title: "Título do evento"
1824
1834
  }
1825
1835
  }
1826
- }, N = ["companion", "operative"], P = {
1836
+ }, I = ["companion", "operative"], L = {
1827
1837
  ...s,
1828
1838
  breakage: {
1829
1839
  ...s.breakage,
@@ -1861,7 +1871,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1861
1871
  ...s.robbery,
1862
1872
  reasons: ["robbery_machine", "robbery_option"]
1863
1873
  }
1864
- }, F = [
1874
+ }, R = [
1865
1875
  "n1_control",
1866
1876
  "other_request",
1867
1877
  "breakdown",
@@ -1879,13 +1889,13 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1879
1889
  "hours_record",
1880
1890
  "robbery",
1881
1891
  "other"
1882
- ], I = [
1892
+ ], z = [
1883
1893
  "n1_control",
1884
1894
  "n3_control",
1885
1895
  "machine_assignment",
1886
1896
  "operator_change",
1887
1897
  "hours_record"
1888
- ], L = [
1898
+ ], B = [
1889
1899
  c.controls,
1890
1900
  c.admin_request,
1891
1901
  c.machine_problem,
@@ -1894,88 +1904,88 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1894
1904
  c.delivery,
1895
1905
  c.documents,
1896
1906
  c.other
1897
- ], R = {
1898
- events: F.map((e) => P[e]),
1899
- groups: L,
1907
+ ], V = {
1908
+ events: R.map((e) => L[e]),
1909
+ groups: B,
1900
1910
  id: "bouygues",
1901
1911
  pricing: {
1902
1912
  asksReBillRatio: !0,
1903
1913
  showsPrice: !0
1904
1914
  },
1905
1915
  side: "client"
1906
- }, z = {
1907
- events: F.filter((e) => !I.includes(e)).map((e) => P[e]),
1908
- groups: L,
1916
+ }, H = {
1917
+ events: R.filter((e) => !z.includes(e)).map((e) => L[e]),
1918
+ groups: B,
1909
1919
  id: "bouyguesField",
1910
1920
  pricing: {
1911
1921
  asksReBillRatio: !1,
1912
1922
  showsPrice: !1
1913
1923
  },
1914
1924
  side: "client"
1915
- }, B = [{
1916
- funnels: [R, z],
1917
- getFunnel: (e) => N.includes(e ?? "") ? z : R,
1925
+ }, U = [{
1926
+ funnels: [V, H],
1927
+ getFunnel: (e) => I.includes(e ?? "") ? H : V,
1918
1928
  tenants: ["bouygues"]
1919
- }], V = [
1929
+ }], W = [
1920
1930
  l,
1921
1931
  u,
1922
- ...B.flatMap(({ funnels: e }) => e)
1923
- ], H = ({ side: e, tenantName: t, roleName: n }) => e === "supplier" ? u : B.find(({ tenants: e }) => e.includes(t ?? ""))?.getFunnel(n) ?? l, U = (e) => V.find((t) => t.id === e), W = 10, G = (e) => e.slice(0, W), K = (e) => e.lineType === "booking_events", q = ({ workflowValues: e }, t) => Array.isArray(e) ? e.find((e) => typeof e == "object" && !!e && e.name === t) : void 0, J = (e) => {
1924
- let t = q(e, a.unitPrice)?.value;
1932
+ ...U.flatMap(({ funnels: e }) => e)
1933
+ ], G = ({ side: e, tenantName: t, roleName: n }) => e === "supplier" ? u : U.find(({ tenants: e }) => e.includes(t ?? ""))?.getFunnel(n) ?? l, K = (e) => W.find((t) => t.id === e), q = 10, J = (e) => e.slice(0, q), Y = (e) => e.lineType === "booking_events", X = ({ workflowValues: e }, t) => Array.isArray(e) ? e.find((e) => typeof e == "object" && !!e && e.name === t) : void 0, ee = (e) => {
1934
+ let t = X(e, a.unitPrice)?.value;
1925
1935
  return typeof t == "string" || typeof t == "number" ? f(String(t)) : null;
1926
- }, ee = (e) => {
1927
- let t = J(e);
1928
- return t !== null && t < 0 && !!q(e, a.dates);
1929
- }, te = (e = [], t) => e.filter(K).flatMap((e) => {
1936
+ }, te = (e) => {
1937
+ let t = ee(e);
1938
+ return t !== null && t < 0 && !!X(e, a.dates);
1939
+ }, ne = (e = [], t) => e.filter(Y).flatMap((e) => {
1930
1940
  let [n, r] = e.dates ?? [];
1931
- return e.id !== t && n && r && ee(e) ? [{
1932
- fromDate: G(n),
1941
+ return e.id !== t && n && r && te(e) ? [{
1942
+ fromDate: J(n),
1933
1943
  line: e,
1934
- toDate: G(r)
1944
+ toDate: J(r)
1935
1945
  }] : [];
1936
- }), ne = (e, t) => t.find(({ fromDate: t, toDate: n }) => G(t) <= G(e) && G(e) <= G(n)), re = ({ fromDate: e, toDate: t }, n) => e && t ? n.find((n) => G(e) <= G(n.toDate) && G(n.fromDate) <= G(t)) : void 0, Y = (e, t) => e.billingType !== "DELTA" || t?.qtyUnit === "HOURS", ie = (e, t) => ({
1946
+ }), re = (e, t) => t.find(({ fromDate: t, toDate: n }) => J(t) <= J(e) && J(e) <= J(n)), ie = ({ fromDate: e, toDate: t }, n) => e && t ? n.find((n) => J(e) <= J(n.toDate) && J(n.fromDate) <= J(t)) : void 0, Z = (e, t) => e.billingType !== "DELTA" || t?.qtyUnit === "HOURS", ae = (e, t) => ({
1937
1947
  ...e,
1938
- events: e.events.filter((e) => Y(e, t))
1939
- }), X = 10, Z = (e) => typeof e == "object" && e && "value" in e ? Z(e.value) : typeof e == "string" || typeof e == "number" ? String(e) : "", Q = (e) => e === !0 || e === "true", $ = (e) => {
1948
+ events: e.events.filter((e) => Z(e, t))
1949
+ }), Q = 10, $ = (e) => typeof e == "object" && e && "value" in e ? $(e.value) : typeof e == "string" || typeof e == "number" ? String(e) : "", oe = (e) => e === !0 || e === "true", se = (e) => {
1940
1950
  let t = f(e);
1941
1951
  return t === null ? e : String(t);
1942
- }, ae = (e, t) => {
1943
- let n = (e) => t.find((t) => t.name === e)?.value, r = Z(t.find(({ tag: e }) => e === "reason")?.value), i = t.find(({ tag: e }) => e === "description")?.value ?? n(a.description), o = e.hasTitle ? "" : Z(e.reasonDetail ? n(e.reasonDetail) : r), s = n(a.dates), [c = "", l = ""] = Array.isArray(s) ? s.map(Z) : [], u = Z(n(_(e, o)?.name ?? a.date)), d = Number(Z(n(a.unitPrice)) || NaN), f = Number.isFinite(d);
1952
+ }, ce = (e, t) => {
1953
+ let n = (e) => t.find((t) => t.name === e)?.value, r = $(t.find(({ tag: e }) => e === "reason")?.value), i = t.find(({ tag: e }) => e === "description")?.value ?? n(a.description), o = e.hasTitle ? "" : $(e.reasonDetail ? n(e.reasonDetail) : r), s = n(a.dates), [c = "", l = ""] = Array.isArray(s) ? s.map($) : [], u = $(n(b(e, o)?.name ?? a.date)), d = Number($(n(a.unitPrice)) || NaN), f = Number.isFinite(d);
1944
1954
  return {
1945
1955
  amount: f ? String(e.price === "credit" || e.hasCreditNoteChoice ? Math.abs(d) : d) : "",
1946
1956
  ...e.amountGate && { amountGate: f },
1947
1957
  ...e.hasCreditNoteChoice && f && { isCreditNote: d < 0 },
1948
- checks: Object.fromEntries((e.checks ?? []).map((e) => [e, Q(n(e))])),
1958
+ checks: Object.fromEntries((e.checks ?? []).map((e) => [e, oe(n(e))])),
1949
1959
  dates: {
1950
- fromDate: (c || u).slice(0, X),
1951
- toDate: (l || u).slice(0, X)
1960
+ fromDate: (c || u).slice(0, Q),
1961
+ toDate: (l || u).slice(0, Q)
1952
1962
  },
1953
- description: Z(i),
1954
- fields: Object.fromEntries((e.fields ?? []).map(({ name: e, type: t }) => [e, t === "number" ? $(Z(n(e))) : Z(n(e))])),
1955
- intervention: Q(n(a.intervention)),
1963
+ description: $(i),
1964
+ fields: Object.fromEntries((e.fields ?? []).map(({ name: e, type: t }) => [e, t === "number" ? se($(n(e))) : $(n(e))])),
1965
+ intervention: oe(n(a.intervention)),
1956
1966
  reason: o,
1957
- reBillRatio: $(Z(n(a.reBillRatio))),
1967
+ reBillRatio: se($(n(a.reBillRatio))),
1958
1968
  title: e.hasTitle ? r : ""
1959
1969
  };
1960
- }, oe = (e, t, { reason: n }) => e.reasonDetail === t.reasonDetail && !!e.hasTitle == !!t.hasTitle && (!!e.hasTitle || !!e.reasonDetail || (e.reasons?.includes(n) ?? n === e.reason)), se = (e, t) => e === "client" && t === "supplier", ce = ({ workflow: e, workflowValues: t }, n) => {
1961
- if (!O(e)) return;
1962
- let r = U(e.funnel), i = n.side === e.side ? n.events.find(({ id: t }) => t === e.eventId) : void 0, a = r?.events.find(({ id: t }) => t === e.eventId) ?? i;
1970
+ }, le = (e, t, { reason: n }) => e.reasonDetail === t.reasonDetail && !!e.hasTitle == !!t.hasTitle && (!!e.hasTitle || !!e.reasonDetail || (e.reasons?.includes(n) ?? n === e.reason)), ue = (e, t) => e === "client" && t === "supplier", de = ({ workflow: e, workflowValues: t }, n) => {
1971
+ if (!j(e)) return;
1972
+ let r = K(e.funnel), i = n.side === e.side ? n.events.find(({ id: t }) => t === e.eventId) : void 0, a = r?.events.find(({ id: t }) => t === e.eventId) ?? i;
1963
1973
  if (!a) return;
1964
- let o = ae(a, t ?? []);
1965
- return i && oe(i, a, o) ? {
1974
+ let o = ce(a, t ?? []);
1975
+ return i && le(i, a, o) ? {
1966
1976
  answers: o,
1967
1977
  editFunnel: n,
1968
1978
  event: i,
1969
1979
  side: e.side
1970
1980
  } : {
1971
1981
  answers: o,
1972
- editFunnel: r && !a.isProof && se(n.side, e.side) ? {
1982
+ editFunnel: r && !a.isProof && ue(n.side, e.side) ? {
1973
1983
  ...r,
1974
1984
  pricing: n.pricing
1975
1985
  } : void 0,
1976
1986
  event: a,
1977
1987
  side: e.side
1978
1988
  };
1979
- }, le = ({ answers: e, event: t }) => !!t.hasTitle && !!e.title || !t.reasons?.length;
1989
+ }, fe = ({ answers: e, event: t }) => !!t.hasTitle && !!e.title || !t.reasons?.length;
1980
1990
  //#endregion
1981
- export { s as CLIENT_EVENTS, c as CLIENT_GROUPS, E as DEDICATED_FUNNEL, l as DEFAULT_CLIENT_FUNNEL, M as EVENT_LOCALES, n as EVENT_NAMESPACE, o as INVENTORY_ID, r as NATIVE_EVENT_SOURCE, i as NATIVE_EVENT_VERSION, u as SUPPLIER_FUNNEL, a as VALUE_NAMES, Y as billsOnLine, k as buildEventPayload, ne as findCreditOfDay, re as findCreditOverlap, U as findEventFunnel, te as getCreditedPeriods, D as getDedicatedEventWorkflow, _ as getEndDate, m as getEventAmounts, H as getEventFunnel, y as getFirstQuestion, g as getFunnelGroups, ie as getLineFunnel, S as getReason, v as getSteps, p as getUnitPrice, h as isAmountToComplete, le as isNamedByDeclaration, O as isNativeEventWorkflow, x as isStepAnswered, ce as readEvent, f as toDecimal, j as useEventDeclaration };
1991
+ export { s as CLIENT_EVENTS, c as CLIENT_GROUPS, h as DAILY_PRICE_SHARES, k as DEDICATED_FUNNEL, l as DEFAULT_CLIENT_FUNNEL, F as EVENT_LOCALES, n as EVENT_NAMESPACE, o as INVENTORY_ID, r as NATIVE_EVENT_SOURCE, i as NATIVE_EVENT_VERSION, u as SUPPLIER_FUNNEL, a as VALUE_NAMES, Z as billsOnLine, M as buildEventPayload, re as findCreditOfDay, ie as findCreditOverlap, K as findEventFunnel, _ as findShare, ne as getCreditedPeriods, A as getDedicatedEventWorkflow, b as getEndDate, m as getEventAmounts, G as getEventFunnel, S as getFirstQuestion, y as getFunnelGroups, ae as getLineFunnel, T as getReason, g as getShareAmount, x as getSteps, p as getUnitPrice, v as isAmountToComplete, fe as isNamedByDeclaration, j as isNativeEventWorkflow, w as isStepAnswered, de as readEvent, f as toDecimal, P as useEventDeclaration };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.62.0",
3
+ "version": "2.63.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",