23 Commits

Author SHA1 Message Date
hugh-unicenta ec49bc1860 Merge branch 'main' into customer-api 2023-11-10 17:52:33 +00:00
hugh 23432540aa latest plugins 2023-11-10 17:49:07 +00:00
hugh-unicenta 9490344284 Merge pull request #19 from uniCenta/UOCL-251-mac-in-full-screen-freezes-on-arm-architecture
UOCL-251 work around added
2023-11-10 12:21:10 +00:00
hugh 69d6264c79 UOCL-251 work around added 2023-11-10 12:15:50 +00:00
hugh ac9a7c0453 UOCL-244: poc working 2023-10-05 16:50:50 +01:00
hugh 9497d52428 UOCL-244: receipts added to main code base 2023-10-05 12:17:20 +01:00
hugh 1174c0ccd6 UOCL-244: receipts added to main code base 2023-10-05 12:06:34 +01:00
hugh f965cf9172 wip 2023-09-28 16:04:55 +01:00
hugh cd95e2c7fd UCA-1: find customers update 2023-09-14 14:59:47 +01:00
hugh cdc81b4517 UOCL-244: development 2023-08-28 14:39:25 +01:00
hugh 4d6e83024a UOCL-247: removing netbeans repo 2023-07-31 13:01:53 +01:00
hugh 649da0a6e3 UOCL-241: Fixing scale exception 2023-06-28 10:38:41 +01:00
hugh b1c0d9c08e 5.0.1 migration scripts 2023-06-28 10:38:41 +01:00
hugh 7b09e0e430 5.0.1 migration scripts 2023-06-28 10:38:41 +01:00
hugh 6a772eae0e UOCL-242: voucher fix 2023-06-28 10:37:51 +01:00
hugh 60347fd054 fixing totalDiscount 2023-06-27 17:28:57 +01:00
hugh 51b833e0cd fixing sendOrder script 2023-06-27 17:28:57 +01:00
hugh 184c53d4ac reverting pom as https resolved 2023-06-27 17:28:57 +01:00
hugh b5903aa497 fixing broken pom 2023-06-27 17:28:57 +01:00
hugh 3b6c408850 5.0.1 migration scripts 2023-06-27 17:28:57 +01:00
hugh 74e406bb25 5.0.1 release 2023-06-27 17:28:57 +01:00
hugh 28afe3f197 5.0 migration fix 2023-06-27 17:28:57 +01:00
hugh 4a67f915a1 Fix for UOCL-240 migration fix 2023-06-27 17:28:40 +01:00
28 changed files with 467 additions and 119 deletions
+2
View File
@@ -6,3 +6,5 @@ nb-configuration.xml
nbactions.xml
*.log
docker.sock
.DS_Store
+10 -9
View File
@@ -4,7 +4,7 @@
<groupId>com.unicenta</groupId>
<artifactId>unicentaopos</artifactId>
<version>5.0</version>
<version>5.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -145,6 +145,11 @@
<artifactId>rxtxcomm</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>org.jpos</groupId>
<artifactId>jpos</artifactId>
@@ -207,6 +212,7 @@
<artifactId>javacsv</artifactId>
<version>2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.netbeans.external/AbsoluteLayout -->
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>AbsoluteLayout</artifactId>
@@ -319,12 +325,7 @@
<dependency>
<groupId>com.unicenta</groupId>
<artifactId>unicenta-plugins</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>uk.co.pos_apps</groupId>
<artifactId>openbravo</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
@@ -564,12 +565,12 @@
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<!--These are needed for Swing/Netbeans -->
<!--These are needed for Swing/Netbeans
<repository>
<id>netbeans</id>
<name>NetBeans</name>
<url>https://netbeans.apidesign.org/maven2/</url>
</repository>
</repository>-->
<!--These are needed for Swing/Netbeans -->
<repository>
<id>flatlaf</id>
@@ -67,12 +67,12 @@ public class PreparedSentence extends JDBCSentence {
/**
*
* @param s
* @param session
* @param sentence
* @param serwrite
*/
public PreparedSentence(Session s, String sentence, SerializerWrite serwrite) {
this(s, sentence, serwrite, null);
public PreparedSentence(Session session, String sentence, SerializerWrite serwrite) {
this(session, sentence, serwrite, null);
}
/**
@@ -29,14 +29,14 @@ import com.unicenta.basic.BasicException;
*/
public abstract class SentenceExecTransaction implements SentenceExec {
private Session m_s;
private Session session;
/**
*
* @param s
* @param session
*/
public SentenceExecTransaction(Session s) {
m_s = s;
public SentenceExecTransaction(Session session) {
this.session = session;
}
/**
@@ -66,7 +66,7 @@ public abstract class SentenceExecTransaction implements SentenceExec {
*/
public final int exec(final Object params) throws BasicException {
Transaction<Integer> t = new Transaction<Integer>(m_s) {
Transaction<Integer> t = new Transaction<Integer>(session) {
public Integer transact() throws BasicException{
return execInTransaction(params);
}
@@ -358,6 +358,7 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
jcboMachineScale.addItem("dialog1");
jcboMachineScale.addItem("mtind221");
jcboMachineScale.addItem("samsungesp");
jcboMachineScale.addItem("samsungesp-v2");
jcboSerialScale.addItem("COM1");
jcboSerialScale.addItem("COM2");
@@ -612,6 +613,7 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
if ("casiopd1".equals(sparam) ||
"dialog1".equals(sparam) ||
"samsungesp".equals(sparam) ||
"samsungesp-v2".equals(sparam) ||
"caspdii".equals(sparam) ||
"acompc100".equals(sparam) ||
"averyberkel6720".equals(sparam) ||
@@ -820,6 +822,7 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
if ("casiopd1".equals(sMachineScale) ||
"dialog1".equals(sMachineScale) ||
"samsungesp".equals(sMachineScale) ||
"samsungesp-v2".equals(sMachineScale) ||
"caspdii".equals(sMachineScale) ||
"acompc100".equals(sMachineScale) ||
"averyberkel6720".equals(sMachineScale) ||
@@ -2307,6 +2310,7 @@ public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelC
if ("casiopd1".equals(jcboMachineScale.getSelectedItem()) ||
"dialog1".equals(jcboMachineScale.getSelectedItem()) ||
"samsungesp".equals(jcboMachineScale.getSelectedItem()) ||
"samsungesp-v2".equals(jcboMachineScale.getSelectedItem()) ||
"caspdii".equals(jcboMachineScale.getSelectedItem())||
"acompc100".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_ID = "unicentaopos";
public static final String APP_VERSION = "5.0";
public static final String APP_VERSION = "5.0.1";
private static final LocaleResources m_resources;
@@ -61,6 +61,14 @@ public class JRootFrame extends javax.swing.JFrame implements AppMessage {
initComponents();
}
public JRootApp getRootapp() {
return m_rootapp;
}
public void setRootapp(JRootApp m_rootapp) {
this.m_rootapp = m_rootapp;
}
/**
* @param props
*/
@@ -98,6 +106,7 @@ public class JRootFrame extends javax.swing.JFrame implements AppMessage {
new JFrmConfig(props).setVisible(true); // Show the configuration window.
}
setRootapp(m_rootapp);
}
/**
@@ -58,12 +58,24 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
initComponents();
}
public JRootApp getRootapp() {
return m_rootapp;
}
public void setRootapp(JRootApp m_rootapp) {
this.m_rootapp = m_rootapp;
}
/**
*
* @param props
* @throws java.io.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_props = props;
@@ -84,21 +96,16 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, d.width, d.height);
if (isMac) {
setBounds(0, 25, d.width, d.height - 25);
}
else {
setBounds(0, 0, d.width, d.height);
}
/*
* 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");
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GraphicsDevice device = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (device.isFullScreenSupported() && !isWindows) {
if (device.isFullScreenSupported() && !isWindows && !isMac) {
setResizable(true);
addFocusListener(new FocusListener() {
@@ -121,7 +128,8 @@ public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
"Connection", JOptionPane.INFORMATION_MESSAGE);
new JFrmConfig(props).setVisible(true); // Show the configuration window.
}
}
setRootapp(m_rootapp);
}
@Override
@@ -98,7 +98,6 @@ public class StartPOS {
String hostname = config.getProperty("machine.hostname");
TicketInfo.setHostname(hostname);
applicationStarted(hostname);
String screenmode = config.getProperty("machine.screenmode");
@@ -106,6 +105,8 @@ public class StartPOS {
JRootKiosk rootkiosk = new JRootKiosk();
try {
rootkiosk.initFrame(config);
applicationStarted(hostname, rootkiosk.getRootapp());
} catch (IOException ex) {
log.error(ex.getMessage());
}
@@ -113,18 +114,25 @@ public class StartPOS {
JRootFrame rootframe = new JRootFrame();
try {
rootframe.initFrame(config);
applicationStarted(hostname, rootframe.getRootapp());
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
});
}
private static void applicationStarted(String host) {
private static void applicationStarted(String host, JRootApp jRootApp) {
new Thread(() -> {
Metrics metrics = new Metrics();
metrics.setDevice(host);
metrics.setUniCentaVersion(AppLocal.APP_VERSION);
new Application().postMetrics(metrics);
try {
Metrics metrics = new Metrics();
metrics.setDevice(host);
metrics.setUniCentaVersion(AppLocal.APP_VERSION);
Application application = new Application();
application.postMetrics(metrics);
application.startEventListener(host, jRootApp);
} catch (Exception e) {
log.error("Problem with starting the uniCenta plugin application:${}", e.getMessage());
}
}).start();
}
}
@@ -30,7 +30,6 @@ import java.util.ArrayList;
import java.util.Iterator;
/**
*
* @author JG uniCenta
*/
@Slf4j
@@ -50,120 +49,158 @@ public abstract class BasicTicket implements PrintItem {
*
*/
protected int m_iBodyHeight;
/** Creates a new instance of AbstractTicket */
public BasicTicket() {
// JG 16 May 12 use diamond inference
m_aCommands = new ArrayList<>();
pil = null;
m_iBodyHeight = 0;
}
/**
*
* Creates a new instance of AbstractTicket
*/
public BasicTicket() {
// JG 16 May 12 use diamond inference
m_aCommands = new ArrayList<>();
pil = null;
m_iBodyHeight = 0;
}
/**
* @return
*/
protected abstract Font getBaseFont();
/**
*
* @return
*/
protected abstract int getFontHeight();
/**
*
* @return
*/
protected abstract double getImageScale();
/**
*
* @return
*/
@Override
public int getHeight() {
return m_iBodyHeight;
}
public int getHeight() {
return m_iBodyHeight;
}
/**
*
* @param g2d
* @param x
* @param y
* @param width
*/
@Override
public void draw(Graphics2D g2d, int x, int y, int width) {
public void draw(Graphics2D g2d, int x, int y, int width) {
int currenty = y;
for (PrintItem pi : m_aCommands) {
pi.draw(g2d, x, currenty, width);
currenty += pi.getHeight();
}
}
int currenty = y;
for (PrintItem pi : m_aCommands) {
pi.draw(g2d, x, currenty, width);
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
*/
public java.util.List<PrintItem> getCommands() {
return m_aCommands;
}
return m_aCommands;
}
// INTERFAZ PRINTER 2
// INTERFAZ PRINTER 2
/**
*
* @param image
*/
public void printImage(BufferedImage image) {
public void printImage(BufferedImage image) {
PrintItem pi = new PrintItemImage(image, getImageScale());
m_aCommands.add(pi);
m_iBodyHeight += pi.getHeight();
}
PrintItem pi = new PrintItemImage(image, getImageScale());
m_aCommands.add(pi);
m_iBodyHeight += pi.getHeight();
}
/**
*
* @param type
* @param position
* @param code
*/
public void printBarCode(String type, String position, String code) {
PrintItem pi = new PrintItemBarcode(type, position, code, getImageScale());
m_aCommands.add(pi);
m_iBodyHeight += pi.getHeight();
}
PrintItem pi = new PrintItemBarcode(type, position, code, getImageScale());
m_aCommands.add(pi);
m_iBodyHeight += pi.getHeight();
}
/**
*
* @param iTextSize
*/
public void beginLine(int iTextSize) {
pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight());
}
pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight());
}
/**
*
* @param iStyle
* @param sText
*/
public void printText(int iStyle, String sText) {
if (pil != null) {
pil.addText(iStyle, sText);
}
}
if (pil != null) {
pil.addText(iStyle, sText);
}
}
/**
*
*/
public void endLine() {
if (pil != null) {
m_aCommands.add(pil);
m_iBodyHeight += pil.getHeight();
pil = null;
}
}
}
if (pil != null) {
m_aCommands.add(pil);
m_iBodyHeight += pil.getHeight();
pil = null;
}
}
}
@@ -70,4 +70,12 @@ public class PrintItemImage implements PrintItem {
public int getHeight() {
return (int) (image.getHeight() * scale);
}
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage image) {
this.image = image;
}
}
@@ -56,6 +56,9 @@ public class DeviceScale {
case "samsungesp":
m_scale = new ScaleSamsungEsp(sScaleParam1);
break;
case "samsungesp-v2":
m_scale = new ScaleSamsungEspV2(sScaleParam1);
break;
case "caspdii":
m_scale = new ScaleCASPDII(sScaleParam1);
break;
@@ -0,0 +1,95 @@
// 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 int ticketstatus;
private static String Hostname;
private static String hostname;
public static void setHostname(String name) {
Hostname=name;
hostname =name;
}
public static String getHostname() {
return Hostname;
return hostname;
}
/** Creates new TicketModel */
@@ -19,6 +19,7 @@
package com.unicenta.pos.ticket;
import com.google.gson.Gson;
import com.unicenta.basic.BasicException;
import com.unicenta.data.loader.DataRead;
import com.unicenta.data.loader.DataWrite;
@@ -40,6 +41,12 @@ public class TicketLineInfo implements SerializableWrite, SerializableRead, Seri
private String m_sTicket;
private int m_iLine;
private double multiply;
@Override
public String toString() {
return new Gson().toJson(this);
}
private double price;
private TaxInfo tax;
private Properties attributes;
@@ -153,7 +153,7 @@ public final class VoucherEditor extends javax.swing.JPanel implements EditorRec
} else switch (m_jStatus.getText()) {
case "A":
jLblStatus.setIcon(new javax.swing.ImageIcon(getClass()
.getResource("/com/unicenta/images/OK.png")));
.getResource("/com/unicenta/images/ok.png")));
m_jNumber.setEnabled(true);
m_jAmount.setEnabled(true);
m_jCustomer.setEnabled(true);
@@ -0,0 +1,7 @@
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,6 +44,15 @@ COMMIT;
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated';
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
DELETE FROM roles WHERE id = '0';
INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} );
@@ -44,6 +44,14 @@ COMMIT;
UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated';
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
DELETE FROM roles WHERE id = '0';
@@ -21,7 +21,3 @@
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// **************************************************************************
import uk.co.pos_apps.PosApps;
PosApps.createCustomer(device, customer);
@@ -21,7 +21,3 @@
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// **************************************************************************
import uk.co.pos_apps.PosApps;
PosApps.deleteCustomer(device, customer);
@@ -21,7 +21,3 @@
// You should have received a copy of the GNU General Public License
// 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++){
line = ticket.getLine(i);
if (line.getProperty("product.printer")!=null) {
if (line.getProperty("product.printer")!=null && line.getProperty("ticket.updated")!=null) {
if (line.getProperty("product.printer").equals("1")) {
if((printedP1 == false) && line.getProperty("ticket.updated").equals("true")) {
@@ -36,15 +36,16 @@ if (index >= 0) {
sdiscount = Formats.PERCENT.formatValue((discountrate));
for (int number= 0; number < ticket.getLinesCount(); number++) {
line = ticket.getLine(number);
ticket.setLine(number,
new TicketLineInfo(
line.getProductID(),
line.getProductName() + " - Item Discount @ " + sdiscount,
line.getProductTaxCategoryID(),
line.getProductPrinter(),
line.getMultiply(),
line.getNewPrice() - (double)Math.abs(line.getNewPrice() * discountrate * 100) /100,
line.getTaxInfo()));
TicketLineInfo ticketLineInfo = new TicketLineInfo(
line.getProductID(),
line.getProductName() + " - Item Discount @ " + sdiscount,
line.getProductTaxCategoryID(),
line.getProductPrinter(),
line.getMultiply(),
line.getNewPrice() - (double)Math.abs(line.getNewPrice() * discountrate * 100) /100,
line.getTaxInfo());
ticketLineInfo.setTicketUpdated("ticket.updated", "true");
ticket.setLine(number,ticketLineInfo);
}
} else {
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.emptynumber=Number cannot be empty
message.enterbuyprice=Enter new Buy Price
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.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.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.ibuttonnotfound=No iButton adapter found. Key fobs will be disabled.
@@ -0,0 +1,95 @@
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
@@ -0,0 +1,35 @@
{
"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
}
@@ -0,0 +1,23 @@
{
"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
}