@asteby/storefront-react 0.26.0 → 0.28.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.
Files changed (38) hide show
  1. package/README.md +7 -2
  2. package/dist/account-server.cjs +533 -83
  3. package/dist/account-server.cjs.map +1 -1
  4. package/dist/account-server.d.cts +13 -2
  5. package/dist/account-server.d.ts +13 -2
  6. package/dist/account-server.js +23 -6
  7. package/dist/account-server.js.map +1 -1
  8. package/dist/account.cjs +572 -96
  9. package/dist/account.cjs.map +1 -1
  10. package/dist/account.d.cts +82 -45
  11. package/dist/account.d.ts +82 -45
  12. package/dist/account.js +53 -14
  13. package/dist/account.js.map +1 -1
  14. package/dist/checkout.cjs +114 -38
  15. package/dist/checkout.cjs.map +1 -1
  16. package/dist/checkout.d.cts +24 -1
  17. package/dist/checkout.d.ts +24 -1
  18. package/dist/checkout.js +114 -38
  19. package/dist/checkout.js.map +1 -1
  20. package/dist/chunk-BXKV2KWZ.js +291 -0
  21. package/dist/chunk-BXKV2KWZ.js.map +1 -0
  22. package/dist/chunk-LIUEQENV.js +156 -0
  23. package/dist/chunk-LIUEQENV.js.map +1 -0
  24. package/dist/fiscal-server.cjs +27 -2
  25. package/dist/fiscal-server.cjs.map +1 -1
  26. package/dist/fiscal-server.d.cts +10 -1
  27. package/dist/fiscal-server.d.ts +10 -1
  28. package/dist/fiscal-server.js +26 -3
  29. package/dist/fiscal-server.js.map +1 -1
  30. package/dist/voucher-document-FWH4DQ5N.js +72 -0
  31. package/dist/voucher-document-FWH4DQ5N.js.map +1 -0
  32. package/dist/voucher-pdf-LQC333AB.js +213 -0
  33. package/dist/voucher-pdf-LQC333AB.js.map +1 -0
  34. package/package.json +1 -1
  35. package/dist/chunk-TXEYBDFG.js +0 -182
  36. package/dist/chunk-TXEYBDFG.js.map +0 -1
  37. package/dist/voucher-document-SFWJCLTN.js +0 -124
  38. package/dist/voucher-document-SFWJCLTN.js.map +0 -1
