@tesouro/embedded-components-react 0.5.267 → 0.5.270

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 (56) hide show
  1. package/dist/index.css +4 -10
  2. package/dist/index.d.ts +13 -9
  3. package/dist/lib/ReceivablesWidget.d.ts +13 -9
  4. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index.js +3 -1
  5. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js +44 -0
  6. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js +97 -0
  7. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +76 -150
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +63 -57
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/actionsModal.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/auditHistory/labels.js +1 -1
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +161 -152
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +30 -34
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +12 -8
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/statusCards.js +18 -19
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +208 -158
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +91 -85
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +197 -196
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +147 -115
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +14 -14
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +3 -5
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +37 -34
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +22 -7
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +17 -15
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +17 -13
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +37 -31
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +29 -23
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +38 -11
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +26 -28
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +20 -14
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +8 -24
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +34 -83
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +14 -404
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +28 -2
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +79 -39
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +490 -68
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +2 -502
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +41 -216
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +70 -21
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +484 -5
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +224 -0
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +21 -263
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +8 -2
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +261 -24
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +2 -237
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +100 -3
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +21 -242
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +226 -82
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +3 -59
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +233 -178
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +85 -37
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index54.js +60 -0
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index55.js +194 -0
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +45 -0
  54. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +0 -100
@@ -47,41 +47,41 @@ function st(e, t) {
47
47
  ...t ? { customerEmail: "" } : {}
48
48
  });
49
49
  }
50
- function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, onCreated: ut }) {
51
- let dt = Ue(), ft = Ge(), pt = Ke(), mt = Je(), ht = We(), g = m("draft"), gt = m(!1), [_t, vt] = h(), _ = m(!1), v = m(!1), yt = m(null), y = m(void 0), b = m([]), bt = m(""), [x, S] = h(!1), [C, xt] = h("create"), [St, Ct] = h(), [wt, Tt] = h(), [w, T] = h(() => Me()), E = m(w), [Et, D] = h(!1), [Dt, O] = h({}), [Ot, kt] = h("none"), At = ge(), k = he(), A = k.data?.data, { unitNamesById: j } = At, [jt, Mt] = h(), [M, Nt] = h(!1), Pt = m(!1), Ft = m(!1), N = m(!1), P = m({
50
+ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, onCreated: ut, onUpdated: dt }) {
51
+ let ft = Ue(), pt = Ge(), mt = Ke(), ht = Je(), gt = We(), g = m("draft"), _t = m(!1), [vt, yt] = h(), _ = m(!1), v = m(!1), bt = m(null), y = m(void 0), b = m([]), xt = m(""), [x, S] = h(!1), [C, St] = h("create"), [Ct, wt] = h(), [Tt, Et] = h(), [w, T] = h(() => Me()), E = m(w), [Dt, D] = h(!1), [Ot, O] = h({}), [kt, At] = h("none"), jt = ge(), k = he(), A = k.data?.data, { unitNamesById: j } = jt, [Mt, Nt] = h(), [M, Pt] = h(!1), Ft = m(!1), N = m(!1), P = m(!1), F = m({
52
52
  lines: !1,
53
53
  discount: !1
54
- }), [It, F] = h(!1), Lt = p(() => t(), []), Rt = p(() => ({
54
+ }), [It, I] = h(!1), Lt = p(() => t(), []), Rt = p(() => ({
55
55
  ...n,
56
56
  ...ct
57
- }), [ct]), zt = a(w.customerId), Bt = i(w.customerId || void 0), Vt = zt.data?.data?.[0], { billingAddressId: I, billingAddress: Ht, shippingAddressId: Ut } = Re({
57
+ }), [ct]), zt = a(w.customerId), Bt = i(w.customerId || void 0), Vt = zt.data?.data?.[0], { billingAddressId: L, billingAddress: Ht, shippingAddressId: Ut } = Re({
58
58
  values: w,
59
59
  counterpart: Bt.data,
60
60
  addresses: zt.data?.data
61
- }), L = !!w.customerId && (zt.isLoading || Bt.isLoading), R = Ye({
61
+ }), R = !!w.customerId && (zt.isLoading || Bt.isLoading), z = Ye({
62
62
  counterpartId: w.customerId,
63
- billingAddressId: I,
63
+ billingAddressId: L,
64
64
  billingCountry: Ht?.country
65
- }), Wt = R.isLoading || L, Gt = d((e) => {
65
+ }), Wt = z.isLoading || R, Gt = d((e) => {
66
66
  T((t) => ({
67
67
  ...t,
68
68
  attachments: e(t.attachments)
69
69
  }));
70
- }, []), z = et({
70
+ }, []), B = et({
71
71
  attachments: w.attachments,
72
72
  setAttachments: Gt,
73
- receivableId: St
74
- }), { reset: B, discardUploads: Kt, commitRemovals: qt } = z, Jt = w.type === "invoice" ? me({
73
+ receivableId: Ct
74
+ }), { reset: V, discardUploads: Kt, commitRemovals: qt } = B, Jt = w.type === "invoice" ? me({
75
75
  attachments: w.attachments,
76
- pendingUploads: z.pendingUploads,
77
- isCountLimitReached: z.isCountLimitReached,
76
+ pendingUploads: B.pendingUploads,
77
+ isCountLimitReached: B.isCountLimitReached,
78
78
  isRecurring: u(w),
79
79
  messages: l
80
80
  }) : void 0, Yt = d((e) => {
81
81
  T((t) => st(t, e ?? ""));
82
82
  }, []), Xt = o({
83
- view: Ot,
84
- setView: kt,
83
+ view: kt,
84
+ setView: At,
85
85
  selectedId: w.customerId || void 0,
86
86
  setSelectedId: Yt,
87
87
  messages: Rt,
@@ -122,18 +122,18 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
122
122
  ...t,
123
123
  ...e
124
124
  }));
125
- }, []), V = rt({
125
+ }, []), H = rt({
126
126
  open: x,
127
127
  bankAccountId: w.bankAccountId,
128
128
  bankAccountType: w.bankAccountType,
129
129
  embeddedBankName: lt,
130
130
  messages: l,
131
131
  onSelect: rn
132
- }), an = V.reset, on = qe(wt), H = wt ? on.data : void 0, U = be(H), sn = U > 0, W = !!wt && on.isLoading, G = m(void 0);
132
+ }), an = H.reset, on = qe(Tt), U = Tt ? on.data : void 0, W = be(U), sn = W > 0, G = !!Tt && on.isLoading, K = m(void 0);
133
133
  f(() => {
134
- if (!H || G.current === H.id) return;
135
- G.current = H.id;
136
- let e = xe(H);
134
+ if (!U || K.current === U.id) return;
135
+ K.current = U.id;
136
+ let e = xe(U);
137
137
  E.current = {
138
138
  ...E.current,
139
139
  ...e
@@ -141,7 +141,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
141
141
  ...t,
142
142
  ...e
143
143
  }));
