// barcode of a customers card
try {
CustomerInfoExt newcustomer = dlSales.findCustomerExt(sCode);
if (newcustomer == null) {
Toolkit.getDefaultToolkit().beep();
new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocustomer")).show(this);
} else {
m_oTicket.setCustomer(newcustomer);
m_jTicketId.setText(m_oTicket.getName(m_oTicketExt));
}
} catch (BasicException e) {
Toolkit.getDefaultToolkit().beep();
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();