Skip to main content

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 Lithuanian 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:

  • Fixed header lines and header logo graphics are configured on setup by Strongpoint
  • One transaction specific barcode may be printed in the last line of the footer
  • The paper is cut after completion of the print

You can start http://localhost:5618/peri/pugedit for layout configuration, it works as a WYSIWYG editor.

Besides fiscal.pug different non-fiscal layout files can be provided on directory /EFR/rn/def/cfg, the file name is derived from the NF or DT tag: NF="Login" => "login.pug" (filename lowercase). If it is required to store non-fiscal transactions without having printed them, set ESR tag Document Delivery DD="noprint".

For non-fiscal printouts:

  • The whole print line width can be used
  • Lines can be formatted, like emphasized with <em> or double height with <h3>

PUG Editor

Workflow:

  • Start http://localhost:5618/peri/pugedit with a browser
  • [Open] e.g. file /EFR/rn/def/cfg/fiscal.pug
  • Copy your sample transaction data into the textbox at the left side
  • 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/def/cfg/

EFR now transforms every transaction into HTML and renders it to the line printer. By their nature, fiscal printers provide only very limited formatting functionality.

At the moment, the editor implementation is fairly basic, but it is going to be evolved as base technique for transaction rendering and print layout.

Layout Example

//- fiscal.pug - Layout for Fiscal Transactions
-
function fStr(str) { return str || str === 0 ? str.toString().replace(/\r/g, '') : '' }
function fDec(dec) { return fStr(dec).replace(/\./, ',') }
function fAmt(Amt) { return fDec(Amt && Amt.toFixed ? Amt.toFixed(2) : Amt) }
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 pos(p)
if p.TaxG
.Dsc= fStr(p.Dsc)
.TaxG= fStr(p.TaxG)
else
.Dsc2= fStr(p.Dsc)
if p.Amt
.Amt= fAmt(p.Amt)
else
.Amt= fStr(p.LAmt)

mixin tot(t)
.Disp
hr
.Tot
.Dsc2 TOTAL
.Amt= fAmt(t)
.Disp
hr

mixin pay(p)
if p.Amt
.DscTxt= fStr(p.Dsc)
.Amt= fAmt(p.Amt)
else
.DscTxt= ' ' + fStr(p.Dsc)
.Amt= fStr(p.LAmt)

mixin tax(t)
.DscTax
.Prc= fPrc(t.Prc)
.Net= fAmt(t.Net)
.TAmt= fAmt(t.TAmt)
.TaxG= fStr(t.TaxG)
.Amt= fAmt(t.Amt)

mixin head(h)
if h
br
each v, k in h
if '_' !== k
.Txt= v._ ? fStr(v.value) : fStr(v)

mixin foot(f)
if f
br
each v, k in f
if '_' !== k
.TxtCenter= v._ ? fStr(v.value) : fStr(v)

html
head
title= ESR.DT||ESR.NF||'Receipt'
style(type='text/css').
body {
font-family: Consolas, 'Courier New';
width: 42ch;
background-color: white;
}
.Txt { white-space: pre; }
.TxtCenter {
white-space: pre;
text-align: center;
}
.Net, .TAmt, .TaxG, .Amt { text-align: right; }
.Pos, .Mod, .Lin, .Tot, .Pay, .Tax, .ItemHead {
display: grid;
grid-template-columns: 33ch 1ch 8ch;
}
.Dsc { grid-column: 1; }
.Dsc2, .DscTxt { grid-column: 1 / span 2; }
.DscTxt { white-space: pre; }
.TaxG { grid-column: 2; }
.Amt { grid-column: 3; }
.DscTax {
width: 90%;
display: grid;
grid-template-columns: 4fr 10fr 10fr;
}
.Print { display: none; }
@media fiscal {
.Disp, .Tax, .Tot { display: none; }
.Print { display: block; }
}
body

//- Logo
.TxtCenter.Disp
//- img(src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARYAAABWBAMAAAD4TKSkAAAAMFBMVEX9/v62xdWes8iGoLpOdJorWIduja0MQHUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACpDntAAAAACXBIWXMAAAsSAAALEgHS3X78AAAIIklEQVR42u2azVviOhSHk0JhW0Dstn4wbN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TazCGFiky628jiF20gfcHjKfvasI/ktzqLpMlZ02R7AwjtSZErjOss4ZCVQ31J08VSWmUIN8Rexd/COevKTwtJXRIrk8cwsBafYD0BnEtfk9QYb2cqAkfykxDZt5Yj9AGQjWwl2yslNYVHO3eKw5MjSLtQeMxkMxiLOyfL9gemeQZxh5RF4O22piC1uJgkI8xdh0HtU3Tm/G1iEFHdSuw/FzOLv2MIs7FBX5r0gfynzwSAp78heDSzlDKW7tLXCQtIkWXoVNe2x2tVhXywxZFOxiaWewwpHlvMOZhhiKDCW+l2pSGRVlnqmI4J1T2NRDwwR3F8Md8gigVBZrBrLwvDJDGkX0Lv5Af5Sn3BsZKkZaVcmCZHKohwD3twDbISwJky5T2os+nF3gQyUykLOK8aK1m3F9HcSA4smjJTyjDUW6TnjFoP+7Vcd5B41sSi39TvpmCh9MKs925wJWGQrSWd2naW8Fyf5Xb9UKiEKUUuP2Qh3hH8RrfgyDRv4Rqo9LYpUY63qxMr7Aa8/Lx5ZkMZ5J4CvoZaF3SKl4VPr96JGrN3DRa3+24qkwU014vAlSoOLtt7+L4DyDx46Uj2hUPvWAAAAAElFTkSuQmCC')
//- br
//- br

//- Display Cfg company data
if Cfg && Cfg.Cmp && Cfg.Cmp.Nam
.TxtCenter.Disp= fStr(Cfg.Cmp.Nam)

//- Display Cfg Location data
if Cfg && Cfg.Loc && Cfg.Loc.Adr
.TxtCenter.Disp= fStr(Cfg.Loc.Adr) + ' ' + fStr(Cfg.Loc.Zip) + ' ' + fStr(Cfg.Loc.City)
.TxtCenter.Disp= 'TaxId: ' + fStr(Cfg.Cmp.TaxId)
.TxtCenter.Disp
br

//- Header
+head(ESR.Head)

//- Itemheader
.Disp
hr
.Lin.Disp
.Dsc Item
.TaxG %
.Amt Amt
.Disp
hr

//- required, do not change
each p in ESR.PosA||[]
div(class=p._)
+pos(p)
+tot(ESR.T)
each p in ESR.PayA||[]
div(class=p._)
+pay(p)
if ESR.TaxA
each t in ESR.TaxA
div(class=t._)
+tax(t)

//- Footer
.Disp
br
+foot(ESR.Foot)
.Disp
hr
br
.TxtCenter= 'Terminal: ' + fStr(ESR.TL) + '/' + fStr(ESR.TT) + ' ' + fStr(ESR.DT || ESR.NF || 'Receipt') + ': ' + fStr(ESR.TN)
.TxtCenter= fD(ESR.D) + ' ' + fTime(ESR.D)
br

Restrictions

The fiscal printer only allows layout of header- and footer lines, as well as item text, but the amounts are formatted by the printer itself.

warning

Although transaction data usually is provided with UTF-8 encoding, not all characters can be printed. E.g. printing of the Euro symbol is not allowed.

Barcode

Not supported in current BETA version.