@tesouro/embedded-components-react 0.5.53 → 0.5.55

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.
@@ -28,16 +28,20 @@ function c({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart:
28
28
  let m = { currency: t };
29
29
  i ? m.counterpart_id = i : a && (m.counterpart_id = null), i ? m.counterpart_bank_account_id = o ?? null : a && (m.counterpart_bank_account_id = null), e.invoiceNumber && (m.document_id = e.invoiceNumber), e.invoiceDate && (m.issued_at = e.invoiceDate), e.dueDate && (m.due_date = e.dueDate);
30
30
  let h = e.poNumber.trim();
31
- if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s && (m.discount = n(s.discount) ?? 0, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = (n(s.total) ?? 0) + (n(s.discount) ?? 0))), c && d) {
31
+ if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s) {
32
+ let e = n(s.discount) ?? 0;
33
+ m.discount = e, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = (n(s.total) ?? 0) + e);
34
+ }
35
+ if (c && d) {
32
36
  let e = u(d), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) + t : (n(c.total) ?? 0) + r;
33
- e !== void 0 && (m.subtotal = e), m.tax_amount = t, m.total_amount = i;
37
+ e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
34
38
  } else if (r && !("total_amount" in m)) {
35
- let e = l(r, s?.tax);
39
+ let e = l(r, { tax: s?.tax });
36
40
  e !== void 0 && (m.total_amount = e);
37
41
  }
38
42
  return m;
39
43
  }
40
- function l(e, t) {
44
+ function l(e, { tax: t }) {
41
45
  let r = u(e);
42
46
  if (r !== void 0) return r + (t ? n(t) ?? 0 : 0);
43
47
  }
@@ -17,27 +17,31 @@ function r(e) {
17
17
  function i(e) {
18
18
  return typeof e == "string" ? e : "";
19
19
  }
20
- function a({ payable: a, lineItems: o }) {
21
- let s = {
22
- invoiceNumber: a.document_id ?? "",
23
- invoiceDate: a.issued_at ?? "",
24
- dueDate: a.due_date ?? "",
25
- poNumber: i(a.purchase_order_number)
26
- }, c = o.map((n) => ({
20
+ function a(e) {
21
+ if (typeof e.amount_due == "number") return e.amount_due;
22
+ if (typeof e.total_amount == "number") return e.total_amount - (e.discount ?? 0);
23
+ }
24
+ function o({ payable: o, lineItems: s }) {
25
+ let c = {
26
+ invoiceNumber: o.document_id ?? "",
27
+ invoiceDate: o.issued_at ?? "",
28
+ dueDate: o.due_date ?? "",
29
+ poNumber: i(o.purchase_order_number)
30
+ }, l = s.map((n) => ({
27
31
  id: n.id,
28
32
  description: n.name ?? "",
29
33
  glCode: n.ledger_account_id ?? "",
30
34
  quantity: String(t(n)),
31
35
  price: r(n.unit_price),
32
36
  amount: r(e(n))
33
- })), l = a.amount_due ?? (a.total_amount == null ? void 0 : a.total_amount - (a.discount ?? 0));
37
+ })), u = a(o);
34
38
  return {
35
- values: s,
36
- lineItems: c.length ? c : [n()],
37
- discount: r(a.discount),
38
- tax: r(a.tax_amount),
39
- total: l ? r(l) : ""
39
+ values: c,
40
+ lineItems: l.length ? l : [n()],
41
+ discount: r(o.discount),
42
+ tax: r(o.tax_amount),
43
+ total: u ? r(u) : ""
40
44
  };
41
45
  }
42
46
  //#endregion
43
- export { n as emptyLineItem, a as mapPayableToBillForm };
47
+ export { n as emptyLineItem, o as mapPayableToBillForm };
@@ -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.53", n = "cbace9101359b08670cf697d63fb61b236069005", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.55", n = "79d2b352eef5c5ee7dd525ae6744ac25f85a262f", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.53",
3
+ "version": "0.5.55",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {