@tesouro/embedded-components-react 0.5.257 → 0.5.259

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 (64) hide show
  1. package/README.md +2 -1
  2. package/dist/fixtures/index.d.ts +1 -1
  3. package/dist/index.css +109 -9
  4. package/dist/index.d.ts +41 -10
  5. package/dist/lib/ReceivablesWidget.d.ts +41 -10
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +42 -94
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +91 -76
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +67 -173
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +186 -17
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +27 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +28 -72
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +128 -53
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +66 -28
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +28 -34
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +24 -168
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +173 -44
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +274 -267
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +99 -95
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +1 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +28 -25
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +49 -43
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/unsavedChanges.js +13 -0
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +4 -4
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +77 -72
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +4 -4
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +363 -295
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +1 -1
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePreview.js +36 -21
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +1 -1
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +12 -10
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +21 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +68 -64
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +383 -379
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +22 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +8 -2
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +258 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +2 -100
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +95 -23
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +23 -231
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +237 -3
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +3 -249
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +234 -78
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +87 -53
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +49 -349
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +359 -0
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +45 -0
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  56. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +247 -214
  57. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +175 -147
  58. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +1 -1
  59. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  60. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
  61. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +2 -1
  62. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +109 -89
  63. package/package.json +1 -1
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +0 -4
@@ -15,27 +15,27 @@ import "../../../../ui/dist/index19.js";
15
15
  import "../../../../ui/dist/index.js";
16
16
  import { buildLineItemControls as ee, commitLineItemField as s, commitTaxRateInput as c, convertPriceInput as te, createLineItem as ne, getCurrencySymbol as re, lineItemFromProduct as ie, reconcileLineItemIds as ae, reconcileMeasureUnits as oe, sanitizeLineItemPatch as se, sanitizeTaxRateInput as ce, stepLineItemQuantity as le, stripBlankLineItems as ue, summarizeLineItemErrors as de, toSheetLineItem as fe, validateLineItems as pe } from "./lineItems.js";
17
17
  import { buildReceivableAttachmentsView as me } from "./attachments.js";
18
- import { getCurrencyOptions as he } from "../../../../../shared/product-catalog/feature/dist/lib/helpers.js";
19
- import { useMeasureUnitsQuery as ge } from "../../../../../shared/product-catalog/data-access/dist/index9.js";
20
- import { useMeasureUnits as _e } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
18
+ import { useMeasureUnitsQuery as he } from "../../../../../shared/product-catalog/data-access/dist/index9.js";
19
+ import { useMeasureUnits as ge } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
21
20
  import "../../../../../shared/product-catalog/feature/dist/index.js";
22
- import { getInlineItems as ve } from "./actionsModal.js";
23
- import { buildCreateRecurrencePayload as ye, buildUpdateRecurrencePayload as be, clearRecurrenceRecipients as l, countIssuedIterations as xe, isRecurring as u, recurrenceToFormFields as Se, validateRecurrence as Ce, willRecurrenceIssue as we } from "./recurrence.js";
24
- import { convertDiscountInput as Te, decorateDiscountInput as Ee, discountInputToMinorUnits as De, sanitizeDiscountInput as Oe } from "./discount.js";
25
- import { buildFormTotalsView as ke, calculateFormTotals as Ae, validateDiscount as je, validateInvoiceTotals as Me } from "./totals.js";
26
- import { createEmptyReceivableFormValues as Ne, hasReceivableFormErrors as Pe, receivableFormValuesToCreatePayload as Fe, receivableFormValuesToLineItemChanges as Ie, receivableFormValuesToUpdatePayload as Le, receivableToFormValues as Re, resolveCounterpartAddresses as ze, submittedLineItemRows as Be, validateReceivableForm as Ve } from "./helpers.js";
27
- import { getIssueReminderBlocker as He, shouldShowRemindersInitially as Ue } from "./reminders.js";
28
- import { useCreateReceivableMutation as We, useIssueReceivableMutation as Ge, useUpdateReceivableMutation as Ke } from "../../../../data-access/dist/index8.js";
29
- import { useCreateRecurrenceMutation as qe, useRecurrenceQuery as Je, useUpdateRecurrenceMutation as Ye } from "../../../../data-access/dist/index12.js";
21
+ import { getInlineItems as _e } from "./actionsModal.js";
22
+ import { buildCreateRecurrencePayload as ve, buildUpdateRecurrencePayload as ye, clearRecurrenceRecipients as l, countIssuedIterations as be, isRecurring as u, recurrenceToFormFields as xe, validateRecurrence as Se, willRecurrenceIssue as Ce } from "./recurrence.js";
23
+ import { convertDiscountInput as we, decorateDiscountInput as Te, discountInputToMinorUnits as Ee, sanitizeDiscountInput as De } from "./discount.js";
24
+ import { buildFormTotalsView as Oe, calculateFormTotals as ke, validateDiscount as Ae, validateInvoiceTotals as je } from "./totals.js";
25
+ import { createEmptyReceivableFormValues as Me, hasReceivableFormErrors as Ne, receivableFormValuesToCreatePayload as Pe, receivableFormValuesToLineItemChanges as Fe, receivableFormValuesToUpdatePayload as Ie, receivableToFormValues as Le, resolveCounterpartAddresses as Re, submittedLineItemRows as ze, validateReceivableForm as Be } from "./helpers.js";
26
+ import { getIssueReminderBlocker as Ve, shouldShowRemindersInitially as He } from "./reminders.js";
27
+ import { useCreateReceivableMutation as Ue, useIssueReceivableMutation as We, useUpdateReceivableMutation as Ge } from "../../../../data-access/dist/index9.js";
28
+ import { useCreateRecurrenceMutation as Ke, useRecurrenceQuery as qe, useUpdateRecurrenceMutation as Je } from "../../../../data-access/dist/index13.js";
30
29
  import "../../../../data-access/dist/index.js";
