5.3.1 release (#36)
* UOCL-265: Spanish translation improvements * UOCL-246: Reprint receipt fix * UOCL-246: Reprint receipt fix * UOCL-246: reprint receipt * UOCL-283: Porting ZATCA QR-code! * UOCL-283: Porting ZATCA QR-code! * UOCL-246: reprint receipt * UOCL-274: Top 10 sales rpt fix * UOCL-274: Top 10 sales rpt fix * 5.3.1 release
This commit is contained in:
@@ -228,7 +228,7 @@ public class AppConfig implements AppProperties {
|
||||
|
||||
}
|
||||
|
||||
private void refreshProperties() {
|
||||
private void pullLatestProperties() {
|
||||
try {
|
||||
InputStream in = new FileInputStream(configfile);
|
||||
if (in != null) {
|
||||
@@ -252,9 +252,11 @@ public class AppConfig implements AppProperties {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveWithExistingProperties() throws IOException {
|
||||
public void setLastTicket(String lastTicketNumber, String lastTicketType) throws IOException {
|
||||
|
||||
refreshProperties();
|
||||
pullLatestProperties();
|
||||
properties.setProperty("lastticket.number", lastTicketNumber);
|
||||
properties.setProperty("lastticket.type", lastTicketType);
|
||||
|
||||
OutputStream out = new FileOutputStream(configfile);
|
||||
if (out != null) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AppLocal {
|
||||
|
||||
public static final String APP_NAME = "uniCenta oPOS";
|
||||
public static final String APP_ID = "unicentaopos";
|
||||
public static final String APP_VERSION = "5.3";
|
||||
public static final String APP_VERSION = "5.3.1";
|
||||
|
||||
private static final LocaleResources m_resources;
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ import javax.imageio.ImageIO;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import com.unicenta.pos.util.QRCode;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
@@ -49,52 +51,52 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class TicketParser extends DefaultHandler {
|
||||
|
||||
|
||||
private static SAXParser m_sp = null;
|
||||
|
||||
|
||||
private DeviceTicket m_printer;
|
||||
private DataLogicSystem m_system;
|
||||
|
||||
|
||||
private StringBuilder text;
|
||||
|
||||
|
||||
private String bctype;
|
||||
private String bcposition;
|
||||
private int m_iTextAlign;
|
||||
private int m_iTextLength;
|
||||
private int m_iTextStyle;
|
||||
private int size;
|
||||
|
||||
|
||||
private StringBuilder m_sVisorLine;
|
||||
private int m_iVisorAnimation;
|
||||
private String m_sVisorLine1;
|
||||
private String m_sVisorLine2;
|
||||
|
||||
|
||||
private double m_dValue1;
|
||||
private double m_dValue2;
|
||||
private int attribute3;
|
||||
|
||||
|
||||
private int m_iOutputType;
|
||||
private static final int OUTPUT_NONE = 0;
|
||||
private static final int OUTPUT_DISPLAY = 1;
|
||||
private static final int OUTPUT_TICKET = 2;
|
||||
private static final int OUTPUT_FISCAL = 3;
|
||||
private DevicePrinter m_oOutputPrinter;
|
||||
private DevicePrinter m_oOutputPrinter;
|
||||
private DateFormat df= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
private Date today;
|
||||
private String cUser;
|
||||
private String ticketId;
|
||||
private String pickupId;
|
||||
|
||||
|
||||
|
||||
|
||||
/** Creates a new instance of TicketParser
|
||||
* @param printer
|
||||
* @param system */
|
||||
public TicketParser(DeviceTicket printer, DataLogicSystem system) {
|
||||
m_printer = printer;
|
||||
m_system = system;
|
||||
today = Calendar.getInstance().getTime();
|
||||
today = Calendar.getInstance().getTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sIn
|
||||
@@ -103,27 +105,27 @@ public class TicketParser extends DefaultHandler {
|
||||
*/
|
||||
public void printTicket(String sIn, TicketInfo ticket) throws TicketPrinterException {
|
||||
// cUser=ticket.getUser().getName();
|
||||
cUser=ticket.getName();
|
||||
ticketId=Integer.toString(ticket.getTicketId());
|
||||
cUser=ticket.getName();
|
||||
ticketId=Integer.toString(ticket.getTicketId());
|
||||
pickupId=Integer.toString(ticket.getPickupId());
|
||||
|
||||
|
||||
if (ticket.getTicketId()==0){
|
||||
ticketId="No Sale";
|
||||
}
|
||||
if (ticket.getPickupId()==0){
|
||||
pickupId="No PickupId";
|
||||
}
|
||||
}
|
||||
printTicket(new StringReader(sIn));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sIn
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public void printTicket(String sIn) throws TicketPrinterException {
|
||||
public void printTicket(String sIn) throws TicketPrinterException {
|
||||
printTicket(new StringReader(sIn));
|
||||
}
|
||||
|
||||
@@ -133,15 +135,15 @@ public class TicketParser extends DefaultHandler {
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public void printTicket(Reader in) throws TicketPrinterException {
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if (m_sp == null) {
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
m_sp = spf.newSAXParser();
|
||||
}
|
||||
m_sp.parse(new InputSource(in), this);
|
||||
|
||||
|
||||
} catch (ParserConfigurationException ePC) {
|
||||
throw new TicketPrinterException(LocalRes.getIntString("exception.parserconfig") , ePC);
|
||||
} catch (SAXException eSAX) {
|
||||
@@ -149,8 +151,8 @@ public class TicketParser extends DefaultHandler {
|
||||
} catch (IOException eIO) {
|
||||
throw new TicketPrinterException(LocalRes.getIntString("exception.iofile") , eIO);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDocument() throws SAXException {
|
||||
// inicalizo las variables pertinentes
|
||||
@@ -168,293 +170,300 @@ public class TicketParser extends DefaultHandler {
|
||||
@Override
|
||||
public void endDocument() throws SAXException {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException{
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException{
|
||||
String openDate = df.format(today);
|
||||
Date dNow = new Date();
|
||||
|
||||
|
||||
switch (m_iOutputType) {
|
||||
case OUTPUT_NONE:
|
||||
switch (qName) {
|
||||
case "opendrawer":
|
||||
m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1")).openDrawer();
|
||||
// Cashdrawer has been activated record the data in the table
|
||||
try {
|
||||
m_system.execDrawerOpened(
|
||||
//new Object[] {df.format(dNow),cUser,ticketId});
|
||||
new Object[] {cUser,ticketId});
|
||||
} catch (BasicException ex) {}
|
||||
break;
|
||||
case "play":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "ticket":
|
||||
m_iOutputType = OUTPUT_TICKET;
|
||||
m_oOutputPrinter = m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1"));
|
||||
m_oOutputPrinter.beginReceipt();
|
||||
break;
|
||||
case "display":
|
||||
m_iOutputType = OUTPUT_DISPLAY;
|
||||
String animation = attributes.getValue("animation");
|
||||
if ("scroll".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_SCROLL;
|
||||
} else if ("flyer".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_FLYER;
|
||||
} else if ("blink".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_BLINK;
|
||||
} else if ("curtain".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_CURTAIN;
|
||||
} else { // "none"
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
}
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_oOutputPrinter = null;
|
||||
break;
|
||||
case "fiscalreceipt":
|
||||
m_iOutputType = OUTPUT_FISCAL;
|
||||
m_printer.getFiscalPrinter().beginReceipt();
|
||||
break;
|
||||
case "fiscalzreport":
|
||||
m_printer.getFiscalPrinter().printZReport();
|
||||
break;
|
||||
case "fiscalxreport":
|
||||
m_printer.getFiscalPrinter().printXReport();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_TICKET:
|
||||
if (null != qName)switch (qName) {
|
||||
case "logo":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "image":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "barcode":
|
||||
text = new StringBuilder();
|
||||
bctype = attributes.getValue("type");
|
||||
bcposition = attributes.getValue("position");
|
||||
break;
|
||||
case "line":
|
||||
m_oOutputPrinter.beginLine(parseInt(attributes.getValue("size"), DevicePrinter.SIZE_0));
|
||||
break;
|
||||
case "text":
|
||||
text = new StringBuilder();
|
||||
m_iTextStyle = ("true".equals(attributes.getValue("bold"))
|
||||
? DevicePrinter.STYLE_BOLD : DevicePrinter.STYLE_PLAIN)
|
||||
| ("true".equals(attributes.getValue("underline"))
|
||||
? DevicePrinter.STYLE_UNDERLINE : DevicePrinter.STYLE_PLAIN);
|
||||
String sAlign = attributes.getValue("align");
|
||||
if (null == sAlign) {
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
} else switch (sAlign) {
|
||||
case "right":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_RIGHT;
|
||||
break;
|
||||
case "center":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_CENTER;
|
||||
break;
|
||||
default:
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
m_iTextLength = parseInt(attributes.getValue("length"), 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_DISPLAY:
|
||||
if (null != qName) switch (qName) {
|
||||
case "line":
|
||||
// line 1 or 2 of the display
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "line1":
|
||||
// linea 1 del visor
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "line2":
|
||||
// linea 2 del visor
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "text":
|
||||
text = new StringBuilder();
|
||||
String sAlign = attributes.getValue("align");
|
||||
if (null == sAlign) {
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
} else switch (sAlign) {
|
||||
case "right":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_RIGHT;
|
||||
break;
|
||||
case "center":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_CENTER;
|
||||
break;
|
||||
default:
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
m_iTextLength = parseInt(attributes.getValue("length"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_FISCAL:
|
||||
if (null != qName)
|
||||
case OUTPUT_NONE:
|
||||
switch (qName) {
|
||||
case "line":
|
||||
text = new StringBuilder();
|
||||
m_dValue1 = parseDouble(attributes.getValue("price"));
|
||||
m_dValue2 = parseDouble(attributes.getValue("units"), 1.0);
|
||||
attribute3 = parseInt(attributes.getValue("tax"));
|
||||
break;
|
||||
case "message":
|
||||
case "opendrawer":
|
||||
m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1")).openDrawer();
|
||||
// Cashdrawer has been activated record the data in the table
|
||||
try {
|
||||
m_system.execDrawerOpened(
|
||||
//new Object[] {df.format(dNow),cUser,ticketId});
|
||||
new Object[] {cUser,ticketId});
|
||||
} catch (BasicException ex) {}
|
||||
break;
|
||||
case "play":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "total":
|
||||
case "ticket":
|
||||
m_iOutputType = OUTPUT_TICKET;
|
||||
m_oOutputPrinter = m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1"));
|
||||
m_oOutputPrinter.beginReceipt();
|
||||
break;
|
||||
case "display":
|
||||
m_iOutputType = OUTPUT_DISPLAY;
|
||||
String animation = attributes.getValue("animation");
|
||||
if ("scroll".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_SCROLL;
|
||||
} else if ("flyer".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_FLYER;
|
||||
} else if ("blink".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_BLINK;
|
||||
} else if ("curtain".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_CURTAIN;
|
||||
} else { // "none"
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
}
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_oOutputPrinter = null;
|
||||
break;
|
||||
case "fiscalreceipt":
|
||||
m_iOutputType = OUTPUT_FISCAL;
|
||||
m_printer.getFiscalPrinter().beginReceipt();
|
||||
break;
|
||||
case "fiscalzreport":
|
||||
m_printer.getFiscalPrinter().printZReport();
|
||||
break;
|
||||
case "fiscalxreport":
|
||||
m_printer.getFiscalPrinter().printXReport();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_TICKET:
|
||||
if (null != qName)switch (qName) {
|
||||
case "logo":
|
||||
text = new StringBuilder();
|
||||
m_dValue1 = parseDouble(attributes.getValue("paid"));
|
||||
break;
|
||||
case "image":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "barcode":
|
||||
text = new StringBuilder();
|
||||
bctype = attributes.getValue("type");
|
||||
bcposition = attributes.getValue("position");
|
||||
break;
|
||||
case "qr-code":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "line":
|
||||
m_oOutputPrinter.beginLine(parseInt(attributes.getValue("size"), DevicePrinter.SIZE_0));
|
||||
break;
|
||||
case "text":
|
||||
text = new StringBuilder();
|
||||
m_iTextStyle = ("true".equals(attributes.getValue("bold"))
|
||||
? DevicePrinter.STYLE_BOLD : DevicePrinter.STYLE_PLAIN)
|
||||
| ("true".equals(attributes.getValue("underline"))
|
||||
? DevicePrinter.STYLE_UNDERLINE : DevicePrinter.STYLE_PLAIN);
|
||||
String sAlign = attributes.getValue("align");
|
||||
if (null == sAlign) {
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
} else switch (sAlign) {
|
||||
case "right":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_RIGHT;
|
||||
break;
|
||||
case "center":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_CENTER;
|
||||
break;
|
||||
default:
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
m_iTextLength = parseInt(attributes.getValue("length"), 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case OUTPUT_DISPLAY:
|
||||
if (null != qName) switch (qName) {
|
||||
case "line":
|
||||
// line 1 or 2 of the display
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "line1":
|
||||
// linea 1 del visor
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "line2":
|
||||
// linea 2 del visor
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "text":
|
||||
text = new StringBuilder();
|
||||
String sAlign = attributes.getValue("align");
|
||||
if (null == sAlign) {
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
} else switch (sAlign) {
|
||||
case "right":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_RIGHT;
|
||||
break;
|
||||
case "center":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_CENTER;
|
||||
break;
|
||||
default:
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
m_iTextLength = parseInt(attributes.getValue("length"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_FISCAL:
|
||||
if (null != qName)
|
||||
switch (qName) {
|
||||
case "line":
|
||||
text = new StringBuilder();
|
||||
m_dValue1 = parseDouble(attributes.getValue("price"));
|
||||
m_dValue2 = parseDouble(attributes.getValue("units"), 1.0);
|
||||
attribute3 = parseInt(attributes.getValue("tax"));
|
||||
break;
|
||||
case "message":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "total":
|
||||
text = new StringBuilder();
|
||||
m_dValue1 = parseDouble(attributes.getValue("paid"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
|
||||
switch (m_iOutputType) {
|
||||
case OUTPUT_NONE:
|
||||
if ("play".equals(qName)) {
|
||||
try {
|
||||
AudioClip oAudio = Applet.newAudioClip(getClass().getClassLoader().getResource(text.toString()));
|
||||
oAudio.play();
|
||||
} catch (Exception fnfe) {
|
||||
//throw new ResourceNotFoundException( fnfe.getMessage() );
|
||||
case OUTPUT_NONE:
|
||||
if ("play".equals(qName)) {
|
||||
try {
|
||||
AudioClip oAudio = Applet.newAudioClip(getClass().getClassLoader().getResource(text.toString()));
|
||||
oAudio.play();
|
||||
} catch (Exception fnfe) {
|
||||
//throw new ResourceNotFoundException( fnfe.getMessage() );
|
||||
}
|
||||
text = null;
|
||||
}
|
||||
text = null;
|
||||
}
|
||||
break;
|
||||
|
||||
// Added 23.05.13 used by star TSP700 to print stored logo image JDL
|
||||
case OUTPUT_TICKET:
|
||||
if ("logo".equals(qName)){
|
||||
m_oOutputPrinter.printLogo();
|
||||
// }
|
||||
}else if ("image".equals(qName)){
|
||||
try {
|
||||
// BufferedImage image = ImageIO.read(getClass().getClassLoader().getResourceAsStream(text.toString()));
|
||||
BufferedImage image = m_system.getResourceAsImage(text.toString());
|
||||
break;
|
||||
|
||||
if (image == null) {
|
||||
image = decodeToImage(text.toString());
|
||||
}
|
||||
if (image != null) {
|
||||
m_oOutputPrinter.printImage(image);
|
||||
}
|
||||
|
||||
} catch (Exception fnfe) {
|
||||
//throw new ResourceNotFoundException( fnfe.getMessage() );
|
||||
// Added 23.05.13 used by star TSP700 to print stored logo image JDL
|
||||
case OUTPUT_TICKET:
|
||||
if ("logo".equals(qName)){
|
||||
m_oOutputPrinter.printLogo();
|
||||
// }
|
||||
}
|
||||
text = null;
|
||||
} else if ("barcode".equals(qName)) {
|
||||
m_oOutputPrinter.printBarCode(bctype, bcposition, text.toString());
|
||||
text = null;
|
||||
} else if ("text".equals(qName)) {
|
||||
if (m_iTextLength > 0) {
|
||||
switch(m_iTextAlign) {
|
||||
case DevicePrinter.ALIGN_RIGHT:
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignRight(text.toString(), m_iTextLength));
|
||||
break;
|
||||
case DevicePrinter.ALIGN_CENTER:
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignCenter(text.toString(), m_iTextLength));
|
||||
break;
|
||||
default: // DevicePrinter.ALIGN_LEFT
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignLeft(text.toString(), m_iTextLength));
|
||||
break;
|
||||
if ("image".equals(qName)){
|
||||
try {
|
||||
// BufferedImage image = ImageIO.read(getClass().getClassLoader().getResourceAsStream(text.toString()));
|
||||
BufferedImage image = m_system.getResourceAsImage(text.toString());
|
||||
|
||||
if (image == null) {
|
||||
image = decodeToImage(text.toString());
|
||||
}
|
||||
if (image != null) {
|
||||
m_oOutputPrinter.printImage(image);
|
||||
}
|
||||
|
||||
} catch (Exception fnfe) {
|
||||
//throw new ResourceNotFoundException( fnfe.getMessage() );
|
||||
}
|
||||
} else {
|
||||
m_oOutputPrinter.printText(m_iTextStyle, text.toString());
|
||||
text = null;
|
||||
} else if ("qr-code".equals(qName)) {
|
||||
m_oOutputPrinter.printImage(QRCode.printQRCode(text.toString()));
|
||||
}
|
||||
text = null;
|
||||
} else if ("line".equals(qName)) {
|
||||
m_oOutputPrinter.endLine();
|
||||
} else if ("ticket".equals(qName)) {
|
||||
m_oOutputPrinter.endReceipt();
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_DISPLAY:
|
||||
if ("line".equals(qName)) { // line 1 or 2 of the display
|
||||
if (m_sVisorLine1 == null) {
|
||||
else if ("barcode".equals(qName)) {
|
||||
m_oOutputPrinter.printBarCode(bctype, bcposition, text.toString());
|
||||
text = null;
|
||||
} else if ("text".equals(qName)) {
|
||||
if (m_iTextLength > 0) {
|
||||
switch(m_iTextAlign) {
|
||||
case DevicePrinter.ALIGN_RIGHT:
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignRight(text.toString(), m_iTextLength));
|
||||
break;
|
||||
case DevicePrinter.ALIGN_CENTER:
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignCenter(text.toString(), m_iTextLength));
|
||||
break;
|
||||
default: // DevicePrinter.ALIGN_LEFT
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignLeft(text.toString(), m_iTextLength));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
m_oOutputPrinter.printText(m_iTextStyle, text.toString());
|
||||
}
|
||||
text = null;
|
||||
} else if ("line".equals(qName)) {
|
||||
m_oOutputPrinter.endLine();
|
||||
} else if ("ticket".equals(qName)) {
|
||||
m_oOutputPrinter.endReceipt();
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_DISPLAY:
|
||||
if ("line".equals(qName)) { // line 1 or 2 of the display
|
||||
if (m_sVisorLine1 == null) {
|
||||
m_sVisorLine1 = m_sVisorLine.toString();
|
||||
} else {
|
||||
m_sVisorLine2 = m_sVisorLine.toString();
|
||||
}
|
||||
m_sVisorLine = null;
|
||||
} else if ("line1".equals(qName)) { // linea 1 del visor
|
||||
m_sVisorLine1 = m_sVisorLine.toString();
|
||||
} else {
|
||||
m_sVisorLine = null;
|
||||
} else if ("line2".equals(qName)) { // linea 2 del visor
|
||||
m_sVisorLine2 = m_sVisorLine.toString();
|
||||
}
|
||||
m_sVisorLine = null;
|
||||
} else if ("line1".equals(qName)) { // linea 1 del visor
|
||||
m_sVisorLine1 = m_sVisorLine.toString();
|
||||
m_sVisorLine = null;
|
||||
} else if ("line2".equals(qName)) { // linea 2 del visor
|
||||
m_sVisorLine2 = m_sVisorLine.toString();
|
||||
m_sVisorLine = null;
|
||||
} else if ("text".equals(qName)) {
|
||||
if (m_iTextLength > 0) {
|
||||
switch(m_iTextAlign) {
|
||||
case DevicePrinter.ALIGN_RIGHT:
|
||||
m_sVisorLine.append(DeviceTicket.alignRight(text.toString(), m_iTextLength));
|
||||
break;
|
||||
case DevicePrinter.ALIGN_CENTER:
|
||||
m_sVisorLine.append(DeviceTicket.alignCenter(text.toString(), m_iTextLength));
|
||||
break;
|
||||
default: // DevicePrinter.ALIGN_LEFT
|
||||
m_sVisorLine.append(DeviceTicket.alignLeft(text.toString(), m_iTextLength));
|
||||
break;
|
||||
m_sVisorLine = null;
|
||||
} else if ("text".equals(qName)) {
|
||||
if (m_iTextLength > 0) {
|
||||
switch(m_iTextAlign) {
|
||||
case DevicePrinter.ALIGN_RIGHT:
|
||||
m_sVisorLine.append(DeviceTicket.alignRight(text.toString(), m_iTextLength));
|
||||
break;
|
||||
case DevicePrinter.ALIGN_CENTER:
|
||||
m_sVisorLine.append(DeviceTicket.alignCenter(text.toString(), m_iTextLength));
|
||||
break;
|
||||
default: // DevicePrinter.ALIGN_LEFT
|
||||
m_sVisorLine.append(DeviceTicket.alignLeft(text.toString(), m_iTextLength));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
m_sVisorLine.append(text);
|
||||
}
|
||||
} else {
|
||||
m_sVisorLine.append(text);
|
||||
text = null;
|
||||
} else if ("display".equals(qName)) {
|
||||
m_printer.getDeviceDisplay().writeVisor(m_iVisorAnimation, m_sVisorLine1, m_sVisorLine2);
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
text = null;
|
||||
} else if ("display".equals(qName)) {
|
||||
m_printer.getDeviceDisplay().writeVisor(m_iVisorAnimation, m_sVisorLine1, m_sVisorLine2);
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_FISCAL:
|
||||
if ("fiscalreceipt".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().endReceipt();
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
} else if ("line".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printLine(text.toString(), m_dValue1, m_dValue2, attribute3);
|
||||
text = null;
|
||||
} else if ("message".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printMessage(text.toString());
|
||||
text = null;
|
||||
} else if ("total".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printTotal(text.toString(), m_dValue1);
|
||||
text = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_FISCAL:
|
||||
if ("fiscalreceipt".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().endReceipt();
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
} else if ("line".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printLine(text.toString(), m_dValue1, m_dValue2, attribute3);
|
||||
text = null;
|
||||
} else if ("message".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printMessage(text.toString());
|
||||
text = null;
|
||||
} else if ("total".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printTotal(text.toString(), m_dValue1);
|
||||
text = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
if (text != null) {
|
||||
text.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int parseInt(String sValue, int iDefault) {
|
||||
try {
|
||||
return Integer.parseInt(sValue);
|
||||
@@ -462,11 +471,11 @@ public class TicketParser extends DefaultHandler {
|
||||
return iDefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int parseInt(String sValue) {
|
||||
return parseInt(sValue, 0);
|
||||
}
|
||||
|
||||
|
||||
private double parseDouble(String sValue, double ddefault) {
|
||||
try {
|
||||
return Double.parseDouble(sValue);
|
||||
@@ -474,11 +483,11 @@ public class TicketParser extends DefaultHandler {
|
||||
return ddefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private double parseDouble(String sValue) {
|
||||
return parseDouble(sValue, 0.0);
|
||||
}
|
||||
|
||||
|
||||
private String readString(String sValue, String sDefault) {
|
||||
if (sValue == null || sValue.equals("")) {
|
||||
return sDefault;
|
||||
@@ -502,5 +511,5 @@ public class TicketParser extends DefaultHandler {
|
||||
return image;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ package com.unicenta.pos.reports;
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.*;
|
||||
import com.unicenta.data.user.EditorCreator;
|
||||
import com.unicenta.pos.forms.AppConfig;
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.forms.AppView;
|
||||
import com.unicenta.pos.forms.BeanFactoryException;
|
||||
@@ -197,5 +198,12 @@ public class PanelReportBean extends JPanelReport {
|
||||
*/
|
||||
public void addQBFFilter(ReportEditorCreator qbff) {
|
||||
qbffilter.addEditor(qbff);
|
||||
}
|
||||
}
|
||||
public String getDBType() {
|
||||
String url = AppConfig.getInstance().getProperty("db.URL");
|
||||
if (url.contains("derby")) {
|
||||
return "derby";
|
||||
}
|
||||
return "mysql";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import com.unicenta.pos.panels.JProductFinder;
|
||||
import com.unicenta.pos.payment.JPaymentSelect;
|
||||
import com.unicenta.pos.payment.JPaymentSelectReceipt;
|
||||
import com.unicenta.pos.payment.JPaymentSelectRefund;
|
||||
import com.unicenta.pos.printer.DeviceTicket;
|
||||
import com.unicenta.pos.printer.TicketParser;
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import com.unicenta.pos.sales.restaurant.RestaurantDBUtils;
|
||||
@@ -1839,9 +1838,11 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac
|
||||
|
||||
try {
|
||||
dlSales.saveTicket(ticket, m_App.getInventoryLocation());
|
||||
m_config.setProperty("lastticket.number", Integer.toString(ticket.getTicketId()));
|
||||
m_config.setProperty("lastticket.type", Integer.toString(ticket.getTicketType()));
|
||||
m_config.saveWithExistingProperties();
|
||||
String lastTicketNumber = Integer.toString(ticket.getTicketId());
|
||||
String lastTicketType = Integer.toString(ticket.getTicketType());
|
||||
m_config.setProperty("lastticket.number", lastTicketNumber);
|
||||
m_config.setProperty("lastticket.type", lastTicketType);
|
||||
m_config.setLastTicket(lastTicketNumber, lastTicketType);
|
||||
|
||||
} catch (BasicException eData) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
|
||||
@@ -3269,7 +3270,11 @@ public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFac
|
||||
if (listener != null) {
|
||||
listener.stop();
|
||||
}
|
||||
Object[] options = {"Create", "Find", "Cancel"};
|
||||
Object[] options = {
|
||||
AppLocal.getIntString("label.create"),
|
||||
AppLocal.getIntString("label.find"),
|
||||
AppLocal.getIntString("label.cancel")
|
||||
};
|
||||
|
||||
int n = JOptionPane.showOptionDialog(null,
|
||||
AppLocal.getIntString("message.customeradd"),
|
||||
|
||||
@@ -648,7 +648,17 @@ public final class TicketInfo implements SerializableRead, Externalizable {
|
||||
String row =(m_config.getProperty("tkt."+data));
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
public String printQRCode(String nameHeader, String vatHeader, String vatLabel){
|
||||
String name = getTicketHeaderFooterData(nameHeader);
|
||||
String vatNumberHeader = getTicketHeaderFooterData(vatHeader);
|
||||
String vatNumber = vatNumberHeader.split(vatLabel)[1];
|
||||
String date = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss").format(getDate());
|
||||
String total = String.valueOf(getTotal());
|
||||
String vatValue = String.valueOf(getTax());
|
||||
return name+","+vatNumber+","+date+","+total+","+vatValue;
|
||||
}
|
||||
|
||||
public String printTicketHeaderLine1() {
|
||||
String lineData = getTicketHeaderFooterData("header1");
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.unicenta.pos.util;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
public class QRCode {
|
||||
|
||||
public static BufferedImage printQRCode(String data) {
|
||||
|
||||
String[] values = data.split(",");
|
||||
|
||||
try {
|
||||
// Name
|
||||
QRObject name = new QRObject(1, values[0] );
|
||||
byte nameTagByte = (byte) name.getTag();
|
||||
byte nameLengthByte = (byte) name.getLength();
|
||||
byte[] nameBytes = {nameTagByte, nameLengthByte};
|
||||
String nameString = new String(nameBytes, StandardCharsets.UTF_8)+name.getValue();
|
||||
|
||||
//vat number
|
||||
QRObject vat = new QRObject(2, values[1]);
|
||||
byte vatTagByte = (byte) vat.getTag();
|
||||
byte vatLengthByte = (byte) vat.getLength();
|
||||
byte[] vatBytes = {vatTagByte, vatLengthByte};
|
||||
String vatString = new String(vatBytes, StandardCharsets.UTF_8)+vat.getValue();
|
||||
|
||||
// date
|
||||
QRObject date = new QRObject(3, values[2]);
|
||||
byte dateTagByte = (byte) date.getTag();
|
||||
byte dateLengthByte = (byte) date.getLength();
|
||||
byte[] dateBytes = {dateTagByte, dateLengthByte};
|
||||
String dateString = new String(dateBytes, StandardCharsets.UTF_8)+date.getValue();
|
||||
|
||||
// amount
|
||||
QRObject amount = new QRObject(4, values[3]);
|
||||
byte amountTagByte = (byte) amount.getTag();
|
||||
byte amountLengthByte = (byte) amount.getLength();
|
||||
byte[] amountBytes = {amountTagByte, amountLengthByte};
|
||||
String amountString = new String(amountBytes, StandardCharsets.UTF_8)+amount.getValue();
|
||||
|
||||
|
||||
// Vat amount
|
||||
QRObject vatAmount = new QRObject(5, values[4]);
|
||||
byte vatAmountTag = (byte) vatAmount.getTag();
|
||||
byte vatAmountLengthByte = (byte) vatAmount.getLength();
|
||||
byte[] vatAmountBytes = {vatAmountTag, vatAmountLengthByte};
|
||||
String vatAmountString = new String(vatAmountBytes, StandardCharsets.UTF_8)+vatAmount.getValue();
|
||||
|
||||
|
||||
//barcode
|
||||
String barCodeString = nameString+vatString+dateString+amountString+vatAmountString;
|
||||
String encodedBarcode = Base64.getEncoder().encodeToString(barCodeString.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
System.out.println(encodedBarcode);
|
||||
|
||||
QRCodeWriter barcodeWriter = new QRCodeWriter();
|
||||
BitMatrix bitMatrix = barcodeWriter.encode(encodedBarcode, BarcodeFormat.QR_CODE, 200, 200);
|
||||
|
||||
BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(bitMatrix);
|
||||
return MatrixToImageWriter.toBufferedImage(bitMatrix);
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.unicenta.pos.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class QRObject {
|
||||
|
||||
private int tag;
|
||||
private int length;
|
||||
private String value;
|
||||
|
||||
public QRObject(int tag, String value) {
|
||||
this.tag = tag;
|
||||
this.length = setLength(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(int tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
private static int setLength(String value) {
|
||||
return value.getBytes(StandardCharsets.UTF_8).length;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user