@@ -0,0 +1,291 @@
1
+ // src/account/voucher.ts
2
+ var MAX = 256;
3
+ var CASH_METHODS = /* @__PURE__ */ new Set(["oxxo", "cash", "store", "convenience_store", "efectivo", "bank_deposit", "deposit", "paynet", "paycash", "bancomer", "7eleven", "seven_eleven", "farmacias_guadalajara", "circle_k"]);
4
+ var TRANSFER_METHODS = /* @__PURE__ */ new Set(["spei", "bank_transfer", "transfer", "wire", "clabe"]);
5
+ function formatOf(v) {
6
+ const f = typeof v === "string" ? v.toLowerCase().replace(/[^a-z0-9]/g, "") : "";
7
+ if (f === "code128" || f === "c128" || f === "code128b" || f === "code128c") return "code128";
8
+ if (f === "code39" || f === "c39") return "code39";
9
+ if (f === "itf" || f === "itf14" || f === "i25" || f === "interleaved2of5") return "itf";
10
+ if (f === "ean13") return "ean13";
11
+ return null;
12
+ }
13
+ function barcodeOf(ext, raw) {
14
+ if ("barcode_data" in ext) {
15
+ const d = ext.barcode_data;
16
+ if (d && typeof d === "object") {
17
+ const o = d;
18
+ const value2 = text(o.value);
19
+ const format = formatOf(o.format);
20
+ if (value2 && format && barcodeModules(value2, format)) return { draw: { value: value2, format }, text: null };
21
+ return { draw: null, text: value2 ?? text(raw) };
22
+ }
23
+ return { draw: null, text: text(raw) };
24
+ }
25
+ if (raw && typeof raw === "object") {
26
+ const o = raw;
27
+ const value2 = text(o.value);
28
+ const format = formatOf(o.format ?? "code128");
29
+ return { draw: value2 && format ? { value: value2, format } : null, text: null };
30
+ }
31
+ const value = text(raw);
32
+ return { draw: value ? { value, format: "code128" } : null, text: null };
33
+ }
34
+ function instructionsKeyOf(raw) {
35
+ const k = raw?.replace(/^payment\.voucher\.instructions\./, "").toLowerCase() ?? "";
36
+ return !k ? null : k === "other" ? "generic" : k;
37
+ }
38
+ function httpsUrl(v) {
39
+ const s = typeof v === "string" ? v.trim() : "";
40
+ return /^https:\/\//i.test(s) && s.length <= 2048 ? s : null;
41
+ }
42
+ function kindOf(kind, method, key) {
43
+ for (const c of [kind, method, key]) {
44
+ const k = c?.toLowerCase();
45
+ if (!k || k === "other" || k === "generic") continue;
46
+ if (k === "oxxo" || k === "cash" || CASH_METHODS.has(k)) return "cash";
47
+ if (k === "spei" || k === "transfer" || TRANSFER_METHODS.has(k)) return "transfer";
48
+ }
49
+ return "generic";
50
+ }
51
+ var digits = (s) => s ? s.replace(/\D/g, "") : "";
52
+ function text(v) {
53
+ if (typeof v === "number" && Number.isFinite(v)) return String(v);
54
+ if (typeof v !== "string") return null;
55
+ const s = v.trim().slice(0, MAX);
56
+ return s || null;
57
+ }
58
+ function moneyOf(v) {
59
+ if (!v || typeof v !== "object") return null;
60
+ const m = v;
61
+ const amount = text(m.amount);
62
+ const cur = text(m.currency_code);
63
+ return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null;
64
+ }
65
+ function voucherOf(p) {
66
+ const pay = p?.payment;
67
+ if (!pay || typeof pay !== "object") return null;
68
+ const ext = pay;
69
+ const method = text(pay.method ?? pay.provider);
70
+ const key = instructionsKeyOf(text(ext.instructions_key));
71
+ const bc = barcodeOf(ext, pay.barcode);
72
+ const clabe = text(pay.clabe);
73
+ let reference = text(pay.reference);
74
+ if (clabe && reference && digits(reference) === digits(clabe)) reference = null;
75
+ const v = {
76
+ method,
77
+ reference,
78
+ barcode: bc.draw?.value ?? null,
79
+ barcode_format: bc.draw?.format ?? null,
80
+ barcode_text: bc.text && bc.text !== reference ? bc.text : null,
81
+ clabe,
82
+ beneficiary: text(ext.beneficiary),
83
+ bank: text(ext.bank),
84
+ kind: kindOf(text(ext.kind), method, key),
85
+ instructions_key: key,
86
+ ticket_url: httpsUrl(ext.ticket_url) ?? httpsUrl(ext.voucher_url),
87
+ expires_at: text(pay.expires_at) ?? text(p?.expires_at),
88
+ amount: moneyOf(pay.amount) ?? moneyOf(p?.total),
89
+ instructions: text(pay.instructions)
90
+ };
91
+ return v.reference || v.barcode || v.barcode_text || v.clabe ? v : null;
92
+ }
93
+ function barcodeValue(v) {
94
+ return v.barcode;
95
+ }
96
+ var BARS = [
97
+ "11011001100",
98
+ "11001101100",
99
+ "11001100110",
100
+ "10010011000",
101
+ "10010001100",
102
+ "10001001100",
103
+ "10011001000",
104
+ "10011000100",
105
+ "10001100100",
106
+ "11001001000",
107
+ "11001000100",
108
+ "11000100100",
109
+ "10110011100",
110
+ "10011011100",
111
+ "10011001110",
112
+ "10111001100",
113
+ "10011101100",
114
+ "10011100110",
115
+ "11001110010",
116
+ "11001011100",
117
+ "11001001110",
118
+ "11011100100",
119
+ "11001110100",
120
+ "11101101110",
121
+ "11101001100",
122
+ "11100101100",
123
+ "11100100110",
124
+ "11101100100",
125
+ "11100110100",
126
+ "11100110010",
127
+ "11011011000",
128
+ "11011000110",
129
+ "11000110110",
130
+ "10100011000",
131
+ "10001011000",
132
+ "10001000110",
133
+ "10110001000",
134
+ "10001101000",
135
+ "10001100010",
136
+ "11010001000",
137
+ "11000101000",
138
+ "11000100010",
139
+ "10110111000",
140
+ "10110001110",
141
+ "10001101110",
142
+ "10111011000",
143
+ "10111000110",
144
+ "10001110110",
145
+ "11101110110",
146
+ "11010001110",
147
+ "11000101110",
148
+ "11011101000",
149
+ "11011100010",
150
+ "11011101110",
151
+ "11101011000",
152
+ "11101000110",
153
+ "11100010110",
154
+ "11101101000",
155
+ "11101100010",
156
+ "11100011010",
157
+ "11101111010",
158
+ "11001000010",
159
+ "11110001010",
160
+ "10100110000",
161
+ "10100001100",
162
+ "10010110000",
163
+ "10010000110",
164
+ "10000101100",
165
+ "10000100110",
166
+ "10110010000",
167
+ "10110000100",
168
+ "10011010000",
169
+ "10011000010",
170
+ "10000110100",
171
+ "10000110010",
172
+ "11000010010",
173
+ "11001010000",
174
+ "11110111010",
175
+ "11000010100",
176
+ "10001111010",
177
+ "10100111100",
178
+ "10010111100",
179
+ "10010011110",
180
+ "10111100100",
181
+ "10011110100",
182
+ "10011110010",
183
+ "11110100100",
184
+ "11110010100",
185
+ "11110010010",
186
+ "11011011110",
187
+ "11011110110",
188
+ "11110110110",
189
+ "10101111000",
190
+ "10100011110",
191
+ "10001011110",
192
+ "10111101000",
193
+ "10111100010",
194
+ "11110101000",
195
+ "11110100010",
196
+ "10111011110",
197
+ "10111101110",
198
+ "11101011110",
199
+ "11110101110",
200
+ "11010000100",
201
+ "11010010000",
202
+ "11010011100"
203
+ ];
204
+ var STOP = "1100011101011";
205
+ function code128Modules(value) {
206
+ if (!value || value.length > 80) return null;
207
+ let codes;
208
+ if (/^\d+$/.test(value) && value.length % 2 === 0) {
209
+ codes = [105];
210
+ for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)));
211
+ } else {
212
+ codes = [104];
213
+ for (const ch of value) {
214
+ const c = ch.charCodeAt(0);
215
+ if (c < 32 || c > 126) return null;
216
+ codes.push(c - 32);
217
+ }
218
+ }
219
+ let sum = codes[0];
220
+ for (let i = 1; i < codes.length; i++) sum += codes[i] * i;
221
+ codes.push(sum % 103);
222
+ return codes.map((c) => BARS[c]).join("") + STOP;
223
+ }
224
+ var C39_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. */+%$";
225
+ var C39_WIDE = "346038238023348034234368036236058258025458045245568056256456078278027478047247678067267467018128012148014124168016126146137157357135";
226
+ var CODE39_PATTERNS = Object.fromEntries(
227
+ [...C39_CHARS].map((ch, i) => [ch, [...Array(9).keys()].map((e) => C39_WIDE.slice(i * 3, i * 3 + 3).includes(String(e)) ? "w" : "n").join("")])
228
+ );
229
+ function code39Modules(value) {
230
+ if (!value || value.length > 40) return null;
231
+ let out = "";
232
+ for (const ch of `*${value}*`) {
233
+ const p = Object.prototype.hasOwnProperty.call(CODE39_PATTERNS, ch) ? CODE39_PATTERNS[ch] : void 0;
234
+ if (!p || ch === "*" && value.includes("*")) return null;
235
+ for (let i = 0; i < 9; i++) out += (i % 2 === 0 ? "1" : "0").repeat(p[i] === "w" ? 3 : 1);
236
+ out += "0";
237
+ }
238
+ return out.slice(0, -1);
239
+ }
240
+ var ITF_DIGITS = ["nnwwn", "wnnnw", "nwnnw", "wwnnn", "nnwnw", "wnwnn", "nwwnn", "nnnww", "wnnwn", "nwnwn"];
241
+ function itfModules(value) {
242
+ if (!value || value.length > 80 || value.length % 2 !== 0 || !/^\d+$/.test(value)) return null;
243
+ let out = "1010";
244
+ for (let i = 0; i < value.length; i += 2) {
245
+ const bars = ITF_DIGITS[Number(value[i])];
246
+ const spaces = ITF_DIGITS[Number(value[i + 1])];
247
+ for (let e = 0; e < 5; e++) out += "1".repeat(bars[e] === "w" ? 3 : 1) + "0".repeat(spaces[e] === "w" ? 3 : 1);
248
+ }
249
+ return out + "11101";
250
+ }
251
+ var EAN_L = ["0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011"];
252
+ var EAN_R = EAN_L.map((c) => [...c].map((b) => b === "1" ? "0" : "1").join(""));
253
+ var EAN_G = EAN_R.map((c) => [...c].reverse().join(""));
254
+ var EAN_PARITY = ["LLLLLL", "LLGLGG", "LLGGLG", "LLGGGL", "LGLLGG", "LGGLLG", "LGGGLL", "LGLGLG", "LGLGGL", "LGGLGL"];
255
+ function ean13Modules(value) {
256
+ if (!/^\d{13}$/.test(value)) return null;
257
+ const d = [...value].map(Number);
258
+ const sum = d.slice(0, 12).reduce((a, n, i) => a + n * (i % 2 === 0 ? 1 : 3), 0);
259
+ if ((10 - sum % 10) % 10 !== d[12]) return null;
260
+ const parity = EAN_PARITY[d[0]];
261
+ let out = "101";
262
+ for (let i = 0; i < 6; i++) out += (parity[i] === "L" ? EAN_L : EAN_G)[d[i + 1]];
263
+ out += "01010";
264
+ for (let i = 7; i < 13; i++) out += EAN_R[d[i]];
265
+ return out + "101";
266
+ }
267
+ function barcodeModules(value, format = "code128") {
268
+ return format === "code39" ? code39Modules(value) : format === "itf" ? itfModules(value) : format === "ean13" ? ean13Modules(value) : code128Modules(value);
269
+ }
270
+ function barcodeGeometry(value, opts = {}) {
271
+ const bits = barcodeModules(value, opts.format);
272
+ if (!bits) return null;
273
+ const mod = opts.module ?? 2;
274
+ const quiet = 10;
275
+ const rects = [];
276
+ for (let i = 0; i < bits.length; ) {
277
+ if (bits[i] === "0") {
278
+ i++;
279
+ continue;
280
+ }
281
+ let j = i;
282
+ while (j < bits.length && bits[j] === "1") j++;
283
+ rects.push({ x: (quiet + i) * mod, w: (j - i) * mod });
284
+ i = j;
285
+ }
286
+ return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects };
287
+ }
288
+
289
+ export { barcodeGeometry, barcodeModules, barcodeValue, code128Modules, code39Modules, voucherOf };
290
+ //# sourceMappingURL=chunk-BXKV2KWZ.js.map
291
+ //# sourceMappingURL=chunk-BXKV2KWZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/account/voucher.ts"],"names":["value"],"mappings":";AAmCA,IAAM,GAAA,GAAM,GAAA;AAKZ,IAAM,+BAAe,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,MAAA,EAAQ,SAAS,mBAAA,EAAqB,UAAA,EAAY,cAAA,EAAgB,SAAA,EAAW,UAAU,SAAA,EAAW,UAAA,EAAY,WAAW,cAAA,EAAgB,uBAAA,EAAyB,UAAU,CAAC,CAAA;AACnN,IAAM,gBAAA,uBAAuB,GAAA,CAAI,CAAC,QAAQ,eAAA,EAAiB,UAAA,EAAY,MAAA,EAAQ,OAAO,CAAC,CAAA;AAEvF,SAAS,SAAS,CAAA,EAAkC;AAClD,EAAA,MAAM,CAAA,GAAI,OAAO,CAAA,KAAM,QAAA,GAAW,CAAA,CAAE,aAAY,CAAE,OAAA,CAAQ,YAAA,EAAc,EAAE,CAAA,GAAI,EAAA;AAC9E,EAAA,IAAI,CAAA,KAAM,aAAa,CAAA,KAAM,MAAA,IAAU,MAAM,UAAA,IAAc,CAAA,KAAM,YAAY,OAAO,SAAA;AACpF,EAAA,IAAI,CAAA,KAAM,QAAA,IAAY,CAAA,KAAM,KAAA,EAAO,OAAO,QAAA;AAC1C,EAAA,IAAI,CAAA,KAA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AAa,KAAK,CAAA,GAAI,eAAe,KAAK,CAAA;AAC5J;AAKO,SAAS,eAAA,CAAgB,KAAA,EAAe,IAAA,GAAqE,EAAC,EAA2B;AAC9I,EAAA,MAAM,IAAA,GAAO,cAAA,CAAe,KAAA,EAAO,IAAA,CAAK,MAAM,CAAA;AAC9C,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,MAAM,GAAA,GAAM,KAAK,MAAA,IAAU,CAAA;AAC3B,EAAA,MAAM,KAAA,GAAQ,EAAA;AACd,EAAA,MAAM,QAAoC,EAAC;AAC3C,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,MAAA,IAAU;AACjC,IAAA,IAAI,IAAA,CAAK,CAAC,CAAA,KAAM,GAAA,EAAK;AACnB,MAAA,CAAA,EAAA;AACA,MAAA;AAAA,IACF;AACA,IAAA,IAAI,CAAA,GAAI,CAAA;AACR,IAAA,OAAO,IAAI,IAAA,CAAK,MAAA,IAAU,IAAA,CAAK,CAAC,MAAM,GAAA,EAAK,CAAA,EAAA;AAC3C,IAAA,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA,EAAA,CAAI,KAAA,GAAQ,CAAA,IAAK,KAAK,CAAA,EAAA,CAAI,CAAA,GAAI,CAAA,IAAK,GAAA,EAAK,CAAA;AACrD,IAAA,CAAA,GAAI,CAAA;AAAA,EACN;AACA,EAAA,OAAO,EAAE,KAAA,EAAA,CAAQ,IAAA,CAAK,MAAA,GAAS,KAAA,GAAQ,CAAA,IAAK,GAAA,EAAK,MAAA,EAAQ,IAAA,CAAK,MAAA,IAAU,EAAA,EAAI,KAAA,EAAM;AACpF","file":"chunk-BXKV2KWZ.js","sourcesContent":["/**\n * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the\n * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page\n * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).\n */\nimport type { Money, PendingPayment } from '@asteby/storefront'\n\nexport type VoucherView = {\n /** `oxxo`, `spei`, ... as the gateway publishes it. */\n method: string | null\n reference: string | null\n /** Value the barcode encodes, exactly as the server sent it. `null` when the server sent none or it cannot be drawn. */\n barcode: string | null\n /** Symbology of `barcode`; `null` when there is no barcode or its format is not one we can draw. */\n barcode_format: BarcodeFormat | null\n /**\n * Code the server sent but that is NOT drawn (`barcode_data` is null or names a symbology we cannot draw): shown as\n * plain text. `null` when there is nothing to show (also when it is the same as `reference`).\n */\n barcode_text: string | null\n clabe: string | null\n /** SPEI / transfer: who receives the money and in which bank. */\n beneficiary: string | null\n bank: string | null\n /** What kind of document to print: cash at a store, bank transfer, or unknown (generic, no brand named). */\n kind: VoucherKind\n /** Server-chosen key of the instructions (`oxxo`, `spei`...); unknown keys fall back to the kind. */\n instructions_key: string | null\n /** `https` link to the provider's own receipt: `ticket_url`, else the older `voucher_url`. */\n ticket_url: string | null\n expires_at: string | null\n amount: Money | null\n instructions: string | null\n}\n\nconst MAX = 256\n\nexport type BarcodeFormat = 'code128' | 'code39' | 'itf' | 'ean13'\nexport type VoucherKind = 'cash' | 'transfer' | 'generic'\n\nconst CASH_METHODS = new Set(['oxxo', 'cash', 'store', 'convenience_store', 'efectivo', 'bank_deposit', 'deposit', 'paynet', 'paycash', 'bancomer', '7eleven', 'seven_eleven', 'farmacias_guadalajara', 'circle_k'])\nconst TRANSFER_METHODS = new Set(['spei', 'bank_transfer', 'transfer', 'wire', 'clabe'])\n\nfunction formatOf(v: unknown): BarcodeFormat | null {\n const f = typeof v === 'string' ? v.toLowerCase().replace(/[^a-z0-9]/g, '') : ''\n if (f === 'code128' || f === 'c128' || f === 'code128b' || f === 'code128c') return 'code128'\n if (f === 'code39' || f === 'c39') return 'code39'\n if (f === 'itf' || f === 'itf14' || f === 'i25' || f === 'interleaved2of5') return 'itf'\n if (f === 'ean13') return 'ean13'\n return null\n}\n\n/**\n * The barcode the server declared. `barcode_data` (contract 1.10) is authoritative when the key is present, object or\n * `null`: `value` is what to draw, `text` what to show when it cannot be drawn. Without the key (older servers) the\n * plain `barcode` string is Code 128.\n */\nfunction barcodeOf(ext: Record<string, unknown>, raw: unknown): { draw: { value: string; format: BarcodeFormat } | null; text: string | null } {\n if ('barcode_data' in ext) {\n const d = ext.barcode_data\n if (d && typeof d === 'object') {\n const o = d as Record<string, unknown>\n const value = text(o.value)\n const format = formatOf(o.format)\n if (value && format && barcodeModules(value, format)) return { draw: { value, format }, text: null }\n return { draw: null, text: value ?? text(raw) }\n }\n return { draw: null, text: text(raw) }\n }\n if (raw && typeof raw === 'object') {\n const o = raw as Record<string, unknown>\n const value = text(o.value)\n const format = formatOf(o.format ?? 'code128')\n return { draw: value && format ? { value, format } : null, text: null }\n }\n const value = text(raw)\n return { draw: value ? { value, format: 'code128' } : null, text: null }\n}\n\n/** `payment.voucher.instructions.oxxo` -> `oxxo`; `other` -> `generic`. */\nfunction instructionsKeyOf(raw: string | null): string | null {\n const k = raw?.replace(/^payment\\.voucher\\.instructions\\./, '').toLowerCase() ?? ''\n return !k ? null : k === 'other' ? 'generic' : k\n}\n\nfunction httpsUrl(v: unknown): string | null {\n const s = typeof v === 'string' ? v.trim() : ''\n return /^https:\\/\\//i.test(s) && s.length <= 2048 ? s : null\n}\n\nfunction kindOf(kind: string | null, method: string | null, key: string | null): VoucherKind {\n for (const c of [kind, method, key]) {\n const k = c?.toLowerCase()\n if (!k || k === 'other' || k === 'generic') continue\n if (k === 'oxxo' || k === 'cash' || CASH_METHODS.has(k)) return 'cash'\n if (k === 'spei' || k === 'transfer' || TRANSFER_METHODS.has(k)) return 'transfer'\n }\n return 'generic'\n}\n\nconst digits = (s: string | null) => (s ? s.replace(/\\D/g, '') : '')\n\nfunction text(v: unknown): string | null {\n if (typeof v === 'number' && Number.isFinite(v)) return String(v)\n if (typeof v !== 'string') return null\n const s = v.trim().slice(0, MAX)\n return s || null\n}\n\nfunction moneyOf(v: unknown): Money | null {\n if (!v || typeof v !== 'object') return null\n const m = v as Record<string, unknown>\n const amount = text(m.amount)\n const cur = text(m.currency_code)\n return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null\n}\n\n/** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */\nexport function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null {\n const pay = p?.payment\n if (!pay || typeof pay !== 'object') return null\n // Fields the contract adds later are read defensively: an older SDK type does not declare them yet.\n const ext = pay as Record<string, unknown>\n const method = text(pay.method ?? pay.provider)\n const key = instructionsKeyOf(text(ext.instructions_key))\n const bc = barcodeOf(ext, pay.barcode)\n const clabe = text(pay.clabe)\n let reference = text(pay.reference)\n // Some gateways publish the CLABE as the \"reference\" too: printing both reads as two different numbers.\n if (clabe && reference && digits(reference) === digits(clabe)) reference = null\n const v: VoucherView = {\n method,\n reference,\n barcode: bc.draw?.value ?? null,\n barcode_format: bc.draw?.format ?? null,\n barcode_text: bc.text && bc.text !== reference ? bc.text : null,\n clabe,\n beneficiary: text(ext.beneficiary),\n bank: text(ext.bank),\n kind: kindOf(text(ext.kind), method, key),\n instructions_key: key,\n ticket_url: httpsUrl(ext.ticket_url) ?? httpsUrl(ext.voucher_url),\n expires_at: text(pay.expires_at) ?? text(p?.expires_at),\n amount: moneyOf(pay.amount) ?? moneyOf(p?.total),\n instructions: text(pay.instructions),\n }\n return v.reference || v.barcode || v.barcode_text || v.clabe ? v : null\n}\n\n/**\n * The value the barcode encodes: only what the server sent. A reference is NOT a barcode (an OXXO reference and its\n * scannable code differ), so without `barcode` nothing is drawn and the reference is shown as text.\n */\nexport function barcodeValue(v: Pick<VoucherView, 'barcode'>): string | null {\n return v.barcode\n}\n\n// 11-module patterns of symbols 0..105 and the 13-module stop (ISO/IEC 15417).\nconst BARS = [\n '11011001100', '11001101100', '11001100110', '10010011000', '10010001100', '10001001100', '10011001000', '10011000100', '10001100100', '11001001000',\n '11001000100', '11000100100', '10110011100', '10011011100', '10011001110', '10111001100', '10011101100', '10011100110', '11001110010', '11001011100',\n '11001001110', '11011100100', '11001110100', '11101101110', '11101001100', '11100101100', '11100100110', '11101100100', '11100110100', '11100110010',\n '11011011000', '11011000110', '11000110110', '10100011000', '10001011000', '10001000110', '10110001000', '10001101000', '10001100010', '11010001000',\n '11000101000', '11000100010', '10110111000', '10110001110', '10001101110', '10111011000', '10111000110', '10001110110', '11101110110', '11010001110',\n '11000101110', '11011101000', '11011100010', '11011101110', '11101011000', '11101000110', '11100010110', '11101101000', '11101100010', '11100011010',\n '11101111010', '11001000010', '11110001010', '10100110000', '10100001100', '10010110000', '10010000110', '10000101100', '10000100110', '10110010000',\n '10110000100', '10011010000', '10011000010', '10000110100', '10000110010', '11000010010', '11001010000', '11110111010', '11000010100', '10001111010',\n '10100111100', '10010111100', '10010011110', '10111100100', '10011110100', '10011110010', '11110100100', '11110010100', '11110010010', '11011011110',\n '11011110110', '11110110110', '10101111000', '10100011110', '10001011110', '10111101000', '10111100010', '11110101000', '11110100010', '10111011110',\n '10111101110', '11101011110', '11110101110', '11010000100', '11010010000', '11010011100',\n]\nconst STOP = '1100011101011'\n\n/**\n * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,\n * set B (printable ASCII) otherwise. `null` when it cannot be encoded.\n */\nexport function code128Modules(value: string): string | null {\n if (!value || value.length > 80) return null\n let codes: number[]\n if (/^\\d+$/.test(value) && value.length % 2 === 0) {\n codes = [105]\n for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)))\n } else {\n codes = [104]\n for (const ch of value) {\n const c = ch.charCodeAt(0)\n if (c < 32 || c > 126) return null\n codes.push(c - 32)\n }\n }\n let sum = codes[0]!\n for (let i = 1; i < codes.length; i++) sum += codes[i]! * i\n codes.push(sum % 103)\n return codes.map((c) => BARS[c]).join('') + STOP\n}\n\n// Code 39: 9 elements per character (bar, space, bar...), 3 of them wide (3 modules, the rest 1). Per character, in\n// order of `C39_CHARS`, the indices (0..8) of its wide elements. One narrow gap separates characters.\nconst C39_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. */+%$'\nconst C39_WIDE = '346038238023348034234368036236058258025458045245568056256456078278027478047247678067267467018128012148014124168016126146137157357135'\n/** Code 39 patterns as `n`/`w` strings per character (exported for the tests). */\nexport const CODE39_PATTERNS: Record<string, string> = Object.fromEntries(\n [...C39_CHARS].map((ch, i) => [ch, [...Array(9).keys()].map((e) => (C39_WIDE.slice(i * 3, i * 3 + 3).includes(String(e)) ? 'w' : 'n')).join('')]),\n)\n\n/** Modules of the Code 39 of `value` (`*` start/stop added). `null` for lower case, `*` or anything outside its set. */\nexport function code39Modules(value: string): string | null {\n if (!value || value.length > 40) return null\n let out = ''\n for (const ch of `*${value}*`) {\n const p = Object.prototype.hasOwnProperty.call(CODE39_PATTERNS, ch) ? CODE39_PATTERNS[ch] : undefined\n if (!p || (ch === '*' && value.includes('*'))) return null\n for (let i = 0; i < 9; i++) out += (i % 2 === 0 ? '1' : '0').repeat(p[i] === 'w' ? 3 : 1)\n out += '0'\n }\n return out.slice(0, -1)\n}\n\n// Interleaved 2 of 5: digits in pairs, the first of each pair in the bars, the second in the spaces. Per digit the\n// 5 elements as `n`/`w` (wide = 3 modules). Start: bar-space-bar-space narrow; stop: wide bar, narrow space, narrow bar.\nconst ITF_DIGITS = ['nnwwn', 'wnnnw', 'nwnnw', 'wwnnn', 'nnwnw', 'wnwnn', 'nwwnn', 'nnnww', 'wnnwn', 'nwnwn']\n\n/** Modules of the ITF (Interleaved 2 of 5) of `value`: digits only, even count. `null` otherwise. */\nexport function itfModules(value: string): string | null {\n if (!value || value.length > 80 || value.length % 2 !== 0 || !/^\\d+$/.test(value)) return null\n let out = '1010'\n for (let i = 0; i < value.length; i += 2) {\n const bars = ITF_DIGITS[Number(value[i])]!\n const spaces = ITF_DIGITS[Number(value[i + 1])]!\n for (let e = 0; e < 5; e++) out += '1'.repeat(bars[e] === 'w' ? 3 : 1) + '0'.repeat(spaces[e] === 'w' ? 3 : 1)\n }\n return out + '11101'\n}\n\nconst EAN_L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']\nconst EAN_R = EAN_L.map((c) => [...c].map((b) => (b === '1' ? '0' : '1')).join(''))\nconst EAN_G = EAN_R.map((c) => [...c].reverse().join(''))\nconst EAN_PARITY = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL']\n\n/** Modules (95) of the EAN-13 of `value`: exactly 13 digits whose last one is the correct check digit. `null` otherwise. */\nexport function ean13Modules(value: string): string | null {\n if (!/^\\d{13}$/.test(value)) return null\n const d = [...value].map(Number)\n const sum = d.slice(0, 12).reduce((a, n, i) => a + n * (i % 2 === 0 ? 1 : 3), 0)\n if ((10 - (sum % 10)) % 10 !== d[12]) return null\n const parity = EAN_PARITY[d[0]!]!\n let out = '101'\n for (let i = 0; i < 6; i++) out += (parity[i] === 'L' ? EAN_L : EAN_G)[d[i + 1]!]\n out += '01010'\n for (let i = 7; i < 13; i++) out += EAN_R[d[i]!]\n return out + '101'\n}\n\n/** Modules of `value` in the given symbology. */\nexport function barcodeModules(value: string, format: BarcodeFormat = 'code128'): string | null {\n return format === 'code39' ? code39Modules(value) : format === 'itf' ? itfModules(value) : format === 'ean13' ? ean13Modules(value) : code128Modules(value)\n}\n\nexport type BarcodeGeometry = { width: number; height: number; rects: { x: number; w: number }[] }\n\n/** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */\nexport function barcodeGeometry(value: string, opts: { module?: number; height?: number; format?: BarcodeFormat } = {}): BarcodeGeometry | null {\n const bits = barcodeModules(value, opts.format)\n if (!bits) return null\n const mod = opts.module ?? 2\n const quiet = 10\n const rects: { x: number; w: number }[] = []\n for (let i = 0; i < bits.length; ) {\n if (bits[i] === '0') {\n i++\n continue\n }\n let j = i\n while (j < bits.length && bits[j] === '1') j++\n rects.push({ x: (quiet + i) * mod, w: (j - i) * mod })\n i = j\n }\n return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects }\n}\n"]}
@@ -0,0 +1,156 @@
1
+ // src/account/voucher-text.ts
2
+ var KEEP_ES = "Conserva tu comprobante: confirmaremos tu pago autom\xE1ticamente.";
3
+ var KEEP_EN = "Keep your receipt: we will confirm your payment automatically.";
4
+ var ES = {
5
+ title: "Ficha de pago",
6
+ total: "Total a pagar",
7
+ reference: "Referencia",
8
+ clabe: "CLABE",
9
+ beneficiary: "Beneficiario",
10
+ bank: "Banco",
11
+ expires: "Vence",
12
+ expiresNote: "Pasada esa fecha la ficha deja de ser v\xE1lida.",
13
+ order: "Pedido",
14
+ barcode: "C\xF3digo de barras",
15
+ code: "C\xF3digo",
16
+ print: "Imprimir",
17
+ downloadPdf: "Descargar PDF",
18
+ noScript: "Para imprimir usa la opci\xF3n Imprimir de tu navegador (Ctrl+P) o descarga el PDF.",
19
+ stepsTitle: "C\xF3mo pagar",
20
+ footer: "Tu pedido se genera cuando se confirma el pago. Esta ficha es de un solo uso; no la compartas.",
21
+ methods: { oxxo: "OXXO", spei: "Transferencia SPEI", bank_transfer: "Transferencia bancaria", bank_deposit: "Dep\xF3sito bancario", cash: "Pago en efectivo" },
22
+ cash: "Pago en efectivo",
23
+ steps: {
24
+ oxxo: (v) => [
25
+ "Acude a cualquier tienda OXXO y di que vas a hacer un pago de servicio en efectivo.",
26
+ v.barcode ? "Muestra el c\xF3digo de barras en caja o dicta la referencia, y paga el monto exacto." : "Dicta la referencia en caja y paga el monto exacto.",
27
+ KEEP_ES
28
+ ],
29
+ cash: (v) => [
30
+ "Acude a la tienda o comercio indicado y di que vas a hacer un pago en efectivo.",
31
+ v.barcode ? "Muestra el c\xF3digo de barras o dicta la referencia, y paga el monto exacto." : "Dicta la referencia y paga el monto exacto.",
32
+ KEEP_ES
33
+ ],
34
+ spei: (v) => [
35
+ "Entra a la banca en l\xEDnea o a la app de tu banco.",
36
+ "Haz una transferencia SPEI a la CLABE indicada, por el monto exacto.",
37
+ ...v.reference ? ["Escribe la referencia de esta ficha en el concepto o referencia de la transferencia."] : [],
38
+ KEEP_ES
39
+ ],
40
+ bank_transfer: (v) => [
41
+ "Entra a la banca en l\xEDnea o a la app de tu banco.",
42
+ "Haz una transferencia a la cuenta o CLABE indicada, por el monto exacto.",
43
+ ...v.reference ? ["Escribe la referencia de esta ficha en el concepto de la transferencia."] : [],
44
+ KEEP_ES
45
+ ],
46
+ bank_deposit: (v) => [
47
+ "Acude a una sucursal del banco indicado o a su cajero con dep\xF3sitos.",
48
+ `Deposita el monto exacto a la cuenta${v.reference ? " con la referencia de esta ficha" : " indicada"}.`,
49
+ KEEP_ES
50
+ ],
51
+ transfer: (v) => [
52
+ "Entra a la banca en l\xEDnea o a la app de tu banco.",
53
+ "Haz una transferencia a la CLABE indicada, por el monto exacto.",
54
+ ...v.reference ? ["Escribe la referencia de esta ficha en el concepto de la transferencia."] : [],
55
+ KEEP_ES
56
+ ],
57
+ generic: () => ["Realiza el pago con los datos de esta ficha, por el monto exacto y antes de que venza.", KEEP_ES]
58
+ }
59
+ };
60
+ var EN = {
61
+ title: "Payment voucher",
62
+ total: "Amount to pay",
63
+ reference: "Reference",
64
+ clabe: "CLABE",
65
+ beneficiary: "Beneficiary",
66
+ bank: "Bank",
67
+ expires: "Expires",
68
+ expiresNote: "After that date the voucher is no longer valid.",
69
+ order: "Order",
70
+ barcode: "Barcode",
71
+ code: "Code",
72
+ print: "Print",
73
+ downloadPdf: "Download PDF",
74
+ noScript: "To print, use your browser's Print option (Ctrl+P) or download the PDF.",
75
+ stepsTitle: "How to pay",
76
+ footer: "Your order is created when the payment is confirmed. This voucher is single-use; do not share it.",
77
+ methods: { oxxo: "OXXO", spei: "SPEI transfer", bank_transfer: "Bank transfer", bank_deposit: "Bank deposit", cash: "Cash payment" },
78
+ cash: "Cash payment",
79
+ steps: {
80
+ oxxo: (v) => [
81
+ "Go to any OXXO store and say you want to make a cash service payment.",
82
+ v.barcode ? "Show the barcode at the register or read out the reference, and pay the exact amount." : "Read out the reference at the register and pay the exact amount.",
83
+ KEEP_EN
84
+ ],
85
+ cash: (v) => [
86
+ "Go to the store indicated and say you want to make a cash payment.",
87
+ v.barcode ? "Show the barcode or read out the reference, and pay the exact amount." : "Read out the reference and pay the exact amount.",
88
+ KEEP_EN
89
+ ],
90
+ spei: (v) => [
91
+ "Open your online banking or your bank app.",
92
+ "Make a SPEI transfer to the CLABE below for the exact amount.",
93
+ ...v.reference ? ["Enter the reference of this voucher as the transfer concept or reference."] : [],
94
+ KEEP_EN
95
+ ],
96
+ bank_transfer: (v) => [
97
+ "Open your online banking or your bank app.",
98
+ "Make a transfer to the account or CLABE below for the exact amount.",
99
+ ...v.reference ? ["Enter the reference of this voucher as the transfer concept."] : [],
100
+ KEEP_EN
101
+ ],
102
+ bank_deposit: (v) => [
103
+ "Go to a branch of the bank indicated or to one of its deposit ATMs.",
104
+ `Deposit the exact amount to the account${v.reference ? " with the reference of this voucher" : " indicated"}.`,
105
+ KEEP_EN
106
+ ],
107
+ transfer: (v) => [
108
+ "Open your online banking or your bank app.",
109
+ "Make a transfer to the CLABE below for the exact amount.",
110
+ ...v.reference ? ["Enter the reference of this voucher as the transfer concept."] : [],
111
+ KEEP_EN
112
+ ],
113
+ generic: () => ["Make the payment with the details of this voucher, for the exact amount and before it expires.", KEEP_EN]
114
+ }
115
+ };
116
+ var isEnglish = (locale) => locale.toLowerCase().startsWith("en");
117
+ function docText(locale) {
118
+ return isEnglish(locale) ? EN : ES;
119
+ }
120
+ var own = (o, k) => {
121
+ const key = k?.toLowerCase();
122
+ return key && Object.prototype.hasOwnProperty.call(o, key) ? o[key] : void 0;
123
+ };
124
+ function methodName(v, t) {
125
+ return v.method ? own(t.methods, v.method) ?? v.method : t.cash;
126
+ }
127
+ function voucherSteps(v, t) {
128
+ const fn = own(t.steps, v.instructions_key) ?? own(t.steps, v.method) ?? (v.kind === "cash" ? t.steps.cash : v.kind === "transfer" ? t.steps.transfer : t.steps.generic);
129
+ return fn(v);
130
+ }
131
+ function voucherFields(v, t) {
132
+ const f = (key, label, value) => value ? [{ key, label, value }] : [];
133
+ return v.kind === "transfer" ? [...f("beneficiary", t.beneficiary, v.beneficiary), ...f("bank", t.bank, v.bank), ...f("clabe", t.clabe, v.clabe), ...f("reference", t.reference, v.reference), ...f("code", t.code, v.barcode_text)] : [...f("reference", t.reference, v.reference), ...f("clabe", t.clabe, v.clabe), ...f("beneficiary", t.beneficiary, v.beneficiary), ...f("bank", t.bank, v.bank), ...f("code", t.code, v.barcode_text)];
134
+ }
135
+ function formatMoney(m, locale) {
136
+ if (!m) return "";
137
+ try {
138
+ return new Intl.NumberFormat(locale, { style: "currency", currency: m.currency_code }).format(Number(m.amount));
139
+ } catch {
140
+ return `${m.amount} ${m.currency_code}`;
141
+ }
142
+ }
143
+ function formatDate(iso, locale, timeZone) {
144
+ if (!iso) return "";
145
+ const d = new Date(iso);
146
+ if (Number.isNaN(d.getTime())) return "";
147
+ try {
148
+ return d.toLocaleString(locale, { dateStyle: "long", timeStyle: "short", ...timeZone ? { timeZone } : {} });
149
+ } catch {
150
+ return d.toISOString();
151
+ }
152
+ }
153
+
154
+ export { docText, formatDate, formatMoney, methodName, voucherFields, voucherSteps };
155
+ //# sourceMappingURL=chunk-LIUEQENV.js.map
156
+ //# sourceMappingURL=chunk-LIUEQENV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/account/voucher-text.ts"],"names":[],"mappings":";AAkCA,IAAM,OAAA,GAAU,oEAAA;AAChB,IAAM,OAAA,GAAU,gEAAA;AAEhB,IAAM,EAAA,GAAc;AAAA,EAClB,KAAA,EAAO,eAAA;AAAA,EACP,KAAA,EAAO,eAAA;AAAA,EACP,SAAA,EAAW,YAAA;AAAA,EACX,KAAA,EAAO,OAAA;AAAA,EACP,W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,WAAW,EAAE,QAAA,EAAS,GAAI,IAAK,CAAA;AAAA,EAC9G,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,WAAA,EAAY;AAAA,EACvB;AACF","file":"chunk-LIUEQENV.js","sourcesContent":["/**\n * Texts and layout decisions of the printable voucher, shared by the HTML document and the PDF so both say the same\n * thing: which fields a method prints and which instructions it gets. Plain data, no React, no DOM. Loaded only with\n * one of the two generators (never in the first load of the order screens).\n *\n * A voucher is per METHOD: cash at a store (barcode + reference + store steps), bank transfer (beneficiary, bank,\n * CLABE, reference + transfer steps), or generic (no brand named). The server picks the instructions with\n * `instructions_key` (or the method); an unknown key falls back to the kind, never to another method's steps.\n */\nimport type { Money } from '@asteby/storefront'\nimport type { VoucherView } from './voucher.js'\n\nexport type DocText = {\n title: string\n total: string\n reference: string\n clabe: string\n beneficiary: string\n bank: string\n expires: string\n expiresNote: string\n order: string\n barcode: string\n code: string\n print: string\n downloadPdf: string\n noScript: string\n stepsTitle: string\n footer: string\n methods: Record<string, string>\n cash: string\n steps: Record<string, (v: VoucherView) => string[]>\n}\n\nconst KEEP_ES = 'Conserva tu comprobante: confirmaremos tu pago automáticamente.'\nconst KEEP_EN = 'Keep your receipt: we will confirm your payment automatically.'\n\nconst ES: DocText = {\n title: 'Ficha de pago',\n total: 'Total a pagar',\n reference: 'Referencia',\n clabe: 'CLABE',\n beneficiary: 'Beneficiario',\n bank: 'Banco',\n expires: 'Vence',\n expiresNote: 'Pasada esa fecha la ficha deja de ser válida.',\n order: 'Pedido',\n barcode: 'Código de barras',\n code: 'Código',\n print: 'Imprimir',\n downloadPdf: 'Descargar PDF',\n noScript: 'Para imprimir usa la opción Imprimir de tu navegador (Ctrl+P) o descarga el PDF.',\n stepsTitle: 'Cómo pagar',\n footer: 'Tu pedido se genera cuando se confirma el pago. Esta ficha es de un solo uso; no la compartas.',\n methods: { oxxo: 'OXXO', spei: 'Transferencia SPEI', bank_transfer: 'Transferencia bancaria', bank_deposit: 'Depósito bancario', cash: 'Pago en efectivo' },\n cash: 'Pago en efectivo',\n steps: {\n oxxo: (v) => [\n 'Acude a cualquier tienda OXXO y di que vas a hacer un pago de servicio en efectivo.',\n v.barcode ? 'Muestra el código de barras en caja o dicta la referencia, y paga el monto exacto.' : 'Dicta la referencia en caja y paga el monto exacto.',\n KEEP_ES,\n ],\n cash: (v) => [\n 'Acude a la tienda o comercio indicado y di que vas a hacer un pago en efectivo.',\n v.barcode ? 'Muestra el código de barras o dicta la referencia, y paga el monto exacto.' : 'Dicta la referencia y paga el monto exacto.',\n KEEP_ES,\n ],\n spei: (v) => [\n 'Entra a la banca en línea o a la app de tu banco.',\n 'Haz una transferencia SPEI a la CLABE indicada, por el monto exacto.',\n ...(v.reference ? ['Escribe la referencia de esta ficha en el concepto o referencia de la transferencia.'] : []),\n KEEP_ES,\n ],\n bank_transfer: (v) => [\n 'Entra a la banca en línea o a la app de tu banco.',\n 'Haz una transferencia a la cuenta o CLABE indicada, por el monto exacto.',\n ...(v.reference ? ['Escribe la referencia de esta ficha en el concepto de la transferencia.'] : []),\n KEEP_ES,\n ],\n bank_deposit: (v) => [\n 'Acude a una sucursal del banco indicado o a su cajero con depósitos.',\n `Deposita el monto exacto a la cuenta${v.reference ? ' con la referencia de esta ficha' : ' indicada'}.`,\n KEEP_ES,\n ],\n transfer: (v) => [\n 'Entra a la banca en línea o a la app de tu banco.',\n 'Haz una transferencia a la CLABE indicada, por el monto exacto.',\n ...(v.reference ? ['Escribe la referencia de esta ficha en el concepto de la transferencia.'] : []),\n KEEP_ES,\n ],\n generic: () => ['Realiza el pago con los datos de esta ficha, por el monto exacto y antes de que venza.', KEEP_ES],\n },\n}\n\nconst EN: DocText = {\n title: 'Payment voucher',\n total: 'Amount to pay',\n reference: 'Reference',\n clabe: 'CLABE',\n beneficiary: 'Beneficiary',\n bank: 'Bank',\n expires: 'Expires',\n expiresNote: 'After that date the voucher is no longer valid.',\n order: 'Order',\n barcode: 'Barcode',\n code: 'Code',\n print: 'Print',\n downloadPdf: 'Download PDF',\n noScript: 'To print, use your browser\\'s Print option (Ctrl+P) or download the PDF.',\n stepsTitle: 'How to pay',\n footer: 'Your order is created when the payment is confirmed. This voucher is single-use; do not share it.',\n methods: { oxxo: 'OXXO', spei: 'SPEI transfer', bank_transfer: 'Bank transfer', bank_deposit: 'Bank deposit', cash: 'Cash payment' },\n cash: 'Cash payment',\n steps: {\n oxxo: (v) => [\n 'Go to any OXXO store and say you want to make a cash service payment.',\n v.barcode ? 'Show the barcode at the register or read out the reference, and pay the exact amount.' : 'Read out the reference at the register and pay the exact amount.',\n KEEP_EN,\n ],\n cash: (v) => [\n 'Go to the store indicated and say you want to make a cash payment.',\n v.barcode ? 'Show the barcode or read out the reference, and pay the exact amount.' : 'Read out the reference and pay the exact amount.',\n KEEP_EN,\n ],\n spei: (v) => [\n 'Open your online banking or your bank app.',\n 'Make a SPEI transfer to the CLABE below for the exact amount.',\n ...(v.reference ? ['Enter the reference of this voucher as the transfer concept or reference.'] : []),\n KEEP_EN,\n ],\n bank_transfer: (v) => [\n 'Open your online banking or your bank app.',\n 'Make a transfer to the account or CLABE below for the exact amount.',\n ...(v.reference ? ['Enter the reference of this voucher as the transfer concept.'] : []),\n KEEP_EN,\n ],\n bank_deposit: (v) => [\n 'Go to a branch of the bank indicated or to one of its deposit ATMs.',\n `Deposit the exact amount to the account${v.reference ? ' with the reference of this voucher' : ' indicated'}.`,\n KEEP_EN,\n ],\n transfer: (v) => [\n 'Open your online banking or your bank app.',\n 'Make a transfer to the CLABE below for the exact amount.',\n ...(v.reference ? ['Enter the reference of this voucher as the transfer concept.'] : []),\n KEEP_EN,\n ],\n generic: () => ['Make the payment with the details of this voucher, for the exact amount and before it expires.', KEEP_EN],\n },\n}\n\nexport const isEnglish = (locale: string) => locale.toLowerCase().startsWith('en')\nexport function docText(locale: string): DocText {\n return isEnglish(locale) ? EN : ES\n}\n\nconst own = <T>(o: Record<string, T>, k: string | null | undefined): T | undefined => {\n const key = k?.toLowerCase()\n return key && Object.prototype.hasOwnProperty.call(o, key) ? o[key] : undefined\n}\n\n/** Method as the buyer reads it. Own keys only: a method named `constructor` or `__proto__` prints as itself. */\nexport function methodName(v: VoucherView, t: DocText): string {\n return (v.method ? own(t.methods, v.method) ?? v.method : t.cash)\n}\n\n/** Numbered instructions of this voucher: the server's `instructions_key`, else the method, else the kind. */\nexport function voucherSteps(v: VoucherView, t: DocText): string[] {\n const fn = own(t.steps, v.instructions_key) ?? own(t.steps, v.method) ?? (v.kind === 'cash' ? t.steps.cash : v.kind === 'transfer' ? t.steps.transfer : t.steps.generic)\n return fn!(v)\n}\n\nexport type VoucherField = { key: 'beneficiary' | 'bank' | 'clabe' | 'reference' | 'code'; label: string; value: string }\n\n/** Fields to print, in the order the method needs them: transfers lead with who/where/CLABE, cash with the reference. */\nexport function voucherFields(v: VoucherView, t: DocText): VoucherField[] {\n const f = (key: VoucherField['key'], label: string, value: string | null): VoucherField[] => (value ? [{ key, label, value }] : [])\n return v.kind === 'transfer'\n ? [...f('beneficiary', t.beneficiary, v.beneficiary), ...f('bank', t.bank, v.bank), ...f('clabe', t.clabe, v.clabe), ...f('reference', t.reference, v.reference), ...f('code', t.code, v.barcode_text)]\n : [...f('reference', t.reference, v.reference), ...f('clabe', t.clabe, v.clabe), ...f('beneficiary', t.beneficiary, v.beneficiary), ...f('bank', t.bank, v.bank), ...f('code', t.code, v.barcode_text)]\n}\n\nexport function formatMoney(m: Money | null, locale: string): string {\n if (!m) return ''\n try {\n return new Intl.NumberFormat(locale, { style: 'currency', currency: m.currency_code }).format(Number(m.amount))\n } catch {\n return `${m.amount} ${m.currency_code}`\n }\n}\n\nexport function formatDate(iso: string | null, locale: string, timeZone?: string): string {\n if (!iso) return ''\n const d = new Date(iso)\n if (Number.isNaN(d.getTime())) return ''\n try {\n return d.toLocaleString(locale, { dateStyle: 'long', timeStyle: 'short', ...(timeZone ? { timeZone } : {}) })\n } catch {\n return d.toISOString()\n }\n}\n"]}
@@ -138,7 +138,30 @@ function logMisconfigured(scopes) {
138
138
  `[@asteby/storefront-react] La credencial de la tienda no tiene permisos${scopes.length ? ` (${scopes.join(", ")})` : ""}; la facturaci\xF3n no funciona hasta repararlo en ${storefront.repairPath()}.`
139
139
  );
