POS - Cashregister log report
Code snippetName: POS - Cashregister log report
|
This code snippet is intented to implement a simple cashregister log report.
To Menu.Root add new row:
submenu.addPanel("/com/openbravo/images/appointment.png", "Menu.Logi", "/com/openbravo/reports/logi.bs");
Into pos_messages.properties add new row:
Menu.Logi=Cashregister log report
Into roles add new row:
<class name="/com/openbravo/reports/logi.bs"/>
Make new file called logi.bs into reports folder:
report = new com.openbravo.pos.reports.PanelReportBean(); report.setTitleKey("Menu.Logi"); report.setReport("/com/openbravo/reports/logi"); report.setResourceBundle("com/openbravo/reports/logi_messages"); report.setSentence("SELECT " + "TICKETS.TICKETID AS TICKET_NO, " + "RECEIPTS.DATENEW AS TICKET_DATE, " + "PAYMENTS.TOTAL AS MONEY, " + "CUSTOMERS.NAME AS CUSTOMER, " + "PAYMENTS.PAYMENT AS PAYMENT " + "FROM RECEIPTS " + "LEFT JOIN TICKETS ON RECEIPTS.ID = TICKETS.ID " + "LEFT JOIN PAYMENTS ON RECEIPTS.ID = PAYMENTS.RECEIPT " + "LEFT JOIN CUSTOMERS ON TICKETS.CUSTOMER = CUSTOMERS.ID " + "WHERE ?(QBF_FILTER) " + "ORDER BY RECEIPTS.DATENEW"); report.addParameter("RECEIPTS.DATENEW"); report.addParameter("RECEIPTS.DATENEW"); paramdates = new com.openbravo.pos.reports.JParamsDatesInterval(); paramdates.setStartDate(com.openbravo.beans.DateUtils.getToday()); report.addQBFFilter(paramdates); report.addField("TICKET_NO", com.openbravo.data.loader.Datas.STRING); report.addField("TICKET_DATE", com.openbravo.data.loader.Datas.TIMESTAMP); report.addField("MONEY", com.openbravo.data.loader.Datas.DOUBLE); report.addField("CUSTOMER", com.openbravo.data.loader.Datas.STRING); report.addField("PAYMENT", com.openbravo.data.loader.Datas.STRING); return report;
Make new file called logi.jrxml into reports folder:
<?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="logi" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <parameter name="ARG" isForPrompting="false" class="java.lang.Object"/> <queryString><![CDATA[SELECT TICKETS.TICKETID AS TICKET_NO, RECEIPTS.DATENEW AS TICKET_DATE, PAYMENTS.TOTAL AS MONEY, CUSTOMERS.NAME AS CUSTOMER, PAYMENTS.PAYMENT AS PAYMENT FROM RECEIPTS LEFT JOIN TICKETS ON RECEIPTS.ID = TICKETS.ID LEFT JOIN PAYMENTS ON RECEIPTS.ID = PAYMENTS.RECEIPT LEFT JOIN CUSTOMERS ON TICKETS.CUSTOMER = CUSTOMERS.ID ORDER BY TICKETS.TICKETID]]></queryString> <field name="TICKET_NO" class="java.lang.String"/> <field name="TICKET_DATE" class="java.util.Date"/> <field name="MONEY" class="java.lang.Double"/> <field name="CUSTOMER" class="java.lang.String"/> <field name="PAYMENT" class="java.lang.String"/> <variable name="MONEYGTOTAL" class="java.lang.Double" resetType="Report" calculation="Sum"> <variableExpression><![CDATA[$F{MONEY}]]></variableExpression> </variable> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="74" isSplitAllowed="true" > <rectangle radius="5" > <reportElement mode="Opaque" x="0" y="0" width="530" height="36" forecolor="#000000" backcolor="#409617" key="rectangle-1"/> <graphicElement stretchType="NoStretch" fill="Solid" > <pen lineWidth="0.25" lineStyle="Solid"/> </graphicElement> </rectangle> <image scaleImage="Clip" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="390" y="1" width="132" height="34" key="image-1"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <graphicElement stretchType="NoStretch"/> <imageExpression class="java.awt.Image"><![CDATA[com.openbravo.data.loader.ImageUtils.readImageFromResource("/com/openbravo/images/poweredby.png")]]></imageExpression> </image> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Transparent" x="13" y="7" width="375" height="28" forecolor="#FFFFFF" backcolor="#FFFFFF" key="textField-18"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="18" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.title}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="232" y="45" width="147" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-19"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.printed}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="EEEEE dd MMMMM yyyy" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="380" y="45" width="144" height="18" key="textField"/> <box></box> <textElement> <font size="12"/> </textElement> <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="37" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="429" y="9" width="90" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-22"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.payment}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="205" y="9" width="119" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-21"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.customer}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="332" y="9" width="90" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-20"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.sum}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="90" y="9" width="109" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-12"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.date}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="3" y="10" width="82" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-14"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.ticket}]]></textFieldExpression> </textField> <line direction="TopDown"> <reportElement mode="Opaque" x="0" y="25" width="530" height="0" forecolor="#000000" backcolor="#FFFFFF" key="line-4"/> <graphicElement stretchType="NoStretch" fill="Solid" > <pen lineWidth="0.25" lineStyle="Solid"/> </graphicElement> </line> </band> </columnHeader> <detail> <band height="20" isSplitAllowed="true" > <line direction="TopDown"> <reportElement mode="Opaque" x="0" y="15" width="530" height="0" forecolor="#000000" backcolor="#FFFFFF" key="line-2"/> <graphicElement stretchType="NoStretch" fill="Solid" > <pen lineWidth="0.25" lineStyle="Solid"/> </graphicElement> </line> <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="13" y="0" width="72" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{TICKET_NO}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="90" y="0" width="109" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[com.openbravo.format.Formats.TIMESTAMP.formatValue($F{TICKET_DATE})]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="¤ #,##0.00" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="332" y="0" width="90" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.Double"><![CDATA[$F{MONEY} == null ? Double.valueOf(0) : $F{MONEY}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="205" y="0" width="119" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{CUSTOMER}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="429" y="0" width="90" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[str("transpayment." + (String)field_PAYMENT.getValue())]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="50" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="422" y="20" width="40" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-16"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> </box> <textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="482" y="20" width="40" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-17"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Opaque" x="462" y="20" width="20" height="20" forecolor="#000000" backcolor="#FFFFFF" key="staticText-7"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> </box> <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <text><![CDATA[/]]></text> </staticText> <line direction="TopDown"> <reportElement mode="Opaque" x="3" y="10" width="530" height="0" forecolor="#000000" backcolor="#FFFFFF" key="line-5"/> <graphicElement stretchType="NoStretch" fill="Solid" > <pen lineWidth="0.25" lineStyle="Solid"/> </graphicElement> </line> </band> </pageFooter> <summary> <band height="60" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="¤ #,##0.00" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="332" y="5" width="100" height="18" key="textField"/> <box></box> <textElement> <font pdfFontName="Helvetica-Bold" size="12" isBold="true"/> </textElement> <textFieldExpression class="java.lang.Double"><![CDATA[$V{MONEYGTOTAL}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Opaque" x="239" y="5" width="90" height="18" forecolor="#000000" backcolor="#FFFFFF" key="textField-23"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Dialog" pdfFontName="Helvetica" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$R{label.total}]]></textFieldExpression> </textField> </band> </summary> </jasperReport>
Make new file called logi_messages.properties into reports folder:
# Openbravo POS is a point of sales application designed for touch screens. # Copyright (C) 2007-2008 Openbravo, S.L.U. # http://sourceforge.net/projects/openbravopos # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA label.title=Cashregister log label.noreference= label.noproduct=(no sales) label.printed=Printed: label.date=Date label.ticket=Ticket no label.sum=Sum label.customer=Customer label.payment=Payment label.total=Grand Total transpayment.cash=Cash transpayment.magcard=Card transpayment.cashrefund=Refund transpayment.magcardrefund=Card refund transpayment.cheque=Cheque transpayment.chequerefund=Cheque refund transpayment.cashin=(in) Cash transpayment.cashout=(out) Cash transpayment.free=Free transpayment.ticket=Ticket transpayment.paperin=Note input transpayment.paperout=Note output transpayment.debt=Debt transpayment.debtpaid=Debt paid
Save changes and restart the application.