@facturas/pdf 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -58,7 +58,8 @@ function formatAmount(minor) {
58
58
  return `${negative ? "-" : ""}${units},${digits.slice(-2)}`;
59
59
  }
60
60
  function formatMoney(minor, currencyId) {
61
- return `${CURRENCY_PREFIX[currencyId] ?? currencyId} ${formatAmount(minor)}`;
61
+ const prefix = CURRENCY_PREFIX[currencyId] ?? currencyId;
62
+ return `${minor < 0 ? "-" : ""}${prefix} ${formatAmount(Math.abs(minor))}`;
62
63
  }
63
64
  function formatDecimal(value) {
64
65
  const [units = "0", decimals = ""] = value.split(".");
@@ -461,6 +462,14 @@ function totalsRows(doc) {
461
462
  const { totals } = doc;
462
463
  const classA = doc.voucherClass === "A";
463
464
  return [
465
+ // The lines are before the discount and the subtotal after it.
466
+ ...totals.globalDiscount > 0 ? [
467
+ {
468
+ key: "global-discount",
469
+ label: "Descuento global",
470
+ amount: -totals.globalDiscount
471
+ }
472
+ ] : [],
464
473
  {
465
474
  key: "subtotal",
466
475
  label: classA ? "Importe neto gravado" : "Subtotal",
@@ -1 +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,a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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"]}
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 // The lines are before the discount and the subtotal after it.\n ...(totals.globalDiscount > 0\n ? [\n {\n key: \"global-discount\",\n label: \"Descuento global\",\n amount: -totals.globalDiscount,\n },\n ]\n : []),\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/**\n * Minor units with the voucher currency: `$ 1.234,56` or `USD 1.234,56`, and\n * a negative amount signed before the currency, `-$ 12,00`.\n */\nexport function formatMoney(minor: number, currencyId: string): string {\n const prefix = CURRENCY_PREFIX[currencyId] ?? currencyId;\n return `${minor < 0 ? \"-\" : \"\"}${prefix} ${formatAmount(Math.abs(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,SA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Aa,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,6 @@
1
1
  {
2
2
  "name": "@facturas/pdf",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
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
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -46,7 +46,7 @@
46
46
  "access": "public"
47
47
  },
48
48
  "peerDependencies": {
49
- "facturas": "0.24.0",
49
+ "facturas": "0.25.0",
50
50
  "react": "^18.0.0 || ^19.0.0"
51
51
  },
52
52
  "dependencies": {
@@ -58,7 +58,7 @@
58
58
  "@types/node": "^22.20.2",
59
59
  "@types/qrcode": "^1.5.5",
60
60
  "@types/react": "^19.2.0",
61
- "facturas": "0.24.0",
61
+ "facturas": "0.25.0",
62
62
  "pdfjs-dist": "^6.4.299",
63
63
  "react": "^19.3.0",
64
64
  "tsup": "^8.5.1",