@infuro/cms-core 1.0.68 → 1.0.70
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/{OrderTrackPage-W3J6WIG2.js → OrderTrackPage-VBZUVZOU.js} +1 -1
- package/dist/{OrderTrackPage-Z6FCJQYY.cjs → OrderTrackPage-VFIXWJOW.cjs} +4 -4
- package/dist/admin.cjs +2831 -2680
- package/dist/admin.js +1590 -1439
- package/dist/api.cjs +57 -57
- package/dist/api.js +24 -24
- package/dist/auth.cjs +62 -62
- package/dist/auth.js +6 -6
- package/dist/{chunk-XJNNOSJR.js → chunk-2BNVRFUQ.js} +1 -1
- package/dist/chunk-2JHGIWH7.cjs +2700 -0
- package/dist/{chunk-3DZRIZOD.cjs → chunk-3ASNJS2H.cjs} +3 -3
- package/dist/{chunk-N4LBZXBG.js → chunk-3LF4RYAJ.js} +360 -30
- package/dist/{chunk-7NMT3GBR.cjs → chunk-3LQS4ATQ.cjs} +4 -4
- package/dist/{chunk-P6S4XFZO.cjs → chunk-47G65M5Q.cjs} +2 -2
- package/dist/{chunk-UMC7W5G3.cjs → chunk-4MNVIGVJ.cjs} +11 -11
- package/dist/{chunk-OY2YTBMP.cjs → chunk-4WZNRVEZ.cjs} +3 -3
- package/dist/chunk-5BKT4CS5.js +28 -0
- package/dist/{chunk-IKTBZJHT.js → chunk-5DSY3GQI.js} +1 -1
- package/dist/{chunk-AYERBA7I.js → chunk-5NVGWJSY.js} +1 -1
- package/dist/{chunk-HF3L2GIT.cjs → chunk-5YMKJ3TH.cjs} +16 -16
- package/dist/{chunk-MYUGQHU4.js → chunk-7NQMGB2S.js} +162 -51
- package/dist/{chunk-SYBOCAWB.js → chunk-7QJI56OL.js} +1 -1
- package/dist/{chunk-DBPSJYLZ.js → chunk-BK5XW5XH.js} +1 -1
- package/dist/{chunk-SUUD7OUG.cjs → chunk-BQQMTQ4C.cjs} +27 -27
- package/dist/{chunk-6YOQ7G5O.js → chunk-CFUSYGSA.js} +1 -1
- package/dist/{chunk-OOTLNH63.cjs → chunk-CIZZX57T.cjs} +2 -2
- package/dist/{chunk-5NOZSG6J.js → chunk-CJY2HUJC.js} +20 -20
- package/dist/{chunk-HBUV73RB.cjs → chunk-CKTRA3Q2.cjs} +81 -81
- package/dist/{chunk-7L6KWI7S.cjs → chunk-CTTV375J.cjs} +13 -13
- package/dist/{chunk-2IAXTKQN.cjs → chunk-DZNWS2MM.cjs} +2 -2
- package/dist/{chunk-M5GPOPGX.cjs → chunk-E62LKM6Z.cjs} +2 -2
- package/dist/{chunk-CRFV5WJK.js → chunk-ECNYZG6T.js} +1 -1
- package/dist/{chunk-OVTOP42W.js → chunk-ECUGNV2I.js} +2 -58
- package/dist/{chunk-TZEMLHSP.cjs → chunk-EYUBL7YH.cjs} +7 -7
- package/dist/{chunk-OV5TRZET.cjs → chunk-FNLF6G2N.cjs} +27 -27
- package/dist/{chunk-SKJH7PX4.js → chunk-HZZTDM5J.js} +3 -3
- package/dist/{chunk-TJ2MIQUT.cjs → chunk-JRW3GQD4.cjs} +4 -4
- package/dist/{chunk-3K5AIEIZ.js → chunk-JYRFSFXH.js} +1 -1
- package/dist/{chunk-GWDI752Q.js → chunk-K6JT7BKY.js} +59 -2
- package/dist/{chunk-WKDBMDUX.js → chunk-K6RXCLD5.js} +1 -1
- package/dist/{chunk-PA6YDMFZ.cjs → chunk-K742UE6S.cjs} +13 -12
- package/dist/{chunk-WFMVD567.cjs → chunk-KB7EBYPR.cjs} +9 -67
- package/dist/{chunk-H3IVLIPR.cjs → chunk-KJB5LBFQ.cjs} +63 -4
- package/dist/{chunk-O4AFPDQ4.cjs → chunk-LCZZ3S4I.cjs} +49 -49
- package/dist/{chunk-7JCCPQEF.js → chunk-LJ5C4RBF.js} +3 -3
- package/dist/{chunk-EIZKW2PF.js → chunk-LY7CDNC6.js} +1 -1
- package/dist/{chunk-MQBT33IV.js → chunk-MGT4DJ2D.js} +1 -1
- package/dist/{chunk-GN4LKG4V.cjs → chunk-NIBEGDD4.cjs} +18 -18
- package/dist/{chunk-ZY64VJMS.js → chunk-NQF6H656.js} +2 -2
- package/dist/{chunk-22XKONB5.cjs → chunk-OP624LWU.cjs} +1204 -1093
- package/dist/{chunk-ZIT4IP6N.js → chunk-PQJIJ4ZX.js} +6 -6
- package/dist/{chunk-HY3AXLOI.cjs → chunk-PRXVSSIF.cjs} +13 -13
- package/dist/{chunk-TDV6EJHV.js → chunk-PRZOLCFW.js} +2 -2
- package/dist/{chunk-VM6OVUUM.cjs → chunk-QN6PZLAP.cjs} +40 -40
- package/dist/{chunk-UPLVMVRX.cjs → chunk-RQCXRCYM.cjs} +2 -2
- package/dist/{chunk-Z5G54EGD.js → chunk-SCE2GIKH.js} +5 -5
- package/dist/{chunk-WUQAOTHA.js → chunk-SERRQ736.js} +1 -1
- package/dist/{chunk-SMHQV3WL.cjs → chunk-TTOEY7AH.cjs} +496 -166
- package/dist/{chunk-FLUF2GZH.js → chunk-W2ZTGLUH.js} +2 -1
- package/dist/{chunk-JC6DLWTE.js → chunk-WQZ4AH2P.js} +1 -1
- package/dist/{chunk-D5FBNKQM.cjs → chunk-WXH3GMCF.cjs} +8 -8
- package/dist/chunk-XHPRD45G.cjs +32 -0
- package/dist/{chunk-THL5JDWJ.cjs → chunk-Y54WDY2O.cjs} +2 -2
- package/dist/{chunk-YRCKEGL2.js → chunk-YDMHG6BA.js} +1 -1
- package/dist/chunk-YHVA5NHI.js +2698 -0
- package/dist/{chunk-JXF23MPG.js → chunk-ZMIMKNSQ.js} +1 -1
- package/dist/cli.cjs +10 -10
- package/dist/cli.js +1 -1
- package/dist/email-queue-BJDH2ID7.cjs +29 -0
- package/dist/email-queue-MWP4R67H.js +8 -0
- package/dist/email-service-6JODEMUA.js +3 -0
- package/dist/email-service-VA4Q4ZRB.cjs +28 -0
- package/dist/emit-order-notification-trigger-I4HQSTEN.cjs +16 -0
- package/dist/emit-order-notification-trigger-TBXAZAPS.js +3 -0
- package/dist/erp-config-enabled-32XTHBBT.cjs +11 -0
- package/dist/erp-config-enabled-CASE5YVI.js +2 -0
- package/dist/erp-order-invoice-5O42ZKC5.cjs +28 -0
- package/dist/erp-order-invoice-JEQKFXG4.js +7 -0
- package/dist/{event-order-defaults-DU7V3YND.cjs → event-order-defaults-TR45WAQQ.cjs} +10 -10
- package/dist/{event-order-defaults-H4RT7NMR.js → event-order-defaults-VXYO6NHT.js} +2 -2
- package/dist/generate-local-invoice-pdf-2NCA2WBL.cjs +12 -0
- package/dist/generate-local-invoice-pdf-XUH6GYEJ.js +3 -0
- package/dist/hooks.cjs +24 -24
- package/dist/hooks.js +2 -2
- package/dist/index.cjs +504 -504
- package/dist/index.js +39 -39
- package/dist/interpolate-KD37IRF2.js +2 -0
- package/dist/interpolate-WP6OSJHN.cjs +11 -0
- package/dist/{invoice-templates-RB462AQN.cjs → invoice-templates-2ESQ7K4N.cjs} +5 -5
- package/dist/invoice-templates-3AXTXERZ.js +2 -0
- package/dist/middleware.cjs +4 -4
- package/dist/middleware.js +2 -2
- package/dist/{order-assignees-handlers-KF7RMTV5.cjs → order-assignees-handlers-E6PQZP4H.cjs} +25 -6
- package/dist/{order-assignees-handlers-L3RVKUBS.js → order-assignees-handlers-YCT3Q3KC.js} +23 -4
- package/dist/{order-completion-otp-handlers-DDQREULW.cjs → order-completion-otp-handlers-2ZKRK5SN.cjs} +25 -25
- package/dist/{order-completion-otp-handlers-NROWBGXN.js → order-completion-otp-handlers-KHLZQQJX.js} +12 -12
- package/dist/{order-inventory-76V4XIGW.js → order-inventory-R3AU6N4V.js} +2 -2
- package/dist/{order-inventory-2MYRKEPC.cjs → order-inventory-UUFPWLBW.cjs} +10 -10
- package/dist/order-notification-dispatcher-37KDVHBM.cjs +38 -0
- package/dist/order-notification-dispatcher-Z3MXNF4U.js +13 -0
- package/dist/paid-order-erp-GRXR2OG6.js +3 -0
- package/dist/paid-order-erp-X5QHPI23.cjs +12 -0
- package/dist/pg-boss-service-CMW3KQJM.js +2 -0
- package/dist/pg-boss-service-GA6ZVD5G.cjs +15 -0
- package/dist/{razorpay-U23LGY72.cjs → razorpay-GP2DXVP2.cjs} +2 -2
- package/dist/{razorpay-KLO2KNCB.js → razorpay-I3G5LNYH.js} +1 -1
- package/dist/{rbac-debug-db-DFZWZ6GV.js → rbac-debug-db-JK3U5UZK.js} +2 -2
- package/dist/{rbac-debug-db-KWV7D5PQ.cjs → rbac-debug-db-S3D6N6HN.cjs} +4 -4
- package/dist/resolve-invoice-asset-url-64QQUVC3.js +2 -0
- package/dist/resolve-invoice-asset-url-J7WAMD26.cjs +11 -0
- package/dist/retire-soft-deleted-unique-DZALT537.cjs +15 -0
- package/dist/{retire-soft-deleted-unique-NXQIH4BC.js → retire-soft-deleted-unique-F25KZBZK.js} +2 -2
- package/dist/sms-defaults-DSO3M26Y.js +2 -0
- package/dist/{sms-defaults-KCOPKQBA.cjs → sms-defaults-GDFILHHR.cjs} +5 -5
- package/dist/{sms-notification-templates-handlers-SJLO7JGZ.js → sms-notification-templates-handlers-ZGDCVS5Z.js} +1 -1
- package/dist/{sms-notification-templates-handlers-YSB3L2PK.cjs → sms-notification-templates-handlers-ZKLKFRFZ.cjs} +3 -3
- package/dist/{stripe-VU6OEG2D.cjs → stripe-2APRZHKU.cjs} +2 -2
- package/dist/{stripe-4FD27QVJ.js → stripe-7CO2ETTN.js} +1 -1
- package/dist/theme.cjs +10 -10
- package/dist/theme.js +3 -3
- package/dist/vendor-invite-status-45ZCWKCX.js +2 -0
- package/dist/{vendor-invite-status-77O7ZQ3U.cjs → vendor-invite-status-AT2E4FUA.cjs} +5 -5
- package/package.json +2 -1
- package/dist/chunk-SHUYVCID.js +0 -4
- package/dist/chunk-USNT2KNT.cjs +0 -6
- package/dist/chunk-Z5OB5QGN.js +0 -465
- package/dist/chunk-ZX5U3VCB.cjs +0 -471
- package/dist/email-queue-3QBQ63F7.js +0 -8
- package/dist/email-queue-K4E4OFI7.cjs +0 -29
- package/dist/email-service-5O24BSFR.cjs +0 -28
- package/dist/email-service-ADDF52PJ.js +0 -3
- package/dist/emit-order-notification-trigger-ROASTYQP.cjs +0 -16
- package/dist/emit-order-notification-trigger-YUQTPELC.js +0 -3
- package/dist/erp-config-enabled-CUMQ6N2V.cjs +0 -11
- package/dist/erp-config-enabled-T37X7T34.js +0 -2
- package/dist/erp-order-invoice-AZ5MX2JB.cjs +0 -28
- package/dist/erp-order-invoice-XSYHAMBS.js +0 -7
- package/dist/generate-local-invoice-pdf-BQTCL5MW.cjs +0 -12
- package/dist/generate-local-invoice-pdf-OCFG47SE.js +0 -3
- package/dist/interpolate-WAKPN56R.cjs +0 -11
- package/dist/interpolate-WDUWDF3I.js +0 -2
- package/dist/invoice-templates-GZ33OENC.js +0 -2
- package/dist/order-notification-dispatcher-6HCJ6Q75.cjs +0 -38
- package/dist/order-notification-dispatcher-KM2SY7TX.js +0 -13
- package/dist/paid-order-erp-3USEG6WL.js +0 -3
- package/dist/paid-order-erp-FSQ3GSXE.cjs +0 -12
- package/dist/pg-boss-service-BDGOKM2T.cjs +0 -15
- package/dist/pg-boss-service-WCBJD4JB.js +0 -2
- package/dist/resolve-invoice-asset-url-JEZRENJW.cjs +0 -11
- package/dist/resolve-invoice-asset-url-QZ2FRDHI.js +0 -2
- package/dist/retire-soft-deleted-unique-5VXBA5XX.cjs +0 -15
- package/dist/sms-defaults-2NL24H57.js +0 -2
- package/dist/vendor-invite-status-PWJ3DE76.js +0 -2
package/dist/chunk-Z5OB5QGN.js
DELETED
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
import { normalizeInvoiceTemplateId } from './chunk-WKDBMDUX.js';
|
|
2
|
-
import { __name } from './chunk-SHUYVCID.js';
|
|
3
|
-
import { rgb, PDFDocument, StandardFonts } from 'pdf-lib';
|
|
4
|
-
import qrcode from 'qr.js';
|
|
5
|
-
|
|
6
|
-
var THEMES = {
|
|
7
|
-
classic: {
|
|
8
|
-
accent: rgb(0.15, 0.25, 0.45),
|
|
9
|
-
headerBg: rgb(0.96, 0.96, 0.97),
|
|
10
|
-
headerText: rgb(0.12, 0.12, 0.14),
|
|
11
|
-
text: rgb(0.12, 0.12, 0.14),
|
|
12
|
-
muted: rgb(0.4, 0.42, 0.45),
|
|
13
|
-
line: rgb(0.82, 0.84, 0.86),
|
|
14
|
-
bandText: rgb(1, 1, 1)
|
|
15
|
-
},
|
|
16
|
-
modern: {
|
|
17
|
-
accent: rgb(0.1, 0.45, 0.55),
|
|
18
|
-
headerBg: rgb(0.93, 0.97, 0.98),
|
|
19
|
-
headerText: rgb(0.1, 0.12, 0.14),
|
|
20
|
-
text: rgb(0.1, 0.12, 0.14),
|
|
21
|
-
muted: rgb(0.38, 0.42, 0.45),
|
|
22
|
-
line: rgb(0.78, 0.86, 0.88),
|
|
23
|
-
bandText: rgb(1, 1, 1)
|
|
24
|
-
},
|
|
25
|
-
compact: {
|
|
26
|
-
accent: rgb(0.2, 0.2, 0.22),
|
|
27
|
-
headerBg: rgb(0.95, 0.95, 0.95),
|
|
28
|
-
headerText: rgb(0.1, 0.1, 0.1),
|
|
29
|
-
text: rgb(0.1, 0.1, 0.1),
|
|
30
|
-
muted: rgb(0.45, 0.45, 0.45),
|
|
31
|
-
line: rgb(0.85, 0.85, 0.85),
|
|
32
|
-
bandText: rgb(1, 1, 1)
|
|
33
|
-
},
|
|
34
|
-
bold: {
|
|
35
|
-
accent: rgb(0.55, 0.12, 0.12),
|
|
36
|
-
headerBg: rgb(0.55, 0.12, 0.12),
|
|
37
|
-
headerText: rgb(1, 1, 1),
|
|
38
|
-
text: rgb(0.1, 0.1, 0.1),
|
|
39
|
-
muted: rgb(0.4, 0.4, 0.4),
|
|
40
|
-
line: rgb(0.8, 0.75, 0.75),
|
|
41
|
-
bandText: rgb(1, 1, 1)
|
|
42
|
-
},
|
|
43
|
-
service_detailed: {
|
|
44
|
-
accent: rgb(0.15, 0.25, 0.45),
|
|
45
|
-
headerBg: rgb(0.96, 0.96, 0.97),
|
|
46
|
-
headerText: rgb(0.12, 0.12, 0.14),
|
|
47
|
-
text: rgb(0.12, 0.12, 0.14),
|
|
48
|
-
muted: rgb(0.4, 0.42, 0.45),
|
|
49
|
-
line: rgb(0.82, 0.84, 0.86),
|
|
50
|
-
bandText: rgb(1, 1, 1)
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
function money(amount, currency) {
|
|
54
|
-
const n = Number.isFinite(amount) ? amount : 0;
|
|
55
|
-
const code = (currency || "INR").trim().toUpperCase() || "INR";
|
|
56
|
-
return `${code} ${n.toFixed(2)}`;
|
|
57
|
-
}
|
|
58
|
-
__name(money, "money");
|
|
59
|
-
function fmtDate(d) {
|
|
60
|
-
const date = d instanceof Date ? d : new Date(d);
|
|
61
|
-
if (Number.isNaN(date.getTime())) return String(d);
|
|
62
|
-
const y = date.getFullYear();
|
|
63
|
-
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
64
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
65
|
-
return `${day}-${m}-${y}`;
|
|
66
|
-
}
|
|
67
|
-
__name(fmtDate, "fmtDate");
|
|
68
|
-
function winAnsiSafe(input) {
|
|
69
|
-
return String(input ?? "").replace(/\u20B9/g, "INR ").replace(/\u20AC/g, "EUR ").replace(/\u00A3/g, "GBP ").replace(/[^\x09\x0A\x0D\x20-\x7E]/g, "?");
|
|
70
|
-
}
|
|
71
|
-
__name(winAnsiSafe, "winAnsiSafe");
|
|
72
|
-
function addrLines(a) {
|
|
73
|
-
if (!a) return [];
|
|
74
|
-
const out = [];
|
|
75
|
-
if (a.line1?.trim()) out.push(a.line1.trim());
|
|
76
|
-
if (a.line2?.trim()) out.push(a.line2.trim());
|
|
77
|
-
const cityLine = [
|
|
78
|
-
a.city,
|
|
79
|
-
a.state,
|
|
80
|
-
a.postalCode
|
|
81
|
-
].filter((x) => x && String(x).trim()).join(", ");
|
|
82
|
-
if (cityLine) out.push(cityLine);
|
|
83
|
-
if (a.country?.trim()) out.push(a.country.trim());
|
|
84
|
-
return out.map(winAnsiSafe);
|
|
85
|
-
}
|
|
86
|
-
__name(addrLines, "addrLines");
|
|
87
|
-
function companyHeaderDetailLines(company) {
|
|
88
|
-
const lines = [];
|
|
89
|
-
if (company.supportEmail?.trim()) {
|
|
90
|
-
lines.push(`Email: ${company.supportEmail.trim()}`);
|
|
91
|
-
}
|
|
92
|
-
if (company.supportPhone?.trim()) {
|
|
93
|
-
lines.push(`Phone: ${company.supportPhone.trim()}`);
|
|
94
|
-
}
|
|
95
|
-
if (company.address?.trim()) {
|
|
96
|
-
const parts = company.address.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
97
|
-
if (parts.length === 1) {
|
|
98
|
-
lines.push(`Address: ${parts[0]}`);
|
|
99
|
-
} else if (parts.length > 1) {
|
|
100
|
-
lines.push(`Address: ${parts[0]}`);
|
|
101
|
-
lines.push(...parts.slice(1));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return lines.map(winAnsiSafe);
|
|
105
|
-
}
|
|
106
|
-
__name(companyHeaderDetailLines, "companyHeaderDetailLines");
|
|
107
|
-
function drawText(page, text, x, y, font, size, color) {
|
|
108
|
-
const safe = winAnsiSafe(text).slice(0, 120);
|
|
109
|
-
if (!safe) return;
|
|
110
|
-
page.drawText(safe, {
|
|
111
|
-
x,
|
|
112
|
-
y,
|
|
113
|
-
size,
|
|
114
|
-
font,
|
|
115
|
-
color
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
__name(drawText, "drawText");
|
|
119
|
-
function wrapText(text, font, size, maxWidth) {
|
|
120
|
-
const words = winAnsiSafe(text).split(/\s+/).filter(Boolean);
|
|
121
|
-
if (!words.length) return [
|
|
122
|
-
""
|
|
123
|
-
];
|
|
124
|
-
const lines = [];
|
|
125
|
-
let cur = "";
|
|
126
|
-
for (const w of words) {
|
|
127
|
-
const next = cur ? `${cur} ${w}` : w;
|
|
128
|
-
if (font.widthOfTextAtSize(next, size) <= maxWidth) {
|
|
129
|
-
cur = next;
|
|
130
|
-
} else {
|
|
131
|
-
if (cur) lines.push(cur);
|
|
132
|
-
cur = w;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (cur) lines.push(cur);
|
|
136
|
-
return lines.slice(0, 4);
|
|
137
|
-
}
|
|
138
|
-
__name(wrapText, "wrapText");
|
|
139
|
-
async function tryEmbedLogo(doc, logoUrl, maxW, maxH) {
|
|
140
|
-
const url = String(logoUrl ?? "").trim();
|
|
141
|
-
if (!url || !/^https?:\/\//i.test(url)) return null;
|
|
142
|
-
try {
|
|
143
|
-
const res = await fetch(url, {
|
|
144
|
-
signal: AbortSignal.timeout(8e3)
|
|
145
|
-
});
|
|
146
|
-
if (!res.ok) return null;
|
|
147
|
-
const buf = new Uint8Array(await res.arrayBuffer());
|
|
148
|
-
if (buf.byteLength < 24 || buf.byteLength > 25e5) return null;
|
|
149
|
-
const ct = (res.headers.get("content-type") || "").toLowerCase();
|
|
150
|
-
const isPng = ct.includes("png") || buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71;
|
|
151
|
-
const isJpg = ct.includes("jpeg") || ct.includes("jpg") || buf[0] === 255 && buf[1] === 216;
|
|
152
|
-
let image;
|
|
153
|
-
if (isPng) image = await doc.embedPng(buf);
|
|
154
|
-
else if (isJpg) image = await doc.embedJpg(buf);
|
|
155
|
-
else {
|
|
156
|
-
try {
|
|
157
|
-
image = await doc.embedPng(buf);
|
|
158
|
-
} catch {
|
|
159
|
-
image = await doc.embedJpg(buf);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const scale = Math.min(maxW / image.width, maxH / image.height, 1);
|
|
163
|
-
return {
|
|
164
|
-
image,
|
|
165
|
-
width: image.width * scale,
|
|
166
|
-
height: image.height * scale
|
|
167
|
-
};
|
|
168
|
-
} catch {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
__name(tryEmbedLogo, "tryEmbedLogo");
|
|
173
|
-
function drawQrCode(page, text, x, y, size) {
|
|
174
|
-
try {
|
|
175
|
-
const fn = typeof qrcode === "function" ? qrcode : qrcode?.default;
|
|
176
|
-
if (!fn) return;
|
|
177
|
-
const qr = fn(text, {
|
|
178
|
-
errorCorrectLevel: 2
|
|
179
|
-
});
|
|
180
|
-
const modules = qr.modules;
|
|
181
|
-
if (!modules || !modules.length) return;
|
|
182
|
-
const count = modules.length;
|
|
183
|
-
const cellSize = size / count;
|
|
184
|
-
page.drawRectangle({
|
|
185
|
-
x: x - 3,
|
|
186
|
-
y: y - 3,
|
|
187
|
-
width: size + 6,
|
|
188
|
-
height: size + 6,
|
|
189
|
-
color: rgb(1, 1, 1)
|
|
190
|
-
});
|
|
191
|
-
for (let r = 0; r < count; r++) {
|
|
192
|
-
for (let c = 0; c < count; c++) {
|
|
193
|
-
if (modules[r][c]) {
|
|
194
|
-
page.drawRectangle({
|
|
195
|
-
x: x + c * cellSize,
|
|
196
|
-
y: y + (count - 1 - r) * cellSize,
|
|
197
|
-
width: cellSize + 0.05,
|
|
198
|
-
height: cellSize + 0.05,
|
|
199
|
-
color: rgb(0.1, 0.1, 0.1)
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
} catch (err) {
|
|
205
|
-
console.error("[invoice-pdf] Failed to draw QR code:", err);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
__name(drawQrCode, "drawQrCode");
|
|
209
|
-
async function generateLocalInvoicePdf(input) {
|
|
210
|
-
const templateId = normalizeInvoiceTemplateId(input.templateId);
|
|
211
|
-
const theme = THEMES[templateId];
|
|
212
|
-
const doc = await PDFDocument.create();
|
|
213
|
-
const font = await doc.embedFont(StandardFonts.Helvetica);
|
|
214
|
-
const fontBold = await doc.embedFont(StandardFonts.HelveticaBold);
|
|
215
|
-
const pageWidth = 595.28;
|
|
216
|
-
const pageHeight = 841.89;
|
|
217
|
-
const margin = templateId === "compact" ? 36 : 48;
|
|
218
|
-
let page = doc.addPage([
|
|
219
|
-
pageWidth,
|
|
220
|
-
pageHeight
|
|
221
|
-
]);
|
|
222
|
-
let y = pageHeight - margin;
|
|
223
|
-
const companyName = input.company.name || "Store";
|
|
224
|
-
const logo = await tryEmbedLogo(doc, input.company.logoUrl, 120, 40);
|
|
225
|
-
const ensureSpace = /* @__PURE__ */ __name((need) => {
|
|
226
|
-
if (y - need < margin + 40) {
|
|
227
|
-
page = doc.addPage([
|
|
228
|
-
pageWidth,
|
|
229
|
-
pageHeight
|
|
230
|
-
]);
|
|
231
|
-
y = pageHeight - margin;
|
|
232
|
-
}
|
|
233
|
-
}, "ensureSpace");
|
|
234
|
-
const companyDetails = companyHeaderDetailLines(input.company);
|
|
235
|
-
const detailLineH = 11;
|
|
236
|
-
const detailsBlockH = companyDetails.length * detailLineH;
|
|
237
|
-
if (templateId === "bold" || templateId === "modern") {
|
|
238
|
-
const contentH = 22 + 16 + detailsBlockH;
|
|
239
|
-
const bandH = Math.max(templateId === "bold" ? 72 : 56, logo ? logo.height + 24 : 56, contentH + 20);
|
|
240
|
-
page.drawRectangle({
|
|
241
|
-
x: 0,
|
|
242
|
-
y: pageHeight - bandH,
|
|
243
|
-
width: pageWidth,
|
|
244
|
-
height: bandH,
|
|
245
|
-
color: theme.accent
|
|
246
|
-
});
|
|
247
|
-
if (logo) {
|
|
248
|
-
page.drawImage(logo.image, {
|
|
249
|
-
x: pageWidth - margin - logo.width,
|
|
250
|
-
y: pageHeight - bandH + (bandH - logo.height) / 2,
|
|
251
|
-
width: logo.width,
|
|
252
|
-
height: logo.height
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
let hy = pageHeight - 26;
|
|
256
|
-
drawText(page, "TAX INVOICE", margin, hy, fontBold, 18, theme.bandText);
|
|
257
|
-
hy -= 18;
|
|
258
|
-
drawText(page, companyName, margin, hy, font, 11, theme.bandText);
|
|
259
|
-
hy -= 14;
|
|
260
|
-
for (const line of companyDetails) {
|
|
261
|
-
drawText(page, line, margin, hy, font, 8, theme.bandText);
|
|
262
|
-
hy -= detailLineH;
|
|
263
|
-
}
|
|
264
|
-
y = pageHeight - bandH - 24;
|
|
265
|
-
} else {
|
|
266
|
-
const contentH = 18 + 14 + detailsBlockH;
|
|
267
|
-
const headerH = Math.max(44, logo ? logo.height + 16 : 44, contentH + 20);
|
|
268
|
-
page.drawRectangle({
|
|
269
|
-
x: margin,
|
|
270
|
-
y: y - headerH + 16,
|
|
271
|
-
width: pageWidth - margin * 2,
|
|
272
|
-
height: headerH,
|
|
273
|
-
color: theme.headerBg
|
|
274
|
-
});
|
|
275
|
-
if (logo) {
|
|
276
|
-
page.drawImage(logo.image, {
|
|
277
|
-
x: pageWidth - margin - 12 - logo.width,
|
|
278
|
-
y: y - headerH + 16 + (headerH - logo.height) / 2,
|
|
279
|
-
width: logo.width,
|
|
280
|
-
height: logo.height
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
let hy = y + 2;
|
|
284
|
-
drawText(page, "TAX INVOICE", margin + 12, hy, fontBold, 16, theme.accent);
|
|
285
|
-
hy -= 16;
|
|
286
|
-
drawText(page, companyName, margin + 12, hy, font, 10, theme.muted);
|
|
287
|
-
hy -= 13;
|
|
288
|
-
for (const line of companyDetails) {
|
|
289
|
-
drawText(page, line, margin + 12, hy, font, 8, theme.muted);
|
|
290
|
-
hy -= detailLineH;
|
|
291
|
-
}
|
|
292
|
-
y -= headerH + 16;
|
|
293
|
-
}
|
|
294
|
-
drawText(page, `Invoice #: ${input.orderNumber}`, margin, y, fontBold, 11, theme.text);
|
|
295
|
-
drawText(page, `Date: ${fmtDate(input.orderDate)}`, pageWidth / 2, y, font, 10, theme.muted);
|
|
296
|
-
y -= 22;
|
|
297
|
-
ensureSpace(100);
|
|
298
|
-
const colW = (pageWidth - margin * 2 - 16) / 2;
|
|
299
|
-
drawText(page, "Bill to", margin, y, fontBold, 10, theme.accent);
|
|
300
|
-
drawText(page, "Ship to", margin + colW + 16, y, fontBold, 10, theme.accent);
|
|
301
|
-
y -= 14;
|
|
302
|
-
const bill = [
|
|
303
|
-
input.customerName,
|
|
304
|
-
input.customerEmail || "",
|
|
305
|
-
input.customerPhone || "",
|
|
306
|
-
...addrLines(input.billingAddress)
|
|
307
|
-
].filter(Boolean);
|
|
308
|
-
const ship = addrLines(input.shippingAddress).length ? [
|
|
309
|
-
input.customerName,
|
|
310
|
-
...addrLines(input.shippingAddress)
|
|
311
|
-
] : bill;
|
|
312
|
-
const rows = Math.max(bill.length, ship.length, 1);
|
|
313
|
-
for (let i = 0; i < rows; i++) {
|
|
314
|
-
ensureSpace(14);
|
|
315
|
-
if (bill[i]) drawText(page, bill[i], margin, y, font, 9, theme.text);
|
|
316
|
-
if (ship[i]) drawText(page, ship[i], margin + colW + 16, y, font, 9, theme.text);
|
|
317
|
-
y -= 12;
|
|
318
|
-
}
|
|
319
|
-
y -= 12;
|
|
320
|
-
const isServiceTemplate = templateId === "service_detailed";
|
|
321
|
-
if (isServiceTemplate) {
|
|
322
|
-
y -= 6;
|
|
323
|
-
ensureSpace(50);
|
|
324
|
-
const sCol1 = margin;
|
|
325
|
-
const sCol2 = margin + colW + 16;
|
|
326
|
-
drawText(page, "Order Date:", sCol1, y, fontBold, 9.5, theme.accent);
|
|
327
|
-
drawText(page, fmtDate(input.orderDate), sCol1 + 75, y, font, 9.5, theme.text);
|
|
328
|
-
drawText(page, "Service Date:", sCol2, y, fontBold, 9.5, theme.accent);
|
|
329
|
-
drawText(page, input.serviceDate ? fmtDate(input.serviceDate) : "Not scheduled", sCol2 + 85, y, font, 9.5, theme.text);
|
|
330
|
-
y -= 16;
|
|
331
|
-
drawText(page, "Slot:", sCol1, y, fontBold, 9.5, theme.accent);
|
|
332
|
-
drawText(page, input.timeSlot ? String(input.timeSlot) : "Standard", sCol1 + 75, y, font, 9.5, theme.text);
|
|
333
|
-
drawText(page, "Assigned to:", sCol2, y, fontBold, 9.5, theme.accent);
|
|
334
|
-
drawText(page, input.assignedTo ? String(input.assignedTo) : "Pending Assignment", sCol2 + 85, y, font, 9.5, theme.text);
|
|
335
|
-
y -= 24;
|
|
336
|
-
}
|
|
337
|
-
const right = pageWidth - margin;
|
|
338
|
-
const contentRight = right - 4;
|
|
339
|
-
const colTotalW = 100;
|
|
340
|
-
const colTaxW = 100;
|
|
341
|
-
const colPriceW = 100;
|
|
342
|
-
const colQtyW = 40;
|
|
343
|
-
const totalRight = contentRight;
|
|
344
|
-
const taxRight = totalRight - colTotalW;
|
|
345
|
-
const priceRight = taxRight - colTaxW;
|
|
346
|
-
const qtyRight = priceRight - colPriceW;
|
|
347
|
-
const itemMaxW = Math.max(80, qtyRight - colQtyW - margin - 8);
|
|
348
|
-
const drawRight = /* @__PURE__ */ __name((text, rightEdge, atY, f, size, color) => {
|
|
349
|
-
const safe = winAnsiSafe(text).slice(0, 40);
|
|
350
|
-
if (!safe) return;
|
|
351
|
-
const w = f.widthOfTextAtSize(safe, size);
|
|
352
|
-
page.drawText(safe, {
|
|
353
|
-
x: rightEdge - w,
|
|
354
|
-
y: atY,
|
|
355
|
-
size,
|
|
356
|
-
font: f,
|
|
357
|
-
color
|
|
358
|
-
});
|
|
359
|
-
}, "drawRight");
|
|
360
|
-
ensureSpace(30);
|
|
361
|
-
const headerBarH = 20;
|
|
362
|
-
const headerBarBottom = y - 5;
|
|
363
|
-
page.drawRectangle({
|
|
364
|
-
x: margin,
|
|
365
|
-
y: headerBarBottom,
|
|
366
|
-
width: pageWidth - margin * 2,
|
|
367
|
-
height: headerBarH,
|
|
368
|
-
color: theme.headerBg
|
|
369
|
-
});
|
|
370
|
-
const headerTextY = headerBarBottom + 6;
|
|
371
|
-
drawText(page, "Item", margin + 4, headerTextY, fontBold, 9, theme.headerText);
|
|
372
|
-
drawRight("Qty", qtyRight, headerTextY, fontBold, 9, theme.headerText);
|
|
373
|
-
drawRight("Price", priceRight, headerTextY, fontBold, 9, theme.headerText);
|
|
374
|
-
drawRight("Tax", taxRight, headerTextY, fontBold, 9, theme.headerText);
|
|
375
|
-
drawRight("Total", totalRight, headerTextY, fontBold, 9, theme.headerText);
|
|
376
|
-
y = headerBarBottom - 10;
|
|
377
|
-
for (const line of input.lineItems) {
|
|
378
|
-
const nameLines = wrapText(line.name || "Item", font, 9, itemMaxW);
|
|
379
|
-
const skuText = line.sku ? winAnsiSafe(`SKU: ${line.sku}`).slice(0, 80) : "";
|
|
380
|
-
const nameH = Math.max(11, nameLines.length * 11);
|
|
381
|
-
const skuH = skuText ? 10 : 0;
|
|
382
|
-
const blockH = nameH + skuH + 6;
|
|
383
|
-
ensureSpace(blockH + 10);
|
|
384
|
-
let ty = y;
|
|
385
|
-
for (const nl of nameLines) {
|
|
386
|
-
drawText(page, nl, margin + 4, ty, font, 9, theme.text);
|
|
387
|
-
ty -= 11;
|
|
388
|
-
}
|
|
389
|
-
if (skuText) {
|
|
390
|
-
drawText(page, skuText, margin + 4, ty, font, 7, theme.muted);
|
|
391
|
-
ty -= 10;
|
|
392
|
-
}
|
|
393
|
-
drawRight(String(line.quantity), qtyRight, y, font, 9, theme.text);
|
|
394
|
-
drawRight(money(line.unitPrice, input.currency), priceRight, y, font, 9, theme.text);
|
|
395
|
-
drawRight(money(line.tax ?? 0, input.currency), taxRight, y, font, 9, theme.text);
|
|
396
|
-
drawRight(money(line.total, input.currency), totalRight, y, font, 9, theme.text);
|
|
397
|
-
const contentBottom = Math.min(ty, y - 12);
|
|
398
|
-
y = contentBottom - 2;
|
|
399
|
-
page.drawLine({
|
|
400
|
-
start: {
|
|
401
|
-
x: margin,
|
|
402
|
-
y
|
|
403
|
-
},
|
|
404
|
-
end: {
|
|
405
|
-
x: pageWidth - margin,
|
|
406
|
-
y
|
|
407
|
-
},
|
|
408
|
-
thickness: 0.5,
|
|
409
|
-
color: theme.line
|
|
410
|
-
});
|
|
411
|
-
y -= 8;
|
|
412
|
-
}
|
|
413
|
-
y -= 16;
|
|
414
|
-
ensureSpace(95);
|
|
415
|
-
const summaryTopY = y;
|
|
416
|
-
const summaryLabelX = totalRight - colTotalW - colTaxW - 8;
|
|
417
|
-
const rowsSummary = [
|
|
418
|
-
[
|
|
419
|
-
"Subtotal",
|
|
420
|
-
money(input.subtotal, input.currency),
|
|
421
|
-
false
|
|
422
|
-
],
|
|
423
|
-
[
|
|
424
|
-
"Discount",
|
|
425
|
-
money(input.discount, input.currency),
|
|
426
|
-
false
|
|
427
|
-
],
|
|
428
|
-
[
|
|
429
|
-
"Tax",
|
|
430
|
-
money(input.tax, input.currency),
|
|
431
|
-
false
|
|
432
|
-
],
|
|
433
|
-
[
|
|
434
|
-
"Total",
|
|
435
|
-
money(input.total, input.currency),
|
|
436
|
-
true
|
|
437
|
-
]
|
|
438
|
-
];
|
|
439
|
-
let sy = summaryTopY;
|
|
440
|
-
for (const [label, value, strong] of rowsSummary) {
|
|
441
|
-
const f = strong ? fontBold : font;
|
|
442
|
-
const size = strong ? 11 : 9;
|
|
443
|
-
drawText(page, label, summaryLabelX, sy, f, size, strong ? theme.accent : theme.muted);
|
|
444
|
-
drawRight(value, totalRight, sy, f, size, theme.text);
|
|
445
|
-
sy -= strong ? 18 : 14;
|
|
446
|
-
}
|
|
447
|
-
let qrBottomY = summaryTopY;
|
|
448
|
-
const shouldDrawQr = input.includeQrCode === true && Boolean(input.qrData || input.qrToken);
|
|
449
|
-
if (shouldDrawQr) {
|
|
450
|
-
const qrSize = 64;
|
|
451
|
-
const qrX = margin + 4;
|
|
452
|
-
const qrY = summaryTopY - qrSize + 8;
|
|
453
|
-
const qrContent = input.qrData || String(input.orderNumber);
|
|
454
|
-
drawQrCode(page, qrContent, qrX, qrY, qrSize);
|
|
455
|
-
qrBottomY = qrY - 10;
|
|
456
|
-
}
|
|
457
|
-
y = Math.min(sy, qrBottomY) - 16;
|
|
458
|
-
ensureSpace(30);
|
|
459
|
-
drawText(page, "Thank you for your purchase.", margin, y, font, 9, theme.muted);
|
|
460
|
-
y -= 12;
|
|
461
|
-
return doc.save();
|
|
462
|
-
}
|
|
463
|
-
__name(generateLocalInvoicePdf, "generateLocalInvoicePdf");
|
|
464
|
-
|
|
465
|
-
export { generateLocalInvoicePdf };
|