"use client"; import { useEffect, useState } from "react"; import { getCashReceipt } from "@/lib/api"; import { formatDate, formatMoney } from "@/lib/labels"; import type { CashReceipt, CompanyHeader } from "@/lib/types"; /** * One EFE receipt, laid out to print and hand to the customer. No app shell: * the page is the paper. */ export default function CashReceiptPrint({ params }: { params: { folio: string } }) { const [r, setR] = useState<(CashReceipt & { company: CompanyHeader }) | null>(null); const [error, setError] = useState(null); useEffect(() => { getCashReceipt(Number(params.folio)) .then(setR) .catch((e) => setError((e as Error)?.message ?? "No se encontró el recibo.")); }, [params.folio]); if (error) return
{error}
; if (!r) return
Cargando…
; const c = r.company; const voided = r.transaction.voidedAt != null; const converted = r.exchangeRate != null; return (
{c.name}
{c.addressLine1}
{c.addressLine2 &&
{c.addressLine2}
}
{c.cityState}
{c.mailingAddress &&
{c.mailingAddress}
}
{c.phone} · {c.email}
{c.taxId &&
RFC {c.taxId}
}
RECIBO DE EFECTIVO
Folio {r.folio}
{formatDate(r.receivedAt)}
{voided &&
ANULADO
}
{r.customer.name} {r.customer.folderNumber != null && ` · Carpeta ${r.customer.folderNumber}`} {formatMoney(r.amount, r.currency)} {converted && ` (abonado ${formatMoney(r.transaction.amount, r.transaction.currency)} a T.C. ${Number(r.exchangeRate).toFixed(4)})`} {r.concept}{r.preparedBy.name} {r.depositedAt && {formatDate(r.depositedAt)}}
Recibí
Entregó
); } function Row({ label, children }: { label: string; children: React.ReactNode }) { return ( {label} {children} ); }