public class TicketFormatter extends Object
ticket)
, which makes the methods available in the following
velocity templates:
Modifier and Type | Field and Description |
---|---|
protected org.apache.log4j.Logger |
contentLogger |
Constructor and Description |
---|
TicketFormatter(Ticket ticket)
Create a formatter object for a ticket.
|
Modifier and Type | Method and Description |
---|---|
int |
calculateItemCount()
Get the total of items for a ticket.
|
String |
getCompanyData(String element)
Retrieve elements from the CompanyData.xml ressource.
|
CustomerFormatter |
getCustomer()
When tickets are printed from an environment which does not supply the
$customer variable this method can be used to get the CustomerFormatter
for this ticket.
|
Double |
getDiscount()
Calculate the discount amount for the ticket.
|
Integer |
getGuests()
Retrieve the number of guests which is assigned when a ticket is created.
|
String |
getHost() |
List<KitchenLineFormatter> |
getKitchenLines()
Get a list of kitchen line formatters.
|
List<TicketLineFormatter> |
getLines()
Get a list of formatters for the tickets lines.
|
Integer |
getNumber()
Retrieve the ticket number which is assigned when a ticket is closed.
|
List<PaymentFormatter> |
getPayments()
Get a list of formatters for the tickets payments.
|
String |
getPlace()
Print the name of the place the ticket is assigned to (xml escaped string).
|
String |
getSignature()
Print the signature string of the ticket as XML escaped string.
|
SignatureFormatter |
getSignatureFormatter()
Get a SignatureFormatter which will provide methods to retrieve
signature information according to country specific fiscal regulations -
Find the formatters layout in SignatureFormatter<country-code>.
|
Double |
getSubTotalByTax(TaxFormatter taxFormatter)
Get the total taxable base (=nat value) for the tax represented by the tax formatter object.
|
List<TaxFormatter> |
getTaxes()
Each ticketline is associated with one or more (if combined taxes are
used) taxes.
|
Double |
getTaxSum(TaxFormatter taxFormatter)
Get the total tax for the tax represented by the tax formatter object.
|
String |
getTaxTotal(TaxFormatter taxFormatter)
Deprecated.
Use printTaxSum instead.
|
double |
getTotal()
Calculate the total amount for the ticket.
|
Double |
getTotalByTax(TaxFormatter taxFormatter)
Get the total taxable (= gross value) for the tax represented by the tax formatter object.
|
UserFormatter |
getUser()
Get the formatter object for the user assigned to the ticket.
|
Integer |
getVisibleId()
Retrieve the tickets visibleId which is assigned when a ticket is created.
|
boolean |
hasStatus(int status)
Check if the status matches the given status mask.
|
boolean |
isCancelled()
Deprecated.
Use isVoided() instead.
|
boolean |
isTraining()
Check if the ticket is a training ticket.
|
boolean |
isVoided()
Check if the ticket is voided.
|
boolean |
isVoiding()
Check if the ticket is a voiding ticket.
|
void |
logTicket()
logTicket() shall report ticket data like dateClose, user, place, ...
|
String |
printComment()
Print the tickets comment entry.
|
String |
printCurrentDate(String pattern)
Prints the current date formatted according to the given pattern.
|
String |
printDateClose(String pattern)
Print the tickets closing date.
|
String |
printDateClose(String pattern,
String language)
Print the tickets closing date.
|
String |
printDateClose(String pattern,
String language,
String country)
Print the tickets closing date.
|
String |
printDateClose(String pattern,
String language,
String country,
String variant)
Print the tickets closing date.
|
String |
printDiscount()
Print the currency formatted discount granted for the ticket
|
String |
printDiscountPercent()
Print the discount percentage granted for the line total
|
String |
printHost()
Print the hostname like defined in config
|
String |
printPlace()
Print the name of the place the ticket is assigned to.
|
String |
printReceiptClose()
Deprecated.
Use printDateClose instead
|
String |
printReference()
Print the visibleId of the referenced ticket, if any.
|
String |
printsDiscount()
Print the discount granted for the ticket
|
String |
printSignature()
Print the signature string of the ticket which shall be contained in
the QR-code printed on the ticket amd as described in the BDI documents.
|
String |
printSignatureCounter()
Return the signature counter from the QR code as string
|
String |
printSignatureValue()
Print the signature as returned by the TSE.
|
String |
printsSubTotal()
Calculate the subtotal for the ticket which is the net amount w/o taxes.
|
String |
printsSubTotalByTax(TaxFormatter taxFormatter)
Calculate the subtotal for the ticketlines matching the given tax.
|
String |
printsTaxes()
Calculate the tax total for the ticket.
|
String |
printsTaxSum(TaxFormatter taxFormatter)
Print the total for the tax represented by the tax formatter object.
|
String |
printsTotal()
Calculate the total amount for the ticket.
|
String |
printsTotalByTax(TaxFormatter taxFormatter)
Calculate the subtotal for the ticket which is the net amount w/o taxes.
|
String |
printSubTotal()
Calculate the subtotal for the ticket which is the net amount w/o taxes.
|
String |
printSubTotalByTax(TaxFormatter taxFormatter)
Calculate the subtotal for the ticketlines matching the given tax.
|
String |
printTaxes()
Calculate the tax total for the ticket.
|
String |
printTaxSum(TaxFormatter taxFormatter)
Print the total for the tax represented by the tax formatter object.
|
String |
printTotal()
Calculate the total amount for the ticket.
|
String |
printTotalByTax(TaxFormatter taxFormatter)
Calculate the subtotal for the ticket which is the net amount w/o taxes.
|
String |
printTransactionEnd()
Print the start date of the transaction
|
String |
printTransactionNumber()
Print the transaction number as String if the transaction has finshed or
an error message otherwise.
|
String |
printTransactionStart()
Print the start date of the transaction - shall only be used for Gastro
and is actually the creation date of a place ticket
|
String |
printVoidingReference() |
void |
refreshCompanyData()
Reread the company data resource.
|
List<String> |
splitStringToLines(String sOldLine,
int iMaxLen)
Split a string in lines, length of lines defined with parameter iMaxLen.
|
public TicketFormatter(Ticket ticket)
ticket
- public String printTaxes()
public String printsTaxes()
public String printTotal()
public String printsTotal()
public double getTotal()
public String printSubTotal()
public String printsSubTotal()
public String printSubTotalByTax(TaxFormatter taxFormatter)
taxFormatter
- a tax formatter object. A list of taxes can be retrieved
getTaxes().public String printTotalByTax(TaxFormatter taxFormatter)
taxFormatter
- taxFormatter a tax formatter object. A list of taxes can be retrieved
getTaxes().public String printsSubTotalByTax(TaxFormatter taxFormatter)
taxFormatter
- taxFormatter a tax formatter object. A list of taxes can be retrieved
getTaxes().public String printsTotalByTax(TaxFormatter taxFormatter)
taxFormatter
- taxFormatter a tax formatter object. A list of taxes can be retrieved
getTaxes().public String printReceiptClose()
public String printDateClose(String pattern)
pattern
- a simple date format patternpublic String printDateClose(String pattern, String language)
pattern
- a simple date format patternlanguage
- the language code to be used for Localepublic String printDateClose(String pattern, String language, String country)
pattern
- a simple date format patternlanguage
- the language code to be used for Localecountry
- the country code to be used for Localepublic String printDateClose(String pattern, String language, String country, String variant)
pattern
- a simple date format patternvariant
- the variant code to be used for Localecountry
- the country code to be used for Localelanguage
- the language code to be used for Localepublic Integer getNumber()
public Integer getGuests()
public Integer getVisibleId()
public UserFormatter getUser()
public String printComment()
public String printVoidingReference()
public List<TicketLineFormatter> getLines()
public List<KitchenLineFormatter> getKitchenLines()
public int calculateItemCount()
public List<PaymentFormatter> getPayments()
public List<TaxFormatter> getTaxes()
public String getTaxTotal(TaxFormatter taxFormatter)
taxFormatter
- public String printTaxSum(TaxFormatter taxFormatter)
taxFormatter
- public String printsTaxSum(TaxFormatter taxFormatter)
taxFormatter
- public Double getTaxSum(TaxFormatter taxFormatter)
taxFormatter
- public Double getTotalByTax(TaxFormatter taxFormatter)
taxFormatter
- public Double getSubTotalByTax(TaxFormatter taxFormatter)
taxFormatter
- public boolean isCancelled()
public boolean isVoided()
public boolean isVoiding()
public boolean isTraining()
public String printReference()
public boolean hasStatus(int status)
status
- public String printHost()
public String getHost()
public String getCompanyData(String element)
element
- public void refreshCompanyData()
public String getPlace()
public String printPlace()
public String printSignature()
public String printSignatureValue()
public String printSignatureCounter()
public String printTransactionStart()
public String printTransactionEnd()
public String getSignature()
public SignatureFormatter getSignatureFormatter()
public CustomerFormatter getCustomer()
public String printCurrentDate(String pattern)
pattern
- a SimpleDateFormat string. If null, a TIMESTAMP is used.public List<String> splitStringToLines(String sOldLine, int iMaxLen)
#foreach ($ufline in $ticket.splitStringToLines($!{customer.getUser_field_1()},45)) <line> <text>$ufline</text> </line> #endHint: Some printers like the EPSON TM-T88 series can print over multiple lines. Just omit the lenght= atrribute in the line tag. align= will not work if no length is given and line break will not regard white spaces. Using the spliStringToLines method can give you more control.
sOldLine
- - String to splitiMaxLen
- - Maximum line length, default = 80public void logTicket()
public Double getDiscount()
public String printDiscount()
public String printsDiscount()
public String printDiscountPercent()
public String printTransactionNumber()
Copyright © 2021. All rights reserved.