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