144
- }, [H]);
144
+ }, [U]);
145
145
  let cn = d((e) => T(e), []), ln = d((e) => O((t) => {
146
146
  if (!e.some((e) => e in t)) return t;
147
147
  let n = { ...t };
@@ -159,7 +159,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
159
159
  un.current = [];
160
160
  let t = Se({
161
161
  fields: w,
162
- issuedCount: U,
162
+ issuedCount: W,
163
163
  messages: l
164
164
  });
165
165
  O((n) => {
@@ -169,25 +169,25 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
169
169
  }), r;
170
170
  });
171
171
  }, [
172
- U,
172
+ W,
173
173
  l,
174
174
  w
175
175
  ]);
176
176
  let fn = nt({
177
177
  values: w,
178
- errors: Dt,
178
+ errors: Ot,
179
179
  lockSchedule: sn,
180
180
  messages: l,
181
181
  onChange: cn,
182
182
  onClearErrors: ln,
183
183
  onRevalidateErrors: dn
184
- }), K = fn.reset, pn = d((e) => T((t) => ({
184
+ }), q = fn.reset, pn = d((e) => T((t) => ({
185
185
  ...t,
186
186
  ...e
187
- })), []), q = dt.isPending || ft.isPending || pt.isPending || mt.isPending || ht.isPending, mn = it({
187
+ })), []), J = ft.isPending || pt.isPending || mt.isPending || ht.isPending || gt.isPending, mn = it({
188
188
  open: x,
189
189
  isInvoice: w.type === "invoice",
190
- disabled: q,
190
+ disabled: J,
191
191
  paymentTermsId: w.paymentTermsId,
192
192
  paymentTermsCustomDate: w.paymentTermsCustomDate,
193
193
  paymentReminderId: w.paymentReminderId,
@@ -195,40 +195,40 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
195
195
  messages: l,
196
196
  onSelect: pn
197
197
  }), hn = mn.reset, gn = d(() => {
198
- b.current = [], Mt(void 0), xt("create"), Ct(void 0), Tt(void 0), G.current = void 0, y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, T(Me()), D(!1), O({}), Nt(!1), F(!1), P.current = {
198
+ b.current = [], Nt(void 0), St("create"), wt(void 0), Et(void 0), K.current = void 0, y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, T(Me()), D(!1), O({}), Pt(!1), I(!1), F.current = {
199
199
  lines: !1,
200
200
  discount: !1
201
- }, B(), K();
202
- }, [B, K]), _n = d((e = "invoice", { customerId: t = "" } = {}) => {
203
- nn(), an(), K();
201
+ }, V(), q();
202
+ }, [V, q]), _n = d((e = "invoice", { customerId: t = "" } = {}) => {
203
+ nn(), an(), q();
204
204
  let n = {
205
205
  ...Me(),
206
206
  type: e,
207
207
  customerId: t
208
208
  };
209
- hn(He(n)), b.current = [], y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, G.current = void 0, Mt(void 0), xt("create"), Ct(void 0), Tt(void 0), E.current = n, T(n), D(!1), O({}), B(), Nt(!1), F(!1), P.current = {
209
+ hn(He(n)), b.current = [], y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, K.current = void 0, Nt(void 0), St("create"), wt(void 0), Et(void 0), E.current = n, T(n), D(!1), O({}), V(), Pt(!1), I(!1), F.current = {
210
210
  lines: !1,
211
211
  discount: !1
212
212
  }, S(!0);
213
213
  }, [
214
- B,
214
+ V,
215
215
  nn,
216
216
  an,
217
- K,
217
+ q,
218
218
  hn
219
219
  ]), vn = d((e, { highlightForIssue: t = !1 } = {}) => {
220
220
  if (e.type === "credit_note") return;
221
- nn(), an(), K();
221
+ nn(), an(), q();
222
222
  let n = Le(e, A);
223
- hn(He(n)), b.current = e.line_items, bt.current = e.currency, y.current = void 0, g.current = t ? "issue" : "draft", _.current = !1, v.current = t, G.current = void 0, Mt(void 0), xt("edit"), Ct(e.id), Tt(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), E.current = n, T(n), D(!1), O({}), Nt(!1), F(!1), P.current = {
223
+ hn(He(n)), b.current = e.line_items, xt.current = e.currency, y.current = void 0, g.current = t ? "issue" : "draft", _.current = !1, v.current = t, K.current = void 0, Nt(void 0), St("edit"), wt(e.id), Et(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), E.current = n, T(n), D(!1), O({}), Pt(!1), I(!1), F.current = {
224
224
  lines: !1,
225
225
  discount: !1
226
- }, B(), S(!0);
226
+ }, V(), S(!0);
227
227
  }, [
228
- B,
228
+ V,
229
229
  nn,
230
230
  an,
231
- K,
231
+ q,
232
232
  hn,
233
233
  A
234
234
  ]);
@@ -244,14 +244,14 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
244
244
  };
