4 Commits

Author SHA1 Message Date
hugh 4bb441ffe0 5.0.1 release 2023-05-18 14:27:29 +01:00
hugh 725fdabc5e 5.0 migration fix 2023-05-04 15:18:17 +01:00
hugh-unicenta 28e29a2396 Merge pull request #9 from uniCenta/5.0-migration-fix
#8 5.0 migration fix
2023-05-04 14:08:00 +01:00
hugh 22236cc1a0 #8 5.0 migration fix
Fix for #8 migration fix
2023-05-04 14:07:19 +01:00
30 changed files with 119 additions and 569 deletions
-2
View File
@@ -6,5 +6,3 @@ nb-configuration.xml
nbactions.xml nbactions.xml
*.log *.log
docker.sock docker.sock
.DS_Store
+9 -10
View File
@@ -4,7 +4,7 @@
<groupId>com.unicenta</groupId> <groupId>com.unicenta</groupId>
<artifactId>unicentaopos</artifactId> <artifactId>unicentaopos</artifactId>
<version>5.0.2-SNAPSHOT</version> <version>5.0.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -145,11 +145,6 @@
<artifactId>rxtxcomm</artifactId> <artifactId>rxtxcomm</artifactId>
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.9.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.jpos</groupId> <groupId>org.jpos</groupId>
<artifactId>jpos</artifactId> <artifactId>jpos</artifactId>
@@ -212,7 +207,6 @@
<artifactId>javacsv</artifactId> <artifactId>javacsv</artifactId>
<version>2.0</version> <version>2.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.netbeans.external/AbsoluteLayout -->
<dependency> <dependency>
<groupId>org.netbeans.external</groupId> <groupId>org.netbeans.external</groupId>
<artifactId>AbsoluteLayout</artifactId> <artifactId>AbsoluteLayout</artifactId>
@@ -325,7 +319,12 @@
<dependency> <dependency>
<groupId>com.unicenta</groupId> <groupId>com.unicenta</groupId>
<artifactId>unicenta-plugins</artifactId> <artifactId>unicenta-plugins</artifactId>
<version>1.2</version> <version>1.1</version>
</dependency>
<dependency>
<groupId>uk.co.pos_apps</groupId>
<artifactId>openbravo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.gluonhq</groupId> <groupId>com.gluonhq</groupId>
@@ -565,12 +564,12 @@
<url>https://repo1.maven.org/maven2/</url> <url>https://repo1.maven.org/maven2/</url>
<layout>default</layout> <layout>default</layout>
</repository> </repository>
<!--These are needed for Swing/Netbeans <!--These are needed for Swing/Netbeans -->
<repository> <repository>
<id>netbeans</id> <id>netbeans</id>
<name>NetBeans</name> <name>NetBeans</name>
<url>https://netbeans.apidesign.org/maven2/</url> <url>https://netbeans.apidesign.org/maven2/</url>
</repository>--> </repository>
<!--These are needed for Swing/Netbeans --> <!--These are needed for Swing/Netbeans -->
<repository> <repository>
<id>flatlaf</id> <id>flatlaf</id>
@@ -67,12 +67,12 @@ public class PreparedSentence extends JDBCSentence {
/** /**
* *
* @param session * @param s
* @param sentence * @param sentence
* @param serwrite * @param serwrite
*/ */
public PreparedSentence(Session session, String sentence, SerializerWrite serwrite) { public PreparedSentence(Session s, String sentence, SerializerWrite serwrite) {
this(session, sentence, serwrite, null); this(s, sentence, serwrite, null);
} }
/** /**
@@ -29,14 +29,14 @@ import com.unicenta.basic.BasicException;
*/ */
public abstract class SentenceExecTransaction implements SentenceExec { public abstract class SentenceExecTransaction implements SentenceExec {
private Session session; private Session m_s;
/** /**
* *
* @param session * @param s
*/ */
public SentenceExecTransaction(Session session) { public SentenceExecTransaction(Session s) {
this.session = session; m_s = s;
} }
/** /**
@@ -66,7 +66,7 @@ public abstract class SentenceExecTransaction implements SentenceExec {
*/ */
public final int exec(final Object params) throws BasicException { public final int exec(final Object params) throws BasicException {
Transaction<Integer> t = new Transaction<Integer>(session) { Transaction<Integer> t = new Transaction<Integer>(m_s) {
public Integer transact() throws BasicException{ public Integer transact() throws BasicException{
return execInTransaction(params); return execInTransaction(params);
} }
@@ -52,7 +52,6 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
initPayments("Not defined", new ConfigPaymentPanelEmpty()); initPayments("Not defined", new ConfigPaymentPanelEmpty());
initPayments("external", new ConfigPaymentPanelEmpty()); initPayments("external", new ConfigPaymentPanelEmpty());
initPayments("PaymentSense", new ConfigPaymentPanelEmpty()); initPayments("PaymentSense", new ConfigPaymentPanelEmpty());
initPayments("Teya", new ConfigPaymentPanelEmpty());
// Lector de tarjetas. // Lector de tarjetas.
jcboCardReader.addItem("Not defined"); jcboCardReader.addItem("Not defined");
@@ -278,12 +277,6 @@ public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConf
emvConfigPanel.setVisible(Boolean.TRUE); emvConfigPanel.setVisible(Boolean.TRUE);
jcboCardReader.setSelectedItem("EMV"); jcboCardReader.setSelectedItem("EMV");
jcboCardReader.setEnabled(Boolean.FALSE); jcboCardReader.setEnabled(Boolean.FALSE);
}
else if (comboValue(jcboPaymentGateway.getSelectedItem()).equals("Teya")) {
emvConfigPanel.setVisible(Boolean.FALSE);
jcboCardReader.setSelectedItem("EMV");
jcboCardReader.setEnabled(Boolean.FALSE);
} }
else { else {
emvConfigPanel.setVisible(Boolean.FALSE); emvConfigPanel.setVisible(Boolean.FALSE);
@@ -358,7 +358,6 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
jcboMachineScale.addItem("dialog1"); jcboMachineScale.addItem("dialog1");
jcboMachineScale.addItem("mtind221"); jcboMachineScale.addItem("mtind221");
jcboMachineScale.addItem("samsungesp"); jcboMachineScale.addItem("samsungesp");
jcboMachineScale.addItem("samsungesp-v2");
jcboSerialScale.addItem("COM1"); jcboSerialScale.addItem("COM1");
jcboSerialScale.addItem("COM2"); jcboSerialScale.addItem("COM2");
@@ -613,7 +612,6 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
if ("casiopd1".equals(sparam) || if ("casiopd1".equals(sparam) ||
"dialog1".equals(sparam) || "dialog1".equals(sparam) ||
"samsungesp".equals(sparam) || "samsungesp".equals(sparam) ||
"samsungesp-v2".equals(sparam) ||
"caspdii".equals(sparam) || "caspdii".equals(sparam) ||
"acompc100".equals(sparam) || "acompc100".equals(sparam) ||
"averyberkel6720".equals(sparam) || "averyberkel6720".equals(sparam) ||
@@ -822,7 +820,6 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
if ("casiopd1".equals(sMachineScale) || if ("casiopd1".equals(sMachineScale) ||
"dialog1".equals(sMachineScale) || "dialog1".equals(sMachineScale) ||
"samsungesp".equals(sMachineScale) || "samsungesp".equals(sMachineScale) ||
"samsungesp-v2".equals(sMachineScale) ||
"caspdii".equals(sMachineScale) || "caspdii".equals(sMachineScale) ||
"acompc100".equals(sMachineScale) || "acompc100".equals(sMachineScale) ||
"averyberkel6720".equals(sMachineScale) || "averyberkel6720".equals(sMachineScale) ||
@@ -2310,7 +2307,6 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
if ("casiopd1".equals(jcboMachineScale.getSelectedItem()) || if ("casiopd1".equals(jcboMachineScale.getSelectedItem()) ||
"dialog1".equals(jcboMachineScale.getSelectedItem()) || "dialog1".equals(jcboMachineScale.getSelectedItem()) ||
"samsungesp".equals(jcboMachineScale.getSelectedItem()) || "samsungesp".equals(jcboMachineScale.getSelectedItem()) ||
"samsungesp-v2".equals(jcboMachineScale.getSelectedItem()) ||
"caspdii".equals(jcboMachineScale.getSelectedItem())|| "caspdii".equals(jcboMachineScale.getSelectedItem())||
"acompc100".equals(jcboMachineScale.getSelectedItem())|| "acompc100".equals(jcboMachineScale.getSelectedItem())||
"averyberkel6720".equals(jcboMachineScale.getSelectedItem())|| "averyberkel6720".equals(jcboMachineScale.getSelectedItem())||
@@ -30,7 +30,7 @@ public class AppLocal {
public static final String APP_NAME = "uniCenta oPOS"; public static final String APP_NAME = "uniCenta oPOS";
public static final String APP_ID = "unicentaopos"; public static final String APP_ID = "unicentaopos";
public static final String APP_VERSION = "5.0.1"; public static final String APP_VERSION = "5.0";
private static final LocaleResources m_resources; private static final LocaleResources m_resources;
@@ -61,14 +61,6 @@ public class JRootFrame extends javax.swing.JFrame implements AppMessage {
initComponents(); initComponents();
} }
public JRootApp getRootapp() {
return m_rootapp;
}
public void setRootapp(JRootApp m_rootapp) {
this.m_rootapp = m_rootapp;
}
/** /**
* @param props * @param props
*/ */
@@ -106,7 +98,6 @@ public class JRootFrame extends javax.swing.JFrame implements AppMessage {
new JFrmConfig(props).setVisible(true); // Show the configuration window. new JFrmConfig(props).setVisible(true); // Show the configuration window.
} }
setRootapp(m_rootapp);
} }
/** /**
@@ -58,14 +58,6 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
initComponents(); initComponents();
} }
public JRootApp getRootapp() {
return m_rootapp;
}
public void setRootapp(JRootApp m_rootapp) {
this.m_rootapp = m_rootapp;
}
/** /**
* *
* @param props * @param props
@@ -73,10 +65,6 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
*/ */
public void initFrame(AppProperties props) throws IOException { public void initFrame(AppProperties props) throws IOException {
String osName = System.getProperty("os.name").toLowerCase();
boolean isWindows = osName.startsWith("windows");
boolean isMac = osName.startsWith("mac");
m_OS = new OSValidator(); m_OS = new OSValidator();
m_props = props; m_props = props;
@@ -96,16 +84,21 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION); setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
if (isMac) {
setBounds(0, 25, d.width, d.height - 25);
}
else {
setBounds(0, 0, d.width, d.height); setBounds(0, 0, d.width, d.height);
}
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); /*
* 4 Sep 17 JG
* 2 Dec 17 - Mod' Thanks Hayk Sokolov!
* Change here for Linux/Ubuntu full screen
* Thanks to Hans Lengerke for solution
*/
String osName = System.getProperty("os.name").toLowerCase();
boolean isWindows = osName.startsWith("windows");
if (device.isFullScreenSupported() && !isWindows && !isMac) { GraphicsDevice device = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (device.isFullScreenSupported() && !isWindows) {
setResizable(true); setResizable(true);
addFocusListener(new FocusListener() { addFocusListener(new FocusListener() {
@@ -129,7 +122,6 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
new JFrmConfig(props).setVisible(true); // Show the configuration window. new JFrmConfig(props).setVisible(true); // Show the configuration window.
} }
setRootapp(m_rootapp);
} }
@Override @Override
@@ -98,6 +98,7 @@ public class StartPOS {
String hostname = config.getProperty("machine.hostname"); String hostname = config.getProperty("machine.hostname");
TicketInfo.setHostname(hostname); TicketInfo.setHostname(hostname);
applicationStarted(hostname);
String screenmode = config.getProperty("machine.screenmode"); String screenmode = config.getProperty("machine.screenmode");
@@ -105,8 +106,6 @@ public class StartPOS {
JRootKiosk rootkiosk = new JRootKiosk(); JRootKiosk rootkiosk = new JRootKiosk();
try { try {
rootkiosk.initFrame(config); rootkiosk.initFrame(config);
applicationStarted(hostname, rootkiosk.getRootapp());
} catch (IOException ex) { } catch (IOException ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
} }
@@ -114,25 +113,18 @@ public class StartPOS {
JRootFrame rootframe = new JRootFrame(); JRootFrame rootframe = new JRootFrame();
try { try {
rootframe.initFrame(config); rootframe.initFrame(config);
applicationStarted(hostname, rootframe.getRootapp());
} catch (Exception ex) { } catch (Exception ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
} }
} }
}); });
} }
private static void applicationStarted(String host, JRootApp jRootApp) { private static void applicationStarted(String host) {
new Thread(() -> { new Thread(() -> {
try {
Metrics metrics = new Metrics(); Metrics metrics = new Metrics();
metrics.setDevice(host); metrics.setDevice(host);
metrics.setUniCentaVersion(AppLocal.APP_VERSION); metrics.setUniCentaVersion(AppLocal.APP_VERSION);
Application application = new Application(); new Application().postMetrics(metrics);
application.postMetrics(metrics);
application.startEventListener(host, jRootApp);
} catch (Exception e) {
log.error("Problem with starting the uniCenta plugin application:${}", e.getMessage());
}
}).start(); }).start();
} }
} }
@@ -39,8 +39,6 @@ public class PaymentGatewayFac {
return new PaymentGatewayExt(); return new PaymentGatewayExt();
case "PaymentSense": case "PaymentSense":
return new PaymentGatewayPaymentSense(); return new PaymentGatewayPaymentSense();
case "Teya":
return new PaymentGatewayTeya();
default: default:
return null; return null;
} }
@@ -1,101 +0,0 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// 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/>.
package com.unicenta.pos.payment;
import com.unicenta.plugins.Application;
import com.unicenta.plugins.common.AppContext;
import com.unicenta.pos.util.RoundUtils;
import lombok.extern.slf4j.Slf4j;
import java.awt.*;
import java.util.ArrayList;
@Slf4j
public class PaymentGatewayTeya implements PaymentGateway {
/** Creates a new instance of PaymentGatewayExt */
public PaymentGatewayTeya() {
}
Window getPaymentWindow(double amount) {
if (amount > 0) {
ArrayList<JPaymentSelectReceipt> paymentWindows = new ArrayList<>();
for (Window window : Window.getWindows()) {
if (window instanceof JPaymentSelectReceipt) {
paymentWindows.add((JPaymentSelectReceipt) window);
}
}
return paymentWindows.get(paymentWindows.size()-1);
}
else {
ArrayList<JPaymentSelectRefund> paymentWindows = new ArrayList<>();
for (Window window : Window.getWindows()) {
if (window instanceof JPaymentSelectRefund) {
paymentWindows.add((JPaymentSelectRefund) window);
}
}
return paymentWindows.get(paymentWindows.size()-1);
}
}
/**
*
* @param payinfo
*/
@Override
public void execute(PaymentInfoMagcard payinfo) {
int timer = 0;
int timeout = 150;
double roundedValue = RoundUtils.round(payinfo.getTotal());
new Application().teyaTransaction(roundedValue, getPaymentWindow(roundedValue), payinfo.getTransactionID());
while (AppContext.getTeyaPaymentResult() == null) {
try {
log.info("uniCenta-oPos: waiting for payment to complete ....");
Thread.sleep(1000);
timer += 1;
if (timer > timeout) break;
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
if (AppContext.getTeyaPaymentResult().getStatus().equals("SUCCESSFUL")) {
payinfo.setCardName("Teya");
payinfo.setVerification("Chip and Pin");
payinfo.setChipAndPin(true);
payinfo.paymentOK(
roundedValue > 0 ? AppContext.getTeyaPaymentResult().getReferenceId() : "",
roundedValue > 0 ? AppContext.getTeyaPaymentResult().getGatewayPaymentId() : "",
AppContext.getTeyaPaymentResult().getStatus()
);
}
else {
payinfo.paymentError("Transaction Error! Please try again", AppContext.getTeyaPaymentResult().getStatus());
}
}
}
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
/** /**
*
* @author JG uniCenta * @author JG uniCenta
*/ */
@Slf4j @Slf4j
@@ -50,9 +51,7 @@ public abstract class BasicTicket implements PrintItem {
*/ */
protected int m_iBodyHeight; protected int m_iBodyHeight;
/** /** Creates a new instance of AbstractTicket */
* Creates a new instance of AbstractTicket
*/
public BasicTicket() { public BasicTicket() {
// JG 16 May 12 use diamond inference // JG 16 May 12 use diamond inference
m_aCommands = new ArrayList<>(); m_aCommands = new ArrayList<>();
@@ -61,21 +60,25 @@ public abstract class BasicTicket implements PrintItem {
} }
/** /**
*
* @return * @return
*/ */
protected abstract Font getBaseFont(); protected abstract Font getBaseFont();
/** /**
*
* @return * @return
*/ */
protected abstract int getFontHeight(); protected abstract int getFontHeight();
/** /**
*
* @return * @return
*/ */
protected abstract double getImageScale(); protected abstract double getImageScale();
/** /**
*
* @return * @return
*/ */
@Override @Override
@@ -84,6 +87,7 @@ public abstract class BasicTicket implements PrintItem {
} }
/** /**
*
* @param g2d * @param g2d
* @param x * @param x
* @param y * @param y
@@ -97,55 +101,10 @@ public abstract class BasicTicket implements PrintItem {
pi.draw(g2d, x, currenty, width); pi.draw(g2d, x, currenty, width);
currenty += pi.getHeight(); currenty += pi.getHeight();
} }
saveTicket(g2d, x, y, width);
}
private void saveTicket(Graphics2D g2d, int x, int y, int width) {
int receiptHeight = 5;
PrintItem pi;
for(Iterator i$ = m_aCommands.iterator(); i$.hasNext(); receiptHeight += pi.getHeight()) {
pi = (PrintItem)i$.next();
}
BufferedImage image = new BufferedImage(width + 10, receiptHeight, 1);
g2d = image.createGraphics();
int currenty = y;
for(Iterator i$ = this.m_aCommands.iterator(); i$.hasNext(); currenty += pi.getHeight()) {
pi = (PrintItem)i$.next();
if (pi instanceof PrintItemImage) {
((PrintItemImage) pi).setImage(negative(((PrintItemImage) pi).getImage()));
}
pi.draw(g2d, x, currenty, width);
}
try {
ImageIO.write(this.negative(image), "png", new File(System.getProperty("user.home") + "/receipt.png"));
}
catch (Exception e) {
System.out.println("Error serialising receipt image !!! : " + e);
}
}
public BufferedImage negative(BufferedImage img) {
for (int x = 0; x < img.getWidth(); ++x) {
for (int y = 0; y < img.getHeight(); ++y) {
int RGBA = img.getRGB(x, y);
Color col = new Color(RGBA, true);
col = new Color(Math.abs(col.getRed() - 255), Math.abs(col.getGreen() - 255), Math.abs(col.getBlue() - 255));
img.setRGB(x, y, col.getRGB());
}
}
return img;
} }
/** /**
*
* @return * @return
*/ */
public java.util.List<PrintItem> getCommands() { public java.util.List<PrintItem> getCommands() {
@@ -155,6 +114,7 @@ public abstract class BasicTicket implements PrintItem {
// INTERFAZ PRINTER 2 // INTERFAZ PRINTER 2
/** /**
*
* @param image * @param image
*/ */
public void printImage(BufferedImage image) { public void printImage(BufferedImage image) {
@@ -165,6 +125,7 @@ public abstract class BasicTicket implements PrintItem {
} }
/** /**
*
* @param type * @param type
* @param position * @param position
* @param code * @param code
@@ -177,6 +138,7 @@ public abstract class BasicTicket implements PrintItem {
} }
/** /**
*
* @param iTextSize * @param iTextSize
*/ */
public void beginLine(int iTextSize) { public void beginLine(int iTextSize) {
@@ -184,6 +146,7 @@ public abstract class BasicTicket implements PrintItem {
} }
/** /**
*
* @param iStyle * @param iStyle
* @param sText * @param sText
*/ */
@@ -203,4 +166,4 @@ public abstract class BasicTicket implements PrintItem {
pil = null; pil = null;
} }
} }
} }
@@ -70,12 +70,4 @@ public class PrintItemImage implements PrintItem {
public int getHeight() { public int getHeight() {
return (int) (image.getHeight() * scale); return (int) (image.getHeight() * scale);
} }
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage image) {
this.image = image;
}
} }
@@ -56,9 +56,6 @@ public class DeviceScale {
case "samsungesp": case "samsungesp":
m_scale = new ScaleSamsungEsp(sScaleParam1); m_scale = new ScaleSamsungEsp(sScaleParam1);
break; break;
case "samsungesp-v2":
m_scale = new ScaleSamsungEspV2(sScaleParam1);
break;
case "caspdii": case "caspdii":
m_scale = new ScaleCASPDII(sScaleParam1); m_scale = new ScaleCASPDII(sScaleParam1);
break; break;
@@ -1,95 +0,0 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2023 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// 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/>.
package com.unicenta.pos.scale;
import com.fazecast.jSerialComm.SerialPort;
import com.fazecast.jSerialComm.SerialPortDataListener;
import com.fazecast.jSerialComm.SerialPortEvent;
public class ScaleSamsungEspV2 implements Scale {
private String result;
private final String m_sPortScale;
/** Creates a new instance of ScaleComm
* @param sPortPrinter */
public ScaleSamsungEspV2(String sPortPrinter) {
m_sPortScale = sPortPrinter;
}
private final SerialPortDataListener dataListener = new SerialPortDataListener() {
@Override
public int getListeningEvents() {
return SerialPort.LISTENING_EVENT_DATA_AVAILABLE;
}
@Override
public void serialEvent(SerialPortEvent event) {
if (event.getEventType() == SerialPort.LISTENING_EVENT_DATA_AVAILABLE) {
SerialPort serialPort = (SerialPort) event.getSerialPort();
byte[] newData = new byte[serialPort.bytesAvailable()];
serialPort.readBytes(newData, newData.length);
String receivedData = new String(newData);
result = result + receivedData;
}
}
};
/**
*
* @return
*/
@Override
public Double readWeight() {
// Configura los parámetros del puerto serie
SerialPort serialPort = SerialPort.getCommPort(m_sPortScale);
serialPort.setBaudRate(4800);
serialPort.setNumDataBits(8);
serialPort.setNumStopBits(1);
serialPort.setParity(1);
// Abre el puerto serie
if (serialPort.openPort()) {
// Agrega el objeto de escucha al puerto serie
serialPort.addDataListener(dataListener);
// Escribe en el puerto serie
result = "";
byte[] data = new byte[] {0x24};
serialPort.writeBytes(data, data.length);
// Espera unos segundos para recibir la respuesta (puedes ajustar este tiempo)
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
// Cierra el puerto serie
serialPort.closePort();
}
try {
return Double.valueOf(result);
} catch (NumberFormatException e) {
return 0.0;
}
}
}
@@ -79,14 +79,14 @@ public final class TicketInfo implements SerializableRead, Externalizable {
private Double nsum; private Double nsum;
private int ticketstatus; private int ticketstatus;
private static String hostname; private static String Hostname;
public static void setHostname(String name) { public static void setHostname(String name) {
hostname =name; Hostname=name;
} }
public static String getHostname() { public static String getHostname() {
return hostname; return Hostname;
} }
/** Creates new TicketModel */ /** Creates new TicketModel */
@@ -19,7 +19,6 @@
package com.unicenta.pos.ticket; package com.unicenta.pos.ticket;
import com.google.gson.Gson;
import com.unicenta.basic.BasicException; import com.unicenta.basic.BasicException;
import com.unicenta.data.loader.DataRead; import com.unicenta.data.loader.DataRead;
import com.unicenta.data.loader.DataWrite; import com.unicenta.data.loader.DataWrite;
@@ -41,12 +40,6 @@ public class TicketLineInfo implements SerializableWrite, SerializableRead, Seri
private String m_sTicket; private String m_sTicket;
private int m_iLine; private int m_iLine;
private double multiply; private double multiply;
@Override
public String toString() {
return new Gson().toJson(this);
}
private double price; private double price;
private TaxInfo tax; private TaxInfo tax;
private Properties attributes; private Properties attributes;
@@ -153,7 +153,7 @@ public final class VoucherEditor extends javax.swing.JPanel implements EditorRec
} else switch (m_jStatus.getText()) { } else switch (m_jStatus.getText()) {
case "A": case "A":
jLblStatus.setIcon(new javax.swing.ImageIcon(getClass() jLblStatus.setIcon(new javax.swing.ImageIcon(getClass()
.getResource("/com/unicenta/images/ok.png"))); .getResource("/com/unicenta/images/OK.png")));
m_jNumber.setEnabled(true); m_jNumber.setEnabled(true);
m_jAmount.setEnabled(true); m_jAmount.setEnabled(true);
m_jCustomer.setEnabled(true); m_jCustomer.setEnabled(true);
@@ -1,7 +0,0 @@
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Linediscount.txt} WHERE name = 'script.Linediscount';
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt} WHERE name = 'script.Totaldiscount';
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.multibuy.txt} WHERE name = 'script.multibuy';
UPDATE applications SET version = $APP_VERSION{} WHERE id = $APP_ID{};
@@ -44,15 +44,6 @@ COMMIT;
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated'; UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated';
COMMIT; COMMIT;
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Linediscount.txt} WHERE name = 'script.Linediscount';
COMMIT;
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt} WHERE name = 'script.Totaldiscount';
COMMIT;
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/script.multibuy.txt} WHERE name = 'script.multibuy';
COMMIT;
-- ROLES -- ROLES
DELETE FROM roles WHERE id = '0'; DELETE FROM roles WHERE id = '0';
INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} );
@@ -21,3 +21,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. // along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// ************************************************************************** // **************************************************************************
import uk.co.pos_apps.PosApps;
PosApps.createCustomer(device, customer);
@@ -21,3 +21,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. // along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// ************************************************************************** // **************************************************************************
import uk.co.pos_apps.PosApps;
PosApps.deleteCustomer(device, customer);
@@ -21,3 +21,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. // along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// ************************************************************************** // **************************************************************************
import uk.co.pos_apps.PosApps;
PosApps.updateCustomer(device, customer);
@@ -31,7 +31,7 @@ private boolean printedP6 = false;
for(int i= 0; i < ticket.getLinesCount(); i++){ for(int i= 0; i < ticket.getLinesCount(); i++){
line = ticket.getLine(i); line = ticket.getLine(i);
if (line.getProperty("product.printer")!=null && line.getProperty("ticket.updated")!=null) { if (line.getProperty("product.printer")!=null) {
if (line.getProperty("product.printer").equals("1")) { if (line.getProperty("product.printer").equals("1")) {
if((printedP1 == false) && line.getProperty("ticket.updated").equals("true")) { if((printedP1 == false) && line.getProperty("ticket.updated").equals("true")) {
@@ -36,16 +36,15 @@ if (index >= 0) {
sdiscount = Formats.PERCENT.formatValue((discountrate)); sdiscount = Formats.PERCENT.formatValue((discountrate));
for (int number= 0; number < ticket.getLinesCount(); number++) { for (int number= 0; number < ticket.getLinesCount(); number++) {
line = ticket.getLine(number); line = ticket.getLine(number);
TicketLineInfo ticketLineInfo = new TicketLineInfo( ticket.setLine(number,
new TicketLineInfo(
line.getProductID(), line.getProductID(),
line.getProductName() + " - Item Discount @ " + sdiscount, line.getProductName() + " - Item Discount @ " + sdiscount,
line.getProductTaxCategoryID(), line.getProductTaxCategoryID(),
line.getProductPrinter(), line.getProductPrinter(),
line.getMultiply(), line.getMultiply(),
line.getNewPrice() - (double)Math.abs(line.getNewPrice() * discountrate * 100) /100, line.getNewPrice() - (double)Math.abs(line.getNewPrice() * discountrate * 100) /100,
line.getTaxInfo()); line.getTaxInfo()));
ticketLineInfo.setTicketUpdated("ticket.updated", "true");
ticket.setLine(number,ticketLineInfo);
} }
} else { } else {
java.awt.Toolkit.getDefaultToolkit().beep(); java.awt.Toolkit.getDefaultToolkit().beep();
+1 -1
View File
@@ -881,7 +881,7 @@ message.email=Desktop email app' not found
message.emptycustomer=Customer cannot be empty message.emptycustomer=Customer cannot be empty
message.emptynumber=Number cannot be empty message.emptynumber=Number cannot be empty
message.enterbuyprice=Enter new Buy Price message.enterbuyprice=Enter new Buy Price
message.eolupdate=<html><center><h2>Version 5.0.1 Upgrade!</h2></br><h3>Your current database version is {0}</h3><br>For version 5.0 click <b>YES</b><br/><br/>For any other version click <b>NO</b> and get to 5.0 first<br><br/> message.eolupdate=<html><center><h2>Version 5.0 Upgrade!</h2></br><h3>Your current database version is {0}</h3><br>For version 4.6.4 click <b>YES</b><br/><br/>For any other version click <b>NO</b> and get to 4.6.4 first<br><br/>
message.ibuttonassign=<html><center>Get the iButton ID<br>Place iButton onto the reader then click OK message.ibuttonassign=<html><center>Get the iButton ID<br>Place iButton onto the reader then click OK
message.ibuttonnotassign=<html><center>The iButton used is not yet assigned to anyone message.ibuttonnotassign=<html><center>The iButton used is not yet assigned to anyone
message.ibuttonnotfound=No iButton adapter found. Key fobs will be disabled. message.ibuttonnotfound=No iButton adapter found. Key fobs will be disabled.
@@ -1,95 +0,0 @@
package com.unicenta.pos.ticket;
import com.google.gson.Gson;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import static org.junit.Assert.*;
public class TicketLineInfoTest {
@Test
public void shouldSendOrderDiscountToPrinter(){
String json = getText("src/test/resources/TicketLineInfo.json");
assert json != null;
TicketLineInfo ticketLineInfo = new Gson().fromJson(json, TicketLineInfo.class);
assert ticketLineInfo != null;
sendOrderScript(ticketLineInfo);
}
@Test
public void shouldSendItemDiscountToPrinter() {
String json = getText("src/test/resources/TicketLineInfoOrderDiscount.json");
assert json != null;
TicketLineInfo ticketLineInfo = new Gson().fromJson(json, TicketLineInfo.class);
assert ticketLineInfo != null;
sendOrderScript(ticketLineInfo);
}
private void sendOrderScript(TicketLineInfo line) {
boolean printedP1 = false;
boolean printedP2 = false;
boolean printedP3 = false;
boolean printedP4 = false;
boolean printedP5 = false;
boolean printedP6 = false;
if (line.getProperty("product.printer")!=null && line.getProperty("ticket.updated")!=null) {
if (line.getProperty("product.printer").equals("1")) {
System.out.print("getting property: ");
System.out.println(line.getProperty("ticket.updated").equals("true"));
if((printedP1 == false)) {
//sales.printTicket("Printer.Ticket.P1");
printedP1 = true;
}
}
if (line.getProperty("product.printer").equals("2")) {
if((printedP2 == false) && line.getProperty("ticket.updated").equals("true")){
//sales.printTicket("Printer.Ticket.P2");
printedP2 = true;
}
}
if (line.getProperty("product.printer").equals("3")) {
if((printedP3 == false) && line.getProperty("ticket.updated").equals("true")){
//sales.printTicket("Printer.Ticket.P3");
printedP3 = true;
}
}
if (line.getProperty("product.printer").equals("4")) {
if((printedP4 == false) && line.getProperty("ticket.updated").equals("true")){
//sales.printTicket("Printer.Ticket.P4");
printedP4 = true;
}
}
if (line.getProperty("product.printer").equals("5")) {
if((printedP5 == false) && line.getProperty("ticket.updated").equals("true")){
//sales.printTicket("Printer.Ticket.P5");
printedP5 = true;
}
}
if (line.getProperty("product.printer").equals("6")) {
if((printedP6 == false) && line.getProperty("ticket.updated").equals("true")){
//sales.printTicket("Printer.Ticket.P6");
printedP6 = true;
}
}
}
}
private String getText(String path) {
try {
return new String(Files.readAllBytes(Paths.get(path)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
-35
View File
@@ -1,35 +0,0 @@
{
"m_sTicket": "8c5bfd03-f4f8-4a3f-b216-57f194e1cda6",
"m_iLine": 0,
"multiply": 1.0,
"price": 8.333333333333334,
"tax":
{
"id": "001",
"name": "Tax Standard",
"taxcategoryid": "001",
"rate": 0.2,
"cascade": false
},
"attributes":
{
"product.printer": "1",
"product.warranty": "false",
"product.reference": "123",
"product.com": "false",
"product.verpatrib": "false",
"ticket.updated": "true",
"product.name": "Burger",
"product.service": "false",
"product.categoryid": "000",
"product.taxcategoryid": "001",
"product.memodate": "1900-01-01 00:00:01",
"product.code": "123",
"product.vprice": "false",
"product.texttip": "",
"product.constant": "false"
},
"productid": "fc33fa54-3af1-486b-85e7-9838160053ea",
"updated": false,
"newprice": 10.0
}
@@ -1,23 +0,0 @@
{
"m_sTicket": "5ff16e4c-0df9-4002-bc54-cc60fce92de2",
"m_iLine": 0,
"multiply": 1.0,
"price": 7.333333333333334,
"tax":
{
"id": "001",
"name": "Tax Standard",
"taxcategoryid": "001",
"rate": 0.2,
"cascade": false
},
"attributes":
{
"product.taxcategoryid": "001",
"product.printer": "1",
"product.name": "Burger - Item Discount @ 12%"
},
"productid": "fc33fa54-3af1-486b-85e7-9838160053ea",
"updated": false,
"newprice": 0.0
}