new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocustomer"), e).show(this);
}
stateToZero();
} else if (sCode.length() == 13 && sCode.startsWith("250")) {
// barcode of the other machine
ProductInfoExt oProduct = new ProductInfoExt(); // Es un ticket
oProduct.setReference(null); // para que no se grabe
oProduct.setCode(sCode);
oProduct.setName("Ticket " + sCode.substring(3, 7));
oProduct.setPriceSell(Double.parseDouble(sCode.substring(7, 12)) / 100);
oProduct.setTaxCategoryID(((TaxCategoryInfo) taxcategoriesmodel.getSelectedItem()).getID());
// Se anade directamente una unidad con el precio y todo
addTicketLine(oProduct, 1.0, includeTaxes(oProduct.getTaxCategoryID(), oProduct.getPriceSell()));
} else if (sCode.length() == 13 && sCode.startsWith("210")) {
// barcode of a weigth product
incProductByCodePrice(sCode.substring(0, 7), Double.parseDouble(sCode.substring(7, 12)) / 100);
} else {
incProductByCode(sCode);
}
} else {
Toolkit.getDefaultToolkit().beep();
}
} else {
// otro caracter
// Esto es para el codigo de barras...
m_sBarcode.append(cTrans);
// Esto es para el los productos normales...
if (cTrans == '\u007f') {
stateToZero();
} else if ((cTrans == '0')
&& (m_iNumberStatus == NUMBER_INPUTZERO)) {
m_jPrice.setText("0");
} else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
&& (m_iNumberStatus == NUMBER_INPUTZERO)) {
// Un numero entero
m_jPrice.setText(Character.toString(cTrans));
m_iNumberStatus = NUMBER_INPUTINT;
m_iNumberStatusInput = NUMBERVALID;
} else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
&& (m_iNumberStatus == NUMBER_INPUTINT)) {
// Un numero entero
m_jPrice.setText(m_jPrice.getText() + cTrans);
} else if (cTrans == '.' && m_iNumberStatus == NUMBER_INPUTZERO) {
m_jPrice.setText("0.");
m_iNumberStatus = NUMBER_INPUTZERODEC;
} else if (cTrans == '.' && m_iNumberStatus == NUMBER_INPUTINT) {
m_jPrice.setText(m_jPrice.getText() + ".");
m_iNumberStatus = NUMBER_INPUTDEC;
} else if ((cTrans == '0')
&& (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) {
// Un numero decimal
m_jPrice.setText(m_jPrice.getText() + cTrans);
} else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
&& (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) {
// Un numero decimal
m_jPrice.setText(m_jPrice.getText() + cTrans);
m_iNumberStatus = NUMBER_INPUTDEC;
m_iNumberStatusInput = NUMBERVALID;
} else if (cTrans == '*'
&& (m_iNumberStatus == NUMBER_INPUTINT || m_iNumberStatus == NUMBER_INPUTDEC)) {
m_jPor.setText("x");
m_iNumberStatus = NUMBER_PORZERO;
} else if (cTrans == '*'
&& (m_iNumberStatus == NUMBER_INPUTZERO || m_iNumberStatus == NUMBER_INPUTZERODEC)) {
m_jPrice.setText("0");
m_jPor.setText("x");
m_iNumberStatus = NUMBER_PORZERO;
} else if ((cTrans == '0')
&& (m_iNumberStatus == NUMBER_PORZERO)) {
m_jPor.setText("x0");
} else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
&& (m_iNumberStatus == NUMBER_PORZERO)) {
// Un numero entero
m_jPor.setText("x" + Character.toString(cTrans));
m_iNumberStatus = NUMBER_PORINT;
m_iNumberStatusPor = NUMBERVALID;
} else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
&& (m_iNumberStatus == NUMBER_PORINT)) {
// Un numero entero
m_jPor.setText(m_jPor.getText() + cTrans);
} else if (cTrans == '.' && m_iNumberStatus == NUMBER_PORZERO) {
m_jPor.setText("x0.");
m_iNumberStatus = NUMBER_PORZERODEC;
} else if (cTrans == '.' && m_iNumberStatus == NUMBER_PORINT) {
m_jPor.setText(m_jPor.getText() + ".");
m_iNumberStatus = NUMBER_PORDEC;
} else if ((cTrans == '0')
&& (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) {
// Un numero decimal
m_jPor.setText(m_jPor.getText() + cTrans);
} else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')
&& (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) {
// Un numero decimal
m_jPor.setText(m_jPor.getText() + cTrans);
m_iNumberStatus = NUMBER_PORDEC;
m_iNumberStatusPor = NUMBERVALID;
} else if (cTrans == '\u00a7'
&& m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO) {
// Scale button pressed and a number typed as a price
if (m_App.getDeviceScale().existsScale() && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
try {
Double value = m_App.getDeviceScale().readWeight();
if (value != null) {
ProductInfoExt product = getInputProduct();
addTicketLine(product, value.doubleValue(), product.getPriceSell());
}
} catch (ScaleException e) {
Toolkit.getDefaultToolkit().beep();
new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.noweight"), e).show(this);
stateToZero();
}
} else {
// No existe la balanza;
Toolkit.getDefaultToolkit().beep();
}
} else if (cTrans == '\u00a7'
&& m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {
// Scale button pressed and no number typed.
int i = m_ticketlines.getSelectedIndex();
if (i < 0){
Toolkit.getDefaultToolkit().beep();
} else if (m_App.getDeviceScale().existsScale()) {
try {
Double value = m_App.getDeviceScale().readWeight();
if (value != null) {
TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i));
newline.setMultiply(value.doubleValue());
newline.setPrice(Math.abs(newline.getPrice()));
paintTicketLine(i, newline);
}
} catch (ScaleException e) {
// Error de pesada.
Toolkit.getDefaultToolkit().beep();
new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.noweight"), e).show(this);
stateToZero();
}
} else {
// No existe la balanza;
Toolkit.getDefaultToolkit().beep();
}
// Add one product more to the selected line
} else if (cTrans == '+'
&& m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {
int i = m_ticketlines.getSelectedIndex();
if (i < 0){
Toolkit.getDefaultToolkit().beep();
} else {
TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i));
//If it's a refund + button means one unit less
if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND){
newline.setMultiply(newline.getMultiply() - 1.0);
paintTicketLine(i, newline);
}
else {
// add one unit to the selected line
newline.setMultiply(newline.getMultiply() + 1.0);
paintTicketLine(i, newline);
}
}
// Delete one product of the selected line
} else if (cTrans == '-'
&& m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO
&& m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
int i = m_ticketlines.getSelectedIndex();
if (i < 0){
Toolkit.getDefaultToolkit().beep();
} else {
TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i));
//If it's a refund - button means one unit more
if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND){
newline.setMultiply(newline.getMultiply() + 1.0);
if (newline.getMultiply() >= 0) {
removeTicketLine(i);
} else {
paintTicketLine(i, newline);
}
} else {
// substract one unit to the selected line
newline.setMultiply(newline.getMultiply() - 1.0);
if (newline.getMultiply() <= 0.0) {
removeTicketLine(i); // elimino la linea
} else {
paintTicketLine(i, newline);
}
}
}
// Set n products to the selected line
} else if (cTrans == '+'
&& m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERVALID) {
int i = m_ticketlines.getSelectedIndex();
if (i < 0){
Toolkit.getDefaultToolkit().beep();
} else {
double dPor = getPorValue();
TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i));
if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) {
newline.setMultiply(-dPor);
newline.setPrice(Math.abs(newline.getPrice()));
paintTicketLine(i, newline);
} else {
newline.setMultiply(dPor);
newline.setPrice(Math.abs(newline.getPrice()));
paintTicketLine(i, newline);
}
}
// Set n negative products to the selected line
} else if (cTrans == '-'
&& m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERVALID
&& m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
int i = m_ticketlines.getSelectedIndex();
if (i < 0){
Toolkit.getDefaultToolkit().beep();
} else {
double dPor = getPorValue();
TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i));
if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_NORMAL) {
newline.setMultiply(dPor);
newline.setPrice(-Math.abs(newline.getPrice()));
paintTicketLine(i, newline);
}
}
// Anadimos 1 producto
} else if (cTrans == '+'
&& m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO
&& m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
ProductInfoExt product = getInputProduct();
addTicketLine(product, 1.0, product.getPriceSell());
// Anadimos 1 producto con precio negativo
} else if (cTrans == '-'
&& m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO
&& m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
ProductInfoExt product = getInputProduct();
addTicketLine(product, 1.0, -product.getPriceSell());
// Anadimos n productos
} else if (cTrans == '+'
&& m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERVALID
&& m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
ProductInfoExt product = getInputProduct();
addTicketLine(product, getPorValue(), product.getPriceSell());
// Anadimos n productos con precio negativo ?
} else if (cTrans == '-'
&& m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERVALID
&& m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) {
ProductInfoExt product = getInputProduct();
addTicketLine(product, getPorValue(), -product.getPriceSell());
// Totals() Igual;
} else if (cTrans == ' ' || cTrans == '=') {
if (m_oTicket.getLinesCount() > 0) {