<?xml version="1.0" encoding="UTF-8"?>
<!-- 
    uniCenta oPOS - Touch friendly Point Of Sale
    Copyright (c) 2009-2018 uniCenta.
    http://sourceforge.net/projects/unicentaopos

    This file is part of uniCenta oPOS.

    uniCenta oPOS is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    uniCenta oPOS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with uniCenta oPOS.  If not, see <http://www.gnu.org/licenses/>.
 -->

<output>

    <display>
        <line><text align="left" length="8">Total</text><text align="right" length="12">${ticket.printTotal()}</text></line>
        <line><text align="center" length="20">Thank you</text></line>
    </display>

    <ticket>
        <image>Printer.Ticket.Logo</image>
        <line></line>
        #if (${ticket.printTicketHeaderLine1()} != "")
            <line><text align="center" length="42">${ticket.printTicketHeaderLine1()}</text></line>
        #end
        #if (${ticket.printTicketHeaderLine2()} != "")
            <line><text align="center" length="42">${ticket.printTicketHeaderLine2()}</text></line>
        #end
        #if (${ticket.printTicketHeaderLine3()} != "")
            <line><text align="center" length="42">${ticket.printTicketHeaderLine3()}</text></line>
        #end
        #if (${ticket.printTicketHeaderLine4()} != "")
            <line><text align="center" length="42">${ticket.printTicketHeaderLine4()}</text></line>
        #end
        #if (${ticket.printTicketHeaderLine5()} != "")
            <line><text align="center" length="42">${ticket.printTicketHeaderLine5()}</text></line>
        #end
        #if (${ticket.printTicketHeaderLine6()} != "")
            <line><text align="center" length="42">${ticket.printTicketHeaderLine6()}</text></line>
        #end

        <line><text align="center" length="42">Printer.TicketPreview</text></line>
        <line></line>        
        #if (${ticket.ticketType} == 0)
            <line><text align="left" length="15">Receipt:</text><text>${ticket.printId()}</text></line>
        #end
        #if (${ticket.ticketType} == 1)
            <line><text align="left" length="15">Refund:</text><text>${ticket.printId()}</text></line>
        #end
	
        <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line>
        <line><text align="left" length="15">Terminal: </text><text>${ticket.getHost()}</text></line> 
        <line><text align="left" length="15">Served by:</text><text>${ticket.printUser()}</text></line>

        #if ($ticket.getCustomer())
            <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line>
            <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().printName()}</text></line>
            <line><text align="left" length="15">Address:</text><text>${ticket.getCustomer().printAddress()}</text></line>
            <line><text align="left" length="15">Postal:</text><text>${ticket.getCustomer().printPostal()}</text></line>
            <line><text align="left" length="15">Phone:</text><text>${ticket.getCustomer().printPhone1()}</text></line>
            <line><text align="left" length="15">Current Debt:</text><text>${ticket.getCustomer().printCurDebt()}</text></line>
            <line><text align="left" length="15">Balance:</text><text>${ticket.getCustomer().printCurBal()}</text></line>            
        #end     

        #if (${tickettext.place} != ${place})
            <line><text align="left" length="15">Table:</text><text>${place}</text></line>
	#end
	<line></line>
        <line>
            <text align ="left" length="17">Item</text>
            <text align ="right" length="8">Price</text>
            <text align ="right" length="7">Qty</text>
            <text align ="right" length="10">Value</text>
        </line>
        <line><text align="left" length="42">------------------------------------------</text></line>
    
        #foreach ($ticketline in $ticket.getLines())
        <line>
            #if ($ticketline.isProductCom())
                <text align ="left" length="17">*${ticketline.printName()}</text>
            #else
                <text align ="left" length="17">${ticketline.printName()}</text>
            #end
<!-- Print line to show Prices pre-Tax
            <text align ="right" length="8">${ticketline.printPrice()}</text>
            <text align ="right" length="7">x${ticketline.printMultiply()}</text>
            <text align ="right" length="8">${ticketline.printSubValue()}</text>
         </line>
-->

<!-- Print line to show Prices inc. Tax -->
            <text align ="right" length="8">${ticketline.printPriceTax()}</text>
            <text align ="right" length="7">x${ticketline.printMultiply()}</text>
            <text align ="right" length="10">${ticketline.printValue()}</text>
         </line>
        
<!-- un-comment line below if you want to add a product's properties -->
            <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> -->

<!-- un-comment line below if you want to add a user input sales line's Note -->
            <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> 
 
<!-- un-comment line below if you want to add a product's barcode -->
        <!-- <line><text align ="left" length="12">Barcode :   </text>${ticketline.printCode()}</text></line> -->
        