31
- import { useReceivableIssuePreflight as Xe } from "./useReceivableIssuePreflight.js";
32
- import { UNSUBMITTED_PAYLOAD_VARIANTS as Ze, apiValidationErrorsToFormErrors as Qe, getApiErrorMessage as $e, parseApiValidationErrors as et } from "./apiValidationErrors.js";
33
- import { useReceivableAttachmentUploads as tt } from "./useReceivableAttachmentUploads.js";
34
- import { useReceivablePaymentTerms as nt } from "./useReceivablePaymentTerms.js";
35
- import { useReceivableRecurrence as rt } from "./useReceivableRecurrence.js";
36
- import { useReceivableBankAccount as it } from "./useReceivableBankAccount.js";
37
- import { useReceivableReminders as at } from "./useReceivableReminders.js";
38
- import { useReceivablePreview as ot } from "./useReceivablePreview.js";
30
+ import { useReceivableIssuePreflight as Ye } from "./useReceivableIssuePreflight.js";
31
+ import { UNSUBMITTED_PAYLOAD_VARIANTS as Xe, apiValidationErrorsToFormErrors as Ze, getApiErrorMessage as Qe, parseApiValidationErrors as $e } from "./apiValidationErrors.js";
32
+ import { useReceivableAttachmentUploads as et } from "./useReceivableAttachmentUploads.js";
33
+ import { useReceivablePaymentTerms as tt } from "./useReceivablePaymentTerms.js";
34
+ import { useReceivableRecurrence as nt } from "./useReceivableRecurrence.js";
35
+ import { useReceivableBankAccount as rt } from "./useReceivableBankAccount.js";
36
+ import { useReceivableReminders as it } from "./useReceivableReminders.js";
37
+ import { useReceivablePreview as at } from "./useReceivablePreview.js";
38
+ import { hasUnsavedChanges as ot } from "./unsavedChanges.js";
39
39
  import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
40
40
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js
41
41
  function st(e, t) {
@@ -43,51 +43,61 @@ function st(e, t) {
43
43
  ...e,
44
44
  customerId: t,
45
45
  billingAddressId: "",
46
- shippingAddressId: ""
46
+ shippingAddressId: "",
47
+ ...t ? { customerEmail: "" } : {}
47
48
  });
48
49
  }
