From fd1290c9213236dfe162b564913a508f857edb9f Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Fri, 28 Nov 2008 18:33:49 +0000 Subject: [PATCH] [2093355 ] Small bugs in OpenXpertya POS merging to branches/stable as requested by Pirate King who loves burnt chickens. --- client/src/org/compiere/pos/SubCheckout.java | 55 +++++++++++++++---- .../src/org/compiere/pos/SubCurrentLine.java | 52 ++++++++++++------ .../src/org/compiere/pos/SubFunctionKeys.java | 6 +- client/src/org/compiere/pos/SubLines.java | 2 + 4 files changed, 82 insertions(+), 33 deletions(-) diff --git a/client/src/org/compiere/pos/SubCheckout.java b/client/src/org/compiere/pos/SubCheckout.java index 34fd444b1c..6469f38f78 100644 --- a/client/src/org/compiere/pos/SubCheckout.java +++ b/client/src/org/compiere/pos/SubCheckout.java @@ -308,23 +308,54 @@ public class SubCheckout extends PosSubPanel implements ActionListener * *Copyright � ConSerTi */ public void processOrder() - { - + { p_posPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MOrder order = p_posPanel.f_curLine.getOrder(); if (order != null) - if (order.getDocStatus().equals("DR")) + // check if order completed OK + if (order.getDocStatus().equals("DR") ) { order.setDocAction(DocAction.ACTION_Complete); - order.processIt(DocAction.ACTION_Complete); - order.save(); - - order = null; - p_posPanel.newOrder(); - f_cashGiven.setValue(Env.ZERO); + try + { + if (order.processIt(DocAction.ACTION_Complete) ) + { + order.save(); + } + else + { + log.info( "SubCheckout - processOrder FAILED"); + p_posPanel.f_status.setStatusLine("Order can not be completed."); + } + } + catch (Exception e) + { + log.severe("Order can not be completed - " + e.getMessage()); + p_posPanel.f_status.setStatusLine("Error when processing order."); + } + finally + { // When order failed convert it back to draft so it can be processed + if( order.getDocStatus().equals("IN") ) + { + order.setDocStatus("DR"); + } + else if( order.getDocStatus().equals("CO") ) + { + order = null; + p_posPanel.newOrder(); + f_cashGiven.setValue(Env.ZERO); + log.info( "SubCheckout - processOrder OK"); + p_posPanel.f_status.setStatusLine("Order completed."); + } + else + { + log.info( "SubCheckout - processOrder - unrecognized DocStatus"); + p_posPanel.f_status.setStatusLine("Orden was not completed correctly."); + } + } // try-finally } p_posPanel.setCursor(Cursor.getDefaultCursor()); - } + } // processOrder /** * Print Ticket @@ -373,8 +404,8 @@ public class SubCheckout extends PosSubPanel implements ActionListener BigDecimal total = new BigDecimal(0); if (order != null) total = order.getGrandTotal(); - double vuelta = given.doubleValue() - total.doubleValue(); - f_cashReturn.setValue(new BigDecimal(vuelta)); + double cashReturn = given.doubleValue() - total.doubleValue(); + f_cashReturn.setValue(new BigDecimal(cashReturn)); } } diff --git a/client/src/org/compiere/pos/SubCurrentLine.java b/client/src/org/compiere/pos/SubCurrentLine.java index c870c763e3..6c10a55131 100644 --- a/client/src/org/compiere/pos/SubCurrentLine.java +++ b/client/src/org/compiere/pos/SubCurrentLine.java @@ -34,6 +34,7 @@ import org.compiere.util.*; * *Basado en Codigo Original Modificado, Revisado y Optimizado de: * *Copyright � Jorg Janke * @version $Id: SubCurrentLine.java,v 1.3 2004/07/24 04:31:52 jjanke Exp $ + * red1 - [2093355 ] Small bugs in OpenXpertya POS */ public class SubCurrentLine extends PosSubPanel implements ActionListener { /** @@ -227,9 +228,9 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener { * * @param qty */ - public void setQty(BigDecimal price) { - f_quantity.setValue(price); - } // setPrice + public void setQty(BigDecimal qty) { + f_quantity.setValue(qty); + } // setQty /** * Get Qty @@ -238,7 +239,7 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener { */ public BigDecimal getQty() { return (BigDecimal) f_quantity.getValue(); - } // getPrice + } // getQty /*************************************************************************** * New Line @@ -282,6 +283,7 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener { if (numLineas > row) { //delete line from order + lineas[row].setQtyReserved(Env.ZERO); //red1 - [2093355 ] Small bugs in OpenXpertya POS lineas[row].delete(true); for (int i = row; i < (numLineas - 1); i++) lineas[i] = lineas[i + 1]; @@ -437,31 +439,45 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener { if (!order.getDocStatus().equals("DR")) return null; //add new line or increase qty - MOrderLine[] lineas = order.getLines(); - int numLineas = lineas.length; - for (int i = 0; i < numLineas; i++) + + // catch Exceptions at order.getLines() + int numLineas = 0; + MOrderLine[] lineas = null; + try { - if (lineas[i].getM_Product_ID() == product.getM_Product_ID()) + lineas = order.getLines(); + numLineas = lineas.length; + for (int i = 0; i < numLineas; i++) { - //increase qty - double current = lineas[i].getQtyEntered().doubleValue(); - double toadd = QtyOrdered.doubleValue(); - double total = current + toadd; - lineas[i].setQty(new BigDecimal(total)); - lineas[i].setPrice(); // sets List/limit - lineas[i].save(); - return lineas[i]; + if (lineas[i].getM_Product_ID() == product.getM_Product_ID()) + { + //increase qty + double current = lineas[i].getQtyEntered().doubleValue(); + double toadd = QtyOrdered.doubleValue(); + double total = current + toadd; + lineas[i].setQty(new BigDecimal(total)); + lineas[i].setPrice(); // sets List/limit + lineas[i].save(); + return lineas[i]; + } } } - //create new line + catch (Exception e) + { + log.severe("Order lines cannot be created - " + e.getMessage()); + } + + //create new line MOrderLine line = new MOrderLine(order); line.setProduct(product); line.setQty(QtyOrdered); + line.setPrice(); // sets List/limit line.setPrice(PriceActual); line.save(); return line; - } // getLine + + } // createLine /** * @param m_c_order_id diff --git a/client/src/org/compiere/pos/SubFunctionKeys.java b/client/src/org/compiere/pos/SubFunctionKeys.java index 369d0cefd9..0b25eb2268 100644 --- a/client/src/org/compiere/pos/SubFunctionKeys.java +++ b/client/src/org/compiere/pos/SubFunctionKeys.java @@ -65,8 +65,8 @@ public class SubFunctionKeys extends PosSubPanel implements ActionListener if (fKeys.get_ID() == 0) return; - int COLUMNS = 3; // Min Columns - int ROWS = 6; // Min Rows + int COLUMNS = 4; // Min Columns + int ROWS = 5; // Min Rows m_keys = fKeys.getKeys(false); int noKeys = m_keys.length; int rows = Math.max (((noKeys-1) / COLUMNS) + 1, ROWS); @@ -106,7 +106,7 @@ public class SubFunctionKeys extends PosSubPanel implements ActionListener button.setFocusable(false); content.add (button); } - content.setPreferredSize(new Dimension(cols*70, rows*50)); + content.setPreferredSize(new Dimension(cols*150, rows*50)); add (content); } // init diff --git a/client/src/org/compiere/pos/SubLines.java b/client/src/org/compiere/pos/SubLines.java index 2dd9cbe671..9172bb94bb 100644 --- a/client/src/org/compiere/pos/SubLines.java +++ b/client/src/org/compiere/pos/SubLines.java @@ -214,6 +214,7 @@ public class SubLines extends PosSubPanel implements ActionListener if (row < 0) row = 0; m_table.getSelectionModel().setSelectionInterval(row, row); + return; } else if ("Next".equalsIgnoreCase(e.getActionCommand())) { @@ -225,6 +226,7 @@ public class SubLines extends PosSubPanel implements ActionListener if (row >= rows) row = rows - 1; m_table.getSelectionModel().setSelectionInterval(row, row); + return; } // Delete else if (action.equals("Delete"))