@facturas/pdf 0.0.0-stage → 0.24.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # @facturas/pdf
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ El PDF de un comprobante autorizado por ARCA, en A4 y con la ubicación de datos
4
+ de la RG 1415, Anexo II, Apartado B. Dibuja el modelo que arma
5
+ `buildVoucherDocument()` de [facturas](https://www.npmjs.com/package/facturas)
6
+ con [@react-pdf/renderer](https://react-pdf.org).
7
+
8
+ ```bash
9
+ pnpm add facturas @facturas/pdf @react-pdf/renderer react
10
+ ```
11
+
12
+ ```ts
13
+ import { renderVoucherPdf } from "@facturas/pdf";
14
+
15
+ const pdf = await renderVoucherPdf(comprobante, {
16
+ logo: await readFile("logo.png"),
17
+ notes: "Garantía oficial de 6 meses.",
18
+ theme: { accentColor: "#C00000" },
19
+ });
20
+ ```
21
+
22
+ - Los bloques fiscales son fijos: el recuadro del emisor, la letra en el centro,
23
+ el bloque de transparencia fiscal abajo a la izquierda y el CAE con su
24
+ vencimiento en 12 puntos abajo a la derecha.
25
+ - El tema cambia tipografía y colores. El logo, los datos de contacto, los
26
+ pagos junto a los totales y las notas tienen su espacio fuera de las zonas
27
+ fiscales.
28
+ - El QR se dibuja en vectores y es un link a la constatación de ARCA.
29
+ - Sale con la misma versión que `facturas`.
30
+
31
+ La guía completa está en
32
+ [Comprobante impreso](https://facturas-sdk.dev/guides/printed-voucher).
@@ -0,0 +1,83 @@
1
+ import { VoucherDocument } from 'facturas';
2
+ import * as react from 'react';
3
+ import { ReactNode, ReactElement } from 'react';
4
+
5
+ /**
6
+ * What a voucher may restyle: fonts and colours. Sizes and placement are
7
+ * fixed, because the norms set them (the CAE due date at 12 pt or more, the
8
+ * Apartado B zones), so a theme cannot shrink or move a fiscal datum.
9
+ */
10
+ type VoucherTheme = {
11
+ /** A family registered with `Font.register`, or a standard PDF font. */
12
+ fontFamily?: string;
13
+ /** The bold face of `fontFamily`. */
14
+ boldFontFamily?: string;
15
+ /** Titles, the letter and the total. */
16
+ accentColor?: string;
17
+ /** Body text. */
18
+ textColor?: string;
19
+ /** The labels before a value, such as "CUIT:". */
20
+ mutedColor?: string;
21
+ /** The separators between table rows and totals. */
22
+ borderColor?: string;
23
+ };
24
+
25
+ type VoucherProps = {
26
+ /** What `buildVoucherDocument()` returned. */
27
+ doc: VoucherDocument;
28
+ theme?: VoucherTheme;
29
+ /** Only the slots: brand, issuer and receiver details, aside and notes. */
30
+ children?: ReactNode;
31
+ };
32
+ /** Top left, above the issuer's name: a logo or a brand mark. */
33
+ declare function VoucherBrand({ children }: {
34
+ children?: ReactNode;
35
+ }): react.JSX.Element;
36
+ /**
37
+ * In the issuer box, after the issuer's fiscal data: phone, email or website.
38
+ */
39
+ declare function VoucherIssuerDetails({ children }: {
40
+ children?: ReactNode;
41
+ }): react.JSX.Element;
42
+ /** After the receiver's fiscal data: phone, email or a customer number. */
43
+ declare function VoucherReceiverDetails({ children }: {
44
+ children?: ReactNode;
45
+ }): react.JSX.Element;
46
+ /**
47
+ * Beside the totals, on their left: payments received or the account
48
+ * balance. It never takes the totals' column. It moves with the totals and
49
+ * the CAE as one block, so keep it short.
50
+ */
51
+ declare function VoucherAside({ children }: {
52
+ children?: ReactNode;
53
+ }): react.JSX.Element;
54
+ /**
55
+ * After the receiver, before the lines, as Stripe's memo: anything else the
56
+ * voucher should say, such as warranty, returns, a CBU or terms. It cannot sit
57
+ * in a fiscal zone, and it may run long: it breaks across sheets.
58
+ */
59
+ declare function VoucherNotes({ children }: {
60
+ children?: ReactNode;
61
+ }): react.JSX.Element;
62
+ /**
63
+ * An A4 printed voucher laid out as RG 1415, Anexo II, Apartado B places its
64
+ * data. The fiscal blocks are fixed: a theme changes fonts and colours, and
65
+ * the slots add a brand and notes, but nothing moves or drops a fiscal datum.
66
+ */
67
+ declare function Voucher({ doc, theme, children }: VoucherProps): react.JSX.Element;
68
+
69
+ type RenderVoucherPdfOptions = {
70
+ theme?: VoucherTheme;
71
+ /** A PNG or JPEG for the brand slot: a URL, a data URI or its bytes. */
72
+ logo?: string | Uint8Array;
73
+ /** Free text for the notes slot, such as warranty or returns. */
74
+ notes?: string;
75
+ };
76
+ /**
77
+ * The A4 PDF of a voucher. Pass the document, with the options for a logo and
78
+ * notes, or a `<Voucher>` element you composed. A wrong composition throws
79
+ * here, before anything renders, with the error that names the mistake.
80
+ */
81
+ declare function renderVoucherPdf(input: VoucherDocument | ReactElement<VoucherProps>, options?: RenderVoucherPdfOptions): Promise<Uint8Array>;
82
+
83
+ export { type RenderVoucherPdfOptions, Voucher, VoucherAside, VoucherBrand, VoucherIssuerDetails, VoucherNotes, type VoucherProps, VoucherReceiverDetails, type VoucherTheme, renderVoucherPdf };
package/dist/index.mjs ADDED
@@ -0,0 +1,707 @@
1
+ // src/render.tsx
2
+ import {
3
+ Image,
4
+ renderToBuffer,
5
+ Text as Text3
6
+ } from "@react-pdf/renderer";
7
+ import { isValidElement as isValidElement2 } from "react";
8
+
9
+ // src/voucher.tsx
10
+ import { Document, Page, Text as Text2, View as View2 } from "@react-pdf/renderer";
11
+ import {
12
+ Children,
13
+ isValidElement
14
+ } from "react";
15
+
16
+ // src/blocks.tsx
17
+ import { Text, View } from "@react-pdf/renderer";
18
+ import { PRINTED_VOUCHER_TEXT } from "facturas";
19
+
20
+ // src/context.tsx
21
+ import { createContext, useContext } from "react";
22
+ var VoucherContext = createContext(null);
23
+ function useVoucher(part) {
24
+ const context = useContext(VoucherContext);
25
+ if (context === null) {
26
+ throw new Error(`<${part}> must be used within <Voucher>.`);
27
+ }
28
+ return context;
29
+ }
30
+
31
+ // src/format.ts
32
+ var CURRENCY_PREFIX = { PES: "$", DOL: "USD" };
33
+ var TITLES = {
34
+ FACTURA: "Factura",
35
+ "NOTA DE D\xC9BITO": "Nota de d\xE9bito",
36
+ "NOTA DE CR\xC9DITO": "Nota de cr\xE9dito"
37
+ };
38
+ var LOWERCASE_PARTICLES = /* @__PURE__ */ new Set(["de", "del"]);
39
+ function formatConditionLegend(legend) {
40
+ return legend.split(" ").map((word, index) => {
41
+ if (word === "IVA" || /\d/.test(word)) {
42
+ return word;
43
+ }
44
+ const lower = word.toLocaleLowerCase("es-AR");
45
+ if (index > 0 && LOWERCASE_PARTICLES.has(lower)) {
46
+ return lower;
47
+ }
48
+ return lower.charAt(0).toLocaleUpperCase("es-AR") + lower.slice(1);
49
+ }).join(" ");
50
+ }
51
+ function formatTitle(title) {
52
+ return TITLES[title];
53
+ }
54
+ function formatAmount(minor) {
55
+ const negative = minor < 0;
56
+ const digits = String(Math.abs(Math.trunc(minor))).padStart(3, "0");
57
+ const units = digits.slice(0, -2).replace(/\B(?=(\d{3})+(?!\d))/g, ".");
58
+ return `${negative ? "-" : ""}${units},${digits.slice(-2)}`;
59
+ }
60
+ function formatMoney(minor, currencyId) {
61
+ return `${CURRENCY_PREFIX[currencyId] ?? currencyId} ${formatAmount(minor)}`;
62
+ }
63
+ function formatDecimal(value) {
64
+ const [units = "0", decimals = ""] = value.split(".");
65
+ return `${units.replace(/\B(?=(\d{3})+(?!\d))/g, ".")},${decimals.padEnd(2, "0")}`;
66
+ }
67
+ function formatQuantity(quantity) {
68
+ return String(quantity).replace(".", ",");
69
+ }
70
+ function formatDate(iso) {
71
+ const [year, month, day] = iso.split("-");
72
+ return `${day}/${month}/${year}`;
73
+ }
74
+ function formatTaxId(value) {
75
+ return /^\d{11}$/.test(value) ? `${value.slice(0, 2)}-${value.slice(2, 10)}-${value.slice(10)}` : value;
76
+ }
77
+ function formatVatRate(rate) {
78
+ if (rate === "exempt") {
79
+ return "Exento";
80
+ }
81
+ if (rate === "untaxed") {
82
+ return "No gravado";
83
+ }
84
+ return `${String(rate).replace(".", ",")}%`;
85
+ }
86
+
87
+ // src/qr.tsx
88
+ import { Link, Path, Svg } from "@react-pdf/renderer";
89
+ import QRCode from "qrcode";
90
+
91
+ // src/theme.ts
92
+ import { StyleSheet } from "@react-pdf/renderer";
93
+ var DEFAULT_THEME = {
94
+ fontFamily: "Helvetica",
95
+ boldFontFamily: "Helvetica-Bold",
96
+ accentColor: "#000000",
97
+ textColor: "#000000",
98
+ mutedColor: "#000000",
99
+ borderColor: "#EBEBEB"
100
+ };
101
+ function resolveTheme(theme = {}) {
102
+ const resolved = { ...DEFAULT_THEME };
103
+ for (const key of Object.keys(DEFAULT_THEME)) {
104
+ const value = theme[key];
105
+ if (typeof value === "string" && value.trim() !== "") {
106
+ resolved[key] = value;
107
+ }
108
+ }
109
+ return resolved;
110
+ }
111
+ var CM = 72 / 2.54;
112
+ var ISSUER_BOX_MIN_HEIGHT = 3 * CM;
113
+ var CAE_DUE_DATE_FONT_SIZE = 12;
114
+ var QR_SIZE = 76;
115
+ var OUTLINE_COLOR = "#999999";
116
+ var A4_WIDTH = 595.28;
117
+ var PAGE_MARGIN = 40;
118
+ var BOX_PADDING = 14;
119
+ var LETTER_COLUMN_WIDTH = 84;
120
+ var RIGHT_COLUMN_WIDTH = (A4_WIDTH - 2 * PAGE_MARGIN - LETTER_COLUMN_WIDTH) / 2;
121
+ function createStyles(theme) {
122
+ const bold = { fontFamily: theme.boldFontFamily };
123
+ const leading = { fontSize: 9, lineHeight: 1.35 };
124
+ const outline = {
125
+ borderColor: OUTLINE_COLOR,
126
+ borderStyle: "solid",
127
+ borderWidth: 0.6
128
+ };
129
+ return StyleSheet.create({
130
+ page: {
131
+ paddingTop: 32,
132
+ paddingBottom: 36,
133
+ paddingHorizontal: PAGE_MARGIN,
134
+ fontFamily: theme.fontFamily,
135
+ fontSize: 9,
136
+ color: theme.textColor,
137
+ flexDirection: "column"
138
+ },
139
+ bold,
140
+ muted: { color: theme.mutedColor },
141
+ // L3: the "recuadro" is a thin rounded rectangle.
142
+ header: {
143
+ ...outline,
144
+ flexDirection: "row",
145
+ minHeight: ISSUER_BOX_MIN_HEIGHT,
146
+ borderRadius: 12
147
+ },
148
+ headerSide: { ...leading, flex: 1, padding: BOX_PADDING, gap: 1 },
149
+ headerRight: {
150
+ ...leading,
151
+ flex: 1,
152
+ padding: BOX_PADDING,
153
+ gap: 1,
154
+ alignItems: "flex-start"
155
+ },
156
+ headerCenter: {
157
+ width: LETTER_COLUMN_WIDTH,
158
+ alignItems: "center",
159
+ paddingTop: 14,
160
+ gap: 5
161
+ },
162
+ // L4: the letter stands out by its size and weight, in an outlined box.
163
+ letterBox: {
164
+ ...outline,
165
+ width: 40,
166
+ height: 40,
167
+ borderRadius: 8,
168
+ alignItems: "center",
169
+ justifyContent: "center"
170
+ },
171
+ letter: { ...bold, fontSize: 24, lineHeight: 1, color: theme.accentColor },
172
+ code: { fontSize: 7.5, color: theme.textColor },
173
+ letterLegend: { ...bold, fontSize: 6.5, textAlign: "center" },
174
+ issuerName: {
175
+ ...bold,
176
+ fontSize: 11,
177
+ color: theme.accentColor,
178
+ marginBottom: 2
179
+ },
180
+ details: { marginTop: 4, gap: 1, color: theme.textColor },
181
+ conditionLegend: { color: theme.textColor, marginTop: 2 },
182
+ title: { ...bold, fontSize: 18, lineHeight: 1.1, color: theme.accentColor },
183
+ number: { ...bold, fontSize: 10, marginBottom: 6 },
184
+ section: { marginTop: 18 },
185
+ sectionTitle: {
186
+ ...bold,
187
+ fontSize: 9,
188
+ color: theme.textColor,
189
+ marginBottom: 3
190
+ },
191
+ row: { flexDirection: "row" },
192
+ columnLeft: { ...leading, flex: 1, gap: 1, paddingRight: BOX_PADDING },
193
+ columnRight: {
194
+ ...leading,
195
+ width: RIGHT_COLUMN_WIDTH,
196
+ paddingLeft: BOX_PADDING,
197
+ gap: 1
198
+ },
199
+ table: { ...leading, marginTop: 6 },
200
+ // Fixed, so on later sheets its top padding separates it from the box.
201
+ tableHead: {
202
+ flexDirection: "row",
203
+ paddingTop: 18,
204
+ paddingBottom: 5,
205
+ borderBottomWidth: 1,
206
+ borderBottomColor: theme.accentColor,
207
+ borderBottomStyle: "solid",
208
+ fontSize: 7.5,
209
+ color: theme.textColor
210
+ },
211
+ tableRow: {
212
+ flexDirection: "row",
213
+ paddingVertical: 3,
214
+ borderBottomWidth: 0.5,
215
+ borderBottomColor: theme.borderColor,
216
+ borderBottomStyle: "solid"
217
+ },
218
+ cellCode: { width: 72, paddingRight: 8 },
219
+ cellDescription: { flex: 1, paddingRight: 6 },
220
+ cellNumber: { width: 64, textAlign: "right" },
221
+ cellDiscount: { width: 52, textAlign: "right" },
222
+ cellNarrow: { width: 40, textAlign: "right" },
223
+ totalsRow: { flexDirection: "row", marginTop: 10, gap: 32 },
224
+ aside: { flex: 1, paddingTop: 5 },
225
+ totals: { ...leading, width: 240 },
226
+ totalRow: {
227
+ flexDirection: "row",
228
+ justifyContent: "space-between",
229
+ // Stripe's pitch: 9 pt rows, 14.25 pt apart.
230
+ paddingVertical: 1,
231
+ borderBottomWidth: 0.5,
232
+ borderBottomColor: theme.borderColor,
233
+ borderBottomStyle: "solid"
234
+ },
235
+ // A long tax name wraps in its own column; the amount keeps its width.
236
+ totalLabel: { flex: 1, paddingRight: 8 },
237
+ totalAmount: { flexShrink: 0, textAlign: "right" },
238
+ grandTotalRow: { flexDirection: "row", gap: 32 },
239
+ grandTotal: {
240
+ ...bold,
241
+ color: theme.accentColor,
242
+ borderBottomWidth: 0
243
+ },
244
+ legends: {
245
+ marginTop: 20,
246
+ gap: 2,
247
+ fontSize: 7.5,
248
+ lineHeight: 1.4,
249
+ color: theme.textColor
250
+ },
251
+ notes: { ...leading, marginTop: 14, color: theme.textColor },
252
+ closing: { flexGrow: 1 },
253
+ footer: {
254
+ marginTop: "auto",
255
+ paddingTop: 12,
256
+ borderTopWidth: 0.5,
257
+ borderTopColor: theme.borderColor,
258
+ borderTopStyle: "solid",
259
+ flexDirection: "row",
260
+ gap: 16
261
+ },
262
+ footerLeft: { ...leading, flex: 1, gap: 1, justifyContent: "flex-end" },
263
+ footerRight: {
264
+ flex: 1,
265
+ flexDirection: "row",
266
+ gap: 12,
267
+ justifyContent: "flex-end",
268
+ alignItems: "center"
269
+ },
270
+ transparencyTitle: { ...bold, fontSize: 7.5, marginBottom: 2 },
271
+ transparency: { fontSize: 8, color: theme.textColor },
272
+ cae: { ...bold, fontSize: 10, color: theme.accentColor },
273
+ caeDueDate: {
274
+ ...bold,
275
+ fontSize: CAE_DUE_DATE_FONT_SIZE,
276
+ color: theme.accentColor
277
+ },
278
+ // No lineHeight here: react-pdf drops a `render` text that sets one.
279
+ pageNumber: {
280
+ position: "absolute",
281
+ bottom: 20,
282
+ right: 40,
283
+ fontSize: 7.5,
284
+ color: theme.textColor
285
+ }
286
+ });
287
+ }
288
+
289
+ // src/qr.tsx
290
+ import { jsx } from "react/jsx-runtime";
291
+ function qrPath(text) {
292
+ const { modules } = QRCode.create(text, { errorCorrectionLevel: "M" });
293
+ const { size, data } = modules;
294
+ let d = "";
295
+ for (let row = 0; row < size; row++) {
296
+ for (let column = 0; column < size; column++) {
297
+ if (data[row * size + column]) {
298
+ d += `M${column} ${row}h1v1h-1z`;
299
+ }
300
+ }
301
+ }
302
+ return { size, d };
303
+ }
304
+ function ArcaQr({ url }) {
305
+ const { size, d } = qrPath(url);
306
+ const quiet = 2;
307
+ const box = size + quiet * 2;
308
+ return /* @__PURE__ */ jsx(Link, { src: url, children: /* @__PURE__ */ jsx(Svg, { height: QR_SIZE, viewBox: `0 0 ${box} ${box}`, width: QR_SIZE, children: /* @__PURE__ */ jsx(Path, { d, fill: "#000000", transform: `translate(${quiet} ${quiet})` }) }) });
309
+ }
310
+
311
+ // src/blocks.tsx
312
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
313
+ function Labeled({ label, children }) {
314
+ const { styles } = useVoucher("Labeled");
315
+ return /* @__PURE__ */ jsxs(Text, { children: [
316
+ /* @__PURE__ */ jsxs(Text, { style: styles.muted, children: [
317
+ label,
318
+ " "
319
+ ] }),
320
+ children
321
+ ] });
322
+ }
323
+ function IssuerHeader({
324
+ brand,
325
+ details
326
+ }) {
327
+ const { doc, styles } = useVoucher("IssuerHeader");
328
+ const { issuer } = doc;
329
+ return /* @__PURE__ */ jsxs(View, { fixed: true, style: styles.header, children: [
330
+ /* @__PURE__ */ jsxs(View, { style: styles.headerSide, children: [
331
+ brand,
332
+ issuer.tradeName ? /* @__PURE__ */ jsx2(Text, { style: styles.issuerName, children: issuer.tradeName }) : null,
333
+ /* @__PURE__ */ jsx2(Text, { style: issuer.tradeName ? styles.bold : styles.issuerName, children: issuer.legalName }),
334
+ /* @__PURE__ */ jsx2(Text, { children: issuer.address }),
335
+ /* @__PURE__ */ jsx2(Text, { style: styles.conditionLegend, children: formatConditionLegend(issuer.conditionLegend) }),
336
+ details
337
+ ] }),
338
+ /* @__PURE__ */ jsx2(LetterBox, {}),
339
+ /* @__PURE__ */ jsxs(View, { style: styles.headerRight, children: [
340
+ /* @__PURE__ */ jsx2(Text, { style: styles.title, children: formatTitle(doc.title) }),
341
+ /* @__PURE__ */ jsxs(Text, { style: styles.number, children: [
342
+ "N\xBA ",
343
+ doc.number
344
+ ] }),
345
+ /* @__PURE__ */ jsx2(Labeled, { label: "Fecha de emisi\xF3n:", children: formatDate(doc.issueDate) }),
346
+ /* @__PURE__ */ jsx2(Labeled, { label: "CUIT:", children: formatTaxId(issuer.taxId) }),
347
+ /* @__PURE__ */ jsx2(Labeled, { label: "Ingresos Brutos:", children: issuer.grossIncome }),
348
+ issuer.activitiesStartDate ? (
349
+ // D9: the norm's INICIO DE ACTIVIDADES, in the case of the other labels.
350
+ /* @__PURE__ */ jsx2(Labeled, { label: "Inicio de actividades:", children: formatDate(issuer.activitiesStartDate) })
351
+ ) : null
352
+ ] })
353
+ ] });
354
+ }
355
+ function LetterBox() {
356
+ const { doc, styles } = useVoucher("LetterBox");
357
+ return /* @__PURE__ */ jsxs(View, { style: styles.headerCenter, children: [
358
+ /* @__PURE__ */ jsx2(View, { style: styles.letterBox, children: /* @__PURE__ */ jsx2(Text, { style: styles.letter, children: doc.voucherClass }) }),
359
+ /* @__PURE__ */ jsxs(Text, { style: styles.code, children: [
360
+ PRINTED_VOUCHER_TEXT.code,
361
+ " ",
362
+ doc.code
363
+ ] }),
364
+ doc.letterLegend ? /* @__PURE__ */ jsx2(Text, { style: styles.letterLegend, children: doc.letterLegend }) : null
365
+ ] });
366
+ }
367
+ function ReceiverBlock({ details }) {
368
+ const { doc, styles } = useVoucher("ReceiverBlock");
369
+ const { receiver } = doc;
370
+ return /* @__PURE__ */ jsx2(View, { style: styles.section, children: /* @__PURE__ */ jsxs(View, { style: styles.row, children: [
371
+ /* @__PURE__ */ jsxs(View, { style: styles.columnLeft, children: [
372
+ /* @__PURE__ */ jsx2(Text, { style: styles.sectionTitle, children: "Receptor" }),
373
+ receiver.name ? /* @__PURE__ */ jsx2(Text, { style: styles.bold, children: receiver.name }) : null,
374
+ receiver.document ? /* @__PURE__ */ jsxs(Labeled, { label: `${receiver.document.label ?? "Documento"}:`, children: [
375
+ formatTaxId(receiver.document.number),
376
+ " \xB7",
377
+ " ",
378
+ formatConditionLegend(receiver.conditionLegend)
379
+ ] }) : /* @__PURE__ */ jsx2(Text, { children: formatConditionLegend(receiver.conditionLegend) }),
380
+ receiver.address ? /* @__PURE__ */ jsx2(Text, { children: receiver.address }) : null,
381
+ details
382
+ ] }),
383
+ /* @__PURE__ */ jsxs(View, { style: styles.columnRight, children: [
384
+ /* @__PURE__ */ jsx2(Text, { style: styles.sectionTitle, children: "Operaci\xF3n" }),
385
+ /* @__PURE__ */ jsx2(Labeled, { label: "Condici\xF3n de venta:", children: doc.saleConditions }),
386
+ doc.servicePeriod ? /* @__PURE__ */ jsxs(Labeled, { label: "Per\xEDodo facturado:", children: [
387
+ formatDate(doc.servicePeriod.from),
388
+ " al",
389
+ " ",
390
+ formatDate(doc.servicePeriod.to)
391
+ ] }) : null,
392
+ doc.paymentDueDate ? /* @__PURE__ */ jsx2(Labeled, { label: "Vencimiento para el pago:", children: formatDate(doc.paymentDueDate) }) : null,
393
+ doc.remitos.length > 0 ? /* @__PURE__ */ jsx2(Labeled, { label: "Remitos:", children: doc.remitos.join(", ") }) : null,
394
+ doc.currency.exchangeRate ? /* @__PURE__ */ jsxs(Labeled, { label: "Moneda:", children: [
395
+ doc.currency.id,
396
+ " \xB7 Tipo de cambio",
397
+ " ",
398
+ formatDecimal(doc.currency.exchangeRate)
399
+ ] }) : null
400
+ ] })
401
+ ] }) });
402
+ }
403
+ var LONG_TOKEN = 20;
404
+ function wrapDescription(word) {
405
+ return word.length > LONG_TOKEN ? [...word] : [word];
406
+ }
407
+ var UNBREAKABLE_DESCRIPTION = 600;
408
+ function LinesTable() {
409
+ const { doc, styles } = useVoucher("LinesTable");
410
+ const showCode = doc.lines.some((line) => line.code !== void 0);
411
+ const showDiscount = doc.lines.some((line) => line.discount !== void 0);
412
+ const showRate = doc.voucherClass === "A" && new Set(doc.lines.map((line) => line.vatRate)).size > 1;
413
+ return /* @__PURE__ */ jsxs(View, { style: styles.table, children: [
414
+ /* @__PURE__ */ jsxs(View, { fixed: true, style: styles.tableHead, children: [
415
+ showCode ? /* @__PURE__ */ jsx2(Text, { style: styles.cellCode, children: "C\xF3digo" }) : null,
416
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellDescription, children: "Descripci\xF3n" }),
417
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellNarrow, children: "Cant." }),
418
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellNumber, children: "P. unitario" }),
419
+ showDiscount ? /* @__PURE__ */ jsx2(Text, { style: styles.cellDiscount, children: "Bonif." }) : null,
420
+ showRate ? /* @__PURE__ */ jsx2(Text, { style: styles.cellNarrow, children: "IVA" }) : null,
421
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellNumber, children: "Subtotal" })
422
+ ] }),
423
+ doc.lines.map((line, index) => /* @__PURE__ */ jsxs(
424
+ View,
425
+ {
426
+ style: styles.tableRow,
427
+ wrap: line.description.length > UNBREAKABLE_DESCRIPTION,
428
+ children: [
429
+ showCode ? /* @__PURE__ */ jsx2(Text, { style: styles.cellCode, children: line.code ?? "" }) : null,
430
+ /* @__PURE__ */ jsx2(
431
+ Text,
432
+ {
433
+ hyphenationCallback: wrapDescription,
434
+ style: styles.cellDescription,
435
+ children: line.description
436
+ }
437
+ ),
438
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellNarrow, children: formatQuantity(line.quantity) }),
439
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellNumber, children: formatDecimal(line.unitPrice) }),
440
+ showDiscount ? /* @__PURE__ */ jsx2(Text, { style: styles.cellDiscount, children: line.discount ? formatAmount(line.discount) : "" }) : null,
441
+ showRate ? /* @__PURE__ */ jsx2(Text, { style: styles.cellNarrow, children: line.vatRate === void 0 ? "" : formatVatRate(line.vatRate) }) : null,
442
+ /* @__PURE__ */ jsx2(Text, { style: styles.cellNumber, children: formatAmount(line.amount) })
443
+ ]
444
+ },
445
+ `${index}-${line.description}`
446
+ ))
447
+ ] });
448
+ }
449
+ function TotalRow({ label, amount }) {
450
+ const { doc, styles } = useVoucher("TotalRow");
451
+ return /* @__PURE__ */ jsxs(View, { style: styles.totalRow, wrap: false, children: [
452
+ /* @__PURE__ */ jsx2(Text, { style: [styles.totalLabel, styles.muted], children: label }),
453
+ /* @__PURE__ */ jsx2(Text, { style: styles.totalAmount, children: formatMoney(amount, doc.currency.id) })
454
+ ] });
455
+ }
456
+ var UNBREAKABLE_TOTALS_HEIGHT = 250;
457
+ var TOTALS_LABEL_CHARS_PER_LINE = 28;
458
+ var TOTALS_LINE_HEIGHT = 12.15;
459
+ var TOTALS_ROW_CHROME = 2.5;
460
+ function totalsRows(doc) {
461
+ const { totals } = doc;
462
+ const classA = doc.voucherClass === "A";
463
+ return [
464
+ {
465
+ key: "subtotal",
466
+ label: classA ? "Importe neto gravado" : "Subtotal",
467
+ amount: totals.subtotal
468
+ },
469
+ ...classA && totals.exempt > 0 ? [{ key: "exempt", label: "Importe exento", amount: totals.exempt }] : [],
470
+ ...classA && totals.untaxed > 0 ? [
471
+ {
472
+ key: "untaxed",
473
+ label: "Importe no gravado",
474
+ amount: totals.untaxed
475
+ }
476
+ ] : [],
477
+ ...totals.vatRates.map((row) => ({
478
+ key: `vat-${row.id}`,
479
+ label: `IVA ${row.rate === void 0 ? `(${row.id})` : formatVatRate(row.rate)}`,
480
+ amount: row.amount
481
+ })),
482
+ // Two provinces' IIBB perceptions share the tribute id.
483
+ ...totals.otherTaxes.map((tax, index) => ({
484
+ key: `tax-${index}-${tax.id}`,
485
+ label: tax.description,
486
+ amount: tax.amount
487
+ })),
488
+ ...totals.adjustment === 0 ? [] : [{ key: "adjustment", label: "Ajuste", amount: totals.adjustment }]
489
+ ];
490
+ }
491
+ function totalsBreak(doc) {
492
+ const height = totalsRows(doc).reduce(
493
+ (sum, row) => sum + Math.ceil(row.label.length / TOTALS_LABEL_CHARS_PER_LINE) * TOTALS_LINE_HEIGHT + TOTALS_ROW_CHROME,
494
+ 0
495
+ );
496
+ return height > UNBREAKABLE_TOTALS_HEIGHT;
497
+ }
498
+ function GrandTotal() {
499
+ const { doc, styles } = useVoucher("GrandTotal");
500
+ return /* @__PURE__ */ jsxs(View, { style: [styles.totalRow, styles.grandTotal], children: [
501
+ /* @__PURE__ */ jsx2(Text, { style: styles.totalLabel, children: "Importe total" }),
502
+ /* @__PURE__ */ jsx2(Text, { style: styles.totalAmount, children: formatMoney(doc.totals.total, doc.currency.id) })
503
+ ] });
504
+ }
505
+ function TotalsBlock({
506
+ aside,
507
+ breakable
508
+ }) {
509
+ const { doc, styles } = useVoucher("TotalsBlock");
510
+ return /* @__PURE__ */ jsxs(View, { style: styles.totalsRow, wrap: breakable, children: [
511
+ aside ?? /* @__PURE__ */ jsx2(View, { style: styles.aside }),
512
+ /* @__PURE__ */ jsxs(View, { style: styles.totals, children: [
513
+ totalsRows(doc).map((row) => /* @__PURE__ */ jsx2(TotalRow, { amount: row.amount, label: row.label }, row.key)),
514
+ breakable ? null : /* @__PURE__ */ jsx2(GrandTotal, {})
515
+ ] })
516
+ ] });
517
+ }
518
+ function LegendsBlock() {
519
+ const { doc, styles } = useVoucher("LegendsBlock");
520
+ if (doc.legends.length === 0) {
521
+ return null;
522
+ }
523
+ return /* @__PURE__ */ jsx2(View, { style: styles.legends, wrap: false, children: doc.legends.map((legend) => /* @__PURE__ */ jsx2(Text, { children: legend.text }, legend.rule)) });
524
+ }
525
+ function FiscalFooter({
526
+ doc,
527
+ styles
528
+ }) {
529
+ return /* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
530
+ /* @__PURE__ */ jsx2(View, { style: styles.footerLeft, children: doc.transparency ? /* @__PURE__ */ jsx2(Transparency, { doc, styles }) : null }),
531
+ /* @__PURE__ */ jsxs(View, { style: styles.footerRight, children: [
532
+ /* @__PURE__ */ jsx2(ArcaQr, { url: doc.qr }),
533
+ /* @__PURE__ */ jsxs(View, { style: { gap: 3 }, children: [
534
+ /* @__PURE__ */ jsxs(Text, { style: styles.cae, children: [
535
+ PRINTED_VOUCHER_TEXT.cae,
536
+ " ",
537
+ doc.authorization.code
538
+ ] }),
539
+ /* @__PURE__ */ jsxs(Text, { style: styles.caeDueDate, children: [
540
+ PRINTED_VOUCHER_TEXT.caeDueDate,
541
+ " ",
542
+ formatDate(doc.authorization.dueDate)
543
+ ] })
544
+ ] })
545
+ ] })
546
+ ] });
547
+ }
548
+ function Transparency({
549
+ doc,
550
+ styles
551
+ }) {
552
+ const transparency = doc.transparency;
553
+ if (transparency === void 0) {
554
+ return null;
555
+ }
556
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
557
+ /* @__PURE__ */ jsx2(Text, { style: styles.transparencyTitle, children: PRINTED_VOUCHER_TEXT.transparencyTitle }),
558
+ /* @__PURE__ */ jsxs(Text, { style: styles.transparency, children: [
559
+ PRINTED_VOUCHER_TEXT.vatContained,
560
+ ":",
561
+ " ",
562
+ formatMoney(transparency.vatContained, doc.currency.id)
563
+ ] }),
564
+ /* @__PURE__ */ jsxs(Text, { style: styles.transparency, children: [
565
+ PRINTED_VOUCHER_TEXT.otherNationalIndirectTaxes,
566
+ ":",
567
+ " ",
568
+ formatMoney(transparency.otherNationalIndirectTaxes, doc.currency.id)
569
+ ] })
570
+ ] });
571
+ }
572
+
573
+ // src/voucher.tsx
574
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
575
+ function VoucherBrand({ children }) {
576
+ useVoucher("VoucherBrand");
577
+ return /* @__PURE__ */ jsx3(View2, { style: { marginBottom: 10 }, children });
578
+ }
579
+ function VoucherIssuerDetails({ children }) {
580
+ const { styles } = useVoucher("VoucherIssuerDetails");
581
+ return /* @__PURE__ */ jsx3(View2, { style: styles.details, children });
582
+ }
583
+ function VoucherReceiverDetails({ children }) {
584
+ const { styles } = useVoucher("VoucherReceiverDetails");
585
+ return /* @__PURE__ */ jsx3(View2, { style: styles.details, children });
586
+ }
587
+ function VoucherAside({ children }) {
588
+ const { styles } = useVoucher("VoucherAside");
589
+ return /* @__PURE__ */ jsx3(View2, { style: styles.aside, children });
590
+ }
591
+ function VoucherNotes({ children }) {
592
+ const { styles } = useVoucher("VoucherNotes");
593
+ return /* @__PURE__ */ jsx3(View2, { style: styles.notes, children });
594
+ }
595
+ var SLOTS = /* @__PURE__ */ new Map([
596
+ [VoucherBrand, "brand"],
597
+ [VoucherIssuerDetails, "issuerDetails"],
598
+ [VoucherReceiverDetails, "receiverDetails"],
599
+ [VoucherAside, "aside"],
600
+ [VoucherNotes, "notes"]
601
+ ]);
602
+ var SLOT_NAMES = {
603
+ brand: "VoucherBrand",
604
+ issuerDetails: "VoucherIssuerDetails",
605
+ receiverDetails: "VoucherReceiverDetails",
606
+ aside: "VoucherAside",
607
+ notes: "VoucherNotes"
608
+ };
609
+ function collectSlots(children) {
610
+ const slots = {};
611
+ for (const child of Children.toArray(children)) {
612
+ const slot = isValidElement(child) ? SLOTS.get(child.type) : void 0;
613
+ if (slot === void 0) {
614
+ throw new Error(
615
+ `<Voucher> only takes ${Object.values(SLOT_NAMES).map((name) => `<${name}>`).join(
616
+ ", "
617
+ )} as children: the fiscal blocks are placed by <Voucher> itself.`
618
+ );
619
+ }
620
+ if (slots[slot] !== void 0) {
621
+ throw new Error(`<Voucher> takes one <${SLOT_NAMES[slot]}>.`);
622
+ }
623
+ slots[slot] = child;
624
+ }
625
+ return slots;
626
+ }
627
+ function ClosingFooter() {
628
+ const { doc, styles } = useVoucher("FiscalFooter");
629
+ return /* @__PURE__ */ jsx3(FiscalFooter, { doc, styles });
630
+ }
631
+ function sheetNumber({
632
+ pageNumber,
633
+ totalPages
634
+ }) {
635
+ return totalPages > 1 ? `Hoja ${pageNumber} de ${totalPages}` : "";
636
+ }
637
+ function Voucher({ doc, theme, children }) {
638
+ const slots = collectSlots(children);
639
+ const resolved = resolveTheme(theme);
640
+ const styles = createStyles(resolved);
641
+ const breakTotals = totalsBreak(doc);
642
+ return /* @__PURE__ */ jsx3(VoucherContext.Provider, { value: { doc, theme: resolved, styles }, children: /* @__PURE__ */ jsx3(
643
+ Document,
644
+ {
645
+ author: doc.issuer.legalName,
646
+ creator: "facturas",
647
+ producer: "@facturas/pdf",
648
+ title: `${formatTitle(doc.title)} ${doc.voucherClass} ${doc.number}`,
649
+ children: /* @__PURE__ */ jsxs2(Page, { size: "A4", style: styles.page, children: [
650
+ /* @__PURE__ */ jsx3(IssuerHeader, { brand: slots.brand, details: slots.issuerDetails }),
651
+ /* @__PURE__ */ jsx3(ReceiverBlock, { details: slots.receiverDetails }),
652
+ slots.notes,
653
+ /* @__PURE__ */ jsx3(LinesTable, {}),
654
+ breakTotals ? /* @__PURE__ */ jsx3(TotalsBlock, { breakable: true }) : null,
655
+ /* @__PURE__ */ jsxs2(View2, { style: styles.closing, wrap: false, children: [
656
+ breakTotals ? (
657
+ // The aside stays beside the total, with the CAE.
658
+ /* @__PURE__ */ jsxs2(View2, { style: styles.grandTotalRow, children: [
659
+ slots.aside ?? /* @__PURE__ */ jsx3(View2, { style: styles.aside }),
660
+ /* @__PURE__ */ jsx3(View2, { style: styles.totals, children: /* @__PURE__ */ jsx3(GrandTotal, {}) })
661
+ ] })
662
+ ) : /* @__PURE__ */ jsx3(TotalsBlock, { aside: slots.aside, breakable: false }),
663
+ /* @__PURE__ */ jsx3(LegendsBlock, {}),
664
+ /* @__PURE__ */ jsx3(ClosingFooter, {})
665
+ ] }),
666
+ /* @__PURE__ */ jsx3(Text2, { fixed: true, render: sheetNumber, style: styles.pageNumber })
667
+ ] })
668
+ }
669
+ ) });
670
+ }
671
+
672
+ // src/render.tsx
673
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
674
+ async function renderVoucherPdf(input, options = {}) {
675
+ const element = isValidElement2(input) ? input : defaultVoucher(input, options);
676
+ if (element.type !== Voucher) {
677
+ throw new Error(
678
+ "renderVoucherPdf() renders a <Voucher> element or a voucher document."
679
+ );
680
+ }
681
+ collectSlots(element.props.children);
682
+ const document = element;
683
+ return new Uint8Array(await renderToBuffer(document));
684
+ }
685
+ function defaultVoucher(doc, options) {
686
+ const logo = options.logo instanceof Uint8Array ? Buffer.from(options.logo) : options.logo;
687
+ return /* @__PURE__ */ jsxs3(Voucher, { doc, theme: options.theme, children: [
688
+ logo === void 0 ? null : /* @__PURE__ */ jsx4(VoucherBrand, { children: /* @__PURE__ */ jsx4(
689
+ Image,
690
+ {
691
+ src: logo,
692
+ style: { maxHeight: 40, maxWidth: 140, objectFit: "contain" }
693
+ }
694
+ ) }),
695
+ options.notes ? /* @__PURE__ */ jsx4(VoucherNotes, { children: /* @__PURE__ */ jsx4(Text3, { children: options.notes }) }) : null
696
+ ] });
697
+ }
698
+ export {
699
+ Voucher,
700
+ VoucherAside,
701
+ VoucherBrand,
702
+ VoucherIssuerDetails,
703
+ VoucherNotes,
704
+ VoucherReceiverDetails,
705
+ renderVoucherPdf
706
+ };
707
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/render.tsx","../src/voucher.tsx","../src/blocks.tsx","../src/context.tsx","../src/format.ts","../src/qr.tsx","../src/theme.ts"],"sourcesContent":["import {\n type DocumentProps,\n Image,\n renderToBuffer,\n Text,\n} from \"@react-pdf/renderer\";\nimport type { VoucherDocument } from \"facturas\";\nimport { isValidElement, type ReactElement } from \"react\";\nimport type { VoucherTheme } from \"./theme\";\nimport {\n collectSlots,\n Voucher,\n VoucherBrand,\n VoucherNotes,\n type VoucherProps,\n} from \"./voucher\";\n\nexport type RenderVoucherPdfOptions = {\n theme?: VoucherTheme;\n /** A PNG or JPEG for the brand slot: a URL, a data URI or its bytes. */\n logo?: string | Uint8Array;\n /** Free text for the notes slot, such as warranty or returns. */\n notes?: string;\n};\n\n/**\n * The A4 PDF of a voucher. Pass the document, with the options for a logo and\n * notes, or a `<Voucher>` element you composed. A wrong composition throws\n * here, before anything renders, with the error that names the mistake.\n */\nexport async function renderVoucherPdf(\n input: VoucherDocument | ReactElement<VoucherProps>,\n options: RenderVoucherPdfOptions = {}\n): Promise<Uint8Array> {\n const element = isValidElement(input)\n ? input\n : defaultVoucher(input, options);\n if (element.type !== Voucher) {\n throw new Error(\n \"renderVoucherPdf() renders a <Voucher> element or a voucher document.\"\n );\n }\n collectSlots((element.props as VoucherProps).children);\n // <Voucher> renders a <Document> at its root, which is what react-pdf expects.\n const document = element as unknown as ReactElement<DocumentProps>;\n return new Uint8Array(await renderToBuffer(document));\n}\n\nfunction defaultVoucher(\n doc: VoucherDocument,\n options: RenderVoucherPdfOptions\n): ReactElement<VoucherProps> {\n const logo =\n options.logo instanceof Uint8Array\n ? Buffer.from(options.logo)\n : options.logo;\n return (\n <Voucher doc={doc} theme={options.theme}>\n {logo === undefined ? null : (\n <VoucherBrand>\n <Image\n src={logo}\n style={{ maxHeight: 40, maxWidth: 140, objectFit: \"contain\" }}\n />\n </VoucherBrand>\n )}\n {options.notes ? (\n <VoucherNotes>\n <Text>{options.notes}</Text>\n </VoucherNotes>\n ) : null}\n </Voucher>\n );\n}\n","import { Document, Page, Text, View } from \"@react-pdf/renderer\";\nimport type { VoucherDocument } from \"facturas\";\nimport {\n Children,\n isValidElement,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport {\n FiscalFooter,\n GrandTotal,\n IssuerHeader,\n LegendsBlock,\n LinesTable,\n ReceiverBlock,\n TotalsBlock,\n totalsBreak,\n} from \"./blocks\";\nimport { useVoucher, VoucherContext } from \"./context\";\nimport { formatTitle } from \"./format\";\nimport { createStyles, resolveTheme, type VoucherTheme } from \"./theme\";\n\nexport type VoucherProps = {\n /** What `buildVoucherDocument()` returned. */\n doc: VoucherDocument;\n theme?: VoucherTheme;\n /** Only the slots: brand, issuer and receiver details, aside and notes. */\n children?: ReactNode;\n};\n\n/** Top left, above the issuer's name: a logo or a brand mark. */\nexport function VoucherBrand({ children }: { children?: ReactNode }) {\n useVoucher(\"VoucherBrand\");\n return <View style={{ marginBottom: 10 }}>{children}</View>;\n}\n\n/**\n * In the issuer box, after the issuer's fiscal data: phone, email or website.\n */\nexport function VoucherIssuerDetails({ children }: { children?: ReactNode }) {\n const { styles } = useVoucher(\"VoucherIssuerDetails\");\n return <View style={styles.details}>{children}</View>;\n}\n\n/** After the receiver's fiscal data: phone, email or a customer number. */\nexport function VoucherReceiverDetails({ children }: { children?: ReactNode }) {\n const { styles } = useVoucher(\"VoucherReceiverDetails\");\n return <View style={styles.details}>{children}</View>;\n}\n\n/**\n * Beside the totals, on their left: payments received or the account\n * balance. It never takes the totals' column. It moves with the totals and\n * the CAE as one block, so keep it short.\n */\nexport function VoucherAside({ children }: { children?: ReactNode }) {\n const { styles } = useVoucher(\"VoucherAside\");\n return <View style={styles.aside}>{children}</View>;\n}\n\n/**\n * After the receiver, before the lines, as Stripe's memo: anything else the\n * voucher should say, such as warranty, returns, a CBU or terms. It cannot sit\n * in a fiscal zone, and it may run long: it breaks across sheets.\n */\nexport function VoucherNotes({ children }: { children?: ReactNode }) {\n const { styles } = useVoucher(\"VoucherNotes\");\n return <View style={styles.notes}>{children}</View>;\n}\n\nconst SLOTS = new Map<unknown, keyof Slots>([\n [VoucherBrand, \"brand\"],\n [VoucherIssuerDetails, \"issuerDetails\"],\n [VoucherReceiverDetails, \"receiverDetails\"],\n [VoucherAside, \"aside\"],\n [VoucherNotes, \"notes\"],\n]);\n\nconst SLOT_NAMES: Record<keyof Slots, string> = {\n brand: \"VoucherBrand\",\n issuerDetails: \"VoucherIssuerDetails\",\n receiverDetails: \"VoucherReceiverDetails\",\n aside: \"VoucherAside\",\n notes: \"VoucherNotes\",\n};\n\ntype Slots = {\n brand?: ReactElement;\n issuerDetails?: ReactElement;\n receiverDetails?: ReactElement;\n aside?: ReactElement;\n notes?: ReactElement;\n};\n\n/** @internal Also used by `renderVoucherPdf` to refuse a wrong tree before rendering. */\nexport function collectSlots(children: ReactNode): Slots {\n const slots: Slots = {};\n for (const child of Children.toArray(children)) {\n const slot = isValidElement(child) ? SLOTS.get(child.type) : undefined;\n if (slot === undefined) {\n throw new Error(\n `<Voucher> only takes ${Object.values(SLOT_NAMES)\n .map((name) => `<${name}>`)\n .join(\n \", \"\n )} as children: the fiscal blocks are placed by <Voucher> itself.`\n );\n }\n if (slots[slot] !== undefined) {\n throw new Error(`<Voucher> takes one <${SLOT_NAMES[slot]}>.`);\n }\n slots[slot] = child as ReactElement;\n }\n return slots;\n}\n\nfunction ClosingFooter() {\n const { doc, styles } = useVoucher(\"FiscalFooter\");\n return <FiscalFooter doc={doc} styles={styles} />;\n}\n\n/** \"Hoja n de m\" on every sheet of a voucher that takes more than one. */\nfunction sheetNumber({\n pageNumber,\n totalPages,\n}: {\n pageNumber: number;\n totalPages: number;\n}): string {\n return totalPages > 1 ? `Hoja ${pageNumber} de ${totalPages}` : \"\";\n}\n\n/**\n * An A4 printed voucher laid out as RG 1415, Anexo II, Apartado B places its\n * data. The fiscal blocks are fixed: a theme changes fonts and colours, and\n * the slots add a brand and notes, but nothing moves or drops a fiscal datum.\n */\nexport function Voucher({ doc, theme, children }: VoucherProps) {\n const slots = collectSlots(children);\n const resolved = resolveTheme(theme);\n const styles = createStyles(resolved);\n const breakTotals = totalsBreak(doc);\n return (\n <VoucherContext.Provider value={{ doc, theme: resolved, styles }}>\n <Document\n author={doc.issuer.legalName}\n creator=\"facturas\"\n producer=\"@facturas/pdf\"\n title={`${formatTitle(doc.title)} ${doc.voucherClass} ${doc.number}`}\n >\n <Page size=\"A4\" style={styles.page}>\n <IssuerHeader brand={slots.brand} details={slots.issuerDetails} />\n <ReceiverBlock details={slots.receiverDetails} />\n {/* Free text goes before the lines, as Stripe's memo: it may run long and break across sheets. */}\n {slots.notes}\n <LinesTable />\n {/*\n * The total, legends and fiscal footer stay together: when they do\n * not fit, they move to the next sheet as one, so the CAE is never\n * alone. A long tax breakdown flows before them; see totalsBreak.\n */}\n {breakTotals ? <TotalsBlock breakable /> : null}\n <View style={styles.closing} wrap={false}>\n {breakTotals ? (\n // The aside stays beside the total, with the CAE.\n <View style={styles.grandTotalRow}>\n {slots.aside ?? <View style={styles.aside} />}\n <View style={styles.totals}>\n <GrandTotal />\n </View>\n </View>\n ) : (\n <TotalsBlock aside={slots.aside} breakable={false} />\n )}\n <LegendsBlock />\n <ClosingFooter />\n </View>\n <Text fixed render={sheetNumber} style={styles.pageNumber} />\n </Page>\n </Document>\n </VoucherContext.Provider>\n );\n}\n","import { Text, View } from \"@react-pdf/renderer\";\nimport { PRINTED_VOUCHER_TEXT, type VoucherDocument } from \"facturas\";\nimport type { ReactNode } from \"react\";\nimport { useVoucher } from \"./context\";\nimport {\n formatAmount,\n formatConditionLegend,\n formatDate,\n formatDecimal,\n formatMoney,\n formatQuantity,\n formatTaxId,\n formatTitle,\n formatVatRate,\n} from \"./format\";\nimport { ArcaQr } from \"./qr\";\nimport type { VoucherStyles } from \"./theme\";\n\n/**\n * The fiscal blocks. They are internal on purpose: `<Voucher>` places each\n * one in its Apartado B zone, so no template can move or drop them. Rule ids\n * refer to `.github/PRINTED_VOUCHER_SOURCES.md`.\n */\n\nfunction Labeled({ label, children }: { label: string; children: ReactNode }) {\n const { styles } = useVoucher(\"Labeled\");\n return (\n <Text>\n <Text style={styles.muted}>{label} </Text>\n {children}\n </Text>\n );\n}\n\n/** L1, L2, L3 and L4: the issuer box with the letter at its top centre. */\nexport function IssuerHeader({\n brand,\n details,\n}: {\n brand?: ReactNode;\n details?: ReactNode;\n}) {\n const { doc, styles } = useVoucher(\"IssuerHeader\");\n const { issuer } = doc;\n // Fixed: every sheet of a long voucher says whose voucher it is.\n return (\n <View fixed style={styles.header}>\n <View style={styles.headerSide}>\n {brand}\n {issuer.tradeName ? (\n <Text style={styles.issuerName}>{issuer.tradeName}</Text>\n ) : null}\n <Text style={issuer.tradeName ? styles.bold : styles.issuerName}>\n {issuer.legalName}\n </Text>\n <Text>{issuer.address}</Text>\n <Text style={styles.conditionLegend}>\n {formatConditionLegend(issuer.conditionLegend)}\n </Text>\n {details}\n </View>\n <LetterBox />\n <View style={styles.headerRight}>\n <Text style={styles.title}>{formatTitle(doc.title)}</Text>\n <Text style={styles.number}>Nº {doc.number}</Text>\n <Labeled label=\"Fecha de emisión:\">{formatDate(doc.issueDate)}</Labeled>\n <Labeled label=\"CUIT:\">{formatTaxId(issuer.taxId)}</Labeled>\n <Labeled label=\"Ingresos Brutos:\">{issuer.grossIncome}</Labeled>\n {issuer.activitiesStartDate ? (\n // D9: the norm's INICIO DE ACTIVIDADES, in the case of the other labels.\n <Labeled label=\"Inicio de actividades:\">\n {formatDate(issuer.activitiesStartDate)}\n </Labeled>\n ) : null}\n </View>\n </View>\n );\n}\n\n/** L4, G4 and G5: the letter, its code and the legend next to the letter A. */\nfunction LetterBox() {\n const { doc, styles } = useVoucher(\"LetterBox\");\n return (\n <View style={styles.headerCenter}>\n <View style={styles.letterBox}>\n <Text style={styles.letter}>{doc.voucherClass}</Text>\n </View>\n <Text style={styles.code}>\n {PRINTED_VOUCHER_TEXT.code} {doc.code}\n </Text>\n {doc.letterLegend ? (\n <Text style={styles.letterLegend}>{doc.letterLegend}</Text>\n ) : null}\n </View>\n );\n}\n\n/** C13 to C17, L5 and L6, C12, C22 and the service period. */\nexport function ReceiverBlock({ details }: { details?: ReactNode }) {\n const { doc, styles } = useVoucher(\"ReceiverBlock\");\n const { receiver } = doc;\n return (\n <View style={styles.section}>\n <View style={styles.row}>\n <View style={styles.columnLeft}>\n <Text style={styles.sectionTitle}>Receptor</Text>\n {/* Who, their fiscal identity, then where and how to reach them. */}\n {receiver.name ? (\n <Text style={styles.bold}>{receiver.name}</Text>\n ) : null}\n {receiver.document ? (\n <Labeled label={`${receiver.document.label ?? \"Documento\"}:`}>\n {formatTaxId(receiver.document.number)} ·{\" \"}\n {formatConditionLegend(receiver.conditionLegend)}\n </Labeled>\n ) : (\n <Text>{formatConditionLegend(receiver.conditionLegend)}</Text>\n )}\n {receiver.address ? <Text>{receiver.address}</Text> : null}\n {details}\n </View>\n <View style={styles.columnRight}>\n <Text style={styles.sectionTitle}>Operación</Text>\n <Labeled label=\"Condición de venta:\">{doc.saleConditions}</Labeled>\n {doc.servicePeriod ? (\n <Labeled label=\"Período facturado:\">\n {formatDate(doc.servicePeriod.from)} al{\" \"}\n {formatDate(doc.servicePeriod.to)}\n </Labeled>\n ) : null}\n {doc.paymentDueDate ? (\n <Labeled label=\"Vencimiento para el pago:\">\n {formatDate(doc.paymentDueDate)}\n </Labeled>\n ) : null}\n {doc.remitos.length > 0 ? (\n <Labeled label=\"Remitos:\">{doc.remitos.join(\", \")}</Labeled>\n ) : null}\n {doc.currency.exchangeRate ? (\n <Labeled label=\"Moneda:\">\n {doc.currency.id} · Tipo de cambio{\" \"}\n {formatDecimal(doc.currency.exchangeRate)}\n </Labeled>\n ) : null}\n </View>\n </View>\n </View>\n );\n}\n\n/** Longer than a description column holds: such a token may break anywhere. */\nconst LONG_TOKEN = 20;\n\n/**\n * Descriptions wrap between words, never as \"Col-or\". Only a token too long\n * for the column, such as a URL, breaks inside so it cannot overrun the\n * quantity and price columns.\n */\nfunction wrapDescription(word: string): string[] {\n return word.length > LONG_TOKEN ? [...word] : [word];\n}\n\n/**\n * A row stays on one sheet unless its description could outgrow one: an\n * unbreakable row taller than the sheet would be clipped.\n */\nconst UNBREAKABLE_DESCRIPTION = 600;\n\n/** C19 to C21: the lines, without VAT on class A and with VAT on class B. */\nexport function LinesTable() {\n const { doc, styles } = useVoucher(\"LinesTable\");\n const showCode = doc.lines.some((line) => line.code !== undefined);\n const showDiscount = doc.lines.some((line) => line.discount !== undefined);\n // The rate per line only tells something apart when the lines differ: with\n // one rate, the VAT row of the totals already names it.\n const showRate =\n doc.voucherClass === \"A\" &&\n new Set(doc.lines.map((line) => line.vatRate)).size > 1;\n return (\n <View style={styles.table}>\n <View fixed style={styles.tableHead}>\n {showCode ? <Text style={styles.cellCode}>Código</Text> : null}\n <Text style={styles.cellDescription}>Descripción</Text>\n <Text style={styles.cellNarrow}>Cant.</Text>\n <Text style={styles.cellNumber}>P. unitario</Text>\n {showDiscount ? <Text style={styles.cellDiscount}>Bonif.</Text> : null}\n {showRate ? <Text style={styles.cellNarrow}>IVA</Text> : null}\n <Text style={styles.cellNumber}>Subtotal</Text>\n </View>\n {doc.lines.map((line, index) => (\n <View\n key={`${index}-${line.description}`}\n style={styles.tableRow}\n wrap={line.description.length > UNBREAKABLE_DESCRIPTION}\n >\n {showCode ? (\n <Text style={styles.cellCode}>{line.code ?? \"\"}</Text>\n ) : null}\n <Text\n hyphenationCallback={wrapDescription}\n style={styles.cellDescription}\n >\n {line.description}\n </Text>\n <Text style={styles.cellNarrow}>{formatQuantity(line.quantity)}</Text>\n <Text style={styles.cellNumber}>{formatDecimal(line.unitPrice)}</Text>\n {showDiscount ? (\n <Text style={styles.cellDiscount}>\n {line.discount ? formatAmount(line.discount) : \"\"}\n </Text>\n ) : null}\n {showRate ? (\n <Text style={styles.cellNarrow}>\n {line.vatRate === undefined ? \"\" : formatVatRate(line.vatRate)}\n </Text>\n ) : null}\n <Text style={styles.cellNumber}>{formatAmount(line.amount)}</Text>\n </View>\n ))}\n </View>\n );\n}\n\nfunction TotalRow({ label, amount }: { label: string; amount: number }) {\n const { doc, styles } = useVoucher(\"TotalRow\");\n return (\n <View style={styles.totalRow} wrap={false}>\n <Text style={[styles.totalLabel, styles.muted]}>{label}</Text>\n <Text style={styles.totalAmount}>\n {formatMoney(amount, doc.currency.id)}\n </Text>\n </View>\n );\n}\n\n/** Totals rows taller than this may break across sheets; see `TotalsBlock`. */\nconst UNBREAKABLE_TOTALS_HEIGHT = 250;\n/** A conservative fit for a totals label beside its amount, at 9 pt. */\nconst TOTALS_LABEL_CHARS_PER_LINE = 28;\nconst TOTALS_LINE_HEIGHT = 12.15;\nconst TOTALS_ROW_CHROME = 2.5;\n\ntype TotalsRowData = { key: string; label: string; amount: number };\n\n/** C23, C25, L7: the rows above the total, VAT by rate right after the lines on class A. */\nfunction totalsRows(doc: VoucherDocument): TotalsRowData[] {\n const { totals } = doc;\n const classA = doc.voucherClass === \"A\";\n return [\n {\n key: \"subtotal\",\n label: classA ? \"Importe neto gravado\" : \"Subtotal\",\n amount: totals.subtotal,\n },\n ...(classA && totals.exempt > 0\n ? [{ key: \"exempt\", label: \"Importe exento\", amount: totals.exempt }]\n : []),\n ...(classA && totals.untaxed > 0\n ? [\n {\n key: \"untaxed\",\n label: \"Importe no gravado\",\n amount: totals.untaxed,\n },\n ]\n : []),\n ...totals.vatRates.map((row) => ({\n key: `vat-${row.id}`,\n label: `IVA ${row.rate === undefined ? `(${row.id})` : formatVatRate(row.rate)}`,\n amount: row.amount,\n })),\n // Two provinces' IIBB perceptions share the tribute id.\n ...totals.otherTaxes.map((tax, index) => ({\n key: `tax-${index}-${tax.id}`,\n label: tax.description,\n amount: tax.amount,\n })),\n ...(totals.adjustment === 0\n ? []\n : [{ key: \"adjustment\", label: \"Ajuste\", amount: totals.adjustment }]),\n ];\n}\n\n/**\n * Whether the rows above the total may break across sheets. A usual breakdown\n * stays in one block with the total and the CAE. A long one, many wrapped tax\n * names, would not fit a sheet that way, so its rows flow and only the total\n * stays with the CAE.\n */\nexport function totalsBreak(doc: VoucherDocument): boolean {\n const height = totalsRows(doc).reduce(\n (sum, row) =>\n sum +\n Math.ceil(row.label.length / TOTALS_LABEL_CHARS_PER_LINE) *\n TOTALS_LINE_HEIGHT +\n TOTALS_ROW_CHROME,\n 0\n );\n return height > UNBREAKABLE_TOTALS_HEIGHT;\n}\n\nexport function GrandTotal() {\n const { doc, styles } = useVoucher(\"GrandTotal\");\n return (\n <View style={[styles.totalRow, styles.grandTotal]}>\n <Text style={styles.totalLabel}>Importe total</Text>\n <Text style={styles.totalAmount}>\n {formatMoney(doc.totals.total, doc.currency.id)}\n </Text>\n </View>\n );\n}\n\n/**\n * The totals, with the aside slot on their left. With `breakable`, the rows\n * may continue on the next sheet, and the total and the aside are left out:\n * `<Voucher>` puts them with the CAE.\n */\nexport function TotalsBlock({\n aside,\n breakable,\n}: {\n aside?: ReactNode;\n breakable: boolean;\n}) {\n const { doc, styles } = useVoucher(\"TotalsBlock\");\n return (\n <View style={styles.totalsRow} wrap={breakable}>\n {aside ?? <View style={styles.aside} />}\n <View style={styles.totals}>\n {totalsRows(doc).map((row) => (\n <TotalRow amount={row.amount} key={row.key} label={row.label} />\n ))}\n {breakable ? null : <GrandTotal />}\n </View>\n </View>\n );\n}\n\n/** G1 and G3: the conditional legends. */\nexport function LegendsBlock() {\n const { doc, styles } = useVoucher(\"LegendsBlock\");\n if (doc.legends.length === 0) {\n return null;\n }\n return (\n <View style={styles.legends} wrap={false}>\n {doc.legends.map((legend) => (\n <Text key={legend.rule}>{legend.text}</Text>\n ))}\n </View>\n );\n}\n\n/** L8, G2 and Ley 27.743: bottom left. L9, Q1: CAE, its due date and QR, bottom right. */\nexport function FiscalFooter({\n doc,\n styles,\n}: {\n doc: VoucherDocument;\n styles: VoucherStyles;\n}) {\n return (\n <View style={styles.footer}>\n <View style={styles.footerLeft}>\n {doc.transparency ? <Transparency doc={doc} styles={styles} /> : null}\n </View>\n <View style={styles.footerRight}>\n <ArcaQr url={doc.qr} />\n <View style={{ gap: 3 }}>\n <Text style={styles.cae}>\n {PRINTED_VOUCHER_TEXT.cae} {doc.authorization.code}\n </Text>\n <Text style={styles.caeDueDate}>\n {PRINTED_VOUCHER_TEXT.caeDueDate}{\" \"}\n {formatDate(doc.authorization.dueDate)}\n </Text>\n </View>\n </View>\n </View>\n );\n}\n\nfunction Transparency({\n doc,\n styles,\n}: {\n doc: VoucherDocument;\n styles: VoucherStyles;\n}) {\n const transparency = doc.transparency;\n if (transparency === undefined) {\n return null;\n }\n return (\n <>\n <Text style={styles.transparencyTitle}>\n {PRINTED_VOUCHER_TEXT.transparencyTitle}\n </Text>\n <Text style={styles.transparency}>\n {PRINTED_VOUCHER_TEXT.vatContained}:{\" \"}\n {formatMoney(transparency.vatContained, doc.currency.id)}\n </Text>\n <Text style={styles.transparency}>\n {PRINTED_VOUCHER_TEXT.otherNationalIndirectTaxes}:{\" \"}\n {formatMoney(transparency.otherNationalIndirectTaxes, doc.currency.id)}\n </Text>\n </>\n );\n}\n","import type { VoucherDocument } from \"facturas\";\nimport { createContext, useContext } from \"react\";\nimport type { ResolvedTheme, VoucherStyles } from \"./theme\";\n\nexport type VoucherContextValue = {\n doc: VoucherDocument;\n theme: ResolvedTheme;\n styles: VoucherStyles;\n};\n\nexport const VoucherContext = createContext<VoucherContextValue | null>(null);\n\n/** Every part reads the voucher from `<Voucher>`, and fails loudly outside it. */\nexport function useVoucher(part: string): VoucherContextValue {\n const context = useContext(VoucherContext);\n if (context === null) {\n throw new Error(`<${part}> must be used within <Voucher>.`);\n }\n return context;\n}\n","import type { VoucherDocument } from \"facturas\";\n\n/** es-AR formatting of the model's minor units, ISO dates and identifiers. */\n\nconst CURRENCY_PREFIX: Record<string, string> = { PES: \"$\", DOL: \"USD\" };\n\nconst TITLES: Record<VoucherDocument[\"title\"], string> = {\n FACTURA: \"Factura\",\n \"NOTA DE DÉBITO\": \"Nota de débito\",\n \"NOTA DE CRÉDITO\": \"Nota de crédito\",\n};\n\nconst LOWERCASE_PARTICLES = new Set([\"de\", \"del\"]);\n\n/**\n * D9: a VAT condition legend, written in capitals by the norms, in the case\n * ARCA's own vouchers print it: `IVA RESPONSABLE INSCRIPTO` as\n * `IVA Responsable Inscripto`.\n */\nexport function formatConditionLegend(legend: string): string {\n return legend\n .split(\" \")\n .map((word, index) => {\n if (word === \"IVA\" || /\\d/.test(word)) {\n return word;\n }\n const lower = word.toLocaleLowerCase(\"es-AR\");\n if (index > 0 && LOWERCASE_PARTICLES.has(lower)) {\n return lower;\n }\n return lower.charAt(0).toLocaleUpperCase(\"es-AR\") + lower.slice(1);\n })\n .join(\" \");\n}\n\n/** The model's title, `FACTURA`, as the PDF prints it: `Factura`. */\nexport function formatTitle(title: VoucherDocument[\"title\"]): string {\n return TITLES[title];\n}\n\n/** Minor units as `1.234,56`, with no floating point on the way. */\nexport function formatAmount(minor: number): string {\n const negative = minor < 0;\n const digits = String(Math.abs(Math.trunc(minor))).padStart(3, \"0\");\n const units = digits.slice(0, -2).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \".\");\n return `${negative ? \"-\" : \"\"}${units},${digits.slice(-2)}`;\n}\n\n/** Minor units with the voucher currency: `$ 1.234,56` or `USD 1.234,56`. */\nexport function formatMoney(minor: number, currencyId: string): string {\n return `${CURRENCY_PREFIX[currencyId] ?? currencyId} ${formatAmount(minor)}`;\n}\n\n/** A major-unit decimal string such as `605.5` as `605,50`, keeping extra decimals. */\nexport function formatDecimal(value: string): string {\n const [units = \"0\", decimals = \"\"] = value.split(\".\");\n return `${units.replace(/\\B(?=(\\d{3})+(?!\\d))/g, \".\")},${decimals.padEnd(2, \"0\")}`;\n}\n\nexport function formatQuantity(quantity: number): string {\n return String(quantity).replace(\".\", \",\");\n}\n\n/** `YYYY-MM-DD` as `DD/MM/YYYY`. */\nexport function formatDate(iso: string): string {\n const [year, month, day] = iso.split(\"-\");\n return `${day}/${month}/${year}`;\n}\n\n/** An 11-digit CUIT as `20-12345678-9`; anything else is left as is. */\nexport function formatTaxId(value: string): string {\n return /^\\d{11}$/.test(value)\n ? `${value.slice(0, 2)}-${value.slice(2, 10)}-${value.slice(10)}`\n : value;\n}\n\n/** A VAT rate as `21%` or `10,5%`, or the word for exempt and untaxed lines. */\nexport function formatVatRate(rate: number | \"exempt\" | \"untaxed\"): string {\n if (rate === \"exempt\") {\n return \"Exento\";\n }\n if (rate === \"untaxed\") {\n return \"No gravado\";\n }\n return `${String(rate).replace(\".\", \",\")}%`;\n}\n","import { Link, Path, Svg } from \"@react-pdf/renderer\";\nimport QRCode from \"qrcode\";\nimport { QR_SIZE } from \"./theme\";\n\n/** The dark modules of a QR as one SVG path, one unit per module. */\nexport function qrPath(text: string): { size: number; d: string } {\n const { modules } = QRCode.create(text, { errorCorrectionLevel: \"M\" });\n const { size, data } = modules;\n let d = \"\";\n for (let row = 0; row < size; row++) {\n for (let column = 0; column < size; column++) {\n if (data[row * size + column]) {\n d += `M${column} ${row}h1v1h-1z`;\n }\n }\n }\n return { size, d };\n}\n\n/**\n * Q1 and Q2: the ARCA QR, drawn as vectors so it stays sharp when printed,\n * inside a link to the same URL so it can also be opened from the PDF.\n */\nexport function ArcaQr({ url }: { url: string }) {\n const { size, d } = qrPath(url);\n const quiet = 2;\n const box = size + quiet * 2;\n return (\n <Link src={url}>\n <Svg height={QR_SIZE} viewBox={`0 0 ${box} ${box}`} width={QR_SIZE}>\n <Path d={d} fill=\"#000000\" transform={`translate(${quiet} ${quiet})`} />\n </Svg>\n </Link>\n );\n}\n","import { StyleSheet } from \"@react-pdf/renderer\";\n\n/**\n * What a voucher may restyle: fonts and colours. Sizes and placement are\n * fixed, because the norms set them (the CAE due date at 12 pt or more, the\n * Apartado B zones), so a theme cannot shrink or move a fiscal datum.\n */\nexport type VoucherTheme = {\n /** A family registered with `Font.register`, or a standard PDF font. */\n fontFamily?: string;\n /** The bold face of `fontFamily`. */\n boldFontFamily?: string;\n /** Titles, the letter and the total. */\n accentColor?: string;\n /** Body text. */\n textColor?: string;\n /** The labels before a value, such as \"CUIT:\". */\n mutedColor?: string;\n /** The separators between table rows and totals. */\n borderColor?: string;\n};\n\nexport type ResolvedTheme = Required<VoucherTheme>;\n\nconst DEFAULT_THEME: ResolvedTheme = {\n fontFamily: \"Helvetica\",\n boldFontFamily: \"Helvetica-Bold\",\n accentColor: \"#000000\",\n textColor: \"#000000\",\n mutedColor: \"#000000\",\n borderColor: \"#EBEBEB\",\n};\n\nexport function resolveTheme(theme: VoucherTheme = {}): ResolvedTheme {\n const resolved = { ...DEFAULT_THEME };\n for (const key of Object.keys(DEFAULT_THEME) as (keyof ResolvedTheme)[]) {\n const value = theme[key];\n if (typeof value === \"string\" && value.trim() !== \"\") {\n resolved[key] = value;\n }\n }\n return resolved;\n}\n\n/** RG 1415, Anexo II, B, after b): the issuer data box is at least 7 × 3 cm. */\nconst CM = 72 / 2.54;\nexport const ISSUER_BOX_MIN_HEIGHT = 3 * CM;\n/** L9: the CAE due date is printed at 12 pt. */\nexport const CAE_DUE_DATE_FONT_SIZE = 12;\nexport const QR_SIZE = 76;\nconst OUTLINE_COLOR = \"#999999\";\n\nconst A4_WIDTH = 595.28;\nconst PAGE_MARGIN = 40;\nconst BOX_PADDING = 14;\nconst LETTER_COLUMN_WIDTH = 84;\n/**\n * The right column of the issuer box. The receiver section's second column\n * takes the same width, so all the text on the right starts on one vertical.\n */\nconst RIGHT_COLUMN_WIDTH =\n (A4_WIDTH - 2 * PAGE_MARGIN - LETTER_COLUMN_WIDTH) / 2;\n\nexport function createStyles(theme: ResolvedTheme) {\n const bold = { fontFamily: theme.boldFontFamily };\n // Leading for wrapped text, set per block: on the page it would reach the\n // sheet number, and react-pdf drops a `render` text that sets one. A block\n // resolves it against its own font size, so the size goes with it.\n const leading = { fontSize: 9, lineHeight: 1.35 };\n // The issuer box and the letter box: a mid grey, darker than the separators\n // so the box L3 requires shows on screen and in print.\n const outline = {\n borderColor: OUTLINE_COLOR,\n borderStyle: \"solid\",\n borderWidth: 0.6,\n } as const;\n return StyleSheet.create({\n page: {\n paddingTop: 32,\n paddingBottom: 36,\n paddingHorizontal: PAGE_MARGIN,\n fontFamily: theme.fontFamily,\n fontSize: 9,\n color: theme.textColor,\n flexDirection: \"column\",\n },\n bold,\n muted: { color: theme.mutedColor },\n // L3: the \"recuadro\" is a thin rounded rectangle.\n header: {\n ...outline,\n flexDirection: \"row\",\n minHeight: ISSUER_BOX_MIN_HEIGHT,\n borderRadius: 12,\n },\n headerSide: { ...leading, flex: 1, padding: BOX_PADDING, gap: 1 },\n headerRight: {\n ...leading,\n flex: 1,\n padding: BOX_PADDING,\n gap: 1,\n alignItems: \"flex-start\",\n },\n headerCenter: {\n width: LETTER_COLUMN_WIDTH,\n alignItems: \"center\",\n paddingTop: 14,\n gap: 5,\n },\n // L4: the letter stands out by its size and weight, in an outlined box.\n letterBox: {\n ...outline,\n width: 40,\n height: 40,\n borderRadius: 8,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n letter: { ...bold, fontSize: 24, lineHeight: 1, color: theme.accentColor },\n code: { fontSize: 7.5, color: theme.textColor },\n letterLegend: { ...bold, fontSize: 6.5, textAlign: \"center\" },\n issuerName: {\n ...bold,\n fontSize: 11,\n color: theme.accentColor,\n marginBottom: 2,\n },\n details: { marginTop: 4, gap: 1, color: theme.textColor },\n conditionLegend: { color: theme.textColor, marginTop: 2 },\n title: { ...bold, fontSize: 18, lineHeight: 1.1, color: theme.accentColor },\n number: { ...bold, fontSize: 10, marginBottom: 6 },\n section: { marginTop: 18 },\n sectionTitle: {\n ...bold,\n fontSize: 9,\n color: theme.textColor,\n marginBottom: 3,\n },\n row: { flexDirection: \"row\" },\n columnLeft: { ...leading, flex: 1, gap: 1, paddingRight: BOX_PADDING },\n columnRight: {\n ...leading,\n width: RIGHT_COLUMN_WIDTH,\n paddingLeft: BOX_PADDING,\n gap: 1,\n },\n table: { ...leading, marginTop: 6 },\n // Fixed, so on later sheets its top padding separates it from the box.\n tableHead: {\n flexDirection: \"row\",\n paddingTop: 18,\n paddingBottom: 5,\n borderBottomWidth: 1,\n borderBottomColor: theme.accentColor,\n borderBottomStyle: \"solid\",\n fontSize: 7.5,\n color: theme.textColor,\n },\n tableRow: {\n flexDirection: \"row\",\n paddingVertical: 3,\n borderBottomWidth: 0.5,\n borderBottomColor: theme.borderColor,\n borderBottomStyle: \"solid\",\n },\n cellCode: { width: 72, paddingRight: 8 },\n cellDescription: { flex: 1, paddingRight: 6 },\n cellNumber: { width: 64, textAlign: \"right\" },\n cellDiscount: { width: 52, textAlign: \"right\" },\n cellNarrow: { width: 40, textAlign: \"right\" },\n totalsRow: { flexDirection: \"row\", marginTop: 10, gap: 32 },\n aside: { flex: 1, paddingTop: 5 },\n totals: { ...leading, width: 240 },\n totalRow: {\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n // Stripe's pitch: 9 pt rows, 14.25 pt apart.\n paddingVertical: 1,\n borderBottomWidth: 0.5,\n borderBottomColor: theme.borderColor,\n borderBottomStyle: \"solid\",\n },\n // A long tax name wraps in its own column; the amount keeps its width.\n totalLabel: { flex: 1, paddingRight: 8 },\n totalAmount: { flexShrink: 0, textAlign: \"right\" },\n grandTotalRow: { flexDirection: \"row\", gap: 32 },\n grandTotal: {\n ...bold,\n color: theme.accentColor,\n borderBottomWidth: 0,\n },\n legends: {\n marginTop: 20,\n gap: 2,\n fontSize: 7.5,\n lineHeight: 1.4,\n color: theme.textColor,\n },\n notes: { ...leading, marginTop: 14, color: theme.textColor },\n closing: { flexGrow: 1 },\n footer: {\n marginTop: \"auto\",\n paddingTop: 12,\n borderTopWidth: 0.5,\n borderTopColor: theme.borderColor,\n borderTopStyle: \"solid\",\n flexDirection: \"row\",\n gap: 16,\n },\n footerLeft: { ...leading, flex: 1, gap: 1, justifyContent: \"flex-end\" },\n footerRight: {\n flex: 1,\n flexDirection: \"row\",\n gap: 12,\n justifyContent: \"flex-end\",\n alignItems: \"center\",\n },\n transparencyTitle: { ...bold, fontSize: 7.5, marginBottom: 2 },\n transparency: { fontSize: 8, color: theme.textColor },\n cae: { ...bold, fontSize: 10, color: theme.accentColor },\n caeDueDate: {\n ...bold,\n fontSize: CAE_DUE_DATE_FONT_SIZE,\n color: theme.accentColor,\n },\n // No lineHeight here: react-pdf drops a `render` text that sets one.\n pageNumber: {\n position: \"absolute\",\n bottom: 20,\n right: 40,\n fontSize: 7.5,\n color: theme.textColor,\n },\n });\n}\n\nexport type VoucherStyles = ReturnType<typeof createStyles>;\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA,QAAAA;AAAA,OACK;AAEP,SAAS,kBAAAC,uBAAyC;;;ACPlD,SAAS,UAAU,MAAM,QAAAC,OAAM,QAAAC,aAAY;AAE3C;AAAA,EACE;AAAA,EACA;AAAA,OAGK;;;ACPP,SAAS,MAAM,YAAY;AAC3B,SAAS,4BAAkD;;;ACA3D,SAAS,eAAe,kBAAkB;AASnC,IAAM,iBAAiB,cAA0C,IAAI;AAGrE,SAAS,WAAW,MAAmC;AAC5D,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,IAAI,IAAI,kCAAkC;AAAA,EAC5D;AACA,SAAO;AACT;;;ACfA,IAAM,kBAA0C,EAAE,KAAK,KAAK,KAAK,MAAM;AAEvE,IAAM,SAAmD;AAAA,EACvD,SAAS;AAAA,EACT,qBAAkB;AAAA,EAClB,sBAAmB;AACrB;AAEA,IAAM,sBAAsB,oBAAI,IAAI,CAAC,MAAM,KAAK,CAAC;AAO1C,SAAS,sBAAsB,QAAwB;AAC5D,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,UAAU;AACpB,QAAI,SAAS,SAAS,KAAK,KAAK,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AACA,UAAM,QAAQ,KAAK,kBAAkB,OAAO;AAC5C,QAAI,QAAQ,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ACd;AAAA,eACF;AAAA,cAEA,gBAAAA,KAAC,eAAY,OAAO,MAAM,OAAO,WAAW,OAAO;AAAA,UAErD,gBAAAA,KAAC,gBAAa;AAAA,UACd,gBAAAA,KAAC,iBAAc;AAAA,WACjB;AAAA,QACA,gBAAAA,KAACG,OAAA,EAAK,OAAK,MAAC,QAAQ,aAAa,OAAO,OAAO,YAAY;AAAA,SAC7D;AAAA;AAAA,EACF,GACF;AAEJ;;;AD7HI,SAGM,OAAAC,MAHN,QAAAC,aAAA;AA3BJ,eAAsB,iBACpB,OACA,UAAmC,CAAC,GACf;AACrB,QAAM,UAAUC,gBAAe,KAAK,IAChC,QACA,eAAe,OAAO,OAAO;AACjC,MAAI,QAAQ,SAAS,SAAS;AAC5B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,eAAc,QAAQ,MAAuB,QAAQ;AAErD,QAAM,WAAW;AACjB,SAAO,IAAI,WAAW,MAAM,eAAe,QAAQ,CAAC;AACtD;AAEA,SAAS,eACP,KACA,SAC4B;AAC5B,QAAM,OACJ,QAAQ,gBAAgB,aACpB,OAAO,KAAK,QAAQ,IAAI,IACxB,QAAQ;AACd,SACE,gBAAAD,MAAC,WAAQ,KAAU,OAAO,QAAQ,OAC/B;AAAA,aAAS,SAAY,OACpB,gBAAAD,KAAC,gBACC,0BAAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,OAAO,EAAE,WAAW,IAAI,UAAU,KAAK,WAAW,UAAU;AAAA;AAAA,IAC9D,GACF;AAAA,IAED,QAAQ,QACP,gBAAAA,KAAC,gBACC,0BAAAA,KAACG,OAAA,EAAM,kBAAQ,OAAM,GACvB,IACE;AAAA,KACN;AAEJ;","names":["Text","isValidElement","Text","View","jsx","jsx","jsxs","View","Text","jsx","jsxs","isValidElement","Text"]}
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
2
  "name": "@facturas/pdf",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.24.0",
