Receipt Layout
Layout
For printing a fiscal transaction, the data has to be formatted, which is done using the HTML templating engine PUG (former JADE). Language details can be found on pugjs.org.
For Italian fiscal printers, the item description and additional text lines may be formatted freely, but referring amounts are created by the printer in a fixed format.
The following rules occur for fiscal receipts:
- one transaction specific barcode may be printed in the footer
- paper is cut after print completion For details of layout commands see chapter 4 PUG Layout.
You can start Layout editor on page kontrola in section PugEdit for layout configuration, it works as a WYSIWYG editor. Actual printout may differ due to limitations of the fiscal printer compared to HTML.
Besides fiscal.pug different non-fiscal layout files can be provided on directory /EFR/rn/def/cfg, the file name is derived from the DT or NF tag: NF="Login" => "login.pug" (filename lowercase).
For non-fiscal printouts:
- the whole print line width (46 characters) can be used
- lines can be formatted emphazised (
<em>
) or double height (<h3>
)
Transaction Time
The fiscal printer itself has a clock. Date and time printed on the receipt are printer time; transaction date ESR.D is not used.
Printing of Payments
This chapter does not apply to the new FP-T88FVA Online printer. Due to Polish fiscal regulations the payment procedure is considered as optional – it is not required to record payments. It is only allowed to print predefined texts for payments on the printer, and amounts are printed right-aligned. To use one of these texts please send Pay.PayG with one of the following values:
A | Wpłacono |
C | Kaucja |
D | Wypłata kaucji |
E | Gotówka |
F | Czek |
G | Karta kredytowa |
H | Voucher |
K | Kredyt lokalny |
U | Wartość Voucher |
V | Zapłacono Voucher |
W | Waluta wartość |
a | Płatność |
i | Zaliczka |
t | Karta |
Example:
<PayA>
<Pay Dsc="EUR" Amt="10.00" PayG="C"/>
</PayA>
This would print the line: Kaucja 10.00
Footer Printing
It is only allowed to print parameterized predefined texts in the footer, parameters are printed right-aligned. To use these, the lines have to start with one of the following predefined texts:
Predefined text | Parameter type Exorigo | Parameter type POSNET |
---|---|---|
Reszta | 4 | |
linia bez słowa kluczowego | 1 | |
Bez narzutu | 1 | |
Numer | 1 | 4 |
Przebieg km | 1 | |
Waluta | 1 | 4 |
Stan licznika | 1 | |
Nr transakcji | 1 | 4 |
Numer kierowcy | 1 | |
podpis | - | |
Przelicznik | 4 | 4 |
Kasjer | 2 | 4 |
Przedpłata do paragonu | 1 | |
Przedpłata do faktury | 1 | |
Uwzględniono rabat | 1 | |
Do zapłaty | 1 | |
Do wypłaty | 1 | |
pusta linia (spacje) | - | |
Wypłata zaliczki | 1 | |
Udzielony rabat | 1 | 4 |
Punkty – bonus | 1 | 4 |
Punkty – paragon | 1 | 4 |
Razem punktów | 1 | 4 |
Numer karty | 1 | 4 |
Zyskałeś | 1 | |
Przyznano pkt | 1 | |
Stan konta | 1 | |
Dziękujemy za lojalność | - | |
Typ karty | 1 | 4 |
Ważnado | 1 | 4 |
Numer kasy | 1 | |
Numer zmiany | 1 | |
Nr pracownika | 1 | 4 |
Nazw. pracownika | 2 | |
Konto przed tr. | 1 | 4 |
Przyznano | 1 | 4 |
Wykorzystano | 1 | 4 |
Kontopotr. | 1 | 4 |
Klient stały | 1 | 4 |
Ilość sprzed. tow. | 1 | 4 |
Kod | 4 | 4 |
Nazwa | 4 | 4 |
Opis | 4 | 4 |
Liczba | 4 | 4 |
Nazwisko | 4 | 4 |
Nr zamówienia | 4 | 4 |
Numer rej | 4 | |
Nazwa. kasjera | 4 | |
Zaliczka | 4 | |
Voucher | 4 | |
Wartość Voucher | 4 | |
Zapłata Voucher | 4 | |
Numer pracownika | 4 |
Parameter Types
Type 1 Parameter is a string that contains digits, special characters, blanks (ASCII code 0x20), and maximum 3 different letters or characters. The length of the string is from 1 to 24 characters.
Type 2 Parameter is a string that contains letters, special characters, blanks (ASCII code 0x20), and maximum 3 different digits. The length of the string is from 1 to 24 characters.
Type 4 Wide range of characters, footers do not contain LF characters. The length of the string is from 1 to 40 characters.
PUG Editor
Workflow:
- start http://localhost:5618/peri/pugedit with a browser
- [open] e.g. file /EFR/rn/[your-client-id]/cfg/fiscal.pug
- copy your sample transaction data into the textbox at the left side (JSON only)
- the right side box shows the transaction data transformed to HTML
- modifications in PUG code (center box) are shown immediately
- when finished [download] e.g. as fiscal.pug and copy it to
/EFR/rn/[your-client-id]/cfg/
EFR now transforms every transaction into HTML and renders to the line printer. By their nature fiscal printers provide only very limited formatting functionality. At the moment the editor implementation is basic, but it is going to be evolved as base technique for transaction rendering and print layout.
Layout Example
/EFR/app/PL/cfg/fiscal.pug.template:
//- fiscal.pug - Layout for Fiscal Transactions
-
function fDec(dec) { return dec.replace(/\./,',') }
function fQty(Qty) { if (Qty || Qty===0) return fDec(Qty.toString()) }
function fAmt(Amt) { if (Amt || Amt===0) return fDec(Amt.replace?Amt:Amt.toFixed(2))
}
function fPrc(Prc) { return fDec((Prc+'%').replace(/%%$/,'%')) }
function fD(D) { return D.substr(8,2)+'-'+D.substr(5,2)+'-'+D.substr(2,2) }
function fTime(D) { return D.substr(11,8).replace(/^0/,'') }
mixin row(arr)
if arr
hr
each e in arr
div(class=e._)
if e.Qty
.Lin
.Dsc2= ' ' + fQty(e.Qty) + ' ' + (e.QtyU||'') + ' x ' + fAmt(e.Pri)
if e.TaxG
if e._!='Tax'
.Dsc= e.Dsc
else
.DscTax
.Prc= fPrc(e.Prc)
.Net= fAmt(e.Net)
.TAmt= fAmt(e.TAmt)
.TaxG= e.TaxG
else if e.Dsc
.Dsc2= e.Dsc
if !/^-*$/.test(e.LAmt)
.Amt= fAmt(e.LAmt||e.Amt)
else
.Amt
hr
mixin txt(arr)
if arr
br
each e in arr
.Txt= 'string'===typeof e ? e : 'Txt'===e._ ? e.value : unknown
html
head
title= ESR.DT||ESR.NF||'Receipt'
style(type='text/css').
body { font-family:Courier; width:46ch }
.Txt { text-align:center; white-space:pre }
.Pos,.Mod,.Lin,.Tot,.Pay,.Tax
{ display:grid; grid-template-columns:35ch 1ch 8ch }
.Dsc { grid-column:1 }
.TaxG { }
.Dsc2 { grid-column:1/span2 }
.DscTax { width:90%; display:grid; grid-template-columns:4fr 10fr 10fr }
.Prc { }
.Net, .TAmt { text-align:right }
.Amt { text-align:right; grid-column:3 }
@media fiscal {
.Txt,.Tax,.Tot { display:none }}
body
if Sto
.Txt= Sto.Name + ' ' + Sto.Add1
.Txt= Sto.Zip + ' ' + Sto.City + ' TaxId: ' + Sto.VatR
+txt(ESR.Head)
+row(ESR.PosA)
+row([{ _: 'Tot', Dsc: 'TOTAL', Amt: ESR.T }])
+row(ESR.PayA)
+row(ESR.TaxA)
+txt(ESR.Foot)
hr
.Txt= 'Terminal: ' + ESR.TL + '/' + ESR.TT + ' ' + (ESR.NF||'Receipt') + ': ' +
ESR.TN
.Txt= fD(ESR.D) + ' ' + fTime(ESR.D)
Restrictions
The fiscal printer allows only layout of item text, amounts are formatted by the printer. Although transaction data usually is provided with UTF-8 encoding, only CP852 characters can be printed.
Barcode
To add a barcode to a fiscal or non-fiscal layout enter:
div
img(data-barcode="type=ean13" data-value="123456789012" style="width:30ch;height:3ch")
The data-barcode attribute defines barcode parameters, data-value the content. Style (local or CSS) is used for dimensioning. On fiscal layouts, barcodes are only allowed in the footer of the receipt and only 1 barcode can be printed per position. By defining pos in the data-barcode attribute, barcodes can be positioned before (pos=1) or after the footer (pos=2):
div
img(data-barcode="type=qr;pos=1" data-value="123456789012")
data-barcode
type | character set (as regular expression) | |
---|---|---|
upc-a | A | [0-9]{11,12} |
ean13 | C | [0-9]{12,13} |
ean8 | D | [0-9]{7,8} |
code39 | E | [0-9A-Z $%*+-./]{1,34} |
itf | F | [0-9]{2,62} |
codabar | G | [0-9A-Da-d$+-.&/:]{1,47} |
code93 | H | [\u0000-\u007f^{ |
code128-a | 73 | [\u0000-\u007f^{ |
code128-b | 74 | [\u0000-\u007f^{ |
code128-c | 91 | [\u0000-\u007f^{ |
qr | R | .* |
data-value
For EAN types an eventually missing check digit is computed by EFR.
The data-value can be set programmatically:
div
- var x = ESR.TL + ("0" + ESR.TT).slice(-2) + ("00000" + ESR.TN).slice(-6)
img(data-value=x style="width:30ch;height:3ch")
Example Response
XML Response
XML Response:
<TraC SQ="3803">
<Result RC="OK"/>
<Fis D="10-09-18 14:36" FN="25" ZI="5" ID="CCO1800000739"/>
</TraC>
JSON Response
JSON Response:
{
"TraC":{"SQ":3800,
"Result":{"RC":"OK"},
"Fis":{"D":"10-09-18 14:34","FN":22,"ZI":5,"ID":"CCO1800000739"}}}
Response Fis fields:
Element | Description |
---|---|
D | fiscal printer Date and time |
FN | receipt Fiscal Number |
ZI | Z report Index |
ID | fiscal printer ID |