@tesouro/embedded-components-react 0.11.141 → 0.11.167
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/NOTICE +24 -0
- package/README.md +15 -37
- package/dist/experimental/BalanceHistoryWidget.d.ts +0 -11
- package/dist/experimental/QuickViewWidget.d.ts +0 -11
- package/dist/experimental/RemoteCheckCapture.d.ts +0 -11
- package/dist/experimental/index.d.ts +0 -11
- package/dist/fixtures/index.d.ts +27 -1
- package/dist/index.css +6976 -6246
- package/dist/index.d.ts +64 -173
- package/dist/index.js +9 -10
- package/dist/lib/AcceptDisclosuresWidget.d.ts +0 -11
- package/dist/lib/BalancesWidget.d.ts +0 -11
- package/dist/lib/BankAccountOnboardingWidget.d.ts +0 -11
- package/dist/lib/BankAccountsWidget.d.ts +2 -11
- package/dist/lib/BankingComplianceBannerWidget.d.ts +0 -11
- package/dist/lib/BillPayWidget.d.ts +0 -11
- package/dist/lib/CardDetailsWidget.d.ts +0 -11
- package/dist/lib/CounterpartsWidget.d.ts +1 -12
- package/dist/lib/CounterpartsWidgetPublic.d.ts +1 -12
- package/dist/lib/CreditCardsWidget.d.ts +0 -11
- package/dist/lib/DebitCardsWidget.d.ts +0 -11
- package/dist/lib/ExpenseManagementWidget.d.ts +1 -12
- package/dist/lib/InsightsWidget.d.ts +0 -11
- package/dist/lib/LinkedAccountsWidget.d.ts +0 -11
- package/dist/lib/OfferWidget.d.ts +0 -11
- package/dist/lib/ReceivablesWidget.d.ts +60 -17
- package/dist/lib/ReceivablesWidget.js +3 -2
- package/dist/lib/SettingsWidget.d.ts +0 -11
- package/dist/lib/TransfersWidget.d.ts +0 -11
- package/dist/lib/WidgetProvider.d.ts +0 -11
- package/dist/lib/WidgetProviderPublic.d.ts +0 -11
- package/dist/lib/WidgetSuite.d.ts +60 -15
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/BankAccountOnboardingWidget.js +20 -19
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index10.js +8 -8
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index4.js +2 -3
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index10.js +83 -82
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index4.js +84 -79
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index9.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/formatters.js +2 -3
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/useBankAccountsWidget.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/AccountCard.js +51 -46
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/labels.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/feature/dist/index10.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/useActivateCard.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/useCardLock.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/useEditCardNickname.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/ExpenseManagementWidget.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/TransactionDetails/TransactionDetailsFeature.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index16.js +66 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +351 -318
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +126 -133
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +63 -56
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/invoicesFilter.js +78 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/invoicesFilterLabels.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +14 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +138 -129
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurringSeries.js +119 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/statusCards.js +37 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/tabs.js +1 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useInvoicesFilter.js +131 -81
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useLocalDayStart.js +15 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +46 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +13 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +440 -438
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentTerms.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableRecurrence.js +62 -56
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +47 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +78 -86
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +180 -158
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useRecurringSeriesTable.js +132 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/invoicing.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js +153 -137
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +22 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +6 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index60.js +137 -129
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index61.js +21 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index62.js +143 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index63.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index64.js +47 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +25 -25
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductDelete.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/products.js +3 -11
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/scenarios.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index2.js +36 -77
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/summarizeCardSpend.js +11 -13
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/useCardSpendSummary.js +20 -17
- package/dist/libs/tesouro-embedded-components-react/remote-check-capture/feature/dist/lib/RemoteCheckCaptureWidget/useRemoteCheckCaptureWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/mocks/settings.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index8.js +4 -9
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index12.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index16.js +2 -3
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/lib/SettingsWidgetUi/SettingsWidgetUi.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index3.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useDeleteController.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +43 -43
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +233 -211
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +66 -42
- package/dist/libs/tesouro-embedded-components-react/shared/document-status/util/dist/lib/receivableFilledTone.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/expense-requirements/feature/dist/lib/ExpenseRequirementsWidget.js +5 -4
- 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/lib/MeasureUnitsManagerContainer.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/toasts.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +28 -28
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/EmbeddedToaster.js +33 -32
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransferMoneyModalController.js +9 -8
- package/dist/node_modules/sonner/dist/index.js +620 -0
- package/dist/packages/shared-ui-shadcn/dist/index.js +6072 -6062
- package/dist/scenarios/index.d.ts +1 -3
- package/dist/scenarios/index.js +17 -20
- package/package.json +17 -4
- package/dist/lib/CustomersWidget.d.ts +0 -993
- package/dist/lib/CustomersWidget.js +0 -2
- package/dist/lib/ProductsWidget.d.ts +0 -893
- package/dist/lib/ProductsWidget.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/index.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidget/CustomersWidget.js +0 -41
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/analytics/events.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/scenarios.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useUtcDayStart.js +0 -15
|
@@ -5,13 +5,13 @@ import { AN_ENTITY_BANK_ACCOUNT as i, AN_OVERDUE_REMINDER as a, A_FILE as o, A_P
|
|
|
5
5
|
import { RECEIVABLES_LABELS as f } from "./labels.js";
|
|
6
6
|
import { SCENARIO_LABELS as p } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/labels.js";
|
|
7
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
|
|
9
|
-
import { CUSTOMERS as
|
|
8
|
+
import { MintKind as C, finopsOffsetPage as w, listOverride as ee, minter as te, notFound as T } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/worlds.js";
|
|
9
|
+
import { CUSTOMERS as E, CUSTOMER_ADDRESSES as ne, CUSTOMER_INVOICES as D, billTo as re, customerRoutes as ie, customerWorld as ae, filterInvoices as oe, id as O, invoice as k, lineItem as A } 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 se, productWorld as ce } from "../../../../products-widget/feature/dist/mocks/products.js";
|
|
12
12
|
import "../../../../products-widget/feature/dist/scenarios.js";
|
|
13
13
|
// ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js
|
|
14
|
-
var
|
|
14
|
+
var j = [
|
|
15
15
|
e.InvoiceReadOrg,
|
|
16
16
|
e.InvoiceWriteOrg,
|
|
17
17
|
e.CounterpartReadOrg,
|
|
@@ -22,16 +22,16 @@ var M = [
|
|
|
22
22
|
e.BankAccountWriteOrg,
|
|
23
23
|
e.ExternalBankAccountReadOrg,
|
|
24
24
|
e.PaymentRecordWriteOrg
|
|
25
|
-
],
|
|
25
|
+
], M = {
|
|
26
26
|
...l,
|
|
27
|
-
id:
|
|
28
|
-
},
|
|
29
|
-
...
|
|
30
|
-
id:
|
|
27
|
+
id: O(350)
|
|
28
|
+
}, N = [{
|
|
29
|
+
...M,
|
|
30
|
+
id: O(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
|
+
}, M], P = [
|
|
35
35
|
"Copywriting",
|
|
36
36
|
"Photo retouching",
|
|
37
37
|
"Event staffing",
|
|
@@ -41,8 +41,8 @@ var M = [
|
|
|
41
41
|
"Training video",
|
|
42
42
|
"Signage install"
|
|
43
43
|
].map((e, t) => {
|
|
44
|
-
let n =
|
|
45
|
-
return
|
|
44
|
+
let n = E[t % E.length];
|
|
45
|
+
return k(352 + t, n, [A(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,27 +50,39 @@ var M = [
|
|
|
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
|
+
}), F = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), I = 864e5;
|
|
54
|
+
function L(e) {
|
|
55
|
+
let t = 0;
|
|
56
|
+
return e.map((e) => {
|
|
57
|
+
if (e.status !== "paid") return e;
|
|
58
|
+
let n = t % 3 == 2 ? 45 + t : 2 + t * 5;
|
|
59
|
+
return t += 1, {
|
|
60
|
+
...e,
|
|
61
|
+
paid_at: (/* @__PURE__ */ new Date(Date.now() - n * I)).toISOString()
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
var R = (e, t) => {
|
|
54
66
|
let n = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
55
67
|
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
56
|
-
},
|
|
68
|
+
}, z = 12, B = {
|
|
57
69
|
month: 1,
|
|
58
70
|
quarter: 3,
|
|
59
71
|
year: 12
|
|
60
|
-
},
|
|
72
|
+
}, V = {
|
|
61
73
|
day: 1,
|
|
62
74
|
week: 7
|
|
63
75
|
};
|
|
64
|
-
function
|
|
65
|
-
let r = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`), i =
|
|
66
|
-
if (!i) return r.setUTCDate(r.getUTCDate() + (
|
|
76
|
+
function H(e, t, n) {
|
|
77
|
+
let r = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`), i = B[t];
|
|
78
|
+
if (!i) return r.setUTCDate(r.getUTCDate() + (V[t] ?? 1) * n), r.toISOString().slice(0, 10);
|
|
67
79
|
let a = r.getUTCFullYear(), o = r.getUTCMonth() + i * n, s = new Date(Date.UTC(a, o + 1, 0)).getUTCDate();
|
|
68
80
|
return new Date(Date.UTC(a, o, Math.min(r.getUTCDate(), s))).toISOString().slice(0, 10);
|
|
69
81
|
}
|
|
70
|
-
function
|
|
71
|
-
let { start_date: t, frequency: n, interval: r, max_occurrences: i, end_date: a } = e, o = i ?? (a ? Infinity :
|
|
82
|
+
function U(e) {
|
|
83
|
+
let { start_date: t, frequency: n, interval: r, max_occurrences: i, end_date: a } = e, o = i ?? (a ? Infinity : z), s = [];
|
|
72
84
|
for (let e = 0; e < o; e += 1) {
|
|
73
|
-
let i =
|
|
85
|
+
let i = H(t, n, e * r);
|
|
74
86
|
if (a && i > a) break;
|
|
75
87
|
s.push({
|
|
76
88
|
iteration: e + 1,
|
|
@@ -81,7 +93,7 @@ function H(e) {
|
|
|
81
93
|
}
|
|
82
94
|
return s;
|
|
83
95
|
}
|
|
84
|
-
function
|
|
96
|
+
function le(e, t) {
|
|
85
97
|
return e.flatMap((e) => {
|
|
86
98
|
let n = {
|
|
87
99
|
...u,
|
|
@@ -111,7 +123,7 @@ function ce(e, t) {
|
|
|
111
123
|
];
|
|
112
124
|
});
|
|
113
125
|
}
|
|
114
|
-
function
|
|
126
|
+
function ue(e, t) {
|
|
115
127
|
return e.filter((e) => e.amount_paid > 0).map((e) => {
|
|
116
128
|
let n = e.paid_at ?? e.updated_at;
|
|
117
129
|
return {
|
|
@@ -133,7 +145,7 @@ function le(e, t) {
|
|
|
133
145
|
};
|
|
134
146
|
});
|
|
135
147
|
}
|
|
136
|
-
function
|
|
148
|
+
function W(e) {
|
|
137
149
|
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;
|
|
138
150
|
return {
|
|
139
151
|
...e,
|
|
@@ -149,24 +161,24 @@ function U(e) {
|
|
|
149
161
|
amount_due: Math.max(0, u - e.amount_paid)
|
|
150
162
|
};
|
|
151
163
|
}
|
|
152
|
-
function
|
|
164
|
+
function G(e, t, n) {
|
|
153
165
|
return {
|
|
154
|
-
...
|
|
166
|
+
...A(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),
|
|
155
167
|
...t.tax_status ? { tax_status: t.tax_status } : {},
|
|
156
168
|
...t.discount ? { discount: t.discount } : {}
|
|
157
169
|
};
|
|
158
170
|
}
|
|
159
|
-
function
|
|
160
|
-
let t =
|
|
171
|
+
function K(e) {
|
|
172
|
+
let t = N.find((t) => t.id === e.payment_terms_id);
|
|
161
173
|
if (t) return t;
|
|
162
174
|
if (e.payment_terms?.term_final) return { term_final: e.payment_terms.term_final };
|
|
163
175
|
if (e.payment_terms_id === null || e.payment_terms === null) return null;
|
|
164
176
|
}
|
|
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;
|
|
168
|
-
}
|
|
169
177
|
function q(e, t) {
|
|
178
|
+
let n = K(e)?.term_final;
|
|
179
|
+
return n?.end_date ? n.end_date : n?.number_of_days !== void 0 && n.number_of_days !== null ? R(t, n.number_of_days) : e.due_date ?? null;
|
|
180
|
+
}
|
|
181
|
+
function J(e, t) {
|
|
170
182
|
return (t ?? []).flatMap((t) => {
|
|
171
183
|
let n = e.files.find((e) => e.id === t.id);
|
|
172
184
|
return n ? [{
|
|
@@ -175,34 +187,38 @@ function q(e, t) {
|
|
|
175
187
|
}] : [];
|
|
176
188
|
});
|
|
177
189
|
}
|
|
178
|
-
var
|
|
190
|
+
var Y = `${h}/receivables`, de = `${h}/analytics/receivables`, X = {
|
|
179
191
|
issue: "The customer has no billing address on file.",
|
|
180
192
|
send: "The mail server rejected the message.",
|
|
181
193
|
payment: "The payment date falls in a closed accounting period.",
|
|
182
194
|
cancel: "The invoice has a payment in progress."
|
|
183
195
|
};
|
|
184
|
-
function
|
|
196
|
+
function fe() {
|
|
185
197
|
let e = (e) => () => S(422, "Unprocessable Entity", e);
|
|
186
198
|
return [
|
|
187
|
-
v("POST", `${
|
|
188
|
-
v("POST", `${
|
|
189
|
-
v("POST", `${h}/payment-records`, e(
|
|
190
|
-
v("POST", `${
|
|
199
|
+
v("POST", `${Y}/:id/issue`, e(X.issue)),
|
|
200
|
+
v("POST", `${Y}/:id/send`, e(X.send)),
|
|
201
|
+
v("POST", `${h}/payment-records`, e(X.payment)),
|
|
202
|
+
v("POST", `${Y}/:id/cancel`, e(X.cancel))
|
|
191
203
|
];
|
|
192
204
|
}
|
|
193
|
-
function
|
|
205
|
+
function pe(e, t) {
|
|
194
206
|
let n = t.get("type"), r = t.getAll("status__in"), i = t.get("aggregation_function") === "count", a = t.get("metric") === "amount_due" ? "amount_due" : "total_amount", o = /* @__PURE__ */ new Map();
|
|
195
|
-
for (let
|
|
196
|
-
if (n &&
|
|
197
|
-
let e =
|
|
198
|
-
|
|
207
|
+
for (let s of e) {
|
|
208
|
+
if (n && s.type !== n || r.length && !r.includes(s.status)) continue;
|
|
209
|
+
let e = s.paid_at ?? "", c = t.get("paid_at__gte");
|
|
210
|
+
if (c && (!e || e < c)) continue;
|
|
211
|
+
let l = t.get("paid_at__lte");
|
|
212
|
+
if (l && (!e || e > l)) continue;
|
|
213
|
+
let u = i ? 1 : s[a] ?? 0;
|
|
214
|
+
o.set(s.status, (o.get(s.status) ?? 0) + u);
|
|
199
215
|
}
|
|
200
216
|
return { data: [...o].map(([e, t]) => ({
|
|
201
217
|
dimension_value: e,
|
|
202
218
|
metric_value: t
|
|
203
219
|
})) };
|
|
204
220
|
}
|
|
205
|
-
function
|
|
221
|
+
function Z(e) {
|
|
206
222
|
let t = _(e);
|
|
207
223
|
return {
|
|
208
224
|
paid_at: t.paid_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -210,66 +226,66 @@ function X(e) {
|
|
|
210
226
|
...t.is_external == null ? {} : { is_external: t.is_external }
|
|
211
227
|
};
|
|
212
228
|
}
|
|
213
|
-
function
|
|
214
|
-
let y =
|
|
229
|
+
function me({ invoices: e = L(D), customers: l = E, list: f, writes: p }) {
|
|
230
|
+
let y = te(), O = {
|
|
215
231
|
invoices: [...e],
|
|
216
|
-
history:
|
|
232
|
+
history: le(e, y),
|
|
217
233
|
mails: e.some((e) => e.id === n.id) ? [{
|
|
218
234
|
receivable_id: n.id,
|
|
219
235
|
mail: d
|
|
220
236
|
}] : [],
|
|
221
237
|
bankDetails: [i],
|
|
222
238
|
files: [],
|
|
223
|
-
paymentRecords:
|
|
239
|
+
paymentRecords: ue(e, y),
|
|
224
240
|
recurrences: [],
|
|
225
241
|
paymentReminders: [c],
|
|
226
242
|
overdueReminders: [a],
|
|
227
243
|
mint: y,
|
|
228
244
|
nextNumber: 1050
|
|
229
|
-
},
|
|
245
|
+
}, A = ae(l, ne.filter((e) => l.some((t) => t.id === e.counterpart_id)), () => O.invoices, y), j = ce(void 0, void 0, y), M = (e) => O.invoices.find((t) => t.id === e), P = (e) => (O.invoices = O.invoices.map((t) => t.id === e.id ? e : t), e), I = (e, t, n) => O.history.push({
|
|
230
246
|
...u,
|
|
231
247
|
id: y(C.HistoryEvent),
|
|
232
248
|
receivable_id: e.id,
|
|
233
249
|
event_type: t,
|
|
234
250
|
event_data: n,
|
|
235
251
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
236
|
-
}), z = (e, t) => (
|
|
252
|
+
}), z = (e, t) => (I(e, "status_changed", {
|
|
237
253
|
old_status: e.status,
|
|
238
254
|
new_status: t
|
|
239
|
-
}),
|
|
255
|
+
}), P({
|
|
240
256
|
...e,
|
|
241
257
|
status: t,
|
|
242
258
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
243
259
|
})), B = (e, t, n) => {
|
|
244
|
-
let r = Math.min(e.total_amount ?? 0, e.amount_paid + t), i =
|
|
260
|
+
let r = Math.min(e.total_amount ?? 0, e.amount_paid + t), i = W({
|
|
245
261
|
...e,
|
|
246
262
|
amount_paid: r
|
|
247
263
|
});
|
|
248
|
-
|
|
264
|
+
I(e, "payment_received", {
|
|
249
265
|
amount_paid: t,
|
|
250
266
|
amount_due: i.amount_due,
|
|
251
267
|
...n
|
|
252
268
|
});
|
|
253
269
|
let a = i.amount_due === 0;
|
|
254
|
-
return
|
|
270
|
+
return P({
|
|
255
271
|
...z(e, a ? "paid" : "partially_paid"),
|
|
256
272
|
amount_paid: i.amount_paid,
|
|
257
273
|
amount_due: i.amount_due,
|
|
258
274
|
...a ? { paid_at: n.paid_at } : {}
|
|
259
275
|
});
|
|
260
|
-
}, V = (e) => (
|
|
261
|
-
let r =
|
|
262
|
-
return r ? n(r, e) :
|
|
263
|
-
}),
|
|
264
|
-
let r =
|
|
265
|
-
return r ? n(r, e) :
|
|
276
|
+
}, V = (e) => (O.recurrences = O.recurrences.map((t) => t.id === e.id ? e : t), b(e)), H = (e, t, n) => v(e, `${h}/recurrences/:id${t}`, (e, { id: t }) => {
|
|
277
|
+
let r = O.recurrences.find((e) => e.id === t);
|
|
278
|
+
return r ? n(r, e) : T();
|
|
279
|
+
}), X = (e, t, n) => v(e, `${Y}/:id${t}`, (e, { id: t }) => {
|
|
280
|
+
let r = M(t);
|
|
281
|
+
return r ? n(r, e) : T();
|
|
266
282
|
});
|
|
267
283
|
return [
|
|
268
|
-
...f ? [ee(f,
|
|
269
|
-
...p === "failing" ?
|
|
270
|
-
v("GET", `${h}/payment-terms`, () => b({ data:
|
|
284
|
+
...f ? [ee(f, Y, () => O.invoices)] : [],
|
|
285
|
+
...p === "failing" ? fe() : [],
|
|
286
|
+
v("GET", `${h}/payment-terms`, () => b({ data: N })),
|
|
271
287
|
v("GET", `${h}/bank-details`, () => b({
|
|
272
|
-
data:
|
|
288
|
+
data: O.bankDetails,
|
|
273
289
|
next_pagination_token: null
|
|
274
290
|
})),
|
|
275
291
|
v("POST", `${h}/bank-details`, (e) => {
|
|
@@ -282,9 +298,9 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
282
298
|
display_name: t.display_name ?? null,
|
|
283
299
|
routing_number: t.routing_number ?? null
|
|
284
300
|
};
|
|
285
|
-
return
|
|
301
|
+
return O.bankDetails.push(n), b(n, 201);
|
|
286
302
|
}),
|
|
287
|
-
v("GET", `${h}/payment-reminders`, () => b({ data:
|
|
303
|
+
v("GET", `${h}/payment-reminders`, () => b({ data: O.paymentReminders })),
|
|
288
304
|
v("POST", `${h}/payment-reminders`, (e) => {
|
|
289
305
|
let t = _(e), n = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
290
306
|
...c,
|
|
@@ -297,9 +313,9 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
297
313
|
term_2_reminder: t.term_2_reminder ?? null,
|
|
298
314
|
term_final_reminder: t.term_final_reminder ?? null
|
|
299
315
|
};
|
|
300
|
-
return
|
|
316
|
+
return O.paymentReminders.push(r), b(r, 201);
|
|
301
317
|
}),
|
|
302
|
-
v("GET", `${h}/overdue-reminders`, () => b({ data:
|
|
318
|
+
v("GET", `${h}/overdue-reminders`, () => b({ data: O.overdueReminders })),
|
|
303
319
|
v("POST", `${h}/overdue-reminders`, (e) => {
|
|
304
320
|
let t = _(e), n = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
305
321
|
...a,
|
|
@@ -310,7 +326,7 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
310
326
|
recipients: t.recipients ?? null,
|
|
311
327
|
terms: t.terms ?? null
|
|
312
328
|
};
|
|
313
|
-
return
|
|
329
|
+
return O.overdueReminders.push(r), b(r, 201);
|
|
314
330
|
}),
|
|
315
331
|
v("GET", `${g}/bank-accounts`, () => b({
|
|
316
332
|
data: [r],
|
|
@@ -320,110 +336,110 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
320
336
|
data: [t],
|
|
321
337
|
[m.next]: null
|
|
322
338
|
})),
|
|
323
|
-
v("GET",
|
|
324
|
-
v("POST",
|
|
325
|
-
let t = _(e), n =
|
|
339
|
+
v("GET", Y, ({ query: e }) => b(w(oe(O.invoices, e), e))),
|
|
340
|
+
v("POST", Y, (e) => {
|
|
341
|
+
let t = _(e), n = A.customers.find((e) => e.id === t.counterpart_id);
|
|
326
342
|
if (!n) return S(422, "Unprocessable Entity", "Unknown customer.");
|
|
327
|
-
let r = (/* @__PURE__ */ new Date()).toISOString(), i =
|
|
343
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = W(k(y(C.Invoice), n, (t.line_items ?? []).map((e) => G(O, e)), {
|
|
328
344
|
document_id: null,
|
|
329
345
|
status: "draft",
|
|
330
346
|
currency: t.currency ?? "USD",
|
|
331
347
|
issue_date: null,
|
|
332
|
-
due_date:
|
|
348
|
+
due_date: q(t, F()),
|
|
333
349
|
memo: t.memo || null,
|
|
334
350
|
footer: t.footer || null,
|
|
335
|
-
payment_terms:
|
|
351
|
+
payment_terms: K(t) ?? null,
|
|
336
352
|
discount: t.discount ?? null,
|
|
337
353
|
bank_account_id: t.bank_account_id ?? null,
|
|
338
354
|
bank_account_type: t.bank_account_type ?? null,
|
|
339
355
|
payment_reminder_id: t.payment_reminder_id ?? null,
|
|
340
356
|
overdue_reminder_id: t.overdue_reminder_id ?? null,
|
|
341
|
-
attachments:
|
|
357
|
+
attachments: J(O, t.attachments),
|
|
342
358
|
created_at: r,
|
|
343
359
|
updated_at: r
|
|
344
360
|
}));
|
|
345
|
-
return
|
|
361
|
+
return O.invoices.unshift(i), I(i, "receivable_created", {
|
|
346
362
|
source: "manual",
|
|
347
363
|
status: "draft"
|
|
348
364
|
}), b(i, 201);
|
|
349
365
|
}),
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
let { line_items: n, ...r } = _(t).invoice ?? {}, i =
|
|
366
|
+
X("GET", "", (e) => b(e)),
|
|
367
|
+
X("PATCH", "", (e, t) => {
|
|
368
|
+
let { line_items: n, ...r } = _(t).invoice ?? {}, i = A.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) => {
|
|
353
369
|
let t = n?.replace?.find((t) => t.id === e.id);
|
|
354
|
-
return t ?
|
|
355
|
-
}), ...(n?.add ?? []).map((e) =>
|
|
356
|
-
|
|
370
|
+
return t ? G(O, t.data, e.id) : e;
|
|
371
|
+
}), ...(n?.add ?? []).map((e) => G(O, e))];
|
|
372
|
+
I(e, "receivable_updated", {});
|
|
357
373
|
let s = r.issue_date ?? e.issue_date;
|
|
358
|
-
return b(
|
|
374
|
+
return b(P(W({
|
|
359
375
|
...e,
|
|
360
|
-
...i ?
|
|
376
|
+
...i ? re(i) : {},
|
|
361
377
|
currency: r.currency ?? e.currency,
|
|
362
378
|
issue_date: s,
|
|
363
379
|
memo: r.memo ?? e.memo,
|
|
364
380
|
..."discount" in r ? { discount: r.discount ?? null } : {},
|
|
365
381
|
footer: r.footer ?? e.footer,
|
|
366
|
-
due_date:
|
|
367
|
-
payment_terms:
|
|
382
|
+
due_date: q(r, s ?? F()) ?? e.due_date,
|
|
383
|
+
payment_terms: K(r) === void 0 ? e.payment_terms : K(r),
|
|
368
384
|
...r.bank_account_id === void 0 ? {} : {
|
|
369
385
|
bank_account_id: r.bank_account_id,
|
|
370
386
|
bank_account_type: r.bank_account_type ?? null
|
|
371
387
|
},
|
|
372
388
|
...r.payment_reminder_id === void 0 ? {} : { payment_reminder_id: r.payment_reminder_id },
|
|
373
389
|
...r.overdue_reminder_id === void 0 ? {} : { overdue_reminder_id: r.overdue_reminder_id },
|
|
374
|
-
...r.attachments === void 0 ? {} : { attachments:
|
|
390
|
+
...r.attachments === void 0 ? {} : { attachments: J(O, r.attachments) },
|
|
375
391
|
line_items: o,
|
|
376
392
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
377
393
|
})));
|
|
378
394
|
}),
|
|
379
|
-
v("DELETE", `${
|
|
380
|
-
v("GET", `${
|
|
381
|
-
v("GET", `${
|
|
382
|
-
v("GET", `${
|
|
395
|
+
v("DELETE", `${Y}/:id`, (e, { id: t }) => (O.invoices = O.invoices.filter((e) => e.id !== t), x())),
|
|
396
|
+
v("GET", `${Y}/:id/history`, ({ query: e }, { id: t }) => b(w(O.history.filter((e) => e.receivable_id === t).sort((e, t) => t.timestamp.localeCompare(e.timestamp)), e))),
|
|
397
|
+
v("GET", `${Y}/:id/mails`, ({ query: e }, { id: t }) => b(w(O.mails.filter((e) => e.receivable_id === t).map((e) => e.mail), e))),
|
|
398
|
+
v("GET", `${Y}/:id/pdf-link`, () => b({
|
|
383
399
|
file_url: null,
|
|
384
400
|
original_file_url: null
|
|
385
401
|
})),
|
|
386
|
-
|
|
387
|
-
let t = z(e, "issued"), n = e.issue_date ??
|
|
388
|
-
return b(
|
|
402
|
+
X("POST", "/issue", (e) => {
|
|
403
|
+
let t = z(e, "issued"), n = e.issue_date ?? F();
|
|
404
|
+
return b(P({
|
|
389
405
|
...t,
|
|
390
|
-
document_id: `INV-${
|
|
406
|
+
document_id: `INV-${O.nextNumber++}`,
|
|
391
407
|
issue_date: n,
|
|
392
|
-
due_date: e.due_date ??
|
|
408
|
+
due_date: e.due_date ?? R(n, 30)
|
|
393
409
|
}));
|
|
394
410
|
}),
|
|
395
|
-
|
|
396
|
-
|
|
411
|
+
X("POST", "/cancel", (e) => b(z(e, "canceled"))),
|
|
412
|
+
X("POST", "/mark-as-uncollectible", (e, t) => {
|
|
397
413
|
let { comment: n } = _(t);
|
|
398
414
|
return b(z(n ? {
|
|
399
415
|
...e,
|
|
400
416
|
comment: n
|
|
401
417
|
} : e, "uncollectible"));
|
|
402
418
|
}),
|
|
403
|
-
|
|
404
|
-
let n =
|
|
405
|
-
|
|
419
|
+
X("POST", "/mark-as-paid", (e, t) => {
|
|
420
|
+
let n = Z(t), r = e.total_amount ?? 0;
|
|
421
|
+
I(e, "payment_received", {
|
|
406
422
|
amount_paid: r - e.amount_paid,
|
|
407
423
|
amount_due: 0,
|
|
408
424
|
...n
|
|
409
425
|
});
|
|
410
426
|
let i = z(e, "paid");
|
|
411
|
-
return b(
|
|
427
|
+
return b(P({
|
|
412
428
|
...i,
|
|
413
429
|
amount_paid: r,
|
|
414
430
|
amount_due: 0,
|
|
415
431
|
paid_at: n.paid_at
|
|
416
432
|
}));
|
|
417
433
|
}),
|
|
418
|
-
|
|
434
|
+
X("POST", "/mark-as-partially-paid", (e, t) => {
|
|
419
435
|
let n = _(t).amount_paid ?? 0;
|
|
420
|
-
return b(B(e, n,
|
|
436
|
+
return b(B(e, n, Z(t)));
|
|
421
437
|
}),
|
|
422
|
-
v("GET", `${h}/payment-records`, ({ query: e }) => b(w(
|
|
438
|
+
v("GET", `${h}/payment-records`, ({ query: e }) => b(w(O.paymentRecords.filter((t) => t.object.id === e.get("object_id")), e))),
|
|
423
439
|
v("POST", `${h}/payment-records`, (e) => {
|
|
424
|
-
let t = _(e), n =
|
|
425
|
-
if (!n) return
|
|
426
|
-
let r =
|
|
440
|
+
let t = _(e), n = M(t.object?.id ?? "");
|
|
441
|
+
if (!n) return T();
|
|
442
|
+
let r = Z(e), i = B(n, t.amount ?? 0, r), a = {
|
|
427
443
|
...s,
|
|
428
444
|
id: y(C.PaymentRecord),
|
|
429
445
|
amount: t.amount ?? 0,
|
|
@@ -441,9 +457,9 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
441
457
|
new_status: i.status
|
|
442
458
|
}
|
|
443
459
|
};
|
|
444
|
-
return
|
|
460
|
+
return O.paymentRecords.push(a), b(a, 201);
|
|
445
461
|
}),
|
|
446
|
-
|
|
462
|
+
X("POST", "/clone", (e) => {
|
|
447
463
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
|
|
448
464
|
...e,
|
|
449
465
|
id: y(C.Invoice),
|
|
@@ -456,12 +472,12 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
456
472
|
created_at: t,
|
|
457
473
|
updated_at: t
|
|
458
474
|
};
|
|
459
|
-
return
|
|
475
|
+
return O.invoices.unshift(n), I(n, "receivable_created", {
|
|
460
476
|
source: "based_on",
|
|
461
477
|
status: "draft"
|
|
462
478
|
}), b(n, 201);
|
|
463
479
|
}),
|
|
464
|
-
|
|
480
|
+
X("POST", "/send", (e, t) => {
|
|
465
481
|
let n = _(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
466
482
|
...d,
|
|
467
483
|
id: y(C.Mail),
|
|
@@ -472,20 +488,20 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
472
488
|
is_success: !0
|
|
473
489
|
})) }
|
|
474
490
|
};
|
|
475
|
-
return
|
|
491
|
+
return O.mails.push({
|
|
476
492
|
receivable_id: e.id,
|
|
477
493
|
mail: i
|
|
478
|
-
}),
|
|
494
|
+
}), I(e, "mail_sent", {
|
|
479
495
|
mail_id: i.id,
|
|
480
496
|
mail_status: "sent"
|
|
481
497
|
}), b({ mail_id: i.id });
|
|
482
498
|
}),
|
|
483
|
-
v("GET", `${h}/recurrences`, () => b({ data:
|
|
499
|
+
v("GET", `${h}/recurrences`, () => b({ data: O.recurrences })),
|
|
484
500
|
v("POST", `${h}/recurrences`, (e) => {
|
|
485
|
-
let t = _(e), n =
|
|
486
|
-
if (!n) return
|
|
501
|
+
let t = _(e), n = M(t.invoice_id ?? "");
|
|
502
|
+
if (!n) return T();
|
|
487
503
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
488
|
-
start_date: t.start_date ??
|
|
504
|
+
start_date: t.start_date ?? F(),
|
|
489
505
|
frequency: t.frequency ?? "month",
|
|
490
506
|
interval: t.interval ?? 1,
|
|
491
507
|
max_occurrences: t.max_occurrences ?? null,
|
|
@@ -502,15 +518,15 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
502
518
|
recipients: t.recipients ?? null,
|
|
503
519
|
current_iteration: 0,
|
|
504
520
|
status: "active",
|
|
505
|
-
iterations:
|
|
521
|
+
iterations: U(i)
|
|
506
522
|
};
|
|
507
|
-
return
|
|
523
|
+
return O.recurrences.push(a), P({
|
|
508
524
|
...z(n, "recurring"),
|
|
509
525
|
recurrence_id: a.id
|
|
510
526
|
}), b(a);
|
|
511
527
|
}),
|
|
512
|
-
|
|
513
|
-
|
|
528
|
+
H("GET", "", (e) => b(e)),
|
|
529
|
+
H("PATCH", "", (e, t) => {
|
|
514
530
|
let n = {
|
|
515
531
|
...e,
|
|
516
532
|
..._(t),
|
|
@@ -518,18 +534,18 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
518
534
|
};
|
|
519
535
|
return V({
|
|
520
536
|
...n,
|
|
521
|
-
iterations:
|
|
537
|
+
iterations: U(n)
|
|
522
538
|
});
|
|
523
539
|
}),
|
|
524
|
-
|
|
540
|
+
H("POST", "/pause", (e) => V({
|
|
525
541
|
...e,
|
|
526
542
|
status: "paused"
|
|
527
543
|
})),
|
|
528
|
-
|
|
544
|
+
H("POST", "/resume", (e) => V({
|
|
529
545
|
...e,
|
|
530
546
|
status: "active"
|
|
531
547
|
})),
|
|
532
|
-
|
|
548
|
+
H("POST", "/cancel", (e) => V({
|
|
533
549
|
...e,
|
|
534
550
|
status: "canceled",
|
|
535
551
|
iterations: e.iterations.map((e) => e.status === "pending" ? {
|
|
@@ -545,7 +561,7 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
545
561
|
mimetype: t?.type || "application/octet-stream",
|
|
546
562
|
url: `https://example.com/attachments/${encodeURIComponent(t?.name ?? "attachment")}`
|
|
547
563
|
};
|
|
548
|
-
return
|
|
564
|
+
return O.files.push(n), b({
|
|
549
565
|
...o,
|
|
550
566
|
...n,
|
|
551
567
|
file_type: "attachments"
|
|
@@ -553,37 +569,37 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
|
|
|
553
569
|
}),
|
|
554
570
|
v("GET", `${h}/files`, ({ query: e }) => {
|
|
555
571
|
let t = e.getAll("id__in");
|
|
556
|
-
return b({ data:
|
|
572
|
+
return b({ data: O.files.filter((e) => t.includes(e.id)).map((e) => ({
|
|
557
573
|
...o,
|
|
558
574
|
...e
|
|
559
575
|
})) });
|
|
560
576
|
}),
|
|
561
|
-
v("DELETE", `${h}/files/:id`, (e, { id: t }) => (
|
|
562
|
-
(e) => e.method === "GET" && e.path ===
|
|
563
|
-
...
|
|
564
|
-
...
|
|
577
|
+
v("DELETE", `${h}/files/:id`, (e, { id: t }) => (O.files = O.files.filter((e) => e.id !== t), x())),
|
|
578
|
+
(e) => e.method === "GET" && e.path === de && e.query.get("dimension") === "status" ? b(pe(O.invoices, e.query)) : void 0,
|
|
579
|
+
...ie(A),
|
|
580
|
+
...se(j)
|
|
565
581
|
];
|
|
566
582
|
}
|
|
567
583
|
function Q(e, t, n = {}) {
|
|
568
584
|
return {
|
|
569
585
|
key: e,
|
|
570
586
|
...t,
|
|
571
|
-
routes: () => [y(
|
|
587
|
+
routes: () => [y(j), ...me(n)]
|
|
572
588
|
};
|
|
573
589
|
}
|
|
574
590
|
var $ = (e, t = {}) => Q(e, {
|
|
575
591
|
label: p[e].label,
|
|
576
592
|
blurb: f.blurbs[e]
|
|
577
|
-
}, t),
|
|
593
|
+
}, t), he = [
|
|
578
594
|
$("populated"),
|
|
579
595
|
$("empty", { invoices: [] }),
|
|
580
596
|
$("loading", { list: "held" }),
|
|
581
597
|
$("error", { list: "failing" }),
|
|
582
|
-
$("paginated", { invoices: [...
|
|
598
|
+
$("paginated", { invoices: L([...D, ...P]) }),
|
|
583
599
|
Q("no-customers", f.scenarios["no-customers"], {
|
|
584
600
|
invoices: [],
|
|
585
601
|
customers: []
|
|
586
602
|
}),
|
|
587
603
|
Q("writes-failing", f.scenarios["writes-failing"], { writes: "failing" })
|
|
588
604
|
];
|
|
589
|
-
export {
|
|
605
|
+
export { X as REFUSED_WRITE_REASONS, he as receivablesScenarios };
|