@tesouro/embedded-components-react 0.5.210 → 0.5.212

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/index.d.ts +16 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +16 -0
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +113 -109
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +416 -132
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +113 -211
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +154 -37
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +193 -135
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +32 -37
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +150 -58
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +35 -89
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +58 -116
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +96 -47
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +103 -347
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +364 -64
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +66 -106
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +105 -275
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +288 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +76 -61
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +48 -422
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +5 -5
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +38 -62
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +61 -391
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +457 -89
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +91 -234
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +234 -78
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +80 -331
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +344 -0
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +10 -0
  32. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  33. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4927,6 +4927,16 @@ interface ReceivableFormSheetLabels extends ReceivableBillingSectionLabels {
4927
4927
  taxRateLabel: string;
4928
4928
  taxRatePlaceholder: string;
4929
4929
  taxRateSuffix: string;
4930
+ discountLabel: string;
4931
+ discountPercentageOption: string;
4932
+ discountAmountOptionAriaLabel: string;
4933
+ discountPercentageOptionAriaLabel: string;
4934
+ subtotalLabel: string;
4935
+ discountTotalLabel: string;
4936
+ nonTaxableSubtotalLabel: string;
4937
+ taxableSubtotalLabel: string;
4938
+ taxTotalLabel: string;
4939
+ totalLabel: string;
4930
4940
  decreaseQuantityButton: string;
4931
4941
  increaseQuantityButton: string;
4932
4942
  addLineItemButton: string;
@@ -5053,6 +5063,12 @@ interface ReceivableMessageLabels {
5053
5063
  lineItemNameTooLong: string;
5054
5064
  /** `{maxAmount}` is replaced with the formatted cap. */
5055
5065
  lineItemPriceTooHigh: string;
5066
+ discountPercentageTooHigh: string;
5067
+ discountExceedsSubtotal: string;
5068
+ /** `{maxAmount}` is replaced with the formatted cap. */
5069
+ invoiceSubtotalTooHigh: string;
5070
+ /** `{maxAmount}` is replaced with the formatted cap. */
5071
+ invoiceTotalTooHigh: string;
5056
5072
  sendToRequired: string;
5057
5073
  sendSubjectRequired: string;
5058
5074
  sendBodyRequired: string;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import { InsightsWidget as L } from "./libs/tesouro-embedded-components-react/in
27
27
  import { UploadReceiptWidget as R } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index2.js";
28
28
  import { ExpenseManagementWidget as z } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index21.js";
29
29
  import { InvoicingWidget as B } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js";
30
- import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js";
30
+ import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js";
31
31
  import { SettingsSection as H } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index4.js";
32
32
  import { HELP_FAQ_EN as U } from "./libs/tesouro-embedded-components-react/settings-widget/help/ui/contract/dist/index3.js";
33
33
  import { SettingsWidget as W } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js";
@@ -971,6 +971,16 @@ interface ReceivableFormSheetLabels extends ReceivableBillingSectionLabels {
971
971
  taxRateLabel: string;
972
972
  taxRatePlaceholder: string;
973
973
  taxRateSuffix: string;
974
+ discountLabel: string;
975
+ discountPercentageOption: string;
976
+ discountAmountOptionAriaLabel: string;
977
+ discountPercentageOptionAriaLabel: string;
978
+ subtotalLabel: string;
979
+ discountTotalLabel: string;
980
+ nonTaxableSubtotalLabel: string;
981
+ taxableSubtotalLabel: string;
982
+ taxTotalLabel: string;
983
+ totalLabel: string;
974
984
  decreaseQuantityButton: string;
975
985
  increaseQuantityButton: string;
976
986
  addLineItemButton: string;
@@ -1097,6 +1107,12 @@ interface ReceivableMessageLabels {
1097
1107
  lineItemNameTooLong: string;
1098
1108
  /** `{maxAmount}` is replaced with the formatted cap. */
1099
1109
  lineItemPriceTooHigh: string;
1110
+ discountPercentageTooHigh: string;
1111
+ discountExceedsSubtotal: string;
1112
+ /** `{maxAmount}` is replaced with the formatted cap. */
1113
+ invoiceSubtotalTooHigh: string;
1114
+ /** `{maxAmount}` is replaced with the formatted cap. */
1115
+ invoiceTotalTooHigh: string;
1100
1116
  sendToRequired: string;
1101
1117
  sendSubjectRequired: string;
1102
1118
  sendBodyRequired: string;
@@ -1,3 +1,3 @@
1
- import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js";
1
+ import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js";
2
2
  import "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js";
3
3
  export { e as ReceivablesWidget };
@@ -1,3 +1,3 @@
1
1
  import { InvoicingWidget as e } from "./index3.js";
2
- import { ReceivablesWidget as t } from "./index23.js";
2
+ import { ReceivablesWidget as t } from "./index24.js";
3
3
  export { e as InvoicingWidget, t as ReceivablesWidget };
@@ -1,111 +1,115 @@
1
+ import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.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 "./index9.js";
1
4
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js
2
- var e = {
3
- customerRequired: "Customer is required",
4
- customerAddressRequired: "The selected customer needs a billing address before a receivable can be created.",
5
- currencyRequired: "Currency is required",
6
- lineItemNameTooLong: "Product name must be 100 characters or less",
7
- lineItemPriceTooHigh: "Price must be {maxAmount} or less",
8
- sendToRequired: "Enter at least one recipient",
9
- sendSubjectRequired: "Subject is required",
10
- sendBodyRequired: "Message is required",
11
- paymentAmountInvalid: "Amount paid must be greater than 0",
12
- genericError: "Something went wrong. Please try again.",
13
- lineItemsLoading: "Please wait for invoice details to finish loading.",
14
- paymentTermsCustomDatePlaceholder: "Mon DD, YYYY",
15
- bankAccountFallbackName: "Bank Account",
16
- bankAccountPoweredBy: "Powered by {embeddedBankName}",
17
- bankAccountLinked: "Linked account",
18
- bankAccountHolderNameRequired: "Account holder name is required",
19
- bankAccountHolderNameTooLong: "Account holder name must be 255 characters or less",
20
- bankAccountNumberRequired: "Account number is required",
21
- bankAccountNumberDigitsOnly: "Account number must contain only digits",
22
- bankAccountNumberTooShort: "Account number must be at least 4 digits",
23
- bankAccountNumberTooLong: "Account number must be at most 17 digits",
24
- bankAccountRoutingNumberRequired: "Routing number is required",
25
- bankAccountRoutingNumberInvalid: "Routing number must be 9 digits",
26
- bankAccountNicknameTooLong: "Display name must be 200 characters or less",
27
- bankAccountCreated: "Bank Account \"{name}\" has been created.",
28
- bankAccountCreateFailed: "Failed to create Bank Account.",
29
- untitledDocument: "Untitled document",
30
- unknownCustomer: "Unknown customer",
31
- notAvailable: "Not available",
32
- invoiceType: "Invoice",
33
- quoteType: "Quote",
34
- creditNoteType: "Credit note",
35
- summaryDocumentType: "Document type",
36
- summaryDocumentNumber: "Document number",
37
- summaryCustomer: "Customer",
38
- summaryIssued: "Issued",
39
- summaryDue: "Due",
40
- summaryCreated: "Created",
41
- summaryUpdated: "Updated",
42
- summaryTotal: "Total",
43
- summaryAmountDue: "Amount due",
44
- activityStatusChanged: "Status changed",
45
- activityReceivableCreated: "Receivable created",
46
- activityReceivableUpdated: "Receivable updated",
47
- activityPaymentReceived: "Payment received",
48
- activityMailSent: "Email sent",
49
- activityUnknown: "Activity",
50
- recipientsNone: "No recipients",
51
- sendSubjectDefault: "Your receivable document",
52
- sendBodyDefault: "Please find the receivable document attached.",
53
- issueTitle: "Issue receivable?",
54
- issueDescription: "Issuing locks the document and makes it ready to send to the customer.",
55
- issueConfirm: "Issue",
56
- acceptTitle: "Accept quote?",
57
- acceptDescription: "This marks the quote as accepted.",
58
- acceptConfirm: "Accept",
59
- declineTitle: "Decline quote?",
60
- declineDescription: "This marks the quote as declined.",
61
- declineConfirm: "Decline",
62
- cancelTitle: "Cancel receivable?",
63
- cancelDescription: "This cancels the document. You cannot undo this action.",
64
- cancelConfirm: "Cancel document",
65
- cloneTitle: "Clone receivable?",
66
- cloneDescription: "This creates a new draft based on the selected document.",
67
- cloneConfirm: "Clone",
68
- deleteTitle: "Delete draft?",
69
- deleteDescription: "This permanently deletes the draft document. You cannot undo this action.",
70
- deleteConfirm: "Delete",
71
- markPaidTitle: "Mark invoice as paid?",
72
- markPaidDescription: "This records the invoice as fully paid.",
73
- markPaidConfirm: "Mark paid",
74
- markUncollectibleTitle: "Mark invoice uncollectible?",
75
- markUncollectibleDescription: "This records the invoice as uncollectible. You cannot undo this action.",
76
- markUncollectibleConfirm: "Mark uncollectible",
77
- attachmentsEmailCaption: "Selected files will be attached to the invoice email sent to the customer.",
78
- attachmentsRecurringEmailCaption: "Selected files will be attached to every invoice email in the recurring series.",
79
- attachmentIncludeInEmail: "Include in email:",
80
- attachmentRemove: "Remove",
81
- attachmentUploading: "Uploading…",
82
- attachmentUploadFailed: "Upload failed. Please try again.",
83
- attachmentTooLarge: "File too large (max 3 MB)",
84
- attachmentUnsupportedType: "File type not supported. Use PDF, DOC, JPG or PNG",
85
- attachmentsCountLimit: "You can attach up to 10 files.",
86
- attachmentIncludedInEmail: "Included in email",
87
- attachmentNotIncludedInEmail: "Not included in email",
88
- reminderUnitDay: "day",
89
- reminderUnitDays: "days",
90
- reminderNameDay: "{days} day",
91
- reminderNameDays: "{days} days",
92
- reminderNameAnd: "and",
93
- reminderBeforeDueCaption: "Add schedule",
94
- reminderOverdueCaption: "Add schedule (Specify up to 3 terms)",
95
- reminderOverdueEmptyCaption: "Send up to three reminders",
96
- reminderOverdueTermLabel: "Reminder {index}, days after due date",
97
- reminderDaysRange: "Enter a number of days between {min} and {max}.",
98
- reminderPastDueWarning: "This reminder would be sent after the due date has already passed.",
99
- reminderAdded: "Reminder has been added",
100
- reminderBeforeDueSubject: "Payment is due soon",
101
- reminderBeforeDueBody: "Payment is due on {dueDate}.",
102
- reminderBeforeDueBodyNoDate: "Payment is due soon.",
103
- reminderOverdueSubject: "Payment is overdue",
104
- reminderOverdueBody: "Payment was due on {dueDate}.",
105
- reminderOverdueBodyNoDate: "Payment is overdue.",
106
- issueRemindersDisabled: "Payment reminders are disabled for this customer. Please enable them in the customer details or turn them off.",
107
- issueRemindersNoEmail: "No email address is added for the selected customer. Please add it to the customer details or turn off the reminders.",
108
- issueRemindersDisabledNoEmail: "Reminders are disabled for this customer, and no email address has been added for it. Please update the details or turn off reminders."
109
- };
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
+ }
15
+ return {
16
+ taxableItemsSubtotal: i,
17
+ nonTaxableItemsSubtotal: a,
18
+ subtotal: i + a,
19
+ rateMinorUnits: r
20
+ };
21
+ }
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);
26
+ }
27
+ function f({ taxableItemsSubtotal: e, nonTaxableItemsSubtotal: t, discountAmount: n }) {
28
+ let r = e + t, i = r > 0 ? Math.round(e / r * n) : 0;
29
+ return {
30
+ taxableSubtotal: e - i,
31
+ nonTaxableSubtotal: t - (n - i)
32
+ };
33
+ }
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;
67
+ return {
68
+ ...a,
69
+ discountAmount: o,
70
+ discountedSubtotal: m,
71
+ taxableSubtotal: s,
72
+ nonTaxableSubtotal: c,
73
+ totalTaxes: l,
74
+ total: m + l
75
+ };
76
+ }
77
+ function h(e) {
78
+ return m({
79
+ lineItems: e.lineItems.filter((e) => !t(e)),
80
+ currency: e.currency,
81
+ taxRate: Number(e.taxRate) || void 0,
82
+ keepSavedRate: n(e.taxRate, e.savedTaxRate),
83
+ discount: s(e)
84
+ });
85
+ }
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;
89
+ }
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);
95
+ }
96
+ function v(t, n, r) {
97
+ return new Intl.NumberFormat(void 0, {
98
+ style: "currency",
99
+ currency: n,
100
+ currencyDisplay: "narrowSymbol",
101
+ currencySign: r
102
+ }).format(t / 10 ** e(n));
103
+ }
104
+ function y(e, t) {
105
+ return {
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)
112
+ };
113
+ }
110
114
  //#endregion
111
- export { e as RECEIVABLE_MESSAGE_LABELS_EN };
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 };