4
+ "description": "PDF de comprobantes de ARCA que cumplen la RG 1415 por construcción: el modelo de facturas dibujado con @react-pdf/renderer.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": "LaPyme",
8
+ "homepage": "https://facturas-sdk.dev/guides/printed-voucher",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/LaPyme/facturas.git",
12
+ "directory": "packages/pdf"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/LaPyme/facturas/issues"
16
+ },
17
+ "keywords": [
18
+ "arca",
19
+ "afip",
20
+ "argentina",
21
+ "factura",
22
+ "pdf",
23
+ "react-pdf",
24
+ "rg-1415"
25
+ ],
26
+ "engines": {
27
+ "node": ">=22"
28
+ },
29
+ "sideEffects": false,
30
+ "main": "./dist/index.mjs",
31
+ "module": "./dist/index.mjs",
32
+ "types": "./dist/index.d.ts",
33
+ "files": [
34
+ "dist",
35
+ "README.md",
36
+ "LICENSE"
37
+ ],
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "default": "./dist/index.mjs"
42
+ },
43
+ "./package.json": "./package.json"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "peerDependencies": {
49
+ "facturas": "0.24.0",
50
+ "react": "^18.0.0 || ^19.0.0"
51
+ },
52
+ "dependencies": {
53
+ "@react-pdf/renderer": "^4.9.0",
54
+ "qrcode": "^1.5.4"
55
+ },
56
+ "devDependencies": {
57
+ "@biomejs/biome": "2.5.13",
58
+ "@types/node": "^22.20.2",
59
+ "@types/qrcode": "^1.5.5",
60
+ "@types/react": "^19.2.0",
61
+ "facturas": "0.24.0",
62
+ "pdfjs-dist": "^6.4.299",
63
+ "react": "^19.3.0",
64
+ "tsup": "^8.5.1",
65
+ "typescript": "^6.0.3",
66
+ "ultracite": "7.11.1",
67
+ "vitest": "^5.0.0"
68
+ },
69
+ "scripts": {
70
+ "build": "tsup --config tsup.config.ts",
71
+ "pack:check": "npm pack --dry-run",
72
+ "typecheck": "tsc --project tsconfig.json --noEmit",
73
+ "test": "vitest run --config vitest.config.ts",
74
+ "check": "ultracite check",
75
+ "fix": "ultracite fix"
76
+ }
6
77
  }