362 Template: Quotation letter

Quotation letter

Type on the left - the preview on the right updates with real data from the chosen record. Click a field in the list to insert it at the cursor.

← All templates

Syntax

# Title / ## HeadingLarge title / blue sub heading
**bold words**Bold text - a whole line or just some words
^ text / > textCentred / right-aligned line
---Horizontal line
| A | B |Table row - the first row is the header
{{customer.name}}Data field (list on the right)
[[lines]] [[totals]]Invoice line table / totals (INVOICE source)
[[barcode:TEXT]] [[qr:TEXT]]Code 128 / QR code - TEXT may contain fields
[[signature:Name|Role]]Signature line
[[pagebreak]]Start a new page
Print PDF (saved version)

Quotation INV-202610-005

9 November 2026

Green Valley International School

300 Moo 5, Nong Prue, Bang Lamung, Chon Buri 20150

Attn: Mrs. Sarah Collins

Dear Mrs. Sarah Collins,

Thank you for your enquiry. We are pleased to quote 6 item(s) as follows:

#DescriptionQtyUnit priceAmount
1Thermal Labels 50 x 30 mm (1,000)12250.003,000.00
2Price Tag Labels (10 rolls)11160.001,760.00
3Kraft Mailer Box S612.0072.00
4Price Tag Labels (10 rolls)10160.001,600.00
5Binder Clips Assorted (box)11120.001,320.00
6Kraft Mailer Box S1212.00144.00
Subtotal7,896.00
VAT 7%552.72
Total (THB)8,448.72

Terms

ItemDetail
Validity30 days from 21 October 2026
Delivery3 working days after confirmation
PaymentBank transfer, 30 days

barcode

Sales Manager
Northwind Print Co., Ltd.

Fields for INVOICE

{{company.name}}Northwind Print Co., Ltd.
{{company.address}}88 Rama VI Road, Ratchathewi, Bangkok 10400
{{company.taxId}}0105559999999
{{company.phone}}+66 2 123 4567
{{today}}9 November 2026
{{invoice.no}}INV-202610-005
{{invoice.date}}21 October 2026
{{invoice.due}}20 November 2026
{{invoice.status}}DRAFT
{{invoice.subtotal}}7,896.00
{{invoice.vat}}552.72
{{invoice.total}}8,448.72
{{invoice.items}}6
{{invoice.notes}}Thank you for your order. Delivery within 3 working days.
{{customer.code}}C-1008
{{customer.name}}Green Valley International School
{{customer.contact}}Mrs. Sarah Collins
{{customer.email}}finance@greenvalley.example
{{customer.phone}}+66 38 555 808
{{customer.address}}300 Moo 5, Nong Prue, Bang Lamung, Chon Buri 20150
{{customer.taxId}}0205558889990
{{record.label}}INV-202610-005
How it works
  1. DocTemplateEngine.parse(body) turns each line into a block: Heading, Text, TableBlock, Tag ... (Java 21 sealed interface + records).
  2. fill() replaces {{key}} with a regex; unknown keys show as [?key].
  3. The same blocks are rendered twice: toHtml() for this preview (a switch with pattern matching) and toPdf() with OpenPDF for printing.
  4. The data map is built from SQL Server in TemplateService.context().
for (Block b : blocks) {
    switch (b) {
        case Heading h  -> doc.add(para(fill(h.text(), ctx), Fonts.bold(18), ALIGN_LEFT, 6));
        case TableBlock t -> doc.add(tablePdf(t, ctx));
        case Tag t      -> tagPdf(doc, t, ctx, barcodes);   // [[lines]], [[qr:...]] ...
        ...
    }
}

Files: service/DocTemplateEngine.java, service/TemplateService.java, web/TemplateController.java.