@tesouro/embedded-components-react 0.5.298 → 0.5.300
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/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +6 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/labels.js +10 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js +333 -156
- package/dist/libs/tesouro-embedded-components-react/shared/data-access-mocks/dist/mocks/scenarios/worlds.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -27,11 +27,16 @@ function m({ initialCounterpartId: m, messages: g, statusLabels: _, filterLabels
|
|
|
27
27
|
labels: v
|
|
28
28
|
});
|
|
29
29
|
l(() => {
|
|
30
|
+
if (O === A) return;
|
|
30
31
|
let e = setTimeout(() => {
|
|
31
32
|
j(O), M();
|
|
32
33
|
}, 300);
|
|
33
34
|
return () => clearTimeout(e);
|
|
34
|
-
}, [
|
|
35
|
+
}, [
|
|
36
|
+
A,
|
|
37
|
+
M,
|
|
38
|
+
O
|
|
39
|
+
]);
|
|
35
40
|
let P = S[0]?.id, F = P ? h[P] : void 0, I = S[0] ? S[0].desc ? "desc" : "asc" : void 0, L = e({
|
|
36
41
|
enabled: b,
|
|
37
42
|
type: "invoice",
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/labels.js
CHANGED
|
@@ -28,10 +28,16 @@ var e = { scenarios: {
|
|
|
28
28
|
error: "The invoices read fails with a 500, so the table shows Failed to load receivables. Try again re-issues the read, which fails again.",
|
|
29
29
|
paginated: "Sixteen invoices at ten a page. The next and previous arrows follow the pagination token; a search, status filter or new page size starts again from page one."
|
|
30
30
|
},
|
|
31
|
-
scenarios: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
scenarios: {
|
|
32
|
+
"no-customers": {
|
|
33
|
+
label: "No customers yet",
|
|
34
|
+
blurb: "No invoices and no customers. Press Create, open the Customer picker and choose to create one, give it a name, email and address, and it is selected for the invoice; add an item and create."
|
|
35
|
+
},
|
|
36
|
+
"writes-failing": {
|
|
37
|
+
label: "Actions fail",
|
|
38
|
+
blurb: "The same eight invoices, but the API refuses to issue, send, record a payment or cancel, each with its own reason. Every other write still works, so a draft saved on the way to issuing is kept."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
35
41
|
};
|
|
36
42
|
//#endregion
|
|
37
43
|
export { e as INVOICING_LABELS, t as RECEIVABLES_LABELS };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Scope as e } from "../../../../shared/data-access/dist/lib/scopes.js";
|
|
2
2
|
import "../../../../shared/data-access/dist/index.js";
|
|
3
3
|
import { AN_EXTERNAL_BANK_ACCOUNT as t, AN_OUTSTANDING_INVOICE as n, A_BANK_ACCOUNT as r } from "../../../../shared/data-access-mocks/dist/lib/fixtures.js";
|
|
4
|
-
import { AN_ENTITY_BANK_ACCOUNT as i, AN_OVERDUE_REMINDER as a, A_FILE as o,
|
|
5
|
-
import { RECEIVABLES_LABELS as
|
|
6
|
-
import { SCENARIO_LABELS as
|
|
7
|
-
import { EMBEDDED_PAGING as
|
|
8
|
-
import { MintKind as
|
|
9
|
-
import { CUSTOMERS as D, CUSTOMER_ADDRESSES as
|
|
4
|
+
import { AN_ENTITY_BANK_ACCOUNT as i, AN_OVERDUE_REMINDER as a, A_FILE as o, A_PAYMENT_RECORD as s, A_PAYMENT_REMINDER as c, A_PAYMENT_TERMS as l, A_RECEIVABLE_HISTORY_ENTRY as u, A_RECEIVABLE_MAIL as d } from "./fixtures.js";
|
|
5
|
+
import { RECEIVABLES_LABELS as f } from "./labels.js";
|
|
6
|
+
import { SCENARIO_LABELS as p } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/labels.js";
|
|
7
|
+
import { EMBEDDED_PAGING as m, FINOPS as h, PROXY as g, bodyOf as _, endpoint as v, initRoute as y, json as b, noContent as x, problem as S } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/scenario.js";
|
|
8
|
+
import { MintKind as C, finopsOffsetPage as w, listOverride as ee, minter as T, notFound as E } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/worlds.js";
|
|
9
|
+
import { CUSTOMERS as D, CUSTOMER_ADDRESSES as te, CUSTOMER_INVOICES as O, billTo as ne, customerRoutes as re, customerWorld as ie, filterInvoices as ae, id as k, invoice as A, lineItem as j } from "../../../../counterparts-widget/feature/dist/mocks/counterparts.js";
|
|
10
10
|
import "../../../../counterparts-widget/feature/dist/scenarios.js";
|
|
11
|
-
import { productRoutes as
|
|
11
|
+
import { productRoutes as oe, productWorld as se } from "../../../../products-widget/feature/dist/mocks/products.js";
|
|
12
12
|
import "../../../../products-widget/feature/dist/scenarios.js";
|
|
13
13
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js
|
|
14
|
-
var
|
|
14
|
+
var M = [
|
|
15
15
|
e.InvoiceReadOrg,
|
|
16
16
|
e.InvoiceWriteOrg,
|
|
17
17
|
e.CounterpartReadOrg,
|
|
@@ -22,16 +22,16 @@ var L = [
|
|
|
22
22
|
e.BankAccountWriteOrg,
|
|
23
23
|
e.ExternalBankAccountReadOrg,
|
|
24
24
|
e.PaymentRecordWriteOrg
|
|
25
|
-
],
|
|
26
|
-
...
|
|
27
|
-
id:
|
|
28
|
-
},
|
|
29
|
-
...
|
|
30
|
-
id:
|
|
25
|
+
], N = {
|
|
26
|
+
...l,
|
|
27
|
+
id: k(350)
|
|
28
|
+
}, P = [{
|
|
29
|
+
...N,
|
|
30
|
+
id: k(351),
|
|
31
31
|
name: "Net 15",
|
|
32
32
|
description: "Payment due 15 days after the issue date.",
|
|
33
33
|
term_final: { number_of_days: 15 }
|
|
34
|
-
},
|
|
34
|
+
}, N], F = [
|
|
35
35
|
"Copywriting",
|
|
36
36
|
"Photo retouching",
|
|
37
37
|
"Event staffing",
|
|
@@ -42,7 +42,7 @@ var L = [
|
|
|
42
42
|
"Signage install"
|
|
43
43
|
].map((e, t) => {
|
|
44
44
|
let n = D[t % D.length];
|
|
45
|
-
return
|
|
45
|
+
return A(352 + t, n, [j(352 + t, e, 4 + t, 8e3, "hour")], {
|
|
46
46
|
document_id: `INV-10${String(10 + t)}`,
|
|
47
47
|
status: "paid",
|
|
48
48
|
amount_paid: (4 + t) * 8e3,
|
|
@@ -50,31 +50,90 @@ var L = [
|
|
|
50
50
|
due_date: `2026-04-${String(2 + t * 3).padStart(2, "0")}`,
|
|
51
51
|
created_at: `2026-03-${String(2 + t * 3).padStart(2, "0")}T09:00:00.000Z`
|
|
52
52
|
});
|
|
53
|
-
}),
|
|
53
|
+
}), I = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), L = (e, t) => {
|
|
54
54
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
55
55
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
56
|
+
}, R = 12, z = {
|
|
57
|
+
month: 1,
|
|
58
|
+
quarter: 3,
|
|
59
|
+
year: 12
|
|
60
|
+
}, B = {
|
|
61
|
+
day: 1,
|
|
62
|
+
week: 7
|
|
56
63
|
};
|
|
57
|
-
function
|
|
64
|
+
function V(e, t, n) {
|
|
65
|
+
let r = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`), i = z[t];
|
|
66
|
+
if (!i) return r.setUTCDate(r.getUTCDate() + (B[t] ?? 1) * n), r.toISOString().slice(0, 10);
|
|
67
|
+
let a = r.getUTCFullYear(), o = r.getUTCMonth() + i * n, s = new Date(Date.UTC(a, o + 1, 0)).getUTCDate();
|
|
68
|
+
return new Date(Date.UTC(a, o, Math.min(r.getUTCDate(), s))).toISOString().slice(0, 10);
|
|
69
|
+
}
|
|
70
|
+
function H(e) {
|
|
71
|
+
let { start_date: t, frequency: n, interval: r, max_occurrences: i, end_date: a } = e, o = i ?? (a ? Infinity : R), s = [];
|
|
72
|
+
for (let e = 0; e < o; e += 1) {
|
|
73
|
+
let i = V(t, n, e * r);
|
|
74
|
+
if (a && i > a) break;
|
|
75
|
+
s.push({
|
|
76
|
+
iteration: e + 1,
|
|
77
|
+
issue_at: i,
|
|
78
|
+
issued_invoice_id: null,
|
|
79
|
+
status: "pending"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return s;
|
|
83
|
+
}
|
|
84
|
+
function ce(e, t) {
|
|
58
85
|
return e.flatMap((e) => {
|
|
59
86
|
let n = {
|
|
60
|
-
...
|
|
61
|
-
id: t(
|
|
87
|
+
...u,
|
|
88
|
+
id: t(C.HistoryEvent),
|
|
62
89
|
receivable_id: e.id,
|
|
63
90
|
timestamp: e.created_at
|
|
64
91
|
};
|
|
65
|
-
return e.status === "draft" ? [n] : [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
92
|
+
return e.status === "draft" ? [n] : [
|
|
93
|
+
n,
|
|
94
|
+
{
|
|
95
|
+
...n,
|
|
96
|
+
id: t(C.HistoryEvent),
|
|
97
|
+
event_type: "status_changed",
|
|
98
|
+
event_data: {
|
|
99
|
+
old_status: "draft",
|
|
100
|
+
new_status: e.status
|
|
101
|
+
},
|
|
102
|
+
timestamp: e.updated_at
|
|
72
103
|
},
|
|
73
|
-
|
|
74
|
-
|
|
104
|
+
{
|
|
105
|
+
...n,
|
|
106
|
+
id: t(C.HistoryEvent),
|
|
107
|
+
event_type: "mail_sent",
|
|
108
|
+
event_data: { mail_status: "sent" },
|
|
109
|
+
timestamp: e.updated_at
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function le(e, t) {
|
|
115
|
+
return e.filter((e) => e.amount_paid > 0).map((e) => {
|
|
116
|
+
let n = e.paid_at ?? e.updated_at;
|
|
117
|
+
return {
|
|
118
|
+
...s,
|
|
119
|
+
id: t(C.PaymentRecord),
|
|
120
|
+
amount: e.amount_paid,
|
|
121
|
+
currency: e.currency,
|
|
122
|
+
paid_at: n,
|
|
123
|
+
history: [{
|
|
124
|
+
status: "succeeded",
|
|
125
|
+
timestamp: n
|
|
126
|
+
}],
|
|
127
|
+
object: {
|
|
128
|
+
id: e.id,
|
|
129
|
+
type: "receivable",
|
|
130
|
+
old_status: "issued",
|
|
131
|
+
new_status: e.status
|
|
132
|
+
}
|
|
133
|
+
};
|
|
75
134
|
});
|
|
76
135
|
}
|
|
77
|
-
function
|
|
136
|
+
function U(e) {
|
|
78
137
|
let t = e.line_items.filter((e) => e.tax_status === "taxable"), n = (e) => e.reduce((e, t) => e + t.total_before_tax, 0), r = n(e.line_items), i = n(t), a = e.discount, o = a ? Math.min(r, a.type === "amount" ? a.amount : Math.round(r * a.amount / 1e4)) : 0, s = i - (r > 0 ? Math.round(i / r * o) : 0), c = t.reduce((e, t) => e + t.total_before_tax * (t.product.tax_rate?.value ?? 0), 0), l = a ? i > 0 ? Math.round(c * s / i / 1e4) : 0 : e.line_items.reduce((e, t) => e + t.total_after_tax - t.total_before_tax, 0), u = r - o + l;
|
|
79
138
|
return {
|
|
80
139
|
...e,
|
|
@@ -90,24 +149,24 @@ function W(e) {
|
|
|
90
149
|
amount_due: Math.max(0, u - e.amount_paid)
|
|
91
150
|
};
|
|
92
151
|
}
|
|
93
|
-
function
|
|
152
|
+
function W(e, t, n) {
|
|
94
153
|
return {
|
|
95
|
-
...
|
|
154
|
+
...j(n ?? e.mint(C.LineItem), t.product?.name ?? "", t.quantity ?? 1, t.product?.price?.value ?? 0, t.product?.measure_unit?.name, t.tax_rate_value ?? 0),
|
|
96
155
|
...t.tax_status ? { tax_status: t.tax_status } : {},
|
|
97
156
|
...t.discount ? { discount: t.discount } : {}
|
|
98
157
|
};
|
|
99
158
|
}
|
|
100
|
-
function
|
|
101
|
-
let t =
|
|
159
|
+
function G(e) {
|
|
160
|
+
let t = P.find((t) => t.id === e.payment_terms_id);
|
|
102
161
|
if (t) return t;
|
|
103
162
|
if (e.payment_terms?.term_final) return { term_final: e.payment_terms.term_final };
|
|
104
163
|
if (e.payment_terms_id === null || e.payment_terms === null) return null;
|
|
105
164
|
}
|
|
106
|
-
function
|
|
107
|
-
let n =
|
|
108
|
-
return n?.end_date ? n.end_date : n?.number_of_days !== void 0 && n.number_of_days !== null ?
|
|
165
|
+
function K(e, t) {
|
|
166
|
+
let n = G(e)?.term_final;
|
|
167
|
+
return n?.end_date ? n.end_date : n?.number_of_days !== void 0 && n.number_of_days !== null ? L(t, n.number_of_days) : e.due_date ?? null;
|
|
109
168
|
}
|
|
110
|
-
function
|
|
169
|
+
function q(e, t) {
|
|
111
170
|
return (t ?? []).flatMap((t) => {
|
|
112
171
|
let n = e.files.find((e) => e.id === t.id);
|
|
113
172
|
return n ? [{
|
|
@@ -116,71 +175,117 @@ function J(e, t) {
|
|
|
116
175
|
}] : [];
|
|
117
176
|
});
|
|
118
177
|
}
|
|
119
|
-
var
|
|
178
|
+
var J = `${h}/receivables`, ue = `${h}/analytics/receivables`, Y = {
|
|
179
|
+
issue: "The customer has no billing address on file.",
|
|
180
|
+
send: "The mail server rejected the message.",
|
|
181
|
+
payment: "The payment date falls in a closed accounting period.",
|
|
182
|
+
cancel: "The invoice has a payment in progress."
|
|
183
|
+
};
|
|
184
|
+
function de() {
|
|
185
|
+
let e = (e) => () => S(422, "Unprocessable Entity", e);
|
|
186
|
+
return [
|
|
187
|
+
v("POST", `${J}/:id/issue`, e(Y.issue)),
|
|
188
|
+
v("POST", `${J}/:id/send`, e(Y.send)),
|
|
189
|
+
v("POST", `${h}/payment-records`, e(Y.payment)),
|
|
190
|
+
v("POST", `${J}/:id/cancel`, e(Y.cancel))
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
function fe(e, t) {
|
|
194
|
+
let n = t.get("type"), r = t.getAll("status__in"), i = t.get("aggregation_function") === "count", a = /* @__PURE__ */ new Map();
|
|
195
|
+
for (let t of e) {
|
|
196
|
+
if (n && t.type !== n || r.length && !r.includes(t.status)) continue;
|
|
197
|
+
let e = i ? 1 : t.total_amount ?? 0;
|
|
198
|
+
a.set(t.status, (a.get(t.status) ?? 0) + e);
|
|
199
|
+
}
|
|
200
|
+
return { data: [...a].map(([e, t]) => ({
|
|
201
|
+
dimension_value: e,
|
|
202
|
+
metric_value: t
|
|
203
|
+
})) };
|
|
204
|
+
}
|
|
120
205
|
function X(e) {
|
|
121
|
-
let t =
|
|
206
|
+
let t = _(e);
|
|
122
207
|
return {
|
|
123
208
|
paid_at: t.paid_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
124
209
|
...t.comment ? { comment: t.comment } : {},
|
|
125
210
|
...t.is_external == null ? {} : { is_external: t.is_external }
|
|
126
211
|
};
|
|
127
212
|
}
|
|
128
|
-
function Z({ invoices: e =
|
|
129
|
-
let
|
|
213
|
+
function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
214
|
+
let y = T(), k = {
|
|
130
215
|
invoices: [...e],
|
|
131
|
-
history:
|
|
216
|
+
history: ce(e, y),
|
|
132
217
|
mails: e.some((e) => e.id === n.id) ? [{
|
|
133
218
|
receivable_id: n.id,
|
|
134
|
-
mail:
|
|
219
|
+
mail: d
|
|
135
220
|
}] : [],
|
|
136
221
|
bankDetails: [i],
|
|
137
222
|
files: [],
|
|
138
|
-
|
|
223
|
+
paymentRecords: le(e, y),
|
|
224
|
+
recurrences: [],
|
|
225
|
+
paymentReminders: [c],
|
|
139
226
|
overdueReminders: [a],
|
|
140
|
-
mint:
|
|
227
|
+
mint: y,
|
|
141
228
|
nextNumber: 1050
|
|
142
|
-
},
|
|
143
|
-
...
|
|
144
|
-
id:
|
|
229
|
+
}, j = ie(l, te.filter((e) => l.some((t) => t.id === e.counterpart_id)), () => k.invoices, y), M = se(void 0, void 0, y), N = (e) => k.invoices.find((t) => t.id === e), F = (e) => (k.invoices = k.invoices.map((t) => t.id === e.id ? e : t), e), R = (e, t, n) => k.history.push({
|
|
230
|
+
...u,
|
|
231
|
+
id: y(C.HistoryEvent),
|
|
145
232
|
receivable_id: e.id,
|
|
146
233
|
event_type: t,
|
|
147
234
|
event_data: n,
|
|
148
235
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
149
|
-
}),
|
|
236
|
+
}), z = (e, t) => (R(e, "status_changed", {
|
|
150
237
|
old_status: e.status,
|
|
151
238
|
new_status: t
|
|
152
|
-
}),
|
|
239
|
+
}), F({
|
|
153
240
|
...e,
|
|
154
241
|
status: t,
|
|
155
242
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
156
|
-
})),
|
|
157
|
-
let r =
|
|
243
|
+
})), B = (e, t, n) => {
|
|
244
|
+
let r = Math.min(e.total_amount ?? 0, e.amount_paid + t), i = U({
|
|
245
|
+
...e,
|
|
246
|
+
amount_paid: r
|
|
247
|
+
});
|
|
248
|
+
return R(e, "payment_received", {
|
|
249
|
+
amount_paid: t,
|
|
250
|
+
amount_due: i.amount_due,
|
|
251
|
+
...n
|
|
252
|
+
}), F({
|
|
253
|
+
...z(e, i.amount_due === 0 ? "paid" : "partially_paid"),
|
|
254
|
+
amount_paid: i.amount_paid,
|
|
255
|
+
amount_due: i.amount_due
|
|
256
|
+
});
|
|
257
|
+
}, V = (e) => (k.recurrences = k.recurrences.map((t) => t.id === e.id ? e : t), b(e)), Y = (e, t, n) => v(e, `${h}/recurrences/:id${t}`, (e, { id: t }) => {
|
|
258
|
+
let r = k.recurrences.find((e) => e.id === t);
|
|
259
|
+
return r ? n(r, e) : E();
|
|
260
|
+
}), Z = (e, t, n) => v(e, `${J}/:id${t}`, (e, { id: t }) => {
|
|
261
|
+
let r = N(t);
|
|
158
262
|
return r ? n(r, e) : E();
|
|
159
263
|
});
|
|
160
264
|
return [
|
|
161
|
-
...
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
265
|
+
...f ? [ee(f, J, () => k.invoices)] : [],
|
|
266
|
+
...p === "failing" ? de() : [],
|
|
267
|
+
v("GET", `${h}/payment-terms`, () => b({ data: P })),
|
|
268
|
+
v("GET", `${h}/bank-details`, () => b({
|
|
269
|
+
data: k.bankDetails,
|
|
165
270
|
next_pagination_token: null
|
|
166
271
|
})),
|
|
167
|
-
|
|
168
|
-
let t =
|
|
272
|
+
v("POST", `${h}/bank-details`, (e) => {
|
|
273
|
+
let t = _(e), n = {
|
|
169
274
|
...i,
|
|
170
|
-
id:
|
|
275
|
+
id: y(C.BankDetails),
|
|
171
276
|
account_holder_name: t.account_holder_name ?? null,
|
|
172
277
|
account_number: null,
|
|
173
278
|
account_number_last4: t.account_number?.slice(-4) ?? null,
|
|
174
279
|
display_name: t.display_name ?? null,
|
|
175
280
|
routing_number: t.routing_number ?? null
|
|
176
281
|
};
|
|
177
|
-
return
|
|
282
|
+
return k.bankDetails.push(n), b(n, 201);
|
|
178
283
|
}),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
let t =
|
|
182
|
-
...
|
|
183
|
-
id:
|
|
284
|
+
v("GET", `${h}/payment-reminders`, () => b({ data: k.paymentReminders })),
|
|
285
|
+
v("POST", `${h}/payment-reminders`, (e) => {
|
|
286
|
+
let t = _(e), n = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
287
|
+
...c,
|
|
288
|
+
id: y(C.PaymentReminder),
|
|
184
289
|
created_at: n,
|
|
185
290
|
updated_at: n,
|
|
186
291
|
name: t.name ?? "",
|
|
@@ -189,143 +294,156 @@ function Z({ invoices: e = k, customers: c = D, list: d }) {
|
|
|
189
294
|
term_2_reminder: t.term_2_reminder ?? null,
|
|
190
295
|
term_final_reminder: t.term_final_reminder ?? null
|
|
191
296
|
};
|
|
192
|
-
return
|
|
297
|
+
return k.paymentReminders.push(r), b(r, 201);
|
|
193
298
|
}),
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
let t =
|
|
299
|
+
v("GET", `${h}/overdue-reminders`, () => b({ data: k.overdueReminders })),
|
|
300
|
+
v("POST", `${h}/overdue-reminders`, (e) => {
|
|
301
|
+
let t = _(e), n = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
197
302
|
...a,
|
|
198
|
-
id:
|
|
303
|
+
id: y(C.OverdueReminder),
|
|
199
304
|
created_at: n,
|
|
200
305
|
updated_at: n,
|
|
201
306
|
name: t.name ?? "",
|
|
202
307
|
recipients: t.recipients ?? null,
|
|
203
308
|
terms: t.terms ?? null
|
|
204
309
|
};
|
|
205
|
-
return
|
|
310
|
+
return k.overdueReminders.push(r), b(r, 201);
|
|
206
311
|
}),
|
|
207
|
-
|
|
312
|
+
v("GET", `${g}/bank-accounts`, () => b({
|
|
208
313
|
data: [r],
|
|
209
|
-
[
|
|
314
|
+
[m.next]: null
|
|
210
315
|
})),
|
|
211
|
-
|
|
316
|
+
v("GET", `${g}/external-bank-accounts`, () => b({
|
|
212
317
|
data: [t],
|
|
213
|
-
[
|
|
318
|
+
[m.next]: null
|
|
214
319
|
})),
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
let t =
|
|
218
|
-
if (!n) return
|
|
219
|
-
let r = (/* @__PURE__ */ new Date()).toISOString(), i =
|
|
320
|
+
v("GET", J, ({ query: e }) => b(w(ae(k.invoices, e), e))),
|
|
321
|
+
v("POST", J, (e) => {
|
|
322
|
+
let t = _(e), n = j.customers.find((e) => e.id === t.counterpart_id);
|
|
323
|
+
if (!n) return S(422, "Unprocessable Entity", "Unknown customer.");
|
|
324
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = U(A(y(C.Invoice), n, (t.line_items ?? []).map((e) => W(k, e)), {
|
|
220
325
|
document_id: null,
|
|
221
326
|
status: "draft",
|
|
222
327
|
currency: t.currency ?? "USD",
|
|
223
328
|
issue_date: null,
|
|
224
|
-
due_date:
|
|
329
|
+
due_date: K(t, I()),
|
|
225
330
|
memo: t.memo || null,
|
|
226
331
|
footer: t.footer || null,
|
|
227
|
-
payment_terms:
|
|
332
|
+
payment_terms: G(t) ?? null,
|
|
228
333
|
discount: t.discount ?? null,
|
|
229
334
|
bank_account_id: t.bank_account_id ?? null,
|
|
230
335
|
bank_account_type: t.bank_account_type ?? null,
|
|
231
336
|
payment_reminder_id: t.payment_reminder_id ?? null,
|
|
232
337
|
overdue_reminder_id: t.overdue_reminder_id ?? null,
|
|
233
|
-
attachments:
|
|
338
|
+
attachments: q(k, t.attachments),
|
|
234
339
|
created_at: r,
|
|
235
340
|
updated_at: r
|
|
236
341
|
}));
|
|
237
|
-
return
|
|
342
|
+
return k.invoices.unshift(i), R(i, "receivable_created", {
|
|
238
343
|
source: "manual",
|
|
239
344
|
status: "draft"
|
|
240
|
-
}),
|
|
345
|
+
}), b(i, 201);
|
|
241
346
|
}),
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
let { line_items: n, ...r } =
|
|
347
|
+
Z("GET", "", (e) => b(e)),
|
|
348
|
+
Z("PATCH", "", (e, t) => {
|
|
349
|
+
let { line_items: n, ...r } = _(t).invoice ?? {}, i = j.customers.find((t) => t.id === (r.counterpart_id ?? e.counterpart_id)), a = new Set(n?.remove ?? []), o = [...e.line_items.filter((e) => !a.has(e.id)).map((e) => {
|
|
245
350
|
let t = n?.replace?.find((t) => t.id === e.id);
|
|
246
|
-
return t ?
|
|
247
|
-
}), ...(n?.add ?? []).map((e) =>
|
|
248
|
-
|
|
351
|
+
return t ? W(k, t.data, e.id) : e;
|
|
352
|
+
}), ...(n?.add ?? []).map((e) => W(k, e))];
|
|
353
|
+
R(e, "receivable_updated", {});
|
|
249
354
|
let s = r.issue_date ?? e.issue_date;
|
|
250
|
-
return
|
|
355
|
+
return b(F(U({
|
|
251
356
|
...e,
|
|
252
|
-
...i ?
|
|
357
|
+
...i ? ne(i) : {},
|
|
253
358
|
currency: r.currency ?? e.currency,
|
|
254
359
|
issue_date: s,
|
|
255
360
|
memo: r.memo ?? e.memo,
|
|
256
361
|
..."discount" in r ? { discount: r.discount ?? null } : {},
|
|
257
362
|
footer: r.footer ?? e.footer,
|
|
258
|
-
due_date:
|
|
259
|
-
payment_terms:
|
|
363
|
+
due_date: K(r, s ?? I()) ?? e.due_date,
|
|
364
|
+
payment_terms: G(r) === void 0 ? e.payment_terms : G(r),
|
|
260
365
|
...r.bank_account_id === void 0 ? {} : {
|
|
261
366
|
bank_account_id: r.bank_account_id,
|
|
262
367
|
bank_account_type: r.bank_account_type ?? null
|
|
263
368
|
},
|
|
264
369
|
...r.payment_reminder_id === void 0 ? {} : { payment_reminder_id: r.payment_reminder_id },
|
|
265
370
|
...r.overdue_reminder_id === void 0 ? {} : { overdue_reminder_id: r.overdue_reminder_id },
|
|
266
|
-
...r.attachments === void 0 ? {} : { attachments:
|
|
371
|
+
...r.attachments === void 0 ? {} : { attachments: q(k, r.attachments) },
|
|
267
372
|
line_items: o,
|
|
268
373
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
269
374
|
})));
|
|
270
375
|
}),
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
376
|
+
v("DELETE", `${J}/:id`, (e, { id: t }) => (k.invoices = k.invoices.filter((e) => e.id !== t), x())),
|
|
377
|
+
v("GET", `${J}/:id/history`, ({ query: e }, { id: t }) => b(w(k.history.filter((e) => e.receivable_id === t).sort((e, t) => t.timestamp.localeCompare(e.timestamp)), e))),
|
|
378
|
+
v("GET", `${J}/:id/mails`, ({ query: e }, { id: t }) => b(w(k.mails.filter((e) => e.receivable_id === t).map((e) => e.mail), e))),
|
|
379
|
+
v("GET", `${J}/:id/pdf-link`, () => b({
|
|
275
380
|
file_url: null,
|
|
276
381
|
original_file_url: null
|
|
277
382
|
})),
|
|
278
|
-
|
|
279
|
-
let t =
|
|
280
|
-
return
|
|
383
|
+
Z("POST", "/issue", (e) => {
|
|
384
|
+
let t = z(e, "issued"), n = e.issue_date ?? I();
|
|
385
|
+
return b(F({
|
|
281
386
|
...t,
|
|
282
|
-
document_id: `INV-${
|
|
387
|
+
document_id: `INV-${k.nextNumber++}`,
|
|
283
388
|
issue_date: n,
|
|
284
|
-
due_date: e.due_date ??
|
|
389
|
+
due_date: e.due_date ?? L(n, 30)
|
|
285
390
|
}));
|
|
286
391
|
}),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
let { comment: n } =
|
|
290
|
-
return
|
|
392
|
+
Z("POST", "/cancel", (e) => b(z(e, "canceled"))),
|
|
393
|
+
Z("POST", "/mark-as-uncollectible", (e, t) => {
|
|
394
|
+
let { comment: n } = _(t);
|
|
395
|
+
return b(z(n ? {
|
|
291
396
|
...e,
|
|
292
397
|
comment: n
|
|
293
398
|
} : e, "uncollectible"));
|
|
294
399
|
}),
|
|
295
|
-
|
|
400
|
+
Z("POST", "/mark-as-paid", (e, t) => {
|
|
296
401
|
let n = X(t), r = e.total_amount ?? 0;
|
|
297
|
-
|
|
402
|
+
R(e, "payment_received", {
|
|
298
403
|
amount_paid: r - e.amount_paid,
|
|
299
404
|
amount_due: 0,
|
|
300
405
|
...n
|
|
301
406
|
});
|
|
302
|
-
let i =
|
|
303
|
-
return
|
|
407
|
+
let i = z(e, "paid");
|
|
408
|
+
return b(F({
|
|
304
409
|
...i,
|
|
305
410
|
amount_paid: r,
|
|
306
411
|
amount_due: 0,
|
|
307
412
|
paid_at: n.paid_at
|
|
308
413
|
}));
|
|
309
414
|
}),
|
|
310
|
-
|
|
311
|
-
let n =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
415
|
+
Z("POST", "/mark-as-partially-paid", (e, t) => {
|
|
416
|
+
let n = _(t).amount_paid ?? 0;
|
|
417
|
+
return b(B(e, n, X(t)));
|
|
418
|
+
}),
|
|
419
|
+
v("GET", `${h}/payment-records`, ({ query: e }) => b(w(k.paymentRecords.filter((t) => t.object.id === e.get("object_id")), e))),
|
|
420
|
+
v("POST", `${h}/payment-records`, (e) => {
|
|
421
|
+
let t = _(e), n = N(t.object?.id ?? "");
|
|
422
|
+
if (!n) return E();
|
|
423
|
+
let r = X(e), i = B(n, t.amount ?? 0, r), a = {
|
|
424
|
+
...s,
|
|
425
|
+
id: y(C.PaymentRecord),
|
|
426
|
+
amount: t.amount ?? 0,
|
|
427
|
+
currency: t.currency ?? n.currency,
|
|
428
|
+
is_external: t.is_external ?? !0,
|
|
429
|
+
paid_at: r.paid_at,
|
|
430
|
+
history: [{
|
|
431
|
+
status: "succeeded",
|
|
432
|
+
timestamp: r.paid_at
|
|
433
|
+
}],
|
|
434
|
+
object: {
|
|
435
|
+
id: n.id,
|
|
436
|
+
type: "receivable",
|
|
437
|
+
old_status: n.status,
|
|
438
|
+
new_status: i.status
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
return k.paymentRecords.push(a), b(a, 201);
|
|
324
442
|
}),
|
|
325
|
-
|
|
443
|
+
Z("POST", "/clone", (e) => {
|
|
326
444
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
|
|
327
445
|
...e,
|
|
328
|
-
id:
|
|
446
|
+
id: y(C.Invoice),
|
|
329
447
|
document_id: null,
|
|
330
448
|
status: "draft",
|
|
331
449
|
issue_date: null,
|
|
@@ -335,15 +453,15 @@ function Z({ invoices: e = k, customers: c = D, list: d }) {
|
|
|
335
453
|
created_at: t,
|
|
336
454
|
updated_at: t
|
|
337
455
|
};
|
|
338
|
-
return
|
|
456
|
+
return k.invoices.unshift(n), R(n, "receivable_created", {
|
|
339
457
|
source: "based_on",
|
|
340
458
|
status: "draft"
|
|
341
|
-
}),
|
|
459
|
+
}), b(n, 201);
|
|
342
460
|
}),
|
|
343
|
-
|
|
344
|
-
let n =
|
|
345
|
-
...
|
|
346
|
-
id:
|
|
461
|
+
Z("POST", "/send", (e, t) => {
|
|
462
|
+
let n = _(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
463
|
+
...d,
|
|
464
|
+
id: y(C.Mail),
|
|
347
465
|
created_at: r,
|
|
348
466
|
updated_at: r,
|
|
349
467
|
recipients: { to: (n.recipients?.to ?? []).map((e) => ({
|
|
@@ -351,60 +469,119 @@ function Z({ invoices: e = k, customers: c = D, list: d }) {
|
|
|
351
469
|
is_success: !0
|
|
352
470
|
})) }
|
|
353
471
|
};
|
|
354
|
-
return
|
|
472
|
+
return k.mails.push({
|
|
355
473
|
receivable_id: e.id,
|
|
356
474
|
mail: i
|
|
357
|
-
}),
|
|
475
|
+
}), R(e, "mail_sent", {
|
|
358
476
|
mail_id: i.id,
|
|
359
477
|
mail_status: "sent"
|
|
360
|
-
}),
|
|
478
|
+
}), b({ mail_id: i.id });
|
|
479
|
+
}),
|
|
480
|
+
v("GET", `${h}/recurrences`, () => b({ data: k.recurrences })),
|
|
481
|
+
v("POST", `${h}/recurrences`, (e) => {
|
|
482
|
+
let t = _(e), n = N(t.invoice_id ?? "");
|
|
483
|
+
if (!n) return E();
|
|
484
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
485
|
+
start_date: t.start_date ?? I(),
|
|
486
|
+
frequency: t.frequency ?? "month",
|
|
487
|
+
interval: t.interval ?? 1,
|
|
488
|
+
max_occurrences: t.max_occurrences ?? null,
|
|
489
|
+
end_date: t.end_date ?? null
|
|
490
|
+
}, a = {
|
|
491
|
+
...i,
|
|
492
|
+
id: y(C.Recurrence),
|
|
493
|
+
created_at: r,
|
|
494
|
+
updated_at: r,
|
|
495
|
+
invoice_id: n.id,
|
|
496
|
+
automation_level: t.automation_level ?? "issue",
|
|
497
|
+
subject_text: t.subject_text ?? null,
|
|
498
|
+
body_text: t.body_text ?? null,
|
|
499
|
+
recipients: t.recipients ?? null,
|
|
500
|
+
current_iteration: 0,
|
|
501
|
+
status: "active",
|
|
502
|
+
iterations: H(i)
|
|
503
|
+
};
|
|
504
|
+
return k.recurrences.push(a), F({
|
|
505
|
+
...z(n, "recurring"),
|
|
506
|
+
recurrence_id: a.id
|
|
507
|
+
}), b(a, 201);
|
|
361
508
|
}),
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
509
|
+
Y("GET", "", (e) => b(e)),
|
|
510
|
+
Y("PATCH", "", (e, t) => {
|
|
511
|
+
let n = {
|
|
512
|
+
...e,
|
|
513
|
+
..._(t),
|
|
514
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
515
|
+
};
|
|
516
|
+
return V({
|
|
517
|
+
...n,
|
|
518
|
+
iterations: H(n)
|
|
519
|
+
});
|
|
520
|
+
}),
|
|
521
|
+
Y("POST", "/pause", (e) => V({
|
|
522
|
+
...e,
|
|
523
|
+
status: "paused"
|
|
524
|
+
})),
|
|
525
|
+
Y("POST", "/resume", (e) => V({
|
|
526
|
+
...e,
|
|
527
|
+
status: "active"
|
|
528
|
+
})),
|
|
529
|
+
Y("POST", "/cancel", (e) => V({
|
|
530
|
+
...e,
|
|
531
|
+
status: "canceled",
|
|
532
|
+
iterations: e.iterations.map((e) => e.status === "pending" ? {
|
|
533
|
+
...e,
|
|
534
|
+
status: "canceled"
|
|
535
|
+
} : e)
|
|
536
|
+
})),
|
|
537
|
+
v("POST", `${h}/files`, (e) => {
|
|
538
|
+
let { file: t } = _(e), n = {
|
|
539
|
+
id: y(C.File),
|
|
365
540
|
name: t?.name ?? "attachment",
|
|
366
541
|
size: t?.size ?? 0,
|
|
367
542
|
mimetype: t?.type || "application/octet-stream",
|
|
368
543
|
url: `https://example.com/attachments/${encodeURIComponent(t?.name ?? "attachment")}`
|
|
369
544
|
};
|
|
370
|
-
return
|
|
545
|
+
return k.files.push(n), b({
|
|
371
546
|
...o,
|
|
372
547
|
...n,
|
|
373
548
|
file_type: "attachments"
|
|
374
549
|
}, 201);
|
|
375
550
|
}),
|
|
376
|
-
|
|
551
|
+
v("GET", `${h}/files`, ({ query: e }) => {
|
|
377
552
|
let t = e.getAll("id__in");
|
|
378
|
-
return
|
|
553
|
+
return b({ data: k.files.filter((e) => t.includes(e.id)).map((e) => ({
|
|
379
554
|
...o,
|
|
380
555
|
...e
|
|
381
556
|
})) });
|
|
382
557
|
}),
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
...
|
|
558
|
+
v("DELETE", `${h}/files/:id`, (e, { id: t }) => (k.files = k.files.filter((e) => e.id !== t), x())),
|
|
559
|
+
(e) => e.method === "GET" && e.path === ue && e.query.get("dimension") === "status" ? b(fe(k.invoices, e.query)) : void 0,
|
|
560
|
+
...re(j),
|
|
561
|
+
...oe(M)
|
|
386
562
|
];
|
|
387
563
|
}
|
|
388
564
|
function Q(e, t, n = {}) {
|
|
389
565
|
return {
|
|
390
566
|
key: e,
|
|
391
567
|
...t,
|
|
392
|
-
routes: () => [
|
|
568
|
+
routes: () => [y(M), ...Z(n)]
|
|
393
569
|
};
|
|
394
570
|
}
|
|
395
571
|
var $ = (e, t = {}) => Q(e, {
|
|
396
|
-
label:
|
|
397
|
-
blurb:
|
|
398
|
-
}, t),
|
|
572
|
+
label: p[e].label,
|
|
573
|
+
blurb: f.blurbs[e]
|
|
574
|
+
}, t), pe = [
|
|
399
575
|
$("populated"),
|
|
400
576
|
$("empty", { invoices: [] }),
|
|
401
577
|
$("loading", { list: "held" }),
|
|
402
578
|
$("error", { list: "failing" }),
|
|
403
|
-
$("paginated", { invoices: [...
|
|
404
|
-
Q("no-customers",
|
|
579
|
+
$("paginated", { invoices: [...O, ...F] }),
|
|
580
|
+
Q("no-customers", f.scenarios["no-customers"], {
|
|
405
581
|
invoices: [],
|
|
406
582
|
customers: []
|
|
407
|
-
})
|
|
583
|
+
}),
|
|
584
|
+
Q("writes-failing", f.scenarios["writes-failing"], { writes: "failing" })
|
|
408
585
|
];
|
|
409
586
|
//#endregion
|
|
410
|
-
export {
|
|
587
|
+
export { Y as REFUSED_WRITE_REASONS, pe as receivablesScenarios };
|
|
@@ -35,7 +35,9 @@ var u = (e, t) => (e ?? "").toLowerCase().includes(t.toLowerCase()), d = () => a
|
|
|
35
35
|
PaymentReminder: "a",
|
|
36
36
|
OverdueReminder: "b",
|
|
37
37
|
BankAccount: "c",
|
|
38
|
-
ExternalAccount: "d"
|
|
38
|
+
ExternalAccount: "d",
|
|
39
|
+
PaymentRecord: "e",
|
|
40
|
+
Recurrence: "f"
|
|
39
41
|
};
|
|
40
42
|
function h() {
|
|
41
43
|
let e = 0;
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
|
|
2
|
-
var e = "@tesouro/embedded-components-react", t = "0.5.
|
|
2
|
+
var e = "@tesouro/embedded-components-react", t = "0.5.300", n = "7475f80ff3e4d108ae108bdfaa7d95124502ed00", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|