Types
TicketData
Input data required to generate a receipt PDF.Complete order information for receipt generation
Functions
generateTicketPDF
Renders an HTML receipt template and saves it as a PDF file.Order data to render in the receipt
Local file URI of the generated PDF (e.g.,
file:///path/to/ticket.pdf)Example
Table order example
Receipt template
The generated PDF includes:- Header: TableOrder branding with orange theme (#E25822)
- Metadata: Auto-generated order ID, service type badge, date/time
- Order details: Itemized list with quantities and line totals
- Totals section:
- Subtotal
- Discount (only shown if > 0%)
- Shipping cost (only shown if > 0)
- Grand total with emphasized styling
- Footer: Restaurant name from configuration
Order ID format
Order IDs are generated using the pattern:Localization
All text in the receipt is in Spanish (es-ES):- Date formatting uses
toLocaleString('es-ES') - Labels and messages are in Spanish
- Currency formatting uses 2 decimal places
Styling
The receipt uses a modern, mobile-optimized design:- Font: Apple system fonts with Helvetica fallback
- Colors: Orange primary (#E25822), neutral grays
- Layout: 420px max width, rounded corners, box shadow
- Typography: Clean hierarchy with uppercase labels
The HTML template is embedded in the service code. Modify the
buildTicketHTML function (src/lib/services/pdfService.ts:30-230) to customize the receipt design.Configuration
The service usesConfig.restaurant.name for the footer branding. Ensure this is configured before generating receipts.
Integration
Typical workflow:- Collect order data from checkout flow
- Generate PDF using
generateTicketPDF - Send PDF to Telegram using
sendTicketToTelegram - Clean up temporary files if needed