49
50
  function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, onCreated: ut }) {
50
- let dt = We(), ft = Ke(), pt = qe(), mt = Ye(), ht = Ge(), 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(() => Ne()), [Et, E] = h({}), [Dt, Ot] = h("none"), kt = _e(), D = ge(), O = D.data?.data, { unitNamesById: k } = kt, [At, jt] = h(), [A, Mt] = h(!1), Nt = m(!1), j = m(!1), M = m(!1), N = m({
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), N = m(!1), P = m(!1), F = m({
51
52
  lines: !1,
52
53
  discount: !1
53
- }), [Pt, P] = h(!1), Ft = p(() => t(), []), It = p(() => ({
54
+ }), [Ft, I] = h(!1), It = p(() => t(), []), Lt = p(() => ({
54
55
  ...n,
55
56
  ...ct
56
- }), [ct]), Lt = a(w.customerId), Rt = i(w.customerId || void 0), zt = Lt.data?.data?.[0], { billingAddressId: F, billingAddress: Bt, shippingAddressId: Vt } = ze({
57
+ }), [ct]), Rt = a(w.customerId), zt = i(w.customerId || void 0), Bt = Rt.data?.data?.[0], { billingAddressId: L, billingAddress: Vt, shippingAddressId: Ht } = Re({
57
58
  values: w,
58
- counterpart: Rt.data,
59
- addresses: Lt.data?.data
60
- }), I = !!w.customerId && (Lt.isLoading || Rt.isLoading), L = Xe({
59
+ counterpart: zt.data,
60
+ addresses: Rt.data?.data
61
+ }), R = !!w.customerId && (Rt.isLoading || zt.isLoading), z = Ye({
61
62
  counterpartId: w.customerId,
62
- billingAddressId: F,
63
- billingCountry: Bt?.country
64
- }), Ht = L.isLoading || I, Ut = d((e) => {
63
+ billingAddressId: L,
64
+ billingCountry: Vt?.country
65
+ }), Ut = z.isLoading || R, Wt = d((e) => {
65
66
  T((t) => ({
66
67
  ...t,
67
68
  attachments: e(t.attachments)
68
69
  }));
69
- }, []), R = tt({
70
+ }, []), B = et({
70
71
  attachments: w.attachments,
71
- setAttachments: Ut,
72
+ setAttachments: Wt,
72
73
  receivableId: St
73
- }), { reset: z, discardUploads: B, commitRemovals: Wt } = R, Gt = w.type === "invoice" ? me({
74
+ }), { reset: V, discardUploads: Gt, commitRemovals: Kt } = B, qt = w.type === "invoice" ? me({
74
75
  attachments: w.attachments,
75
- pendingUploads: R.pendingUploads,
76
- isCountLimitReached: R.isCountLimitReached,
76
+ pendingUploads: B.pendingUploads,
77
+ isCountLimitReached: B.isCountLimitReached,
77
78
  isRecurring: u(w),
78
79
  messages: l
79
- }) : void 0, Kt = d((e) => {
80
+ }) : void 0, Jt = d((e) => {
80
81
  T((t) => st(t, e ?? ""));
81
- }, []), qt = o({
82
- view: Dt,
83
- setView: Ot,
82
+ }, []), Yt = o({
83
+ view: Ot,
84
+ setView: kt,
84
85
  selectedId: w.customerId || void 0,
85
- setSelectedId: Kt,
86
- messages: It,
86
+ setSelectedId: Jt,
87
+ messages: Lt,
87
88
  counterpartType: "customer",
88
89
  counterpart: void 0,
89
- primaryAddress: zt
90
- }), Jt = d((e) => T((t) => {
90
+ primaryAddress: Bt
91
+ }), { openCreate: Xt, setValues: Zt } = Yt, Qt = d(() => {
92
+ Xt(), Zt((e) => ({
93
+ ...e,
94
+ email: w.customerEmail.trim()
95
+ }));
96
+ }, [
97
+ Xt,
98
+ Zt,
99
+ w.customerEmail
100
+ ]), $t = d((e) => T((t) => {
91
101
  let n = e({
92
102
  paymentTermsId: t.paymentTermsId,
93
103
  paymentTermsCustomDate: t.paymentTermsCustomDate
@@ -97,256 +107,291 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
97
107
  ...n,
98
108
  ...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
99
109
  };
100
- }), []), Yt = nt({
110
+ }), []), en = tt({
101
111
  paymentTermsId: w.paymentTermsId,
102
112
  paymentTermsCustomDate: w.paymentTermsCustomDate,
103
113
  issueDate: w.issueDate,
104
114
  isRecurring: w.type === "invoice" && u(w),
105
115
  messages: l,
106
- onChange: Jt
107
- }), Xt = Yt.reset, Zt = d((e) => T((t) => ({
108
- ...t,
109
- ...e
110
- })), []), V = it({
116
+ onChange: $t
117
+ }), tn = en.reset, nn = d((e, { automatic: t = !1 } = {}) => {
118
+ t && (E.current = {
119
+ ...E.current,
120
+ ...e
121
+ }), T((t) => ({
122
+ ...t,
123
+ ...e
124
+ }));
125
+ }, []), H = rt({
111
126
  open: x,
112
127
  bankAccountId: w.bankAccountId,
128
+ bankAccountType: w.bankAccountType,
113
129
  embeddedBankName: lt,
114
130
  messages: l,
115
- onSelect: Zt
116
- }), Qt = V.reset, $t = Je(wt), H = wt ? $t.data : void 0, U = xe(H), en = U > 0, W = !!wt && $t.isLoading, G = m(void 0);
131
+ onSelect: nn
132
+ }), rn = H.reset, an = qe(wt), U = wt ? an.data : void 0, W = be(U), on = W > 0, G = !!wt && an.isLoading, K = m(void 0);
117
133
  f(() => {
118
- H && G.current !== H.id && (G.current = H.id, T((e) => ({
119
- ...e,
120
- ...Se(H)
121
- })));
122
- }, [H]);
123
- let tn = d((e) => T(e), []), nn = d((e) => E((t) => {
134
+ if (!U || K.current === U.id) return;
135
+ K.current = U.id;
136
+ let e = xe(U);
137
+ E.current = {
138
+ ...E.current,
139
+ ...e
140
+ }, T((t) => ({
141
+ ...t,
142
+ ...e
143
+ }));
144
+ }, [U]);
145
+ let sn = d((e) => T(e), []), cn = d((e) => O((t) => {
124
146
  if (!e.some((e) => e in t)) return t;
125
147
  let n = { ...t };
126
148
  return e.forEach((e) => delete n[e]), n;
127
- }), []), rn = m([]), an = d((e) => {
128
- if (!A) {
129
- nn(e);
149
+ }), []), ln = m([]), un = d((e) => {
150
+ if (!M) {
151
+ cn(e);
130
152
  return;
131
153
  }
132
- rn.current.push(...e);
133
- }, [nn, A]);
154
+ ln.current.push(...e);
155
+ }, [cn, M]);
134
156
  f(() => {
135
- let e = rn.current;
157
+ let e = ln.current;
136
158
  if (!e.length) return;
137
- rn.current = [];
138
- let t = Ce({
159
+ ln.current = [];
160
+ let t = Se({
139
161
  fields: w,
140
- issuedCount: U,
162
+ issuedCount: W,
141
163
  messages: l
142
164
  });
143
- E((n) => {
165
+ O((n) => {
144
166
  let r = { ...n };
145
167
  return e.forEach((e) => {
146
168
  t[e] ? r[e] = t[e] : delete r[e];
147
169
  }), r;
148
170
  });
149
171
  }, [
150
- U,
172
+ W,
151
173
  l,
152
174
  w
153
175
  ]);
154
- let on = rt({
176
+ let dn = nt({
155
177
  values: w,
156
- errors: Et,
157
- lockSchedule: en,
178
+ errors: Dt,
179
+ lockSchedule: on,
158
180
  messages: l,
159
- onChange: tn,
160
- onClearErrors: nn,
161
- onRevalidateErrors: an
162
- }), K = on.reset, sn = d((e) => T((t) => ({
181
+ onChange: sn,
182
+ onClearErrors: cn,
183
+ onRevalidateErrors: un
184
+ }), q = dn.reset, fn = d((e) => T((t) => ({
163
185
  ...t,
164
186
  ...e
165
- })), []), q = dt.isPending || ft.isPending || pt.isPending || mt.isPending || ht.isPending, cn = at({
187
+ })), []), J = dt.isPending || ft.isPending || pt.isPending || mt.isPending || ht.isPending, pn = it({
166
188
  open: x,
167
189
  isInvoice: w.type === "invoice",
168
- disabled: q,
190
+ disabled: J,
169
191
  paymentTermsId: w.paymentTermsId,
170
192
  paymentTermsCustomDate: w.paymentTermsCustomDate,
171
193
  paymentReminderId: w.paymentReminderId,
172
194
  overdueReminderId: w.overdueReminderId,
173
195
  messages: l,
174
- onSelect: sn
175
- }), ln = cn.reset, un = d(() => {
176
- b.current = [], jt(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(Ne()), E({}), Mt(!1), P(!1), N.current = {
196
+ onSelect: fn
197
+ }), mn = pn.reset, hn = d(() => {
198
+ b.current = [], Mt(void 0), xt("create"), Ct(void 0), Tt(void 0), K.current = void 0, y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, T(Me()), D(!1), O({}), Nt(!1), I(!1), F.current = {
177
199
  lines: !1,
178
200
  discount: !1
179
- }, z(), K();
180
- }, [z, K]), dn = d((e = "invoice", { customerId: t = "" } = {}) => {
181
- Xt(), Qt(), K();
201
+ }, V(), q();
202
+ }, [V, q]), gn = d((e = "invoice", { customerId: t = "" } = {}) => {
203
+ tn(), rn(), q();
182
204
  let n = {
183
- ...Ne(),
205
+ ...Me(),
184
206
  type: e,
185
207
  customerId: t
186
208
  };
187
- ln(Ue(n)), b.current = [], y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, G.current = void 0, jt(void 0), xt("create"), Ct(void 0), Tt(void 0), T(n), E({}), z(), Mt(!1), P(!1), N.current = {
209
+ mn(He(n)), b.current = [], y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, K.current = void 0, Mt(void 0), xt("create"), Ct(void 0), Tt(void 0), E.current = n, T(n), D(!1), O({}), V(), Nt(!1), I(!1), F.current = {
188
210
  lines: !1,
189
211
  discount: !1
190
212
  }, S(!0);
191
213
  }, [
192
- z,
193
- Xt,
194
- Qt,
195
- K,
196
- ln
197
- ]), fn = d((e, { highlightForIssue: t = !1 } = {}) => {
214
+ V,
215
+ tn,
216
+ rn,
217
+ q,
218
+ mn
219
+ ]), _n = d((e, { highlightForIssue: t = !1 } = {}) => {
198
220
  if (e.type === "credit_note") return;
199
- Xt(), Qt(), K();
200
- let n = Re(e, O);
201
- ln(Ue(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, jt(void 0), xt("edit"), Ct(e.id), Tt(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), T(n), E({}), Mt(!1), P(!1), N.current = {
221
+ tn(), rn(), q();
222
+ let n = Le(e, A);
223
+ mn(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, K.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), I(!1), F.current = {
202
224
  lines: !1,
203
225
  discount: !1
204
- }, z(), S(!0);
226
+ }, V(), S(!0);
205
227
  }, [
206
- z,
207
- Xt,
208
- Qt,
209
- K,
210
- ln,
211
- O
228
+ V,
229
+ tn,
230
+ rn,
231
+ q,
232
+ mn,
233
+ A
212
234
  ]);
213
235
  f(() => {
214
- O?.length && T((e) => {
215
- let t = oe(e.lineItems, O);
236
+ A?.length && (E.current = {
237
+ ...E.current,
238
+ lineItems: oe(E.current.lineItems, A)
239
+ }, T((e) => {
240
+ let t = oe(e.lineItems, A);
216
241
  return t === e.lineItems ? e : {
217
242
  ...e,
218
243
  lineItems: t
219
244
  };
220
- });
221
- }, [O]);
222
- let pn = R.isUploading, mn = d(() => {
223
- pn || (B(), S(!1), E({}));
224
- }, [B, pn]), hn = d((e) => {
245
+ }));
246
+ }, [A]);
247
+ let Y = B.isUploading, X = d(() => {
248
+ Y || (Gt(), D(!1), S(!1), O({}));
249
+ }, [Gt, Y]), vn = d(() => {
250
+ if (Et) {
251
+ D(!1);
252
+ return;
253
+ }
254
+ if (Y) {
255
+ e.error(l.attachmentsUploading);
256
+ return;
257
+ }
258
+ if (ot(E.current, w)) {
259
+ D(!0);
260
+ return;
261
+ }
262
+ X();
263
+ }, [
264
+ X,
265
+ Y,
266
+ l.attachmentsUploading,
267
+ Et,
268
+ w
269
+ ]), yn = d((e) => {
225
270
  let t = { ...e };
226
- t.taxRate !== void 0 && (t.taxRate = ce(t.taxRate), M.current = !0), t.type !== void 0 && t.type !== "invoice" && B(), t.type !== void 0 && (g.current = "draft"), t.discount !== void 0 && A && (j.current = !0), t.discountType !== void 0 && (j.current = !0), t.currency !== void 0 && (Nt.current = !0), T((e) => {
271
+ t.taxRate !== void 0 && (t.taxRate = ce(t.taxRate), P.current = !0), t.type !== void 0 && t.type !== "invoice" && Gt(), 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 && (Pt.current = !0), T((e) => {
227
272
  let n = {
228
273
  ...t.customerId === void 0 ? e : st(e, t.customerId),
229
274
  ...t
230
275
  };
231
- return t.discount !== void 0 && (n.discount = Oe(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
276
+ return t.discount !== void 0 && (n.discount = De(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
232
277
  ...t,
233
278
  price: te(t.price, e.currency, n.currency)
234
- }))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = Te({
279
+ }))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = we({
235
280
  value: n.discount,
236
281
  type: n.discountType,
237
282
  currency: n.currency
238
283
  })), n;
239
284
  });
240
- }, [B, A]), gn = d(() => P(!0), []), _n = d(() => {
241
- P(!1), j.current = !0, T((e) => ({
285
+ }, [Gt, M]), bn = d(() => I(!0), []), xn = d(() => {
286
+ I(!1), N.current = !0, T((e) => ({
242
287
  ...e,
243
- discount: Te({
288
+ discount: we({
244
289
  value: e.discount,
245
290
  type: e.discountType,
246
291
  currency: e.currency
247
292
  })
248
293
  }));
249
- }, []), vn = d(() => {
250
- M.current = !0, T((e) => {
294
+ }, []), Sn = d(() => {
295
+ P.current = !0, T((e) => {
251
296
  let t = c(e.taxRate);
252
297
  return t === e.taxRate ? e : {
253
298
  ...e,
254
299
  taxRate: t
255
300
  };
256
301
  });
257
- }, []), J = d((e, { validate: t }) => {
258
- t && (Nt.current = !0), T((t) => ({
302
+ }, []), Z = d((e, { validate: t }) => {
303
+ t && (Pt.current = !0), T((t) => ({
259
304
  ...t,
260
305
  lineItems: e(t.lineItems)
261
306
  }));
262
307
  }, []);
263
308
  f(() => {
264
- let e = Nt.current, t = j.current;
265
- if (!e && !t && !M.current) return;
266
- Nt.current = !1, j.current = !1, M.current = !1, e && (N.current.lines = !0), t && (N.current.discount = !0);
267
- let n = _.current || U > 0, r = e ? pe(w.lineItems, {
309
+ let e = Pt.current, t = N.current;
310
+ if (!e && !t && !P.current) return;
311
+ Pt.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, {
268
313
  currency: w.currency,
269
314
  messages: l,
270
315
  requireComplete: n
271
316
  }) : void 0;
272
- E((t) => {
317
+ O((t) => {
273
318
  let i = { ...t };
274
- return N.current.lines && (i.lineItems = e ? r : t.lineItems, i.lineItemsSummary = de(i.lineItems, Me(w, l), n && w.lineItems.length === 0 ? l.lineItemsRequired : void 0)), N.current.discount && (i.discount = je(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;
275
320
  });
276
321
  }, [
277
- U,
322
+ W,
278
323
  l,
279
324
  w
280
325
  ]);
281
- let yn = d((e, t) => {
326
+ let Cn = d((e, t) => {
282
327
  let { unit: n, ...r } = t, i = se(r);
283
- i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (M.current = !0), J((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 ? {
284
329
  ...t,
285
330
  ...i
286
- } : t), { validate: A });
287
- }, [J, A]), bn = d((e, t) => {
288
- J((n) => n.map((n) => n.id === e ? {
331
+ } : t), { validate: M });
332
+ }, [Z, M]), wn = d((e, t) => {
333
+ Z((n) => n.map((n) => n.id === e ? {
289
334
  ...n,
290
335
  ...ie({
291
336
  product: t,
292
337
  currency: w.currency,
293
- unitNamesById: k
338
+ unitNamesById: j
294
339
  })
295
340
  } : n), { validate: !0 });
296
341
  }, [
297
- J,
298
- k,
342
+ Z,
343
+ j,
299
344
  w.currency
300
- ]), xn = d((e, t) => {
301
- t && J((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
345
+ ]), Tn = d((e, t) => {
346
+ t && Z((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
302
347
  ...n,
303
348
  ...t.patch
304
349
  } : n), { validate: !0 });
305
- }, [J]), Sn = d((e, t) => {
350
+ }, [Z]), En = d((e, t) => {
306
351
  let n = w.lineItems.find((t) => t.id === e);
307
- n && xn(e, s({
352
+ n && Tn(e, s({
308
353
  lineItem: n,
309
354
  field: t,
310
355
  rowCount: w.lineItems.length,
311
356
  currency: w.currency
312
357
  }));
313
358
  }, [
314
- xn,
359
+ Tn,
315
360
  w.currency,
316
361
  w.lineItems
317
- ]), Cn = d((e, t) => {
362
+ ]), Dn = d((e, t) => {
318
363
  let n = w.lineItems.find((t) => t.id === e);
319
- n && xn(e, le({
364
+ n && Tn(e, le({
320
365
  lineItem: n,
321
366
  step: t,
322
367
  rowCount: w.lineItems.length
323
368
  }));
324
- }, [xn, w.lineItems]), wn = d(() => {
369
+ }, [Tn, w.lineItems]), On = d(() => {
325
370
  let e = ne(w.currency);
326
- jt(e.id), T((t) => ({
371
+ Mt(e.id), T((t) => ({
327
372
  ...t,
328
373
  lineItems: [...t.lineItems, e]
329
374
  }));
330
- }, [w.currency]), Tn = d((e) => {
331
- J((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
332
- }, [J]), Y = d((e, t) => e.type === "invoice" && (t === "issue" || we(e) && U === 0), [U]), En = d((e, t) => ({
333
- ...Ve({
375
+ }, [w.currency]), kn = d((e) => {
376
+ Z((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
377
+ }, [Z]), An = d((e, t) => e.type === "invoice" && (t === "issue" || Ce(e) && W === 0), [W]), jn = d((e, t) => ({
378
+ ...Be({
334
379
  values: e,
335
- billingAddressId: F,
380
+ billingAddressId: L,
336
381
  messages: l,
337
382
  willIssue: t,
338
- hasStartedRecurrence: U > 0
383
+ hasStartedRecurrence: W > 0
339
384
  }),
340
- ...e.type === "invoice" && u(e) ? Ce({
385
+ ...e.type === "invoice" && u(e) ? Se({
341
386
  fields: e,
342
- issuedCount: U,
387
+ issuedCount: W,
343
388
  messages: l
344
389
  }) : {}
345
390
  }), [
346
- F,
347
- U,
391
+ L,
392
+ W,
348
393
  l
349
- ]), Dn = d(() => {
394
+ ]), Mn = d(() => {
350
395
  requestAnimationFrame(() => {
351
396
  let e = yt.current, t = e?.querySelector("[aria-invalid=\"true\"], [data-invalid=\"true\"]");
352
397
  if (!e || !t) return;
@@ -356,71 +401,72 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
356
401
  behavior: "smooth"
357
402
  });
358
403
  });
359
- }, []), X = d((e, t) => {
360
- E(e), Mt(!0), _.current = t, N.current = {
404
+ }, []), Nn = d((e, t) => {
405
+ O(e), Nt(!0), _.current = t, F.current = {
361
406
  lines: !0,
362
407
  discount: !0
363
- }, Dn();
364
- }, [Dn]), On = !wt || w.frequency !== "once" || $t.isError;
408
+ }, Mn();
409
+ }, [Mn]), Pn = !wt || w.frequency !== "once" || an.isError;
365
410
  f(() => {
366
- if (!x || !v.current || I || W || !On) return;
411
+ if (!x || !v.current || R || G || !Pn) return;
367
412
  v.current = !1;
368
- let e = Y(w, "issue");
369
- X(En(w, e), e);
413
+ let e = An(w, "issue");
414
+ Nn(jn(w, e), e);
370
415
  }, [
371
- I,
416
+ R,
372
417
  x,
373
- On,
374
- W,
375
- X,
376
- En,
418
+ Pn,
419
+ G,
420
+ Nn,
421
+ jn,
377
422
  w,
378
- Y
423
+ An
379
424
  ]);
380
- let kn = m({
425
+ let Fn = m({
381
426
  values: w,
382
- billingAddressId: F
427
+ billingAddressId: L
383
428
  });
384
429
  f(() => {
385
- let e = kn.current;
386
- if (kn.current = {
430
+ let e = Fn.current;
431
+ if (Fn.current = {
387
432
  values: w,
388
- billingAddressId: F
389
- }, !A) return;
433
+ billingAddressId: L
434
+ }, !M) return;
390
435
  let t = [
391
436
  "customerId",
437
+ "customerEmail",
392
438
  "paymentTermsId",
393
439
  "bankAccountId",
394
440
  "openingNote",
395
441
  "closingNote",
396
442
  "taxRate"
397
- ].filter((t) => e.values[t] !== w[t] || t === "customerId" && e.billingAddressId !== F || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== w.paymentTermsCustomDate);
443
+ ].filter((t) => e.values[t] !== w[t] || t === "customerId" && e.billingAddressId !== L || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== w.paymentTermsCustomDate);
398
444
  if (!t.length) return;
399
- let n = Ve({
445
+ let n = Be({
400
446
  values: w,
401
- billingAddressId: F,
447
+ billingAddressId: L,
402
448
  messages: l,
403
449
  willIssue: _.current
404
450
  });
405
- E((e) => {
451
+ O((e) => {
406
452
  let r = { ...e };
407
453
  return t.forEach((e) => {
408
454
  n[e] ? r[e] = n[e] : delete r[e];
409
455
  }), r;
410
456
  });
411
457
  }, [
412
- F,
458
+ L,
413
459
  l,
414
- A,
460
+ M,
415
461
  w
416
462
  ]);
417
- let An = d(async (t) => {
418
- if (g.current = t, W) return;
419
- if (pn) {
463
+ let In = d(async (t) => {
464
+ if (g.current = t, G) return;
465
+ if (Y) {
420
466
  e.error(l.attachmentsUploading);
421
467
  return;
422
468
  }
423
- if (D.isLoading || I) {
469
+ if (k.isLoading || R) {
424
470
  e.error(l.lineItemsLoading);
425
471
  return;
426
472
  }
@@ -429,26 +475,26 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
429
475
  lineItems: n
430
476
  };
431
477
  i !== w && T(i);
432
- let a = i.type === "invoice" && u(i), o = Y(i, t);
433
- if (o && (Ht || V.isLoading)) {
478
+ let a = i.type === "invoice" && u(i), o = An(i, t);
479
+ if (o && (Ut || H.isLoading)) {
434
480
  e.error(l.issueChecksLoading);
435
481
  return;
436
482
  }
437
- if (o && !V.canAddAccount && !i.bankAccountId && !V.hasAccounts) {
483
+ if (o && !H.canAddAccount && !i.bankAccountId && !H.hasAccounts) {
438
484
  e.error(l.issueBankAccountUnavailable);
439
485
  return;
440
486
  }
441
- let ee = En(i, o);
442
- if (Pe(ee)) {
443
- X(ee, o);
487
+ let ee = jn(i, o);
488
+ if (Ne(ee)) {
489
+ Nn(ee, o);
444
490
  return;
445
491
  }
446
- if (E({}), o && L.isTaxIdMissing) {
492
+ if (O({}), o && z.isTaxIdMissing) {
447
493
  e.error(l.issueTaxIdRequired);
448
494
  return;
449
495
  }
450
496
  if (o && (i.paymentReminderId || i.overdueReminderId)) {
451
- let t = He(L.counterpart, l);
497
+ let t = Ve(z.counterpart, l);
452
498
  if (t) {
453
499
  e.error(t);
454
500
  return;
@@ -457,41 +503,41 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
457
503
  let s = C === "edit" ? St : y.current, c, te, ne = {};
458
504
  try {
459
505
  if (s) {
460
- let e = Ie({
506
+ let e = Fe({
461
507
  values: i,
462
508
  originalLineItems: b.current,
463
509
  originalCurrency: bt.current,
464
- unitNamesById: k,
465
- units: O
510
+ unitNamesById: j,
511
+ units: A
466
512
  });
467
- ne = Be({
513
+ ne = ze({
468
514
  values: i,
469
515
  originalLineItems: b.current,
470
516
  changes: e
471
517
  });
472
518
  let t = await ft.mutateAsync({
473
519
  path: { receivable_id: s },
474
- body: Le({
520
+ body: Ie({
475
521
  values: i,
476
- billingAddressId: F,
477
- shippingAddressId: Vt,
522
+ billingAddressId: L,
523
+ shippingAddressId: Ht,
478
524
  lineItemChanges: e
479
525
  })
480
526
  });
481
- Wt(), c = s, te = t?.type ?? i.type, a && t && (b.current = t.line_items, bt.current = t.currency, i = {
527
+ Kt(), c = s, te = t?.type ?? i.type, a && t && (b.current = t.line_items, bt.current = t.currency, i = {
482
528
  ...i,
483
529
  lineItems: ae(i.lineItems, t.line_items)
484
530
  }, T(i));
485
531
  } else {
486
- ne = Be({ values: i });
487
- let e = await dt.mutateAsync({ body: Fe({
532
+ ne = ze({ values: i });
533
+ let e = await dt.mutateAsync({ body: Pe({
488
534
  values: i,
489
- billingAddressId: F,
490
- shippingAddressId: Vt,
491
- unitNamesById: k
535
+ billingAddressId: L,
536
+ shippingAddressId: Ht,
537
+ unitNamesById: j
492
538
  }) });
493
539
  if (!e?.id) {
494
- S(!1), un();
540
+ S(!1), hn();
495
541
  return;
496
542
  }
497
543
  c = e.id, te = e.type, a && (y.current = e.id, b.current = e.line_items, bt.current = e.currency, i = {
@@ -500,13 +546,13 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
500
546
  }, T(i));
501
547
  }
502
548
  } catch (t) {
503
- let n = Ze[i.type], r = $e(t, {
549
+ let n = Xe[i.type], r = Qe(t, {
504
550
  irrelevantVariants: n,
505
551
  messages: l
506
552
  });
507
553
  e.error((s ? l.updateFailed : l.createFailed).replace("{errorMessage}", r));
508
- let { errors: a, listError: ee } = Qe(et(t, n), ne), c = de(a.lineItems, void 0, ee);
509
- X({
554
+ let { errors: a, listError: ee } = Ze($e(t, n), ne), c = de(a.lineItems, void 0, ee);
555
+ Nn({
510
556
  ...a,
511
557
  ...c ? { lineItemsSummary: c } : {}
512
558
  }, o);
@@ -514,12 +560,12 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
514
560
  }
515
561
  let re = a ? "recurrence" : "draft";
516
562
  if (a) try {
517
- H ? await mt.mutateAsync({
518
- path: { recurrence_id: H.id },
519
- body: be(i, { lockSchedule: en })
520
- }) : await pt.mutateAsync({ body: ye(i, c) });
563
+ U ? await mt.mutateAsync({
564
+ path: { recurrence_id: U.id },
565
+ body: ye(i, { lockSchedule: on })
566
+ }) : await pt.mutateAsync({ body: ve(i, c) });
521
567
  } catch (t) {
522
- e.error($e(t, { messages: l }));
568
+ e.error(Qe(t, { messages: l }));
523
569
  return;
524
570
  }
525
571
  else if (o) try {
@@ -528,66 +574,87 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
528
574
  e.error(l.issueFailedAfterSave);
529
575
  }
530
576
  let ie = C === "create";
531
- S(!1), un(), ie && ut?.(c, te, {
577
+ S(!1), hn(), ie && ut?.(c, te, {
532
578
  mode: re,
533
579
  counterpartId: i.customerId,
534
- inlineItems: ve(i.lineItems, i.currency),
535
- hasCustomerEmail: !!(L.counterpart && r(L.counterpart).trim())
580
+ inlineItems: _e(i.lineItems, i.currency),
581
+ hasCustomerEmail: !!(z.counterpart && r(z.counterpart).trim())
536
582
  });
537
583
  }, [
538
- V.canAddAccount,
539
- V.hasAccounts,
540
- V.isLoading,
541
- F,
542
- Wt,
584
+ H.canAddAccount,
585
+ H.hasAccounts,
586
+ H.isLoading,
587
+ L,
588
+ Kt,
543
589
  dt,
544
590
  pt,
545
591
  St,
546
- H,
547
- I,
548
- pn,
549
- Ht,
592
+ U,
593
+ R,
594
+ Y,
595
+ Ut,
550
596
  ht,
551
- en,
597
+ on,
552
598
  l,
553
599
  C,
554
600
  ut,
555
- L.counterpart,
556
- L.isTaxIdMissing,
557
- W,
558
- un,
559
- Vt,
560
- X,
561
- O,
562
- k,
563
- D.isLoading,
601
+ z.counterpart,
602
+ z.isTaxIdMissing,
603
+ G,
604
+ hn,
605
+ Ht,
606
+ Nn,
607
+ A,
608
+ j,
609
+ k.isLoading,
564
610
  ft,
565
611
  mt,
566
- En,
612
+ jn,
567
613
  w,
568
- Y
569
- ]), Z = d(async (e = g.current) => {
614
+ An
615
+ ]), Q = d(async (e = g.current) => {
570
616
  if (!gt.current) {
571
617
  gt.current = !0, vt(e);
572
618
  try {
573
- await An(e);
619
+ await In(e);
574
620
  } finally {
575
621
  gt.current = !1, vt(void 0);
576
622
  }
577
623
  }
578
- }, [An]), jn = p(() => ({
624
+ }, [In]), Ln = p(() => ({
579
625
  ...w,
580
- discount: Pt ? w.discount : Ee(De(w.discount, w.discountType, w.currency), w.discountType, w.currency),
626
+ discount: Ft ? w.discount : Te(Ee(w.discount, w.discountType, w.currency), w.discountType, w.currency),
581
627
  lineItems: w.lineItems.map(fe)
582
- }), [Pt, w]), Mn = p(() => ee(w.lineItems), [w.lineItems]), Nn = p(() => Ae(w), [w]), Q = w.type === "invoice", Pn = Q && u(w), Fn = q || D.isLoading || I || R.isUploading || W, In = C === "edit" ? l.updateDraftButton : l.saveDraftButton, Ln = Pn ? H ? l.recurrenceUpdateButton : l.recurrenceActivateButton : Q ? l.issueButton : In, $ = Q && !Pn ? "issue" : "draft", Rn = d(() => Z("draft"), [Z]), zn = d(() => Z($), [$, Z]), Bn = d(() => Z(), [Z]), Vn = d(() => {
628
+ }), [Ft, w]), Rn = p(() => ee(w.lineItems), [w.lineItems]), zn = p(() => ke(w), [w]), Bn = w.type === "invoice", Vn = Bn && u(w), Hn = J || k.isLoading || R || B.isUploading || G, Un = C === "edit" ? l.updateDraftButton : l.saveDraftButton, Wn = Vn ? U ? 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(() => {
583
629
  g.current = "draft";
584
- }, []), Hn = d(() => {
630
+ }, []), Yn = d(() => {
585
631
  g.current = $;
586
- }, [$]), Un = p(() => ke(Nn, w.currency), [Nn, w.currency]), Wn = ot({
632
+ }, [$]), Xn = Hn || Vn, Zn = d(async () => {
633
+ if (!Xn) try {
634
+ await Q("draft");
635
+ } finally {
636
+ D(!1);
637
+ }
638
+ }, [Xn, Q]), Qn = d(() => D(!1), []), $n = p(() => ({
639
+ open: Et,
640
+ onSaveDraft: () => void Zn(),
641
+ onDiscard: X,
642
+ onCancel: Qn,
643
+ isSaving: J,
644
+ isSaveDraftDisabled: Xn
645
+ }), [
646
+ Qn,
647
+ X,
648
+ J,
649
+ Xn,
650
+ Zn,
651
+ Et
652
+ ]), er = p(() => Oe(zn, w.currency), [zn, w.currency]), tr = at({
587
653
  values: w,
588
- totals: Nn,
589
- billingAddress: Bt,
590
- unitNamesById: k,
654
+ totals: zn,
655
+ billingAddress: Vt,
656
+ bankAccount: H.selectedAccount,
657
+ unitNamesById: j,
591
658
  messages: l,
592
659
  enabled: x
593
660
  });
@@ -596,62 +663,63 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
596
663
  setOpen: S,
597
664
  mode: C,
598
665
  values: w,
599
- sheetValues: jn,
600
- errors: Et,
666
+ sheetValues: Ln,
667
+ errors: Dt,
601
668
  setValues: T,
602
- updateValues: hn,
603
- commitTaxRate: vn,
604
- focusDiscount: gn,
605
- commitDiscount: _n,
606
- updateLineItem: yn,
607
- selectProduct: bn,
608
- commitLineItem: Sn,
609
- stepLineItem: Cn,
610
- addLineItem: wn,
611
- removeLineItem: Tn,
612
- attachmentsView: Gt,
613
- attachmentsUploading: R.isUploading,
614
- draftButtonLabel: Q && !Pn ? In : void 0,
615
- draftDisabled: Fn,
616
- draftLoading: q && _t === "draft",
617
- primaryButtonLabel: Ln,
618
- primaryLoading: q && _t === $,
619
- primaryDisabled: Fn || V.isLoading && Y(w, $) || Q && (Ht || !Pn && L.isCounterpartLoading),
669
+ updateValues: yn,
670
+ commitTaxRate: Sn,
671
+ focusDiscount: bn,
672
+ commitDiscount: xn,
673
+ updateLineItem: Cn,
674
+ selectProduct: wn,
675
+ commitLineItem: En,
676
+ stepLineItem: Dn,
677
+ addLineItem: On,
678
+ removeLineItem: kn,
679
+ attachmentsView: qt,
680
+ attachmentsUploading: B.isUploading,
681
+ draftButtonLabel: Bn && !Vn ? Un : void 0,
682
+ draftDisabled: Hn,
683
+ draftLoading: J && _t === "draft",
684
+ primaryButtonLabel: Wn,
685
+ primaryLoading: J && _t === $,
686
+ primaryDisabled: Hn || H.isLoading && An(w, $) || Bn && (Ut || !Vn && z.isCounterpartLoading),
620
687
  scrollContainerRef: yt,
621
- selectAttachmentFiles: R.selectFiles,
622
- setAttachmentIncludeInEmail: R.setIncludeInEmail,
623
- removeAttachment: R.remove,
624
- autoFocusLineItemId: At,
625
- lineItemUnitOptions: kt.unitOptions,
626
- lineItemsLoading: D.isLoading,
627
- lineItemControls: Mn,
628
- totals: Nn,
629
- preview: Wn,
630
- totalsView: Un,
688
+ selectAttachmentFiles: B.selectFiles,
689
+ setAttachmentIncludeInEmail: B.setIncludeInEmail,
690
+ removeAttachment: B.remove,
691
+ autoFocusLineItemId: jt,
692
+ lineItemUnitOptions: At.unitOptions,
693
+ lineItemsLoading: k.isLoading,
694
+ lineItemControls: Rn,
695
+ totals: zn,
696
+ preview: tr,
697
+ totalsView: er,
631
698
  currencySymbol: re(w.currency),
632
- isSubmitting: q,
633
- currencyOptions: he(w.currency),
634
- paymentTerms: Yt,
699
+ isSubmitting: J,
700
+ paymentTerms: en,
635
701
  showBillingSection: w.type === "invoice" || C === "edit",
636
- recurrence: on,
702
+ recurrence: dn,
637
703
  showRecurrenceSection: w.type === "invoice",
638
- recurrenceLoading: W,
704
+ recurrenceLoading: G,
639
705
  showDueDateField: w.type === "quote",
640
- openCreate: dn,
641
- openEdit: fn,
642
- close: mn,
643
- submit: Bn,
644
- submitDraft: Rn,
645
- submitPrimary: zn,
646
- selectDraftMode: Vn,
647
- selectPrimaryMode: Hn,
648
- units: kt,
649
- counterpartView: Dt,
650
- counterpartForm: qt,
651
- stateOptions: Ft,
652
- openCounterpartCreate: qt.openCreate,
653
- bankAccount: V,
654
- reminders: cn
706
+ openCreate: gn,
707
+ openEdit: _n,
708
+ close: X,
709
+ requestClose: vn,
710
+ unsavedPrompt: $n,
711
+ submit: qn,
712
+ submitDraft: Gn,
713
+ submitPrimary: Kn,
714
+ selectDraftMode: Jn,
715
+ selectPrimaryMode: Yn,
716
+ units: At,
717
+ counterpartView: Ot,
718
+ counterpartForm: Yt,
719
+ stateOptions: It,
720
+ openCounterpartCreate: Qt,
721
+ bankAccount: H,
722
+ reminders: pn
655
723
  };
656
724
  }
657
725
  //#endregion