@opencxh/domain 1.301.0 → 1.302.0
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/entities/purchase/feed.d.ts +40 -2
- package/dist/index.cjs +17 -17
- package/dist/index.js +689 -679
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -59,9 +59,9 @@ function $l(e, t = () => {
|
|
|
59
59
|
o.items.length > 10 && (t("more than 10 list items"), o.items = o.items.slice(0, 10));
|
|
60
60
|
break;
|
|
61
61
|
case "actions": {
|
|
62
|
-
const s = Array.isArray(o.elements) ? o.elements : [],
|
|
63
|
-
if (
|
|
64
|
-
|
|
62
|
+
const s = Array.isArray(o.elements) ? o.elements : [], i = s.filter((a) => a?.action_id && a.invoke && We(a.text));
|
|
63
|
+
if (i.length !== s.length && t("an action without action_id, invoke or text"), i.length === 0) continue;
|
|
64
|
+
i.length > 5 && t("more than 5 actions"), o.elements = i.slice(0, 5);
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -569,8 +569,8 @@ function ut(e, t, n) {
|
|
|
569
569
|
if ("value" in e)
|
|
570
570
|
return ct(t, e.value) || null;
|
|
571
571
|
const r = {};
|
|
572
|
-
for (const [s,
|
|
573
|
-
r[s] = ct(t,
|
|
572
|
+
for (const [s, i] of Object.entries(e.params ?? {}))
|
|
573
|
+
r[s] = ct(t, i);
|
|
574
574
|
const o = n(e.key, r);
|
|
575
575
|
return o === e.key ? null : o;
|
|
576
576
|
}
|
|
@@ -725,7 +725,7 @@ function Yl(e, t, n = []) {
|
|
|
725
725
|
const r = e.createdAt;
|
|
726
726
|
if (!r) return [];
|
|
727
727
|
const o = new Set(n);
|
|
728
|
-
return e.author.type === "user" && e.author.id && o.add(e.author.id), Object.entries(t).filter(([s,
|
|
728
|
+
return e.author.type === "user" && e.author.id && o.add(e.author.id), Object.entries(t).filter(([s, i]) => i >= r && !o.has(s)).map(([s]) => s);
|
|
729
729
|
}
|
|
730
730
|
function Po(e) {
|
|
731
731
|
return e.createdAt ?? 0;
|
|
@@ -745,24 +745,24 @@ function Le(e, t) {
|
|
|
745
745
|
if (n === 0) return t.map((u, c) => c === 0 ? e : 0);
|
|
746
746
|
const r = t.map((u) => e * u / n), o = r.map((u) => Math.trunc(u));
|
|
747
747
|
let s = e - o.reduce((u, c) => u + c, 0);
|
|
748
|
-
const
|
|
749
|
-
for (let u = 0; s !== 0 && u <
|
|
750
|
-
o[
|
|
748
|
+
const i = r.map((u, c) => ({ index: c, fraction: Math.abs(u - o[c]) })).sort((u, c) => c.fraction - u.fraction), a = s < 0 ? -1 : 1;
|
|
749
|
+
for (let u = 0; s !== 0 && u < i.length; u++)
|
|
750
|
+
o[i[u].index] += a, s -= a;
|
|
751
751
|
return o;
|
|
752
752
|
}
|
|
753
753
|
function z(e, t = {}) {
|
|
754
|
-
const n = t.decimal ?? ",", r = t.group ?? ".", o = e < 0, s = Math.abs(Math.trunc(e)).toString().padStart(3, "0"),
|
|
754
|
+
const n = t.decimal ?? ",", r = t.group ?? ".", o = e < 0, s = Math.abs(Math.trunc(e)).toString().padStart(3, "0"), i = s.slice(0, -2), a = s.slice(-2);
|
|
755
755
|
let u = "";
|
|
756
|
-
for (let c = 0; c <
|
|
757
|
-
c > 0 && (
|
|
758
|
-
return `${o ? "-" : ""}${u}${n}${
|
|
756
|
+
for (let c = 0; c < i.length; c++)
|
|
757
|
+
c > 0 && (i.length - c) % 3 === 0 && (u += r), u += i[c];
|
|
758
|
+
return `${o ? "-" : ""}${u}${n}${a}`;
|
|
759
759
|
}
|
|
760
760
|
function tn(e) {
|
|
761
761
|
const t = e.trim().replace(/[\s ]/g, "");
|
|
762
762
|
if (!t) return;
|
|
763
763
|
const n = t.replace(/^[-+]?[^\d.,-]*/, "").replace(/[^\d.,-]+$/, ""), r = /^-/.test(t) || /-$/.test(t), o = n.replace(/-/g, "");
|
|
764
764
|
if (!o || !/^[\d.,]+$/.test(o)) return;
|
|
765
|
-
const s = o.lastIndexOf(","),
|
|
765
|
+
const s = o.lastIndexOf(","), i = o.lastIndexOf("."), a = Math.max(s, i), u = a === -1 ? "" : o.slice(a + 1), c = a !== -1 && u.length >= 1 && u.length <= 2, l = c ? o.slice(0, a) : o;
|
|
766
766
|
if (!Lo(l)) return;
|
|
767
767
|
const d = l.replace(/[.,]/g, ""), f = c ? u.padEnd(2, "0") : "00";
|
|
768
768
|
if (d === "") return;
|
|
@@ -788,11 +788,11 @@ function Dt(e, t, n) {
|
|
|
788
788
|
Array.from({ length: r }, () => 1)
|
|
789
789
|
);
|
|
790
790
|
let s = 0;
|
|
791
|
-
for (let
|
|
792
|
-
const
|
|
791
|
+
for (let i = Uo(n.from); i < n.to; i = nn(i)) {
|
|
792
|
+
const a = nn(i), u = Math.max(i, n.from), c = Math.min(a, n.to);
|
|
793
793
|
if (c <= u) continue;
|
|
794
|
-
const l = o[new Date(
|
|
795
|
-
s += l * rn(u, c) / rn(
|
|
794
|
+
const l = o[new Date(i).getUTCMonth() % r];
|
|
795
|
+
s += l * rn(u, c) / rn(i, a);
|
|
796
796
|
}
|
|
797
797
|
return P(s);
|
|
798
798
|
}
|
|
@@ -859,7 +859,7 @@ function Go(e, t, n) {
|
|
|
859
859
|
if (!r) return 0;
|
|
860
860
|
if (r.from === t.from && r.to === t.to) return 1;
|
|
861
861
|
if (!n) return 0;
|
|
862
|
-
const o = (s,
|
|
862
|
+
const o = (s, i) => Math.round((i - s) / jo);
|
|
863
863
|
return o(r.from, r.to) / o(t.from, t.to);
|
|
864
864
|
}
|
|
865
865
|
function Wo(e, t, n) {
|
|
@@ -878,31 +878,31 @@ function qo(e) {
|
|
|
878
878
|
}
|
|
879
879
|
const ue = (e) => Math.round((e.to - e.from) / ft);
|
|
880
880
|
function sd(e, t, n, r) {
|
|
881
|
-
const o = [], s = [],
|
|
881
|
+
const o = [], s = [], i = e.graceDays * ft, a = e.proration === !0;
|
|
882
882
|
for (const u of t) {
|
|
883
883
|
const c = B(e, u), l = hr(e, u), d = qo(u), f = n.filter((h) => h.agreementLineId === u.id);
|
|
884
884
|
if (l === "once") {
|
|
885
885
|
const h = { from: c.from, to: c.from + ft };
|
|
886
|
-
c.from +
|
|
886
|
+
c.from + i <= r && !f.some((I) => !I.correction) && o.push({ lineId: u.id, window: h, part: h, share: 1, timing: "advance" });
|
|
887
887
|
continue;
|
|
888
888
|
}
|
|
889
889
|
const m = [];
|
|
890
|
-
for (let h = dt(c.from, l); h.from < (c.to ?? Number.POSITIVE_INFINITY) && h.from +
|
|
890
|
+
for (let h = dt(c.from, l); h.from < (c.to ?? Number.POSITIVE_INFINITY) && h.from + i <= r; h = dt(h.to, l))
|
|
891
891
|
m.push(h);
|
|
892
892
|
const b = u.quantity.from === "fixed";
|
|
893
893
|
for (const h of m.slice(-24)) {
|
|
894
|
-
const I = Nt(c, h), g = h.to +
|
|
894
|
+
const I = Nt(c, h), g = h.to + i <= r, y = f.filter(
|
|
895
895
|
(_) => _.servicePeriod.from >= h.from && _.servicePeriod.from < h.to
|
|
896
896
|
), p = y.find((_) => !_.correction);
|
|
897
897
|
if (!p) {
|
|
898
898
|
if (!I) continue;
|
|
899
899
|
const _ = I.from === h.from && I.to === h.to;
|
|
900
900
|
if (!(d === "advance" && _) && !g) continue;
|
|
901
|
-
const C = b ? Go(c, h,
|
|
901
|
+
const C = b ? Go(c, h, a) : 1;
|
|
902
902
|
C > 0 && o.push({ lineId: u.id, window: h, part: I, share: C, timing: d });
|
|
903
903
|
continue;
|
|
904
904
|
}
|
|
905
|
-
b &&
|
|
905
|
+
b && a && g && s.push(...Vo(u.id, h, I, p, y));
|
|
906
906
|
}
|
|
907
907
|
}
|
|
908
908
|
return { charges: o, corrections: s };
|
|
@@ -913,16 +913,16 @@ function Vo(e, t, n, r, o) {
|
|
|
913
913
|
if (!u.correction) continue;
|
|
914
914
|
Math.sign(u.quantity) !== Math.sign(r.quantity) ? u.servicePeriod.from <= s.from ? s.from = u.servicePeriod.to : s.to = u.servicePeriod.from : u.servicePeriod.to <= s.from ? s.from = u.servicePeriod.from : s.to = u.servicePeriod.to;
|
|
915
915
|
}
|
|
916
|
-
const
|
|
917
|
-
if (s.to > s.from && (n ? (n.from > s.from &&
|
|
916
|
+
const i = [];
|
|
917
|
+
if (s.to > s.from && (n ? (n.from > s.from && i.push({
|
|
918
918
|
part: { from: s.from, to: Math.min(n.from, s.to) },
|
|
919
919
|
sign: -1
|
|
920
|
-
}), n.to < s.to &&
|
|
920
|
+
}), n.to < s.to && i.push({
|
|
921
921
|
part: { from: Math.max(n.to, s.from), to: s.to },
|
|
922
922
|
sign: -1
|
|
923
|
-
}), n.from < s.from &&
|
|
923
|
+
}), n.from < s.from && i.push({ part: { from: n.from, to: s.from }, sign: 1 }), n.to > s.to && i.push({ part: { from: s.to, to: n.to }, sign: 1 })) : i.push({ part: s, sign: -1 })), r.pricePer) {
|
|
924
924
|
const u = r.pricePer;
|
|
925
|
-
return
|
|
925
|
+
return i.map(({ part: c, sign: l }) => ({
|
|
926
926
|
lineId: e,
|
|
927
927
|
window: t,
|
|
928
928
|
part: c,
|
|
@@ -931,13 +931,13 @@ function Vo(e, t, n, r, o) {
|
|
|
931
931
|
pricePer: u
|
|
932
932
|
})).filter((c) => c.unitPriceCents !== 0 && c.quantity !== 0 && ue(c.part) > 0);
|
|
933
933
|
}
|
|
934
|
-
const
|
|
935
|
-
return
|
|
934
|
+
const a = r.unitPriceCents * ue(t) / Math.max(1, ue(r.servicePeriod));
|
|
935
|
+
return i.map(({ part: u, sign: c }) => ({
|
|
936
936
|
lineId: e,
|
|
937
937
|
window: t,
|
|
938
938
|
part: u,
|
|
939
939
|
quantity: c * r.quantity,
|
|
940
|
-
unitPriceCents: P(
|
|
940
|
+
unitPriceCents: P(a * ue(u) / ue(t))
|
|
941
941
|
})).filter((u) => u.unitPriceCents !== 0 && u.quantity !== 0);
|
|
942
942
|
}
|
|
943
943
|
function id(e) {
|
|
@@ -948,10 +948,10 @@ function id(e) {
|
|
|
948
948
|
n += 1;
|
|
949
949
|
continue;
|
|
950
950
|
}
|
|
951
|
-
const s = t.get(o.timing), { from:
|
|
951
|
+
const s = t.get(o.timing), { from: i, to: a } = o.servicePeriod;
|
|
952
952
|
t.set(
|
|
953
953
|
o.timing,
|
|
954
|
-
s ? { timing: o.timing, from: Math.min(s.from,
|
|
954
|
+
s ? { timing: o.timing, from: Math.min(s.from, i), to: Math.max(s.to, a) } : { timing: o.timing, from: i, to: a }
|
|
955
955
|
);
|
|
956
956
|
}
|
|
957
957
|
return {
|
|
@@ -1042,7 +1042,7 @@ function ld(e, t) {
|
|
|
1042
1042
|
return on(e) !== on(t);
|
|
1043
1043
|
}
|
|
1044
1044
|
function dd(e, t, n, r) {
|
|
1045
|
-
const { endsAt: o, ...s } = e,
|
|
1045
|
+
const { endsAt: o, ...s } = e, i = {
|
|
1046
1046
|
...s,
|
|
1047
1047
|
...o != null ? { endsAt: o } : {},
|
|
1048
1048
|
...n,
|
|
@@ -1050,7 +1050,7 @@ function dd(e, t, n, r) {
|
|
|
1050
1050
|
seriesId: e.seriesId ?? e.id,
|
|
1051
1051
|
startsAt: t
|
|
1052
1052
|
};
|
|
1053
|
-
return [{ ...e, endsAt: t },
|
|
1053
|
+
return [{ ...e, endsAt: t }, i];
|
|
1054
1054
|
}
|
|
1055
1055
|
function zo(e, t) {
|
|
1056
1056
|
const n = t.quantity;
|
|
@@ -1131,10 +1131,10 @@ function bd(e, t, n) {
|
|
|
1131
1131
|
const r = Xo(t);
|
|
1132
1132
|
if (!e) return { ...r, ...n, routed: !1 };
|
|
1133
1133
|
for (let o = pt(r.tier); o >= 0; o--) {
|
|
1134
|
-
const s = pe[o],
|
|
1135
|
-
if (!
|
|
1136
|
-
const
|
|
1137
|
-
return { tier: s, reasons:
|
|
1134
|
+
const s = pe[o], i = e[s];
|
|
1135
|
+
if (!i?.accountId || !i.model) continue;
|
|
1136
|
+
const a = s === r.tier ? r.reasons : [...r.reasons, `${r.tier} niet ingericht, ${s} gebruikt`];
|
|
1137
|
+
return { tier: s, reasons: a, accountId: i.accountId, model: i.model, routed: !0 };
|
|
1138
1138
|
}
|
|
1139
1139
|
return {
|
|
1140
1140
|
...r,
|
|
@@ -1390,8 +1390,8 @@ async function Kd(e, t) {
|
|
|
1390
1390
|
try {
|
|
1391
1391
|
await t(o), n++;
|
|
1392
1392
|
} catch (s) {
|
|
1393
|
-
const
|
|
1394
|
-
if (
|
|
1393
|
+
const i = s?.status;
|
|
1394
|
+
if (i === 403 || i === 400) r++;
|
|
1395
1395
|
else throw s;
|
|
1396
1396
|
}
|
|
1397
1397
|
return { decided: n, waiting: r };
|
|
@@ -1408,7 +1408,7 @@ function Bd(e, t) {
|
|
|
1408
1408
|
function Fd(e, t, n, r) {
|
|
1409
1409
|
const o = new Set(e.userIds);
|
|
1410
1410
|
for (const s of e.teamIds)
|
|
1411
|
-
for (const
|
|
1411
|
+
for (const i of t[s] ?? []) o.add(i);
|
|
1412
1412
|
return r || o.delete(n), [...o];
|
|
1413
1413
|
}
|
|
1414
1414
|
function jd(e, t) {
|
|
@@ -1460,13 +1460,13 @@ function us(e) {
|
|
|
1460
1460
|
t += e[n], n += 1;
|
|
1461
1461
|
continue;
|
|
1462
1462
|
}
|
|
1463
|
-
const
|
|
1464
|
-
if (
|
|
1463
|
+
const i = bn(e, s + 2, "(", ")");
|
|
1464
|
+
if (i < 0) {
|
|
1465
1465
|
t += e[n], n += 1;
|
|
1466
1466
|
continue;
|
|
1467
1467
|
}
|
|
1468
|
-
const
|
|
1469
|
-
t += r || !$t(u) ?
|
|
1468
|
+
const a = e.slice(o, s), u = e.slice(s + 2, i).trim().split(/\s+/)[0] ?? "";
|
|
1469
|
+
t += r || !$t(u) ? a : e.slice(n, i + 1), n = i + 1;
|
|
1470
1470
|
}
|
|
1471
1471
|
return t;
|
|
1472
1472
|
}
|
|
@@ -1519,77 +1519,77 @@ function Wd(e, t = () => {
|
|
|
1519
1519
|
const s = typeof o.block_id == "string" ? { block_id: o.block_id } : {};
|
|
1520
1520
|
switch (o.type) {
|
|
1521
1521
|
case "heading": {
|
|
1522
|
-
const
|
|
1523
|
-
if (!
|
|
1522
|
+
const i = L(o.text);
|
|
1523
|
+
if (!i) {
|
|
1524
1524
|
t("a heading without text");
|
|
1525
1525
|
continue;
|
|
1526
1526
|
}
|
|
1527
|
-
const
|
|
1528
|
-
n.push({ ...s, type: "heading", level:
|
|
1527
|
+
const a = o.level === 2 || o.level === 3 ? o.level : 1;
|
|
1528
|
+
n.push({ ...s, type: "heading", level: a, text: i });
|
|
1529
1529
|
break;
|
|
1530
1530
|
}
|
|
1531
1531
|
case "paragraph": {
|
|
1532
|
-
const
|
|
1533
|
-
if (!
|
|
1532
|
+
const i = L(o.text);
|
|
1533
|
+
if (!i) {
|
|
1534
1534
|
t("a paragraph without text");
|
|
1535
1535
|
continue;
|
|
1536
1536
|
}
|
|
1537
|
-
n.push({ ...s, type: "paragraph", text:
|
|
1537
|
+
n.push({ ...s, type: "paragraph", text: i });
|
|
1538
1538
|
break;
|
|
1539
1539
|
}
|
|
1540
1540
|
case "quote": {
|
|
1541
|
-
const
|
|
1542
|
-
if (!
|
|
1541
|
+
const i = L(o.text);
|
|
1542
|
+
if (!i) {
|
|
1543
1543
|
t("a quote without text");
|
|
1544
1544
|
continue;
|
|
1545
1545
|
}
|
|
1546
|
-
n.push({ ...s, type: "quote", text:
|
|
1546
|
+
n.push({ ...s, type: "quote", text: i });
|
|
1547
1547
|
break;
|
|
1548
1548
|
}
|
|
1549
1549
|
case "code": {
|
|
1550
|
-
const
|
|
1551
|
-
if (!
|
|
1550
|
+
const i = ds(o.text);
|
|
1551
|
+
if (!i) {
|
|
1552
1552
|
t("a code block without text");
|
|
1553
1553
|
continue;
|
|
1554
1554
|
}
|
|
1555
|
-
const
|
|
1556
|
-
n.push({ ...s, type: "code", ...
|
|
1555
|
+
const a = typeof o.lang == "string" ? { lang: o.lang.slice(0, 32) } : {};
|
|
1556
|
+
n.push({ ...s, type: "code", ...a, text: i });
|
|
1557
1557
|
break;
|
|
1558
1558
|
}
|
|
1559
1559
|
case "divider":
|
|
1560
1560
|
n.push({ ...s, type: "divider" });
|
|
1561
1561
|
break;
|
|
1562
1562
|
case "list": {
|
|
1563
|
-
const
|
|
1564
|
-
for (const c of
|
|
1565
|
-
if (
|
|
1563
|
+
const i = Array.isArray(o.items) ? o.items : [], a = [];
|
|
1564
|
+
for (const c of i) {
|
|
1565
|
+
if (a.length >= fn) {
|
|
1566
1566
|
t(`more than ${fn} list items`);
|
|
1567
1567
|
break;
|
|
1568
1568
|
}
|
|
1569
1569
|
const l = L(c?.text);
|
|
1570
1570
|
if (!l) continue;
|
|
1571
1571
|
const d = L(c?.lead, 200);
|
|
1572
|
-
|
|
1572
|
+
a.push(d ? { lead: d, text: l } : { text: l });
|
|
1573
1573
|
}
|
|
1574
|
-
if (
|
|
1574
|
+
if (a.length === 0) {
|
|
1575
1575
|
t("a list without usable items");
|
|
1576
1576
|
continue;
|
|
1577
1577
|
}
|
|
1578
1578
|
const u = o.style === "numbered" ? "numbered" : "bulleted";
|
|
1579
|
-
n.push({ ...s, type: "list", style: u, items:
|
|
1579
|
+
n.push({ ...s, type: "list", style: u, items: a });
|
|
1580
1580
|
break;
|
|
1581
1581
|
}
|
|
1582
1582
|
case "table": {
|
|
1583
|
-
const
|
|
1584
|
-
for (const d of
|
|
1585
|
-
if (
|
|
1583
|
+
const i = Array.isArray(o.columns) ? o.columns : [], a = [];
|
|
1584
|
+
for (const d of i) {
|
|
1585
|
+
if (a.length >= mn) {
|
|
1586
1586
|
t(`more than ${mn} table columns`);
|
|
1587
1587
|
break;
|
|
1588
1588
|
}
|
|
1589
1589
|
const f = L(d?.label, ke), m = d?.align === "right" ? "right" : void 0;
|
|
1590
|
-
|
|
1590
|
+
a.push(m ? { label: f, align: m } : { label: f });
|
|
1591
1591
|
}
|
|
1592
|
-
if (
|
|
1592
|
+
if (a.length === 0) {
|
|
1593
1593
|
t("a table without columns");
|
|
1594
1594
|
continue;
|
|
1595
1595
|
}
|
|
@@ -1600,82 +1600,82 @@ function Wd(e, t = () => {
|
|
|
1600
1600
|
break;
|
|
1601
1601
|
}
|
|
1602
1602
|
const f = Array.isArray(d) ? d : [];
|
|
1603
|
-
c.push(
|
|
1603
|
+
c.push(a.map((m, b) => L(f[b], ke)));
|
|
1604
1604
|
}
|
|
1605
1605
|
const l = L(o.caption, ke);
|
|
1606
1606
|
n.push({
|
|
1607
1607
|
...s,
|
|
1608
1608
|
type: "table",
|
|
1609
|
-
columns:
|
|
1609
|
+
columns: a,
|
|
1610
1610
|
rows: c,
|
|
1611
1611
|
...l ? { caption: l } : {}
|
|
1612
1612
|
});
|
|
1613
1613
|
break;
|
|
1614
1614
|
}
|
|
1615
1615
|
case "kpi": {
|
|
1616
|
-
const
|
|
1617
|
-
for (const u of
|
|
1618
|
-
if (
|
|
1616
|
+
const i = Array.isArray(o.items) ? o.items : [], a = [];
|
|
1617
|
+
for (const u of i) {
|
|
1618
|
+
if (a.length >= hn) {
|
|
1619
1619
|
t(`more than ${hn} kpi items`);
|
|
1620
1620
|
break;
|
|
1621
1621
|
}
|
|
1622
1622
|
const c = L(u?.value, 40), l = L(u?.label, 80);
|
|
1623
1623
|
if (!c || !l) continue;
|
|
1624
1624
|
const d = u?.tone;
|
|
1625
|
-
|
|
1625
|
+
a.push(
|
|
1626
1626
|
typeof d == "string" && _r.has(d) ? { value: c, label: l, tone: d } : { value: c, label: l }
|
|
1627
1627
|
);
|
|
1628
1628
|
}
|
|
1629
|
-
if (
|
|
1629
|
+
if (a.length === 0) {
|
|
1630
1630
|
t("a kpi block without usable items");
|
|
1631
1631
|
continue;
|
|
1632
1632
|
}
|
|
1633
|
-
n.push({ ...s, type: "kpi", items:
|
|
1633
|
+
n.push({ ...s, type: "kpi", items: a });
|
|
1634
1634
|
break;
|
|
1635
1635
|
}
|
|
1636
1636
|
case "image": {
|
|
1637
|
-
const
|
|
1638
|
-
if (!
|
|
1637
|
+
const i = typeof o.url == "string" ? o.url.trim() : "";
|
|
1638
|
+
if (!i || !$t(i)) {
|
|
1639
1639
|
t("an image without a usable url");
|
|
1640
1640
|
continue;
|
|
1641
1641
|
}
|
|
1642
|
-
const
|
|
1642
|
+
const a = L(o.alt, 200), u = L(o.caption, ke);
|
|
1643
1643
|
n.push({
|
|
1644
1644
|
...s,
|
|
1645
1645
|
type: "image",
|
|
1646
|
-
url:
|
|
1647
|
-
...
|
|
1646
|
+
url: i,
|
|
1647
|
+
...a ? { alt: a } : {},
|
|
1648
1648
|
...u ? { caption: u } : {}
|
|
1649
1649
|
});
|
|
1650
1650
|
break;
|
|
1651
1651
|
}
|
|
1652
1652
|
case "letterhead": {
|
|
1653
|
-
const
|
|
1654
|
-
for (const l of
|
|
1655
|
-
if (
|
|
1653
|
+
const i = Array.isArray(o.fields) ? o.fields : [], a = [];
|
|
1654
|
+
for (const l of i) {
|
|
1655
|
+
if (a.length >= gn) {
|
|
1656
1656
|
t(`more than ${gn} letterhead fields`);
|
|
1657
1657
|
break;
|
|
1658
1658
|
}
|
|
1659
1659
|
const d = l, f = typeof d?.key == "string" ? d.key.slice(0, 48) : "", m = le(d?.value);
|
|
1660
1660
|
if (!f || !m) continue;
|
|
1661
1661
|
const b = le(d?.label, 80);
|
|
1662
|
-
|
|
1662
|
+
a.push(b ? { key: f, label: b, value: m } : { key: f, value: m });
|
|
1663
1663
|
}
|
|
1664
1664
|
const c = (Array.isArray(o.recipient) ? o.recipient : []).slice(0, os).map((l) => le(l)).filter(Boolean);
|
|
1665
|
-
if (
|
|
1665
|
+
if (a.length === 0 && c.length === 0) {
|
|
1666
1666
|
t("a letterhead without fields or recipient");
|
|
1667
1667
|
continue;
|
|
1668
1668
|
}
|
|
1669
1669
|
n.push({
|
|
1670
1670
|
...s,
|
|
1671
1671
|
type: "letterhead",
|
|
1672
|
-
fields:
|
|
1672
|
+
fields: a,
|
|
1673
1673
|
...c.length > 0 ? { recipient: c } : {}
|
|
1674
1674
|
});
|
|
1675
1675
|
break;
|
|
1676
1676
|
}
|
|
1677
1677
|
case "totals": {
|
|
1678
|
-
const
|
|
1678
|
+
const i = (c) => {
|
|
1679
1679
|
const l = Array.isArray(c) ? c : [], d = [];
|
|
1680
1680
|
for (const f of l) {
|
|
1681
1681
|
if (d.length >= yn) {
|
|
@@ -1688,31 +1688,31 @@ function Wd(e, t = () => {
|
|
|
1688
1688
|
);
|
|
1689
1689
|
}
|
|
1690
1690
|
return d;
|
|
1691
|
-
},
|
|
1692
|
-
if (
|
|
1691
|
+
}, a = i(o.rows);
|
|
1692
|
+
if (a.length === 0 && !o.block_id) {
|
|
1693
1693
|
t("a totals block without usable rows");
|
|
1694
1694
|
continue;
|
|
1695
1695
|
}
|
|
1696
|
-
const u =
|
|
1697
|
-
n.push({ ...s, type: "totals", rows:
|
|
1696
|
+
const u = i(o.taxRows);
|
|
1697
|
+
n.push({ ...s, type: "totals", rows: a, ...u.length > 0 ? { taxRows: u } : {} });
|
|
1698
1698
|
break;
|
|
1699
1699
|
}
|
|
1700
1700
|
case "pagebreak":
|
|
1701
1701
|
n.push({ ...s, type: "pagebreak" });
|
|
1702
1702
|
break;
|
|
1703
1703
|
case "callout": {
|
|
1704
|
-
const
|
|
1705
|
-
if (!
|
|
1704
|
+
const i = L(o.text);
|
|
1705
|
+
if (!i) {
|
|
1706
1706
|
t("a callout without text");
|
|
1707
1707
|
continue;
|
|
1708
1708
|
}
|
|
1709
|
-
const
|
|
1709
|
+
const a = L(o.title, 200);
|
|
1710
1710
|
n.push({
|
|
1711
1711
|
...s,
|
|
1712
1712
|
type: "callout",
|
|
1713
1713
|
tone: fs(o.tone),
|
|
1714
|
-
...
|
|
1715
|
-
text:
|
|
1714
|
+
...a ? { title: a } : {},
|
|
1715
|
+
text: i
|
|
1716
1716
|
});
|
|
1717
1717
|
break;
|
|
1718
1718
|
}
|
|
@@ -1876,10 +1876,10 @@ function rf(e, t, n, r) {
|
|
|
1876
1876
|
}
|
|
1877
1877
|
const In = (e) => e.replace(/[\s.\-/]+/g, "").toUpperCase(), _n = (e, t) => Math.abs(Date.parse(`${e}T00:00:00Z`) - Date.parse(`${t}T00:00:00Z`)) / 864e5;
|
|
1878
1878
|
function of(e, t) {
|
|
1879
|
-
const n = e.amountCents > 0, r = Math.abs(e.amountCents), o = n ? "sales_invoice" : "receipt", s = t.documents.filter((g) => g.kind === o && g.openCents > 0),
|
|
1879
|
+
const n = e.amountCents > 0, r = Math.abs(e.amountCents), o = n ? "sales_invoice" : "receipt", s = t.documents.filter((g) => g.kind === o && g.openCents > 0), i = In(`${e.description} ${e.endToEndId ?? ""}`), a = (g) => g.kind === "sales_invoice" ? { kind: "sales_invoice", transactionId: g.id, sourceApp: g.sourceApp ?? "sales" } : { kind: "receipt", receiptId: g.id }, u = s.filter((g) => g.number && i.includes(In(g.number))), c = u.find((g) => g.openCents === r);
|
|
1880
1880
|
if (c)
|
|
1881
1881
|
return {
|
|
1882
|
-
target:
|
|
1882
|
+
target: a(c),
|
|
1883
1883
|
via: "exact",
|
|
1884
1884
|
confidence: "high",
|
|
1885
1885
|
reasons: ["invoice_number", "amount"],
|
|
@@ -1888,7 +1888,7 @@ function of(e, t) {
|
|
|
1888
1888
|
if (u.length === 1 && u[0]) {
|
|
1889
1889
|
const g = u[0];
|
|
1890
1890
|
return {
|
|
1891
|
-
target:
|
|
1891
|
+
target: a(g),
|
|
1892
1892
|
via: "exact",
|
|
1893
1893
|
confidence: "medium",
|
|
1894
1894
|
reasons: ["invoice_number"],
|
|
@@ -1901,7 +1901,7 @@ function of(e, t) {
|
|
|
1901
1901
|
if (g.length === 1 && g[0]) {
|
|
1902
1902
|
const y = g[0];
|
|
1903
1903
|
return {
|
|
1904
|
-
target:
|
|
1904
|
+
target: a(y),
|
|
1905
1905
|
via: "exact",
|
|
1906
1906
|
confidence: "high",
|
|
1907
1907
|
reasons: ["iban", "amount"],
|
|
@@ -1952,8 +1952,8 @@ function of(e, t) {
|
|
|
1952
1952
|
};
|
|
1953
1953
|
}
|
|
1954
1954
|
function sf(e, t, n) {
|
|
1955
|
-
const [r, o] = [e.slice(0, 3), e.slice(3)], s = r === "jl:" ? "journal_line" : "bank_line",
|
|
1956
|
-
return t -
|
|
1955
|
+
const [r, o] = [e.slice(0, 3), e.slice(3)], s = r === "jl:" ? "journal_line" : "bank_line", i = n.filter((a) => a.status === "active").flatMap((a) => a.allocations).filter((a) => a.item.kind === s && a.item.id === o).reduce((a, u) => a + u.amountCents, 0);
|
|
1956
|
+
return t - i;
|
|
1957
1957
|
}
|
|
1958
1958
|
function af(e) {
|
|
1959
1959
|
return e.allocations.reduce((t, n) => t + n.amountCents, 0) === 0;
|
|
@@ -1993,7 +1993,7 @@ function Is(e) {
|
|
|
1993
1993
|
cents: T(d, "CdtDbtInd") === "DBIT" ? -f : f,
|
|
1994
1994
|
date: vs(d)
|
|
1995
1995
|
};
|
|
1996
|
-
}, s = o("OPBD") ?? o("PRCD"),
|
|
1996
|
+
}, s = o("OPBD") ?? o("PRCD"), i = o("CLBD"), a = q(n, "Ntry").flatMap((l, d) => {
|
|
1997
1997
|
if ((T(l, "Sts", "Cd") ?? T(l, "Sts")) === "PDNG") return [];
|
|
1998
1998
|
const f = Oe(T(l, "Amt"));
|
|
1999
1999
|
if (f === void 0) return [];
|
|
@@ -2011,16 +2011,16 @@ function Is(e) {
|
|
|
2011
2011
|
dedupeKey: C ? `ref:${C}` : `seq:${r}:${d + 1}`
|
|
2012
2012
|
}
|
|
2013
2013
|
];
|
|
2014
|
-
}), u =
|
|
2014
|
+
}), u = a.map((l) => l.date).filter(Boolean).sort(), c = T(n, "Acct", "Id", "IBAN");
|
|
2015
2015
|
return {
|
|
2016
2016
|
format: "camt053",
|
|
2017
2017
|
...c ? { iban: c.replace(/\s+/g, "").toUpperCase() } : {},
|
|
2018
2018
|
...T(n, "Acct", "Ccy") ? { currency: T(n, "Acct", "Ccy") } : {},
|
|
2019
2019
|
from: T(n, "FrToDt", "FrDtTm")?.slice(0, 10) ?? s?.date ?? u[0] ?? "",
|
|
2020
|
-
to: T(n, "FrToDt", "ToDtTm")?.slice(0, 10) ??
|
|
2020
|
+
to: T(n, "FrToDt", "ToDtTm")?.slice(0, 10) ?? i?.date ?? u.at(-1) ?? "",
|
|
2021
2021
|
...s ? { openingCents: s.cents } : {},
|
|
2022
|
-
...
|
|
2023
|
-
lines:
|
|
2022
|
+
...i ? { closingCents: i.cents } : {},
|
|
2023
|
+
lines: a
|
|
2024
2024
|
};
|
|
2025
2025
|
}
|
|
2026
2026
|
const Er = (e) => `20${e.slice(0, 2)}-${e.slice(2, 4)}-${e.slice(4, 6)}`;
|
|
@@ -2052,9 +2052,9 @@ function As(e) {
|
|
|
2052
2052
|
const t = e.replace(/\r?\n/g, ""), n = new RegExp("/(" + _s.join("|") + ")/", "g"), r = [...t.matchAll(n)];
|
|
2053
2053
|
if (!r.length) return { description: t.trim() };
|
|
2054
2054
|
const o = {};
|
|
2055
|
-
r.forEach((
|
|
2056
|
-
const u = (
|
|
2057
|
-
o[
|
|
2055
|
+
r.forEach((i, a) => {
|
|
2056
|
+
const u = (i.index ?? 0) + i[0].length, c = r[a + 1]?.index ?? t.length;
|
|
2057
|
+
o[i[1] ?? ""] = t.slice(u, c).replace(/\/$/, "").trim();
|
|
2058
2058
|
});
|
|
2059
2059
|
const s = (o.REMI ?? "").replace(/^(?:USTD|STRD)\/+(?:[A-Z]+\/+)*/, "").trim();
|
|
2060
2060
|
return {
|
|
@@ -2071,22 +2071,22 @@ function ks(e) {
|
|
|
2071
2071
|
const d = /^:(\d{2}[A-Z]?):([\s\S]*)$/.exec(l.trim());
|
|
2072
2072
|
d && n.push({ tag: d[1] ?? "", value: (d[2] ?? "").replace(/\n-}?$/, "").trim() });
|
|
2073
2073
|
}
|
|
2074
|
-
let r, o = "0", s,
|
|
2075
|
-
const
|
|
2074
|
+
let r, o = "0", s, i;
|
|
2075
|
+
const a = [];
|
|
2076
2076
|
let u = 0;
|
|
2077
2077
|
for (const { tag: l, value: d } of n)
|
|
2078
2078
|
if (l === "25") r = d.split("/")[0]?.replace(/\s+/g, "").toUpperCase();
|
|
2079
2079
|
else if (l === "28C")
|
|
2080
2080
|
o = d, u = 0;
|
|
2081
2081
|
else if (l === "60F" || l === "60M") s ??= kn(d);
|
|
2082
|
-
else if (l === "62F" || l === "62M")
|
|
2082
|
+
else if (l === "62F" || l === "62M") i = kn(d);
|
|
2083
2083
|
else if (l === "61") {
|
|
2084
2084
|
const f = d.split(`
|
|
2085
2085
|
`)[0] ?? "", m = /^(\d{6})(\d{4})?(R?[CD])[A-Z]?([\d,]+)(?:N[A-Z0-9]{3})?([^/]*)(?:\/\/(\S+))?/.exec(f);
|
|
2086
2086
|
if (!m) continue;
|
|
2087
2087
|
u++;
|
|
2088
2088
|
const b = Oe(m[4]) ?? 0, h = m[3] === "C" || m[3] === "RD", I = Er(m[1] ?? ""), g = m[2] ? `${I.slice(0, 4)}-${m[2].slice(0, 2)}-${m[2].slice(2, 4)}` : I, y = m[6] ?? m[5]?.trim();
|
|
2089
|
-
|
|
2089
|
+
a.push({
|
|
2090
2090
|
date: g,
|
|
2091
2091
|
valueDate: I,
|
|
2092
2092
|
amountCents: h ? b : -b,
|
|
@@ -2095,19 +2095,19 @@ function ks(e) {
|
|
|
2095
2095
|
dedupeKey: y && y !== "NONREF" ? `ref:${y}` : `seq:${o}:${u}`
|
|
2096
2096
|
});
|
|
2097
2097
|
} else if (l === "86") {
|
|
2098
|
-
const f =
|
|
2098
|
+
const f = a.at(-1);
|
|
2099
2099
|
f && !f.description && Object.assign(f, As(d));
|
|
2100
2100
|
}
|
|
2101
|
-
const c =
|
|
2101
|
+
const c = a.map((l) => l.date).sort();
|
|
2102
2102
|
return {
|
|
2103
2103
|
format: "mt940",
|
|
2104
2104
|
...r && /^[A-Z]{2}\d{2}/.test(r) ? { iban: r } : {},
|
|
2105
2105
|
...s?.currency ? { currency: s.currency } : {},
|
|
2106
2106
|
from: s?.date ?? c[0] ?? "",
|
|
2107
|
-
to:
|
|
2107
|
+
to: i?.date ?? c.at(-1) ?? "",
|
|
2108
2108
|
...s ? { openingCents: s.cents } : {},
|
|
2109
|
-
...
|
|
2110
|
-
lines:
|
|
2109
|
+
...i ? { closingCents: i.cents } : {},
|
|
2110
|
+
lines: a
|
|
2111
2111
|
};
|
|
2112
2112
|
}
|
|
2113
2113
|
function uf(e) {
|
|
@@ -2151,8 +2151,8 @@ function Es(e, t = "") {
|
|
|
2151
2151
|
].join("|"), s = n.get(o) ?? { line: r, net: 0, tax: 0, words: [] };
|
|
2152
2152
|
s.net += r.netCents, s.tax += r.taxCents, r.description && s.words.push(r.description), n.set(o, s);
|
|
2153
2153
|
}
|
|
2154
|
-
return [...n.values()].map(({ line: r, net: o, tax: s, words:
|
|
2155
|
-
description: [...new Set(
|
|
2154
|
+
return [...n.values()].map(({ line: r, net: o, tax: s, words: i }) => ({
|
|
2155
|
+
description: [...new Set(i)].join(", ").slice(0, 120) || t,
|
|
2156
2156
|
netCents: o,
|
|
2157
2157
|
taxCents: s,
|
|
2158
2158
|
taxRateKey: r.taxRateKey,
|
|
@@ -2198,7 +2198,7 @@ function yf(e) {
|
|
|
2198
2198
|
}
|
|
2199
2199
|
const bf = 10 * 6e4;
|
|
2200
2200
|
function vf(e, t, n) {
|
|
2201
|
-
const r = n ? t.filter((s) => (s.direction ?? "sale") === n) : t, o = (s) => r.find((
|
|
2201
|
+
const r = n ? t.filter((s) => (s.direction ?? "sale") === n) : t, o = (s) => r.find((i) => s(i.match));
|
|
2202
2202
|
return e.productId && o((s) => s.productId === e.productId) || e.ledgerCategoryKey && o((s) => s.ledgerCategoryKey === e.ledgerCategoryKey) || o(
|
|
2203
2203
|
(s) => !!s.taxRateKey && !s.productId && !s.ledgerCategoryKey && s.taxRateKey === e.taxRateKey
|
|
2204
2204
|
) || o((s) => !s.productId && !s.ledgerCategoryKey && !s.taxRateKey);
|
|
@@ -2251,8 +2251,8 @@ function Mf(e, t, n) {
|
|
|
2251
2251
|
const r = e.optionKeys ?? [], o = t.options ?? [];
|
|
2252
2252
|
if (o.map((u) => u.key).length !== r.length || r.some((u) => !o.find((c) => c.key === u && c.value.trim())))
|
|
2253
2253
|
return "variant_options_mismatch";
|
|
2254
|
-
const
|
|
2255
|
-
return n.some((u) => u.id !== t.id &&
|
|
2254
|
+
const i = (u) => r.map((c) => u?.find((l) => l.key === c)?.value.trim() ?? "").join("\0"), a = i(o);
|
|
2255
|
+
return n.some((u) => u.id !== t.id && i(u.options) === a) ? "variant_options_duplicate" : null;
|
|
2256
2256
|
}
|
|
2257
2257
|
function wf(e, t) {
|
|
2258
2258
|
return e.archived ? "product_archived" : t ? t.blocked ? "product_blocked" : null : "product_not_released";
|
|
@@ -2312,18 +2312,18 @@ function Tr(e, t, n, r) {
|
|
|
2312
2312
|
(s) => r(s) && s.currency === e.currency && (s.validFrom == null || s.validFrom <= t.at) && (s.validTo == null || s.validTo >= t.at) && (s.minQuantity == null || t.quantity >= s.minQuantity) && (s.productId == null || s.productId === e.id) && (s.categoryKey == null || s.categoryKey === e.categoryKey) && (s.productId != null || s.categoryKey != null)
|
|
2313
2313
|
);
|
|
2314
2314
|
for (const s of ws) {
|
|
2315
|
-
const
|
|
2316
|
-
if (
|
|
2317
|
-
const
|
|
2315
|
+
const i = o.filter((u) => s.matches(u, t));
|
|
2316
|
+
if (i.length === 0) continue;
|
|
2317
|
+
const a = i.reduce((u, c) => {
|
|
2318
2318
|
const l = (c.minQuantity ?? 0) - (u.minQuantity ?? 0);
|
|
2319
2319
|
return l !== 0 ? l > 0 ? c : u : (c.validFrom ?? 0) >= (u.validFrom ?? 0) ? c : u;
|
|
2320
2320
|
});
|
|
2321
|
-
return { rule:
|
|
2321
|
+
return { rule: a, sourceKey: (a.minQuantity ?? 0) > 1 ? "tier" : s.key };
|
|
2322
2322
|
}
|
|
2323
2323
|
return null;
|
|
2324
2324
|
}
|
|
2325
2325
|
function xs(e, t, n) {
|
|
2326
|
-
const r = Tr(e, t, n, (
|
|
2326
|
+
const r = Tr(e, t, n, (i) => !i.rateCardId), o = {
|
|
2327
2327
|
currency: e.currency,
|
|
2328
2328
|
...e.pricePer ? { per: e.pricePer } : {}
|
|
2329
2329
|
};
|
|
@@ -2354,15 +2354,15 @@ function Nf(e, t, n, r) {
|
|
|
2354
2354
|
return o;
|
|
2355
2355
|
const s = t.find((d) => d.id === o.productId);
|
|
2356
2356
|
if (!s) return o;
|
|
2357
|
-
const
|
|
2358
|
-
if (u === o.unitPriceCents &&
|
|
2357
|
+
const i = o.factor ?? 1, a = xs(s, { ...r, quantity: o.quantity * i }, n), u = a.unitPriceCents == null ? 0 : a.unitPriceCents * i;
|
|
2358
|
+
if (u === o.unitPriceCents && a.sourceKey === o.priceSourceKey && a.per === o.pricePer)
|
|
2359
2359
|
return o;
|
|
2360
2360
|
const { pricePer: c, ...l } = o;
|
|
2361
2361
|
return {
|
|
2362
2362
|
...l,
|
|
2363
2363
|
unitPriceCents: u,
|
|
2364
|
-
priceSourceKey:
|
|
2365
|
-
...
|
|
2364
|
+
priceSourceKey: a.sourceKey,
|
|
2365
|
+
...a.per ? { pricePer: a.per } : {}
|
|
2366
2366
|
};
|
|
2367
2367
|
});
|
|
2368
2368
|
}
|
|
@@ -2383,20 +2383,20 @@ function Sn(e) {
|
|
|
2383
2383
|
return n === void 0 ? void 0 : { kind: "flat", micros: n };
|
|
2384
2384
|
}
|
|
2385
2385
|
function $f(e, t) {
|
|
2386
|
-
const n = [], r = [], o = e.split(/\r?\n/), s = (o[0] ?? "").includes(";") ? ";" : ",",
|
|
2386
|
+
const n = [], r = [], o = e.split(/\r?\n/), s = (o[0] ?? "").includes(";") ? ";" : ",", i = t.dimensions, a = t.display.per > 1, u = 1 + i.length + 1;
|
|
2387
2387
|
return o.forEach((c, l) => {
|
|
2388
2388
|
const d = l + 1;
|
|
2389
2389
|
if (!c.trim()) return;
|
|
2390
2390
|
const f = c.split(s).map((x) => x.trim());
|
|
2391
2391
|
if (l === 0 && !Sn(f[u] ?? "")) return;
|
|
2392
2392
|
const m = f[0] ?? "", b = {};
|
|
2393
|
-
|
|
2393
|
+
i.forEach((x, D) => {
|
|
2394
2394
|
const F = f[1 + D] ?? "";
|
|
2395
2395
|
if (!F) return;
|
|
2396
2396
|
const X = /^[+\d\s-]+$/.test(F) ? F.replace(/\D/g, "").replace(/^00/, "") : F;
|
|
2397
2397
|
b[x.key] = x.match === "prefix" ? { prefix: X } : { equals: F };
|
|
2398
2398
|
});
|
|
2399
|
-
const h = f[1 +
|
|
2399
|
+
const h = f[1 + i.length] ?? "", I = h === "" ? 0 : Mr(h), g = Sn(f[u] ?? ""), [y, p] = a ? (f[u + 1] || "1/1").split("/").map(Number) : [1, 1], _ = a ? f[u + 2] ?? "" : "", E = _ === "" ? 0 : Number(_), C = m ? I === void 0 || !g ? "price" : !(y > 0) || !((p ?? y) > 0) || !Number.isFinite(E) ? "increment" : null : "label";
|
|
2400
2400
|
if (C) {
|
|
2401
2401
|
r.push({ line: d, message: C });
|
|
2402
2402
|
return;
|
|
@@ -2442,7 +2442,7 @@ function En(e) {
|
|
|
2442
2442
|
function Ps(e, t) {
|
|
2443
2443
|
let n;
|
|
2444
2444
|
for (const r of t)
|
|
2445
|
-
Object.entries(r.match).every(([s,
|
|
2445
|
+
Object.entries(r.match).every(([s, i]) => $s(i, e.dimensions[s])) && (!n || En(r) > En(n)) && (n = r);
|
|
2446
2446
|
return n;
|
|
2447
2447
|
}
|
|
2448
2448
|
function Ls(e, t) {
|
|
@@ -2452,45 +2452,45 @@ function Ls(e, t) {
|
|
|
2452
2452
|
function Ks(e, t, n) {
|
|
2453
2453
|
const r = t.tiers;
|
|
2454
2454
|
if (t.mode === "volume") {
|
|
2455
|
-
const
|
|
2456
|
-
return
|
|
2457
|
-
micros: P(e *
|
|
2458
|
-
bands: [{ quantity: e, micros:
|
|
2455
|
+
const a = r.find((u) => u.upTo === void 0 || e <= u.upTo) ?? r.at(-1);
|
|
2456
|
+
return a ? {
|
|
2457
|
+
micros: P(e * a.micros / n),
|
|
2458
|
+
bands: [{ quantity: e, micros: a.micros }]
|
|
2459
2459
|
} : { micros: 0, bands: [] };
|
|
2460
2460
|
}
|
|
2461
2461
|
const o = [];
|
|
2462
|
-
let s = 0,
|
|
2463
|
-
for (const
|
|
2462
|
+
let s = 0, i = 0;
|
|
2463
|
+
for (const a of r) {
|
|
2464
2464
|
if (e <= s) break;
|
|
2465
|
-
const u =
|
|
2466
|
-
c > 0 && (o.push({ quantity: c, micros:
|
|
2465
|
+
const u = a.upTo === void 0 ? e : Math.min(e, a.upTo), c = u - s;
|
|
2466
|
+
c > 0 && (o.push({ quantity: c, micros: a.micros }), i += c * a.micros / n), s = u;
|
|
2467
2467
|
}
|
|
2468
|
-
return { micros: P(
|
|
2468
|
+
return { micros: P(i), bands: o };
|
|
2469
2469
|
}
|
|
2470
2470
|
function Pf(e, t, n = "sum") {
|
|
2471
2471
|
const r = [], o = /* @__PURE__ */ new Map();
|
|
2472
|
-
for (const
|
|
2473
|
-
if (
|
|
2474
|
-
const
|
|
2475
|
-
if (!
|
|
2476
|
-
r.push(
|
|
2472
|
+
for (const i of e) {
|
|
2473
|
+
if (i.quantity <= 0) continue;
|
|
2474
|
+
const a = Ps(i, t);
|
|
2475
|
+
if (!a || a.price.kind === "markup" && i.costMicros == null) {
|
|
2476
|
+
r.push(i);
|
|
2477
2477
|
continue;
|
|
2478
2478
|
}
|
|
2479
|
-
const u = o.get(
|
|
2480
|
-
u.ids.push(
|
|
2481
|
-
quantity: Ls(
|
|
2482
|
-
occurredAt:
|
|
2483
|
-
}), u.costMicros +=
|
|
2484
|
-
}
|
|
2485
|
-
return { groups: [...o.values()].map(({ rate:
|
|
2486
|
-
const l = Ns(
|
|
2479
|
+
const u = o.get(a.id) ?? { rate: a, billed: [], ids: [], costMicros: 0 };
|
|
2480
|
+
u.ids.push(i.id), u.billed.push({
|
|
2481
|
+
quantity: Ls(i.quantity, a),
|
|
2482
|
+
occurredAt: i.occurredAt
|
|
2483
|
+
}), u.costMicros += i.costMicros ?? 0, o.set(a.id, u);
|
|
2484
|
+
}
|
|
2485
|
+
return { groups: [...o.values()].map(({ rate: i, billed: a, ids: u, costMicros: c }) => {
|
|
2486
|
+
const l = Ns(a, n), d = Math.min(i.included ?? 0, l), f = l - d, m = i.setupMicros * a.length;
|
|
2487
2487
|
let b, h;
|
|
2488
|
-
|
|
2488
|
+
i.price.kind === "flat" ? b = P(f * i.price.micros / i.unitSize) : i.price.kind === "tiered" ? { micros: b, bands: h } = Ks(f, i.price, i.unitSize) : b = P(c * (1 + i.price.percent / 100));
|
|
2489
2489
|
const I = b + m;
|
|
2490
2490
|
return {
|
|
2491
|
-
rateId:
|
|
2492
|
-
label:
|
|
2493
|
-
records:
|
|
2491
|
+
rateId: i.id,
|
|
2492
|
+
label: i.label,
|
|
2493
|
+
records: a.length,
|
|
2494
2494
|
recordIds: u,
|
|
2495
2495
|
measured: l,
|
|
2496
2496
|
included: d,
|
|
@@ -2506,8 +2506,8 @@ function Lf(e, t, n) {
|
|
|
2506
2506
|
if (t?.price.kind !== "flat" || t.setupMicros || !e.billed) return r;
|
|
2507
2507
|
const o = t.price.micros * n.per / t.unitSize;
|
|
2508
2508
|
if (!Number.isInteger(o / mt)) return r;
|
|
2509
|
-
const s = o / mt,
|
|
2510
|
-
return P(
|
|
2509
|
+
const s = o / mt, i = Math.round(e.billed / n.per * 1e4) / 1e4;
|
|
2510
|
+
return P(i * s) === e.cents ? { quantity: i, unitKey: n.unit, unitPriceCents: s } : r;
|
|
2511
2511
|
}
|
|
2512
2512
|
function wr(e) {
|
|
2513
2513
|
const t = e.usage;
|
|
@@ -2519,8 +2519,8 @@ function Kf(e, t, n, r) {
|
|
|
2519
2519
|
const {
|
|
2520
2520
|
unitKey: o,
|
|
2521
2521
|
id: s,
|
|
2522
|
-
organizationId:
|
|
2523
|
-
productId:
|
|
2522
|
+
organizationId: i,
|
|
2523
|
+
productId: a,
|
|
2524
2524
|
businessEntityId: u,
|
|
2525
2525
|
updatedAt: c,
|
|
2526
2526
|
...l
|
|
@@ -2660,11 +2660,11 @@ function pp(e) {
|
|
|
2660
2660
|
return ne(e.contactLocale) ?? ne(e.companyLocale) ?? ne(e.organizationLocale);
|
|
2661
2661
|
}
|
|
2662
2662
|
function mp(e, t, n, r) {
|
|
2663
|
-
const o = e.filter((
|
|
2663
|
+
const o = e.filter((a) => a.key === t && !a.archived);
|
|
2664
2664
|
if (o.length === 0) return;
|
|
2665
|
-
const s = ne(n),
|
|
2666
|
-
return o.find((
|
|
2667
|
-
o.find((
|
|
2665
|
+
const s = ne(n), i = ne(r);
|
|
2666
|
+
return o.find((a) => ne(a.locale) === s) ?? o.find((a) => ne(a.locale) === i) ?? // A row with no language at all is the single-language case: it is for everybody.
|
|
2667
|
+
o.find((a) => !a.locale) ?? o[0];
|
|
2668
2668
|
}
|
|
2669
2669
|
const Vs = /\{([a-zA-Z0-9_.]+)\}/g;
|
|
2670
2670
|
function xr(e, t) {
|
|
@@ -2680,9 +2680,9 @@ function Hs(e) {
|
|
|
2680
2680
|
}
|
|
2681
2681
|
function zs(e, t, n) {
|
|
2682
2682
|
const r = [];
|
|
2683
|
-
return { text: e.replace(Vs, (s,
|
|
2684
|
-
const
|
|
2685
|
-
return
|
|
2683
|
+
return { text: e.replace(Vs, (s, i) => {
|
|
2684
|
+
const a = xr(t, i);
|
|
2685
|
+
return a == null || a === "" ? (r.includes(i) || r.push(i), n ?? `{${i}}`) : Hs(a);
|
|
2686
2686
|
}), unresolved: r };
|
|
2687
2687
|
}
|
|
2688
2688
|
function Ys(e, t) {
|
|
@@ -2695,7 +2695,7 @@ function Ys(e, t) {
|
|
|
2695
2695
|
return e.equals !== void 0 ? n === e.equals : !0;
|
|
2696
2696
|
}
|
|
2697
2697
|
function hp(e, t, n, r, o) {
|
|
2698
|
-
const s = [],
|
|
2698
|
+
const s = [], i = [], a = /* @__PURE__ */ new Set(), u = (c) => {
|
|
2699
2699
|
const l = zs(c, t, o);
|
|
2700
2700
|
for (const d of l.unresolved) s.includes(d) || s.push(d);
|
|
2701
2701
|
return l.text;
|
|
@@ -2704,27 +2704,27 @@ function hp(e, t, n, r, o) {
|
|
|
2704
2704
|
if (c.block_id && !Ys(n?.[c.block_id], t)) continue;
|
|
2705
2705
|
const l = c.block_id ? r?.[c.block_id] : void 0;
|
|
2706
2706
|
if (l && c.block_id) {
|
|
2707
|
-
|
|
2707
|
+
a.add(c.block_id), i.push(...l);
|
|
2708
2708
|
continue;
|
|
2709
2709
|
}
|
|
2710
2710
|
switch (c.type) {
|
|
2711
2711
|
case "heading":
|
|
2712
2712
|
case "paragraph":
|
|
2713
2713
|
case "quote":
|
|
2714
|
-
|
|
2714
|
+
i.push({ ...c, text: u(c.text) });
|
|
2715
2715
|
break;
|
|
2716
2716
|
case "callout":
|
|
2717
|
-
|
|
2717
|
+
i.push({
|
|
2718
2718
|
...c,
|
|
2719
2719
|
...c.title ? { title: u(c.title) } : {},
|
|
2720
2720
|
text: u(c.text)
|
|
2721
2721
|
});
|
|
2722
2722
|
break;
|
|
2723
2723
|
case "code":
|
|
2724
|
-
|
|
2724
|
+
i.push(c);
|
|
2725
2725
|
break;
|
|
2726
2726
|
case "list":
|
|
2727
|
-
|
|
2727
|
+
i.push({
|
|
2728
2728
|
...c,
|
|
2729
2729
|
items: c.items.map((d) => ({
|
|
2730
2730
|
...d.lead ? { lead: u(d.lead) } : {},
|
|
@@ -2733,7 +2733,7 @@ function hp(e, t, n, r, o) {
|
|
|
2733
2733
|
});
|
|
2734
2734
|
break;
|
|
2735
2735
|
case "table":
|
|
2736
|
-
|
|
2736
|
+
i.push({
|
|
2737
2737
|
...c,
|
|
2738
2738
|
columns: c.columns.map((d) => ({ ...d, label: u(d.label) })),
|
|
2739
2739
|
rows: c.rows.map((d) => d.map(u)),
|
|
@@ -2741,7 +2741,7 @@ function hp(e, t, n, r, o) {
|
|
|
2741
2741
|
});
|
|
2742
2742
|
break;
|
|
2743
2743
|
case "kpi":
|
|
2744
|
-
|
|
2744
|
+
i.push({
|
|
2745
2745
|
...c,
|
|
2746
2746
|
items: c.items.map((d) => ({
|
|
2747
2747
|
...d,
|
|
@@ -2751,14 +2751,14 @@ function hp(e, t, n, r, o) {
|
|
|
2751
2751
|
});
|
|
2752
2752
|
break;
|
|
2753
2753
|
case "letterhead":
|
|
2754
|
-
|
|
2754
|
+
i.push({
|
|
2755
2755
|
...c,
|
|
2756
2756
|
fields: c.fields.map((d) => ({ ...d, value: u(d.value) })),
|
|
2757
2757
|
...c.recipient ? { recipient: c.recipient.map(u) } : {}
|
|
2758
2758
|
});
|
|
2759
2759
|
break;
|
|
2760
2760
|
case "totals":
|
|
2761
|
-
|
|
2761
|
+
i.push({
|
|
2762
2762
|
...c,
|
|
2763
2763
|
rows: c.rows.map((d) => ({
|
|
2764
2764
|
...d,
|
|
@@ -2775,20 +2775,20 @@ function hp(e, t, n, r, o) {
|
|
|
2775
2775
|
});
|
|
2776
2776
|
break;
|
|
2777
2777
|
case "image":
|
|
2778
|
-
|
|
2778
|
+
i.push({
|
|
2779
2779
|
...c,
|
|
2780
2780
|
url: u(c.url),
|
|
2781
2781
|
...c.alt ? { alt: u(c.alt) } : {}
|
|
2782
2782
|
});
|
|
2783
2783
|
break;
|
|
2784
2784
|
default:
|
|
2785
|
-
|
|
2785
|
+
i.push(c);
|
|
2786
2786
|
}
|
|
2787
2787
|
}
|
|
2788
2788
|
return {
|
|
2789
|
-
blocks:
|
|
2789
|
+
blocks: i,
|
|
2790
2790
|
unresolved: s,
|
|
2791
|
-
unusedSlots: Object.keys(r ?? {}).filter((c) => !
|
|
2791
|
+
unusedSlots: Object.keys(r ?? {}).filter((c) => !a.has(c))
|
|
2792
2792
|
};
|
|
2793
2793
|
}
|
|
2794
2794
|
function Xs(e) {
|
|
@@ -2831,14 +2831,14 @@ function yp(e) {
|
|
|
2831
2831
|
}
|
|
2832
2832
|
async function bp(e, t, n, r, o = Date.now()) {
|
|
2833
2833
|
const s = [];
|
|
2834
|
-
for (const
|
|
2834
|
+
for (const i of n)
|
|
2835
2835
|
try {
|
|
2836
|
-
s.push(await r(
|
|
2837
|
-
} catch (
|
|
2836
|
+
s.push(await r(i));
|
|
2837
|
+
} catch (a) {
|
|
2838
2838
|
s.push({
|
|
2839
|
-
caseId:
|
|
2839
|
+
caseId: i.id,
|
|
2840
2840
|
ok: !1,
|
|
2841
|
-
note: `beoordeling mislukt: ${
|
|
2841
|
+
note: `beoordeling mislukt: ${a?.message ?? String(a)}`
|
|
2842
2842
|
});
|
|
2843
2843
|
}
|
|
2844
2844
|
return Qs(e, t, s, o);
|
|
@@ -2848,17 +2848,17 @@ function Js(e, t) {
|
|
|
2848
2848
|
const n = De(t.from), r = De(t.to) + ze;
|
|
2849
2849
|
if (!(r > n)) return [{ month: [t.from.slice(0, 7), "-01"].join(""), cents: e }];
|
|
2850
2850
|
const o = [];
|
|
2851
|
-
for (let
|
|
2852
|
-
const
|
|
2853
|
-
if (
|
|
2854
|
-
const u = Date.UTC(
|
|
2855
|
-
o.push({ month: Zs(
|
|
2851
|
+
for (let i = new Date(n); ; ) {
|
|
2852
|
+
const a = Date.UTC(i.getUTCFullYear(), i.getUTCMonth(), 1);
|
|
2853
|
+
if (a >= r) break;
|
|
2854
|
+
const u = Date.UTC(i.getUTCFullYear(), i.getUTCMonth() + 1, 1), c = Math.round((Math.min(u, r) - Math.max(a, n)) / ze);
|
|
2855
|
+
o.push({ month: Zs(a), share: c / Math.round((u - a) / ze) }), i = new Date(u);
|
|
2856
2856
|
}
|
|
2857
2857
|
const s = Le(
|
|
2858
2858
|
e,
|
|
2859
|
-
o.map((
|
|
2859
|
+
o.map((i) => i.share)
|
|
2860
2860
|
);
|
|
2861
|
-
return o.map((
|
|
2861
|
+
return o.map((i, a) => ({ month: i.month, cents: s[a] }));
|
|
2862
2862
|
}
|
|
2863
2863
|
function ei(e) {
|
|
2864
2864
|
const t = new Date(De(e.from)), n = new Date(De(e.to));
|
|
@@ -2866,52 +2866,52 @@ function ei(e) {
|
|
|
2866
2866
|
}
|
|
2867
2867
|
const Lt = 864e5, Ue = (e) => new Date(e).toISOString().slice(0, 10), Ne = (e) => Date.parse(`${e}T00:00:00Z`);
|
|
2868
2868
|
function ve(e, t) {
|
|
2869
|
-
const [n, r, o] = e.split("-").map(Number), s = new Date(Date.UTC(n, r - 1 + t, 1)),
|
|
2869
|
+
const [n, r, o] = e.split("-").map(Number), s = new Date(Date.UTC(n, r - 1 + t, 1)), i = new Date(
|
|
2870
2870
|
Date.UTC(s.getUTCFullYear(), s.getUTCMonth() + 1, 0)
|
|
2871
2871
|
).getUTCDate();
|
|
2872
|
-
return s.setUTCDate(Math.min(o,
|
|
2872
|
+
return s.setUTCDate(Math.min(o, i)), Ue(s.getTime());
|
|
2873
2873
|
}
|
|
2874
2874
|
function Or(e) {
|
|
2875
2875
|
const t = Math.max(1, Math.round(e.termMonths)), n = Number(e.ratePercent) / 100 / 12, r = e.principalCents, o = n === 0 ? r / t : r * n / (1 - (1 + n) ** -t), s = [];
|
|
2876
|
-
let
|
|
2877
|
-
for (let
|
|
2878
|
-
const u = Math.round(
|
|
2876
|
+
let i = r;
|
|
2877
|
+
for (let a = 1; a <= t; a++) {
|
|
2878
|
+
const u = Math.round(i * n);
|
|
2879
2879
|
let c = e.method === "annuity" ? Math.round(o) - u : e.method === "linear" ? Math.round(r / t) : 0;
|
|
2880
|
-
|
|
2881
|
-
sequence:
|
|
2882
|
-
dueOn: ve(e.firstDueOn,
|
|
2880
|
+
a === t && (c = i), c = Math.min(c, i), i -= c, s.push({
|
|
2881
|
+
sequence: a,
|
|
2882
|
+
dueOn: ve(e.firstDueOn, a - 1),
|
|
2883
2883
|
interestCents: u,
|
|
2884
2884
|
principalCents: c,
|
|
2885
|
-
remainingCents:
|
|
2885
|
+
remainingCents: i
|
|
2886
2886
|
});
|
|
2887
2887
|
}
|
|
2888
2888
|
return s;
|
|
2889
2889
|
}
|
|
2890
2890
|
function vp(e, t, n, r) {
|
|
2891
2891
|
const o = Number(r) / 100 / 365, s = [...e].sort((c, l) => c.date.localeCompare(l.date));
|
|
2892
|
-
let
|
|
2893
|
-
|
|
2892
|
+
let i = s.filter((c) => c.date < t).reduce((c, l) => c + l.cents, 0), a = s.findIndex((c) => c.date >= t);
|
|
2893
|
+
a < 0 && (a = s.length);
|
|
2894
2894
|
let u = 0;
|
|
2895
2895
|
for (let c = Ne(t); c <= Ne(n); c += Lt) {
|
|
2896
2896
|
const l = Ue(c);
|
|
2897
|
-
for (;
|
|
2898
|
-
|
|
2899
|
-
u +=
|
|
2897
|
+
for (; a < s.length && (s[a]?.date ?? "") <= l; )
|
|
2898
|
+
i += s[a]?.cents ?? 0, a++;
|
|
2899
|
+
u += i * o;
|
|
2900
2900
|
}
|
|
2901
2901
|
return Math.round(u);
|
|
2902
2902
|
}
|
|
2903
2903
|
function Ip(e, t, n) {
|
|
2904
|
-
const r = n === "quarterly" ? 3 : 12, [o, s] = e.split("-").map(Number),
|
|
2905
|
-
let u = `${o}-${String(
|
|
2904
|
+
const r = n === "quarterly" ? 3 : 12, [o, s] = e.split("-").map(Number), i = n === "quarterly" ? Math.floor((s - 1) / 3) * 3 + 1 : 1, a = [];
|
|
2905
|
+
let u = `${o}-${String(i).padStart(2, "0")}-01`;
|
|
2906
2906
|
for (let c = 1; u <= t && c < 400; c++) {
|
|
2907
2907
|
const l = ve(u, r);
|
|
2908
|
-
|
|
2908
|
+
a.push({
|
|
2909
2909
|
sequence: c,
|
|
2910
2910
|
from: u < e ? e : u,
|
|
2911
2911
|
to: Ue(Ne(l) - Lt)
|
|
2912
2912
|
}), u = l;
|
|
2913
2913
|
}
|
|
2914
|
-
return
|
|
2914
|
+
return a;
|
|
2915
2915
|
}
|
|
2916
2916
|
const ti = 5e7, ni = [
|
|
2917
2917
|
"director",
|
|
@@ -2960,19 +2960,19 @@ function Dr(e, t) {
|
|
|
2960
2960
|
const n = Math.max(1, Math.round(t)), r = Math.trunc(e / n);
|
|
2961
2961
|
return Array.from({ length: n }, (o, s) => s === n - 1 ? e - r * (n - 1) : r);
|
|
2962
2962
|
}
|
|
2963
|
-
function Nr(e, t, n, r, o, s,
|
|
2964
|
-
return t.map((
|
|
2965
|
-
cents:
|
|
2966
|
-
sequence:
|
|
2963
|
+
function Nr(e, t, n, r, o, s, i = 1) {
|
|
2964
|
+
return t.map((a, u) => ({
|
|
2965
|
+
cents: a,
|
|
2966
|
+
sequence: i + u,
|
|
2967
2967
|
dueOn: ri(ve(n, u))
|
|
2968
|
-
})).filter((
|
|
2968
|
+
})).filter((a) => a.dueOn <= r && a.cents !== 0).map((a) => ({
|
|
2969
2969
|
financingItemId: e,
|
|
2970
|
-
sequence:
|
|
2971
|
-
dueOn:
|
|
2972
|
-
lines: o(
|
|
2970
|
+
sequence: a.sequence,
|
|
2971
|
+
dueOn: a.dueOn,
|
|
2972
|
+
lines: o(a.cents, a.sequence),
|
|
2973
2973
|
expectedBankCents: 0,
|
|
2974
2974
|
settlesVia: "direct",
|
|
2975
|
-
label: s(
|
|
2975
|
+
label: s(a.sequence)
|
|
2976
2976
|
}));
|
|
2977
2977
|
}
|
|
2978
2978
|
const Tn = 600;
|
|
@@ -2985,13 +2985,13 @@ function oi(e) {
|
|
|
2985
2985
|
}
|
|
2986
2986
|
const o = Number(String(e.ratePercent ?? "0").replace(",", ".")) / 100;
|
|
2987
2987
|
if (!(o > 0 && o < 1)) return [];
|
|
2988
|
-
const s = 1 - (1 - o) ** (1 / 12),
|
|
2989
|
-
let
|
|
2990
|
-
for (;
|
|
2991
|
-
const u = Math.max(1, Math.round(
|
|
2992
|
-
|
|
2988
|
+
const s = 1 - (1 - o) ** (1 / 12), i = [];
|
|
2989
|
+
let a = n;
|
|
2990
|
+
for (; a > e.residualCents && i.length < Tn; ) {
|
|
2991
|
+
const u = Math.max(1, Math.round(a * s)), c = a - u <= e.residualCents || i.length === Tn - 1;
|
|
2992
|
+
i.push(c ? a - e.residualCents : u), a -= i[i.length - 1] ?? 0;
|
|
2993
2993
|
}
|
|
2994
|
-
return
|
|
2994
|
+
return i;
|
|
2995
2995
|
}
|
|
2996
2996
|
function Cp(e, t) {
|
|
2997
2997
|
const n = e.terms;
|
|
@@ -3002,13 +3002,13 @@ function Cp(e, t) {
|
|
|
3002
3002
|
r,
|
|
3003
3003
|
n.restart?.fromMonth ?? n.acquiredOn,
|
|
3004
3004
|
t,
|
|
3005
|
-
(s,
|
|
3005
|
+
(s, i) => [
|
|
3006
3006
|
{ accountId: n.depreciationAccountId, amountCents: s, description: e.name },
|
|
3007
3007
|
{
|
|
3008
3008
|
accountId: n.accumulatedAccountId,
|
|
3009
3009
|
amountCents: -s,
|
|
3010
3010
|
subAccountId: e.id,
|
|
3011
|
-
description: `Afschrijving ${
|
|
3011
|
+
description: `Afschrijving ${i}/${o}`
|
|
3012
3012
|
}
|
|
3013
3013
|
],
|
|
3014
3014
|
(s) => `Afschrijving ${s}/${o}`,
|
|
@@ -3032,7 +3032,7 @@ function Sp(e, t) {
|
|
|
3032
3032
|
subAccountId: e.id,
|
|
3033
3033
|
description: e.name
|
|
3034
3034
|
});
|
|
3035
|
-
const o = r.reduce((s,
|
|
3035
|
+
const o = r.reduce((s, i) => s + i.amountCents, 0);
|
|
3036
3036
|
return o && r.push({ accountId: t.disposalAccountId, amountCents: -o, description: e.name }), r;
|
|
3037
3037
|
}
|
|
3038
3038
|
function Ep(e, t) {
|
|
@@ -3062,10 +3062,10 @@ function Mp(e, t) {
|
|
|
3062
3062
|
return Or(e).filter((r) => r.dueOn > t && r.dueOn <= n).reduce((r, o) => r + o.principalCents, 0);
|
|
3063
3063
|
}
|
|
3064
3064
|
function wp(e, t) {
|
|
3065
|
-
const n = e.terms, r = n.quantity ?? 1, o = (d) => Math.round(d * t.quantity / r), s = o(n.costCents),
|
|
3066
|
-
|
|
3065
|
+
const n = e.terms, r = n.quantity ?? 1, o = (d) => Math.round(d * t.quantity / r), s = o(n.costCents), i = o(n.residualCents), a = o(-t.movementsCents), u = [], c = `${e.name} (${t.quantity}/${r})`;
|
|
3066
|
+
a && u.push({
|
|
3067
3067
|
accountId: n.accumulatedAccountId,
|
|
3068
|
-
amountCents:
|
|
3068
|
+
amountCents: a,
|
|
3069
3069
|
subAccountId: e.id,
|
|
3070
3070
|
description: c
|
|
3071
3071
|
}), t.proceedsCents && u.push({
|
|
@@ -3074,7 +3074,7 @@ function wp(e, t) {
|
|
|
3074
3074
|
description: c
|
|
3075
3075
|
}), u.push({ accountId: e.ledgerAccountId, amountCents: -s, description: c });
|
|
3076
3076
|
const l = u.reduce((d, f) => d + f.amountCents, 0);
|
|
3077
|
-
return l && u.push({ accountId: t.disposalAccountId, amountCents: -l, description: c }), { lines: u, costCents: s, residualCents:
|
|
3077
|
+
return l && u.push({ accountId: t.disposalAccountId, amountCents: -l, description: c }), { lines: u, costCents: s, residualCents: i };
|
|
3078
3078
|
}
|
|
3079
3079
|
const si = { NL: 45e3 }, xp = (e, t) => t ?? si[(e ?? "NL").toUpperCase()], Op = [
|
|
3080
3080
|
{
|
|
@@ -3208,8 +3208,8 @@ function Up(e, t) {
|
|
|
3208
3208
|
const u = Math.min(s * 2, 30);
|
|
3209
3209
|
n += u, s >= 1 && r.push(`waiting:${Math.round(s)}h`);
|
|
3210
3210
|
}
|
|
3211
|
-
const
|
|
3212
|
-
return
|
|
3211
|
+
const i = e.lastActivityPreview;
|
|
3212
|
+
return i?.type === "AI_ACTION_PROPOSED" && (n += 30, r.push("awaiting-approval")), i?.direction === "outbound" && $r(i.type) && (n += 10, r.push("no-reply")), !e.firstResponseAt && e.lastActivityPreview?.direction === "inbound" && (n += 10, r.push("awaiting-reply")), (e.tags?.some((u) => u === "marketing" || u === "automated") || ui(e.remoteParty?.resource, e.lastActivityPreview?.snippet)) && (n -= yi, r.push("bulk")), { score: n, reasons: r };
|
|
3213
3213
|
}
|
|
3214
3214
|
const Bp = (e) => !!e.assignedUserId || !!e.assignedInboxId, Fp = (e) => e.status === "closed", jp = (e) => ({
|
|
3215
3215
|
urgent: 10,
|
|
@@ -3274,7 +3274,7 @@ function Si(e, t) {
|
|
|
3274
3274
|
function Zp(e, t, n) {
|
|
3275
3275
|
if (!e) return !0;
|
|
3276
3276
|
if (e === t) return !1;
|
|
3277
|
-
const r = new Map(n.map((
|
|
3277
|
+
const r = new Map(n.map((i) => [i.id, i]));
|
|
3278
3278
|
if (!r.has(e) || t && Ei(e, t, r)) return !1;
|
|
3279
3279
|
const o = Si(e, r), s = t ? Ur(t, n) : 1;
|
|
3280
3280
|
return o + s <= Kr;
|
|
@@ -3310,18 +3310,18 @@ function em(e, t, n) {
|
|
|
3310
3310
|
return r.find((o) => o.locale === t)?.name ?? (n ? r.find((o) => o.locale === n)?.name : void 0) ?? e.name;
|
|
3311
3311
|
}
|
|
3312
3312
|
function tm(e, t) {
|
|
3313
|
-
const n = (
|
|
3314
|
-
...
|
|
3315
|
-
priorCents: r.get(n(
|
|
3316
|
-
})), s = new Set(o.map(n)),
|
|
3317
|
-
return
|
|
3318
|
-
if (s.has(n(
|
|
3319
|
-
const c =
|
|
3313
|
+
const n = (a) => `${a.level}:${a.key}`, r = new Map((t?.rows ?? []).map((a) => [n(a), a])), o = e.rows.map((a) => ({
|
|
3314
|
+
...a,
|
|
3315
|
+
priorCents: r.get(n(a))?.amountCents ?? 0
|
|
3316
|
+
})), s = new Set(o.map(n)), i = t?.rows ?? [];
|
|
3317
|
+
return i.forEach((a, u) => {
|
|
3318
|
+
if (s.has(n(a))) return;
|
|
3319
|
+
const c = i.slice(0, u).reverse().find((f) => f.level < a.level);
|
|
3320
3320
|
let l = o.length;
|
|
3321
3321
|
const d = c ? o.findIndex((f) => n(f) === n(c)) : -1;
|
|
3322
3322
|
if (d >= 0)
|
|
3323
3323
|
for (l = d + 1; l < o.length && (o[l]?.level ?? 0) > (c?.level ?? 0); ) l += 1;
|
|
3324
|
-
o.splice(l, 0, { ...
|
|
3324
|
+
o.splice(l, 0, { ...a, amountCents: 0, priorCents: a.amountCents }), s.add(n(a));
|
|
3325
3325
|
}), o;
|
|
3326
3326
|
}
|
|
3327
3327
|
function nm(e, t, n) {
|
|
@@ -3342,16 +3342,16 @@ function nm(e, t, n) {
|
|
|
3342
3342
|
const wi = ["revenue", "expense"], Be = (e) => wi.includes(e.type), xi = (e) => (e.reportGroup ?? e.type).split(".")[0] ?? e.type;
|
|
3343
3343
|
function Br(e, t, n, r) {
|
|
3344
3344
|
const o = /* @__PURE__ */ new Map();
|
|
3345
|
-
for (const
|
|
3346
|
-
if (!t(
|
|
3347
|
-
const
|
|
3348
|
-
c.set(u, [...c.get(u) ?? [],
|
|
3345
|
+
for (const i of [...e].sort((a, u) => a.code.localeCompare(u.code))) {
|
|
3346
|
+
if (!t(i)) continue;
|
|
3347
|
+
const a = xi(i), u = i.reportGroup ?? a, c = o.get(a) ?? /* @__PURE__ */ new Map();
|
|
3348
|
+
c.set(u, [...c.get(u) ?? [], i]), o.set(a, c);
|
|
3349
3349
|
}
|
|
3350
3350
|
const s = [];
|
|
3351
|
-
for (const [
|
|
3352
|
-
const u = n(
|
|
3353
|
-
s.push({ key:
|
|
3354
|
-
for (const [d, f] of
|
|
3351
|
+
for (const [i, a] of o) {
|
|
3352
|
+
const u = n(i), c = (d) => u === "debit" ? t(d) : -t(d), l = [...a.values()].flat().reduce((d, f) => d + c(f), 0);
|
|
3353
|
+
s.push({ key: i, label: r(i), level: 0, side: u, amountCents: l });
|
|
3354
|
+
for (const [d, f] of a) {
|
|
3355
3355
|
s.push({
|
|
3356
3356
|
key: d,
|
|
3357
3357
|
label: r(d),
|
|
@@ -3376,31 +3376,31 @@ function rm(e, t, n, r = (o) => o) {
|
|
|
3376
3376
|
const o = e.filter(Be), s = (u) => {
|
|
3377
3377
|
const c = t.get(u.id);
|
|
3378
3378
|
return c ? c.debitCents - c.creditCents : 0;
|
|
3379
|
-
},
|
|
3379
|
+
}, i = Br(
|
|
3380
3380
|
o,
|
|
3381
3381
|
s,
|
|
3382
3382
|
(u) => u === "revenue" || u === "financial" ? "credit" : "debit",
|
|
3383
3383
|
r
|
|
3384
|
-
),
|
|
3385
|
-
return { kind: "profit_and_loss", ...n, rows:
|
|
3384
|
+
), a = -o.reduce((u, c) => u + s(c), 0);
|
|
3385
|
+
return { kind: "profit_and_loss", ...n, rows: i, totals: { resultCents: a }, source: "finance" };
|
|
3386
3386
|
}
|
|
3387
3387
|
function om(e, t, n, r, o = (s) => s) {
|
|
3388
|
-
const s = e.filter((l) => !Be(l)),
|
|
3388
|
+
const s = e.filter((l) => !Be(l)), a = Br(
|
|
3389
3389
|
s,
|
|
3390
3390
|
(l) => t.get(l.id)?.closingCents ?? 0,
|
|
3391
3391
|
(l) => l === "assets" ? "debit" : "credit",
|
|
3392
3392
|
o
|
|
3393
3393
|
);
|
|
3394
3394
|
if (r) {
|
|
3395
|
-
|
|
3395
|
+
a.push({
|
|
3396
3396
|
key: "equity.result_unappropriated",
|
|
3397
3397
|
label: o("equity.result_unappropriated"),
|
|
3398
3398
|
level: 1,
|
|
3399
3399
|
side: "credit",
|
|
3400
3400
|
amountCents: r
|
|
3401
3401
|
});
|
|
3402
|
-
const l =
|
|
3403
|
-
l ? l.amountCents += r :
|
|
3402
|
+
const l = a.find((d) => d.level === 0 && d.key === "equity");
|
|
3403
|
+
l ? l.amountCents += r : a.push({
|
|
3404
3404
|
key: "equity",
|
|
3405
3405
|
label: o("equity"),
|
|
3406
3406
|
level: 0,
|
|
@@ -3408,12 +3408,12 @@ function om(e, t, n, r, o = (s) => s) {
|
|
|
3408
3408
|
amountCents: r
|
|
3409
3409
|
});
|
|
3410
3410
|
}
|
|
3411
|
-
const u =
|
|
3411
|
+
const u = a.filter((l) => l.level === 0 && l.side === "debit").reduce((l, d) => l + d.amountCents, 0), c = a.filter((l) => l.level === 0 && l.side === "credit").reduce((l, d) => l + d.amountCents, 0);
|
|
3412
3412
|
return {
|
|
3413
3413
|
kind: "balance",
|
|
3414
3414
|
from: n.from,
|
|
3415
3415
|
to: n.to,
|
|
3416
|
-
rows:
|
|
3416
|
+
rows: a,
|
|
3417
3417
|
totals: { debitCents: u, creditCents: c },
|
|
3418
3418
|
source: "finance"
|
|
3419
3419
|
};
|
|
@@ -3437,39 +3437,39 @@ function sm(e, t) {
|
|
|
3437
3437
|
});
|
|
3438
3438
|
}
|
|
3439
3439
|
function im(e, t, n, r = 13) {
|
|
3440
|
-
const o = Date.parse(`${n}T00:00:00Z`), s = Array.from({ length: r }, (
|
|
3440
|
+
const o = Date.parse(`${n}T00:00:00Z`), s = Array.from({ length: r }, (a, u) => ({
|
|
3441
3441
|
from: new Date(o + u * 7 * 864e5).toISOString().slice(0, 10),
|
|
3442
3442
|
inCents: 0,
|
|
3443
3443
|
outCents: 0,
|
|
3444
3444
|
closingCents: 0
|
|
3445
3445
|
}));
|
|
3446
|
-
for (const
|
|
3446
|
+
for (const a of t) {
|
|
3447
3447
|
const u = Math.max(
|
|
3448
3448
|
0,
|
|
3449
|
-
Math.floor((Date.parse(`${
|
|
3449
|
+
Math.floor((Date.parse(`${a.date}T00:00:00Z`) - o) / 6048e5)
|
|
3450
3450
|
), c = s[u];
|
|
3451
|
-
c && (
|
|
3451
|
+
c && (a.cents >= 0 ? c.inCents += a.cents : c.outCents -= a.cents);
|
|
3452
3452
|
}
|
|
3453
|
-
let
|
|
3454
|
-
for (const
|
|
3455
|
-
|
|
3453
|
+
let i = e;
|
|
3454
|
+
for (const a of s)
|
|
3455
|
+
i += a.inCents - a.outCents, a.closingCents = i;
|
|
3456
3456
|
return s;
|
|
3457
3457
|
}
|
|
3458
3458
|
function am(e) {
|
|
3459
3459
|
const t = new Map(e.accounts.map((s) => [s.id, s])), n = /* @__PURE__ */ new Map();
|
|
3460
3460
|
for (const s of e.lines) {
|
|
3461
|
-
const
|
|
3462
|
-
!
|
|
3461
|
+
const i = t.get(s.accountId);
|
|
3462
|
+
!i || !Be(i) || n.set(s.accountId, (n.get(s.accountId) ?? 0) + s.functionalCents);
|
|
3463
3463
|
}
|
|
3464
3464
|
const r = [];
|
|
3465
3465
|
let o = 0;
|
|
3466
|
-
for (const [s,
|
|
3467
|
-
|
|
3466
|
+
for (const [s, i] of [...n.entries()].sort(([a], [u]) => a.localeCompare(u)))
|
|
3467
|
+
i && (r.push({
|
|
3468
3468
|
accountId: s,
|
|
3469
|
-
amountCents: -
|
|
3470
|
-
functionalCents: -
|
|
3469
|
+
amountCents: -i,
|
|
3470
|
+
functionalCents: -i,
|
|
3471
3471
|
currency: e.currency
|
|
3472
|
-
}), o +=
|
|
3472
|
+
}), o += i);
|
|
3473
3473
|
return r.length && r.push({
|
|
3474
3474
|
accountId: e.resultAccountId,
|
|
3475
3475
|
amountCents: o,
|
|
@@ -3642,12 +3642,12 @@ const A = (e, t, n, r, o, s) => ({ code: e, name: t, type: n, reportGroup: r, rg
|
|
|
3642
3642
|
function um(e, t) {
|
|
3643
3643
|
const n = [];
|
|
3644
3644
|
e.lines.length < 2 && n.push({ code: "entry_too_few_lines" });
|
|
3645
|
-
const r = e.lines.reduce((s,
|
|
3645
|
+
const r = e.lines.reduce((s, i) => s + i.functionalCents, 0);
|
|
3646
3646
|
r !== 0 && n.push({ code: "entry_unbalanced", params: { cents: String(r) } });
|
|
3647
3647
|
const o = new Map(t.accounts.map((s) => [s.id, s]));
|
|
3648
3648
|
for (const s of e.lines) {
|
|
3649
|
-
const
|
|
3650
|
-
|
|
3649
|
+
const i = o.get(s.accountId);
|
|
3650
|
+
i ? i.archived ? n.push({ code: "entry_account_archived", params: { account: i.code } }) : i.requiresSubAccount && !s.subAccountId && n.push({ code: "entry_sub_account_required", params: { account: i.code } }) : n.push({ code: "entry_unknown_account", params: { account: s.accountId } });
|
|
3651
3651
|
}
|
|
3652
3652
|
return t.period ? (t.period.status === "locked" && t.allow !== "locked" || t.period.status === "closed" && !t.allow) && n.push({ code: "entry_period_closed", params: { day: e.date } }) : n.push({ code: "entry_no_period", params: { day: e.date } }), n;
|
|
3653
3653
|
}
|
|
@@ -3691,7 +3691,7 @@ function fm(e) {
|
|
|
3691
3691
|
}));
|
|
3692
3692
|
}
|
|
3693
3693
|
function Fr(e, t, n) {
|
|
3694
|
-
const r = t.filter((s) => s.appliesTo.direction === n.direction).filter((s) => !s.appliesTo.kind || s.appliesTo.kind === n.kind).sort((s,
|
|
3694
|
+
const r = t.filter((s) => s.appliesTo.direction === n.direction).filter((s) => !s.appliesTo.kind || s.appliesTo.kind === n.kind).sort((s, i) => s.order - i.order), o = (s) => r.find((i) => s(i.match));
|
|
3695
3695
|
return e.productId && o((s) => s.productId === e.productId) || e.ledgerCategoryKey && o((s) => s.ledgerCategoryKey === e.ledgerCategoryKey) || o((s) => !s.productId && !s.ledgerCategoryKey && s.taxRateKey === e.taxRateKey) || o((s) => !s.productId && !s.ledgerCategoryKey && !s.taxRateKey);
|
|
3696
3696
|
}
|
|
3697
3697
|
function Ri(e) {
|
|
@@ -3716,16 +3716,16 @@ function $i(e, t, n) {
|
|
|
3716
3716
|
if (!t.currency || t.currency === n) return e;
|
|
3717
3717
|
const r = Number(t.fxRate);
|
|
3718
3718
|
if (!(r > 0)) return { ok: !1, problem: "fx_rate_required" };
|
|
3719
|
-
const o = e.lines.map((
|
|
3720
|
-
...
|
|
3721
|
-
functionalCents: Math.round(
|
|
3722
|
-
})), s = o.reduce((
|
|
3719
|
+
const o = e.lines.map((i) => ({
|
|
3720
|
+
...i,
|
|
3721
|
+
functionalCents: Math.round(i.amountCents * r)
|
|
3722
|
+
})), s = o.reduce((i, a) => i + a.functionalCents, 0);
|
|
3723
3723
|
return o[0] = { ...o[0], functionalCents: o[0].functionalCents - s }, { ...e, lines: o };
|
|
3724
3724
|
}
|
|
3725
3725
|
function Pi(e, t) {
|
|
3726
3726
|
const n = (b) => t.accounts.find((h) => h.role === b && !h.archived), r = e.direction === "sale", o = n(r ? "debtors" : "creditors");
|
|
3727
3727
|
if (!o) return { ok: !1, problem: r ? "no_debtors_account" : "no_creditors_account" };
|
|
3728
|
-
const s = n(r ? "revenue_default" : "expense_default"),
|
|
3728
|
+
const s = n(r ? "revenue_default" : "expense_default"), i = n(r ? "vat_payable" : "vat_receivable"), a = r ? -1 : 1, u = {
|
|
3729
3729
|
currency: e.currency,
|
|
3730
3730
|
...e.counterparty.companyId ? { counterpartyCompanyId: e.counterparty.companyId } : {}
|
|
3731
3731
|
}, c = e.taxPointDate ?? e.issueDate, l = [], d = /* @__PURE__ */ new Map();
|
|
@@ -3735,23 +3735,23 @@ function Pi(e, t) {
|
|
|
3735
3735
|
l.push({
|
|
3736
3736
|
...u,
|
|
3737
3737
|
accountId: h,
|
|
3738
|
-
amountCents:
|
|
3739
|
-
functionalCents:
|
|
3738
|
+
amountCents: a * b.netCents,
|
|
3739
|
+
functionalCents: a * b.netCents,
|
|
3740
3740
|
taxCode: b.taxRateKey,
|
|
3741
|
-
taxCents:
|
|
3741
|
+
taxCents: a * b.taxCents,
|
|
3742
3742
|
taxPointDate: c,
|
|
3743
3743
|
...b.description ? { description: b.description } : {},
|
|
3744
3744
|
...Ri(b.dimensions)
|
|
3745
3745
|
}), b.taxCents && d.set(b.taxRateKey, (d.get(b.taxRateKey) ?? 0) + b.taxCents);
|
|
3746
3746
|
}
|
|
3747
3747
|
for (const [b, h] of d) {
|
|
3748
|
-
const I = t.taxAccounts.find((y) => y.taxKey === b), g = (r ? I?.payableAccountId : I?.receivableAccountId) ??
|
|
3748
|
+
const I = t.taxAccounts.find((y) => y.taxKey === b), g = (r ? I?.payableAccountId : I?.receivableAccountId) ?? i?.id;
|
|
3749
3749
|
if (!g) return { ok: !1, problem: "no_vat_account" };
|
|
3750
3750
|
l.push({
|
|
3751
3751
|
...u,
|
|
3752
3752
|
accountId: g,
|
|
3753
|
-
amountCents:
|
|
3754
|
-
functionalCents:
|
|
3753
|
+
amountCents: a * h,
|
|
3754
|
+
functionalCents: a * h,
|
|
3755
3755
|
taxCode: b,
|
|
3756
3756
|
taxPointDate: c
|
|
3757
3757
|
});
|
|
@@ -3760,8 +3760,8 @@ function Pi(e, t) {
|
|
|
3760
3760
|
l.unshift({
|
|
3761
3761
|
...u,
|
|
3762
3762
|
accountId: o.id,
|
|
3763
|
-
amountCents: -
|
|
3764
|
-
functionalCents: -
|
|
3763
|
+
amountCents: -a * f,
|
|
3764
|
+
functionalCents: -a * f
|
|
3765
3765
|
});
|
|
3766
3766
|
const m = [e.number, e.counterparty.name].filter(Boolean).join(" · ");
|
|
3767
3767
|
return {
|
|
@@ -3776,11 +3776,11 @@ function Li(e, t) {
|
|
|
3776
3776
|
for (const o of e.lines) {
|
|
3777
3777
|
const s = o.accountKey ?? Fr(o, t.rules, e)?.accountId ?? n(Di[o.ledgerCategoryKey ?? ""])?.id;
|
|
3778
3778
|
if (!s) return { ok: !1, problem: "no_account_for_line" };
|
|
3779
|
-
const
|
|
3780
|
-
|
|
3779
|
+
const i = Math.round(Number(o.amountCents) || 0);
|
|
3780
|
+
i && r.push({
|
|
3781
3781
|
accountId: s,
|
|
3782
|
-
amountCents:
|
|
3783
|
-
functionalCents:
|
|
3782
|
+
amountCents: i,
|
|
3783
|
+
functionalCents: i,
|
|
3784
3784
|
currency: e.currency,
|
|
3785
3785
|
...o.description ? { description: o.description } : {},
|
|
3786
3786
|
...o.dimensions?.projectId ? { projectId: o.dimensions.projectId } : {},
|
|
@@ -3799,12 +3799,12 @@ const Ye = (e) => String(e).padStart(2, "0"), Ki = (e, t) => new Date(Date.UTC(e
|
|
|
3799
3799
|
function hm(e, t = 1) {
|
|
3800
3800
|
const n = t === 1 ? String(e) : `${e}/${e + 1}`;
|
|
3801
3801
|
return Array.from({ length: 12 }, (r, o) => {
|
|
3802
|
-
const s = t - 1 + o,
|
|
3802
|
+
const s = t - 1 + o, i = e + Math.floor(s / 12), a = s % 12 + 1;
|
|
3803
3803
|
return {
|
|
3804
3804
|
fiscalYear: n,
|
|
3805
3805
|
index: o + 1,
|
|
3806
|
-
from: `${
|
|
3807
|
-
to: `${
|
|
3806
|
+
from: `${i}-${Ye(a)}-01`,
|
|
3807
|
+
to: `${i}-${Ye(a)}-${Ye(Ki(i, a))}`,
|
|
3808
3808
|
status: "open"
|
|
3809
3809
|
};
|
|
3810
3810
|
});
|
|
@@ -3908,15 +3908,15 @@ function ym(e) {
|
|
|
3908
3908
|
"</period>"
|
|
3909
3909
|
);
|
|
3910
3910
|
o("</periods>");
|
|
3911
|
-
const
|
|
3912
|
-
if (
|
|
3913
|
-
const c =
|
|
3911
|
+
const i = e.opening.filter((c) => c.cents !== 0);
|
|
3912
|
+
if (i.length) {
|
|
3913
|
+
const c = i.filter((d) => d.cents > 0).reduce((d, f) => d + f.cents, 0), l = -i.filter((d) => d.cents < 0).reduce((d, f) => d + f.cents, 0);
|
|
3914
3914
|
o(
|
|
3915
3915
|
"<openingBalance>",
|
|
3916
|
-
k("linesCount",
|
|
3916
|
+
k("linesCount", i.length),
|
|
3917
3917
|
k("totalDebit", Q(c)),
|
|
3918
3918
|
k("totalCredit", Q(l))
|
|
3919
|
-
),
|
|
3919
|
+
), i.forEach((d, f) => {
|
|
3920
3920
|
o(
|
|
3921
3921
|
"<obLine>",
|
|
3922
3922
|
k("nr", f + 1),
|
|
@@ -3927,18 +3927,18 @@ function ym(e) {
|
|
|
3927
3927
|
);
|
|
3928
3928
|
}), o("</openingBalance>");
|
|
3929
3929
|
}
|
|
3930
|
-
const
|
|
3930
|
+
const a = e.entries.flatMap((c) => c.lines);
|
|
3931
3931
|
o(
|
|
3932
3932
|
"<transactions>",
|
|
3933
|
-
k("linesCount",
|
|
3933
|
+
k("linesCount", a.length),
|
|
3934
3934
|
k(
|
|
3935
3935
|
"totalDebit",
|
|
3936
|
-
Q(
|
|
3936
|
+
Q(a.filter((c) => c.functionalCents > 0).reduce((c, l) => c + l.functionalCents, 0))
|
|
3937
3937
|
),
|
|
3938
3938
|
k(
|
|
3939
3939
|
"totalCredit",
|
|
3940
3940
|
Q(
|
|
3941
|
-
-
|
|
3941
|
+
-a.filter((c) => c.functionalCents < 0).reduce((c, l) => c + l.functionalCents, 0)
|
|
3942
3942
|
)
|
|
3943
3943
|
)
|
|
3944
3944
|
);
|
|
@@ -3994,26 +3994,26 @@ const Fi = (e, t) => {
|
|
|
3994
3994
|
return t === "C" ? -Math.abs(n) : Math.abs(n);
|
|
3995
3995
|
};
|
|
3996
3996
|
function bm(e) {
|
|
3997
|
-
const t = q(e, "ledgerAccount").map((
|
|
3998
|
-
const u = T(
|
|
3997
|
+
const t = q(e, "ledgerAccount").map((a) => {
|
|
3998
|
+
const u = T(a, "RGScode") ?? T(a, "leadCode");
|
|
3999
3999
|
return {
|
|
4000
|
-
code: T(
|
|
4001
|
-
name: T(
|
|
4002
|
-
kind: T(
|
|
4000
|
+
code: T(a, "accID") ?? "",
|
|
4001
|
+
name: T(a, "accDesc") ?? "",
|
|
4002
|
+
kind: T(a, "accTp") === "P" ? "P" : "B",
|
|
4003
4003
|
...u ? { rgs: u } : {}
|
|
4004
4004
|
};
|
|
4005
|
-
}), n = {}, r = (
|
|
4006
|
-
const u = T(
|
|
4007
|
-
u && (n[u] = (n[u] ?? 0) + Fi(T(
|
|
4005
|
+
}), n = {}, r = (a) => {
|
|
4006
|
+
const u = T(a, "accID");
|
|
4007
|
+
u && (n[u] = (n[u] ?? 0) + Fi(T(a, "amnt"), T(a, "amntTp")));
|
|
4008
4008
|
};
|
|
4009
|
-
for (const
|
|
4010
|
-
for (const
|
|
4011
|
-
const o = q(e, "header")[0] ?? "", s = T(o, "fiscalYear"),
|
|
4009
|
+
for (const a of q(e, "obLine")) r(a);
|
|
4010
|
+
for (const a of q(e, "trLine")) r(a);
|
|
4011
|
+
const o = q(e, "header")[0] ?? "", s = T(o, "fiscalYear"), i = T(o, "endDate");
|
|
4012
4012
|
return {
|
|
4013
|
-
accounts: t.filter((
|
|
4013
|
+
accounts: t.filter((a) => a.code),
|
|
4014
4014
|
closing: n,
|
|
4015
4015
|
...s ? { fiscalYear: s } : {},
|
|
4016
|
-
...
|
|
4016
|
+
...i ? { endDate: i } : {}
|
|
4017
4017
|
};
|
|
4018
4018
|
}
|
|
4019
4019
|
function vm(e, t) {
|
|
@@ -4193,7 +4193,7 @@ function Nm(e, t, n) {
|
|
|
4193
4193
|
d ? d.push(c) : o.set(l, [c]);
|
|
4194
4194
|
}
|
|
4195
4195
|
const s = [];
|
|
4196
|
-
let
|
|
4196
|
+
let i = 0, a = 0;
|
|
4197
4197
|
for (const [c, l] of o) {
|
|
4198
4198
|
const d = Wi(c, t), f = l.reduce((h, I) => h + r[I].netCents, 0), m = P(f * d.percent / 100), b = Le(
|
|
4199
4199
|
m,
|
|
@@ -4206,7 +4206,7 @@ function Nm(e, t, n) {
|
|
|
4206
4206
|
kind: d.kind,
|
|
4207
4207
|
netCents: f,
|
|
4208
4208
|
taxCents: m
|
|
4209
|
-
}),
|
|
4209
|
+
}), i += f, a += m;
|
|
4210
4210
|
}
|
|
4211
4211
|
const u = r.reduce(
|
|
4212
4212
|
(c, l) => l.costPriceCents == null || l.optional ? c : c + P(l.costPriceCents * l.quantity),
|
|
@@ -4215,9 +4215,9 @@ function Nm(e, t, n) {
|
|
|
4215
4215
|
return {
|
|
4216
4216
|
lines: r,
|
|
4217
4217
|
totals: {
|
|
4218
|
-
netCents:
|
|
4219
|
-
taxCents:
|
|
4220
|
-
grossCents:
|
|
4218
|
+
netCents: i,
|
|
4219
|
+
taxCents: a,
|
|
4220
|
+
grossCents: i + a,
|
|
4221
4221
|
costCents: u,
|
|
4222
4222
|
byRate: s
|
|
4223
4223
|
}
|
|
@@ -4336,10 +4336,10 @@ function Hr(e, t) {
|
|
|
4336
4336
|
}
|
|
4337
4337
|
function zr(e, t, n, r) {
|
|
4338
4338
|
const o = e.filter(
|
|
4339
|
-
(
|
|
4340
|
-
), s = (
|
|
4341
|
-
return
|
|
4342
|
-
o.filter((
|
|
4339
|
+
(a) => a.effectiveFrom === void 0 || a.effectiveFrom <= r
|
|
4340
|
+
), s = (a) => a.sort((u, c) => (c.effectiveFrom ?? 0) - (u.effectiveFrom ?? 0))[0], i = s(o.filter((a) => a.userId === t));
|
|
4341
|
+
return i || s(
|
|
4342
|
+
o.filter((a) => !a.userId && a.teamId && n.includes(a.teamId))
|
|
4343
4343
|
);
|
|
4344
4344
|
}
|
|
4345
4345
|
function zi(e, t, n) {
|
|
@@ -4360,9 +4360,9 @@ const Nn = { interval: 0, day: 1, week: 2 };
|
|
|
4360
4360
|
function Km(e, t) {
|
|
4361
4361
|
const { entries: n, patterns: r = [], terms: o = [] } = t, s = n.filter(
|
|
4362
4362
|
(d) => d.userId && ye(d.status) && Y(d.kindKey).capacity
|
|
4363
|
-
),
|
|
4363
|
+
), i = n.filter(
|
|
4364
4364
|
(d) => d.userId && ye(d.status) && Y(d.kindKey).absent
|
|
4365
|
-
),
|
|
4365
|
+
), a = t.userIds ?? [
|
|
4366
4366
|
.../* @__PURE__ */ new Set([
|
|
4367
4367
|
...s.map((d) => d.userId),
|
|
4368
4368
|
...r.map((d) => d.userId),
|
|
@@ -4373,7 +4373,7 @@ function Km(e, t) {
|
|
|
4373
4373
|
const l = (d) => {
|
|
4374
4374
|
Nn[d] > Nn[c] && (c = d);
|
|
4375
4375
|
};
|
|
4376
|
-
for (const d of
|
|
4376
|
+
for (const d of a) {
|
|
4377
4377
|
const f = t.teamIdsOf?.(d) ?? [];
|
|
4378
4378
|
let m = 0, b = 0, h = 0;
|
|
4379
4379
|
for (const y of Yi(e)) {
|
|
@@ -4395,7 +4395,7 @@ function Km(e, t) {
|
|
|
4395
4395
|
const y = zi(o, d, e.from);
|
|
4396
4396
|
y && (m += y.weeklyMinutes * 60 * (b / 7), l("week"));
|
|
4397
4397
|
}
|
|
4398
|
-
const I =
|
|
4398
|
+
const I = i.filter((y) => y.userId === d).reduce(
|
|
4399
4399
|
(y, p) => y + gt(p.start, p.end, e.from, e.to),
|
|
4400
4400
|
0
|
|
4401
4401
|
), g = Math.max(0, m - I);
|
|
@@ -4408,49 +4408,49 @@ function Km(e, t) {
|
|
|
4408
4408
|
};
|
|
4409
4409
|
}
|
|
4410
4410
|
function Um(e, t) {
|
|
4411
|
-
if (!e.some((
|
|
4411
|
+
if (!e.some((a) => a.userId)) return [];
|
|
4412
4412
|
const n = "", r = /* @__PURE__ */ new Map();
|
|
4413
|
-
for (const
|
|
4414
|
-
const u =
|
|
4415
|
-
r.set(u, (r.get(u) ?? 0) +
|
|
4413
|
+
for (const a of e) {
|
|
4414
|
+
const u = a.userId ?? n;
|
|
4415
|
+
r.set(u, (r.get(u) ?? 0) + a.seconds);
|
|
4416
4416
|
}
|
|
4417
4417
|
const s = [.../* @__PURE__ */ new Set([
|
|
4418
4418
|
...Object.keys(t.byUser),
|
|
4419
|
-
...[...r.keys()].filter((
|
|
4420
|
-
])].map((
|
|
4421
|
-
const u = r.get(
|
|
4419
|
+
...[...r.keys()].filter((a) => a !== n)
|
|
4420
|
+
])].map((a) => {
|
|
4421
|
+
const u = r.get(a) ?? 0, c = t.byUser[a] ?? 0;
|
|
4422
4422
|
return {
|
|
4423
|
-
userId:
|
|
4423
|
+
userId: a,
|
|
4424
4424
|
requiredSeconds: u,
|
|
4425
4425
|
capacitySeconds: c,
|
|
4426
4426
|
netSeconds: c - u
|
|
4427
4427
|
};
|
|
4428
4428
|
});
|
|
4429
|
-
s.sort((
|
|
4430
|
-
const
|
|
4431
|
-
return
|
|
4429
|
+
s.sort((a, u) => a.netSeconds - u.netSeconds);
|
|
4430
|
+
const i = r.get(n) ?? 0;
|
|
4431
|
+
return i > 0 && s.push({ requiredSeconds: i, capacitySeconds: 0, netSeconds: -i }), s;
|
|
4432
4432
|
}
|
|
4433
4433
|
function Bm(e, t, n, r) {
|
|
4434
4434
|
const o = e.filter(
|
|
4435
|
-
(
|
|
4435
|
+
(i) => i.userId && ye(i.status) && !Y(i.kindKey).absent
|
|
4436
4436
|
), s = Object.entries(r.byUser).map(
|
|
4437
|
-
([
|
|
4437
|
+
([i, a]) => {
|
|
4438
4438
|
let u = 0, c = 0;
|
|
4439
4439
|
for (const l of o) {
|
|
4440
|
-
if (l.userId !==
|
|
4440
|
+
if (l.userId !== i || Y(l.kindKey).capacity && !l.workstreamId) continue;
|
|
4441
4441
|
const d = gt(l.start, l.end, n.from, n.to);
|
|
4442
4442
|
d <= 0 || (Wr(l, t) ? u += d : c += d);
|
|
4443
4443
|
}
|
|
4444
4444
|
return {
|
|
4445
|
-
userId:
|
|
4446
|
-
capacitySeconds:
|
|
4445
|
+
userId: i,
|
|
4446
|
+
capacitySeconds: a,
|
|
4447
4447
|
onThisSeconds: u,
|
|
4448
4448
|
elsewhereSeconds: c,
|
|
4449
|
-
freeSeconds: Math.max(0,
|
|
4449
|
+
freeSeconds: Math.max(0, a - u - c)
|
|
4450
4450
|
};
|
|
4451
4451
|
}
|
|
4452
4452
|
);
|
|
4453
|
-
return s.sort((
|
|
4453
|
+
return s.sort((i, a) => a.freeSeconds - i.freeSeconds), s;
|
|
4454
4454
|
}
|
|
4455
4455
|
const Fm = "demand-source", Rn = 1e3;
|
|
4456
4456
|
function Xi(e, t) {
|
|
@@ -4476,10 +4476,10 @@ function ea(e, t, n, r) {
|
|
|
4476
4476
|
if (e <= 0 || t <= 0) return 0;
|
|
4477
4477
|
const o = Ji(e, t, n);
|
|
4478
4478
|
if (o <= 0) return 0;
|
|
4479
|
-
const s = r.serviceLevelPercent / 100,
|
|
4480
|
-
for (let
|
|
4481
|
-
if (!(
|
|
4482
|
-
return
|
|
4479
|
+
const s = r.serviceLevelPercent / 100, i = r.maxOccupancyPercent ? r.maxOccupancyPercent / 100 : void 0;
|
|
4480
|
+
for (let a = Math.max(1, Math.ceil(o)); a <= Rn; a++)
|
|
4481
|
+
if (!(a <= o) && !(Zi(a, o, r.targetSeconds, t) < s) && !(i && o / a > i))
|
|
4482
|
+
return a;
|
|
4483
4483
|
return Rn;
|
|
4484
4484
|
}
|
|
4485
4485
|
const ta = 36e5, na = 864e5;
|
|
@@ -4496,17 +4496,17 @@ function Ze(e, t, n) {
|
|
|
4496
4496
|
function oa(e, t, n) {
|
|
4497
4497
|
const r = e.handleSeconds ?? 0, o = e.seconds ?? (e.volume !== void 0 ? e.volume * r : 0);
|
|
4498
4498
|
if (o <= 0 && !e.volume) return { seconds: 0, headcount: 0 };
|
|
4499
|
-
const s = (t.unplannedLossPercent ?? 0) / 100,
|
|
4499
|
+
const s = (t.unplannedLossPercent ?? 0) / 100, i = s > 0 && s < 1 ? 1 / (1 - s) : 1;
|
|
4500
4500
|
if (t.model === "queue" && e.volume !== void 0 && r > 0) {
|
|
4501
|
-
const
|
|
4502
|
-
return { seconds: o, headcount:
|
|
4501
|
+
const a = ea(e.volume, r, n, t);
|
|
4502
|
+
return { seconds: o, headcount: a * i };
|
|
4503
4503
|
}
|
|
4504
|
-
return { seconds: o, headcount: o / n *
|
|
4504
|
+
return { seconds: o, headcount: o / n * i };
|
|
4505
4505
|
}
|
|
4506
4506
|
function Gm(e) {
|
|
4507
|
-
const { entries: t, workstreamId: n, staffing: r, demand: o, range: s } = e,
|
|
4508
|
-
for (let h = ge(s.from,
|
|
4509
|
-
const I = h +
|
|
4507
|
+
const { entries: t, workstreamId: n, staffing: r, demand: o, range: s } = e, i = e.grain ?? "hour", a = ra(i), u = a / 1e3, c = e.kinds, l = t.filter((h) => ye(h.status)), d = l.filter((h) => Wr(h, n, c)), f = l.filter((h) => Y(h.kindKey, c).capacity), m = l.filter((h) => Y(h.kindKey, c).absent), b = [];
|
|
4508
|
+
for (let h = ge(s.from, i); h < s.to; h += a) {
|
|
4509
|
+
const I = h + a, g = he(h, i);
|
|
4510
4510
|
let y = 0;
|
|
4511
4511
|
for (const D of d) y += Ze(D, h, I);
|
|
4512
4512
|
let p = 0;
|
|
@@ -4548,14 +4548,14 @@ function la(e) {
|
|
|
4548
4548
|
function da(e, t, n) {
|
|
4549
4549
|
const r = [];
|
|
4550
4550
|
for (let s = 0; s < n; s++) {
|
|
4551
|
-
const
|
|
4551
|
+
const i = t - s * yt, a = i - yt;
|
|
4552
4552
|
let u = 0, c = !1;
|
|
4553
4553
|
for (const [l, d] of e)
|
|
4554
|
-
l >=
|
|
4554
|
+
l >= a && l < i && (u += d, c = !0);
|
|
4555
4555
|
c && r.push(u);
|
|
4556
4556
|
}
|
|
4557
4557
|
if (r.length < 2) return 1;
|
|
4558
|
-
const o = r.reduce((s,
|
|
4558
|
+
const o = r.reduce((s, i) => s + i, 0) / r.length;
|
|
4559
4559
|
return o <= 0 ? 1 : Math.min(ua, Math.max(ca, r[0] / o));
|
|
4560
4560
|
}
|
|
4561
4561
|
function fa(e, t) {
|
|
@@ -4569,7 +4569,7 @@ function Vm(e, t, n) {
|
|
|
4569
4569
|
const r = Math.max(1, n?.weeks ?? aa), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
|
|
4570
4570
|
for (const u of e)
|
|
4571
4571
|
o.set(la(u.period), u.value), s.add(u.period.slice(0, 10));
|
|
4572
|
-
const
|
|
4572
|
+
const i = da(o, ge(t.from, "hour"), r), a = [];
|
|
4573
4573
|
for (let u = ge(t.from, "hour"); u < t.to; u += ia) {
|
|
4574
4574
|
let c = 0, l = 0;
|
|
4575
4575
|
for (let m = 1; m <= r; m++) {
|
|
@@ -4578,11 +4578,11 @@ function Vm(e, t, n) {
|
|
|
4578
4578
|
const g = r - m + 1;
|
|
4579
4579
|
c += I * g, l += g;
|
|
4580
4580
|
}
|
|
4581
|
-
let d = l > 0 ? c / l *
|
|
4581
|
+
let d = l > 0 ? c / l * i : 0;
|
|
4582
4582
|
const f = fa(n?.adjustments, u);
|
|
4583
|
-
f?.absoluteVolume !== void 0 ? d = f.absoluteVolume : f?.factor !== void 0 && (d *= f.factor),
|
|
4583
|
+
f?.absoluteVolume !== void 0 ? d = f.absoluteVolume : f?.factor !== void 0 && (d *= f.factor), a.push({ period: he(u, "hour"), volume: d });
|
|
4584
4584
|
}
|
|
4585
|
-
return
|
|
4585
|
+
return a;
|
|
4586
4586
|
}
|
|
4587
4587
|
const pa = "schedule_entry", ma = "workstream";
|
|
4588
4588
|
function Hm(e) {
|
|
@@ -4606,19 +4606,19 @@ function Je(e, t, n, r) {
|
|
|
4606
4606
|
return o > 0 ? o / 1e3 : 0;
|
|
4607
4607
|
}
|
|
4608
4608
|
function Ym(e, t, n = {}) {
|
|
4609
|
-
const r = n.grain ?? "hour", o = ha(t, r), s = r === "day" ? ce : bt,
|
|
4610
|
-
for (const d of
|
|
4609
|
+
const r = n.grain ?? "hour", o = ha(t, r), s = r === "day" ? ce : bt, i = new Map(o.map((d) => [d, 0])), a = e.filter((d) => d.userId && Y(d.kindKey).capacity), u = n.userIds?.length ? new Set(n.userIds) : null, c = /* @__PURE__ */ new Set();
|
|
4610
|
+
for (const d of a)
|
|
4611
4611
|
if (!(u && d.userId && !u.has(d.userId))) {
|
|
4612
4612
|
for (const f of o) {
|
|
4613
4613
|
const m = Je(d.start, d.end, f, f + s);
|
|
4614
|
-
m > 0 &&
|
|
4614
|
+
m > 0 && i.set(f, (i.get(f) ?? 0) + m);
|
|
4615
4615
|
}
|
|
4616
4616
|
for (const f of $n(t))
|
|
4617
4617
|
Je(d.start, d.end, f, f + ce) > 0 && c.add(`${d.userId}:${f}`);
|
|
4618
4618
|
}
|
|
4619
4619
|
const l = n.userIds ?? [
|
|
4620
4620
|
.../* @__PURE__ */ new Set([
|
|
4621
|
-
...
|
|
4621
|
+
...a.map((d) => d.userId),
|
|
4622
4622
|
...(n.patterns ?? []).map((d) => d.userId)
|
|
4623
4623
|
])
|
|
4624
4624
|
].filter((d) => !!d);
|
|
@@ -4636,17 +4636,17 @@ function Ym(e, t, n = {}) {
|
|
|
4636
4636
|
const [p, _] = I.split(":").map(Number), E = m + p * bt + (_ ?? 0) * 6e4, C = E + h * 6e4;
|
|
4637
4637
|
for (const x of o) {
|
|
4638
4638
|
const D = Je(E, C, x, x + s);
|
|
4639
|
-
D > 0 &&
|
|
4639
|
+
D > 0 && i.set(x, (i.get(x) ?? 0) + D);
|
|
4640
4640
|
}
|
|
4641
4641
|
continue;
|
|
4642
4642
|
}
|
|
4643
4643
|
const g = o.filter((p) => p >= m && p < m + ce);
|
|
4644
4644
|
if (!g.length) continue;
|
|
4645
4645
|
const y = h * 60 / g.length;
|
|
4646
|
-
for (const p of g)
|
|
4646
|
+
for (const p of g) i.set(p, (i.get(p) ?? 0) + y);
|
|
4647
4647
|
}
|
|
4648
4648
|
}
|
|
4649
|
-
return o.map((d) => ({ period: he(d, r), weight:
|
|
4649
|
+
return o.map((d) => ({ period: he(d, r), weight: i.get(d) ?? 0 }));
|
|
4650
4650
|
}
|
|
4651
4651
|
function ga(e, t) {
|
|
4652
4652
|
if (e <= 0 || !t.length) return [];
|
|
@@ -4660,10 +4660,10 @@ function ga(e, t) {
|
|
|
4660
4660
|
function Xm(e, t, n) {
|
|
4661
4661
|
const r = /* @__PURE__ */ new Map();
|
|
4662
4662
|
for (const o of e) {
|
|
4663
|
-
const s = o.by ? t.filter((
|
|
4664
|
-
for (const
|
|
4665
|
-
const u = `${
|
|
4666
|
-
c ? c.seconds +=
|
|
4663
|
+
const s = o.by ? t.filter((a) => n(a.period) < o.by) : t, i = s.length ? s : t;
|
|
4664
|
+
for (const a of ga(o.seconds, i)) {
|
|
4665
|
+
const u = `${a.period}|${o.userId ?? ""}`, c = r.get(u);
|
|
4666
|
+
c ? c.seconds += a.seconds : r.set(u, { ...a, userId: o.userId });
|
|
4667
4667
|
}
|
|
4668
4668
|
}
|
|
4669
4669
|
return [...r.values()].sort(
|
|
@@ -4739,8 +4739,8 @@ function Aa(e) {
|
|
|
4739
4739
|
return e?.kind === "assignment";
|
|
4740
4740
|
}
|
|
4741
4741
|
function sh(e) {
|
|
4742
|
-
const { trigger: t, agentId: n, target: r, activityType: o, assigneeUserId: s, authorUserId:
|
|
4743
|
-
return Aa(t) ? n ? r ? r.activityTypes.includes(o) ? s ? s !== n ? "assigned to someone else" :
|
|
4742
|
+
const { trigger: t, agentId: n, target: r, activityType: o, assigneeUserId: s, authorUserId: i } = e;
|
|
4743
|
+
return Aa(t) ? n ? r ? r.activityTypes.includes(o) ? s ? s !== n ? "assigned to someone else" : i && i === n ? "the agent assigned this to itself, which would restart its own run" : null : `no assignee found at ${r.assigneePath}` : `activity type ${o} does not announce an assignment for ${r.id}` : `assignment target kind "${t.targetKind}" is not declared by any installed app` : "this playbook has no agent, so an assignment can never be for it" : "trigger is not an assignment trigger";
|
|
4744
4744
|
}
|
|
4745
4745
|
const vt = ["suggest", "outward", "auto"];
|
|
4746
4746
|
function ih(e) {
|
|
@@ -4919,7 +4919,7 @@ function Mh(e, t) {
|
|
|
4919
4919
|
function Na(e, t, n = 0.3) {
|
|
4920
4920
|
const r = e.slice(-3);
|
|
4921
4921
|
if (!r.length) return !1;
|
|
4922
|
-
const o = r.reduce((s,
|
|
4922
|
+
const o = r.reduce((s, i) => s + i, 0) / r.length;
|
|
4923
4923
|
return o === 0 ? t !== 0 : Math.abs(t - o) / Math.abs(o) > n;
|
|
4924
4924
|
}
|
|
4925
4925
|
const Pn = (e) => e.seriesId ?? e.id;
|
|
@@ -4930,42 +4930,42 @@ function Ra(e, t, n) {
|
|
|
4930
4930
|
}) ?? t[t.length - 1];
|
|
4931
4931
|
}
|
|
4932
4932
|
function wh(e, t, n, r = {}) {
|
|
4933
|
-
const o = (r.noticeDays ?? 30) * et, s = (r.windowDays ?? 7) * et,
|
|
4934
|
-
for (const
|
|
4935
|
-
if (
|
|
4933
|
+
const o = (r.noticeDays ?? 30) * et, s = (r.windowDays ?? 7) * et, i = [];
|
|
4934
|
+
for (const a of e) {
|
|
4935
|
+
if (a.status !== "active") continue;
|
|
4936
4936
|
const u = /* @__PURE__ */ new Map();
|
|
4937
|
-
for (const c of
|
|
4937
|
+
for (const c of a.lines)
|
|
4938
4938
|
u.set(Pn(c), [...u.get(Pn(c)) ?? [], c]);
|
|
4939
4939
|
for (const c of u.values()) {
|
|
4940
|
-
const l = Ra(
|
|
4940
|
+
const l = Ra(a, c, n), d = B(a, l);
|
|
4941
4941
|
if (d.to != null && d.to <= n) continue;
|
|
4942
|
-
const f = { contractId:
|
|
4942
|
+
const f = { contractId: a.id, lineId: l.id }, m = l.commitment ?? a.commitment, b = yr(a, c), h = d.to ?? xe(b, m, n);
|
|
4943
4943
|
if (l.customerCompanyId) {
|
|
4944
4944
|
const y = l.salesLine ? t.find(
|
|
4945
4945
|
(p) => p.agreementId === l.salesLine?.agreementId && p.seriesId === l.salesLine?.seriesId
|
|
4946
4946
|
) : void 0;
|
|
4947
|
-
y ? y.ended ?
|
|
4947
|
+
y ? y.ended ? i.push({ kind: "not_covered", ...f, reason: "sales_ended" }) : (l.quantity.from === "fixed" && y.quantity != null && y.quantity !== l.quantity.value && i.push({ kind: "not_covered", ...f, reason: "quantity" }), y.unbilled.length && i.push({ kind: "not_billed", ...f, windows: y.unbilled }), h > y.effectiveEndAt && i.push({
|
|
4948
4948
|
kind: "term_mismatch",
|
|
4949
4949
|
...f,
|
|
4950
4950
|
purchaseEnd: h,
|
|
4951
4951
|
salesEnd: y.effectiveEndAt
|
|
4952
|
-
})) :
|
|
4952
|
+
})) : i.push({ kind: "not_covered", ...f, reason: "no_sales_line" });
|
|
4953
4953
|
}
|
|
4954
4954
|
const I = !!m && m.termMonths >= 3 && (m.renew === "term" || n < xe(b, { ...m, renew: "none" }, b)), g = d.to == null && I ? vr(b, m, n) : null;
|
|
4955
|
-
if (g != null && g - n <= o &&
|
|
4955
|
+
if (g != null && g - n <= o && i.push({ kind: "notice_due", ...f, deadline: g }), m && m.termMonths >= 1 && l.changeWindowDays) {
|
|
4956
4956
|
const y = br(b, m, n) + l.changeWindowDays * et;
|
|
4957
|
-
y > n && y - n <= s &&
|
|
4957
|
+
y > n && y - n <= s && i.push({ kind: "change_window", ...f, closesAt: y });
|
|
4958
4958
|
}
|
|
4959
4959
|
if (l.expected === "variable" && l.invoiced && l.invoiced.length >= 2) {
|
|
4960
4960
|
const y = [...l.invoiced].sort((_, E) => _.from - E.from), p = y[y.length - 1];
|
|
4961
4961
|
Na(
|
|
4962
4962
|
y.slice(0, -1).map((_) => _.cents),
|
|
4963
4963
|
p.cents
|
|
4964
|
-
) &&
|
|
4964
|
+
) && i.push({ kind: "variable_jump", ...f, cents: p.cents });
|
|
4965
4965
|
}
|
|
4966
4966
|
}
|
|
4967
4967
|
}
|
|
4968
|
-
return
|
|
4968
|
+
return i;
|
|
4969
4969
|
}
|
|
4970
4970
|
function $a(e, t) {
|
|
4971
4971
|
let n = 0;
|
|
@@ -4983,8 +4983,8 @@ function xh(e) {
|
|
|
4983
4983
|
function Pa(e, t, n) {
|
|
4984
4984
|
const r = [];
|
|
4985
4985
|
for (const o of e.lines) {
|
|
4986
|
-
const s = t.find((
|
|
4987
|
-
(!s || e.movement === "in" &&
|
|
4986
|
+
const s = t.find((a) => a.id === o.poLineId), i = $a(o.poLineId, n);
|
|
4987
|
+
(!s || e.movement === "in" && i + o.quantity > s.quantity) && r.push({ code: "receipt_over_ordered", poLineId: o.poLineId }), e.movement === "return" && o.quantity > i && r.push({ code: "receipt_return_over_received", poLineId: o.poLineId }), o.serials.length && o.serials.length !== Qr(s ?? {}, o.quantity) && r.push({ code: "receipt_serials_count", poLineId: o.poLineId });
|
|
4988
4988
|
}
|
|
4989
4989
|
return r;
|
|
4990
4990
|
}
|
|
@@ -5030,41 +5030,41 @@ function Kn(e) {
|
|
|
5030
5030
|
return t;
|
|
5031
5031
|
}
|
|
5032
5032
|
function Nh(e) {
|
|
5033
|
-
const { now: t } = e, n = [], r = (
|
|
5034
|
-
const c = B(
|
|
5035
|
-
return
|
|
5033
|
+
const { now: t } = e, n = [], r = (a, u) => {
|
|
5034
|
+
const c = B(a, u);
|
|
5035
|
+
return a.status === "active" && (c.to == null || c.to > t);
|
|
5036
5036
|
}, o = e.contracts.flatMap(
|
|
5037
|
-
(
|
|
5038
|
-
contract:
|
|
5039
|
-
line: Ln(
|
|
5040
|
-
start: yr(
|
|
5037
|
+
(a) => [...Kn(a.lines).values()].map((u) => ({
|
|
5038
|
+
contract: a,
|
|
5039
|
+
line: Ln(a, u, t),
|
|
5040
|
+
start: yr(a, u)
|
|
5041
5041
|
}))
|
|
5042
5042
|
);
|
|
5043
|
-
for (const
|
|
5044
|
-
if (!(
|
|
5045
|
-
for (const u of Kn(
|
|
5046
|
-
const c = Ln(
|
|
5043
|
+
for (const a of e.agreements)
|
|
5044
|
+
if (!(a.status !== "active" && a.status !== "draft"))
|
|
5045
|
+
for (const u of Kn(a.lines).values()) {
|
|
5046
|
+
const c = Ln(a, u, t);
|
|
5047
5047
|
if (c.quantity.from !== "fixed") continue;
|
|
5048
5048
|
const l = Ka(
|
|
5049
5049
|
e.offers.filter(
|
|
5050
|
-
(C) => C.productId === c.productId && (C.businessEntityId || "") === (
|
|
5050
|
+
(C) => C.productId === c.productId && (C.businessEntityId || "") === (a.businessEntityId || "")
|
|
5051
5051
|
),
|
|
5052
5052
|
t
|
|
5053
5053
|
);
|
|
5054
5054
|
if (!l) continue;
|
|
5055
|
-
const d = It(c), f = ["demand:",
|
|
5055
|
+
const d = It(c), f = ["demand:", a.id, "#", d].join("");
|
|
5056
5056
|
if (e.open.has(f)) continue;
|
|
5057
5057
|
const m = o.find(
|
|
5058
|
-
(C) => C.line.salesLine?.agreementId ===
|
|
5059
|
-
), b = B(
|
|
5058
|
+
(C) => C.line.salesLine?.agreementId === a.id && C.line.salesLine.seriesId === d && r(C.contract, C.line)
|
|
5059
|
+
), b = B(a, c), h = {
|
|
5060
5060
|
key: f,
|
|
5061
5061
|
level: "item",
|
|
5062
5062
|
supplierCompanyId: l.supplierCompanyId,
|
|
5063
5063
|
offerId: l.id,
|
|
5064
5064
|
productId: c.productId,
|
|
5065
5065
|
name: c.name,
|
|
5066
|
-
customerCompanyId:
|
|
5067
|
-
salesLine: { agreementId:
|
|
5066
|
+
customerCompanyId: a.companyId,
|
|
5067
|
+
salesLine: { agreementId: a.id, seriesId: d }
|
|
5068
5068
|
};
|
|
5069
5069
|
if (b.to != null) {
|
|
5070
5070
|
if (!m) continue;
|
|
@@ -5111,16 +5111,16 @@ function Nh(e) {
|
|
|
5111
5111
|
...E ? {} : { atRenewal: !0, effectiveAt: se(m.start, p, t) }
|
|
5112
5112
|
});
|
|
5113
5113
|
}
|
|
5114
|
-
const s = [],
|
|
5114
|
+
const s = [], i = (a, u, c) => {
|
|
5115
5115
|
const l = e.provisionable.get([u.app, u.offer].join(":"));
|
|
5116
|
-
if (
|
|
5117
|
-
const d = e.offers.find((h) => h.id ===
|
|
5118
|
-
(h) => (h.businessEntityId || "") === d && (!c || h.supplierCompanyId ===
|
|
5116
|
+
if (a.action !== "purchase" || !l?.requires) return;
|
|
5117
|
+
const d = e.offers.find((h) => h.id === a.offerId)?.businessEntityId || "", f = e.offers.find(
|
|
5118
|
+
(h) => (h.businessEntityId || "") === d && (!c || h.supplierCompanyId === a.supplierCompanyId) && h.provider?.app === u.app && h.provider?.offer === l.requires
|
|
5119
5119
|
), m = o.some(
|
|
5120
|
-
(h) => h.line.offerId === f?.id && h.line.customerCompanyId ===
|
|
5120
|
+
(h) => h.line.offerId === f?.id && h.line.customerCompanyId === a.customerCompanyId && r(h.contract, h.line)
|
|
5121
5121
|
);
|
|
5122
5122
|
if (!f || m) return;
|
|
5123
|
-
const b = ["account:",
|
|
5123
|
+
const b = ["account:", a.customerCompanyId, ":", f.id].join("");
|
|
5124
5124
|
return !e.open.has(b) && !s.some((h) => h.key === b) && s.unshift({
|
|
5125
5125
|
key: b,
|
|
5126
5126
|
action: "purchase",
|
|
@@ -5130,23 +5130,25 @@ function Nh(e) {
|
|
|
5130
5130
|
productId: f.productId,
|
|
5131
5131
|
name: l.requires,
|
|
5132
5132
|
quantity: 1,
|
|
5133
|
-
customerCompanyId:
|
|
5133
|
+
customerCompanyId: a.customerCompanyId
|
|
5134
5134
|
}), b;
|
|
5135
5135
|
};
|
|
5136
|
-
for (const
|
|
5137
|
-
const u = e.offers.find((l) => l.id ===
|
|
5138
|
-
u?.deliverTo?.app && a
|
|
5139
|
-
...
|
|
5136
|
+
for (const a of n) {
|
|
5137
|
+
const u = e.offers.find((l) => l.id === a.offerId), c = u?.provider?.app ? i(a, u.provider, !0) : void 0;
|
|
5138
|
+
u?.deliverTo?.app && i(a, u.deliverTo, !1), s.push({
|
|
5139
|
+
...a,
|
|
5140
5140
|
...c ? { waitsFor: c } : {},
|
|
5141
5141
|
...u?.deliverTo?.app ? { deliverTo: u.deliverTo } : {}
|
|
5142
5142
|
});
|
|
5143
5143
|
}
|
|
5144
|
-
return [...s.filter((
|
|
5144
|
+
return [...s.filter((a) => a.level === "account"), ...s.filter((a) => a.level !== "account")];
|
|
5145
5145
|
}
|
|
5146
5146
|
const Zr = [
|
|
5147
5147
|
"vendorSku",
|
|
5148
5148
|
"gtin",
|
|
5149
5149
|
"description",
|
|
5150
|
+
"brand",
|
|
5151
|
+
"group",
|
|
5150
5152
|
"cost",
|
|
5151
5153
|
"list",
|
|
5152
5154
|
"currency",
|
|
@@ -5158,26 +5160,26 @@ const Zr = [
|
|
|
5158
5160
|
month: 31 * 864e5
|
|
5159
5161
|
}, Fa = 10;
|
|
5160
5162
|
function $h(e, t) {
|
|
5161
|
-
const n = (e[0] ?? []).map((
|
|
5162
|
-
for (const
|
|
5163
|
-
const u = t[
|
|
5163
|
+
const n = (e[0] ?? []).map((a) => a.trim().toLowerCase()), r = {}, o = [];
|
|
5164
|
+
for (const a of Zr) {
|
|
5165
|
+
const u = t[a]?.trim();
|
|
5164
5166
|
if (!u) continue;
|
|
5165
5167
|
const c = n.indexOf(u.toLowerCase());
|
|
5166
|
-
c === -1 ? o.push(u) : r[
|
|
5168
|
+
c === -1 ? o.push(u) : r[a] = c;
|
|
5167
5169
|
}
|
|
5168
|
-
const s = [],
|
|
5169
|
-
return r.vendorSku === void 0 && r.gtin === void 0 ? { rows: s, errors: [{ line: 1, message: "feed_no_key" }], missingHeaders: o } : (e.slice(1).forEach((
|
|
5170
|
+
const s = [], i = [];
|
|
5171
|
+
return r.vendorSku === void 0 && r.gtin === void 0 ? { rows: s, errors: [{ line: 1, message: "feed_no_key" }], missingHeaders: o } : (e.slice(1).forEach((a, u) => {
|
|
5170
5172
|
const c = u + 2, l = (p) => {
|
|
5171
5173
|
const _ = r[p];
|
|
5172
|
-
return _ === void 0 ? "" : (
|
|
5174
|
+
return _ === void 0 ? "" : (a[_] ?? "").trim();
|
|
5173
5175
|
}, d = l("vendorSku"), f = Pt(l("gtin"));
|
|
5174
5176
|
if (!d && !f) {
|
|
5175
|
-
|
|
5177
|
+
i.push({ line: c, message: "feed_row_no_key" });
|
|
5176
5178
|
return;
|
|
5177
5179
|
}
|
|
5178
5180
|
const m = l("cost") ? tn(l("cost")) : void 0;
|
|
5179
5181
|
if (l("cost") && m === void 0) {
|
|
5180
|
-
|
|
5182
|
+
i.push({ line: c, message: "feed_row_price" });
|
|
5181
5183
|
return;
|
|
5182
5184
|
}
|
|
5183
5185
|
const b = l("list") ? tn(l("list")) : void 0, h = l("stock"), I = Number(h.replace(/[^\d-]/g, "")), g = r.stock === void 0 ? void 0 : h && /\d/.test(h) && Number.isFinite(I) ? Math.max(0, I) : null, y = Number(l("leadDays"));
|
|
@@ -5186,33 +5188,35 @@ function $h(e, t) {
|
|
|
5186
5188
|
...d ? { vendorSku: d } : {},
|
|
5187
5189
|
...f ? { gtin: f } : {},
|
|
5188
5190
|
...l("description") ? { description: l("description") } : {},
|
|
5191
|
+
...l("brand") ? { brand: l("brand") } : {},
|
|
5192
|
+
...l("group") ? { group: l("group") } : {},
|
|
5189
5193
|
...m !== void 0 ? { costCents: m } : {},
|
|
5190
5194
|
...b !== void 0 ? { listCents: b } : {},
|
|
5191
5195
|
...l("currency") ? { currency: l("currency").toUpperCase() } : {},
|
|
5192
5196
|
...g !== void 0 ? { stock: g } : {},
|
|
5193
5197
|
...l("leadDays") && Number.isFinite(y) ? { leadDays: y } : {}
|
|
5194
5198
|
});
|
|
5195
|
-
}), { rows: s, errors:
|
|
5199
|
+
}), { rows: s, errors: i, missingHeaders: o });
|
|
5196
5200
|
}
|
|
5197
5201
|
function Ph(e, t, n) {
|
|
5198
|
-
const r = new Map(t.filter((
|
|
5199
|
-
for (const
|
|
5200
|
-
for (const
|
|
5201
|
-
const u =
|
|
5202
|
-
u && !s.has(u) && s.set(u,
|
|
5202
|
+
const r = new Map(t.filter((i) => i.vendorSku).map((i) => [i.vendorSku, i])), o = new Map(t.map((i) => [i.productId, i])), s = /* @__PURE__ */ new Map();
|
|
5203
|
+
for (const i of n)
|
|
5204
|
+
for (const a of [i.gtin, ...i.barcodes ?? []]) {
|
|
5205
|
+
const u = a ? Pt(a) : void 0;
|
|
5206
|
+
u && !s.has(u) && s.set(u, i);
|
|
5203
5207
|
}
|
|
5204
|
-
return e.map((
|
|
5205
|
-
const
|
|
5206
|
-
if (
|
|
5207
|
-
const u =
|
|
5208
|
-
if (!u) return { row:
|
|
5208
|
+
return e.map((i) => {
|
|
5209
|
+
const a = i.vendorSku ? r.get(i.vendorSku) : void 0;
|
|
5210
|
+
if (a) return { row: i, offer: a };
|
|
5211
|
+
const u = i.gtin ? s.get(i.gtin) : void 0;
|
|
5212
|
+
if (!u) return { row: i };
|
|
5209
5213
|
const c = o.get(u.id);
|
|
5210
|
-
return c ? { row:
|
|
5214
|
+
return c ? { row: i, offer: c } : { row: i, product: u };
|
|
5211
5215
|
});
|
|
5212
5216
|
}
|
|
5213
5217
|
function Lh(e, t, n, r = Fa) {
|
|
5214
5218
|
const o = /* @__PURE__ */ new Map(), s = [];
|
|
5215
|
-
let
|
|
5219
|
+
let i = 0;
|
|
5216
5220
|
for (const u of e) {
|
|
5217
5221
|
const { row: c } = u;
|
|
5218
5222
|
if (!("offer" in u)) {
|
|
@@ -5221,6 +5225,8 @@ function Lh(e, t, n, r = Fa) {
|
|
|
5221
5225
|
...c.vendorSku ? { vendorSku: c.vendorSku } : {},
|
|
5222
5226
|
...c.gtin ? { gtin: c.gtin } : {},
|
|
5223
5227
|
...c.description ? { description: c.description } : {},
|
|
5228
|
+
...c.brand ? { brand: c.brand } : {},
|
|
5229
|
+
...c.group ? { group: c.group } : {},
|
|
5224
5230
|
...c.costCents !== void 0 ? { costCents: c.costCents } : {},
|
|
5225
5231
|
..."product" in u ? { productId: u.product.id } : {}
|
|
5226
5232
|
});
|
|
@@ -5232,7 +5238,7 @@ function Lh(e, t, n, r = Fa) {
|
|
|
5232
5238
|
source: "feed",
|
|
5233
5239
|
...c.leadDays !== void 0 ? { leadDays: c.leadDays } : {}
|
|
5234
5240
|
}, f = { availability: d };
|
|
5235
|
-
c.costCents !== void 0 && c.costCents !== l.costCents && (f.costCents = c.costCents), c.listCents !== void 0 && c.listCents !== l.listCents && (f.listCents = c.listCents), c.currency && c.currency !== l.currency && (f.currency = c.currency), c.vendorSku && !l.vendorSku && (f.vendorSku = c.vendorSku), Object.keys(f).length > 1 || d.qty !== (l.availability?.qty ?? null) ||
|
|
5241
|
+
c.costCents !== void 0 && c.costCents !== l.costCents && (f.costCents = c.costCents), c.listCents !== void 0 && c.listCents !== l.listCents && (f.listCents = c.listCents), c.currency && c.currency !== l.currency && (f.currency = c.currency), c.vendorSku && !l.vendorSku && (f.vendorSku = c.vendorSku), Object.keys(f).length > 1 || d.qty !== (l.availability?.qty ?? null) || i++;
|
|
5236
5242
|
const b = f.costCents !== void 0 && l.costCents > 0 ? Math.round(Math.abs(f.costCents - l.costCents) / l.costCents * 1e3) / 10 : 0;
|
|
5237
5243
|
o.set(l.id, {
|
|
5238
5244
|
offerId: l.id,
|
|
@@ -5240,8 +5246,8 @@ function Lh(e, t, n, r = Fa) {
|
|
|
5240
5246
|
...b > r ? { jump: { fromCents: l.costCents, toCents: f.costCents, percent: b } } : {}
|
|
5241
5247
|
});
|
|
5242
5248
|
}
|
|
5243
|
-
const
|
|
5244
|
-
return { changes: [...o.values()], unchanged:
|
|
5249
|
+
const a = t.filter((u) => u.availability?.source === "feed" && !o.has(u.id)).map((u) => u.id);
|
|
5250
|
+
return { changes: [...o.values()], unchanged: i, gone: a, unmatched: s };
|
|
5245
5251
|
}
|
|
5246
5252
|
const ja = {
|
|
5247
5253
|
vendorSku: [
|
|
@@ -5256,6 +5262,8 @@ const ja = {
|
|
|
5256
5262
|
],
|
|
5257
5263
|
gtin: ["ean", "gtin", "barcode", "ean13", "upc"],
|
|
5258
5264
|
description: ["omschrijving", "description", "naam", "name", "product"],
|
|
5265
|
+
brand: ["merk", "brand", "fabrikant", "manufacturer", "vendor"],
|
|
5266
|
+
group: ["productgroep", "groep", "categorie", "category", "product group", "productgroup"],
|
|
5259
5267
|
cost: ["netto", "inkoopprijs", "inkoop", "prijs", "price", "net price", "cost", "dealer price"],
|
|
5260
5268
|
list: ["advies", "adviesprijs", "msrp", "rrp", "list price", "erp"],
|
|
5261
5269
|
currency: ["valuta", "currency"],
|
|
@@ -5263,14 +5271,16 @@ const ja = {
|
|
|
5263
5271
|
leadDays: ["levertijd", "lead time", "leadtime", "delivery days"]
|
|
5264
5272
|
};
|
|
5265
5273
|
function Kh(e) {
|
|
5266
|
-
const t = e.map((
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
+
const t = e.map((s) => s.trim()), n = /* @__PURE__ */ new Set(), r = {}, o = (s) => {
|
|
5275
|
+
for (const i of Zr) {
|
|
5276
|
+
if (r[i]) continue;
|
|
5277
|
+
const a = t.find(
|
|
5278
|
+
(u) => !n.has(u) && ja[i].some((c) => s(u.toLowerCase(), c))
|
|
5279
|
+
);
|
|
5280
|
+
a && (r[i] = a, n.add(a));
|
|
5281
|
+
}
|
|
5282
|
+
};
|
|
5283
|
+
return o((s, i) => s === i), o((s, i) => s.startsWith(i)), r;
|
|
5274
5284
|
}
|
|
5275
5285
|
const Ga = [
|
|
5276
5286
|
{
|
|
@@ -5318,43 +5328,43 @@ function Jr(e, t, n) {
|
|
|
5318
5328
|
(u) => u.id === t.offerId || !!t.productId && u.productId === t.productId
|
|
5319
5329
|
).map((u) => K(u.vendorSku)).filter(Boolean).includes(o))
|
|
5320
5330
|
return { via: "sku", rank: Ce.sku };
|
|
5321
|
-
const s = K(e.description),
|
|
5322
|
-
return !s || !
|
|
5331
|
+
const s = K(e.description), i = K(t.name);
|
|
5332
|
+
return !s || !i ? null : s === i ? { via: "description", rank: Ce.description } : i.includes(s) || s.includes(i) ? { via: "description", rank: Ce.loose } : null;
|
|
5323
5333
|
}
|
|
5324
5334
|
function qa(e, t, n) {
|
|
5325
|
-
const r = t.filter((
|
|
5326
|
-
return e.forEach((
|
|
5335
|
+
const r = t.filter((a) => a.kind === "product"), o = /* @__PURE__ */ new Set(), s = [], i = [];
|
|
5336
|
+
return e.forEach((a, u) => {
|
|
5327
5337
|
let c = null;
|
|
5328
5338
|
for (const l of r) {
|
|
5329
5339
|
if (o.has(l.id)) continue;
|
|
5330
|
-
const d = Jr(
|
|
5340
|
+
const d = Jr(a, l, n);
|
|
5331
5341
|
d && (!c || d.rank < c.rank) && (c = { line: l, ...d });
|
|
5332
5342
|
}
|
|
5333
5343
|
if (!c) {
|
|
5334
|
-
|
|
5344
|
+
i.push(u);
|
|
5335
5345
|
return;
|
|
5336
5346
|
}
|
|
5337
5347
|
o.add(c.line.id), s.push({ docIndex: u, poLineId: c.line.id, via: c.via });
|
|
5338
|
-
}), { matches: s, unmatched:
|
|
5348
|
+
}), { matches: s, unmatched: i };
|
|
5339
5349
|
}
|
|
5340
5350
|
function Fh(e, t, n, r) {
|
|
5341
5351
|
const o = Wa(e.lines);
|
|
5342
5352
|
if (!t) return { lines: [], problems: [{ code: "slip_no_order" }] };
|
|
5343
|
-
const { matches: s, unmatched:
|
|
5353
|
+
const { matches: s, unmatched: i } = qa(o, t.lines, n), a = s.map((c) => ({
|
|
5344
5354
|
poLineId: c.poLineId,
|
|
5345
5355
|
quantity: o[c.docIndex].quantity,
|
|
5346
5356
|
serials: o[c.docIndex].serials,
|
|
5347
5357
|
docIndex: c.docIndex,
|
|
5348
5358
|
via: c.via
|
|
5349
5359
|
})), u = [
|
|
5350
|
-
...Pa({ movement: "in", lines:
|
|
5360
|
+
...Pa({ movement: "in", lines: a }, t.lines, r).filter((c) => c.code !== "receipt_return_over_received").map((c) => ({
|
|
5351
5361
|
code: c.code,
|
|
5352
5362
|
poLineId: c.poLineId,
|
|
5353
|
-
docIndex:
|
|
5363
|
+
docIndex: a.find((l) => l.poLineId === c.poLineId)?.docIndex
|
|
5354
5364
|
})),
|
|
5355
|
-
...
|
|
5365
|
+
...i.map((c) => ({ code: "slip_unknown_item", docIndex: c }))
|
|
5356
5366
|
];
|
|
5357
|
-
return { lines:
|
|
5367
|
+
return { lines: a, problems: u };
|
|
5358
5368
|
}
|
|
5359
5369
|
function jh(e) {
|
|
5360
5370
|
let t;
|
|
@@ -5364,14 +5374,14 @@ function jh(e) {
|
|
|
5364
5374
|
return null;
|
|
5365
5375
|
}
|
|
5366
5376
|
const n = (s) => typeof s == "string" || typeof s == "number" ? String(s).trim() : "", r = (Array.isArray(t.lines) ? t.lines : []).flatMap((s) => {
|
|
5367
|
-
const
|
|
5368
|
-
if (!(
|
|
5377
|
+
const i = Number(String(s?.quantity ?? "").replace(",", ".")), a = n(s?.description);
|
|
5378
|
+
if (!(i > 0) || !a && !n(s?.sku)) return [];
|
|
5369
5379
|
const u = [
|
|
5370
5380
|
...Array.isArray(s?.serials) ? s.serials.map(n) : [],
|
|
5371
5381
|
...n(s?.serial) ? [n(s?.serial)] : []
|
|
5372
5382
|
].filter(Boolean);
|
|
5373
5383
|
return [
|
|
5374
|
-
{ ...n(s?.sku) ? { sku: n(s?.sku) } : {}, description:
|
|
5384
|
+
{ ...n(s?.sku) ? { sku: n(s?.sku) } : {}, description: a, quantity: i, serials: u }
|
|
5375
5385
|
];
|
|
5376
5386
|
}), o = n(t.deliveredOn);
|
|
5377
5387
|
return {
|
|
@@ -5383,13 +5393,13 @@ function jh(e) {
|
|
|
5383
5393
|
}
|
|
5384
5394
|
const Va = 864e5, Un = (e) => Date.parse([e, "T00:00:00Z"].join(""));
|
|
5385
5395
|
function Gh(e, t, n, r) {
|
|
5386
|
-
const o = new Map(t.map((u) => [u.id, u.openQty])), s = [],
|
|
5396
|
+
const o = new Map(t.map((u) => [u.id, u.openQty])), s = [], i = [], a = /* @__PURE__ */ new Set();
|
|
5387
5397
|
for (const u of e) {
|
|
5388
5398
|
const c = t.map((p, _) => ({ candidate: p, order: _, hit: Jr(u, p, n) })).filter((p) => !!p.hit).filter(
|
|
5389
|
-
(p) => !(p.candidate.kind === "contract_line" &&
|
|
5399
|
+
(p) => !(p.candidate.kind === "contract_line" && a.has(p.candidate.id))
|
|
5390
5400
|
).sort((p, _) => p.hit.rank - _.hit.rank || p.order - _.order);
|
|
5391
5401
|
if (!c.length) {
|
|
5392
|
-
|
|
5402
|
+
i.push(u.id);
|
|
5393
5403
|
continue;
|
|
5394
5404
|
}
|
|
5395
5405
|
const l = u.period ? { from: Un(u.period.from), to: Un(u.period.to) + Va } : r, d = (p) => ({
|
|
@@ -5408,7 +5418,7 @@ function Gh(e, t, n, r) {
|
|
|
5408
5418
|
}), m = c[0];
|
|
5409
5419
|
if (m.candidate.kind === "contract_line") {
|
|
5410
5420
|
const p = m.candidate;
|
|
5411
|
-
|
|
5421
|
+
a.add(p.id);
|
|
5412
5422
|
const _ = u.quantity ?? p.openQty ?? 1;
|
|
5413
5423
|
s.push({
|
|
5414
5424
|
...d(p),
|
|
@@ -5452,7 +5462,7 @@ function Gh(e, t, n, r) {
|
|
|
5452
5462
|
});
|
|
5453
5463
|
});
|
|
5454
5464
|
}
|
|
5455
|
-
return { allocations: s, unmatched:
|
|
5465
|
+
return { allocations: s, unmatched: i };
|
|
5456
5466
|
}
|
|
5457
5467
|
const Ha = { percent: 1, cents: 100 };
|
|
5458
5468
|
function Wh(e, t, n = Ha) {
|
|
@@ -5462,10 +5472,10 @@ function Wh(e, t, n = Ha) {
|
|
|
5462
5472
|
})), o = /* @__PURE__ */ new Map();
|
|
5463
5473
|
for (const s of e)
|
|
5464
5474
|
o.set(s.receiptLineId, [...o.get(s.receiptLineId) ?? [], s]);
|
|
5465
|
-
for (const [s,
|
|
5466
|
-
if (
|
|
5467
|
-
const
|
|
5468
|
-
Math.abs(u -
|
|
5475
|
+
for (const [s, i] of o) {
|
|
5476
|
+
if (i.some((l) => l.overQuantity) && r.push({ receiptLineId: s, issue: "quantity" }), i.some((l) => l.expectedCents === null)) continue;
|
|
5477
|
+
const a = i.reduce((l, d) => l + (d.expectedCents ?? 0), 0), u = i.reduce((l, d) => l + d.amountCents, 0), c = Math.max(Math.abs(a) * n.percent / 100, n.cents);
|
|
5478
|
+
Math.abs(u - a) > c && r.push({ receiptLineId: s, issue: "price", expectedCents: a, amountCents: u });
|
|
5469
5479
|
}
|
|
5470
5480
|
return { ok: r.length === 0 && e.length > 0, issues: r };
|
|
5471
5481
|
}
|
|
@@ -5506,16 +5516,16 @@ const Ya = [
|
|
|
5506
5516
|
"5g"
|
|
5507
5517
|
];
|
|
5508
5518
|
function Hh(e) {
|
|
5509
|
-
const t = e.taxonomy ?? "nl-ob", n = new Map(e.codes.map((p) => [p.key, p])), r = n.get(e.standardKey ?? "high"), o = {}, s = {},
|
|
5519
|
+
const t = e.taxonomy ?? "nl-ob", n = new Map(e.codes.map((p) => [p.key, p])), r = n.get(e.standardKey ?? "high"), o = {}, s = {}, i = (p, _) => {
|
|
5510
5520
|
if (!e.trace || !p || !_.ref) return;
|
|
5511
5521
|
const E = s[p] ?? [];
|
|
5512
5522
|
E.includes(_.ref) || (s[p] = [...E, _.ref]);
|
|
5513
5523
|
};
|
|
5514
|
-
let
|
|
5524
|
+
let a;
|
|
5515
5525
|
const u = (p, _, E) => {
|
|
5516
5526
|
if (!p || !E) return;
|
|
5517
5527
|
const C = o[p] ?? {};
|
|
5518
|
-
C[_] = (C[_] ?? 0) + E, o[p] = C,
|
|
5528
|
+
C[_] = (C[_] ?? 0) + E, o[p] = C, a && i(p, a);
|
|
5519
5529
|
}, c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set();
|
|
5520
5530
|
let d = 0;
|
|
5521
5531
|
for (const p of e.lines) {
|
|
@@ -5526,17 +5536,17 @@ function Hh(e) {
|
|
|
5526
5536
|
continue;
|
|
5527
5537
|
}
|
|
5528
5538
|
const E = _.boxes[t]?.[p.side];
|
|
5529
|
-
if (
|
|
5539
|
+
if (a = p, p.side === "sales")
|
|
5530
5540
|
u(E?.base, "baseCents", p.baseCents), u(E?.tax, "taxCents", p.taxCents), _.icp && c.set(
|
|
5531
5541
|
p.counterpartyCompanyId ?? "",
|
|
5532
5542
|
(c.get(p.counterpartyCompanyId ?? "") ?? 0) + p.baseCents
|
|
5533
5543
|
);
|
|
5534
5544
|
else if (_.selfAssessed) {
|
|
5535
5545
|
const C = r ? Gr(r, p.taxPointDate) ?? 0 : 0, x = Math.round(p.baseCents * C / 100);
|
|
5536
|
-
u(E?.base, "baseCents", p.baseCents), u(E?.tax, "taxCents", x), d += x, x &&
|
|
5546
|
+
u(E?.base, "baseCents", p.baseCents), u(E?.tax, "taxCents", x), d += x, x && i("5b", p);
|
|
5537
5547
|
} else {
|
|
5538
5548
|
const C = Math.round(p.taxCents * (_.deductiblePercent ?? 100) / 100);
|
|
5539
|
-
d += C, C &&
|
|
5549
|
+
d += C, C && i("5b", p);
|
|
5540
5550
|
}
|
|
5541
5551
|
}
|
|
5542
5552
|
const f = Ya.filter((p) => p < "5"), m = f.reduce((p, _) => p + (o[_]?.taxCents ?? 0), 0);
|
|
@@ -5559,12 +5569,12 @@ function Hh(e) {
|
|
|
5559
5569
|
};
|
|
5560
5570
|
}
|
|
5561
5571
|
function zh(e, t = "quarter") {
|
|
5562
|
-
const n = t === "quarter" ? 3 : t === "month" ? 1 : 12, r = (s) => String(s).padStart(2, "0"), o = (s,
|
|
5563
|
-
return Array.from({ length: 12 / n }, (s,
|
|
5564
|
-
const
|
|
5572
|
+
const n = t === "quarter" ? 3 : t === "month" ? 1 : 12, r = (s) => String(s).padStart(2, "0"), o = (s, i) => new Date(Date.UTC(s, i, 0)).getUTCDate();
|
|
5573
|
+
return Array.from({ length: 12 / n }, (s, i) => {
|
|
5574
|
+
const a = i * n + 1, u = a + n - 1, c = u === 12 ? e + 1 : e, l = u === 12 ? 1 : u + 1;
|
|
5565
5575
|
return {
|
|
5566
|
-
label: t === "quarter" ? `Q${
|
|
5567
|
-
from: `${e}-${r(
|
|
5576
|
+
label: t === "quarter" ? `Q${i + 1} ${e}` : t === "month" ? `${e}-${r(a)}` : String(e),
|
|
5577
|
+
from: `${e}-${r(a)}-01`,
|
|
5568
5578
|
to: `${e}-${r(u)}-${r(o(e, u))}`,
|
|
5569
5579
|
// A yearly return is due three months after the year; a period return the month after.
|
|
5570
5580
|
dueOn: t === "year" ? `${e + 1}-03-31` : `${c}-${r(l)}-${r(o(c, l))}`
|
|
@@ -5605,9 +5615,9 @@ function Ja(e, t, n) {
|
|
|
5605
5615
|
const s = Bn(t, o[1], e, n);
|
|
5606
5616
|
return s === void 0 && !r ? "" : s;
|
|
5607
5617
|
}
|
|
5608
|
-
return e.replace(Qa, (s,
|
|
5609
|
-
const
|
|
5610
|
-
return
|
|
5618
|
+
return e.replace(Qa, (s, i) => {
|
|
5619
|
+
const a = Bn(t, i, s, n);
|
|
5620
|
+
return a == null ? "" : typeof a == "object" ? JSON.stringify(a) : String(a);
|
|
5611
5621
|
});
|
|
5612
5622
|
}
|
|
5613
5623
|
function Bn(e, t, n, r) {
|
|
@@ -5655,9 +5665,9 @@ function At(e) {
|
|
|
5655
5665
|
if (!Array.isArray(r)) return null;
|
|
5656
5666
|
const o = [];
|
|
5657
5667
|
for (const s of r) {
|
|
5658
|
-
const
|
|
5659
|
-
if (!
|
|
5660
|
-
o.push(
|
|
5668
|
+
const i = At(s);
|
|
5669
|
+
if (!i) return null;
|
|
5670
|
+
o.push(i);
|
|
5661
5671
|
}
|
|
5662
5672
|
return { kind: "group", op: n, children: o };
|
|
5663
5673
|
}
|
|
@@ -5710,14 +5720,14 @@ const rt = [
|
|
|
5710
5720
|
function rc(e, t, n) {
|
|
5711
5721
|
const r = /* @__PURE__ */ new Set();
|
|
5712
5722
|
for (const o of e.split(",")) {
|
|
5713
|
-
const [s,
|
|
5714
|
-
if (!Number.isInteger(
|
|
5723
|
+
const [s, i] = o.split("/"), a = i === void 0 ? 1 : Number(i);
|
|
5724
|
+
if (!Number.isInteger(a) || a < 1) return null;
|
|
5715
5725
|
let u = t, c = n;
|
|
5716
5726
|
if (s !== "*" && s !== void 0) {
|
|
5717
5727
|
const [l, d] = s.split("-");
|
|
5718
|
-
if (u = Number(l), c = d === void 0 ? u : Number(d), !Number.isInteger(u) || !Number.isInteger(c) || (d === void 0 &&
|
|
5728
|
+
if (u = Number(l), c = d === void 0 ? u : Number(d), !Number.isInteger(u) || !Number.isInteger(c) || (d === void 0 && i !== void 0 && (c = n), u < t || c > n || u > c)) return null;
|
|
5719
5729
|
}
|
|
5720
|
-
for (let l = u; l <= c; l +=
|
|
5730
|
+
for (let l = u; l <= c; l += a) r.add(l);
|
|
5721
5731
|
}
|
|
5722
5732
|
return r.size ? r : null;
|
|
5723
5733
|
}
|
|
@@ -5732,13 +5742,13 @@ function to(e) {
|
|
|
5732
5742
|
if (!d) return null;
|
|
5733
5743
|
n.push(d);
|
|
5734
5744
|
}
|
|
5735
|
-
const [r, o, s,
|
|
5736
|
-
return
|
|
5745
|
+
const [r, o, s, i, a] = n;
|
|
5746
|
+
return a.has(7) && a.add(0), {
|
|
5737
5747
|
minute: r,
|
|
5738
5748
|
hour: o,
|
|
5739
5749
|
dayOfMonth: s,
|
|
5740
|
-
month:
|
|
5741
|
-
dayOfWeek:
|
|
5750
|
+
month: i,
|
|
5751
|
+
dayOfWeek: a,
|
|
5742
5752
|
anyDayOfMonth: t[2] === "*",
|
|
5743
5753
|
anyDayOfWeek: t[4] === "*"
|
|
5744
5754
|
};
|
|
@@ -5758,63 +5768,63 @@ function ic(e, t, n) {
|
|
|
5758
5768
|
if (o >= jn)
|
|
5759
5769
|
return {
|
|
5760
5770
|
matched: [],
|
|
5761
|
-
skipped: t.map((
|
|
5762
|
-
ruleId:
|
|
5771
|
+
skipped: t.map((a) => ({
|
|
5772
|
+
ruleId: a.id,
|
|
5763
5773
|
reason: `keten te diep (${o} van ${jn})`
|
|
5764
5774
|
}))
|
|
5765
5775
|
};
|
|
5766
|
-
const s = { event: e.payload, subject: e.subject ?? {} },
|
|
5767
|
-
for (const
|
|
5768
|
-
if (!
|
|
5769
|
-
r.push({ ruleId:
|
|
5776
|
+
const s = { event: e.payload, subject: e.subject ?? {} }, i = [];
|
|
5777
|
+
for (const a of t) {
|
|
5778
|
+
if (!a.enabled) {
|
|
5779
|
+
r.push({ ruleId: a.id, reason: "staat uit" });
|
|
5770
5780
|
continue;
|
|
5771
5781
|
}
|
|
5772
|
-
if (
|
|
5782
|
+
if (a.trigger.kind === "schedule") {
|
|
5773
5783
|
if (e.name !== sc) {
|
|
5774
|
-
r.push({ ruleId:
|
|
5784
|
+
r.push({ ruleId: a.id, reason: "luistert op de klok" });
|
|
5775
5785
|
continue;
|
|
5776
5786
|
}
|
|
5777
5787
|
const u = typeof e.payload?.at == "number" ? e.payload.at : Number.NaN;
|
|
5778
5788
|
if (!Number.isFinite(u)) {
|
|
5779
|
-
r.push({ ruleId:
|
|
5789
|
+
r.push({ ruleId: a.id, reason: "tik zonder tijdstip" });
|
|
5780
5790
|
continue;
|
|
5781
5791
|
}
|
|
5782
|
-
if (!oc(
|
|
5783
|
-
r.push({ ruleId:
|
|
5792
|
+
if (!oc(a.trigger.cron, new Date(u))) {
|
|
5793
|
+
r.push({ ruleId: a.id, reason: `niet aan de beurt (${a.trigger.cron})` });
|
|
5784
5794
|
continue;
|
|
5785
5795
|
}
|
|
5786
|
-
} else if (
|
|
5787
|
-
r.push({ ruleId:
|
|
5796
|
+
} else if (a.trigger.kind !== "event") {
|
|
5797
|
+
r.push({ ruleId: a.id, reason: `trigger "${a.trigger.kind}" draait hier niet` });
|
|
5788
5798
|
continue;
|
|
5789
|
-
} else if (
|
|
5790
|
-
r.push({ ruleId:
|
|
5799
|
+
} else if (a.trigger.name !== e.name) {
|
|
5800
|
+
r.push({ ruleId: a.id, reason: `luistert op ${a.trigger.name}` });
|
|
5791
5801
|
continue;
|
|
5792
5802
|
}
|
|
5793
|
-
if (e.causedByRule ===
|
|
5794
|
-
r.push({ ruleId:
|
|
5803
|
+
if (e.causedByRule === a.id) {
|
|
5804
|
+
r.push({ ruleId: a.id, reason: "dit event komt van deze regel zelf" });
|
|
5795
5805
|
continue;
|
|
5796
5806
|
}
|
|
5797
|
-
if (!n(
|
|
5798
|
-
r.push({ ruleId:
|
|
5807
|
+
if (!n(a.when ?? null, s)) {
|
|
5808
|
+
r.push({ ruleId: a.id, reason: "voorwaarde niet waar" });
|
|
5799
5809
|
continue;
|
|
5800
5810
|
}
|
|
5801
|
-
|
|
5811
|
+
i.push({ rule: a, idempotencyKey: `${e.id}:${a.id}:${a.version}` });
|
|
5802
5812
|
}
|
|
5803
|
-
return { matched:
|
|
5813
|
+
return { matched: i, skipped: r };
|
|
5804
5814
|
}
|
|
5805
5815
|
function eg(e, t) {
|
|
5806
5816
|
return { causedByRule: t, depth: (e.depth ?? 0) + 1 };
|
|
5807
5817
|
}
|
|
5808
5818
|
function tg(e, t) {
|
|
5809
|
-
const { event: n, rules: r } = e.input, { matched: o, skipped: s } = ic(n, r, t),
|
|
5810
|
-
if (
|
|
5819
|
+
const { event: n, rules: r } = e.input, { matched: o, skipped: s } = ic(n, r, t), i = o.flatMap((c) => c.rule.then.map((l) => l.action)), a = e.expected?.actions ?? [];
|
|
5820
|
+
if (i.length === a.length && i.every((c, l) => c === a[l]))
|
|
5811
5821
|
return { caseId: e.id, ok: !0 };
|
|
5812
5822
|
const u = s.map((c) => `${c.ruleId}: ${c.reason}`).join(" · ");
|
|
5813
5823
|
return {
|
|
5814
5824
|
caseId: e.id,
|
|
5815
5825
|
ok: !1,
|
|
5816
|
-
got:
|
|
5817
|
-
note:
|
|
5826
|
+
got: i,
|
|
5827
|
+
note: a.length ? `verwacht [${a.join(", ")}], kreeg [${i.join(", ")}]${u ? ` — ${u}` : ""}` : `mocht niet vuren, maar deed [${i.join(", ")}]`
|
|
5818
5828
|
};
|
|
5819
5829
|
}
|
|
5820
5830
|
function ac(e, t) {
|
|
@@ -5874,10 +5884,10 @@ function St(e, t, n) {
|
|
|
5874
5884
|
if (!n) return t - e;
|
|
5875
5885
|
let r = 0, o = e;
|
|
5876
5886
|
for (let s = 0; s < no && o < t; s++) {
|
|
5877
|
-
const
|
|
5878
|
-
if (
|
|
5879
|
-
const
|
|
5880
|
-
u >
|
|
5887
|
+
const i = oo(o, n);
|
|
5888
|
+
if (i) {
|
|
5889
|
+
const a = Math.max(o, i.open), u = Math.min(t, i.close);
|
|
5890
|
+
u > a && (r += u - a);
|
|
5881
5891
|
}
|
|
5882
5892
|
o = so(o, n);
|
|
5883
5893
|
}
|
|
@@ -5887,12 +5897,12 @@ function jt(e, t, n) {
|
|
|
5887
5897
|
if (!n) return e + t;
|
|
5888
5898
|
let r = t, o = e;
|
|
5889
5899
|
for (let s = 0; s < no; s++) {
|
|
5890
|
-
const
|
|
5891
|
-
if (
|
|
5892
|
-
const
|
|
5893
|
-
if (
|
|
5894
|
-
const u =
|
|
5895
|
-
if (r <= u) return
|
|
5900
|
+
const i = oo(o, n);
|
|
5901
|
+
if (i) {
|
|
5902
|
+
const a = Math.max(o, i.open);
|
|
5903
|
+
if (i.close > a) {
|
|
5904
|
+
const u = i.close - a;
|
|
5905
|
+
if (r <= u) return a + r;
|
|
5896
5906
|
r -= u;
|
|
5897
5907
|
}
|
|
5898
5908
|
}
|
|
@@ -5939,19 +5949,19 @@ function gc(e, t, n, r) {
|
|
|
5939
5949
|
return o !== 0 ? { pauseBits: o } : { pauseBits: o, state: "running", dueAt: jt(n, e.remainingMs, r) };
|
|
5940
5950
|
}
|
|
5941
5951
|
function dg({ event: e, at: t, now: n, clocks: r, profile: o }) {
|
|
5942
|
-
const s = Gt(o),
|
|
5952
|
+
const s = Gt(o), i = Math.min(t, n), a = r.map((g) => ({ ...g })), u = [], c = (g, y) => {
|
|
5943
5953
|
y && (u.push({ op: "patch", clockId: g.id, patch: y }), Object.assign(g, y));
|
|
5944
5954
|
}, l = (g) => {
|
|
5945
|
-
for (const y of
|
|
5946
|
-
y.metric === g && c(y, mc(y,
|
|
5955
|
+
for (const y of a)
|
|
5956
|
+
y.metric === g && c(y, mc(y, i));
|
|
5947
5957
|
}, d = (g) => {
|
|
5948
|
-
for (const y of
|
|
5958
|
+
for (const y of a)
|
|
5949
5959
|
g.includes(y.metric) && c(y, Wn(y));
|
|
5950
5960
|
}, f = (g) => {
|
|
5951
|
-
for (const y of
|
|
5961
|
+
for (const y of a) c(y, hc(y, g, i, s));
|
|
5952
5962
|
}, m = (g) => {
|
|
5953
|
-
for (const y of
|
|
5954
|
-
}, b = (g) =>
|
|
5963
|
+
for (const y of a) c(y, gc(y, g, i, s));
|
|
5964
|
+
}, b = (g) => a.reduce((y, p) => p.metric === g ? Math.max(y, p.attempt) : y, 0) + 1, h = (g) => a.some((y) => y.metric === g && Ie(y)), I = (g, y) => {
|
|
5955
5965
|
const p = o.targets.find((E) => E.metric === g);
|
|
5956
5966
|
if (!p) return;
|
|
5957
5967
|
const _ = p.minutes * fc;
|
|
@@ -5966,13 +5976,13 @@ function dg({ event: e, at: t, now: n, clocks: r, profile: o }) {
|
|
|
5966
5976
|
};
|
|
5967
5977
|
switch (e) {
|
|
5968
5978
|
case "apply": {
|
|
5969
|
-
for (const g of
|
|
5979
|
+
for (const g of a)
|
|
5970
5980
|
g.profileId !== o.id && c(g, Wn(g));
|
|
5971
5981
|
for (const g of o.targets) {
|
|
5972
5982
|
if (g.metric === "next_response") continue;
|
|
5973
|
-
|
|
5983
|
+
a.some(
|
|
5974
5984
|
(p) => p.metric === g.metric && p.profileId === o.id
|
|
5975
|
-
) || I(g.metric,
|
|
5985
|
+
) || I(g.metric, i);
|
|
5976
5986
|
}
|
|
5977
5987
|
break;
|
|
5978
5988
|
}
|
|
@@ -5984,7 +5994,7 @@ function dg({ event: e, at: t, now: n, clocks: r, profile: o }) {
|
|
|
5984
5994
|
break;
|
|
5985
5995
|
}
|
|
5986
5996
|
case "inbound": {
|
|
5987
|
-
m(Tt), !h("first_response") && !h("next_response") && I("next_response",
|
|
5997
|
+
m(Tt), !h("first_response") && !h("next_response") && I("next_response", i);
|
|
5988
5998
|
break;
|
|
5989
5999
|
}
|
|
5990
6000
|
case "resolved":
|
|
@@ -5994,7 +6004,7 @@ function dg({ event: e, at: t, now: n, clocks: r, profile: o }) {
|
|
|
5994
6004
|
l("close"), l("resolution"), d(io);
|
|
5995
6005
|
break;
|
|
5996
6006
|
case "reopened":
|
|
5997
|
-
h("resolution") || I("resolution",
|
|
6007
|
+
h("resolution") || I("resolution", i), h("close") || I("close", i);
|
|
5998
6008
|
break;
|
|
5999
6009
|
case "snoozed":
|
|
6000
6010
|
o.pauseOn.includes("snoozed") && f(Et);
|
|
@@ -6035,7 +6045,7 @@ function mg(e, t) {
|
|
|
6035
6045
|
if (!n.length) return;
|
|
6036
6046
|
const r = n.filter((s) => s.state === "running");
|
|
6037
6047
|
return (r.length ? r : n).reduce(
|
|
6038
|
-
(s,
|
|
6048
|
+
(s, i) => wt(i, t) < wt(s, t) ? i : s
|
|
6039
6049
|
);
|
|
6040
6050
|
}
|
|
6041
6051
|
function hg(e, t) {
|
|
@@ -6105,8 +6115,8 @@ const Ac = 864e5, je = (e) => e <= 0 ? 0 : e > 1 ? 1 : e;
|
|
|
6105
6115
|
function Cg(e, t) {
|
|
6106
6116
|
const { direction: n } = e, r = e.startValue ?? 0, o = e.targetValue ?? 0;
|
|
6107
6117
|
if (!Number.isFinite(t)) return 0;
|
|
6108
|
-
const s = n === "down" ? t <= o : t >= o,
|
|
6109
|
-
return (n === "down" ?
|
|
6118
|
+
const s = n === "down" ? t <= o : t >= o, i = o - r;
|
|
6119
|
+
return (n === "down" ? i < 0 : i > 0) ? je((t - r) / i) : s ? 1 : 0;
|
|
6110
6120
|
}
|
|
6111
6121
|
function Sg(e, t) {
|
|
6112
6122
|
const { startDate: n, targetDate: r } = e;
|
|
@@ -6208,12 +6218,12 @@ function wc(e) {
|
|
|
6208
6218
|
}
|
|
6209
6219
|
function Ug(e, t) {
|
|
6210
6220
|
const n = wc(t.text), r = oe(n);
|
|
6211
|
-
if (!r || (e.examples ?? []).some((
|
|
6212
|
-
const o = e.exampleCandidates ?? [], s = o.findIndex((
|
|
6221
|
+
if (!r || (e.examples ?? []).some((i) => oe(i) === r)) return null;
|
|
6222
|
+
const o = e.exampleCandidates ?? [], s = o.findIndex((i) => oe(i.text) === r);
|
|
6213
6223
|
if (s >= 0) {
|
|
6214
6224
|
if (o[s].corrected || !t.corrected) return null;
|
|
6215
|
-
const
|
|
6216
|
-
return
|
|
6225
|
+
const i = [...o];
|
|
6226
|
+
return i[s] = { ...i[s], corrected: !0, addedAt: t.addedAt }, qn(i);
|
|
6217
6227
|
}
|
|
6218
6228
|
return qn([{ ...t, text: n }, ...o]).slice(0, Mc);
|
|
6219
6229
|
}
|
|
@@ -6251,8 +6261,8 @@ function Gg({
|
|
|
6251
6261
|
isRecord: r,
|
|
6252
6262
|
index: o
|
|
6253
6263
|
}) {
|
|
6254
|
-
const s = o.byApp[e] ?? [],
|
|
6255
|
-
return
|
|
6264
|
+
const s = o.byApp[e] ?? [], i = (a) => !!a && (s.includes(a) || r && a !== "apps" && o.visible.includes(a));
|
|
6265
|
+
return i(t) ? t : i(n) ? n : s[0] ?? "apps";
|
|
6256
6266
|
}
|
|
6257
6267
|
const Nc = [
|
|
6258
6268
|
{ key: "home", owner: "assist", icon: "HomeMark", order: 10, sections: ["home"] },
|
|
@@ -6309,8 +6319,8 @@ const Nc = [
|
|
|
6309
6319
|
}
|
|
6310
6320
|
];
|
|
6311
6321
|
function Wg(e, t) {
|
|
6312
|
-
const n = e.search(/[?#]/), r = n < 0 ? e : e.slice(0, n), o = n < 0 ? "" : e.slice(n), [s,
|
|
6313
|
-
return !s || s !== "apps" && s !== "settings" && !t(s) ? null : { workspace: s, ...
|
|
6322
|
+
const n = e.search(/[?#]/), r = n < 0 ? e : e.slice(0, n), o = n < 0 ? "" : e.slice(n), [s, i, ...a] = r.split("/").filter(Boolean);
|
|
6323
|
+
return !s || s !== "apps" && s !== "settings" && !t(s) ? null : { workspace: s, ...i ? { app: i } : {}, path: `/${a.join("/")}${o}` };
|
|
6314
6324
|
}
|
|
6315
6325
|
function qg({ workspace: e, app: t, path: n }) {
|
|
6316
6326
|
if (!t) return `/${e}`;
|
|
@@ -6438,7 +6448,7 @@ function Yg(e) {
|
|
|
6438
6448
|
return !!e.issuedAt && Pc.includes(e.kindKey);
|
|
6439
6449
|
}
|
|
6440
6450
|
function Xg(e, t, n = "sales") {
|
|
6441
|
-
const r = (
|
|
6451
|
+
const r = (a) => e.totals?.byRate?.find((u) => u.taxRateKey === a), o = e.issuedPaper?.billingAddress, s = [o?.street, o?.houseNumber].filter(Boolean).join(" "), i = e.deliveredAt ?? e.periodTo;
|
|
6442
6452
|
return {
|
|
6443
6453
|
sourceApp: n,
|
|
6444
6454
|
documentId: e.id,
|
|
@@ -6466,32 +6476,32 @@ function Xg(e, t, n = "sales") {
|
|
|
6466
6476
|
...o?.country ? { country: o.country } : {}
|
|
6467
6477
|
},
|
|
6468
6478
|
issueDate: te(e.issuedAt ?? Date.now()),
|
|
6469
|
-
...
|
|
6479
|
+
...i ? { taxPointDate: te(i) } : {},
|
|
6470
6480
|
...e.dueAt ? { dueDate: te(e.dueAt) } : {},
|
|
6471
6481
|
currency: e.currency,
|
|
6472
6482
|
...e.fxRate ? { fxRate: e.fxRate } : {},
|
|
6473
|
-
lines: e.lines.filter((
|
|
6474
|
-
const u = e.taxOverrideKey ??
|
|
6483
|
+
lines: e.lines.filter((a) => a.kind === "product" && !a.optional).map((a) => {
|
|
6484
|
+
const u = e.taxOverrideKey ?? a.taxRateKey, c = r(u);
|
|
6475
6485
|
return {
|
|
6476
|
-
description:
|
|
6477
|
-
netCents:
|
|
6478
|
-
taxCents:
|
|
6486
|
+
description: a.name,
|
|
6487
|
+
netCents: a.netCents,
|
|
6488
|
+
taxCents: a.taxCents,
|
|
6479
6489
|
taxRateKey: u,
|
|
6480
6490
|
taxKind: c?.kind ?? "standard",
|
|
6481
6491
|
...c?.percent !== void 0 ? { taxPercent: c.percent } : {},
|
|
6482
|
-
...
|
|
6483
|
-
...
|
|
6492
|
+
...a.ledgerCategoryKey ? { ledgerCategoryKey: a.ledgerCategoryKey } : {},
|
|
6493
|
+
...a.productId ? { productId: a.productId } : {},
|
|
6484
6494
|
// Whose revenue this is: the customer, on every line, for margin per customer.
|
|
6485
6495
|
dimensions: {
|
|
6486
6496
|
customerCompanyId: e.companyId,
|
|
6487
|
-
...
|
|
6497
|
+
...a.dealItemId ? { dealItemId: a.dealItemId } : {}
|
|
6488
6498
|
},
|
|
6489
|
-
...
|
|
6499
|
+
...a.costPriceCents != null ? { costCents: Math.round(a.costPriceCents * a.quantity) } : {},
|
|
6490
6500
|
// What the line bills for (an agreement's window): `to` is exclusive here, inclusive there.
|
|
6491
|
-
...
|
|
6501
|
+
...a.servicePeriod ? {
|
|
6492
6502
|
period: {
|
|
6493
|
-
from: te(
|
|
6494
|
-
to: te(
|
|
6503
|
+
from: te(a.servicePeriod.from),
|
|
6504
|
+
to: te(a.servicePeriod.to - 864e5)
|
|
6495
6505
|
}
|
|
6496
6506
|
} : {}
|
|
6497
6507
|
};
|
|
@@ -6564,9 +6574,9 @@ function ty(e, t) {
|
|
|
6564
6574
|
}
|
|
6565
6575
|
function Lc(e, t) {
|
|
6566
6576
|
const n = j(t).signFlip !== j(e.kindKey).signFlip, r = e.lines.map(
|
|
6567
|
-
({ timeEntryIds: o, agreementLineId: s, ...
|
|
6568
|
-
...
|
|
6569
|
-
quantity: n ? -
|
|
6577
|
+
({ timeEntryIds: o, agreementLineId: s, ...i }) => ({
|
|
6578
|
+
...i,
|
|
6579
|
+
quantity: n ? -i.quantity : i.quantity,
|
|
6570
6580
|
netCents: 0,
|
|
6571
6581
|
taxCents: 0
|
|
6572
6582
|
})
|
|
@@ -6662,7 +6672,7 @@ function ry(e, t = {}) {
|
|
|
6662
6672
|
};
|
|
6663
6673
|
}
|
|
6664
6674
|
function oy(e, t = [], n = Kc) {
|
|
6665
|
-
const r = e.totals ?? { netCents: 0, grossCents: 0, byRate: [] }, o = (
|
|
6675
|
+
const r = e.totals ?? { netCents: 0, grossCents: 0, byRate: [] }, o = (a) => t.find((u) => u.key === a)?.percent ?? 0, s = {
|
|
6666
6676
|
block_id: "lines",
|
|
6667
6677
|
type: "table",
|
|
6668
6678
|
columns: [
|
|
@@ -6672,30 +6682,30 @@ function oy(e, t = [], n = Kc) {
|
|
|
6672
6682
|
{ label: n.net, align: "right" }
|
|
6673
6683
|
],
|
|
6674
6684
|
rows: (e.lines ?? []).map(
|
|
6675
|
-
(
|
|
6685
|
+
(a) => a.kind === "text" ? (
|
|
6676
6686
|
// A text line spans as a heading: empty money cells would read as "free".
|
|
6677
|
-
[
|
|
6687
|
+
[a.name, "", "", ""]
|
|
6678
6688
|
) : [
|
|
6679
|
-
Uc(
|
|
6680
|
-
Fc(
|
|
6689
|
+
Uc(a.name, a.description, a.optional, n.optional),
|
|
6690
|
+
Fc(a, n),
|
|
6681
6691
|
// A rated line has no unit price: its amount is the rated total (plan 049 L).
|
|
6682
|
-
wr(
|
|
6683
|
-
z(
|
|
6692
|
+
wr(a) ? "" : a.pricePer ? [z(a.unitPriceCents), n.per[a.pricePer]].join(" ") : z(a.unitPriceCents),
|
|
6693
|
+
z(a.netCents)
|
|
6684
6694
|
]
|
|
6685
6695
|
)
|
|
6686
|
-
},
|
|
6696
|
+
}, i = {
|
|
6687
6697
|
block_id: "totals",
|
|
6688
6698
|
type: "totals",
|
|
6689
6699
|
rows: [
|
|
6690
6700
|
{ label: n.net, amount: z(r.netCents) },
|
|
6691
6701
|
{ label: n.gross, amount: z(r.grossCents), emphasis: !0 }
|
|
6692
6702
|
],
|
|
6693
|
-
taxRows: r.byRate.map((
|
|
6694
|
-
label: `${n.tax} ${
|
|
6695
|
-
amount: z(
|
|
6703
|
+
taxRows: r.byRate.map((a) => ({
|
|
6704
|
+
label: `${n.tax} ${a.percent ?? o(a.taxRateKey)}%`,
|
|
6705
|
+
amount: z(a.taxCents)
|
|
6696
6706
|
}))
|
|
6697
6707
|
};
|
|
6698
|
-
return { lines: [s], totals: [
|
|
6708
|
+
return { lines: [s], totals: [i] };
|
|
6699
6709
|
}
|
|
6700
6710
|
const Kc = {
|
|
6701
6711
|
description: "Omschrijving",
|
|
@@ -6818,16 +6828,16 @@ Hierbij onze creditnota. De onderstaande bedragen worden met u verrekend.`
|
|
|
6818
6828
|
}, Wc = (e, t) => new Date(Date.parse(`${e}T00:00:00Z`) + t * 864e5).toISOString().slice(0, 10);
|
|
6819
6829
|
function qc(e, t, n) {
|
|
6820
6830
|
if (e.dueAt == null || e.openCents < (t.minOpenCents ?? 0)) return null;
|
|
6821
|
-
const r = [...t.steps].sort((
|
|
6831
|
+
const r = [...t.steps].sort((a, u) => a.level - u.level), o = r.find((a) => a.level > e.dunningLevel);
|
|
6822
6832
|
if (!o) return r.length ? "done" : null;
|
|
6823
|
-
const s = e.dunningLevel && e.lastDunningAt ? e.lastDunningAt : e.dueAt,
|
|
6824
|
-
return
|
|
6833
|
+
const s = e.dunningLevel && e.lastDunningAt ? e.lastDunningAt : e.dueAt, i = Wc(te(s), o.afterDays);
|
|
6834
|
+
return i <= n ? { row: e, step: o, dueOn: i } : null;
|
|
6825
6835
|
}
|
|
6826
6836
|
function cy(e, t, n) {
|
|
6827
6837
|
const r = [], o = [];
|
|
6828
6838
|
for (const s of e) {
|
|
6829
|
-
const
|
|
6830
|
-
|
|
6839
|
+
const i = qc(s, t, n);
|
|
6840
|
+
i === "done" ? o.push(s) : i && r.push(i);
|
|
6831
6841
|
}
|
|
6832
6842
|
return { due: r, waiting: o };
|
|
6833
6843
|
}
|
|
@@ -6883,7 +6893,7 @@ const vy = [
|
|
|
6883
6893
|
"other"
|
|
6884
6894
|
], Xc = (e, t) => !e.direction || e.direction === t;
|
|
6885
6895
|
function Iy(e, t, n = {}) {
|
|
6886
|
-
const r = e.filter((s) => !s.archived && Xc(s, t)), o = (s) => s ? r.find((
|
|
6896
|
+
const r = e.filter((s) => !s.archived && Xc(s, t)), o = (s) => s ? r.find((i) => i.code === s) : void 0;
|
|
6887
6897
|
return o(n.explicit) ?? o(n.role) ?? r.find((s) => s.isDefault && s.direction === t) ?? r.find((s) => s.isDefault) ?? r[0] ?? null;
|
|
6888
6898
|
}
|
|
6889
6899
|
function _y(e, t) {
|
|
@@ -6944,7 +6954,7 @@ function tu(e, t) {
|
|
|
6944
6954
|
function Ty(e, t) {
|
|
6945
6955
|
if (!po(e)) return null;
|
|
6946
6956
|
const n = e.totals?.grossCents ?? 0, r = (e.dunning ?? []).reduce(
|
|
6947
|
-
(s,
|
|
6957
|
+
(s, i) => !s || i.level > s.level ? i : s,
|
|
6948
6958
|
void 0
|
|
6949
6959
|
), o = e.dueAt != null ? tu(te(e.dueAt), t) : 0;
|
|
6950
6960
|
return {
|
|
@@ -7015,8 +7025,8 @@ function Py(e, t) {
|
|
|
7015
7025
|
let r = 0;
|
|
7016
7026
|
const o = [], s = e.priority ?? "normal";
|
|
7017
7027
|
if (Re[s] > 0 && (r += Re[s], o.push(`priority:${s}`)), typeof e.dueDate == "number") {
|
|
7018
|
-
const
|
|
7019
|
-
|
|
7028
|
+
const i = ou(e.dueDate, t.now);
|
|
7029
|
+
i < 0 ? (r += 35, o.push("overdue")) : i === 0 && (r += 20, o.push("due-today"));
|
|
7020
7030
|
}
|
|
7021
7031
|
return e.source?.initiator === "system" && e.source.systemReason && (r += 15, o.push(`auto:${e.source.systemReason}`)), { score: r, reasons: o };
|
|
7022
7032
|
}
|
|
@@ -7216,8 +7226,8 @@ function vu(e) {
|
|
|
7216
7226
|
function hb(e, t = []) {
|
|
7217
7227
|
const n = new Set(t), r = [], o = [];
|
|
7218
7228
|
for (const s of e) {
|
|
7219
|
-
const
|
|
7220
|
-
n.has(
|
|
7229
|
+
const i = vu(s);
|
|
7230
|
+
n.has(i) || (n.add(i), r.push(s), o.push(i));
|
|
7221
7231
|
}
|
|
7222
7232
|
return { sources: r, keys: o };
|
|
7223
7233
|
}
|
|
@@ -7263,11 +7273,11 @@ function Tb(e) {
|
|
|
7263
7273
|
) ? { admit: !1, reason: "busy" } : { admit: !0 };
|
|
7264
7274
|
}
|
|
7265
7275
|
function Iu(e, t) {
|
|
7266
|
-
const n = new Set(e.disabledIntents ?? []), r = e.intentOverrides ?? {}, o = t.intents.filter((
|
|
7276
|
+
const n = new Set(e.disabledIntents ?? []), r = e.intentOverrides ?? {}, o = t.intents.filter((i) => !n.has(i.intent)).map((i) => Au(i, r[i.intent]));
|
|
7267
7277
|
if (!e.extraIntents || e.extraIntents.length === 0) return o;
|
|
7268
|
-
const s = new Set(o.map((
|
|
7269
|
-
for (const
|
|
7270
|
-
s.has(
|
|
7278
|
+
const s = new Set(o.map((i) => i.intent));
|
|
7279
|
+
for (const i of e.extraIntents)
|
|
7280
|
+
s.has(i.intent) || (o.push(i), s.add(i.intent));
|
|
7271
7281
|
return o;
|
|
7272
7282
|
}
|
|
7273
7283
|
function _u(e, t) {
|
|
@@ -7319,8 +7329,8 @@ function Db(e, t, n) {
|
|
|
7319
7329
|
}
|
|
7320
7330
|
function Nb(e, t, n = {}) {
|
|
7321
7331
|
let r = t, o = e;
|
|
7322
|
-
for (const [s,
|
|
7323
|
-
r = r.split("{" + s + "}").join(String(
|
|
7332
|
+
for (const [s, i] of Object.entries(n))
|
|
7333
|
+
r = r.split("{" + s + "}").join(String(i)), o += " " + s + "=" + encodeURIComponent(String(i));
|
|
7324
7334
|
return r + " [" + o + "]";
|
|
7325
7335
|
}
|
|
7326
7336
|
const Cu = / \[([a-z][a-z0-9_]*)((?: [a-zA-Z]\w*=[^\s\]]*)*)\]$/;
|
|
@@ -7336,14 +7346,14 @@ function Rb(e) {
|
|
|
7336
7346
|
}
|
|
7337
7347
|
function $b(e, t) {
|
|
7338
7348
|
const n = t ?? Su(e), r = [];
|
|
7339
|
-
let o = [], s = "",
|
|
7340
|
-
for (let
|
|
7341
|
-
const u = e[
|
|
7342
|
-
|
|
7343
|
-
` || u === "\r" ? (u === "\r" && e[
|
|
7344
|
-
` &&
|
|
7349
|
+
let o = [], s = "", i = !1;
|
|
7350
|
+
for (let a = 0; a < e.length; a++) {
|
|
7351
|
+
const u = e[a];
|
|
7352
|
+
i ? u === '"' && e[a + 1] === '"' ? (s += '"', a++) : u === '"' ? i = !1 : s += u : u === '"' && s === "" ? i = !0 : u === n ? (o.push(s), s = "") : u === `
|
|
7353
|
+
` || u === "\r" ? (u === "\r" && e[a + 1] === `
|
|
7354
|
+
` && a++, o.push(s), s = "", o.some((c) => c !== "") && r.push(o), o = []) : s += u;
|
|
7345
7355
|
}
|
|
7346
|
-
return o.push(s), o.some((
|
|
7356
|
+
return o.push(s), o.some((a) => a !== "") && r.push(o), r;
|
|
7347
7357
|
}
|
|
7348
7358
|
function Su(e) {
|
|
7349
7359
|
const t = e.search(/\r?\n/), n = t === -1 ? e : e.slice(0, t), r = (o) => n.split(o).length - 1;
|
|
@@ -7384,13 +7394,13 @@ function Pb(e) {
|
|
|
7384
7394
|
for (; r < e.length; ) {
|
|
7385
7395
|
const o = e[r], s = o < 128 ? 0 : o >> 5 === 6 ? 1 : o >> 4 === 14 ? 2 : o >> 3 === 30 ? 3 : -1;
|
|
7386
7396
|
if (s < 0 || r + s >= e.length) return Xn(e, t);
|
|
7387
|
-
let
|
|
7388
|
-
for (let
|
|
7389
|
-
const u = e[r +
|
|
7397
|
+
let i = s === 0 ? o : o & 63 >> s;
|
|
7398
|
+
for (let a = 1; a <= s; a++) {
|
|
7399
|
+
const u = e[r + a];
|
|
7390
7400
|
if (u >> 6 !== 2) return Xn(e, t);
|
|
7391
|
-
|
|
7401
|
+
i = i << 6 | u & 63;
|
|
7392
7402
|
}
|
|
7393
|
-
n.push(
|
|
7403
|
+
n.push(i), r += s + 1;
|
|
7394
7404
|
}
|
|
7395
7405
|
return yo(n);
|
|
7396
7406
|
}
|
|
@@ -7826,15 +7836,15 @@ function Yb(e) {
|
|
|
7826
7836
|
}, s = (f, m) => {
|
|
7827
7837
|
r && r.style !== f && o(), r ? r.items.push(er(m)) : r = { style: f, items: [er(m)] };
|
|
7828
7838
|
};
|
|
7829
|
-
let
|
|
7839
|
+
let i = [], a = [];
|
|
7830
7840
|
const u = () => {
|
|
7831
|
-
if (
|
|
7832
|
-
const f =
|
|
7833
|
-
f && n.push({ type: "paragraph", text: f }),
|
|
7841
|
+
if (i.length) {
|
|
7842
|
+
const f = i.join("").trim();
|
|
7843
|
+
f && n.push({ type: "paragraph", text: f }), i = [];
|
|
7834
7844
|
}
|
|
7835
7845
|
}, c = () => {
|
|
7836
|
-
|
|
7837
|
-
`) }),
|
|
7846
|
+
a.length && (n.push({ type: "quote", text: a.join(`
|
|
7847
|
+
`) }), a = []);
|
|
7838
7848
|
}, l = () => {
|
|
7839
7849
|
u(), c(), o();
|
|
7840
7850
|
};
|
|
@@ -7881,7 +7891,7 @@ function Yb(e) {
|
|
|
7881
7891
|
continue;
|
|
7882
7892
|
}
|
|
7883
7893
|
if (/^>\s?/.test(f)) {
|
|
7884
|
-
u(), o(),
|
|
7894
|
+
u(), o(), a.push(f.replace(/^>\s?/, "")), d++;
|
|
7885
7895
|
continue;
|
|
7886
7896
|
}
|
|
7887
7897
|
if (f.trim() === "") {
|
|
@@ -7890,7 +7900,7 @@ function Yb(e) {
|
|
|
7890
7900
|
}
|
|
7891
7901
|
c(), o();
|
|
7892
7902
|
const I = Jn.test(f);
|
|
7893
|
-
|
|
7903
|
+
i.push(f.replace(Jn, "").trim() + (I ? `
|
|
7894
7904
|
` : " ")), d++;
|
|
7895
7905
|
}
|
|
7896
7906
|
return l(), n;
|
|
@@ -7920,7 +7930,7 @@ function r0(e, t) {
|
|
|
7920
7930
|
}
|
|
7921
7931
|
const tr = "main", fe = (e) => `${e.app}:${e.entry}`, st = (e) => fe({ app: e.app, entry: e.entry.id }), nr = (e) => new Set(e.flatMap((t) => t.items.map((n) => n.app)));
|
|
7922
7932
|
function o0(e) {
|
|
7923
|
-
const { manifests: t, defaults: n, org: r, prefs: o, teamIds: s, can:
|
|
7933
|
+
const { manifests: t, defaults: n, org: r, prefs: o, teamIds: s, can: i } = e, a = new Set(t.map((v) => v.name)), u = new Map(r.map((v) => [v.key, v])), c = new Set(n.map((v) => v.key)), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
7924
7934
|
for (const v of t)
|
|
7925
7935
|
for (const S of v.nav ?? [])
|
|
7926
7936
|
for (const R of S.entries) {
|
|
@@ -7959,7 +7969,7 @@ function o0(e) {
|
|
|
7959
7969
|
...S.label ? { label: { text: S.label } } : {},
|
|
7960
7970
|
items: (S.entries ?? []).flatMap((R) => l.get(fe(R)) ?? [])
|
|
7961
7971
|
})), h = [
|
|
7962
|
-
...n.filter((v) =>
|
|
7972
|
+
...n.filter((v) => a.has(v.owner)).map((v) => ({
|
|
7963
7973
|
key: v.key,
|
|
7964
7974
|
label: { key: `workspace_${v.key}` },
|
|
7965
7975
|
icon: v.icon,
|
|
@@ -7973,7 +7983,7 @@ function o0(e) {
|
|
|
7973
7983
|
order: Number.MAX_SAFE_INTEGER,
|
|
7974
7984
|
sections: b(v)
|
|
7975
7985
|
}))
|
|
7976
|
-
], I = new Set(h.flatMap((v) => [...nr(v.sections)])), g = (v) => v.map((S) => ({ ...S, items: S.items.filter((R) => (R.entry.permissions ?? []).every(
|
|
7986
|
+
], I = new Set(h.flatMap((v) => [...nr(v.sections)])), g = (v) => v.map((S) => ({ ...S, items: S.items.filter((R) => (R.entry.permissions ?? []).every(i)) })).filter((S) => S.items.length > 0), y = (v) => o.hidden.includes(v) ? !1 : o.shown.includes(v) ? !0 : p(v), p = (v) => {
|
|
7977
7987
|
const S = u.get(v);
|
|
7978
7988
|
if (S?.visibleByDefault === !1) return !1;
|
|
7979
7989
|
const R = S?.audience?.teamIds;
|
|
@@ -8211,10 +8221,10 @@ function Ku(e) {
|
|
|
8211
8221
|
}
|
|
8212
8222
|
function Uu(e, t) {
|
|
8213
8223
|
const n = e.split("/").filter(Boolean), r = t.split("/").filter(Boolean), o = {};
|
|
8214
|
-
return n.forEach((s,
|
|
8224
|
+
return n.forEach((s, i) => {
|
|
8215
8225
|
if (s.startsWith(":")) {
|
|
8216
|
-
const
|
|
8217
|
-
u && (o[
|
|
8226
|
+
const a = s.endsWith("?") ? s.slice(1, -1) : s.slice(1), u = r[i];
|
|
8227
|
+
u && (o[a] = u);
|
|
8218
8228
|
}
|
|
8219
8229
|
}), o;
|
|
8220
8230
|
}
|
|
@@ -8242,8 +8252,8 @@ function S0(e) {
|
|
|
8242
8252
|
function Fu(e, t) {
|
|
8243
8253
|
const n = e.split("/").filter(Boolean), r = t.split("/").filter(Boolean);
|
|
8244
8254
|
for (let o = 0; o < Math.min(n.length, r.length); o++) {
|
|
8245
|
-
const s = n[o].startsWith(":"),
|
|
8246
|
-
if (s !==
|
|
8255
|
+
const s = n[o].startsWith(":"), i = r[o].startsWith(":");
|
|
8256
|
+
if (s !== i) return i;
|
|
8247
8257
|
}
|
|
8248
8258
|
return n.length > r.length;
|
|
8249
8259
|
}
|
|
@@ -8560,10 +8570,10 @@ function el(e, t) {
|
|
|
8560
8570
|
return o / r.size;
|
|
8561
8571
|
}
|
|
8562
8572
|
function tl(e, t = Hu) {
|
|
8563
|
-
const n = e.filter((
|
|
8573
|
+
const n = e.filter((i) => !i.partial && typeof i.text == "string");
|
|
8564
8574
|
if (!n.length) return { text: "", segmentCount: 0 };
|
|
8565
|
-
const o = n.reduce((
|
|
8566
|
-
return { text: n.filter((
|
|
8575
|
+
const o = n.reduce((i, a) => Math.max(i, a.endedAt ?? 0), 0) - t;
|
|
8576
|
+
return { text: n.filter((i) => (i.endedAt ?? 0) >= o).map((i) => Vu(i.text).trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), segmentCount: n.length };
|
|
8567
8577
|
}
|
|
8568
8578
|
const nl = 60;
|
|
8569
8579
|
function D0(e, t, n = nl) {
|
|
@@ -8581,8 +8591,8 @@ function N0(e) {
|
|
|
8581
8591
|
const s = o.segmentCount - (r.lastSegmentCount ?? 0);
|
|
8582
8592
|
if (r.lastQueryTerms && s < Yu)
|
|
8583
8593
|
return { trigger: !1, reason: "too_few_new" };
|
|
8584
|
-
const
|
|
8585
|
-
return
|
|
8594
|
+
const i = Ju(o.text);
|
|
8595
|
+
return i.length ? r.lastQueryTerms?.length && el(i, r.lastQueryTerms) < Xu ? { trigger: !1, reason: "same_topic" } : { trigger: !0, text: o.text, terms: i, segmentCount: o.segmentCount } : { trigger: !1, reason: "no_speech" };
|
|
8586
8596
|
}
|
|
8587
8597
|
const R0 = [
|
|
8588
8598
|
"personal",
|
|
@@ -8663,16 +8673,16 @@ function ir(e, t) {
|
|
|
8663
8673
|
if (o.startsWith("00")) return sr(o.slice(2));
|
|
8664
8674
|
const s = or(t) ?? or(rl);
|
|
8665
8675
|
if (!s) return null;
|
|
8666
|
-
const
|
|
8667
|
-
if (
|
|
8668
|
-
const
|
|
8669
|
-
return Ee(
|
|
8676
|
+
const i = s.trunkPrefix;
|
|
8677
|
+
if (i && o.startsWith(i)) {
|
|
8678
|
+
const a = o.slice(i.length);
|
|
8679
|
+
return Ee(a, s) ? `+${s.callingCode}${a}` : null;
|
|
8670
8680
|
}
|
|
8671
8681
|
if (o.startsWith(s.callingCode)) {
|
|
8672
|
-
const
|
|
8673
|
-
if (Ee(
|
|
8682
|
+
const a = o.slice(s.callingCode.length);
|
|
8683
|
+
if (Ee(a, s)) return `+${s.callingCode}${a}`;
|
|
8674
8684
|
}
|
|
8675
|
-
return !
|
|
8685
|
+
return !i && Ee(o, s) ? `+${s.callingCode}${o}` : null;
|
|
8676
8686
|
}
|
|
8677
8687
|
function L0(e, t = 9) {
|
|
8678
8688
|
const n = (e ?? "").replace(/\D/g, "");
|
|
@@ -8823,8 +8833,8 @@ function yl(e) {
|
|
|
8823
8833
|
}).replace(
|
|
8824
8834
|
/<a\b([^>]*)>([\s\S]*?)<\/a\s*>/gi,
|
|
8825
8835
|
(n, r, o) => {
|
|
8826
|
-
const s = cr(o.replace(/<[^>]*>/g, "")),
|
|
8827
|
-
return ml.test(
|
|
8836
|
+
const s = cr(o.replace(/<[^>]*>/g, "")), i = it(r, "href");
|
|
8837
|
+
return ml.test(i) ? `[${s || at(i)}](${at(i)})` : s;
|
|
8828
8838
|
}
|
|
8829
8839
|
);
|
|
8830
8840
|
}
|
|
@@ -8844,19 +8854,19 @@ function Sl(e) {
|
|
|
8844
8854
|
}
|
|
8845
8855
|
function El(e) {
|
|
8846
8856
|
const t = [];
|
|
8847
|
-
for (const
|
|
8848
|
-
const
|
|
8849
|
-
for (const u of
|
|
8857
|
+
for (const i of e.matchAll(vl)) {
|
|
8858
|
+
const a = [];
|
|
8859
|
+
for (const u of i[1].matchAll(Il)) {
|
|
8850
8860
|
const c = Sl(u[3]);
|
|
8851
8861
|
if (_l(u[3], c)) return null;
|
|
8852
|
-
|
|
8862
|
+
a.push({ text: c, align: Cl(u[2]) });
|
|
8853
8863
|
}
|
|
8854
|
-
if (
|
|
8855
|
-
|
|
8864
|
+
if (a.length === 0) return null;
|
|
8865
|
+
a.some((u) => u.text !== "") && t.push(a);
|
|
8856
8866
|
}
|
|
8857
8867
|
const n = t[0]?.length ?? 0;
|
|
8858
|
-
if (t.length < 2 || n < 2 || t.some((
|
|
8859
|
-
const r = (
|
|
8868
|
+
if (t.length < 2 || n < 2 || t.some((i) => i.length !== n)) return null;
|
|
8869
|
+
const r = (i) => `| ${i.map((a) => a.text).join(" | ")} |`, o = t[1].map((i) => kl[i.align]).join(" | "), s = t.slice(1).map(r).join(`
|
|
8860
8870
|
`);
|
|
8861
8871
|
return `
|
|
8862
8872
|
|
|
@@ -8939,9 +8949,9 @@ function W0(e) {
|
|
|
8939
8949
|
function ko(e, t) {
|
|
8940
8950
|
if (typeof e != "string" || !e) return "";
|
|
8941
8951
|
let n = e.length;
|
|
8942
|
-
for (const
|
|
8943
|
-
const
|
|
8944
|
-
|
|
8952
|
+
for (const i of dl) {
|
|
8953
|
+
const a = e.search(i);
|
|
8954
|
+
a >= 0 && a < n && (n = a);
|
|
8945
8955
|
}
|
|
8946
8956
|
const r = e.slice(0, n);
|
|
8947
8957
|
let o = fr(dr(ur(r, t)));
|