@tesouro/embedded-components-react 0.5.227 → 0.5.230
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.
- package/README.md +22 -21
- package/dist/index.d.ts +87 -34
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +87 -34
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +29 -59
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +32 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +34 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +120 -52
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +44 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +93 -442
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +356 -201
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +225 -157
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +152 -21
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +18 -221
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +220 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +125 -124
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +58 -150
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +232 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +303 -122
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +43 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +125 -98
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +140 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +46 -232
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +119 -29
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +81 -613
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +116 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +27 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +634 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +39 -119
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +36 -317
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +82 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +139 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +340 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +15 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +55 -468
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +443 -97
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +24 -22
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +32 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +205 -84
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +161 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +12 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +25 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +95 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -18
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +24 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +42 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +14 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +19 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +73 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +17 -261
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +12 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +28 -68
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +288 -479
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +1 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +48 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +72 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +496 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +121 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +106 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +2 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +4 -236
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +90 -239
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +24 -89
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +231 -54
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -353
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +100 -207
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +59 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +353 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +35 -29
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +2 -216
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +9 -159
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +27 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +216 -23
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +189 -211
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +43 -59
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +0 -100
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js
CHANGED
|
@@ -1,464 +1,115 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { attachmentFormValuesToPayload as d, receivableToAttachmentFormValues as f } from "./index7.js";
|
|
5
|
-
import { createEmptyRecurrenceFields as p } from "./index8.js";
|
|
6
|
-
import { buildPaymentTermsPayload as m, buildPaymentTermsUpdatePayload as h, paymentTermsToFormFields as g } from "./index9.js";
|
|
7
|
-
import { createEmptyDiscount as _, discountFromDraft as v, discountToDraft as y } from "./index10.js";
|
|
8
|
-
import { validateDiscount as b, validateInvoiceTotals as x } from "./index11.js";
|
|
2
|
+
import { isBlankLineItem as t, keepsSavedTaxRates as n, lineItemTaxRateMinorUnits as r, maxAmountLabel as i, parseQuantity as a, priceInputToMinorUnits as o } from "./index6.js";
|
|
3
|
+
import { discountFromDraft as s } from "./index11.js";
|
|
9
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
comment: ""
|
|
21
|
-
};
|
|
22
|
-
function w() {
|
|
23
|
-
return {
|
|
24
|
-
type: "invoice",
|
|
25
|
-
customerId: "",
|
|
26
|
-
currency: "USD",
|
|
27
|
-
issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
28
|
-
dueDate: "",
|
|
29
|
-
openingNote: "",
|
|
30
|
-
closingNote: "",
|
|
31
|
-
paymentTermsId: "",
|
|
32
|
-
paymentTermsCustomDate: "",
|
|
33
|
-
taxRate: "",
|
|
34
|
-
..._("USD"),
|
|
35
|
-
lineItems: [n()],
|
|
36
|
-
bankAccountId: "",
|
|
37
|
-
bankAccountType: "",
|
|
38
|
-
paymentReminderId: "",
|
|
39
|
-
overdueReminderId: "",
|
|
40
|
-
attachments: [],
|
|
41
|
-
...p()
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function T(e) {
|
|
45
|
-
return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
|
|
46
|
-
}
|
|
47
|
-
function E(e) {
|
|
48
|
-
return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
|
|
49
|
-
}
|
|
50
|
-
function D(e) {
|
|
51
|
-
return (e?.length ? e : [
|
|
52
|
-
"invoices",
|
|
53
|
-
"quotes",
|
|
54
|
-
"credit_notes"
|
|
55
|
-
]).filter((e, t, n) => [
|
|
56
|
-
"invoices",
|
|
57
|
-
"quotes",
|
|
58
|
-
"credit_notes"
|
|
59
|
-
].includes(e) && n.indexOf(e) === t);
|
|
60
|
-
}
|
|
61
|
-
function O({ defaultTab: e, enabledTabs: t }) {
|
|
62
|
-
return e && t.includes(e) ? e : t[0] ?? "invoices";
|
|
63
|
-
}
|
|
64
|
-
function k(e, n) {
|
|
65
|
-
let r = t(e);
|
|
66
|
-
return r ? new Intl.DateTimeFormat(void 0, {
|
|
67
|
-
day: "numeric",
|
|
68
|
-
month: "short",
|
|
69
|
-
year: "numeric"
|
|
70
|
-
}).format(r) : n;
|
|
71
|
-
}
|
|
72
|
-
function A({ amount: t, currency: n, fallback: r }) {
|
|
73
|
-
return t == null || !n ? r : new Intl.NumberFormat(void 0, {
|
|
74
|
-
currency: n,
|
|
75
|
-
style: "currency"
|
|
76
|
-
}).format(t / 10 ** e(n));
|
|
77
|
-
}
|
|
78
|
-
function j(t, n) {
|
|
79
|
-
let r = Number(t);
|
|
80
|
-
if (!Number.isFinite(r)) return;
|
|
81
|
-
let i = n ? e(n) : 2;
|
|
82
|
-
return Math.round(r * 10 ** i);
|
|
83
|
-
}
|
|
84
|
-
function M(e, t) {
|
|
85
|
-
return e.document_id || t.untitledDocument;
|
|
86
|
-
}
|
|
87
|
-
function N(e, t) {
|
|
88
|
-
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
89
|
-
}
|
|
90
|
-
function P(e) {
|
|
91
|
-
return e === "paid" || e === "accepted" || e === "issued" || e === "recurring" ? "success" : e === "draft" || e === "issuing" ? "neutral" : e === "overdue" || e === "partially_paid" ? "warning" : e === "failed" || e === "declined" || e === "expired" || e === "uncollectible" || e === "canceled" || e === "deleted" ? "danger" : "info";
|
|
92
|
-
}
|
|
93
|
-
function F(e) {
|
|
94
|
-
let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
|
|
95
|
-
"issued",
|
|
96
|
-
"overdue",
|
|
97
|
-
"partially_paid"
|
|
98
|
-
].includes(e.status);
|
|
5
|
+
var c = 1e4;
|
|
6
|
+
function l(e, t) {
|
|
7
|
+
return Math.round(o(e.price, t) * a(e.quantity));
|
|
8
|
+
}
|
|
9
|
+
function u({ lineItems: e, currency: t, taxRate: n }) {
|
|
10
|
+
let r = n ? Math.round(n * 100) : 0, i = 0, a = 0;
|
|
11
|
+
for (let n of e) {
|
|
12
|
+
let e = l(n, t);
|
|
13
|
+
n.taxable ? i += e : a += e;
|
|
14
|
+
}
|
|
99
15
|
return {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"canceled",
|
|
105
|
-
"deleted",
|
|
106
|
-
"uncollectible"
|
|
107
|
-
].includes(e.status) && !t,
|
|
108
|
-
clone: !a && e.status !== "deleted",
|
|
109
|
-
decline: i && n,
|
|
110
|
-
delete: t,
|
|
111
|
-
issue: t,
|
|
112
|
-
markPaid: o,
|
|
113
|
-
markUncollectible: o,
|
|
114
|
-
recordPayment: o,
|
|
115
|
-
send: [
|
|
116
|
-
"issued",
|
|
117
|
-
"accepted",
|
|
118
|
-
"overdue",
|
|
119
|
-
"partially_paid"
|
|
120
|
-
].includes(e.status) && !a
|
|
16
|
+
taxableItemsSubtotal: i,
|
|
17
|
+
nonTaxableItemsSubtotal: a,
|
|
18
|
+
subtotal: i + a,
|
|
19
|
+
rateMinorUnits: r
|
|
121
20
|
};
|
|
122
21
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
id: e.id,
|
|
128
|
-
type: e.type,
|
|
129
|
-
documentLabel: M(e, t),
|
|
130
|
-
customerLabel: e.counterpart_name || t.unknownCustomer,
|
|
131
|
-
status: e.status,
|
|
132
|
-
statusTone: P(e.status),
|
|
133
|
-
issueDateLabel: k(e.issue_date, t.notAvailable),
|
|
134
|
-
dueDateLabel: k(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
|
|
135
|
-
totalLabel: A({
|
|
136
|
-
amount: e.total_amount,
|
|
137
|
-
currency: e.currency,
|
|
138
|
-
fallback: t.notAvailable
|
|
139
|
-
}),
|
|
140
|
-
amountDueLabel: A({
|
|
141
|
-
amount: n,
|
|
142
|
-
currency: e.currency,
|
|
143
|
-
fallback: t.notAvailable
|
|
144
|
-
}),
|
|
145
|
-
actions: F(e)
|
|
146
|
-
};
|
|
147
|
-
});
|
|
22
|
+
function d({ discount: e, subtotal: t }) {
|
|
23
|
+
if (!e) return 0;
|
|
24
|
+
let n = e.value ?? (e.type === "amount" ? e.amount : Math.round(t * e.amount / 1e4));
|
|
25
|
+
return Math.min(Math.max(n, 0), t);
|
|
148
26
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
|
|
27
|
+
function f({ taxableItemsSubtotal: e, nonTaxableItemsSubtotal: t, discountAmount: n }) {
|
|
28
|
+
let r = e + t, i = r > 0 ? Math.round(e / r * n) : 0;
|
|
152
29
|
return {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
title: M(e, i),
|
|
156
|
-
customerLabel: e.counterpart_name || i.unknownCustomer,
|
|
157
|
-
status: e.status,
|
|
158
|
-
statusTone: P(e.status),
|
|
159
|
-
totalLabel: A({
|
|
160
|
-
amount: e.total_amount,
|
|
161
|
-
currency: e.currency,
|
|
162
|
-
fallback: i.notAvailable
|
|
163
|
-
}),
|
|
164
|
-
amountDueLabel: A({
|
|
165
|
-
amount: a,
|
|
166
|
-
currency: e.currency,
|
|
167
|
-
fallback: i.notAvailable
|
|
168
|
-
}),
|
|
169
|
-
pdfUrl: r || e.file_url || e.original_file_url || void 0,
|
|
170
|
-
summaryItems: [
|
|
171
|
-
{
|
|
172
|
-
label: i.summaryDocumentType,
|
|
173
|
-
value: N(e.type, i)
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
label: i.summaryDocumentNumber,
|
|
177
|
-
value: M(e, i)
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
label: i.summaryCustomer,
|
|
181
|
-
value: e.counterpart_name || i.unknownCustomer
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
label: i.summaryIssued,
|
|
185
|
-
value: k(e.issue_date, i.notAvailable)
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
label: i.summaryDue,
|
|
189
|
-
value: k(o, i.notAvailable)
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
label: i.summaryCreated,
|
|
193
|
-
value: k(e.created_at, i.notAvailable)
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
label: i.summaryUpdated,
|
|
197
|
-
value: k(e.updated_at, i.notAvailable)
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
label: i.summaryTotal,
|
|
201
|
-
value: A({
|
|
202
|
-
amount: e.total_amount,
|
|
203
|
-
currency: e.currency,
|
|
204
|
-
fallback: i.notAvailable
|
|
205
|
-
})
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
label: i.summaryAmountDue,
|
|
209
|
-
value: A({
|
|
210
|
-
amount: a,
|
|
211
|
-
currency: e.currency,
|
|
212
|
-
fallback: i.notAvailable
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
],
|
|
216
|
-
lineItems: e.line_items.map((t, n) => ({
|
|
217
|
-
id: t.product.id || String(n),
|
|
218
|
-
name: t.product.name,
|
|
219
|
-
quantityLabel: String(t.quantity),
|
|
220
|
-
unitPriceLabel: A({
|
|
221
|
-
amount: t.product.price?.value,
|
|
222
|
-
currency: t.product.price?.currency || e.currency,
|
|
223
|
-
fallback: i.notAvailable
|
|
224
|
-
}),
|
|
225
|
-
totalLabel: A({
|
|
226
|
-
amount: t.total_after_tax ?? t.total_before_tax,
|
|
227
|
-
currency: e.currency,
|
|
228
|
-
fallback: i.notAvailable
|
|
229
|
-
})
|
|
230
|
-
})),
|
|
231
|
-
activityItems: t.map((e) => ({
|
|
232
|
-
id: e.id,
|
|
233
|
-
title: R(e.event_type, i),
|
|
234
|
-
description: e.event_type,
|
|
235
|
-
timestampLabel: k(e.timestamp, i.notAvailable)
|
|
236
|
-
})),
|
|
237
|
-
mailItems: n.map((e) => ({
|
|
238
|
-
id: e.id,
|
|
239
|
-
statusLabel: e.status,
|
|
240
|
-
recipientsLabel: z(e, i),
|
|
241
|
-
sentAtLabel: k(e.created_at, i.notAvailable)
|
|
242
|
-
})),
|
|
243
|
-
actions: F(e)
|
|
30
|
+
taxableSubtotal: e - i,
|
|
31
|
+
nonTaxableSubtotal: t - (n - i)
|
|
244
32
|
};
|
|
245
33
|
}
|
|
246
|
-
function
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
]
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
})
|
|
279
|
-
}
|
|
280
|
-
function U({ bankAccountId: e, bankAccountType: t }) {
|
|
34
|
+
function p({ lineItems: e, currency: t, rateMinorUnits: n, keepSavedRate: i, taxableItemsSubtotal: a, taxableSubtotal: o }) {
|
|
35
|
+
if (a <= 0) return 0;
|
|
36
|
+
let s = /* @__PURE__ */ new Map();
|
|
37
|
+
for (let a of e) {
|
|
38
|
+
if (!a.taxable) continue;
|
|
39
|
+
let e = r(a, n, i);
|
|
40
|
+
s.set(e, (s.get(e) ?? 0) + l(a, t));
|
|
41
|
+
}
|
|
42
|
+
let u = [...s], d = o, f = 0;
|
|
43
|
+
return u.forEach(([e, t], n) => {
|
|
44
|
+
let r = n === u.length - 1 ? d : Math.round(o * t / a);
|
|
45
|
+
d -= r, f += r * e;
|
|
46
|
+
}), Math.round(f / c);
|
|
47
|
+
}
|
|
48
|
+
function m({ lineItems: e, currency: t, taxRate: n, keepSavedRate: r = !1, discount: i }) {
|
|
49
|
+
let a = u({
|
|
50
|
+
lineItems: e,
|
|
51
|
+
currency: t,
|
|
52
|
+
taxRate: n
|
|
53
|
+
}), o = d({
|
|
54
|
+
discount: i,
|
|
55
|
+
subtotal: a.subtotal
|
|
56
|
+
}), { taxableSubtotal: s, nonTaxableSubtotal: c } = f({
|
|
57
|
+
...a,
|
|
58
|
+
discountAmount: o
|
|
59
|
+
}), l = p({
|
|
60
|
+
lineItems: e,
|
|
61
|
+
currency: t,
|
|
62
|
+
rateMinorUnits: a.rateMinorUnits,
|
|
63
|
+
keepSavedRate: r,
|
|
64
|
+
taxableItemsSubtotal: a.taxableItemsSubtotal,
|
|
65
|
+
taxableSubtotal: s
|
|
66
|
+
}), m = a.subtotal - o;
|
|
281
67
|
return {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
currency: e.currency,
|
|
290
|
-
taxRate: e.taxRate,
|
|
291
|
-
unitNamesById: n
|
|
292
|
-
})), o = {
|
|
293
|
-
counterpart_billing_address_id: t,
|
|
294
|
-
counterpart_id: e.customerId,
|
|
295
|
-
currency: e.currency,
|
|
296
|
-
line_items: i,
|
|
297
|
-
memo: e.openingNote,
|
|
298
|
-
footer: e.closingNote,
|
|
299
|
-
discount: v(e) ?? void 0,
|
|
300
|
-
...U(e)
|
|
301
|
-
};
|
|
302
|
-
return e.type === "quote" ? {
|
|
303
|
-
...o,
|
|
304
|
-
expiry_date: e.dueDate || void 0,
|
|
305
|
-
type: "quote"
|
|
306
|
-
} : {
|
|
307
|
-
...o,
|
|
308
|
-
...m(e),
|
|
309
|
-
payment_reminder_id: e.paymentReminderId || void 0,
|
|
310
|
-
overdue_reminder_id: e.overdueReminderId || void 0,
|
|
311
|
-
attachments: d(e.attachments),
|
|
312
|
-
type: "invoice"
|
|
68
|
+
...a,
|
|
69
|
+
discountAmount: o,
|
|
70
|
+
discountedSubtotal: m,
|
|
71
|
+
taxableSubtotal: s,
|
|
72
|
+
nonTaxableSubtotal: c,
|
|
73
|
+
totalTaxes: l,
|
|
74
|
+
total: m + l
|
|
313
75
|
};
|
|
314
76
|
}
|
|
315
|
-
function
|
|
316
|
-
|
|
317
|
-
|
|
77
|
+
function h(e) {
|
|
78
|
+
return m({
|
|
79
|
+
lineItems: e.lineItems.filter((e) => !t(e)),
|
|
318
80
|
currency: e.currency,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
type: r,
|
|
324
|
-
customerId: e.counterpart_id,
|
|
325
|
-
currency: e.currency,
|
|
326
|
-
issueDate: X(e.issue_date),
|
|
327
|
-
dueDate: e.type === "quote" ? X(e.expiry_date) : "",
|
|
328
|
-
openingNote: e.memo ?? "",
|
|
329
|
-
closingNote: e.footer ?? "",
|
|
330
|
-
...e.type === "invoice" ? g(e.payment_terms) : {},
|
|
331
|
-
taxRate: i,
|
|
332
|
-
savedTaxRate: i,
|
|
333
|
-
...y(e.discount, e.currency),
|
|
334
|
-
lineItems: o.length > 0 ? o : [n(e.currency)],
|
|
335
|
-
bankAccountId: e.bank_account_id ?? "",
|
|
336
|
-
bankAccountType: K(e.bank_account_type),
|
|
337
|
-
paymentReminderId: a?.payment_reminder_id ?? "",
|
|
338
|
-
overdueReminderId: a?.overdue_reminder_id ?? "",
|
|
339
|
-
attachments: f(e)
|
|
340
|
-
};
|
|
81
|
+
taxRate: Number(e.taxRate) || void 0,
|
|
82
|
+
keepSavedRate: n(e.taxRate, e.savedTaxRate),
|
|
83
|
+
discount: s(e)
|
|
84
|
+
});
|
|
341
85
|
}
|
|
342
|
-
function
|
|
343
|
-
|
|
86
|
+
function g(e, t) {
|
|
87
|
+
let n = s(e);
|
|
88
|
+
if (n) return n.type === "percentage" ? n.amount > 1e4 ? t.discountPercentageTooHigh : void 0 : n.amount > h(e).subtotal ? t.discountExceedsSubtotal : void 0;
|
|
344
89
|
}
|
|
345
|
-
function
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
issue_date: e.issueDate || void 0,
|
|
351
|
-
memo: e.openingNote,
|
|
352
|
-
footer: e.closingNote,
|
|
353
|
-
discount: v(e),
|
|
354
|
-
...U(e)
|
|
355
|
-
};
|
|
356
|
-
return e.type === "quote" ? { quote: {
|
|
357
|
-
...r,
|
|
358
|
-
...n ? { line_items: n } : {},
|
|
359
|
-
expiry_date: e.dueDate || void 0,
|
|
360
|
-
...h(e)
|
|
361
|
-
} } : { invoice: {
|
|
362
|
-
...r,
|
|
363
|
-
...n ? { line_items: n } : {},
|
|
364
|
-
...h(e),
|
|
365
|
-
payment_reminder_id: e.paymentReminderId || null,
|
|
366
|
-
overdue_reminder_id: e.overdueReminderId || null,
|
|
367
|
-
attachments: d(e.attachments) ?? null
|
|
368
|
-
} };
|
|
90
|
+
function _(e, n) {
|
|
91
|
+
if (e.lineItems.filter((e) => !t(e)).some((t) => o(t.price, e.currency) > 9e15)) return;
|
|
92
|
+
let { subtotal: r, total: a } = h(e), s = i(e.currency);
|
|
93
|
+
if (r > 9e15) return n.invoiceSubtotalTooHigh.replace("{maxAmount}", s);
|
|
94
|
+
if (a > 9e15) return n.invoiceTotalTooHigh.replace("{maxAmount}", s);
|
|
369
95
|
}
|
|
370
|
-
function
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
currency: t,
|
|
374
|
-
taxRate: n,
|
|
375
|
-
keepSavedRate: d,
|
|
376
|
-
unitNamesById: a
|
|
377
|
-
}), p = new Map(t.map((e) => [e.id, JSON.stringify(f(s({
|
|
378
|
-
lineItem: e,
|
|
96
|
+
function v(t, n, r) {
|
|
97
|
+
return new Intl.NumberFormat(void 0, {
|
|
98
|
+
style: "currency",
|
|
379
99
|
currency: n,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
if (n === void 0) return [];
|
|
384
|
-
let r = f(t, e.currency, e.taxRate);
|
|
385
|
-
return n === JSON.stringify(r) ? [] : [{
|
|
386
|
-
id: t.id,
|
|
387
|
-
data: r
|
|
388
|
-
}];
|
|
389
|
-
}), v = t.filter((e) => !h.has(e.id)).map((e) => e.id);
|
|
390
|
-
if (g.length || _.length || v.length) return {
|
|
391
|
-
...g.length ? { add: g } : {},
|
|
392
|
-
..._.length ? { replace: _ } : {},
|
|
393
|
-
...v.length ? { remove: v } : {}
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
function Y({ values: e, originalLineItems: t, changes: n }) {
|
|
397
|
-
let i = e.lineItems.filter((e) => !r(e)).map((e) => e.id);
|
|
398
|
-
if (!t) return { created: i };
|
|
399
|
-
let a = new Set(t.map((e) => e.id));
|
|
400
|
-
return {
|
|
401
|
-
added: i.filter((e) => !a.has(e)),
|
|
402
|
-
replaced: n?.replace?.map((e) => e.id) ?? []
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
function X(e) {
|
|
406
|
-
return e?.slice(0, 10) ?? "";
|
|
407
|
-
}
|
|
408
|
-
function Z(e, t) {
|
|
409
|
-
let n = {};
|
|
410
|
-
return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
|
|
411
|
-
}
|
|
412
|
-
function Q(e) {
|
|
413
|
-
return Object.keys(e).length > 0;
|
|
414
|
-
}
|
|
415
|
-
function $(e) {
|
|
416
|
-
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
417
|
-
}
|
|
418
|
-
function ee(e, t, n) {
|
|
419
|
-
let r = {};
|
|
420
|
-
if (e.mode === "partial") {
|
|
421
|
-
let i = j(e.amountPaid, n);
|
|
422
|
-
(!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
|
|
423
|
-
}
|
|
424
|
-
return r;
|
|
425
|
-
}
|
|
426
|
-
function te(e) {
|
|
427
|
-
return Object.keys(e).length > 0;
|
|
428
|
-
}
|
|
429
|
-
function ne(e, t) {
|
|
430
|
-
return {
|
|
431
|
-
...S,
|
|
432
|
-
to: e?.counterpart_contact?.email ?? "",
|
|
433
|
-
subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
|
|
434
|
-
body: t.sendBodyDefault
|
|
435
|
-
};
|
|
100
|
+
currencyDisplay: "narrowSymbol",
|
|
101
|
+
currencySign: r
|
|
102
|
+
}).format(t / 10 ** e(n));
|
|
436
103
|
}
|
|
437
|
-
function
|
|
104
|
+
function y(e, t) {
|
|
438
105
|
return {
|
|
439
|
-
|
|
440
|
-
|
|
106
|
+
subtotal: v(e.subtotal, t),
|
|
107
|
+
discount: e.discountAmount > 0 ? v(-e.discountAmount, t, "accounting") : v(0, t),
|
|
108
|
+
nonTaxableSubtotal: v(e.nonTaxableSubtotal, t),
|
|
109
|
+
taxableSubtotal: v(e.taxableSubtotal, t),
|
|
110
|
+
tax: v(e.totalTaxes, t),
|
|
111
|
+
total: v(e.total, t)
|
|
441
112
|
};
|
|
442
113
|
}
|
|
443
|
-
function ie(e = "all") {
|
|
444
|
-
let t = [
|
|
445
|
-
"draft",
|
|
446
|
-
"issued",
|
|
447
|
-
"failed",
|
|
448
|
-
"accepted",
|
|
449
|
-
"expired",
|
|
450
|
-
"declined",
|
|
451
|
-
"recurring",
|
|
452
|
-
"partially_paid",
|
|
453
|
-
"paid",
|
|
454
|
-
"overdue",
|
|
455
|
-
"uncollectible",
|
|
456
|
-
"canceled"
|
|
457
|
-
];
|
|
458
|
-
return e !== "all" && !t.includes(e) && t.push(e), t.map((e) => ({
|
|
459
|
-
value: e,
|
|
460
|
-
label: e.split("_").map((e) => `${e.slice(0, 1).toUpperCase()}${e.slice(1)}`).join(" ")
|
|
461
|
-
}));
|
|
462
|
-
}
|
|
463
114
|
//#endregion
|
|
464
|
-
export {
|
|
115
|
+
export { c as FULL_PERCENT_MINOR_UNITS, f as allocateDiscount, y as buildFormTotalsView, h as calculateFormTotals, m as calculateInvoiceTotals, u as calculateItemsSubtotals, d as resolveDiscountAmount, g as validateDiscount, _ as validateInvoiceTotals };
|