* [ 1639249 ] Complete the POS implementation

Integration of openXpertya code, not fully functional yet.
This commit is contained in:
Heng Sin Low 2007-02-16 09:24:37 +00:00
parent 5409500d1d
commit 6a976b51dd
15 changed files with 1706 additions and 329 deletions

View File

@ -0,0 +1,550 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program 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 this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.pos;
import java.math.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.border.*;
import org.compiere.swing.*;
import org.compiere.apps.*;
import org.compiere.grid.ed.*;
import org.compiere.model.*;
import org.compiere.util.*;
/**
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Jose A.Gonzalez, Conserti.
*
* @version $Id: CashSubFunctions.java,v 0.9 $
*
* @Colaborador $Id: Consultoria y Soporte en Redes y Tecnologias de la Informacion S.L.
*
*/
public class CashSubFunctions extends PosSubPanel implements ActionListener, InputMethodListener
{
/**
* Constructor
*/
public CashSubFunctions (PosPanel posPanel)
{
super(posPanel);
} // PosQueryProduct
private CButton f_displayInitialChange = null;
private CButton f_inputsOutputs = null;
private CButton f_tickets = null;
private CButton f_closingCash = null;
private CButton f_displayCashScrutiny = null;
private CButton f_pos = null;
private CPanel c;
// for initial change
private CPanel cInitial;
private CLabel l_PreviousChange = null;
private VNumber v_PreviousChange;
private CLabel l_change = null;
private VNumber v_change;
private CButton f_change = null;
// for cash scrutiny
private CPanel cScrutiny;
private CLabel l_previousBalance = null;
private VNumber v_previousBalance;
private CLabel l_ActualBalance = null;
private VNumber v_ActualBalance;
private CLabel l_difference = null;
private VNumber v_difference;
private CButton f_calculateDifference = null;
private CPanel panel;
private CScrollPane centerScroll;
private ConfirmPanel confirm;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubCheckout.class);
/**
* Set up Panel
*/
protected void init()
{
setLayout(new BorderLayout(2,6));
setVisible(false);
// North
panel = new CPanel(new GridBagLayout());
add (panel, BorderLayout.CENTER);
panel.setBorder(new TitledBorder(Msg.getMsg(p_ctx, "Cash Functions")));
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = PosSubPanel.INSETS2;
//
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.CENTER;
gbc.weightx = .3;
gbc.weighty = 0.05;
//******************** Main buttons **********************************
f_displayInitialChange = createButtonAction("InitialChange", null);
f_displayInitialChange.setText("Initial Change");
f_displayInitialChange.setActionCommand("displayInitialChange");
f_displayInitialChange.setMaximumSize(new Dimension(160,35));
f_displayInitialChange.setMinimumSize(new Dimension(160,35));
f_displayInitialChange.setPreferredSize(new Dimension(160,35));
panel.add (f_displayInitialChange, gbc);
//
f_closingCash = createButtonAction("InitialChange", null);
f_closingCash.setText("Cash Closing");
f_closingCash.setActionCommand("CashClosing");
f_closingCash.setPreferredSize(new Dimension(160,35));
f_closingCash.setMaximumSize(new Dimension(160,35));
f_closingCash.setMinimumSize(new Dimension(160,35));
gbc.gridy = 1;
panel.add (f_closingCash, gbc);
//
f_displayCashScrutiny = createButtonAction("Scrutiny", null);
f_displayCashScrutiny.setText("Cash Scrutiny");
f_displayCashScrutiny.setActionCommand("displayCashScrutiny");
f_displayCashScrutiny.setPreferredSize(new Dimension(160,35));
f_displayCashScrutiny.setMaximumSize(new Dimension(160,35));
f_displayCashScrutiny.setMinimumSize(new Dimension(160,35));
gbc.gridy = 2;
panel.add (f_displayCashScrutiny, gbc);
//
f_inputsOutputs = createButtonAction("Inputs", null);
f_inputsOutputs.setText("Inputs and Outputs");
f_inputsOutputs.setActionCommand("InputsOutputs");
f_inputsOutputs.setPreferredSize(new Dimension(160,35));
f_inputsOutputs.setMaximumSize(new Dimension(160,35));
f_inputsOutputs.setMinimumSize(new Dimension(160,35));
gbc.gridy = 3;
panel.add (f_inputsOutputs, gbc);
//
f_tickets = createButtonAction("Tickets", null);
f_tickets.setText("Tickets");
f_tickets.setPreferredSize(new Dimension(160,35));
f_tickets.setMaximumSize(new Dimension(160,35));
f_tickets.setMinimumSize(new Dimension(160,35));
gbc.gridy = 4;
panel.add (f_tickets, gbc);
//
f_pos = createButtonAction("End", null);
f_pos.setText("POS");
f_pos.setPreferredSize(new Dimension(160,35));
f_pos.setMaximumSize(new Dimension(160,35));
f_pos.setMinimumSize(new Dimension(160,35));
gbc.gridy = 5;
panel.add (f_pos, gbc);
//*************************** Panel to put buttons *************************
gbc.gridx = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridy = 0;
gbc.gridheight = 5;
c = new CPanel(new GridBagLayout());
c.setBorder(new TitledBorder(""));
c.setMaximumSize(new Dimension(400,400));
c.setMinimumSize(new Dimension(400,400));
c.setPreferredSize(new Dimension(400,400));
panel.add (c, gbc);
//*************************** Panel for initial change *************************
gbc.gridx = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridy = 0;
gbc.gridheight = 5;
cInitial = new CPanel(new GridBagLayout());
cInitial.setBorder(new TitledBorder("Initial Change"));
cInitial.setVisible(false);
panel.add (cInitial, gbc);
GridBagConstraints gbc0 = new GridBagConstraints();
gbc0.insets = INSETS2;
gbc0.anchor = GridBagConstraints.CENTER;
//
gbc0.gridx = 0;
gbc0.gridy = 0;
l_PreviousChange = new CLabel("Previous Change");
cInitial.add (l_PreviousChange, gbc0);
gbc0.gridx = 1;
v_PreviousChange = new VNumber("PreviousChange", false, true, false, DisplayType.Amount, "PreviousChange");
v_PreviousChange.setColumns(10, 25);
cInitial.add(v_PreviousChange, gbc0);
v_PreviousChange.setValue(Env.ZERO);
//
gbc0.gridx = 0;
gbc0.gridy = 1;
l_change = new CLabel("Initial Change");
cInitial.add (l_change, gbc0);
gbc0.gridx = 1;
v_change = new VNumber("Change", false, false, true, DisplayType.Amount, "Change");
v_change.setColumns(10, 25);
cInitial.add(v_change, gbc0);
v_change.setValue(Env.ZERO);
gbc0.gridy = 2;
gbc0.gridx = 0;
gbc0.gridwidth = 2;
//gbc0.fill = GridBagConstraints.HORIZONTAL;
f_change = createButtonAction("InitialChange", null);
f_change.setText("Save Change");
f_change.setActionCommand("saveChange");
cInitial.add (f_change, gbc0);
f_change.setPreferredSize(new Dimension(160,35));
f_change.setMaximumSize(new Dimension(160,35));
f_change.setMinimumSize(new Dimension(160,35));
cInitial.setMaximumSize(new Dimension(400,400));
cInitial.setMinimumSize(new Dimension(400,400));
cInitial.setPreferredSize(new Dimension(400,400));
//****************************** Panel for cash scrutiniy ************************
gbc.gridx = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridy = 0;
gbc.gridheight = 5;
// gbc.weightx = .7;
cScrutiny = new CPanel(new GridBagLayout());
cScrutiny.setBorder(new TitledBorder("Cash Scrutiny"));
cScrutiny.setVisible(false);
panel.add (cScrutiny, gbc);
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.insets = INSETS2;
gbc1.anchor = GridBagConstraints.CENTER;
//
gbc1.gridx = 0;
gbc1.gridy = 0;
l_previousBalance = new CLabel("Previous Balance");
cScrutiny.add (l_previousBalance, gbc1);
gbc1.gridx = 1;
v_previousBalance = new VNumber("PreviousBalance", false, true, false, DisplayType.Amount, "PreviousBalance");
v_previousBalance.setColumns(10, 25);
cScrutiny.add(v_previousBalance, gbc1);
v_previousBalance.setValue(Env.ZERO);
//
gbc1.gridx = 0;
gbc1.gridy = 1;
l_ActualBalance = new CLabel("Actual Balance");
cScrutiny.add (l_ActualBalance, gbc1);
gbc1.gridx = 1;
v_ActualBalance = new VNumber("ActualBalance", false, false, true, DisplayType.Amount, "ActualBalance");
v_ActualBalance.setColumns(10, 25);
v_ActualBalance.addActionListener(this);
v_ActualBalance.addInputMethodListener(this);
cScrutiny.add(v_ActualBalance, gbc1);
v_ActualBalance.setValue(Env.ZERO);
//
gbc1.gridx = 0;
gbc1.gridy = 2;
l_difference = new CLabel("Difference");
cScrutiny.add (l_difference, gbc1);
gbc1.gridx = 1;
v_difference = new VNumber("Difference", false, true, false, DisplayType.Amount, "Difference");
v_difference.setColumns(10, 25);
cScrutiny.add(v_difference, gbc1);
v_difference.setValue(Env.ZERO);
//
gbc1.gridx = 0;
gbc1.gridy = 4;
gbc1.gridwidth = 2;
gbc1.fill = GridBagConstraints.HORIZONTAL;
f_calculateDifference = createButtonAction("InitialChange", null);
f_calculateDifference.setText("Annotate Difference");
f_calculateDifference.setActionCommand("AnnotateDiference");
cScrutiny.add (f_calculateDifference, gbc1);
cScrutiny.setMaximumSize(new Dimension(400,400));
cScrutiny.setMinimumSize(new Dimension(400,400));
cScrutiny.setPreferredSize(new Dimension(400,400));
} // init
/**
* Get GridBagConstraints
* @return constraints
*/
protected GridBagConstraints getGridBagConstraints ()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = GridBagConstraints.RELATIVE;
gbc.gridwidth = 2; // GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 0.5;
gbc.weighty = 0.5;
return gbc;
} // getGridBagConstraints
/**
* Dispose
*/
public void dispose()
{
removeAll();
panel = null;
centerScroll = null;
confirm = null;
} // dispose
/**
* Set Visible
* @param aFlag visible
*/
public void setVisible (boolean aFlag)
{
super.setVisible (aFlag);
} // setVisible
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info("PosCashSubFunctions - actionPerformed: " + action);
// to display panel with initial changenicial
if (action.equals("displayInitialChange"))
{
cmd_displayInitialChange();
}
// to display panel with cash closing
else if (action.equals("CashClosing"))
{
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
MQuery query = new MQuery(MCash.Table_Name);
query.addRestriction("C_Cash_ID", MQuery.EQUAL, cash.getC_Cash_ID());
//TODO
//AEnv.openWindow(MCash.Table_ID, query, false);
}
// to open window with inputs and outputs of cash
else if (action.equals("InputsOutputs"))
{
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
//TODO: new method added by openxpertya
//AEnv.detailedZoom(MCash.Table_ID, cash.getC_Cash_ID(), false);
}
else if (action.equals("Tickets"))
{
MQuery query = new MQuery(MOrder.Table_Name);
query.addRestriction("C_DocTypeTarget_ID", MQuery.EQUAL, p_pos.getC_DocType_ID());
//TODO: openxpertya added ad_window_id to c_pos
//AEnv.openWindow(p_pos.getAD_Window_ID(), query, true);
}
// Cash (Payment)
else if (action.equals("displayCashScrutiny"))
{
cmd_displayCashScrutiny();
}
else if (action.equals("End"))
{
p_posPanel.closeQuery(p_posPanel.f_cashfunctions);
}
else if (action.equals("saveChange"))
{
cmd_saveChange();
}
else if (action.equals("AnnotateDifference"))
{
cmd_calculateDifference();
cmd_annotateDifference();
}
else if (e.getSource() == v_ActualBalance)
cmd_calculateDifference();
} // actionPerformed
/**
* Desplegar panel de Cambio Inicial
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
private void cmd_displayInitialChange()
{
cScrutiny.setVisible(false);
c.setVisible(false);
cInitial.setVisible(true);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
if (cash != null)
{
v_PreviousChange.setValue(cash.getEndingBalance());
v_change.setValue(cash.getEndingBalance());
}
else
log.severe("No Cash");
}
/**
* Desplegar panel de Scrutiny de caja
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
private void cmd_displayCashScrutiny()
{
cInitial.setVisible(false);
c.setVisible(false);
cScrutiny.setVisible(true);
// calculate total until the moment and shows it in scrutiny panel
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
v_previousBalance.setValue(cash.getEndingBalance());
}
/**
* Save the initial change of the cash
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
private void cmd_saveChange()
{
MCashBook cashBook = new MCashBook(p_ctx, p_pos.getC_CashBook_ID(), null);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_ctx, /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
BigDecimal initialChange = (BigDecimal)v_change.getValue();
if (cash != null && cash.get_ID() != 0 && initialChange.compareTo(cash.getEndingBalance()) != 0)
{
MCashLine cl = new MCashLine (cash);
cl.setCashType(MCashLine.CASHTYPE_Difference);
cl.setAmount(initialChange.subtract(cash.getEndingBalance()));
cl.setDescription("Initial Change Before: " + cash.getEndingBalance() + " Now: " + initialChange);
cl.save();
}
v_PreviousChange.setValue(initialChange);
}
/**
* Calculate difference between previous balance and actual
* for cash scrutiny
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
private void cmd_calculateDifference()
{
// calculate difference between scrutiny of previous and actual balance
BigDecimal previousValue, actualValue;
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
v_previousBalance.setValue(cash.getEndingBalance());
previousValue = cash.getEndingBalance();
actualValue = (BigDecimal)v_ActualBalance.getValue();
v_difference.setValue(actualValue.subtract(previousValue));
}
/**
* Annotate the difference between previous balance and actual
* from cash scrutiny in the cash book
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
private void cmd_annotateDifference()
{
// calculate difference from scrutiny between previous and actual balance
BigDecimal previousValue, actualValue, difference;
previousValue = (BigDecimal)v_previousBalance.getValue();
actualValue = (BigDecimal)v_ActualBalance.getValue();
difference = actualValue.subtract(previousValue);
MCashBook cashBook = new MCashBook(p_ctx, p_pos.getC_CashBook_ID(), null);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MCash cash = MCash.get(p_ctx, /*cashBook.getAD_Org_ID(),*/ cashBook.getC_CashBook_ID(), today, null);
if (cash != null && cash.get_ID() != 0 && difference.compareTo(cash.getStatementDifference()) != 0)
{
MCashLine cl = new MCashLine (cash);
cl.setCashType(MCashLine.CASHTYPE_Difference);
cl.setAmount(difference);
cl.setDescription(Msg.translate(p_pos.getCtx(), "Cash Scrutiny -> Before: ") + previousValue + " Now: " + actualValue);
cl.save();
}
cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null);
v_previousBalance.setValue(cash.getEndingBalance());
v_ActualBalance.setValue(Env.ZERO);
v_difference.setValue(Env.ZERO);
}
/**
* calculate difference in cash scrutiny every time the cursor moves
*/
public void caretPositionChanged(InputMethodEvent event)
{
cmd_calculateDifference();
}
/**
* calculate difference between cash scrutiniy each time the actual balance text changes
*/
public void inputMethodTextChanged(InputMethodEvent event)
{
cmd_calculateDifference();
}
} // CashSubFunctions

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,120 +10,117 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import org.compiere.apps.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Keyboard Focus Manager * POS Keyboard Focus Manager
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: PosKeyboardFocusManager.java,v 1.2 2006/07/30 00:51:26 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: PosKeyboardFocusManager.java,v 1.2 2004/07/11 19:50:12 jjanke
* Exp $
*/ */
public class PosKeyboardFocusManager extends AKeyboardFocusManager public class PosKeyboardFocusManager extends DefaultKeyboardFocusManager
implements ActionListener implements ActionListener {
{
/**
* PosKeyboardFocusManager
*/
public PosKeyboardFocusManager ()
{
super ();
} // PosKeyboardFocusManager
/** FirstIn First Out List */ /**
* PosKeyboardFocusManager
*/
public PosKeyboardFocusManager() {
super();
} // PosKeyboardFocusManager
/** FirstIn First Out List */
private LinkedList<KeyEvent> m_fifo = new LinkedList<KeyEvent>(); private LinkedList<KeyEvent> m_fifo = new LinkedList<KeyEvent>();
/** Last Key Type */
private long m_lastWhen = 0; /** Last Key Type */
/** Timer */ private long m_lastWhen = 0;
private javax.swing.Timer m_timer = null;
/** Timer */
private javax.swing.Timer m_timer = null;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(PosKeyboardFocusManager.class); private static CLogger log = CLogger.getCLogger(PosKeyboardFocusManager.class);
/** /**
* Dispose * Dispose
*/ */
public void dispose() public void dispose() {
{
if (m_timer != null) if (m_timer != null)
m_timer.stop(); m_timer.stop();
m_timer = null; m_timer = null;
if (m_fifo != null) if (m_fifo != null)
m_fifo.clear(); m_fifo.clear();
m_fifo = null; m_fifo = null;
} // dispose } // dispose
/** /**
* Start Timer * Start Timer
*/ */
public void start() public void start() {
{
// Unqueue time - 200 ms // Unqueue time - 200 ms
int delay = 200; int delay = 200;
log.fine("" + delay); log.fine("PosKeyboardFocusManager.start - " + delay);
if (m_timer == null) if (m_timer == null)
m_timer = new javax.swing.Timer (delay, this); m_timer = new javax.swing.Timer(delay, this);
if (!m_timer.isRunning()) if (!m_timer.isRunning())
m_timer.start(); m_timer.start();
} // start } // start
/** /**
* Stop Timer * Stop Timer
*/ */
public void stop() public void stop() {
{ log.fine("PosKeyboardFocusManager.stop - " + m_timer);
log.fine("" + m_timer);
if (m_timer != null) if (m_timer != null)
m_timer.stop(); m_timer.stop();
} // stop } // stop
/***************************************************************************
/************************************************************************** * Dispatch Key Event - queue
* Dispatch Key Event - queue *
* @param event event * @param eevent
* @return true * event
* @return true
*/ */
public boolean dispatchKeyEvent (KeyEvent event) public boolean dispatchKeyEvent(KeyEvent event) {
{ if (event.getID() == KeyEvent.KEY_PRESSED) {
if (event.getID()==KeyEvent.KEY_PRESSED)
{
// Keyboard Repeat: 485 - then 31 // Keyboard Repeat: 485 - then 31
// log.fine( "PosKeyboardFocusManager.dispatchKeyEvent - " // log.fine( "PosKeyboardFocusManager.dispatchKeyEvent - "
// + event.getWhen() + " - " + (event.getWhen() - m_lastWhen)); // - "
// + event.getWhen() + " - " + (event.getWhen() - m_lastWhen));
m_lastWhen = event.getWhen(); m_lastWhen = event.getWhen();
} }
if (m_timer == null) if (m_timer == null)
super.dispatchKeyEvent (event); super.dispatchKeyEvent(event);
else else
m_fifo.add(event); m_fifo.add(event);
return true; return true;
} // displatchEvent } // displatchEvent
/** /**
* Action Performed - unqueue * Action Performed - unqueue
* @param e event *
* @param e
* event
*/ */
public void actionPerformed (ActionEvent e) public void actionPerformed(ActionEvent e) {
{
if (m_timer == null) if (m_timer == null)
return; return;
// log.fine( "actionPerformed - " + m_fifo.size()); // log.fine( "actionPerformed - " + m_fifo.size());
while (m_fifo.size() > 0) while (m_fifo.size() > 0) {
{ KeyEvent event = (KeyEvent) m_fifo.removeFirst();
KeyEvent event = (KeyEvent)m_fifo.removeFirst(); super.dispatchKeyEvent(event);
super.dispatchKeyEvent (event);
} }
} // actionPerformed } // actionPerformed
} // PosKeyboardFocusManager } // PosKeyboardFocusManager

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,10 +10,8 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
@ -22,18 +20,20 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
import org.compiere.swing.*;
import org.compiere.apps.*; import org.compiere.apps.*;
import org.compiere.apps.form.*; import org.compiere.apps.form.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.swing.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Point of Sales Main Window. * Point of Sales Main Window.
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: PosPanel.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: PosPanel.java,v 1.10 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class PosPanel extends CPanel public class PosPanel extends CPanel
implements FormPanel implements FormPanel
@ -44,6 +44,7 @@ public class PosPanel extends CPanel
public PosPanel() public PosPanel()
{ {
super (new GridBagLayout()); super (new GridBagLayout());
originalKeyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
m_focusMgr = new PosKeyboardFocusManager(); m_focusMgr = new PosKeyboardFocusManager();
KeyboardFocusManager.setCurrentKeyboardFocusManager(m_focusMgr); KeyboardFocusManager.setCurrentKeyboardFocusManager(m_focusMgr);
} // PosPanel } // PosPanel
@ -80,17 +81,22 @@ public class PosPanel extends CPanel
/** Checkout */ /** Checkout */
protected SubCheckout f_checkout = null; protected SubCheckout f_checkout = null;
/** Basic Keys */ /** Basic Keys */
protected SubBasicKeys f_basicKeys = null; // protected SubBasicKeys f_basicKeys = null;
/** Product Query Window */ /** Product Query Window */
protected QueryProduct f_queryProduct = null; protected QueryProduct f_queryProduct = null;
/** BPartner Query Window */ /** BPartner Query Window */
protected QueryBPartner f_queryBPartner = null; protected QueryBPartner f_queryBPartner = null;
/** Ticket Query Window */
protected QueryTicket f_queryTicket = null;
protected CashSubFunctions f_cashfunctions;
// Today's (login) date */ // Today's (login) date */
private Timestamp m_today = Env.getContextAsDate(m_ctx, "#Date"); private Timestamp m_today = Env.getContextAsDate(m_ctx, "#Date");
private KeyboardFocusManager originalKeyboardFocusManager;
/** /**
* Initialize Panel * Initialize Panel
* @param WindowNo window * @param WindowNo window
@ -98,6 +104,7 @@ public class PosPanel extends CPanel
*/ */
public void init (int WindowNo, FormFrame frame) public void init (int WindowNo, FormFrame frame)
{ {
frame.setMaximize(true);
m_SalesRep_ID = Env.getAD_User_ID(m_ctx); m_SalesRep_ID = Env.getAD_User_ID(m_ctx);
log.info("init - SalesRep_ID=" + m_SalesRep_ID); log.info("init - SalesRep_ID=" + m_SalesRep_ID);
m_WindowNo = WindowNo; m_WindowNo = WindowNo;
@ -131,6 +138,7 @@ public class PosPanel extends CPanel
if (m_focusMgr != null) if (m_focusMgr != null)
m_focusMgr.stop(); m_focusMgr.stop();
m_focusMgr = null; m_focusMgr = null;
KeyboardFocusManager.setCurrentKeyboardFocusManager(originalKeyboardFocusManager);
// //
if (f_bpartner != null) if (f_bpartner != null)
f_bpartner.dispose(); f_bpartner.dispose();
@ -139,7 +147,10 @@ public class PosPanel extends CPanel
f_salesRep.dispose(); f_salesRep.dispose();
f_salesRep = null; f_salesRep = null;
if (f_curLine != null) if (f_curLine != null)
{
f_curLine.deleteOrder();
f_curLine.dispose(); f_curLine.dispose();
}
f_curLine = null; f_curLine = null;
if (f_product != null) if (f_product != null)
f_product.dispose(); f_product.dispose();
@ -153,17 +164,23 @@ public class PosPanel extends CPanel
if (f_checkout != null) if (f_checkout != null)
f_checkout.dispose(); f_checkout.dispose();
f_checkout = null; f_checkout = null;
if (f_basicKeys != null) /* if (f_basicKeys != null)
f_basicKeys.dispose(); f_basicKeys.dispose(); removed by ConSerTi upon not appreciating its functionality
f_basicKeys = null; f_basicKeys = null;
// */ //
if (f_queryProduct != null) if (f_queryProduct != null)
f_queryProduct.dispose(); f_queryProduct.dispose();
f_queryProduct = null; f_queryProduct = null;
if (f_queryBPartner != null) if (f_queryBPartner != null)
f_queryBPartner.dispose(); f_queryBPartner.dispose();
f_queryBPartner = null; f_queryBPartner = null;
if (f_queryTicket != null)
f_queryTicket.dispose();
f_queryTicket = null;
// //
if (f_cashfunctions != null)
f_cashfunctions.dispose();
f_cashfunctions = null;
if (m_frame != null) if (m_frame != null)
m_frame.dispose(); m_frame.dispose();
m_frame = null; m_frame = null;
@ -203,9 +220,9 @@ public class PosPanel extends CPanel
f_checkout = new SubCheckout (this); f_checkout = new SubCheckout (this);
add (f_checkout, f_checkout.getGridBagConstraints()); add (f_checkout, f_checkout.getGridBagConstraints());
// //
f_basicKeys = new SubBasicKeys (this); /* f_basicKeys = new SubBasicKeys (this);
add (f_basicKeys, f_basicKeys.getGridBagConstraints()); add (f_basicKeys, f_basicKeys.getGridBagConstraints()); removed by ConSerTi upon not appreciating its functionality
*/
// -- Query // -- Query
f_queryProduct = new QueryProduct (this); f_queryProduct = new QueryProduct (this);
add (f_queryProduct, f_queryProduct.getGridBagConstraints()); add (f_queryProduct, f_queryProduct.getGridBagConstraints());
@ -213,6 +230,12 @@ public class PosPanel extends CPanel
f_queryBPartner = new QueryBPartner (this); f_queryBPartner = new QueryBPartner (this);
add (f_queryBPartner, f_queryBPartner.getGridBagConstraints()); add (f_queryBPartner, f_queryBPartner.getGridBagConstraints());
// //
f_queryTicket = new QueryTicket(this);
add (f_queryTicket, f_queryTicket.getGridBagConstraints());
//
f_cashfunctions = new CashSubFunctions(this);
add (f_cashfunctions, f_cashfunctions.getGridBagConstraints());
newOrder(); newOrder();
return true; return true;
} // dynInit } // dynInit
@ -316,11 +339,19 @@ public class PosPanel extends CPanel
*/ */
public void openQuery (CPanel panel) public void openQuery (CPanel panel)
{ {
if (panel.equals(f_cashfunctions))
{
f_bpartner.setVisible(false);
f_salesRep.setVisible(false);
f_curLine.setVisible(false);
f_product.setVisible(false);
}
f_checkout.setVisible(false); f_checkout.setVisible(false);
f_basicKeys.setVisible(false); // f_basicKeys.setVisible(false); removed by ConSerTi upon not appreciating its functionality
f_lines.setVisible(false); f_lines.setVisible(false);
f_functionKeys.setVisible(false); f_functionKeys.setVisible(false);
panel.setVisible(true); panel.setVisible(true);
} // closeQuery } // closeQuery
/** /**
@ -330,10 +361,14 @@ public class PosPanel extends CPanel
public void closeQuery (CPanel panel) public void closeQuery (CPanel panel)
{ {
panel.setVisible(false); panel.setVisible(false);
f_checkout.setVisible(true); f_bpartner.setVisible(true);
f_basicKeys.setVisible(true); f_salesRep.setVisible(true);
f_curLine.setVisible(true);
f_product.setVisible(true);
// f_basicKeys.setVisible(true); removed by ConSerTi upon not appreciating its functionality
f_lines.setVisible(true); f_lines.setVisible(true);
f_functionKeys.setVisible(true); f_functionKeys.setVisible(true);
f_checkout.setVisible(true);
} // closeQuery } // closeQuery
/************************************************************************** /**************************************************************************
@ -347,14 +382,44 @@ public class PosPanel extends CPanel
/** /**
* New Order * New Order
*
*/ */
public void newOrder() public void newOrder()
{ {
log.info( "PosPabel.newOrder"); log.info( "PosPabel.newOrder");
f_bpartner.setC_BPartner_ID(0); f_bpartner.setC_BPartner_ID(0);
f_curLine.newOrder();
f_curLine.newLine(); f_curLine.newLine();
f_product.f_name.requestFocus(); f_product.f_name.requestFocus();
updateInfo();
} // newOrder } // newOrder
/**
* Get the number of the window for the function calls that it needs
*
* @return the window number
*/
public int getWindowNo()
{
return m_WindowNo;
}
/**
* Get the properties for the process calls that it needs
*
* @return las Propiedades m_ctx
*/
public Properties getPropiedades()
{
return m_ctx;
}
public void updateInfo()
{
if (f_lines != null)
f_lines.updateTable(f_curLine.getOrder());
if (f_checkout != null)
f_checkout.displayReturn();
}
} // PosPanel } // PosPanel

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,27 +10,29 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;
import org.compiere.swing.*;
import org.compiere.apps.*; import org.compiere.apps.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Sub Panel Base Class. * POS Sub Panel Base Class.
* The Panel knows where to position itself in the POS Panel * The Panel knows where to position itself in the POS Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: PosSubPanel.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: PosSubPanel.java,v 1.3 2004/07/12 04:10:04 jjanke Exp $
*/ */
public abstract class PosSubPanel extends CPanel public abstract class PosSubPanel extends CPanel
implements ActionListener implements ActionListener

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,28 +10,30 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.event.*; import javax.swing.event.*;
import org.compiere.swing.*;
import org.compiere.apps.*; import org.compiere.apps.*;
import org.compiere.minigrid.*; import org.compiere.minigrid.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Query BPartner * POS Query BPartner
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: QueryBPartner.java,v 1.2 2006/07/30 00:51:26 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: QueryBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class QueryBPartner extends PosSubPanel public class QueryBPartner extends PosSubPanel
implements ActionListener, MouseListener, ListSelectionListener implements ActionListener, MouseListener, ListSelectionListener
@ -72,7 +74,8 @@ public class QueryBPartner extends PosSubPanel
new ColumnInfo(" ", "C_BPartner_ID", IDColumn.class), new ColumnInfo(" ", "C_BPartner_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "Value", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "Value", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Contact"), "Contact", String.class), //TODO: contact column have been remove from rv_bpartner
//new ColumnInfo(Msg.translate(Env.getCtx(), "Contact"), "Contact", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Email"), "Email", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Email"), "Email", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "Phone", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "Phone", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Postal"), "Postal", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Postal"), "Postal", String.class),
@ -238,7 +241,7 @@ public class QueryBPartner extends PosSubPanel
{ {
setResults(MBPartnerInfo.find (p_ctx, setResults(MBPartnerInfo.find (p_ctx,
f_value.getText(), f_name.getText(), f_value.getText(), f_name.getText(),
f_contact.getText(), f_email.getText(), null, f_email.getText(),
f_phone.getText(), f_city.getText())); f_phone.getText(), f_city.getText()));
return; return;
} }

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,29 +10,31 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.math.*; import java.math.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.event.*; import javax.swing.event.*;
import org.compiere.swing.*;
import org.compiere.apps.*; import org.compiere.apps.*;
import org.compiere.minigrid.*; import org.compiere.minigrid.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Query Product * POS Query Product
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: QueryProduct.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: QueryProduct.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class QueryProduct extends PosSubPanel public class QueryProduct extends PosSubPanel
implements ActionListener, MouseListener, ListSelectionListener implements ActionListener, MouseListener, ListSelectionListener

View File

@ -0,0 +1,356 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program 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 this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.pos;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import org.compiere.swing.*;
import org.compiere.apps.*;
import org.compiere.grid.ed.*;
import org.compiere.minigrid.*;
import org.compiere.util.*;
/**
* POS Query Product
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Jose A.Gonzalez, Conserti.
*
* @version $Id: QueryTicket.java,v 0.9 $
*
* @Colaborador $Id: Consultoria y Soporte en Redes y Tecnologias de la Informacion S.L.
*
*/
public class QueryTicket extends PosSubPanel
implements ActionListener, MouseListener, ListSelectionListener
{
/**
* Constructor
*/
public QueryTicket (PosPanel posPanel)
{
super(posPanel);
} // PosQueryProduct
/** The Table */
private MiniTable m_table;
private CPanel northPanel;
private CScrollPane centerScroll;
private ConfirmPanel confirm;
private CTextField f_c_order_id;
private CTextField f_documentno;
private VDate f_date;
private CButton f_up;
private CButton f_down;
private int m_c_order_id;
/** Logger */
private static CLogger log = CLogger.getCLogger(QueryProduct.class);
/** Table Column Layout Info */
private static ColumnInfo[] s_layout = new ColumnInfo[]
{
new ColumnInfo(" ", "C_Order_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "DocumentNo"), "DocumentNo", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "TotalLines"), "TotalLines", BigDecimal.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "GrandTotal"), "GrandTotal", BigDecimal.class)
};
/**
* Set up Panel
*/
protected void init()
{
setLayout(new BorderLayout(5,5));
setVisible(false);
// North
northPanel = new CPanel(new GridBagLayout());
add (northPanel, BorderLayout.NORTH);
northPanel.setBorder(new TitledBorder(Msg.getMsg(p_ctx, "Query")));
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = PosSubPanel.INSETS2;
//
gbc.gridy = 0;
gbc.gridx = GridBagConstraints.RELATIVE;
CLabel lorder_id = new CLabel(Msg.translate(p_ctx, "C_Order_ID"));
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lorder_id, gbc);
f_c_order_id = new CTextField(20);
lorder_id.setLabelFor(f_c_order_id);
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_c_order_id, gbc);
f_c_order_id.addActionListener(this);
//
CLabel ldoc = new CLabel(Msg.translate(p_ctx, "DocumentNo"));
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (ldoc, gbc);
f_documentno = new CTextField(15);
ldoc.setLabelFor(f_documentno);
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_documentno, gbc);
f_documentno.addActionListener(this);
//
gbc.gridy = 1;
CLabel ldate = new CLabel(Msg.translate(p_ctx, "DateOrdered"));
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (ldate, gbc);
f_date = new VDate();
f_date.setValue(Env.getContextAsDate(Env.getCtx(), "#Date"));
ldate.setLabelFor(f_date);
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_date, gbc);
f_date.addActionListener(this);
//
gbc.gridy = 0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = .1;
f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0));
northPanel.add(f_up, gbc);
gbc.weightx = 0;
f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
northPanel.add(f_down, gbc);
// Confirm
confirm = new ConfirmPanel (true, true, true, false, false, false, false);
add (confirm, BorderLayout.SOUTH);
confirm.addActionListener(this);
// Center
m_table = new MiniTable();
String sql = m_table.prepareTable (s_layout, "C_Order",
"C_DocTypeTarget_ID" + p_pos.getC_DocType_ID()
, false, "C_Order")
+ " ORDER BY Margin, QtyAvailable";
m_table.setRowSelectionAllowed(true);
m_table.setColumnSelectionAllowed(false);
m_table.setMultiSelection(false);
m_table.addMouseListener(this);
m_table.getSelectionModel().addListSelectionListener(this);
enableButtons();
centerScroll = new CScrollPane(m_table);
add (centerScroll, BorderLayout.CENTER);
} // init
/**
* Get GridBagConstraints
* @return constraints
*/
protected GridBagConstraints getGridBagConstraints ()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = GridBagConstraints.RELATIVE;
gbc.gridwidth = 2; // GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 0.1;
gbc.weighty = 0.5;
return gbc;
} // getGridBagConstraints
/**
* Dispose
*/
public void dispose()
{
removeAll();
northPanel = null;
centerScroll = null;
confirm = null;
m_table = null;
} // dispose
/**
* Set Visible
* @param aFlag visible
*/
public void setVisible (boolean aFlag)
{
super.setVisible (aFlag);
if (aFlag)
f_c_order_id.requestFocus();
} // setVisible
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
log.info("PosQueryProduct.actionPerformed - " + e.getActionCommand());
if ("Refresh".equals(e.getActionCommand())
|| e.getSource() == f_c_order_id || e.getSource() == f_documentno
|| e.getSource() == f_date)
{
setResults(p_ctx, f_c_order_id.getText(), f_documentno.getText(), f_date.getTimestamp());
return;
}
else if ("Reset".equals(e.getActionCommand()))
{
reset();
return;
}
else if ("Previous".equalsIgnoreCase(e.getActionCommand()))
{
int rows = m_table.getRowCount();
if (rows == 0)
return;
int row = m_table.getSelectedRow();
row--;
if (row < 0)
row = 0;
m_table.getSelectionModel().setSelectionInterval(row, row);
return;
}
else if ("Next".equalsIgnoreCase(e.getActionCommand()))
{
int rows = m_table.getRowCount();
if (rows == 0)
return;
int row = m_table.getSelectedRow();
row++;
if (row >= rows)
row = rows - 1;
m_table.getSelectionModel().setSelectionInterval(row, row);
return;
}
// Exit
close();
} // actionPerformed
/**
*
*/
public void reset()
{
f_c_order_id.setText(null);
f_documentno.setText(null);
f_date.setValue(Env.getContextAsDate(Env.getCtx(), "#Date"));
setResults(p_ctx, f_c_order_id.getText(), f_documentno.getText(), f_date.getTimestamp());
}
/**
* Set/display Results
* @param results results
*/
public void setResults (Properties ctx, String id, String doc, Timestamp date)
{
String sql = "";
try
{
sql = "SELECT o.C_Order_ID, o.DocumentNo, o.TotalLines, o.GrandTotal FROM C_Order o WHERE o.C_DocTypeTarget_ID = " + p_pos.getC_DocType_ID();
if (id != null && !id.equalsIgnoreCase(""))
sql += " AND o.C_Order_ID = " + id;
if (doc != null && !doc.equalsIgnoreCase(""))
sql += " AND o.DocumentNo = '" + doc + "'";
sql += " AND o.DateOrdered = ?";
PreparedStatement pstm = DB.prepareStatement(sql, null);
pstm.setTimestamp(1, date);
ResultSet rs = pstm.executeQuery();
m_table.loadTable(rs);
enableButtons();
}
catch(Exception e)
{
log.severe("QueryTicket.setResults: " + e + " -> " + sql);
}
} // setResults
/**
* Table selection changed
* @param e event
*/
public void valueChanged (ListSelectionEvent e)
{
if (e.getValueIsAdjusting())
return;
enableButtons();
} // valueChanged
/**
* Enable/Set Buttons and set ID
*/
private void enableButtons()
{
m_c_order_id = -1;
int row = m_table.getSelectedRow();
boolean enabled = row != -1;
if (enabled)
{
Integer ID = m_table.getSelectedRowKey();
if (ID != null)
{
m_c_order_id = ID.intValue();
}
}
confirm.getOKButton().setEnabled(enabled);
log.info("ID=" + m_c_order_id);
} // enableButtons
/**
* Mouse Clicked
* @param e event
*/
public void mouseClicked(MouseEvent e)
{
// Double click with selected row => exit
if (e.getClickCount() > 1 && m_table.getSelectedRow() != -1)
{
enableButtons();
close();
}
} // mouseClicked
public void mouseEntered (MouseEvent e) {}
public void mouseExited (MouseEvent e) {}
public void mousePressed (MouseEvent e) {}
public void mouseReleased (MouseEvent e) {}
/**
* Close.
* Set Values on other panels and close
*/
private void close()
{
log.info("C_Order_ID=" + m_c_order_id);
if (m_c_order_id > 0)
{
p_posPanel.f_curLine.setOldOrder(m_c_order_id);
}
p_posPanel.closeQuery(this);
} // close
} // PosQueryProduct

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,27 +10,29 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.model.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.model.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Customer Sub Panel * Customer Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubBPartner.java,v 1.2 2006/07/30 00:51:26 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class SubBPartner extends PosSubPanel public class SubBPartner extends PosSubPanel
implements ActionListener, FocusListener implements ActionListener, FocusListener
@ -165,6 +167,8 @@ public class SubBPartner extends PosSubPanel
// Name // Name
else if (e.getSource() == f_name) else if (e.getSource() == f_name)
findBPartner(); findBPartner();
p_posPanel.updateInfo();
} // actionPerformed } // actionPerformed
/** /**
@ -224,8 +228,9 @@ public class SubBPartner extends PosSubPanel
String Phone = (noNumber ? null : query); String Phone = (noNumber ? null : query);
String City = null; String City = null;
// //
//TODO: contact have been remove from rv_bpartner
MBPartnerInfo[] results = MBPartnerInfo.find(p_ctx, Value, Name, MBPartnerInfo[] results = MBPartnerInfo.find(p_ctx, Value, Name,
Contact, EMail, Phone, City); /*Contact, */null, EMail, Phone, City);
// Set Result // Set Result
if (results.length == 0) if (results.length == 0)
@ -276,6 +281,7 @@ public class SubBPartner extends PosSubPanel
m_M_PriceList_Version_ID = 0; m_M_PriceList_Version_ID = 0;
getM_PriceList_Version_ID(); getM_PriceList_Version_ID();
fillCombos(); fillCombos();
p_posPanel.f_curLine.setBPartner(); //added by ConSerTi to update the client in the request
} // setC_BPartner_ID } // setC_BPartner_ID
/** /**

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,15 +10,15 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
@ -26,8 +26,10 @@ import org.compiere.util.*;
/** /**
* Basic Key Sub Panel * Basic Key Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubBasicKeys.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubBasicKeys.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class SubBasicKeys extends PosSubPanel implements ActionListener public class SubBasicKeys extends PosSubPanel implements ActionListener
{ {

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,25 +10,31 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.border.*; import java.io.*;
import org.compiere.grid.ed.*; import java.math.*;
import java.util.Properties;
import javax.swing.border.TitledBorder;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.MOrder;
import org.compiere.process.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Checkout Sub Panel * Checkout Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubCheckout.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubCheckout.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class SubCheckout extends PosSubPanel implements ActionListener public class SubCheckout extends PosSubPanel implements ActionListener
{ {
@ -46,19 +52,22 @@ public class SubCheckout extends PosSubPanel implements ActionListener
private CButton f_process = null; private CButton f_process = null;
private CButton f_print = null; private CButton f_print = null;
private CLabel f_lcreditCardNumber = null; //TODO: credit card
/* private CLabel f_lcreditCardNumber = null;
private CTextField f_creditCardNumber = null; private CTextField f_creditCardNumber = null;
private CLabel f_lcreditCardExp = null; private CLabel f_lcreditCardExp = null;
private CTextField f_creditCardExp = null; private CTextField f_creditCardExp = null;
private CLabel f_lcreditCardVV = null; private CLabel f_lcreditCardVV = null;
private CTextField f_creditCardVV = null; private CTextField f_creditCardVV = null;
private CButton f_cashPayment = null;
private CLabel f_lcashGiven = null;
private VNumber f_cashGiven = null;
private CLabel f_lcashReturn = null;
private VNumber f_cashReturn = null;
private CButton f_creditPayment = null; private CButton f_creditPayment = null;
*/
private CLabel f_lcashGiven = null;
private VNumber f_cashGiven;
private CLabel f_lcashReturn = null;
private VNumber f_cashReturn;
private CButton f_cashPayment = null;
private CButton f_cashRegisterFunctions;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(SubCheckout.class); private static CLogger log = CLogger.getCLogger(SubCheckout.class);
@ -84,14 +93,17 @@ public class SubCheckout extends PosSubPanel implements ActionListener
// //
f_summary = createButtonAction("Summary", null); f_summary = createButtonAction("Summary", null);
gbc.gridy = 1; gbc.gridy = 1;
gbc.gridheight = 1;
add (f_summary, gbc); add (f_summary, gbc);
// //
f_process = createButtonAction("Process", null); f_process = createButtonAction("Process", null);
gbc.gridy = 2; gbc.gridy = 2;
gbc.gridheight = 1;
add (f_process, gbc); add (f_process, gbc);
// //
f_print = createButtonAction("Print", null); f_print = createButtonAction("Print", null);
gbc.gridy = 3; gbc.gridy = 3;
gbc.gridheight =1;
add (f_print, gbc); add (f_print, gbc);
// -- 1 -- Cash // -- 1 -- Cash
@ -101,7 +113,7 @@ public class SubCheckout extends PosSubPanel implements ActionListener
gbc.weightx = .1; gbc.weightx = .1;
CPanel cash = new CPanel(new GridBagLayout()); CPanel cash = new CPanel(new GridBagLayout());
cash.setBorder(new TitledBorder(Msg.getMsg(Env.getCtx(), "Cash"))); cash.setBorder(new TitledBorder(Msg.getMsg(Env.getCtx(), "Cash")));
gbc.gridy = 0; gbc.gridy = 1;
add (cash, gbc); add (cash, gbc);
GridBagConstraints gbc0 = new GridBagConstraints(); GridBagConstraints gbc0 = new GridBagConstraints();
gbc0.insets = INSETS2; gbc0.insets = INSETS2;
@ -114,6 +126,7 @@ public class SubCheckout extends PosSubPanel implements ActionListener
f_cashGiven.setColumns(10, 25); f_cashGiven.setColumns(10, 25);
cash.add (f_cashGiven, gbc0); cash.add (f_cashGiven, gbc0);
f_cashGiven.setValue(Env.ZERO); f_cashGiven.setValue(Env.ZERO);
f_cashGiven.addActionListener(this); //para que actualice el cambio con el dinero entregado
// //
f_lcashReturn = new CLabel(Msg.getMsg(Env.getCtx(),"CashReturn")); f_lcashReturn = new CLabel(Msg.getMsg(Env.getCtx(),"CashReturn"));
cash.add (f_lcashReturn, gbc0); cash.add (f_lcashReturn, gbc0);
@ -122,14 +135,31 @@ public class SubCheckout extends PosSubPanel implements ActionListener
f_cashReturn.setColumns(10, 25); f_cashReturn.setColumns(10, 25);
cash.add (f_cashReturn, gbc0); cash.add (f_cashReturn, gbc0);
f_cashReturn.setValue(Env.ZERO); f_cashReturn.setValue(Env.ZERO);
//
f_cashPayment = createButtonAction("Payment", null); f_cashPayment = createButtonAction("Payment", null);
f_cashPayment.setActionCommand("Cash"); f_cashPayment.setActionCommand("Cash");
gbc0.anchor = GridBagConstraints.EAST; gbc0.anchor = GridBagConstraints.EAST;
gbc0.weightx = 0.1; gbc0.weightx = 0.1;
cash.add (f_cashPayment, gbc0); cash.add (f_cashPayment, gbc0);
gbc.gridx=1;
gbc.gridy=3;
gbc.gridheight=1;
CPanel caja = new CPanel();
add(caja,gbc);
caja.setPreferredSize(new Dimension(30,30));
f_cashRegisterFunctions = createButtonAction("CashRegisterFunction", null);
f_cashRegisterFunctions.setText("Cash Register\n Movements");
f_cashRegisterFunctions.setPreferredSize(new Dimension(160,30));
f_cashRegisterFunctions.setMaximumSize(new Dimension(160,30));
f_cashRegisterFunctions.setMinimumSize(new Dimension(160,30));
caja.add(f_cashRegisterFunctions);
//TODO: Credit card
/* Panel para la introducción de los datos de CreditCard para el pago quitada por ConSerTi al no considerar
* que sea útil de momento
// -- 1 -- Creditcard // -- 1 -- Creditcard
CPanel creditcard = new CPanel(new GridBagLayout()); CPanel creditcard = new CPanel(new GridBagLayout());
creditcard.setBorder(new TitledBorder(Msg.translate(Env.getCtx(), "CreditCardType"))); creditcard.setBorder(new TitledBorder(Msg.translate(Env.getCtx(), "CreditCardType")));
@ -170,6 +200,7 @@ public class SubCheckout extends PosSubPanel implements ActionListener
gbc1.weightx = 0.1; gbc1.weightx = 0.1;
creditcard.add (f_creditPayment, gbc1); creditcard.add (f_creditPayment, gbc1);
**/ //fin del comentario para quitar la parte del CreditCard
} // init } // init
/** /**
@ -198,15 +229,208 @@ public class SubCheckout extends PosSubPanel implements ActionListener
*/ */
public void actionPerformed (ActionEvent e) public void actionPerformed (ActionEvent e)
{ {
String action = e.getActionCommand(); String action = e.getActionCommand();
if (action == null || action.length() == 0) if (action == null || action.length() == 0)
return; return;
log.info( "PosSubCheckout - actionPerformed: " + action); log.info( "PosSubCheckout - actionPerformed: " + action);
// Register // Register
if (action.equals("Register"))
{
p_posPanel.f_queryTicket.reset();
p_posPanel.openQuery(p_posPanel.f_queryTicket);
}
// Summary // Summary
else
if (action.equals("Summary"))
{
//TODO: new field added by openxpertya to c_order
//p_posPanel.f_status.setStatusLine(p_posPanel.f_curLine.getOrder().getResumen());
displayReturn();
}
else if (action.equals("Process"))
{
if (isOrderFullyPay())
{
printTicket();
processOrder();
openCashDrawer();
}
}
// Print // Print
else if (action.equals("Print"))
{
if (isOrderFullyPay())
{
printTicket();
openCashDrawer();
}
}
// Cash (Payment) // Cash (Payment)
// CreditCard (Payment) else if (action.equals("Cash"))
{
displayReturn();
openCashDrawer();
}
else if (action.equals("CashRegisterFunction"))
{
p_posPanel.openQuery(p_posPanel.f_cashfunctions);
}
else if (e.getSource() == f_cashGiven)
displayReturn();
/* // CreditCard (Payment)
else if (action.equals("CreditCard"))
{
Log.print("CreditCard");
} fin del comentario para la Credit Card*/
f_cashGiven.setValue(Env.ZERO);
p_posPanel.updateInfo();
} // actionPerformed } // actionPerformed
/**
* Process Order
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
public void processOrder()
{
MOrder order = p_posPanel.f_curLine.getOrder();
if (order != null)
if (order.getDocStatus().equals("DR"))
{
order.setDocAction(DocAction.ACTION_Complete);
order.processIt(DocAction.ACTION_Complete);
order.save();
order = null;
p_posPanel.newOrder();
}
}
/**
* Print Ticket
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
public void printTicket()
{
MOrder order = p_posPanel.f_curLine.getOrder();
int ventana = p_posPanel.getWindowNo();
Properties m_ctx = p_posPanel.getPropiedades();
if (order != null)
{
try
{
//TODO: to incorporate jpos work from Posterita
/*
if (p_pos.getAD_PrintLabel_ID() != 0)
PrintLabel.printLabelTicket(order.getC_Order_ID(), p_pos.getAD_PrintLabel_ID());
*/
}
catch (Exception e)
{
log.severe("PrintTicket - Error Printing Ticket");
}
}
}
/**
* Display cash return
* Display the difference between tender amount and bill amount
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
public void displayReturn()
{
BigDecimal given = new BigDecimal(f_cashGiven.getValue().toString());
if (p_posPanel != null && p_posPanel.f_curLine != null)
{
MOrder order = p_posPanel.f_curLine.getOrder();
BigDecimal total = new BigDecimal(0);
if (order != null)
total = order.getGrandTotal();
double vuelta = given.doubleValue() - total.doubleValue();
f_cashReturn.setValue(new BigDecimal(vuelta));
}
}
/**
* Is order fully pay ?
* Calculates if the given money is sufficient to pay the order
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
public boolean isOrderFullyPay()
{
BigDecimal given = new BigDecimal(f_cashGiven.getValue().toString());
boolean paid = false;
if (p_posPanel != null && p_posPanel.f_curLine != null)
{
MOrder order = p_posPanel.f_curLine.getOrder();
BigDecimal total = new BigDecimal(0);
if (order != null)
total = order.getGrandTotal();
paid = given.doubleValue() >= total.doubleValue();
}
return paid;
}
/**
* Abrir caja
* Abre la caja registradora
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
public void openCashDrawer()
{
String puerto = null;
//TODO - to incorporate jpos work from Posterita
/*
try
{
String sql = "SELECT p.Port"
+ " FROM AD_PrintLabel l"
+ " INNER JOIN AD_LabelPrinter p ON (l.AD_LabelPrinter_ID=p.AD_LabelPrinter_ID)"
+ " WHERE l.AD_PrintLabel_ID=?";
puerto = DB.getSQLValueString(null, sql, p_pos.getAD_PrintLabel_ID());
}
catch(Exception e)
{
log.severe("AbrirCaja - Puerto no encontrado");
}*/
/*
if (puerto == null)
log.severe("Port is mandatory for cash drawner");
try
{
byte data[] = new byte[5];
data[0] = 27;
data[1] = 112;
data[2] = 0;
data[3] = 50;
data[4] = 50;
FileOutputStream fos = new FileOutputStream(puerto);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(data, 0, data.length);
bos.close();
fos.close();
}
catch(Exception e)
{
e.printStackTrace();
}*/
}
} // PosSubCheckout } // PosSubCheckout

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,143 +10,148 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.math.*; import java.math.*;
import java.util.logging.Level;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.swing.*;
import org.compiere.grid.ed.*; import org.compiere.grid.ed.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.swing.*;
import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Current Line Sub Panel * Current Line Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubCurrentLine.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *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 $
*/ */
public class SubCurrentLine extends PosSubPanel implements ActionListener public class SubCurrentLine extends PosSubPanel implements ActionListener {
{
/** /**
* Constructor * Constructor
* @param posPanel POS Panel *
* @param posPanel
* POS Panel
*/ */
public SubCurrentLine (PosPanel posPanel) public SubCurrentLine(PosPanel posPanel) {
{ super(posPanel);
super (posPanel); } // PosSubCurrentLine
} // PosSubCurrentLine
private CButton f_new; private CButton f_new;
private CButton f_reset; private CButton f_reset;
private CButton f_plus; private CButton f_plus;
private CButton f_minus; private CButton f_minus;
private CLabel f_currency; private CLabel f_currency;
private VNumber f_price;
private CLabel f_uom; private VNumber f_price;
private VNumber f_quantity;
private CLabel f_uom;
private MOrder m_order = null;
private VNumber f_quantity;
private MOrder m_order = null;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(SubCurrentLine.class); private static CLogger log = CLogger.getCLogger(SubCurrentLine.class);
/** /**
* Initialize * Initialize
*/ */
public void init() public void init() {
{
// Title // Title
TitledBorder border = new TitledBorder(Msg.getMsg(Env.getCtx(), "CurrentLine")); TitledBorder border = new TitledBorder(Msg.getMsg(Env.getCtx(),
"CurrentLine"));
setBorder(border); setBorder(border);
// Content // Content
setLayout(new GridBagLayout()); setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2; gbc.insets = INSETS2;
gbc.gridy = 0; gbc.gridy = 0;
// -- // --
f_new = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, Event.SHIFT_MASK)); f_new = createButtonAction("New", KeyStroke.getKeyStroke(
KeyEvent.VK_INSERT, Event.SHIFT_MASK));
gbc.gridx = 0; gbc.gridx = 0;
add (f_new, gbc); add(f_new, gbc);
// //
f_reset = createButtonAction("Reset", null); f_reset = createButtonAction("Reset", null);
gbc.gridx = GridBagConstraints.RELATIVE; gbc.gridx = GridBagConstraints.RELATIVE;
add (f_reset, gbc); add(f_reset, gbc);
// //
f_currency = new CLabel("---"); f_currency = new CLabel("---");
gbc.anchor = GridBagConstraints.EAST; gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = .1; gbc.weightx = .1;
gbc.fill = GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
add (f_currency, gbc); add(f_currency, gbc);
// //
f_price = new VNumber("PriceActual", false, false, true, DisplayType.Amount, f_price = new VNumber("PriceActual", false, false, true,
Msg.translate(Env.getCtx(), "PriceActual")); DisplayType.Amount, Msg.translate(Env.getCtx(), "PriceActual"));
f_price.addActionListener(this); f_price.addActionListener(this);
f_price.setColumns(10, 25); f_price.setColumns(10, 25);
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.weightx = 0; gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
add (f_price, gbc); add(f_price, gbc);
setPrice(Env.ZERO); setPrice(Env.ZERO);
// -- // --
f_uom = new CLabel("--"); f_uom = new CLabel("--");
gbc.anchor = GridBagConstraints.EAST; gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = .1; gbc.weightx = .1;
gbc.fill = GridBagConstraints.HORIZONTAL; gbc.fill = GridBagConstraints.HORIZONTAL;
add (f_uom, gbc); add(f_uom, gbc);
// //
f_minus = createButtonAction("Minus", null); f_minus = createButtonAction("Minus", null);
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.weightx = 0; gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
add (f_minus, gbc); add(f_minus, gbc);
// //
f_quantity = new VNumber("QtyOrdered", false, false, true, DisplayType.Quantity, f_quantity = new VNumber("QtyOrdered", false, false, true,
Msg.translate(Env.getCtx(), "QtyOrdered")); DisplayType.Quantity, Msg.translate(Env.getCtx(), "QtyOrdered"));
f_quantity.addActionListener(this); f_quantity.addActionListener(this);
f_quantity.setColumns(5, 25); f_quantity.setColumns(5, 25);
add (f_quantity, gbc); add(f_quantity, gbc);
setQty (Env.ONE); setQty(Env.ONE);
// //
f_plus = createButtonAction("Plus", null); f_plus = createButtonAction("Plus", null);
add (f_plus, gbc); add(f_plus, gbc);
} // init } // init
/** /**
* Get Panel Position * Get Panel Position
*/ */
public GridBagConstraints getGridBagConstraints() public GridBagConstraints getGridBagConstraints() {
{
GridBagConstraints gbc = super.getGridBagConstraints(); GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy = 1; gbc.gridy = 1;
return gbc; return gbc;
} // getGridBagConstraints } // getGridBagConstraints
/**
* Dispose - Free Resources
*/
public void dispose()
{
super.dispose();
} // dispose
/** /**
* Action Listener * Dispose - Free Resources
* @param e event
*/ */
public void actionPerformed (ActionEvent e) public void dispose() {
{ super.dispose();
} // dispose
/**
* Action Listener
*
* @param e event
*/
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand(); String action = e.getActionCommand();
if (action == null || action.length() == 0) if (action == null || action.length() == 0)
return; return;
@ -167,97 +172,94 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener
f_price.setValue(f_price.getValue()); f_price.setValue(f_price.getValue());
else if (e.getSource() == f_quantity) else if (e.getSource() == f_quantity)
f_quantity.setValue(f_quantity.getValue()); f_quantity.setValue(f_quantity.getValue());
} // actionPerformed p_posPanel.updateInfo();
} // actionPerformed
/************************************************************************** /***************************************************************************
* Set Currency * Set Currency
* @param currency currency *
* @param currency
* currency
*/ */
public void setCurrency (String currency) public void setCurrency(String currency) {
{
if (currency == null) if (currency == null)
f_currency.setText("---"); f_currency.setText("---");
else else
f_currency.setText(currency); f_currency.setText(currency);
} // setCurrency } // setCurrency
/** /**
* Set UOM * Set UOM
* @param UOM UOM *
* @param UOM
*/ */
public void setUOM (String UOM) public void setUOM(String UOM) {
{
if (UOM == null) if (UOM == null)
f_uom.setText("--"); f_uom.setText("--");
else else
f_uom.setText(UOM); f_uom.setText(UOM);
} // setUOM } // setUOM
/** /**
* Set Price * Set Price
* @param price price *
* @param price
*/ */
public void setPrice (BigDecimal price) public void setPrice(BigDecimal price) {
{
if (price == null) if (price == null)
price = Env.ZERO; price = Env.ZERO;
f_price.setValue(price); f_price.setValue(price);
boolean rw = Env.ZERO.compareTo(price) == 0 boolean rw = Env.ZERO.compareTo(price) == 0 || p_pos.isModifyPrice();
|| p_pos.isModifyPrice();
f_price.setReadWrite(rw); f_price.setReadWrite(rw);
} // setPrice } // setPrice
/** /**
* Get Price * Get Price
* @return price *
* @return price
*/ */
public BigDecimal getPrice () public BigDecimal getPrice() {
{ return (BigDecimal) f_price.getValue();
return (BigDecimal)f_price.getValue(); } // getPrice
} // getPrice
/** /**
* Set Qty * Set Qty
* @param qty qty *
* @param qty
*/ */
public void setQty (BigDecimal qty) public void setQty(BigDecimal price) {
{ f_quantity.setValue(price);
f_quantity.setValue(qty); } // setPrice
} // setPrice
/** /**
* Get Qty * Get Qty
* @return qty *
* @return qty
*/ */
public BigDecimal getQty () public BigDecimal getQty() {
{ return (BigDecimal) f_quantity.getValue();
return (BigDecimal)f_quantity.getValue(); } // getPrice
} // getPrice
/***************************************************************************
/************************************************************************** * New Line
* New Line
*/ */
public void newLine() public void newLine() {
{
p_posPanel.f_product.setM_Product_ID(0); p_posPanel.f_product.setM_Product_ID(0);
setQty(Env.ONE); setQty(Env.ONE);
setPrice(Env.ZERO); setPrice(Env.ZERO);
p_posPanel.f_lines.updateTable(m_order); } // newLine
} // newLine
/** /**
* Save Line * Save Line
* @return true if saved *
* @return true if saved
*/ */
public boolean saveLine() public boolean saveLine() {
{ MProduct product = p_posPanel.f_product.getProduct();
MProduct product = p_posPanel.f_product.getProduct();
if (product == null) if (product == null)
return false; return false;
BigDecimal QtyOrdered = (BigDecimal)f_quantity.getValue(); BigDecimal QtyOrdered = (BigDecimal) f_quantity.getValue();
BigDecimal PriceActual = (BigDecimal)f_price.getValue(); BigDecimal PriceActual = (BigDecimal) f_price.getValue();
MOrderLine line = createLine(product, QtyOrdered, PriceActual); MOrderLine line = createLine(product, QtyOrdered, PriceActual);
if (line == null) if (line == null)
return false; return false;
@ -266,16 +268,98 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener
// //
newLine(); newLine();
return true; return true;
} // saveLine } // saveLine
/**
* to erase the lines from order
* @return true if deleted
*/
public void deleteLine (int row) {
if (m_order != null & row != -1 )
{
MOrderLine[] lineas = m_order.getLines();
int numLineas = lineas.length;
if (numLineas > row)
{
//to unreserve
lineas[row].setQty(Env.ZERO);
lineas[row].setLineNetAmt(Env.ZERO);
lineas[row].save();
//TODO: openxpertya using private method from MOrder
//m_order.reserveStock(null, lineas);
//delete line from order
lineas[row].delete(true);
for (int i = row; i < (numLineas - 1); i++)
lineas[i] = lineas[i + 1];
lineas[numLineas - 1] = null;
}
}
} // deleteLine
/** /**
* Get/create Header * Delete order from database
* @return header or null *
*/ * @author Comunidad de Desarrollo OpenXpertya
public MOrder getOrder() * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
{ * *Copyright © ConSerTi
if (m_order == null) */
public void deleteOrder () {
if (m_order != null)
{ {
if (m_order.getDocStatus().equals("DR"))
{
MOrderLine[] lineas = m_order.getLines();
if (lineas != null)
{
int numLineas = lineas.length;
if (numLineas > 0)
for (int i = numLineas - 1; i >= 0; i--)
{
if (lineas[i] != null)
deleteLine(i);
}
}
MOrderTax[] taxs = m_order.getTaxes(true);
if (taxs != null)
{
int numTax = taxs.length;
if (numTax > 0)
for (int i = taxs.length - 1; i >= 0; i--)
{
if (taxs[i] != null)
taxs[i].delete(true);
taxs[i] = null;
}
}
m_order.delete(true);
m_order = null;
}
}
} // deleteOrder
/**
* Create new order
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/
public void newOrder()
{
m_order = null;
m_order = getOrder();
}
/**
* Get/create Header
*
* @return header or null
*/
public MOrder getOrder() {
if (m_order == null) {
m_order = new MOrder(Env.getCtx(), 0, null); m_order = new MOrder(Env.getCtx(), 0, null);
m_order.setAD_Org_ID(p_pos.getAD_Org_ID()); m_order.setAD_Org_ID(p_pos.getAD_Org_ID());
m_order.setIsSOTrx(true); m_order.setIsSOTrx(true);
@ -283,16 +367,17 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener
m_order.setC_DocTypeTarget_ID(p_pos.getC_DocType_ID()); m_order.setC_DocTypeTarget_ID(p_pos.getC_DocType_ID());
else else
m_order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS); m_order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS);
MBPartner partner = p_posPanel.f_bpartner.getBPartner(); MBPartner partner = p_posPanel.f_bpartner.getBPartner();
if (partner == null || partner.get_ID() == 0) if (partner == null || partner.get_ID() == 0)
partner = p_pos.getBPartner(); partner = p_pos.getBPartner();
if (partner == null || partner.get_ID() == 0) if (partner == null || partner.get_ID() == 0) {
{
log.log(Level.SEVERE, "SubCurrentLine.getOrder - no BPartner"); log.log(Level.SEVERE, "SubCurrentLine.getOrder - no BPartner");
return null; return null;
} }
log.info( "SubCurrentLine.getOrder -" + partner); log.info( "SubCurrentLine.getOrder -" + partner);
m_order.setBPartner(partner); m_order.setBPartner(partner);
p_posPanel.f_bpartner.setC_BPartner_ID(partner.getC_BPartner_ID());
int id = p_posPanel.f_bpartner.getC_BPartner_Location_ID(); int id = p_posPanel.f_bpartner.getC_BPartner_Location_ID();
if (id != 0) if (id != 0)
m_order.setC_BPartner_Location_ID(id); m_order.setC_BPartner_Location_ID(id);
@ -304,28 +389,94 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener
m_order.setM_Warehouse_ID(p_pos.getM_Warehouse_ID()); m_order.setM_Warehouse_ID(p_pos.getM_Warehouse_ID());
m_order.setSalesRep_ID(p_pos.getSalesRep_ID()); m_order.setSalesRep_ID(p_pos.getSalesRep_ID());
if (!m_order.save()) if (!m_order.save())
{
m_order = null; m_order = null;
log.severe("Unable create Order.");
}
} }
return m_order; return m_order;
} // getHeader } // getHeader
/** /**
* Create new Line * @author Comunidad de Desarrollo OpenXpertya
* @return line or null * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © ConSerTi
*/ */
public MOrderLine createLine(MProduct product, public void setBPartner()
BigDecimal QtyOrdered, BigDecimal PriceActual)
{ {
if (m_order != null)
if (m_order.getDocStatus().equals("DR"))
{
MBPartner partner = p_posPanel.f_bpartner.getBPartner();
//get default from mpos if no selection make
if (partner == null || partner.get_ID() == 0)
partner = p_pos.getBPartner();
if (partner == null || partner.get_ID() == 0) {
log.warning("SubCurrentLine.getOrder - no BPartner");
}
else
{
log.info("SubCurrentLine.getOrder -" + partner);
m_order.setBPartner(partner);
MOrderLine[] lineas = m_order.getLines();
for (int i = 0; i < lineas.length; i++)
{
lineas[i].setC_BPartner_ID(partner.getC_BPartner_ID());
lineas[i].setTax();
lineas[i].save();
}
m_order.save();
}
}
}
/**
* Create new Line
*
* @return line or null
*/
public MOrderLine createLine(MProduct product, BigDecimal QtyOrdered,
BigDecimal PriceActual) {
MOrder order = getOrder(); MOrder order = getOrder();
if (order == null) if (order == null)
return null; return null;
MOrderLine line = new MOrderLine (order); 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++)
{
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
MOrderLine line = new MOrderLine(order);
line.setProduct(product); line.setProduct(product);
line.setQty(QtyOrdered); line.setQty(QtyOrdered);
line.setPrice(); // sets List/limit line.setPrice(); // sets List/limit
line.setPrice(PriceActual); line.setPrice(PriceActual);
line.save(); line.save();
return line; return line;
} // getLine } // getLine
} // PosSubCurrentLine /**
* @param m_c_order_id
*/
public void setOldOrder(int m_c_order_id)
{
deleteOrder();
m_order = new MOrder(p_ctx , m_c_order_id, null);
p_posPanel.updateInfo();
}
} // PosSubCurrentLine

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,26 +10,28 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.swing.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.print.*; import org.compiere.print.*;
import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Function Key Sub Panel * Function Key Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubFunctionKeys.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubFunctionKeys.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class SubFunctionKeys extends PosSubPanel implements ActionListener public class SubFunctionKeys extends PosSubPanel implements ActionListener
{ {
@ -64,7 +66,7 @@ public class SubFunctionKeys extends PosSubPanel implements ActionListener
return; return;
int COLUMNS = 3; // Min Columns int COLUMNS = 3; // Min Columns
int ROWS = 3; // Min Rows int ROWS = 6; // Min Rows
m_keys = fKeys.getKeys(false); m_keys = fKeys.getKeys(false);
int noKeys = m_keys.length; int noKeys = m_keys.length;
int rows = Math.max (((noKeys-1) / COLUMNS) + 1, ROWS); int rows = Math.max (((noKeys-1) / COLUMNS) + 1, ROWS);
@ -116,6 +118,7 @@ public class SubFunctionKeys extends PosSubPanel implements ActionListener
GridBagConstraints gbc = super.getGridBagConstraints(); GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 1; gbc.gridx = 1;
gbc.gridy = 2; gbc.gridy = 2;
gbc.gridheight = 2; //added by ConSerTi so that the panel takes up more space
return gbc; return gbc;
} // getGridBagConstraints } // getGridBagConstraints
@ -149,6 +152,7 @@ public class SubFunctionKeys extends PosSubPanel implements ActionListener
p_posPanel.f_product.setPrice(); p_posPanel.f_product.setPrice();
p_posPanel.f_curLine.setQty(key.getQty()); p_posPanel.f_curLine.setQty(key.getQty());
p_posPanel.f_curLine.saveLine(); p_posPanel.f_curLine.saveLine();
p_posPanel.updateInfo();
return; return;
} }
} }

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,31 +10,33 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.math.*; import java.math.*;
import java.sql.*; import java.sql.*;
import java.util.logging.Level;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.swing.*;
import org.compiere.grid.ed.*; import org.compiere.grid.ed.*;
import org.compiere.minigrid.*; import org.compiere.minigrid.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.swing.*;
import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS All Lines Sub Panel * All Lines Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubLines.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubLines.java,v 1.2 2004/07/21 05:37:51 jjanke Exp $
*/ */
public class SubLines extends PosSubPanel implements ActionListener public class SubLines extends PosSubPanel implements ActionListener
{ {
@ -149,7 +151,7 @@ public class SubLines extends PosSubPanel implements ActionListener
summary.add(f_total); summary.add(f_total);
f_total.setValue (Env.ZERO); f_total.setValue (Env.ZERO);
// //
f_delete.setReadWrite(false); f_delete.setReadWrite(true);
} // init } // init
/** /**
@ -193,7 +195,6 @@ public class SubLines extends PosSubPanel implements ActionListener
if (row < 0) if (row < 0)
row = 0; row = 0;
m_table.getSelectionModel().setSelectionInterval(row, row); m_table.getSelectionModel().setSelectionInterval(row, row);
f_delete.setReadWrite(true);
} }
else if ("Next".equalsIgnoreCase(e.getActionCommand())) else if ("Next".equalsIgnoreCase(e.getActionCommand()))
{ {
@ -205,13 +206,21 @@ public class SubLines extends PosSubPanel implements ActionListener
if (row >= rows) if (row >= rows)
row = rows - 1; row = rows - 1;
m_table.getSelectionModel().setSelectionInterval(row, row); m_table.getSelectionModel().setSelectionInterval(row, row);
f_delete.setReadWrite(true);
} }
// Delete // Delete
else if (action.equals("Delete")) else if (action.equals("Delete"))
{ {
int rows = m_table.getRowCount();
if (rows != 0)
{
int row = m_table.getSelectedRow();
if (row != -1)
{
p_posPanel.f_curLine.deleteLine(row);
}
}
} }
p_posPanel.updateInfo();
} // actionPerformed } // actionPerformed
/** /**
@ -226,7 +235,7 @@ public class SubLines extends PosSubPanel implements ActionListener
if (C_Order_ID == 0) if (C_Order_ID == 0)
{ {
m_table.loadTable(new PO[0]); m_table.loadTable(new PO[0]);
setSums(order); setSums(null);
} }
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -278,6 +287,4 @@ public class SubLines extends PosSubPanel implements ActionListener
f_tax.setValue(order.getGrandTotal().subtract(order.getTotalLines())); f_tax.setValue(order.getGrandTotal().subtract(order.getTotalLines()));
} }
} // setSums } // setSums
} // PosSubAllLines } // PosSubAllLines

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,29 +10,31 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.model.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.model.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Product Sub Panel. * Product Sub Panel.
* Responsible for Product Selection and maintaining * Responsible for Product Selection and maintaining
* M_Product_ID, Name, UOM * M_Product_ID, Name, UOM
* and setting Price * and setting Price
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubProduct.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubProduct.java,v 1.2 2004/07/24 04:31:52 jjanke Exp $
*/ */
public class SubProduct extends PosSubPanel public class SubProduct extends PosSubPanel
implements ActionListener, FocusListener implements ActionListener, FocusListener
@ -134,6 +136,8 @@ public class SubProduct extends PosSubPanel
// Name // Name
else if (e.getSource() == f_name) else if (e.getSource() == f_name)
findProduct(); findProduct();
p_posPanel.updateInfo();
} // actionPerformed } // actionPerformed
/** /**
@ -154,6 +158,8 @@ public class SubProduct extends PosSubPanel
return; return;
log.info( "PosSubProduct - focusLost"); log.info( "PosSubProduct - focusLost");
findProduct(); findProduct();
p_posPanel.updateInfo();
} // focusLost } // focusLost
/** /**
@ -181,7 +187,7 @@ public class SubProduct extends PosSubPanel
boolean allNumber = true; boolean allNumber = true;
try try
{ {
Integer.parseInt(query); Integer.getInteger(query);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution * * Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published * * under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope * * by the Free Software Foundation. This program is distributed in the hope *
@ -10,24 +10,26 @@
* You should have received a copy of the GNU General Public License along * * You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., * * with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/ *****************************************************************************/
package org.compiere.pos; package org.compiere.pos;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.border.*; import javax.swing.border.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* POS Sales Rep Sub Panel * Sales Rep Sub Panel
* *
* @author Jorg Janke * @author Comunidad de Desarrollo OpenXpertya
* @version $Id: SubSalesRep.java,v 1.2 2006/07/30 00:51:26 jjanke Exp $ * *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright © Jorg Janke
* @version $Id: SubSalesRep.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/ */
public class SubSalesRep extends PosSubPanel implements ActionListener public class SubSalesRep extends PosSubPanel implements ActionListener
{ {