<!-- un-comment line below if you want to add a product's Reference -->
        <!-- <line><text align ="left" length="12">Reference : </text>${ticketline.printReference()}</text></line> -->
            
            #if ($ticketline.productAttSetInstId)
                <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line>
            #end
        #end

        <line><text align="left" length="42">------------------------------------------</text></line>
        <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line>
        <line></line>
        <line>
            <text align ="left" bold="true" length="16">Subtotal</text>
            <text align ="right" length="26">${ticket.printSubTotal()}</text>
        </line>
        <line>
            <text align ="left" length="16">Tax</text>
            <text align ="right" length="26">${ticket.printTax()}</text>
        </line>
        <line></line>
        <line size="1">
            <text align ="left" length="16" bold="true">Balance Due</text>
            <text align ="right" length="26" bold="true">${ticket.printTotal()}</text>
        </line>
        <line></line>



        #foreach ($paymentline in $ticket.payments)
            #if ($paymentline.name == "cash")
                <line><text bold="true">Cash</text></line>
                <line><text align="left" length="22">Tendered:</text><text align ="right" length="20">${paymentline.printPaid()}</text></line>
                <line><text align="left" length="22">Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line>
            #end
          	
            #if ($paymentline.name == "cashrefund")
                <line><text align="left" length="22" bold="true">Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line>
            #end
            #if ($paymentline.name == "cheque")
                <line><text align="left" length="22" bold="true">Cheque</text><text align ="right" length="20">${paymentline.printTotal()}</text></line>
            #end
            #if ($paymentline.name == "chequerefund")
                <line><text align="left" length="22" bold="true">Cheque Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line>
            #end
            #if ($paymentline.name == "voucherin")
                <line><text align="left" length="22" bold="true">Voucher</text><text align ="right" length="20">${paymentline.printPaid()}</text></line>
            #end
            #if ($paymentline.name == "voucherout")
                <line><text align="left" length="22" bold="true">Voucher Refund<text align ="right" length="20">${paymentline.printPaid()}</text></line>
            #end
            #if ($paymentline.name == "slip")
                <line><text align="left" length="22" bold="true">Slip</text><text align ="right" length="20">${paymentline.printTotal()}</text></line>
            #end
            #if ($paymentline.name == "free")
                <line><text align="left" length="22" bold="true">Free</text><text align ="right" length="20">${paymentline.printTotal()}</text></line>
            #end
            #if ($paymentline.name == "debt")
                <line><text align="left" length="22" bold="true">On Account</text><text align ="right" length="20">${paymentline.printTotal()}</text></line>
            #end
        #end

        #if (${ticket.printTicketFooterLine1()} != "")
            <line></line>
            <line><text align="center" length="42">${ticket.printTicketFooterLine1()}</text></line>  
            <line><text>==========================================</text></line>
        #end
        #if (${ticket.printTicketFooterLine2()} != "")
            <line><text>${ticket.printTicketFooterLine2()}</text></line>
        #end
        #if (${ticket.printTicketFooterLine3()} != "")
            <line><text>${ticket.printTicketFooterLine3()}</text></line>
        #end
        #if (${ticket.printTicketFooterLine4()} != "")
            <line><text>${ticket.printTicketFooterLine4()}</text></line>
        #end
        #if (${ticket.printTicketFooterLine5()} != "")
            <line><text>${ticket.printTicketFooterLine5()}</text></line>
        #end
        #if (${ticket.printTicketFooterLine6()} != "")
            <line><text>${ticket.printTicketFooterLine6()}</text></line>
        #end
        <line></line>

        #foreach ($paymentline in $ticket.payments)
            #if ($paymentline.name == "ccard")
                #if ($paymentline.chipAndPin)
                    <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line>
                    <line><text align = "center" length="42" bold="true">A card payment was received</text></line>
                    <line></line>
                    <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line>
                #end
                #if (!$paymentline.chipAndPin)
                    <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line>
                    <line><text align = "center" length="42" bold="true">A card payment was received</text></line>
                    <line></line>
                    <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line>
                #end
                    #if ($ticket.hasTip())
                    <line><text align ="left" length="16">Tip:</text><text align ="right" length="26">_______________</text></line>
                    <line></line>
                    <line size="1"><text align ="left" length="16" bold="false">Total</text><text align ="right" length="26" bold="false">_______________</text></line>
                    <line></line>
                    <line></line>
                    <line size="1"><text align ="left" length="42" bold="false">__________________________________________</text></line>
                    <line size="1"><text align ="center" length="42" bold="false">Signature</text></line>
                #else
                    <line size="1"><text align ="left" length="16" bold="true">Total</text><text align ="right" length="26" bold="true">${paymentline.printTotal()}</text></line>
                #end            
            #end
            #if ($paymentline.name == "ccardrefund")
                    <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line>
                    <line></line>
                    <line><text align = "center" length="42" bold="true">A card payment was received</text></line>
                    <line></line>
                    <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line>          
            #end
        #end

    </ticket>

#foreach ($paymentline in $ticket.payments)
    #if ($paymentline.name == "cash")
        <opendrawer/>
    #end
    #if ($paymentline.name == "cashrefund")
        <opendrawer/>
    #end
#end

</output>