245
245
  }));
246
246
  }, [A]);
247
- let J = z.isUploading, Y = d(() => {
248
- J || (Kt(), D(!1), S(!1), O({}));
249
- }, [Kt, J]), yn = d(() => {
250
- if (Et) {
247
+ let Y = B.isUploading, X = d(() => {
248
+ Y || (Kt(), D(!1), S(!1), O({}));
249
+ }, [Kt, Y]), yn = d(() => {
250
+ if (Dt) {
251
251
  D(!1);
252
252
  return;
253
253
  }
254
- if (J) {
254
+ if (Y) {
255
255
  e.error(l.attachmentsUploading);
256
256
  return;
257
257
  }
@@ -259,16 +259,16 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
259
259
  D(!0);
260
260
  return;
261
261
  }
262
- Y();
262
+ X();
263
263
  }, [
264
+ X,
264
265
  Y,
265
- J,
266
266
  l.attachmentsUploading,
267
- Et,
267
+ Dt,
268
268
  w
269
269
  ]), bn = d((e) => {
270
270
  let t = { ...e };
271
- t.taxRate !== void 0 && (t.taxRate = ce(t.taxRate), N.current = !0), t.type !== void 0 && t.type !== "invoice" && Kt(), t.type !== void 0 && (g.current = "draft"), t.discount !== void 0 && M && (Ft.current = !0), t.discountType !== void 0 && (Ft.current = !0), t.currency !== void 0 && (Pt.current = !0), T((e) => {
271
+ t.taxRate !== void 0 && (t.taxRate = ce(t.taxRate), P.current = !0), t.type !== void 0 && t.type !== "invoice" && Kt(), t.type !== void 0 && (g.current = "draft"), t.discount !== void 0 && M && (N.current = !0), t.discountType !== void 0 && (N.current = !0), t.currency !== void 0 && (Ft.current = !0), T((e) => {
272
272
  let n = {
273
273
  ...t.customerId === void 0 ? e : st(e, t.customerId),
274
274
  ...t
@@ -282,8 +282,8 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
282
282
  currency: n.currency
283
283
  })), n;
284
284
  });
285
- }, [Kt, M]), xn = d(() => F(!0), []), Sn = d(() => {
286
- F(!1), Ft.current = !0, T((e) => ({
285
+ }, [Kt, M]), xn = d(() => I(!0), []), Sn = d(() => {
286
+ I(!1), N.current = !0, T((e) => ({
287
287
  ...e,
288
288
  discount: we({
289
289
  value: e.discount,
@@ -292,45 +292,45 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
292
292
  })
293
293
  }));
294
294
  }, []), Cn = d(() => {
295
- N.current = !0, T((e) => {
295
+ P.current = !0, T((e) => {
296
296
  let t = c(e.taxRate);
297
297
  return t === e.taxRate ? e : {
298
298
  ...e,
299
299
  taxRate: t
300
300
  };
301
301
  });
302
- }, []), X = d((e, { validate: t }) => {
303
- t && (Pt.current = !0), T((t) => ({
302
+ }, []), Z = d((e, { validate: t }) => {
303
+ t && (Ft.current = !0), T((t) => ({
304
304
  ...t,
305
305
  lineItems: e(t.lineItems)
306
306
  }));
307
307
  }, []);
308
308
  f(() => {
309
- let e = Pt.current, t = Ft.current;
310
- if (!e && !t && !N.current) return;
311
- Pt.current = !1, Ft.current = !1, N.current = !1, e && (P.current.lines = !0), t && (P.current.discount = !0);
312
- let n = _.current || U > 0, r = e ? pe(w.lineItems, {
309
+ let e = Ft.current, t = N.current;
310
+ if (!e && !t && !P.current) return;
311
+ Ft.current = !1, N.current = !1, P.current = !1, e && (F.current.lines = !0), t && (F.current.discount = !0);
312
+ let n = _.current || W > 0, r = e ? pe(w.lineItems, {
313
313
  currency: w.currency,
314
314
  messages: l,
315
315
  requireComplete: n
316
316
  }) : void 0;
317
317
  O((t) => {
318
318
  let i = { ...t };
319
- return P.current.lines && (i.lineItems = e ? r : t.lineItems, i.lineItemsSummary = de(i.lineItems, je(w, l), n && w.lineItems.length === 0 ? l.lineItemsRequired : void 0)), P.current.discount && (i.discount = Ae(w, l)), i;
319
+ return F.current.lines && (i.lineItems = e ? r : t.lineItems, i.lineItemsSummary = de(i.lineItems, je(w, l), n && w.lineItems.length === 0 ? l.lineItemsRequired : void 0)), F.current.discount && (i.discount = Ae(w, l)), i;
320
320
  });
321
321
  }, [
322
- U,
322
+ W,
323
323
  l,
324
324
  w
325
325
  ]);
326
326
  let wn = d((e, t) => {
327
327
  let { unit: n, ...r } = t, i = se(r);
328
- i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (N.current = !0), X((t) => t.map((t) => t.id === e ? {
328
+ i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (P.current = !0), Z((t) => t.map((t) => t.id === e ? {
329
329
  ...t,
330
330
  ...i
331
331
  } : t), { validate: M });
332
- }, [X, M]), Tn = d((e, t) => {
333
- X((n) => n.map((n) => n.id === e ? {
332
+ }, [Z, M]), Tn = d((e, t) => {
333
+ Z((n) => n.map((n) => n.id === e ? {
334
334
  ...n,
335
335
  ...ie({
336
336
  product: t,
@@ -339,15 +339,15 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
339
339
  })
340
340
  } : n), { validate: !0 });
341
341
  }, [
342
- X,
342
+ Z,
343
343
  j,
344
344
  w.currency
345
345
  ]), En = d((e, t) => {
346
- t && X((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
346
+ t && Z((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
347
347
  ...n,
348
348
  ...t.patch
349
349
  } : n), { validate: !0 });
350
- }, [X]), Dn = d((e, t) => {
350
+ }, [Z]), Dn = d((e, t) => {
351
351
  let n = w.lineItems.find((t) => t.id === e);
352
352
  n && En(e, s({
353
353
  lineItem: n,
@@ -368,32 +368,32 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
368
368
  }));
369
369
  }, [En, w.lineItems]), kn = d(() => {
370
370
  let e = ne(w.currency);
371
- Mt(e.id), T((t) => ({
371
+ Nt(e.id), T((t) => ({
372
372
  ...t,
373
373
  lineItems: [...t.lineItems, e]
374
374
  }));
375
375
  }, [w.currency]), An = d((e) => {
376
- X((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
377
- }, [X]), Z = d((e, t) => e.type === "invoice" && (t === "issue" || Ce(e) && U === 0), [U]), jn = d((e, t) => ({
376
+ Z((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
377
+ }, [Z]), jn = d((e, t) => e.type === "invoice" && (t === "issue" || Ce(e) && W === 0), [W]), Mn = d((e, t) => ({
378
378
  ...Be({
379
379
  values: e,
380
- billingAddressId: I,
380
+ billingAddressId: L,
381
381
  messages: l,
382
382
  willIssue: t,
383
- hasStartedRecurrence: U > 0
383
+ hasStartedRecurrence: W > 0
384
384
  }),
385
385
  ...e.type === "invoice" && u(e) ? Se({
386
386
  fields: e,
387
- issuedCount: U,
387
+ issuedCount: W,
388
388
  messages: l
389
389
  }) : {}
390
390
  }), [
391
- I,
392
- U,
391
+ L,
392
+ W,
393
393
  l
394
- ]), Mn = d(() => {
394
+ ]), Nn = d(() => {
395
395
  requestAnimationFrame(() => {
396
- let e = yt.current, t = e?.querySelector("[aria-invalid=\"true\"], [data-invalid=\"true\"]");
396
+ let e = bt.current, t = e?.querySelector("[aria-invalid=\"true\"], [data-invalid=\"true\"]");
397
397
  if (!e || !t) return;
398
398
  let n = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop;
399
399
  e.scrollTo({
@@ -401,36 +401,36 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
401
401
  behavior: "smooth"
402
402
  });
403
403
  });
404
- }, []), Nn = d((e, t) => {
405
- O(e), Nt(!0), _.current = t, P.current = {
404
+ }, []), Pn = d((e, t) => {
405
+ O(e), Pt(!0), _.current = t, F.current = {
406
406
  lines: !0,
407
407
  discount: !0
408
- }, Mn();
409
- }, [Mn]), Pn = !wt || w.frequency !== "once" || on.isError;
408
+ }, Nn();
409
+ }, [Nn]), Fn = !Tt || w.frequency !== "once" || on.isError;
410
410
  f(() => {
411
- if (!x || !v.current || L || W || !Pn) return;
411
+ if (!x || !v.current || R || G || !Fn) return;
412
412
  v.current = !1;
413
- let e = Z(w, "issue");
414
- Nn(jn(w, e), e);
413
+ let e = jn(w, "issue");
414
+ Pn(Mn(w, e), e);
415
415
  }, [
416
- L,
416
+ R,
417
417
  x,
418
+ Fn,
419
+ G,
418
420
  Pn,
419
- W,
420
- Nn,
421
- jn,
421
+ Mn,
422
422
  w,
423
- Z
423
+ jn
424
424
  ]);
425
- let Fn = m({
425
+ let In = m({
426
426
  values: w,
427
- billingAddressId: I
427
+ billingAddressId: L
428
428
  });
429
429
  f(() => {
430
- let e = Fn.current;
431
- if (Fn.current = {
430
+ let e = In.current;
431
+ if (In.current = {
432
432
  values: w,
433
- billingAddressId: I
433
+ billingAddressId: L
434
434
  }, !M) return;
435
435
  let t = [
436
436
  "customerId",
@@ -441,11 +441,11 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
441
441
  "openingNote",
442
442
  "closingNote",
443
443
  "taxRate"
444
- ].filter((t) => e.values[t] !== w[t] || t === "customerId" && e.billingAddressId !== I || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== w.paymentTermsCustomDate);
444
+ ].filter((t) => e.values[t] !== w[t] || t === "customerId" && e.billingAddressId !== L || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== w.paymentTermsCustomDate);
445
445
  if (!t.length) return;
446
446
  let n = Be({
447
447
  values: w,
448
- billingAddressId: I,
448
+ billingAddressId: L,
449
449
  messages: l,
450
450
  willIssue: _.current
451
451
  });
@@ -456,18 +456,18 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
456
456
  }), r;
457
457
  });
458
458
  }, [
459
- I,
459
+ L,
460
460
  l,
461
461
  M,
462
462
  w
463
463
  ]);
464
- let In = d(async (t) => {
465
- if (g.current = t, W) return;
466
- if (J) {
464
+ let Ln = d(async (t) => {
465
+ if (g.current = t, G) return;
466
+ if (Y) {
467
467
  e.error(l.attachmentsUploading);
468
468
  return;
469
469
  }
470
- if (k.isLoading || L) {
470
+ if (k.isLoading || R) {
471
471
  e.error(l.lineItemsLoading);
472
472
  return;
473
473
  }
@@ -476,38 +476,38 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
476
476
  lineItems: n
477
477
  };
478
478
  i !== w && T(i);
479
- let a = i.type === "invoice" && u(i), o = Z(i, t);
480
- if (o && (Wt || V.isLoading)) {
479
+ let a = i.type === "invoice" && u(i), o = jn(i, t);
480
+ if (o && (Wt || H.isLoading)) {
481
481
  e.error(l.issueChecksLoading);
482
482
  return;
483
483
  }
484
- if (o && !V.canAddAccount && !i.bankAccountId && !V.hasAccounts) {
484
+ if (o && !H.canAddAccount && !i.bankAccountId && !H.hasAccounts) {
485
485
  e.error(l.issueBankAccountUnavailable);
486
486
  return;
487
487
  }
488
- let ee = jn(i, o);
488
+ let ee = Mn(i, o);
489
489
  if (Ne(ee)) {
490
- Nn(ee, o);
490
+ Pn(ee, o);
491
491
  return;
492
492
  }
493
- if (O({}), o && R.isTaxIdMissing) {
493
+ if (O({}), o && z.isTaxIdMissing) {
494
494
  e.error(l.issueTaxIdRequired);
495
495
  return;
496
496
  }
497
497
  if (o && (i.paymentReminderId || i.overdueReminderId)) {
498
- let t = Ve(R.counterpart, l);
498
+ let t = Ve(z.counterpart, l);
499
499
  if (t) {
500
500
  e.error(t);
501
501
  return;
502
502
  }
503
503
  }
504
- let s = C === "edit" ? St : y.current, c, te, ne = {};
504
+ let s = C === "edit" ? Ct : y.current, c, te, ne = {};
505
505
  try {
506
506
  if (s) {
507
507
  let e = Fe({
508
508
  values: i,
509
509
  originalLineItems: b.current,
510
- originalCurrency: bt.current,
510
+ originalCurrency: xt.current,
511
511
  unitNamesById: j,
512
512
  units: A
513
513
  });
@@ -516,24 +516,24 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
516
516
  originalLineItems: b.current,
517
517
  changes: e
518
518
  });
519
- let t = await ft.mutateAsync({
519
+ let t = await pt.mutateAsync({
520
520
  path: { receivable_id: s },
521
521
  body: Ie({
522
522
  values: i,
523
- billingAddressId: I,
523
+ billingAddressId: L,
524
524
  shippingAddressId: Ut,
525
525
  lineItemChanges: e
526
526
  })
527
527
  });
528
- qt(), c = s, te = t?.type ?? i.type, a && t && (b.current = t.line_items, bt.current = t.currency, i = {
528
+ qt(), c = s, te = t?.type ?? i.type, a && t && (b.current = t.line_items, xt.current = t.currency, i = {
529
529
  ...i,
530
530
  lineItems: ae(i.lineItems, t.line_items)
531
531
  }, T(i));
532
532
  } else {
533
533
  ne = ze({ values: i });
534
- let e = await dt.mutateAsync({ body: Pe({
534
+ let e = await ft.mutateAsync({ body: Pe({
535
535
  values: i,
536
- billingAddressId: I,
536
+ billingAddressId: L,
537
537
  shippingAddressId: Ut,
538
538
  unitNamesById: j
539
539
  }) });
@@ -541,7 +541,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
541
541
  S(!1), gn();
542
542
  return;
543
543
  }
544
- c = e.id, te = e.type, a && (y.current = e.id, b.current = e.line_items, bt.current = e.currency, i = {
544
+ c = e.id, te = e.type, a && (y.current = e.id, b.current = e.line_items, xt.current = e.currency, i = {
545
545
  ...i,
546
546
  lineItems: ae(i.lineItems, e.line_items)
547
547
  }, T(i));
@@ -553,7 +553,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
553
553
  });
554
554
  e.error((s ? l.updateFailed : l.createFailed).replace("{errorMessage}", r));
555
555
  let { errors: a, listError: ee } = Ze($e(t, n), ne), c = de(a.lineItems, void 0, ee);
556
- Nn({
556
+ Pn({
557
557
  ...a,
558
558
  ...c ? { lineItemsSummary: c } : {}
559
559
  }, o);
@@ -561,100 +561,101 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
561
561
  }
562
562
  let re = a ? "recurrence" : "draft";
563
563
  if (a) try {
564
- H ? await mt.mutateAsync({
565
- path: { recurrence_id: H.id },
564
+ U ? await ht.mutateAsync({
565
+ path: { recurrence_id: U.id },
566
566
  body: ye(i, { lockSchedule: sn })
567
- }) : await pt.mutateAsync({ body: ve(i, c) });
567
+ }) : await mt.mutateAsync({ body: ve(i, c) });
568
568
  } catch (t) {
569
569
  e.error(Qe(t, { messages: l }));
570
570
  return;
571
571
  }
572
572
  else if (o) try {
573
- await ht.mutateAsync({ path: { receivable_id: c } }), re = "issue";
573
+ await gt.mutateAsync({ path: { receivable_id: c } }), re = "issue";
574
574
  } catch {
575
575
  e.error(l.issueFailedAfterSave);
576
576
  }
577
- let ie = C === "create";
578
- S(!1), gn(), ie && ut?.(c, te, {
577
+ let ie = C === "create" ? ut : dt;
578
+ S(!1), gn(), ie?.(c, te, {
579
579
  mode: re,
580
580
  counterpartId: i.customerId,
581
581
  inlineItems: _e(i.lineItems, i.currency),
582
- hasCustomerEmail: !!(R.counterpart && r(R.counterpart).trim())
582
+ hasCustomerEmail: !!(z.counterpart && r(z.counterpart).trim())
583
583
  });
584
584
  }, [
585
- V.canAddAccount,
586
- V.hasAccounts,
587
- V.isLoading,
588
- I,
589
- qt,
590
- dt,
591
- pt,
592
- St,
593
- H,
585
+ H.canAddAccount,
586
+ H.hasAccounts,
587
+ H.isLoading,
594
588
  L,
595
- J,
589
+ qt,
590
+ ft,
591
+ mt,
592
+ Ct,
593
+ U,
594
+ R,
595
+ Y,
596
596
  Wt,
597
- ht,
597
+ gt,
598
598
  sn,
599
599
  l,
600
600
  C,
601
601
  ut,
602
- R.counterpart,
603
- R.isTaxIdMissing,
604
- W,
602
+ dt,
603
+ z.counterpart,
604
+ z.isTaxIdMissing,
605
+ G,
605
606
  gn,
606
607
  Ut,
607
- Nn,
608
+ Pn,
608
609
  A,
609
610
  j,
610
611
  k.isLoading,
611
- ft,
612
- mt,
613
- jn,
612
+ pt,
613
+ ht,
614
+ Mn,
614
615
  w,
615
- Z
616
+ jn
616
617
  ]), Q = d(async (e = g.current) => {
617
- if (!gt.current) {
618
- gt.current = !0, vt(e);
618
+ if (!_t.current) {
619
+ _t.current = !0, yt(e);
619
620
  try {
620
- await In(e);
621
+ await Ln(e);
621
622
  } finally {
622
- gt.current = !1, vt(void 0);
623
+ _t.current = !1, yt(void 0);
623
624
  }
624
625
  }
625
- }, [In]), Ln = p(() => ({
626
+ }, [Ln]), Rn = p(() => ({
626
627
  ...w,
627
628
  discount: It ? w.discount : Te(Ee(w.discount, w.discountType, w.currency), w.discountType, w.currency),
628
629
  lineItems: w.lineItems.map(fe)
629
- }), [It, w]), Rn = p(() => ee(w.lineItems), [w.lineItems]), zn = p(() => ke(w), [w]), Bn = w.type === "invoice", Vn = Bn && u(w), Hn = q || k.isLoading || L || z.isUploading || W, Un = C === "edit" ? l.updateDraftButton : l.saveDraftButton, Wn = Vn ? H ? l.recurrenceUpdateButton : l.recurrenceActivateButton : Bn ? l.issueButton : Un, $ = Bn && !Vn ? "issue" : "draft", Gn = d(() => Q("draft"), [Q]), Kn = d(() => Q($), [$, Q]), qn = d(() => Q(), [Q]), Jn = d(() => {
630
+ }), [It, w]), zn = p(() => ee(w.lineItems), [w.lineItems]), Bn = p(() => ke(w), [w]), Vn = w.type === "invoice", Hn = Vn && u(w), Un = J || k.isLoading || R || B.isUploading || G, Wn = C === "edit" ? l.updateDraftButton : l.saveDraftButton, Gn = Hn ? U ? l.recurrenceUpdateButton : l.recurrenceActivateButton : Vn ? l.issueButton : Wn, $ = Vn && !Hn ? "issue" : "draft", Kn = d(() => Q("draft"), [Q]), qn = d(() => Q($), [$, Q]), Jn = d(() => Q(), [Q]), Yn = d(() => {
630
631
  g.current = "draft";
631
- }, []), Yn = d(() => {
632
+ }, []), Xn = d(() => {
632
633
  g.current = $;
633
- }, [$]), Xn = Hn || Vn, Zn = d(async () => {
634
- if (!Xn) try {
634
+ }, [$]), Zn = Un || Hn, Qn = d(async () => {
635
+ if (!Zn) try {
635
636
  await Q("draft");
636
637
  } finally {
637
638
  D(!1);
638
639
  }
639
- }, [Xn, Q]), Qn = d(() => D(!1), []), $n = p(() => ({
640
- open: Et,
641
- onSaveDraft: () => void Zn(),
642
- onDiscard: Y,
643
- onCancel: Qn,
644
- isSaving: q,
645
- isSaveDraftDisabled: Xn
640
+ }, [Zn, Q]), $n = d(() => D(!1), []), er = p(() => ({
641
+ open: Dt,
642
+ onSaveDraft: () => void Qn(),
643
+ onDiscard: X,
644
+ onCancel: $n,
645
+ isSaving: J,
646
+ isSaveDraftDisabled: Zn
646
647
  }), [
647
- Qn,
648
- Y,
649
- q,
650
- Xn,
648
+ $n,
649
+ X,
650
+ J,
651
651
  Zn,
652
- Et
653
- ]), er = p(() => Oe(zn, w.currency), [zn, w.currency]), tr = at({
652
+ Qn,
653
+ Dt
654
+ ]), tr = p(() => Oe(Bn, w.currency), [Bn, w.currency]), nr = at({
654
655
  values: w,
655
- totals: zn,
656
+ totals: Bn,
656
657
  billingAddress: Ht,
657
- bankAccount: V.selectedAccount,
658
+ bankAccount: H.selectedAccount,
658
659
  unitNamesById: j,
659
660
  messages: l,
660
661
  enabled: x
@@ -664,8 +665,8 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
664
665
  setOpen: S,
665
666
  mode: C,
666
667
  values: w,
667
- sheetValues: Ln,
668
- errors: Dt,
668
+ sheetValues: Rn,
669
+ errors: Ot,
669
670
  setValues: T,
670
671
  updateValues: bn,
671
672
  commitTaxRate: Cn,
@@ -678,52 +679,52 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
678
679
  addLineItem: kn,
679
680
  removeLineItem: An,
680
681
  attachmentsView: Jt,
681
- attachmentsUploading: z.isUploading,
682
- draftButtonLabel: Bn && !Vn ? Un : void 0,
683
- draftDisabled: Hn,
684
- draftLoading: q && _t === "draft",
685
- primaryButtonLabel: Wn,
686
- primaryLoading: q && _t === $,
687
- primaryDisabled: Hn || V.isLoading && Z(w, $) || Bn && (Wt || !Vn && R.isCounterpartLoading),
688
- scrollContainerRef: yt,
689
- selectAttachmentFiles: z.selectFiles,
690
- setAttachmentIncludeInEmail: z.setIncludeInEmail,
691
- removeAttachment: z.remove,
692
- autoFocusLineItemId: jt,
693
- lineItemUnitOptions: At.unitOptions,
682
+ attachmentsUploading: B.isUploading,
683
+ draftButtonLabel: Vn && !Hn ? Wn : void 0,
684
+ draftDisabled: Un,
685
+ draftLoading: J && vt === "draft",
686
+ primaryButtonLabel: Gn,
687
+ primaryLoading: J && vt === $,
688
+ primaryDisabled: Un || H.isLoading && jn(w, $) || Vn && (Wt || !Hn && z.isCounterpartLoading),
689
+ scrollContainerRef: bt,
690
+ selectAttachmentFiles: B.selectFiles,
691
+ setAttachmentIncludeInEmail: B.setIncludeInEmail,
692
+ removeAttachment: B.remove,
693
+ autoFocusLineItemId: Mt,
694
+ lineItemUnitOptions: jt.unitOptions,
694
695
  lineItemsLoading: k.isLoading,
695
- lineItemControls: Rn,
696
- totals: zn,
697
- preview: tr,
698
- totalsView: er,
696
+ lineItemControls: zn,
697
+ totals: Bn,
698
+ preview: nr,
699
+ totalsView: tr,
699
700
  currencySymbol: re(w.currency),
700
- isSubmitting: q,
701
+ isSubmitting: J,
701
702
  paymentTerms: tn,
702
703
  showBillingSection: w.type === "invoice" || C === "edit",
703
704
  purchaseOrder: C === "create" ? {
704
705
  value: w.purchaseOrder,
705
- error: Dt.purchaseOrder
706
+ error: Ot.purchaseOrder
706
707
  } : void 0,
707
708
  recurrence: fn,
708
709
  showRecurrenceSection: w.type === "invoice",
709
- recurrenceLoading: W,
710
+ recurrenceLoading: G,
710
711
  showDueDateField: w.type === "quote",
711
712
  openCreate: _n,
712
713
  openEdit: vn,
713
- close: Y,
714
+ close: X,
714
715
  requestClose: yn,
715
- unsavedPrompt: $n,
716
- submit: qn,
717
- submitDraft: Gn,
718
- submitPrimary: Kn,
719
- selectDraftMode: Jn,
720
- selectPrimaryMode: Yn,
721
- units: At,
722
- counterpartView: Ot,
716
+ unsavedPrompt: er,
717
+ submit: Jn,
718
+ submitDraft: Kn,
719
+ submitPrimary: qn,
720
+ selectDraftMode: Yn,
721
+ selectPrimaryMode: Xn,
722
+ units: jt,
723
+ counterpartView: kt,
723
724
  counterpartForm: Xt,
724
725
  stateOptions: Lt,
725
726
  openCounterpartCreate: $t,
726
- bankAccount: V,
727
+ bankAccount: H,
727
728
  reminders: mn
728
729
  };
729
730
  }