140
140
  }
141
- var formField = (field, prefix) => field ? field.replace(/^(fiscal|invoice)\./, `${prefix}.`) : void 0;
141
+ var CONTROL_OF = {
142
+ tax_id: "tax_id",
143
+ rfc: "tax_id",
144
+ legal_name: "legal_name",
145
+ razon_social: "legal_name",
146
+ postal_code: "postal_code",
147
+ zip: "postal_code",
148
+ cp: "postal_code",
149
+ tax_regime: "tax_regime",
150
+ regimen: "tax_regime",
151
+ use: "use",
152
+ invoice_use: "use",
153
+ cfdi_use: "use",
154
+ uso_cfdi: "use"
155
+ };
156
+ var formField = (field, prefix) => {
157
+ if (!field) return void 0;
158
+ const control = CONTROL_OF[field.replace(/^(fiscal|invoice)\./, "")];
159
+ return control ? `${prefix}.${control}` : void 0;
160
+ };
161
+ function orderInvoiceBody(invoice) {
162
+ const { requested: _requested, document: _document, use, ...rest } = invoice;
163
+ return { ...rest, ...use ? { invoice_use: use } : {} };
164
+ }
142
165
  function toFailure(err, intent, prefix, values) {
143
166
  const carry = values ? { values } : {};
144
167
  if (!storefront.isStorefrontError(err)) return fail(intent, "unavailable", carry);
@@ -246,7 +269,7 @@ function createInvoiceAction(options) {
246
269
  if (!token) return fail(intent, "unauthorized", { values: echo });
247
270
  const orderId = text("order_id");
248
271
  if (!orderId) return fail(intent, "validation");
249
- const result = await sf.customer.requestInvoice(orderId, invoice, w);
272
+ const result = await sf.customer.requestInvoice(orderId, orderInvoiceBody(invoice), w);
250
273
  return { ok: true, intent, step: result.status === "issued" ? "issued" : "pending", result, ...result.invoice ? { invoice: result.invoice } : {} };
251
274
  }
252
275
  case "extract-document": {
@@ -280,8 +303,10 @@ exports.NO_FISCAL_CONTEXT = NO_FISCAL_CONTEXT;
280
303
  exports.UPLOAD_LIMITS = UPLOAD_LIMITS;
281
304
  exports.createInvoiceAction = createInvoiceAction;
282
305
  exports.extractUploadedDocument = extractUploadedDocument;
306
+ exports.formField = formField;
283
307
  exports.invoiceFromForm = invoiceFromForm;
284
308
  exports.loadFiscalContext = loadFiscalContext;
309
+ exports.orderInvoiceBody = orderInvoiceBody;
285
310
  exports.parseEvidence = parseEvidence;
286
311
  //# sourceMappingURL=fiscal-server.cjs.map
287
312
  //# sourceMappingURL=fiscal-server.cjs.map