Revert FR [2979756] - Touchscreen friendly POS

Although I like the new presentation of the touchscreen POS it removed some basic functionality.
* In previous POS you could select the business partner, here it assign the "Standard" partner and it cannot be changed (not sure if there is a "hidden" button to do it).
* The button "Preferences" do nothing.
* Credit Card Expiration cannot be set to 0911 - it's changed to 911 and then complaining about the format.
* The order was completed with an incomplete payment - an order of 200 - I entered a cash payment of 50 and it was completed with a change of -190
This commit is contained in:
Carlos Ruiz 2011-02-26 19:27:57 -05:00
parent fb7eb25653
commit 403ccaf162
47 changed files with 3027 additions and 10357 deletions

View File

@ -1,4 +0,0 @@
-- Apr 7, 2010 11:08:21 AM CEST
UPDATE C_POS SET C_BankAccount_ID=100,Updated=TO_DATE('2010-04-07 11:08:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_POS_ID=100
;

View File

@ -1,14 +0,0 @@
ALTER TABLE C_POSKey ADD CONSTRAINT ADImage_CPOSKey FOREIGN KEY(AD_Image_ID) REFERENCES AD_Image(AD_Image_ID);
ALTER TABLE C_POS ADD (CONSTRAINT OSKKeyLayout_CPOS FOREIGN KEY (OSK_KeyLayout_ID) REFERENCES C_POSKeyLayout);
ALTER TABLE C_POS ADD (CONSTRAINT OSNPKeyLayout_CPOS FOREIGN KEY (OSNP_KeyLayout_ID) REFERENCES C_POSKeyLayout);
ALTER TABLE C_POSKey ADD (CONSTRAINT ADPrintFont_CPOSKey FOREIGN KEY (AD_PrintFont_ID) REFERENCES AD_PrintFont);
ALTER TABLE C_POSKey ADD (CONSTRAINT SubKeyLayout_CPOSKey FOREIGN KEY (SubKeyLayout_ID) REFERENCES C_POSKeyLayout);
ALTER TABLE C_POSKeyLayout ADD (CONSTRAINT ADPrintColor_CPOSKeyLayout FOREIGN KEY (AD_PrintColor_ID) REFERENCES AD_PrintColor);
ALTER TABLE C_POSKeyLayout ADD (CONSTRAINT ADPrintFont_CPOSKeyLayout FOREIGN KEY (AD_PrintFont_ID) REFERENCES AD_PrintFont);

View File

@ -1,4 +0,0 @@
-- Apr 7, 2010 11:08:21 AM CEST
UPDATE C_POS SET C_BankAccount_ID=100,Updated=TO_TIMESTAMP('2010-04-07 11:08:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_POS_ID=100
;

View File

@ -1,14 +0,0 @@
ALTER TABLE C_POSKey ADD CONSTRAINT ADImage_CPOSKey FOREIGN KEY(AD_Image_ID) REFERENCES AD_Image(AD_Image_ID) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE C_POS ADD CONSTRAINT OSKKeyLayout_CPOS FOREIGN KEY (OSK_KeyLayout_ID) REFERENCES C_POSKeyLayout DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE C_POS ADD CONSTRAINT OSNPKeyLayout_CPOS FOREIGN KEY (OSNP_KeyLayout_ID) REFERENCES C_POSKeyLayout DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE C_POSKey ADD CONSTRAINT ADPrintFont_CPOSKey FOREIGN KEY (AD_PrintFont_ID) REFERENCES AD_PrintFont DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE C_POSKey ADD CONSTRAINT SubKeyLayout_CPOSKey FOREIGN KEY (SubKeyLayout_ID) REFERENCES C_POSKeyLayout DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE C_POSKeyLayout ADD CONSTRAINT ADPrintColor_CPOSKeyLayout FOREIGN KEY (AD_PrintColor_ID) REFERENCES AD_PrintColor DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE C_POSKeyLayout ADD CONSTRAINT ADPrintFont_CPOSKeyLayout FOREIGN KEY (AD_PrintFont_ID) REFERENCES AD_PrintFont DEFERRABLE INITIALLY DEFERRED;

View File

@ -1,96 +0,0 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, 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. *
* 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.process;
import java.util.List;
import org.adempiere.exceptions.FillMandatoryException;
import org.compiere.model.MPOSKey;
import org.compiere.model.MProduct;
import org.compiere.model.Query;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.Env;
public class PosKeyGenerate extends SvrProcess {
private int posKeyLayoutId = 0;
private int productCategoryId = 0;
@Override
protected void prepare() {
for ( ProcessInfoParameter para : getParameter())
{
if ( para.getParameterName().equals("C_POSKeyLayout_ID") )
posKeyLayoutId = para.getParameterAsInt();
if ( para.getParameterName().equals("M_Product_Category_ID") )
productCategoryId = para.getParameterAsInt();
else
log.info("Parameter not found " + para.getParameterName());
}
if ( posKeyLayoutId == 0 )
{
posKeyLayoutId = getRecord_ID();
}
}
/**
* Generate keys for each product
*/
@Override
protected String doIt() throws Exception {
if ( posKeyLayoutId == 0 )
throw new FillMandatoryException("C_POSKeyLayout_ID");
int count = 0;
String where = "";
Object [] params = new Object[] {};
if ( productCategoryId > 0 )
{
where = "M_Product_Category_ID = ? ";
params = new Object[] {productCategoryId};
}
Query query = new Query(getCtx(), MProduct.Table_Name, where, get_TrxName())
.setParameters(params)
.setOnlyActiveRecords(true)
.setOrderBy("Value");
List<MProduct> products = query.list();
for (MProduct product : products )
{
MPOSKey key = new MPOSKey(getCtx(), 0, get_TrxName());
key.setName(product.getName());
key.setM_Product_ID(product.getM_Product_ID());
key.setC_POSKeyLayout_ID(posKeyLayoutId);
key.setSeqNo(count*10);
key.setQty(Env.ONE);
key.saveEx();
count++;
}
return "@Created@ " + count;
}
}

View File

@ -62,19 +62,6 @@ public interface I_C_POS
*/
public int getAD_Org_ID();
/** Column name AutoLogoutDelay */
public static final String COLUMNNAME_AutoLogoutDelay = "AutoLogoutDelay";
/** Set Auto Logout Delay.
* Automatically logout if terminal inactive for this period
*/
public void setAutoLogoutDelay (int AutoLogoutDelay);
/** Get Auto Logout Delay.
* Automatically logout if terminal inactive for this period
*/
public int getAutoLogoutDelay();
/** Column name CashDrawer */
public static final String COLUMNNAME_CashDrawer = "CashDrawer";
@ -283,36 +270,6 @@ public interface I_C_POS
*/
public String getName();
/** Column name OSK_KeyLayout_ID */
public static final String COLUMNNAME_OSK_KeyLayout_ID = "OSK_KeyLayout_ID";
/** Set On Screen Keyboard layout.
* The key layout to use for on screen keyboard for text fields.
*/
public void setOSK_KeyLayout_ID (int OSK_KeyLayout_ID);
/** Get On Screen Keyboard layout.
* The key layout to use for on screen keyboard for text fields.
*/
public int getOSK_KeyLayout_ID();
public I_C_POSKeyLayout getOSK_KeyLayout() throws RuntimeException;
/** Column name OSNP_KeyLayout_ID */
public static final String COLUMNNAME_OSNP_KeyLayout_ID = "OSNP_KeyLayout_ID";
/** Set On Screen Number Pad layout.
* The key layout to use for on screen number pad for numeric fields.
*/
public void setOSNP_KeyLayout_ID (int OSNP_KeyLayout_ID);
/** Get On Screen Number Pad layout.
* The key layout to use for on screen number pad for numeric fields.
*/
public int getOSNP_KeyLayout_ID();
public I_C_POSKeyLayout getOSNP_KeyLayout() throws RuntimeException;
/** Column name PrinterName */
public static final String COLUMNNAME_PrinterName = "PrinterName";

View File

@ -49,21 +49,6 @@ public interface I_C_POSKey
*/
public int getAD_Client_ID();
/** Column name AD_Image_ID */
public static final String COLUMNNAME_AD_Image_ID = "AD_Image_ID";
/** Set Image.
* Image or Icon
*/
public void setAD_Image_ID (int AD_Image_ID);
/** Get Image.
* Image or Icon
*/
public int getAD_Image_ID();
public I_AD_Image getAD_Image() throws RuntimeException;
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
@ -92,21 +77,6 @@ public interface I_C_POSKey
public I_AD_PrintColor getAD_PrintColor() throws RuntimeException;
/** Column name AD_PrintFont_ID */
public static final String COLUMNNAME_AD_PrintFont_ID = "AD_PrintFont_ID";
/** Set Print Font.
* Maintain Print Font
*/
public void setAD_PrintFont_ID (int AD_PrintFont_ID);
/** Get Print Font.
* Maintain Print Font
*/
public int getAD_PrintFont_ID();
public I_AD_PrintFont getAD_PrintFont() throws RuntimeException;
/** Column name C_POSKey_ID */
public static final String COLUMNNAME_C_POSKey_ID = "C_POSKey_ID";
@ -233,56 +203,6 @@ public interface I_C_POSKey
*/
public int getSeqNo();
/** Column name SpanX */
public static final String COLUMNNAME_SpanX = "SpanX";
/** Set Column span.
* Number of columns spanned
*/
public void setSpanX (int SpanX);
/** Get Column span.
* Number of columns spanned
*/
public int getSpanX();
/** Column name SpanY */
public static final String COLUMNNAME_SpanY = "SpanY";
/** Set Row Span.
* Number of rows spanned
*/
public void setSpanY (int SpanY);
/** Get Row Span.
* Number of rows spanned
*/
public int getSpanY();
/** Column name SubKeyLayout_ID */
public static final String COLUMNNAME_SubKeyLayout_ID = "SubKeyLayout_ID";
/** Set Key Layout.
* Key Layout to be displayed when this key is pressed
*/
public void setSubKeyLayout_ID (int SubKeyLayout_ID);
/** Get Key Layout.
* Key Layout to be displayed when this key is pressed
*/
public int getSubKeyLayout_ID();
public I_C_POSKeyLayout getSubKeyLayout() throws RuntimeException;
/** Column name Text */
public static final String COLUMNNAME_Text = "Text";
/** Set Text */
public void setText (String Text);
/** Get Text */
public String getText();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";

View File

@ -62,49 +62,6 @@ public interface I_C_POSKeyLayout
*/
public int getAD_Org_ID();
/** Column name AD_PrintColor_ID */
public static final String COLUMNNAME_AD_PrintColor_ID = "AD_PrintColor_ID";
/** Set Print Color.
* Color used for printing and display
*/
public void setAD_PrintColor_ID (int AD_PrintColor_ID);
/** Get Print Color.
* Color used for printing and display
*/
public int getAD_PrintColor_ID();
public I_AD_PrintColor getAD_PrintColor() throws RuntimeException;
/** Column name AD_PrintFont_ID */
public static final String COLUMNNAME_AD_PrintFont_ID = "AD_PrintFont_ID";
/** Set Print Font.
* Maintain Print Font
*/
public void setAD_PrintFont_ID (int AD_PrintFont_ID);
/** Get Print Font.
* Maintain Print Font
*/
public int getAD_PrintFont_ID();
public I_AD_PrintFont getAD_PrintFont() throws RuntimeException;
/** Column name Columns */
public static final String COLUMNNAME_Columns = "Columns";
/** Set Columns.
* Number of columns
*/
public void setColumns (int Columns);
/** Get Columns.
* Number of columns
*/
public int getColumns();
/** Column name C_POSKeyLayout_ID */
public static final String COLUMNNAME_C_POSKeyLayout_ID = "C_POSKeyLayout_ID";
@ -186,19 +143,6 @@ public interface I_C_POSKeyLayout
*/
public String getName();
/** Column name POSKeyLayoutType */
public static final String COLUMNNAME_POSKeyLayoutType = "POSKeyLayoutType";
/** Set POS Key Layout Type.
* The type of Key Layout
*/
public void setPOSKeyLayoutType (String POSKeyLayoutType);
/** Get POS Key Layout Type.
* The type of Key Layout
*/
public String getPOSKeyLayoutType();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";

View File

@ -1599,16 +1599,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
approveIt();
log.info(toString());
StringBuffer info = new StringBuffer();
// POS supports multiple payments
boolean fromPOS = false;
if ( getC_Order_ID() > 0 )
{
fromPOS = getC_Order().getC_POS_ID() > 0;
}
// Create Cash
if (PAYMENTRULE_Cash.equals(getPaymentRule()) && !fromPOS )
if (PAYMENTRULE_Cash.equals(getPaymentRule()))
{
// Modifications for POSterita
//

View File

@ -95,7 +95,7 @@ public class MPOSKeyLayout extends X_C_POSKeyLayout
return m_keys;
ArrayList<MPOSKey> list = new ArrayList<MPOSKey>();
String sql = "SELECT * FROM C_POSKey WHERE C_POSKeyLayout_ID=? AND IsActive = 'Y' ORDER BY SeqNo";
String sql = "SELECT * FROM C_POSKey WHERE C_POSKeyLayout_ID=? ORDER BY SeqNo";
PreparedStatement pstmt = null;
try
{

View File

@ -42,13 +42,7 @@ public class MPaymentProcessor extends X_C_PaymentProcessor
*/
private static final long serialVersionUID = 1825454310856682804L;
public static MPaymentProcessor[] find (Properties ctx,
String tender, String CCType,
int AD_Client_ID, int AD_Org_ID, int C_Currency_ID, BigDecimal Amt, String trxName)
{
return find(ctx, tender, CCType, AD_Client_ID, C_Currency_ID, Amt, trxName);
}
/**
* Get BankAccount & PaymentProcessor
* @param ctx context

View File

@ -77,26 +77,6 @@ public class X_C_POS extends PO implements I_C_POS, I_Persistent
return sb.toString();
}
/** Set Auto Logout Delay.
@param AutoLogoutDelay
Automatically logout if terminal inactive for this period
*/
public void setAutoLogoutDelay (int AutoLogoutDelay)
{
set_Value (COLUMNNAME_AutoLogoutDelay, Integer.valueOf(AutoLogoutDelay));
}
/** Get Auto Logout Delay.
@return Automatically logout if terminal inactive for this period
*/
public int getAutoLogoutDelay ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AutoLogoutDelay);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set CashDrawer.
@param CashDrawer CashDrawer */
public void setCashDrawer (String CashDrawer)
@ -413,62 +393,6 @@ public class X_C_POS extends PO implements I_C_POS, I_Persistent
return new KeyNamePair(get_ID(), getName());
}
public I_C_POSKeyLayout getOSK_KeyLayout() throws RuntimeException
{
return (I_C_POSKeyLayout)MTable.get(getCtx(), I_C_POSKeyLayout.Table_Name)
.getPO(getOSK_KeyLayout_ID(), get_TrxName()); }
/** Set On Screen Keyboard layout.
@param OSK_KeyLayout_ID
The key layout to use for on screen keyboard for text fields.
*/
public void setOSK_KeyLayout_ID (int OSK_KeyLayout_ID)
{
if (OSK_KeyLayout_ID < 1)
set_Value (COLUMNNAME_OSK_KeyLayout_ID, null);
else
set_Value (COLUMNNAME_OSK_KeyLayout_ID, Integer.valueOf(OSK_KeyLayout_ID));
}
/** Get On Screen Keyboard layout.
@return The key layout to use for on screen keyboard for text fields.
*/
public int getOSK_KeyLayout_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_OSK_KeyLayout_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_C_POSKeyLayout getOSNP_KeyLayout() throws RuntimeException
{
return (I_C_POSKeyLayout)MTable.get(getCtx(), I_C_POSKeyLayout.Table_Name)
.getPO(getOSNP_KeyLayout_ID(), get_TrxName()); }
/** Set On Screen Number Pad layout.
@param OSNP_KeyLayout_ID
The key layout to use for on screen number pad for numeric fields.
*/
public void setOSNP_KeyLayout_ID (int OSNP_KeyLayout_ID)
{
if (OSNP_KeyLayout_ID < 1)
set_Value (COLUMNNAME_OSNP_KeyLayout_ID, null);
else
set_Value (COLUMNNAME_OSNP_KeyLayout_ID, Integer.valueOf(OSNP_KeyLayout_ID));
}
/** Get On Screen Number Pad layout.
@return The key layout to use for on screen number pad for numeric fields.
*/
public int getOSNP_KeyLayout_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_OSNP_KeyLayout_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Printer Name.
@param PrinterName
Name of the Printer

View File

@ -42,9 +42,10 @@ public class X_C_POSKey extends PO implements I_C_POSKey, I_Persistent
{
setC_POSKey_ID (0);
setC_POSKeyLayout_ID (0);
setM_Product_ID (0);
setName (null);
setQty (Env.ZERO);
setSeqNo (0);
// @SQL=SELECT NVL(MAX(SeqNo),0)+10 AS DefaultValue FROM C_POSKey WHERE C_POSKeyLayout_ID=@C_POSKeyLayout_ID@
} */
}
@ -76,34 +77,6 @@ public class X_C_POSKey extends PO implements I_C_POSKey, I_Persistent
return sb.toString();
}
public I_AD_Image getAD_Image() throws RuntimeException
{
return (I_AD_Image)MTable.get(getCtx(), I_AD_Image.Table_Name)
.getPO(getAD_Image_ID(), get_TrxName()); }
/** Set Image.
@param AD_Image_ID
Image or Icon
*/
public void setAD_Image_ID (int AD_Image_ID)
{
if (AD_Image_ID < 1)
set_Value (COLUMNNAME_AD_Image_ID, null);
else
set_Value (COLUMNNAME_AD_Image_ID, Integer.valueOf(AD_Image_ID));
}
/** Get Image.
@return Image or Icon
*/
public int getAD_Image_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Image_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_AD_PrintColor getAD_PrintColor() throws RuntimeException
{
return (I_AD_PrintColor)MTable.get(getCtx(), I_AD_PrintColor.Table_Name)
@ -132,34 +105,6 @@ public class X_C_POSKey extends PO implements I_C_POSKey, I_Persistent
return ii.intValue();
}
public I_AD_PrintFont getAD_PrintFont() throws RuntimeException
{
return (I_AD_PrintFont)MTable.get(getCtx(), I_AD_PrintFont.Table_Name)
.getPO(getAD_PrintFont_ID(), get_TrxName()); }
/** Set Print Font.
@param AD_PrintFont_ID
Maintain Print Font
*/
public void setAD_PrintFont_ID (int AD_PrintFont_ID)
{
if (AD_PrintFont_ID < 1)
set_Value (COLUMNNAME_AD_PrintFont_ID, null);
else
set_Value (COLUMNNAME_AD_PrintFont_ID, Integer.valueOf(AD_PrintFont_ID));
}
/** Get Print Font.
@return Maintain Print Font
*/
public int getAD_PrintFont_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_PrintFont_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set POS Key.
@param C_POSKey_ID
POS Function Key
@ -320,86 +265,4 @@ public class X_C_POSKey extends PO implements I_C_POSKey, I_Persistent
return 0;
return ii.intValue();
}
/** Set Column span.
@param SpanX
Number of columns spanned
*/
public void setSpanX (int SpanX)
{
set_Value (COLUMNNAME_SpanX, Integer.valueOf(SpanX));
}
/** Get Column span.
@return Number of columns spanned
*/
public int getSpanX ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SpanX);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Row Span.
@param SpanY
Number of rows spanned
*/
public void setSpanY (int SpanY)
{
set_Value (COLUMNNAME_SpanY, Integer.valueOf(SpanY));
}
/** Get Row Span.
@return Number of rows spanned
*/
public int getSpanY ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SpanY);
if (ii == null)
return 0;
return ii.intValue();
}
public I_C_POSKeyLayout getSubKeyLayout() throws RuntimeException
{
return (I_C_POSKeyLayout)MTable.get(getCtx(), I_C_POSKeyLayout.Table_Name)
.getPO(getSubKeyLayout_ID(), get_TrxName()); }
/** Set Key Layout.
@param SubKeyLayout_ID
Key Layout to be displayed when this key is pressed
*/
public void setSubKeyLayout_ID (int SubKeyLayout_ID)
{
if (SubKeyLayout_ID < 1)
set_Value (COLUMNNAME_SubKeyLayout_ID, null);
else
set_Value (COLUMNNAME_SubKeyLayout_ID, Integer.valueOf(SubKeyLayout_ID));
}
/** Get Key Layout.
@return Key Layout to be displayed when this key is pressed
*/
public int getSubKeyLayout_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SubKeyLayout_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Text.
@param Text Text */
public void setText (String Text)
{
set_Value (COLUMNNAME_Text, Text);
}
/** Get Text.
@return Text */
public String getText ()
{
return (String)get_Value(COLUMNNAME_Text);
}
}

View File

@ -71,82 +71,6 @@ public class X_C_POSKeyLayout extends PO implements I_C_POSKeyLayout, I_Persiste
return sb.toString();
}
public I_AD_PrintColor getAD_PrintColor() throws RuntimeException
{
return (I_AD_PrintColor)MTable.get(getCtx(), I_AD_PrintColor.Table_Name)
.getPO(getAD_PrintColor_ID(), get_TrxName()); }
/** Set Print Color.
@param AD_PrintColor_ID
Color used for printing and display
*/
public void setAD_PrintColor_ID (int AD_PrintColor_ID)
{
if (AD_PrintColor_ID < 1)
set_Value (COLUMNNAME_AD_PrintColor_ID, null);
else
set_Value (COLUMNNAME_AD_PrintColor_ID, Integer.valueOf(AD_PrintColor_ID));
}
/** Get Print Color.
@return Color used for printing and display
*/
public int getAD_PrintColor_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_PrintColor_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public I_AD_PrintFont getAD_PrintFont() throws RuntimeException
{
return (I_AD_PrintFont)MTable.get(getCtx(), I_AD_PrintFont.Table_Name)
.getPO(getAD_PrintFont_ID(), get_TrxName()); }
/** Set Print Font.
@param AD_PrintFont_ID
Maintain Print Font
*/
public void setAD_PrintFont_ID (int AD_PrintFont_ID)
{
if (AD_PrintFont_ID < 1)
set_Value (COLUMNNAME_AD_PrintFont_ID, null);
else
set_Value (COLUMNNAME_AD_PrintFont_ID, Integer.valueOf(AD_PrintFont_ID));
}
/** Get Print Font.
@return Maintain Print Font
*/
public int getAD_PrintFont_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_PrintFont_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Columns.
@param Columns
Number of columns
*/
public void setColumns (int Columns)
{
set_Value (COLUMNNAME_Columns, Integer.valueOf(Columns));
}
/** Get Columns.
@return Number of columns
*/
public int getColumns ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_Columns);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set POS Key Layout.
@param C_POSKeyLayout_ID
POS Function Key Layout
@ -228,30 +152,4 @@ public class X_C_POSKeyLayout extends PO implements I_C_POSKeyLayout, I_Persiste
{
return new KeyNamePair(get_ID(), getName());
}
/** POSKeyLayoutType AD_Reference_ID=53351 */
public static final int POSKEYLAYOUTTYPE_AD_Reference_ID=53351;
/** Keyboard = K */
public static final String POSKEYLAYOUTTYPE_Keyboard = "K";
/** Numberpad = N */
public static final String POSKEYLAYOUTTYPE_Numberpad = "N";
/** Product = P */
public static final String POSKEYLAYOUTTYPE_Product = "P";
/** Set POS Key Layout Type.
@param POSKeyLayoutType
The type of Key Layout
*/
public void setPOSKeyLayoutType (String POSKeyLayoutType)
{
set_Value (COLUMNNAME_POSKeyLayoutType, POSKeyLayoutType);
}
/** Get POS Key Layout Type.
@return The type of Key Layout
*/
public String getPOSKeyLayoutType ()
{
return (String)get_Value(COLUMNNAME_POSKeyLayoutType);
}
}

View File

@ -78,7 +78,7 @@ public class MiniTable extends CTable implements IMiniTable
/**
*
*/
private static final long serialVersionUID = 2853772547464132497L;
private static final long serialVersionUID = 2853772547464132496L;
/**
* Default Constructor
@ -111,16 +111,7 @@ public class MiniTable extends CTable implements IMiniTable
/** Logger */
private static CLogger log = CLogger.getCLogger(MiniTable.class);
/** Is Total Show */
private boolean showTotals = false;
private boolean autoResize = true;
public boolean isAutoResize() {
return autoResize;
}
public void setAutoResize(boolean autoResize) {
this.autoResize = autoResize;
}
private boolean showTotals = false;
/**
* Gets the swing column of given index. No index checking
@ -145,10 +136,7 @@ public class MiniTable extends CTable implements IMiniTable
* Uses Mimimum Column Size
*/
public void autoSize()
{
if ( !autoResize )
return;
{
long start = System.currentTimeMillis();
//
final int SLACK = 8; // making sure it fits in a column

View File

@ -1,17 +0,0 @@
package org.compiere.pos;
import org.adempiere.exceptions.AdempiereException;
public class AdempierePOSException extends AdempiereException {
public AdempierePOSException(String message) {
super(message);
}
/**
*
*/
private static final long serialVersionUID = -9117127988717827183L;
}

View File

@ -24,7 +24,6 @@ import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Properties;
import javax.swing.border.TitledBorder;
@ -57,7 +56,7 @@ import org.compiere.util.TimeUtil;
*
*/
public class CashSubFunctions extends PosQuery implements ActionListener, InputMethodListener
public class CashSubFunctions extends PosSubPanel implements ActionListener, InputMethodListener
{
/**
*
@ -67,7 +66,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
/**
* Constructor
*/
public CashSubFunctions (PosBasePanel posPanel)
public CashSubFunctions (PosPanel posPanel)
{
super(posPanel);
} // PosQueryProduct
@ -101,7 +100,6 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
private CPanel panel;
private CScrollPane centerScroll;
private ConfirmPanel confirm;
private Properties p_ctx;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubCheckout.class);
@ -111,15 +109,14 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
*/
protected void init()
{
CPanel main = new CPanel();
main.setLayout(new BorderLayout(2,6));
main.setPreferredSize(new Dimension(400,600));
getContentPane().add(main);
setLayout(new BorderLayout(2,6));
setVisible(false);
// North
panel = new CPanel(new GridBagLayout());
main.add (panel, BorderLayout.CENTER);
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;
@ -206,6 +203,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
cInitial.setVisible(false);
panel.add (cInitial, gbc);
GridBagConstraints gbc0 = new GridBagConstraints();
gbc0.insets = INSETS2;
gbc0.anchor = GridBagConstraints.CENTER;
//
gbc0.gridx = 0;
@ -260,6 +258,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
cScrutiny.setVisible(false);
panel.add (cScrutiny, gbc);
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.insets = INSETS2;
gbc1.anchor = GridBagConstraints.CENTER;
//
@ -316,6 +315,22 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
} // 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
*/
@ -327,6 +342,15 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
confirm = null;
} // dispose
/**
* Set Visible
* @param aFlag visible
*/
public void setVisible (boolean aFlag)
{
super.setVisible (aFlag);
} // setVisible
/**
* Action Listener
* @param e event
@ -338,7 +362,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
return;
log.info("PosCashSubFunctions - actionPerformed: " + action);
// to display panel with initial change
// to display panel with initial changenicial
if (action.equals("displayInitialChange"))
{
cmd_displayInitialChange();
@ -376,7 +400,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
}
else if (action.equals("End"))
{
super.dispose();
p_posPanel.closeQuery(p_posPanel.f_cashfunctions);
}
else if (action.equals("saveChange"))
{
@ -543,20 +567,5 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
{
cmd_calculateDifference();
}
@Override
protected void close() {
}
@Override
protected void enableButtons() {
}
@Override
public void reset() {
}
} // CashSubFunctions

View File

@ -1,275 +0,0 @@
/******************************************************************************
* 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.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.HashMap;
import java.util.logging.Level;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.border.TitledBorder;
import javax.swing.text.NumberFormatter;
import javax.swing.text.Position;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.AEnv;
import org.compiere.apps.ConfirmPanel;
import org.compiere.model.MPOSKey;
import org.compiere.model.MPOSKeyLayout;
import org.compiere.print.MPrintColor;
import org.compiere.swing.CButton;
import org.compiere.swing.CDialog;
import org.compiere.swing.CPanel;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
/**
* On Screen Keyboard
* @author Paul Bowden
* Adaxa Pty Ltd
*/
public class POSKeyboard extends CDialog implements ActionListener, PosKeyListener
{
/**
*
*/
private static final long serialVersionUID = 3296839634889851637L;
private PosTextField field;
private MPOSKeyLayout keylayout;
/**
* Constructor
* @param posPanel POS Panel
*/
public POSKeyboard (PosBasePanel posPanel, int C_POSKeyLayout_ID, PosTextField field, String title)
{
this(posPanel, C_POSKeyLayout_ID);
setTitle(title);
setPosTextField(field);
}
public POSKeyboard(PosBasePanel posPanel, int keyLayoutId) {
super(AEnv.getFrame(posPanel), true);
keylayout = MPOSKeyLayout.get(posPanel.getCtx(), keyLayoutId);
init( keyLayoutId );
}
private JFormattedTextField text = new JFormattedTextField();
private HashMap<Integer, MPOSKey> keys;
/** Logger */
private static CLogger log = CLogger.getCLogger(POSKeyboard.class);
/**
* Initialize
* @param startText
* @param POSKeyLayout_ID
*/
public void init(int POSKeyLayout_ID )
{
CPanel panel = new CPanel();
getContentPane().add(panel);
// Content
panel.setLayout(new MigLayout("fill"));
if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad))
text.setHorizontalAlignment(JTextField.TRAILING);
panel.add(text, "north, growx, h 30!, wrap, gap 10 10 10 10");
PosKeyPanel keys = new PosKeyPanel(POSKeyLayout_ID, this);
panel.add(keys, "center, growx, growy");
ConfirmPanel confirm = new ConfirmPanel(true, false, true, false, false, false, false);
confirm.addActionListener(this);
Dimension buttonDim = new Dimension(50,50);
confirm.getResetButton().setPreferredSize(buttonDim);
confirm.getOKButton().setPreferredSize(buttonDim);
confirm.getCancelButton().setPreferredSize(buttonDim);
panel.add(confirm, "south");
pack();
setLocationByPlatform(true);
text.requestFocusInWindow();
} // init
/**
* Dispose - Free Resources
*/
public void dispose()
{
if (keys != null)
{
keys.clear();
keys = null;
}
super.dispose();
} // dispose
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
else if ( action.equals(ConfirmPanel.A_RESET))
{
if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad))
text.setText("0");
else
text.setText("");
try {
text.commitEdit();
} catch (ParseException e1) {
log.log(Level.FINE, "JFormattedTextField commit failed");
}
}
else if ( action.equals(ConfirmPanel.A_CANCEL))
{
dispose();
}
else if (action.equals(ConfirmPanel.A_OK))
{
field.setText(text.getText());
try {
field.commitEdit();
} catch (ParseException e1) {
log.log(Level.FINE, "JFormattedTextField commit failed");
}
dispose();
}
log.info( "PosSubBasicKeys - actionPerformed: " + action);
} // actionPerformed
public void keyReturned(MPOSKey key) {
String entry = key.getText();
String old = text.getText();
int caretPos = text.getCaretPosition();
if ( text.getSelectedText() != null )
caretPos = text.getSelectionStart();
String head = old.substring(0, caretPos);
if ( text.getSelectedText() != null )
caretPos = text.getSelectionEnd();
String tail = old.substring(caretPos, old.length());
if ( entry != null && !entry.isEmpty() )
{
if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Keyboard))
{
if ( key.getText() != null )
text.setText( head + entry + tail);
}
else if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad))
{
if ( entry.equals(".") )
{
text.setText(head + entry + tail);
}
if ( entry.equals(",") )
{
text.setText(head + entry + tail);
}
else if ( entry.equals("C") )
{
text.setText("0");
}
else {
try
{
int number = Integer.parseInt(entry); // test if number
if ( number >= 0 && number <= 9 )
{
text.setText(head + number + tail);
}
// greater than 9, add to existing
else
{
Object current = text.getValue();
if ( current == null )
{
text.setText(Integer.toString(number));
}
else if ( current instanceof BigDecimal )
{
text.setText(((BigDecimal) current).add(
new BigDecimal(Integer.toString(number))).toPlainString());
}
else if ( current instanceof Integer )
{
text.setText(Integer.toString(((Integer) current) + number));
}
else if ( current instanceof Long )
{
text.setText(Long.toString(((Long) current) + number));
}
else if ( current instanceof Double )
{
text.setText(Double.toString(((Double) current) + number));
}
}
}
catch (NumberFormatException e)
{
// ignore non-numbers
}
}
try {
text.commitEdit();
} catch (ParseException e) {
log.log(Level.FINE, "JFormattedTextField commit failed");
}
}
}
}
public void setPosTextField(PosTextField posTextField) {
field = posTextField;
text.setFormatterFactory(field.getFormatterFactory());
text.setText(field.getText());
text.setValue(field.getValue());
getContentPane().invalidate();
}
} // PosSubBasicKeys

View File

@ -1,105 +0,0 @@
package org.compiere.pos;
import java.awt.KeyboardFocusManager;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Properties;
import javax.swing.JFrame;
import org.compiere.Adempiere;
import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.apps.AKeyboardFocusManager;
import org.compiere.apps.ALogin;
import org.compiere.model.MSession;
import org.compiere.swing.CFrame;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Splash;
public class PosApplication {
private Properties m_ctx;
PosApplication() {
Adempiere.startup(true); // needs to be here for UI
Splash splash = Splash.getSplash();
final CFrame frame = new CFrame();
// Focus Traversal
KeyboardFocusManager.setCurrentKeyboardFocusManager(AKeyboardFocusManager.get());
// FocusManager.getCurrentManager().setDefaultFocusTraversalPolicy(AFocusTraversalPolicy.get());
// this.setFocusTraversalPolicy(AFocusTraversalPolicy.get());
ALogin login = new ALogin(splash);
if (!login.initLogin()) // no automatic login
{
// Center the window
try
{
AEnv.showCenterScreen(login); // HTML load errors
}
catch (Exception ex)
{
}
if (!login.isConnected() || !login.isOKpressed())
AEnv.exit(1);
}
// Check Build
if (!DB.isBuildOK(m_ctx))
AEnv.exit(1);
// Check DB (AppsServer Version checked in Login)
DB.isDatabaseOK(m_ctx);
splash.setText(Msg.getMsg(m_ctx, "Loading"));
splash.toFront();
splash.paint(splash.getGraphics());
//
if (!Adempiere.startupEnvironment(true)) // Load Environment
System.exit(1);
MSession.get (Env.getCtx(), true); // Start Session
int m_WindowNo = AEnv.createWindowNo(frame);
// Default Image
frame.setIconImage(Adempiere.getImage16());
// Setting close operation/listener - teo_sarca [ 1684168 ]
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowListener() {
public void windowClosing(WindowEvent e) {
if (!ADialog.ask(0, null, "ExitApplication?"))
return;
frame.dispose();
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
});
PosBasePanel pos = new PosBasePanel();
pos.init(0,frame);
frame.pack();
splash.dispose();
splash = null;
frame.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
new PosApplication();
}
}

View File

@ -1,423 +0,0 @@
/******************************************************************************
* 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.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FocusTraversalPolicy;
import java.awt.Frame;
import java.awt.GridBagLayout;
import java.awt.KeyboardFocusManager;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Properties;
import java.util.Timer;
import java.util.logging.Level;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import net.miginfocom.swing.MigLayout;
import org.compiere.Adempiere;
import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.apps.AKeyboardFocusManager;
import org.compiere.apps.ALogin;
import org.compiere.apps.AMenu;
import org.compiere.apps.StatusBar;
import org.compiere.apps.form.FormFrame;
import org.compiere.apps.form.FormPanel;
import org.compiere.apps.wf.WFActivity;
import org.compiere.apps.wf.WFPanel;
import org.compiere.grid.ed.VLocationDialog;
import org.compiere.grid.tree.VTreePanel;
import org.compiere.model.MBPartner;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderTax;
import org.compiere.model.MPOS;
import org.compiere.model.MSession;
import org.compiere.swing.CDialog;
import org.compiere.swing.CFrame;
import org.compiere.swing.CPanel;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.Msg;
import org.compiere.util.Splash;
/**
* Point of Sales Main Window.
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
* @version $Id: PosPanel.java,v 1.10 2004/07/12 04:10:04 jjanke Exp $
*/
public class PosBasePanel extends CPanel
//implements FormPanel
{
/**
*
*/
private static final long serialVersionUID = -3010214392188209281L;
/**
* Constructor - see init
*/
public PosBasePanel()
{
super (new MigLayout(" fill","[500!]10[300:350:, fill]",""));
originalKeyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
m_focusMgr = new PosKeyboardFocusManager();
KeyboardFocusManager.setCurrentKeyboardFocusManager(m_focusMgr);
} // PosPanel
/** Window No */
private int m_WindowNo = 0;
/** FormFrame */
private CFrame m_frame;
/** Logger */
private CLogger log = CLogger.getCLogger(getClass());
/** Context */
private Properties m_ctx = Env.getCtx();
/** Sales Rep */
private int m_SalesRep_ID = 0;
/** POS Model */
protected MPOS p_pos = null;
/** Keyoard Focus Manager */
private PosKeyboardFocusManager m_focusMgr = null;
/** Order Panel */
protected SubOrder f_order;
/** Current Line */
protected SubCurrentLine f_curLine;
/** Function Keys */
protected SubFunctionKeys f_functionKeys;
protected CashSubFunctions f_cashfunctions;
private javax.swing.Timer logoutTimer;
PosOrderModel m_order = null;
// Today's (login) date */
private Timestamp m_today = Env.getContextAsDate(m_ctx, "#Date");
private KeyboardFocusManager originalKeyboardFocusManager;
private boolean debug = true;
private CFrame frame;
private HashMap<Integer, POSKeyboard> keyboards = new HashMap<Integer, POSKeyboard>();
/**
* Initialize Panel
* @param WindowNo window
* @param frame parent frame
*/
public void init (int WindowNo, CFrame frame)
{
this.frame = frame;
if ( debug )
frame.setPreferredSize(new Dimension(1024,768));
else
{
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setResizable(false);
}
m_SalesRep_ID = Env.getAD_User_ID(m_ctx);
log.info("init - SalesRep_ID=" + m_SalesRep_ID);
m_WindowNo = WindowNo;
m_frame = frame;
frame.setJMenuBar(null);
//
try
{
if (!dynInit())
{
dispose();
frame.dispose();
return;
}
frame.getContentPane().add(this, BorderLayout.CENTER);
}
catch(Exception e)
{
log.log(Level.SEVERE, "init", e);
}
log.config( "PosPanel.init - " + getPreferredSize());
if ( p_pos.getAutoLogoutDelay() > 0 && logoutTimer == null )
{
logoutTimer = new javax.swing.Timer(1000,
new ActionListener() {
PointerInfo pi = null;
long lastMouseMove = System.currentTimeMillis();
long lastKeyboardEvent = System.currentTimeMillis();
public void actionPerformed(ActionEvent e) {
long now = e.getWhen();
PointerInfo newPi = MouseInfo.getPointerInfo();
// mouse moved
if ( newPi != null && pi != null
&& !pi.getLocation().equals(newPi.getLocation()) )
{
lastMouseMove = now;
}
pi = newPi;
lastKeyboardEvent = m_focusMgr.getLastWhen();
if ( p_pos.getAutoLogoutDelay()*1000 < now - Math.max(lastKeyboardEvent, lastMouseMove) )
{
// new PosLogin(this);
}
}
});
logoutTimer.start();
}
m_focusMgr.start();
} // init
/**
* Dispose - Free Resources
*/
public void dispose()
{
keyboards.clear();
keyboards = null;
if ( logoutTimer != null )
logoutTimer.stop();
logoutTimer = null;
if (m_focusMgr != null)
m_focusMgr.stop();
m_focusMgr = null;
KeyboardFocusManager.setCurrentKeyboardFocusManager(originalKeyboardFocusManager);
//
if (f_order != null)
f_order.dispose();
f_order = null;
if (f_curLine != null)
{
// if ( m_order != null )
// m_order.deleteOrder();
f_curLine.dispose();
}
f_curLine = null;
if (f_functionKeys != null)
f_functionKeys.dispose();
f_functionKeys = null;
if (f_cashfunctions != null)
f_cashfunctions.dispose();
f_cashfunctions = null;
if (m_frame != null)
m_frame.dispose();
m_frame = null;
m_ctx = null;
} // dispose
/**************************************************************************
* Dynamic Init.
* PosPanel has a GridBagLayout.
* The Sub Panels return their position
*/
private boolean dynInit()
{
if (!setMPOS())
return false;
frame.setTitle("Adempiere POS: " + p_pos.getName());
// Create Sub Panels
f_order = new SubOrder (this);
add (f_order, "split 2, flowy, growx, spany");
//
f_curLine = new SubCurrentLine (this);
add (f_curLine, "h 300, growx, growy, gaptop 30");
f_functionKeys = new SubFunctionKeys (this);
add (f_functionKeys, "aligny top, h 500, growx, growy, flowy, split 2");
return true;
} // dynInit
/**
* Set MPOS
* @return true if found/set
*/
private boolean setMPOS()
{
MPOS[] poss = null;
if (m_SalesRep_ID == 100) // superUser
poss = getPOSs (0);
else
poss = getPOSs (m_SalesRep_ID);
//
if (poss.length == 0)
{
ADialog.error(m_WindowNo, m_frame, "NoPOSForUser");
return false;
}
else if (poss.length == 1)
{
p_pos = poss[0];
return true;
}
// Select POS
String msg = Msg.getMsg(m_ctx, "SelectPOS");
String title = Env.getHeader(m_ctx, m_WindowNo);
Object selection = JOptionPane.showInputDialog(m_frame, msg, title,
JOptionPane.QUESTION_MESSAGE, null, poss, poss[0]);
if (selection != null)
{
p_pos = (MPOS)selection;
return true;
}
return false;
} // setMPOS
/**
* Get POSs for specific Sales Rep or all
* @param SalesRep_ID
* @return array of POS
*/
private MPOS[] getPOSs (int SalesRep_ID)
{
String pass_field = "SalesRep_ID";
int pass_ID = SalesRep_ID;
if (SalesRep_ID==0)
{
pass_field = "AD_Client_ID";
pass_ID = Env.getAD_Client_ID(m_ctx);
}
return MPOS.getAll(m_ctx, pass_field, pass_ID);
} // getPOSs
/**************************************************************************
* Get Today's date
* @return date
*/
public Timestamp getToday()
{
return m_today;
} // getToday
/**
* New Order
*
*/
public void newOrder()
{
log.info( "PosPanel.newOrder");
f_order.setC_BPartner_ID(0);
m_order = null;
m_order = PosOrderModel.createOrder(p_pos, f_order.getBPartner());
f_curLine.newLine();
f_curLine.f_name.requestFocusInWindow();
updateInfo();
} // 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 getProperties m_ctx
*/
public Properties getCtx()
{
return m_ctx;
}
public void updateInfo()
{
// reload order
if ( m_order != null )
{
m_order.reload();
}
if ( f_curLine != null )
f_curLine.updateTable(m_order);
if (f_order != null)
{
f_order.updateOrder();
}
}
/**
* @param m_c_order_id
*/
public void setOldOrder(int m_c_order_id)
{
if ( m_order != null )
m_order.deleteOrder();
if ( m_c_order_id == 0 )
m_order = null;
else
m_order = new PosOrderModel(m_ctx , m_c_order_id, null, p_pos);
updateInfo();
}
/**
* @param m_c_order_id
*/
public void setOrder(int m_c_order_id)
{
if ( m_c_order_id == 0 )
m_order = null;
else
m_order = new PosOrderModel(m_ctx , m_c_order_id, null, p_pos);
}
public POSKeyboard getKeyboard(int keyLayoutId) {
if ( keyboards.containsKey(keyLayoutId) )
return keyboards.get(keyLayoutId);
else
{
POSKeyboard keyboard = new POSKeyboard(this, keyLayoutId);
keyboards.put(keyLayoutId, keyboard);
return keyboard;
}
}
} // PosPanel

View File

@ -1,30 +0,0 @@
/******************************************************************************
* 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 org.compiere.model.MPOSKey;
/**
* Interface for listening to on screen key events
* @author Paul Bowden
* Adaxa Pty Ltd
*
*/
public interface PosKeyListener {
void keyReturned( MPOSKey key );
}

View File

@ -1,250 +0,0 @@
/******************************************************************************
* 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.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JScrollBar;
import javax.swing.SwingConstants;
import net.miginfocom.swing.MigLayout;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.model.MImage;
import org.compiere.model.MPOSKey;
import org.compiere.model.MPOSKeyLayout;
import org.compiere.print.MPrintColor;
import org.compiere.print.MPrintFont;
import org.compiere.swing.CButton;
import org.compiere.swing.CPanel;
import org.compiere.swing.CScrollPane;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
/**
* Button panel supporting multiple linked layouts
* @author Paul Bowden
* Adaxa Pty Ltd
*
*/
public class PosKeyPanel extends CPanel implements ActionListener {
/**
*
*/
private static final long serialVersionUID = -1773720355288801510L;
/**
* Constructor
*/
public PosKeyPanel (int C_POSKeyLayout_ID, PosKeyListener caller)
{
if (C_POSKeyLayout_ID == 0)
return;
setLayout(cardLayout);
add(createCard(C_POSKeyLayout_ID), Integer.toString(C_POSKeyLayout_ID));
currentLayout = C_POSKeyLayout_ID;
cardLayout.show(this, Integer.toString(C_POSKeyLayout_ID));
this.caller = caller;
} // PosSubFunctionKeys
/** layout */
private CardLayout cardLayout = new CardLayout();
/** Map of map of keys */
private HashMap<Integer, HashMap<Integer, MPOSKey>> keymap = new HashMap<Integer, HashMap<Integer,MPOSKey>>();
/** Currently displayed layout */
int currentLayout;
/** Logger */
private static CLogger log = CLogger.getCLogger(PosKeyPanel.class);
/** Caller */
private PosKeyListener caller;
/**
* @return
*/
private CPanel createCard(int C_POSKeyLayout_ID) {
// already added
if ( keymap.containsKey(C_POSKeyLayout_ID) )
{
return null;
}
CPanel card = new CPanel();
card.setLayout(new MigLayout("fill, ins 0"));
MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
Color stdColor = Color.lightGray;
if (keyLayout.getAD_PrintColor_ID() != 0)
{
MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
stdColor = color.getColor();
}
Font stdFont = AdempierePLAF.getFont_Field();
if (keyLayout.getAD_PrintFont_ID() != 0)
{
MPrintFont font = MPrintFont.get(keyLayout.getAD_PrintFont_ID());
stdFont = font.getFont();
}
if (keyLayout.get_ID() == 0)
return null;
MPOSKey[] keys = keyLayout.getKeys(false);
HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
keymap.put(C_POSKeyLayout_ID, map);
int COLUMNS = 3; // Min Columns
int ROWS = 3; // Min Rows
int noKeys = keys.length;
int cols = keyLayout.getColumns();
if ( cols == 0 )
cols = COLUMNS;
int buttons = 0;
log.fine( "PosSubFunctionKeys.init - NoKeys=" + noKeys
+ ", Cols=" + cols);
// Content
CPanel content = new CPanel (new MigLayout("fill, wrap " + Math.max(cols, 3)));
String buttonSize = "h 50, w 50, growx, growy, sg button,";
for (MPOSKey key : keys)
{
if ( key.getSubKeyLayout_ID() > 0 )
{
CPanel subCard = createCard(key.getSubKeyLayout_ID());
if ( subCard != null )
add(subCard, Integer.toString(key.getSubKeyLayout_ID()));
}
map.put(key.getC_POSKey_ID(), key);
Color keyColor = stdColor;
Font keyFont = stdFont;
StringBuffer buttonHTML = new StringBuffer("<html><p>");
if (key.getAD_PrintColor_ID() != 0)
{
MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
keyColor = color.getColor();
}
if ( key.getAD_PrintFont_ID() != 0)
{
MPrintFont font = MPrintFont.get(key.getAD_PrintFont_ID());
keyFont = font.getFont();
}
buttonHTML.append(key.getName());
buttonHTML.append("</p></html>");
log.fine( "#" + map.size() + " - " + keyColor);
CButton button = new CButton(buttonHTML.toString());
button.setBackground(keyColor);
button.setFont(keyFont);
if ( key.getAD_Image_ID() != 0 )
{
MImage image = MImage.get(Env.getCtx(), key.getAD_Image_ID());
Icon icon = image.getIcon();
button.setIcon(icon);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setHorizontalTextPosition(SwingConstants.CENTER);
}
button.setFocusable(false);
if ( !key.isActive() )
button.setEnabled(false);
button.setActionCommand(String.valueOf(key.getC_POSKey_ID()));
button.addActionListener(this);
String constraints = buttonSize;
int size = 1;
if ( key.getSpanX() > 1 )
{
constraints += "spanx " + key.getSpanX() + ",";
size = key.getSpanX();
}
if ( key.getSpanY() > 1 )
{
constraints += "spany " + key.getSpanY() + ",";
size = size*key.getSpanY();
}
buttons = buttons + size;
content.add (button, constraints);
}
int rows = Math.max ((buttons / cols), ROWS);
if ( buttons % cols > 0 )
rows = rows + 1;
for (int i = buttons; i < rows*cols; i++)
{
CButton button = new CButton("");
button.setFocusable(false);
button.setReadWrite(false);
content.add (button, buttonSize);
}
CScrollPane scroll = new CScrollPane(content);
// scroll.setPreferredSize(new Dimension( 600 - 20, 400-20));
card.add (scroll, "growx, growy");
// increase scrollbar width for touchscreen
scroll.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0,30));
return card;
}
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0 || keymap == null)
return;
log.info( "PosSubFunctionKeys - actionPerformed: " + action);
HashMap<Integer, MPOSKey> currentKeymap = keymap.get(currentLayout);
try
{
int C_POSKey_ID = Integer.parseInt(action);
MPOSKey key = currentKeymap.get(C_POSKey_ID);
// switch layout
if ( key.getSubKeyLayout_ID() > 0 )
{
currentLayout = key.getSubKeyLayout_ID();
cardLayout.show(this, Integer.toString(key.getSubKeyLayout_ID()));
}
else
{
caller.keyReturned(key);
}
}
catch (Exception ex)
{
}
} // actionPerformed
}

View File

@ -47,10 +47,6 @@ public class PosKeyboardFocusManager extends DefaultKeyboardFocusManager
/** Last Key Type */
private long m_lastWhen = 0;
public long getLastWhen() {
return m_lastWhen;
}
/** Timer */
private javax.swing.Timer m_timer = null;
/** Logger */

View File

@ -1,81 +0,0 @@
package org.compiere.pos;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.AEnv;
import org.compiere.apps.AppsAction;
import org.compiere.model.MUser;
import org.compiere.swing.CButton;
import org.compiere.swing.CDialog;
import org.compiere.swing.CLabel;
import org.compiere.swing.CPanel;
import org.compiere.util.Env;
import org.compiere.util.Msg;
public class PosLogin extends CDialog implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 8490567722808711399L;
private PosBasePanel posPanel;
private PosTextField username;
private PosTextField pin;
private CButton bProcess;
/**
* Constructor
* @param posPanel POS Panel
*/
public PosLogin (PosBasePanel posPanel)
{
super (AEnv.getFrame(posPanel),Msg.translate(posPanel.getCtx(), "Login"), true);
init();
this.posPanel = posPanel;
}
private void init() {
CPanel panel = new CPanel();
panel.setLayout(new MigLayout());
getContentPane().add(panel);
panel.add(new CLabel(Msg.translate(posPanel.getCtx(),"SalesRep_ID")));
username = new PosTextField(Msg.translate(posPanel.getCtx(),"SalesRep_ID"),
posPanel, posPanel.p_pos.getOSK_KeyLayout_ID());
panel.add( username, "wrap");
panel.add(new CLabel(Msg.translate(posPanel.getCtx(), "UserPIN")));
pin = new PosTextField(Msg.translate(posPanel.getCtx(), "UserPIN"), posPanel, posPanel.p_pos.getOSNP_KeyLayout_ID());
panel.add(pin, "");
AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
act.setDelegate(this);
bProcess = (CButton)act.getButton();
bProcess.setFocusable(false);
panel.add (bProcess, "h 50!, w 50!");
pack();
}
@Override
public void actionPerformed(ActionEvent e) {
if ( e.getSource().equals(bProcess) )
{
MUser.get(posPanel.getCtx(), username.getText(), pin.getText());
}
dispose();
}
}

View File

@ -1,459 +0,0 @@
/******************************************************************************
* 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.BigDecimal;
import java.util.HashMap;
import java.util.Properties;
import org.compiere.model.MBPartner;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderTax;
import org.compiere.model.MPOS;
import org.compiere.model.MPayment;
import org.compiere.model.MPaymentProcessor;
import org.compiere.model.MProduct;
import org.compiere.process.DocAction;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.ValueNamePair;
/**
* Wrapper for standard order
* @author Paul Bowden
* Adaxa Pty Ltd
*
*/
public class PosOrderModel extends MOrder {
private MPOS m_pos;
public PosOrderModel(Properties ctx, int C_Order_ID, String trxName, MPOS pos) {
super(ctx, C_Order_ID, trxName);
m_pos = pos;
}
/**
* Get/create Order
*
* @return order or null
*/
public static PosOrderModel createOrder(MPOS pos, MBPartner partner) {
PosOrderModel order = new PosOrderModel(Env.getCtx(), 0, null, pos);
order.setAD_Org_ID(pos.getAD_Org_ID());
order.setIsSOTrx(true);
order.setC_POS_ID(pos.getC_POS_ID());
if (pos.getC_DocType_ID() != 0)
order.setC_DocTypeTarget_ID(pos.getC_DocType_ID());
else
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS);
if (partner == null || partner.get_ID() == 0)
partner = pos.getBPartner();
if (partner == null || partner.get_ID() == 0) {
throw new AdempierePOSException("No BPartner for order");
}
order.setBPartner(partner);
//
order.setM_PriceList_ID(pos.getM_PriceList_ID());
order.setM_Warehouse_ID(pos.getM_Warehouse_ID());
order.setSalesRep_ID(pos.getSalesRep_ID());
order.setPaymentRule(MOrder.PAYMENTRULE_Cash);
if (!order.save())
{
order = null;
throw new AdempierePOSException("Save order failed");
}
return order;
} // createOrder
/**
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright ConSerTi
*/
public void setBPartner(MBPartner partner)
{
if (getDocStatus().equals("DR"))
{
if (partner == null || partner.get_ID() == 0) {
throw new AdempierePOSException("no BPartner");
}
else
{
log.info("SubCurrentLine.getOrder -" + partner);
super.setBPartner(partner);
MOrderLine[] lineas = getLines();
for (int i = 0; i < lineas.length; i++)
{
lineas[i].setC_BPartner_ID(partner.getC_BPartner_ID());
lineas[i].setTax();
lineas[i].save();
}
saveEx();
}
}
}
/**
* Create new Line
*
* @return line or null
*/
public MOrderLine createLine(MProduct product, BigDecimal QtyOrdered,
BigDecimal PriceActual) {
if (!getDocStatus().equals("DR") )
return null;
//add new line or increase qty
// catch Exceptions at order.getLines()
int numLines = 0;
MOrderLine[] lines = null;
try
{
lines = getLines(null,"Line");
numLines = lines.length;
for (int i = 0; i < numLines; i++)
{
if (lines[i].getM_Product_ID() == product.getM_Product_ID())
{
//increase qty
BigDecimal current = lines[i].getQtyEntered();
BigDecimal toadd = QtyOrdered;
BigDecimal total = current.add(toadd);
lines[i].setQty(total);
lines[i].setPrice(); // sets List/limit
if ( PriceActual.compareTo(Env.ZERO) > 0 )
lines[i].setPrice(PriceActual);
lines[i].save();
return lines[i];
}
}
}
catch (Exception e)
{
log.severe("Order lines cannot be created - " + e.getMessage());
}
//create new line
MOrderLine line = new MOrderLine(this);
line.setProduct(product);
line.setQty(QtyOrdered);
line.setPrice(); // sets List/limit
if ( PriceActual.compareTo(Env.ZERO) > 0 )
line.setPrice(PriceActual);
line.save();
return line;
} // createLine
/**
* Delete order from database
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public boolean deleteOrder () {
if (getDocStatus().equals("DR"))
{
MOrderLine[] lines = getLines();
if (lines != null)
{
int numLines = lines.length;
if (numLines > 0)
for (int i = numLines - 1; i >= 0; i--)
{
if (lines[i] != null)
deleteLine(lines[i].getC_Order_ID());
}
}
MOrderTax[] taxs = 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;
}
}
getLines(true, null); // requery order
return delete(true);
}
return false;
} // deleteOrder
/**
* to erase the lines from order
* @return true if deleted
*/
public void deleteLine (int C_OrderLine_ID) {
if ( C_OrderLine_ID != -1 )
{
for ( MOrderLine line : getLines(true, "M_Product_ID") )
{
if ( line.getC_OrderLine_ID() == C_OrderLine_ID )
{
line.delete(true);
}
}
}
} // deleteLine
/**
* Process Order
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public boolean processOrder()
{
//Returning orderCompleted to check for order completeness
boolean orderCompleted = false;
// check if order completed OK
if (getDocStatus().equals("DR") || getDocStatus().equals("IP") )
{
setDocAction(DocAction.ACTION_Complete);
try
{
if (processIt(DocAction.ACTION_Complete) )
{
save();
}
else
{
log.info( "Process Order FAILED");
}
}
catch (Exception e)
{
log.severe("Order can not be completed - " + e.getMessage());
}
finally
{ // When order failed convert it back to draft so it can be processed
if( getDocStatus().equals("IN") )
{
setDocStatus("DR");
}
else if( getDocStatus().equals("CO") )
{
orderCompleted = true;
log.info( "SubCheckout - processOrder OK");
}
else
{
log.info( "SubCheckout - processOrder - unrecognized DocStatus");
}
} // try-finally
}
return orderCompleted;
} // processOrder
public BigDecimal getTaxAmt() {
BigDecimal taxAmt = Env.ZERO;
for (MOrderTax tax : getTaxes(true))
{
taxAmt = taxAmt.add(tax.getTaxAmt());
}
return taxAmt;
}
public BigDecimal getSubtotal() {
return getGrandTotal().subtract(getTaxAmt());
}
public BigDecimal getPaidAmt()
{
String sql = "SELECT sum(PayAmt) FROM C_Payment WHERE C_Order_ID = ? AND DocStatus IN ('CO','CL')";
BigDecimal received = DB.getSQLValueBD(null, sql, getC_Order_ID());
if ( received == null )
received = Env.ZERO;
sql = "SELECT sum(Amount) FROM C_CashLine WHERE C_Invoice_ID = ? ";
BigDecimal cashline = DB.getSQLValueBD(null, sql, getC_Invoice_ID());
if ( cashline != null )
received = received.add(cashline);
return received;
}
public boolean payCash(BigDecimal amt) {
MPayment payment = createPayment(MPayment.TENDERTYPE_Cash);
payment.setC_CashBook_ID(m_pos.getC_CashBook_ID());
payment.setAmount(getC_Currency_ID(), amt);
payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID());
payment.save();
payment.setDocAction(MPayment.DOCACTION_Complete);
payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
if ( payment.processIt(MPayment.DOCACTION_Complete) )
{
payment.save();
return true;
}
else return false;
} // payCash
public boolean payCheck(BigDecimal amt, String accountNo, String routingNo, String checkNo)
{
MPayment payment = createPayment(MPayment.TENDERTYPE_Check);
payment.setAmount(getC_Currency_ID(), amt);
payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID());
payment.setAccountNo(accountNo);
payment.setRoutingNo(routingNo);
payment.setCheckNo(checkNo);
payment.saveEx();
payment.setDocAction(MPayment.DOCACTION_Complete);
payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
if ( payment.processIt(MPayment.DOCACTION_Complete) )
{
payment.saveEx();
return true;
}
else return false;
} // payCheck
public boolean payCreditCard(BigDecimal amt, String accountName, int month, int year,
String cardNo, String cvc, String cardtype)
{
MPayment payment = createPayment(MPayment.TENDERTYPE_Check);
payment.setAmount(getC_Currency_ID(), amt);
payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID());
payment.setCreditCard(MPayment.TRXTYPE_Sales, cardtype,
cardNo, cvc, month, year);
payment.saveEx();
payment.setDocAction(MPayment.DOCACTION_Complete);
payment.setDocStatus(MPayment.DOCSTATUS_Drafted);
if ( payment.processIt(MPayment.DOCACTION_Complete) )
{
payment.saveEx();
return true;
}
else return false;
} // payCheck
private MPayment createPayment(String tenderType)
{
MPayment payment = new MPayment(getCtx(), 0, null);
payment.setAD_Org_ID(m_pos.getAD_Org_ID());
payment.setTenderType(tenderType);
payment.setC_Order_ID(getC_Order_ID());
payment.setIsReceipt(true);
payment.setC_BPartner_ID(getC_BPartner_ID());
return payment;
}
public void reload() {
load( get_TrxName());
getLines(true, "");
}
/**
* Duplicated from MPayment
* Get Accepted Credit Cards for amount
* @param amt trx amount
* @return credit cards
*/
public ValueNamePair[] getCreditCards (BigDecimal amt)
{
try
{
MPaymentProcessor[] m_mPaymentProcessors = MPaymentProcessor.find (getCtx (), null, null,
getAD_Client_ID (), getAD_Org_ID(), getC_Currency_ID (), amt, get_TrxName());
//
HashMap<String,ValueNamePair> map = new HashMap<String,ValueNamePair>(); // to eliminate duplicates
for (int i = 0; i < m_mPaymentProcessors.length; i++)
{
if (m_mPaymentProcessors[i].isAcceptAMEX ())
map.put (MPayment.CREDITCARDTYPE_Amex, getCreditCardPair (MPayment.CREDITCARDTYPE_Amex));
if (m_mPaymentProcessors[i].isAcceptDiners ())
map.put (MPayment.CREDITCARDTYPE_Diners, getCreditCardPair (MPayment.CREDITCARDTYPE_Diners));
if (m_mPaymentProcessors[i].isAcceptDiscover ())
map.put (MPayment.CREDITCARDTYPE_Discover, getCreditCardPair (MPayment.CREDITCARDTYPE_Discover));
if (m_mPaymentProcessors[i].isAcceptMC ())
map.put (MPayment.CREDITCARDTYPE_MasterCard, getCreditCardPair (MPayment.CREDITCARDTYPE_MasterCard));
if (m_mPaymentProcessors[i].isAcceptCorporate ())
map.put (MPayment.CREDITCARDTYPE_PurchaseCard, getCreditCardPair (MPayment.CREDITCARDTYPE_PurchaseCard));
if (m_mPaymentProcessors[i].isAcceptVisa ())
map.put (MPayment.CREDITCARDTYPE_Visa, getCreditCardPair (MPayment.CREDITCARDTYPE_Visa));
} // for all payment processors
//
ValueNamePair[] retValue = new ValueNamePair[map.size ()];
map.values ().toArray (retValue);
log.fine("getCreditCards - #" + retValue.length + " - Processors=" + m_mPaymentProcessors.length);
return retValue;
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
} // getCreditCards
/**
*
* Duplicated from MPayment
* Get Type and name pair
* @param CreditCardType credit card Type
* @return pair
*/
private ValueNamePair getCreditCardPair (String CreditCardType)
{
return new ValueNamePair (CreditCardType, getCreditCardName(CreditCardType));
} // getCreditCardPair
/**
*
* Duplicated from MPayment
* Get Name of Credit Card
* @param CreditCardType credit card type
* @return Name
*/
public String getCreditCardName(String CreditCardType)
{
if (CreditCardType == null)
return "--";
else if (MPayment.CREDITCARDTYPE_MasterCard.equals(CreditCardType))
return "MasterCard";
else if (MPayment.CREDITCARDTYPE_Visa.equals(CreditCardType))
return "Visa";
else if (MPayment.CREDITCARDTYPE_Amex.equals(CreditCardType))
return "Amex";
else if (MPayment.CREDITCARDTYPE_ATM.equals(CreditCardType))
return "ATM";
else if (MPayment.CREDITCARDTYPE_Diners.equals(CreditCardType))
return "Diners";
else if (MPayment.CREDITCARDTYPE_Discover.equals(CreditCardType))
return "Discover";
else if (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CreditCardType))
return "PurchaseCard";
return "?" + CreditCardType + "?";
} // getCreditCardName
} // PosOrderModel.class

View File

@ -1,18 +1,406 @@
/******************************************************************************
* 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.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.KeyboardFocusManager;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
import javax.swing.JOptionPane;
import org.compiere.apps.ADialog;
import org.compiere.apps.StatusBar;
import org.compiere.apps.form.FormFrame;
import org.compiere.apps.form.FormPanel;
import org.compiere.model.MPOS;
import org.compiere.swing.CPanel;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
public class PosPanel implements FormPanel {
private PosBasePanel panel;
/**
* Point of Sales Main Window.
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
* @version $Id: PosPanel.java,v 1.10 2004/07/12 04:10:04 jjanke Exp $
*/
public class PosPanel extends CPanel
implements FormPanel
{
/**
*
*/
private static final long serialVersionUID = -3010214392188209281L;
public void dispose() {
panel.dispose();
/**
* Constructor - see init
*/
public PosPanel()
{
super (new GridBagLayout());
originalKeyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
m_focusMgr = new PosKeyboardFocusManager();
KeyboardFocusManager.setCurrentKeyboardFocusManager(m_focusMgr);
} // PosPanel
/** Window No */
private int m_WindowNo = 0;
/** FormFrame */
private FormFrame m_frame;
/** Logger */
private CLogger log = CLogger.getCLogger(getClass());
/** Context */
private Properties m_ctx = Env.getCtx();
/** Sales Rep */
private int m_SalesRep_ID = 0;
/** POS Model */
protected MPOS p_pos = null;
/** Keyoard Focus Manager */
private PosKeyboardFocusManager m_focusMgr = null;
/** Status Bar */
protected StatusBar f_status = new StatusBar();
/** Customer Panel */
protected SubBPartner f_bpartner = null;
/** Sales Rep Panel */
protected SubSalesRep f_salesRep = null;
/** Current Line */
protected SubCurrentLine f_curLine = null;
/** Product Selection */
protected SubProduct f_product = null;
/** All Lines */
protected SubLines f_lines = null;
/** Function Keys */
protected SubFunctionKeys f_functionKeys = null;
/** Checkout */
protected SubCheckout f_checkout = null;
/** Basic Keys */
// protected SubBasicKeys f_basicKeys = null;
/** Product Query Window */
protected QueryProduct f_queryProduct = null;
/** BPartner Query Window */
protected QueryBPartner f_queryBPartner = null;
/** Ticket Query Window */
protected QueryTicket f_queryTicket = null;
protected CashSubFunctions f_cashfunctions;
// Today's (login) date */
private Timestamp m_today = Env.getContextAsDate(m_ctx, "#Date");
private KeyboardFocusManager originalKeyboardFocusManager;
/**
* Initialize Panel
* @param WindowNo window
* @param frame parent frame
*/
public void init (int WindowNo, FormFrame frame)
{
frame.setMaximize(true);
m_SalesRep_ID = Env.getAD_User_ID(m_ctx);
log.info("init - SalesRep_ID=" + m_SalesRep_ID);
m_WindowNo = WindowNo;
m_frame = frame;
//
try
{
if (!dynInit())
{
dispose();
frame.dispose();
return;
}
frame.getContentPane().add(this, BorderLayout.CENTER);
frame.getContentPane().add(f_status, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension (850-20,500-20));
}
catch(Exception e)
{
log.log(Level.SEVERE, "init", e);
}
log.config( "PosPanel.init - " + getPreferredSize());
m_focusMgr.start();
} // init
/**
* Dispose - Free Resources
*/
public void dispose()
{
if (m_focusMgr != null)
m_focusMgr.stop();
m_focusMgr = null;
KeyboardFocusManager.setCurrentKeyboardFocusManager(originalKeyboardFocusManager);
//
if (f_bpartner != null)
f_bpartner.dispose();
f_bpartner = null;
if (f_salesRep != null)
f_salesRep.dispose();
f_salesRep = null;
if (f_curLine != null)
{
f_curLine.deleteOrder();
f_curLine.dispose();
}
f_curLine = null;
if (f_product != null)
f_product.dispose();
f_product = null;
if (f_lines != null)
f_lines.dispose();
f_lines = null;
if (f_functionKeys != null)
f_functionKeys.dispose();
f_functionKeys = null;
if (f_checkout != null)
f_checkout.dispose();
f_checkout = null;
/* if (f_basicKeys != null)
f_basicKeys.dispose(); removed by ConSerTi upon not appreciating its functionality
f_basicKeys = null;
*/ //
if (f_queryProduct != null)
f_queryProduct.dispose();
f_queryProduct = null;
if (f_queryBPartner != null)
f_queryBPartner.dispose();
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)
m_frame.dispose();
m_frame = null;
m_ctx = null;
} // dispose
/**************************************************************************
* Dynamic Init.
* PosPanel has a GridBagLayout.
* The Sub Panels return their position
*/
private boolean dynInit()
{
if (!setMPOS())
return false;
// Create Sub Panels
f_bpartner = new SubBPartner (this);
add (f_bpartner, f_bpartner.getGridBagConstraints());
//
f_salesRep = new SubSalesRep (this);
add (f_salesRep, f_salesRep.getGridBagConstraints());
//
f_curLine = new SubCurrentLine (this);
add (f_curLine, f_curLine.getGridBagConstraints());
//
f_product = new SubProduct (this);
add (f_product, f_product.getGridBagConstraints());
//
f_lines = new SubLines (this);
add (f_lines, f_lines.getGridBagConstraints());
//
f_functionKeys = new SubFunctionKeys (this);
add (f_functionKeys, f_functionKeys.getGridBagConstraints());
//
f_checkout = new SubCheckout (this);
add (f_checkout, f_checkout.getGridBagConstraints());
//
/* f_basicKeys = new SubBasicKeys (this);
add (f_basicKeys, f_basicKeys.getGridBagConstraints()); removed by ConSerTi upon not appreciating its functionality
*/
// -- Query
f_queryProduct = new QueryProduct (this);
add (f_queryProduct, f_queryProduct.getGridBagConstraints());
//
f_queryBPartner = new QueryBPartner (this);
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();
return true;
} // dynInit
/**
* Set MPOS
* @return true if found/set
*/
private boolean setMPOS()
{
MPOS[] poss = null;
if (m_SalesRep_ID == 100) // superUser
poss = getPOSs (0);
else
poss = getPOSs (m_SalesRep_ID);
//
if (poss.length == 0)
{
ADialog.error(m_WindowNo, m_frame, "NoPOSForUser");
return false;
}
else if (poss.length == 1)
{
p_pos = poss[0];
return true;
}
// Select POS
String msg = Msg.getMsg(m_ctx, "SelectPOS");
String title = Env.getHeader(m_ctx, m_WindowNo);
Object selection = JOptionPane.showInputDialog(m_frame, msg, title,
JOptionPane.QUESTION_MESSAGE, null, poss, poss[0]);
if (selection != null)
{
p_pos = (MPOS)selection;
return true;
}
return false;
} // setMPOS
/**
* Get POSs for specific Sales Rep or all
* @param SalesRep_ID
* @return array of POS
*/
private MPOS[] getPOSs (int SalesRep_ID)
{
String pass_field = "SalesRep_ID";
int pass_ID = SalesRep_ID;
if (SalesRep_ID==0)
{
pass_field = "AD_Client_ID";
pass_ID = Env.getAD_Client_ID(m_ctx);
}
return MPOS.getAll(m_ctx, pass_field, pass_ID);
} // getPOSs
/**
* Set Visible
* @param aFlag visible
*/
public void setVisible (boolean aFlag)
{
super.setVisible (aFlag);
f_product.f_name.requestFocus();
} // setVisible
/**
* Open Query Window
* @param panel
*/
public void openQuery (CPanel panel)
{
f_bpartner.setVisible(false);
f_salesRep.setVisible(false);
f_curLine.setVisible(false);
f_product.setVisible(false);
f_checkout.setVisible(false);
// f_basicKeys.setVisible(false); removed by ConSerTi upon not appreciating its functionality
f_lines.setVisible(false);
f_functionKeys.setVisible(false);
panel.setVisible(true);
} // closeQuery
/**
* Close Query Window
* @param panel
*/
public void closeQuery (CPanel panel)
{
panel.setVisible(false);
f_bpartner.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_functionKeys.setVisible(true);
f_checkout.setVisible(true);
} // closeQuery
/**************************************************************************
* Get Today's date
* @return date
*/
public Timestamp getToday()
{
return m_today;
} // getToday
/**
* New Order
*
*/
public void newOrder()
{
log.info( "PosPanel.newOrder");
f_bpartner.setC_BPartner_ID(0);
f_curLine.newOrder();
f_curLine.newLine();
f_product.f_name.requestFocus();
updateInfo();
} // newOrder
/**
* Get the number of the window for the function calls that it needs
*
* @return the window number
*/
public int getWindowNo()
{
return m_WindowNo;
}
public void init(int WindowNo, FormFrame frame) {
panel = new PosBasePanel();
panel.init(0, frame);
/**
* 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
}

View File

@ -1,509 +0,0 @@
/******************************************************************************
* 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.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Properties;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
import javax.swing.text.MaskFormatter;
import net.miginfocom.swing.MigLayout;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.apps.AppsAction;
import org.compiere.model.MCurrency;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MPOS;
import org.compiere.model.MPOSKey;
import org.compiere.model.MPayment;
import org.compiere.model.MPaymentValidate;
import org.compiere.swing.CButton;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CDialog;
import org.compiere.swing.CLabel;
import org.compiere.swing.CPanel;
import org.compiere.swing.CTextField;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
public class PosPayment extends CDialog implements PosKeyListener, VetoableChangeListener, ActionListener {
/**
*
*/
private static final long serialVersionUID = 1961106531807910948L;
@Override
public void actionPerformed(ActionEvent e) {
if ( e.getSource().equals(fTenderAmt) || e.getSource().equals(fPayAmt) )
{
BigDecimal tender = new BigDecimal( fTenderAmt.getText() );
BigDecimal pay = new BigDecimal( fPayAmt.getText() );
if ( tender.compareTo(Env.ZERO) != 0 )
{
fReturnAmt.setValue(tender.subtract(pay));
}
return;
}
if ( e.getSource().equals(f_bProcess))
{
processPayment();
}
if ( e.getSource().equals(f_bCancel))
{
dispose();
return;
}
setTotals();
super.actionPerformed(e);
}
private void processPayment() {
try {
String tenderType = ((ValueNamePair) tenderTypePick.getValue()).getID();
BigDecimal amt = new BigDecimal(fPayAmt.getText());
if ( tenderType.equals(MPayment.TENDERTYPE_Cash) )
{
p_posPanel.m_order.payCash(amt);
}
else if ( tenderType.equals(MPayment.TENDERTYPE_Check) )
{
p_posPanel.m_order.payCheck(amt,fCheckAccountNo.getText(), fCheckRouteNo.getText(), fCheckNo.getText());
p_posPanel.f_order.openCashDrawer();
}
else if ( tenderType.equals(MPayment.TENDERTYPE_CreditCard) )
{
String error = null;
error = MPaymentValidate.validateCreditCardExp(fCCardMonth.getText());
if ( error != null && !error.isEmpty() )
{
ADialog.warn(0, p_posPanel, error);
return;
}
int month = MPaymentValidate.getCreditCardExpMM(fCCardMonth.getText());
int year = MPaymentValidate.getCreditCardExpYY(fCCardMonth.getText());
String type = ((ValueNamePair) fCCardType.getSelectedItem()).getValue();
error = MPaymentValidate.validateCreditCardNumber(fCCardNo.getText(), type);
if ( error != null && !error.isEmpty() )
{
ADialog.warn(0, p_posPanel, error);
return;
}
p_posPanel.m_order.payCreditCard(amt, fCCardName.getText(),
month, year, fCCardNo.getText(), fCCardVC.getText(), type);
p_posPanel.f_order.openCashDrawer();
}
else if ( tenderType.equals(MPayment.TENDERTYPE_Account) )
{
p_posPanel.m_order.payCash(amt);
p_posPanel.f_order.openCashDrawer();
}
else
{
ADialog.warn(0, this, "Unsupported payment type");
}
p_posPanel.f_order.openCashDrawer();
setTotals();
}
catch (Exception e )
{
ADialog.warn(0, this, "Payment processing failed: " + e.getMessage());
}
}
private PosBasePanel p_posPanel;
private MPOS p_pos;
private Properties p_ctx;
private PosOrderModel p_order;
private CTextField fTotal = new CTextField(10);
private CTextField fBalance = new CTextField(10);
private CComboBox tenderTypePick = new CComboBox();
private PosTextField fPayAmt;
private CButton f_bProcess;
private boolean paid = false;
private BigDecimal balance = Env.ZERO;
private PosTextField fCheckAccountNo;
private PosTextField fCheckNo;
private PosTextField fCheckRouteNo;
private PosTextField fCCardNo;
private PosTextField fCCardName;
private CComboBox fCCardType;
private PosTextField fCCardMonth;
private PosTextField fCCardVC;
private CLabel lCheckNo;
private CLabel lCheckAccountNo;
private CLabel lCheckRouteNo;
private CLabel lCCardNo;
private CLabel lCCardName;
private CLabel lCCardType;
private CLabel lCCardMonth;
private CLabel lCCardVC;
private PosTextField fTenderAmt;
private CLabel lTenderAmt;
private PosTextField fReturnAmt;
private CLabel lReturnAmt;
private CButton f_bCancel;
public PosPayment(PosBasePanel posPanel) {
super(AEnv.getFrame(posPanel),true);
p_posPanel = posPanel;
p_pos = posPanel.p_pos;
p_ctx = p_pos.getCtx();
p_order = p_posPanel.m_order;
if ( p_order == null )
dispose();
init();
pack();
setLocationByPlatform(true);
}
private void init() {
Font font = AdempierePLAF.getFont_Field().deriveFont(18f);
// North
CPanel mainPanel = new CPanel(new MigLayout("hidemode 3",
"[100:100:300, trailing]20[200:200:300,grow, trailing]"));
getContentPane().add(mainPanel);
mainPanel.setBorder(new TitledBorder(Msg.translate(p_ctx, "Payment")));
CLabel gtLabel = new CLabel(Msg.translate(p_ctx, "GrandTotal"));
mainPanel.add(gtLabel, "growx");
mainPanel.add(fTotal, "wrap, growx");
fTotal.setEditable(false);
fTotal.setFont(font);
fTotal.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(new CLabel(Msg.translate(p_ctx, "Balance")), "growx");
mainPanel.add(fBalance, "wrap, growx");
fBalance.setEditable(false);
fBalance.setFont(font);
fBalance.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(new CLabel(Msg.translate(p_ctx, "TenderType"), "growx"));
// Payment type selection
int AD_Column_ID = 8416; //C_Payment_v.TenderType
MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, 0, AD_Column_ID, DisplayType.List);
ArrayList<Object> types = lookup.getData(true, false, true, true);
DefaultComboBoxModel typeModel = new DefaultComboBoxModel(types.toArray());
tenderTypePick.setModel(typeModel);
// default to cash payment
for (Object obj : types)
{
if ( obj instanceof ValueNamePair )
{
ValueNamePair key = (ValueNamePair) obj;
if ( key.getID().equals("X")) // Cash
tenderTypePick.setSelectedItem(key);
if ( ! "CKX".contains(key.getID() ) )
tenderTypePick.removeItem(key);
}
}
tenderTypePick.setFont(font);
tenderTypePick.addActionListener(this);
tenderTypePick.setRenderer(new ListCellRenderer() {
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel) defaultRenderer
.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
renderer.setPreferredSize(new Dimension(50, 50));
renderer.setHorizontalAlignment(JLabel.CENTER);
return renderer;
}
});
mainPanel.add(tenderTypePick, "wrap, h 50!, growx");
fPayAmt = new PosTextField(Msg.translate(p_ctx, "PayAmt"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
mainPanel.add(new CLabel(Msg.translate(p_ctx, "PayAmt")), "growx");
fPayAmt.setFont(font);
fPayAmt.setHorizontalAlignment(JTextField.TRAILING);
fPayAmt.addActionListener(this);
mainPanel.add(fPayAmt, "wrap, growx");
fTenderAmt = new PosTextField(Msg.translate(p_ctx, "AmountTendered"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
lTenderAmt = new CLabel(Msg.translate(p_ctx, "AmountTendered"));
mainPanel.add(lTenderAmt, "growx");
fTenderAmt.addActionListener(this);
fTenderAmt.setFont(font);
fTenderAmt.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(fTenderAmt, "wrap, growx");
fReturnAmt = new PosTextField(Msg.translate(p_ctx, "AmountReturned"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
lReturnAmt = new CLabel(Msg.translate(p_ctx, "AmountReturned"));
mainPanel.add(lReturnAmt, "growx");
fReturnAmt.setFont(font);
fReturnAmt.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(fReturnAmt, "wrap, growx");
fReturnAmt.setEditable(false);
fCheckRouteNo = new PosTextField(Msg.translate(p_ctx, "RoutingNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCheckRouteNo = new CLabel(Msg.translate(p_ctx, "RoutingNo"));
mainPanel.add(lCheckRouteNo, "growx");
mainPanel.add(fCheckRouteNo, "wrap, growx");
fCheckRouteNo.setFont(font);
fCheckRouteNo.setHorizontalAlignment(JTextField.TRAILING);
fCheckAccountNo = new PosTextField(Msg.translate(p_ctx, "AccountNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCheckAccountNo = new CLabel(Msg.translate(p_ctx, "AccountNo"));
mainPanel.add(lCheckAccountNo, "growx");
mainPanel.add(fCheckAccountNo, "wrap, growx");
fCheckAccountNo.setFont(font);
fCheckAccountNo.setHorizontalAlignment(JTextField.TRAILING);
fCheckNo = new PosTextField(Msg.translate(p_ctx, "CheckNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCheckNo = new CLabel(Msg.translate(p_ctx, "CheckNo"));
mainPanel.add(lCheckNo, "growx");
mainPanel.add(fCheckNo, "wrap, growx");
fCheckNo.setFont(font);
fCheckNo.setHorizontalAlignment(JTextField.TRAILING);
/**
* Load Credit Cards
*/
ValueNamePair[] ccs = p_order.getCreditCards((BigDecimal) fPayAmt.getValue());
// Set Selection
fCCardType = new CComboBox(ccs);
fCCardType.setRenderer(new ListCellRenderer() {
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel) defaultRenderer
.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
renderer.setPreferredSize(new Dimension(50, 50));
renderer.setHorizontalAlignment(JLabel.CENTER);
return renderer;
}
});
lCCardType = new CLabel(Msg.translate(p_ctx, "CreditCardType"));
mainPanel.add(lCCardType, "growx");
mainPanel.add(fCCardType, "h 50, wrap, growx");
fCCardType.setFont(font);
fCCardNo = new PosTextField(Msg.translate(p_ctx, "CreditCardNumber"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCCardNo = new CLabel(Msg.translate(p_ctx, "CreditCardNumber"));
mainPanel.add(lCCardNo, "growx");
mainPanel.add(fCCardNo, "wrap, growx");
fCCardNo.setFont(font);
fCCardNo.setHorizontalAlignment(JTextField.TRAILING);
fCCardName = new PosTextField(Msg.translate(p_ctx, "Name"), p_posPanel, p_pos.getOSK_KeyLayout_ID());
lCCardName = new CLabel(Msg.translate(p_ctx, "Name"));
mainPanel.add(lCCardName, "growx");
mainPanel.add(fCCardName, "wrap, growx");
fCCardName.setFont(font);
fCCardName.setHorizontalAlignment(JTextField.TRAILING);
fCCardMonth = new PosTextField(Msg.translate(p_ctx, "Expires"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCCardMonth = new CLabel(Msg.translate(p_ctx, "Expires"));
mainPanel.add(lCCardMonth, "growx");
mainPanel.add(fCCardMonth, "wrap, w 75!");
fCCardMonth.setFont(font);
fCCardMonth.setHorizontalAlignment(JTextField.TRAILING);
fCCardVC = new PosTextField(Msg.translate(p_ctx, "CVC"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCCardVC = new CLabel(Msg.translate(p_ctx, "CVC"));
mainPanel.add(lCCardVC, "growx");
mainPanel.add(fCCardVC, "wrap, w 75!");
fCCardVC.setFont(font);
fCCardVC.setHorizontalAlignment(JTextField.TRAILING);
AppsAction actCancel = new AppsAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
actCancel.setDelegate(this);
f_bCancel = (CButton)actCancel.getButton();
f_bCancel.setFocusable(false);
mainPanel.add (f_bCancel, "h 50!, w 50!, skip, split 2, trailing");
AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
act.setDelegate(this);
f_bProcess = (CButton)act.getButton();
f_bProcess.setFocusable(false);
mainPanel.add (f_bProcess, "h 50!, w 50!");
pack();
setTotals();
}
private void setTotals() {
String tenderType = ((ValueNamePair) tenderTypePick.getValue()).getID();
boolean cash = MPayment.TENDERTYPE_Cash.equals(tenderType);
boolean check = MPayment.TENDERTYPE_Check.equals(tenderType);
boolean creditcard = MPayment.TENDERTYPE_CreditCard.equals(tenderType);
boolean account = MPayment.TENDERTYPE_Account.equals(tenderType);
fTenderAmt.setVisible(cash);
fReturnAmt.setVisible(cash);
lTenderAmt.setVisible(cash);
lReturnAmt.setVisible(cash);
fCheckAccountNo.setVisible(check);
fCheckNo.setVisible(check);
fCheckRouteNo.setVisible(check);
lCheckAccountNo.setVisible(check);
lCheckNo.setVisible(check);
lCheckRouteNo.setVisible(check);
fCCardMonth.setVisible(creditcard);
fCCardName.setVisible(creditcard);
fCCardNo.setVisible(creditcard);
fCCardType.setVisible(creditcard);
fCCardVC.setVisible(creditcard);
lCCardMonth.setVisible(creditcard);
lCCardName.setVisible(creditcard);
lCCardNo.setVisible(creditcard);
lCCardType.setVisible(creditcard);
lCCardVC.setVisible(creditcard);
fTotal.setValue(p_order.getGrandTotal());
BigDecimal received = p_order.getPaidAmt();
balance = p_order.getGrandTotal().subtract(received);
balance = balance.setScale(MCurrency.getStdPrecision(p_ctx, p_order.getC_Currency_ID()));
if ( balance.compareTo(Env.ZERO) <= 0 )
{
paid = true;
if ( balance.compareTo(Env.ZERO) < 0 )
ADialog.warn(0, this, Msg.getMsg(p_ctx, "Change") + ": " + balance);
dispose();
}
fBalance.setValue(balance);
fPayAmt.setValue(balance);
if ( !MPayment.TENDERTYPE_Cash.equals(tenderType) )
{
fPayAmt.requestFocusInWindow();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
fPayAmt.selectAll();
}
});
}
else
{
fTenderAmt.requestFocusInWindow();
}
pack();
}
public void keyReturned(MPOSKey key) {
String text = key.getText();
String payAmt = fPayAmt.getText();
String selected = fPayAmt.getSelectedText();
if ( selected != null && !selected.isEmpty() )
{
payAmt = payAmt.replaceAll(selected, "");
}
if ( text != null && !text.isEmpty() )
{
if ( text.equals(".") && payAmt.indexOf(".") == -1 )
{
fPayAmt.setText(payAmt + text);
return;
}
try
{
Integer.parseInt(text); // test if number
fPayAmt.setText(payAmt + text);
}
catch (NumberFormatException e)
{
// ignore non-numbers
}
}
}
public static boolean pay(PosBasePanel posPanel) {
PosPayment pay = new PosPayment(posPanel);
pay.setVisible(true);
return pay.isPaid();
}
private boolean isPaid() {
return paid ;
}
public void vetoableChange(PropertyChangeEvent arg0)
throws PropertyVetoException {
// TODO Auto-generated method stub
}
}

View File

@ -1,139 +0,0 @@
/******************************************************************************
* 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.Dimension;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Properties;
import javax.swing.KeyStroke;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.compiere.apps.AEnv;
import org.compiere.apps.AppsAction;
import org.compiere.apps.ConfirmPanel;
import org.compiere.minigrid.MiniTable;
import org.compiere.model.MPOS;
import org.compiere.swing.CButton;
import org.compiere.swing.CDialog;
import org.compiere.swing.CPanel;
import org.compiere.swing.CScrollPane;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
public abstract class PosQuery extends CDialog implements MouseListener, ListSelectionListener, ActionListener {
protected Properties p_ctx;
/** POS Panel */
protected PosBasePanel p_posPanel = null;
/** Underlying POS Model */
protected MPOS p_pos = null;
/** The Table */
protected PosTable m_table;
protected CPanel northPanel;
protected CScrollPane centerScroll;
protected ConfirmPanel confirm;
protected CButton f_up;
protected CButton f_down;
/** Logger */
protected static CLogger log = CLogger.getCLogger(QueryProduct.class);
public PosQuery() throws HeadlessException {
super();
}
protected abstract void close();
public abstract void reset();
public abstract void actionPerformed(ActionEvent e);
public void dispose() {
removeAll();
northPanel = null;
centerScroll = null;
confirm = null;
m_table = null;
super.dispose();
}
protected abstract void init();
protected abstract void enableButtons();
/**
* Constructor
*/
public PosQuery (PosBasePanel posPanel)
{
super(AEnv.getFrame(posPanel), true);
p_posPanel = posPanel;
p_pos = posPanel.p_pos;
p_ctx = p_pos.getCtx();
init();
pack();
setLocationByPlatform(true);
} // PosQueryBPartner
/**
* Mouse Clicked
* @param e event
*/
public void mouseClicked(MouseEvent e)
{
// Single click with selected row => exit
if (e.getClickCount() > 0 && 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) {}
/**
* Table selection changed
* @param e event
*/
public void valueChanged (ListSelectionEvent e)
{
if (e.getValueIsAdjusting())
return;
enableButtons();
} // valueChanged
/**
* Create Action Button
* @param action action
* @return button
*/
protected CButton createButtonAction(String action, KeyStroke accelerator) {
AppsAction act = new AppsAction(action, accelerator, false);
act.setDelegate(this);
CButton button = (CButton)act.getButton();
button.setPreferredSize(new Dimension(WIDTH, HEIGHT));
button.setMinimumSize(getPreferredSize());
button.setMaximumSize(getPreferredSize());
button.setFocusable(false);
return button;
} // getButtonAction
}

View File

@ -31,10 +31,12 @@ import org.compiere.util.Env;
/**
* POS Sub Panel Base Class.
* The Panel knows where to position itself in the POS Panel
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
*
* @version $Id: PosSubPanel.java,v 1.3 2004/07/12 04:10:04 jjanke Exp $
*/
public abstract class PosSubPanel extends CPanel
implements ActionListener
@ -48,7 +50,7 @@ public abstract class PosSubPanel extends CPanel
* Constructor
* @param posPanel POS Panel
*/
public PosSubPanel (PosBasePanel posPanel)
public PosSubPanel (PosPanel posPanel)
{
super();
p_posPanel = posPanel;
@ -57,23 +59,46 @@ public abstract class PosSubPanel extends CPanel
} // PosSubPanel
/** POS Panel */
protected PosBasePanel p_posPanel;
protected PosPanel p_posPanel = null;
/** Underlying POS Model */
protected MPOS p_pos;
protected MPOS p_pos = null;
/** Position of SubPanel in Main */
protected GridBagConstraints p_position = null;
/** Context */
protected Properties p_ctx = Env.getCtx();
/** Button Width = 50 */
private static final int WIDTH = 50;
/** Button Height = 50 */
private static final int HEIGHT = 50;
/** Button Width = 40 */
private static final int WIDTH = 45;
/** Button Height = 40 */
private static final int HEIGHT = 35;
/** Inset 1all */
public static Insets INSETS1 = new Insets(1,1,1,1);
/** Inset 2all */
public static Insets INSETS2 = new Insets(2,2,2,2);
/**
* Initialize
*/
protected abstract void init();
/**
* Get Panel Position
*/
protected GridBagConstraints getGridBagConstraints()
{
if (p_position == null)
{
p_position = new GridBagConstraints();
p_position.anchor = GridBagConstraints.NORTHWEST;
p_position.fill = GridBagConstraints.BOTH;
p_position.weightx = 0.1;
p_position.weighty = 0.1;
}
return p_position;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
@ -124,6 +149,6 @@ public abstract class PosSubPanel extends CPanel
*/
public void actionPerformed (ActionEvent e)
{
} // actionPerformed
} // actinPerformed
} // PosSubPanel

View File

@ -1,43 +0,0 @@
package org.compiere.pos;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.ListSelectionModel;
import org.compiere.minigrid.MiniTable;
public class PosTable extends MiniTable {
/**
*
*/
private static final long serialVersionUID = 7884238751207398699L;
public PosTable() {
super();
setRowSelectionAllowed(true);
setColumnSelectionAllowed(false);
setMultiSelection(false);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setRowHeight(30);
setAutoResize(false);
}
public void growScrollbars() {
// fatter scroll bars
Container p = getParent();
if (p instanceof JViewport) {
Container gp = p.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane) gp;
scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(30,0));
scrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0,30));
}
}
}
}

View File

@ -1,92 +0,0 @@
/******************************************************************************
* 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.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.Format;
import javax.swing.JFormattedTextField;
import javax.swing.text.DefaultFormatterFactory;
/**
* Formatted Text field with on-screen keyboard support
* @author Paul Bowden
* Adaxa Pty Ltd
*
*/
public class PosTextField extends JFormattedTextField implements MouseListener {
/**
*
*/
private static final long serialVersionUID = -2453719110038264481L;
private DefaultFormatterFactory formatFactory = new DefaultFormatterFactory();
PosBasePanel pos = null;
int keyLayoutId = 0;
private String title;
public PosTextField(String title, PosBasePanel pos, final int posKeyLayout_ID, Format format ) {
super(format);
if ( posKeyLayout_ID > 0 )
addMouseListener(this);
keyLayoutId = posKeyLayout_ID;
this.pos = pos;
this.title = title;
}
public PosTextField(String title, PosBasePanel pos, final int posKeyLayout_ID, AbstractFormatter formatter ) {
super(formatter);
if ( posKeyLayout_ID > 0 )
addMouseListener(this);
keyLayoutId = posKeyLayout_ID;
this.pos = pos;
this.title = title;
}
public PosTextField(String title, PosBasePanel pos, final int posKeyLayout_ID) {
super();
if ( posKeyLayout_ID > 0 )
addMouseListener(this);
keyLayoutId = posKeyLayout_ID;
this.pos = pos;
this.title = title;
}
public void mouseReleased(MouseEvent arg0) {}
public void mousePressed(MouseEvent arg0) {}
public void mouseExited(MouseEvent arg0) {}
public void mouseEntered(MouseEvent arg0) {}
public void mouseClicked(MouseEvent arg0) {
if ( isEnabled() && isEditable() )
{
POSKeyboard keyboard = pos.getKeyboard(keyLayoutId);
keyboard.setTitle(title);
keyboard.setPosTextField(this);
keyboard.setVisible(true);
fireActionPerformed();
}
}
}

View File

@ -14,16 +14,21 @@
package org.compiere.pos;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.ConfirmPanel;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.minigrid.MiniTable;
@ -45,7 +50,8 @@ import org.compiere.util.Msg;
* *Copyright (c) Jorg Janke
* @version $Id: QueryBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class QueryBPartner extends PosQuery
public class QueryBPartner extends PosSubPanel
implements ActionListener, MouseListener, ListSelectionListener
{
/**
*
@ -55,22 +61,29 @@ public class QueryBPartner extends PosQuery
/**
* Constructor
*/
public QueryBPartner (PosBasePanel posPanel)
public QueryBPartner (PosPanel posPanel)
{
super(posPanel);
} // PosQueryBPartner
/** The Table */
private MiniTable m_table;
private PosTextField f_value;
private PosTextField f_name;
private PosTextField f_contact;
private PosTextField f_email;
private PosTextField f_phone;
private CPanel northPanel;
private CScrollPane centerScroll;
private ConfirmPanel confirm;
private CTextField f_value;
private CTextField f_name;
private CTextField f_contact;
private CTextField f_email;
private CTextField f_phone;
private CTextField f_city;
private CButton f_up;
private CButton f_down;
private int m_C_BPartner_ID;
private CButton f_refresh;
private CButton f_ok;
private CButton f_cancel;
/** Logger */
private static CLogger log = CLogger.getCLogger(QueryBPartner.class);
@ -81,6 +94,8 @@ public class QueryBPartner extends PosQuery
new ColumnInfo(" ", "C_BPartner_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "Value", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", 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(), "Phone"), "Phone", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Postal"), "Postal", String.class),
@ -96,89 +111,141 @@ public class QueryBPartner extends PosQuery
*/
protected void init()
{
CPanel panel = new CPanel();
panel.setLayout(new MigLayout("fill"));
getContentPane().add(panel);
setLayout(new BorderLayout(5,5));
setVisible(false);
// North
northPanel = new CPanel(new MigLayout("fill","", "[50][50][]"));
panel.add (northPanel, "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 lvalue = new CLabel(Msg.translate(p_ctx, "Value"));
northPanel.add (lvalue, " growy");
f_value = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lvalue, gbc);
f_value = new CTextField(10);
lvalue.setLabelFor(f_value);
northPanel.add(f_value, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_value, gbc);
f_value.addActionListener(this);
//
CLabel lcontact = new CLabel(Msg.translate(p_ctx, "Contact"));
northPanel.add (lcontact, " growy");
f_contact = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lcontact, gbc);
f_contact = new CTextField(10);
lcontact.setLabelFor(f_contact);
northPanel.add(f_contact, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_contact, gbc);
f_contact.addActionListener(this);
//
CLabel lphone = new CLabel(Msg.translate(p_ctx, "Phone"));
northPanel.add (lphone, " growy");
f_phone = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lphone, gbc);
f_phone = new CTextField(10);
lphone.setLabelFor(f_phone);
northPanel.add(f_phone, "h 30, w 200, wrap");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_phone, gbc);
f_phone.addActionListener(this);
//
gbc.gridy = 1;
CLabel lname = new CLabel(Msg.translate(p_ctx, "Name"));
northPanel.add (lname, " growy");
f_name = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lname, gbc);
f_name = new CTextField(10);
lname.setLabelFor(f_name);
northPanel.add(f_name, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_name, gbc);
f_name.addActionListener(this);
//
CLabel lemail = new CLabel(Msg.translate(p_ctx, "Email"));
northPanel.add (lemail, " growy");
f_email = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lemail, gbc);
f_email = new CTextField(10);
lemail.setLabelFor(f_email);
northPanel.add(f_email, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_email, gbc);
f_email.addActionListener(this);
//
CLabel lcity = new CLabel(Msg.translate(p_ctx, "City"));
northPanel.add (lcity, " growy");
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lcity, gbc);
f_city = new CTextField(10);
lcity.setLabelFor(f_city);
northPanel.add(f_city, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_city, gbc);
f_city.addActionListener(this);
//
f_refresh = createButtonAction("Refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
northPanel.add(f_refresh, "w 50!, h 50!, wrap, alignx trailing");
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, "w 50!, h 50!, span, split 4");
northPanel.add(f_up, gbc);
gbc.weightx = 0;
f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
northPanel.add(f_down, "w 50!, h 50!");
f_ok = createButtonAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
northPanel.add(f_ok, "w 50!, h 50!");
f_cancel = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
northPanel.add(f_cancel, "w 50!, h 50!");
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 PosTable();
m_table = new MiniTable();
String sql = m_table.prepareTable (s_layout, s_sqlFrom,
s_sqlWhere, false, "RV_BPartner")
+ " ORDER BY Value";
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);
panel.add (centerScroll, "growx, growy");
m_table.growScrollbars();
panel.setPreferredSize(new Dimension(800,600));
f_value.requestFocus();
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_value.requestFocus();
} // setVisible
/**
* Action Listener
@ -200,7 +267,13 @@ public class QueryBPartner extends PosQuery
}
else if ("Reset".equals(e.getActionCommand()))
{
reset();
f_value.setText(null);
f_name.setText(null);
f_contact.setText(null);
f_email.setText(null);
f_phone.setText(null);
f_city.setText(null);
setResults(new MBPartnerInfo[0]);
return;
}
else if ("Previous".equalsIgnoreCase(e.getActionCommand()))
@ -241,11 +314,22 @@ public class QueryBPartner extends PosQuery
m_table.loadTable(results);
enableButtons();
} // setResults
/**
* Table selection changed
* @param e event
*/
public void valueChanged (ListSelectionEvent e)
{
if (e.getValueIsAdjusting())
return;
enableButtons();
} // valueChanged
/**
* Enable/Set Buttons and set ID
*/
protected void enableButtons()
private void enableButtons()
{
m_C_BPartner_ID = -1;
int row = m_table.getSelectedRow();
@ -260,41 +344,48 @@ public class QueryBPartner extends PosQuery
// m_Price = (BigDecimal)m_table.getValueAt(row, 7);
}
}
f_ok.setEnabled(enabled);
confirm.getOKButton().setEnabled(enabled);
log.fine("C_BPartner_ID=" + m_C_BPartner_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
*/
protected void close()
private void close()
{
log.fine("C_BPartner_ID=" + m_C_BPartner_ID);
if (m_C_BPartner_ID > 0)
{
p_posPanel.f_order.setC_BPartner_ID(m_C_BPartner_ID);
p_posPanel.f_bpartner.setC_BPartner_ID(m_C_BPartner_ID);
// p_posPanel.f_curLine.setCurrency(m_Price);
}
else
{
p_posPanel.f_order.setC_BPartner_ID(0);
p_posPanel.f_bpartner.setC_BPartner_ID(0);
// p_posPanel.f_curLine.setPrice(Env.ZERO);
}
dispose();
p_posPanel.closeQuery(this);
} // close
@Override
public void reset() {
f_value.setText(null);
f_name.setText(null);
f_contact.setText(null);
f_email.setText(null);
f_phone.setText(null);
f_city.setText(null);
setResults(new MBPartnerInfo[0]);
}
} // PosQueryBPartner

View File

@ -14,17 +14,22 @@
package org.compiere.pos;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.ConfirmPanel;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.minigrid.MiniTable;
@ -46,7 +51,8 @@ import org.compiere.util.Msg;
* *Copyright (c) Jorg Janke
* @version $Id: QueryProduct.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class QueryProduct extends PosQuery
public class QueryProduct extends PosSubPanel
implements ActionListener, MouseListener, ListSelectionListener
{
/**
*
@ -56,15 +62,25 @@ public class QueryProduct extends PosQuery
/**
* Constructor
*/
public QueryProduct (PosBasePanel posPanel)
public QueryProduct (PosPanel posPanel)
{
super(posPanel);
} // PosQueryProduct
/** The Table */
private MiniTable m_table;
private PosTextField f_value;
private PosTextField f_name;
private PosTextField f_upc;
private PosTextField f_sku;
private CPanel northPanel;
private CScrollPane centerScroll;
private ConfirmPanel confirm;
private CTextField f_value;
private CTextField f_name;
private CTextField f_upc;
private CTextField f_sku;
private CButton f_up;
private CButton f_down;
private int m_M_Product_ID;
private String m_ProductName;
@ -72,9 +88,6 @@ public class QueryProduct extends PosQuery
//
private int m_M_PriceList_Version_ID;
private int m_M_Warehouse_ID;
private CButton f_refresh;
private CButton f_ok;
private CButton f_cancel;
/** Logger */
private static CLogger log = CLogger.getCLogger(QueryProduct.class);
@ -101,74 +114,124 @@ public class QueryProduct extends PosQuery
*/
protected void init()
{
CPanel panel = new CPanel();
panel.setLayout(new MigLayout("fill"));
getContentPane().add(panel);
setLayout(new BorderLayout(5,5));
setVisible(false);
// North
northPanel = new CPanel(new MigLayout("fill", "", "[50][50][]"));
panel.add (northPanel, "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 lvalue = new CLabel(Msg.translate(p_ctx, "Value"));
northPanel.add (lvalue, "growy");
f_value = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lvalue, gbc);
f_value = new CTextField(20);
lvalue.setLabelFor(f_value);
northPanel.add(f_value, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_value, gbc);
f_value.addActionListener(this);
//
CLabel lupc = new CLabel(Msg.translate(p_ctx, "UPC"));
northPanel.add (lupc, "growy");
f_upc = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lupc, gbc);
f_upc = new CTextField(15);
lupc.setLabelFor(f_upc);
northPanel.add(f_upc, "h 30, w 200, wrap");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_upc, gbc);
f_upc.addActionListener(this);
//
gbc.gridy = 1;
CLabel lname = new CLabel(Msg.translate(p_ctx, "Name"));
northPanel.add (lname, "growy");
f_name = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lname, gbc);
f_name = new CTextField(20);
lname.setLabelFor(f_name);
northPanel.add(f_name, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_name, gbc);
f_name.addActionListener(this);
//
CLabel lsku = new CLabel(Msg.translate(p_ctx, "SKU"));
northPanel.add (lsku, "growy");
f_sku = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (lsku, gbc);
f_sku = new CTextField(15);
lsku.setLabelFor(f_sku);
northPanel.add(f_sku, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_sku, gbc);
f_sku.addActionListener(this);
//
f_refresh = createButtonAction("Refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
northPanel.add(f_refresh, "w 50!, h 50!, wrap, alignx trailing");
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, "w 50!, h 50!, span, split 4");
northPanel.add(f_up, gbc);
gbc.weightx = 0;
f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
northPanel.add(f_down, "w 50!, h 50!");
northPanel.add(f_down, gbc);
f_ok = createButtonAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
northPanel.add(f_ok, "w 50!, h 50!");
f_cancel = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
northPanel.add(f_cancel, "w 50!, h 50!");
// Confirm
confirm = new ConfirmPanel (true, true, true, false, false, false, false);
add (confirm, BorderLayout.SOUTH);
confirm.addActionListener(this);
// Center
m_table = new PosTable();
m_table = new MiniTable();
String sql = m_table.prepareTable (s_layout, s_sqlFrom,
s_sqlWhere, false, "RV_WarehousePrice")
+ " 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);
panel.add (centerScroll, "growx, growy,south");
m_table.growScrollbars();
panel.setPreferredSize(new Dimension(800,600));
f_value.requestFocus();
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_value.requestFocus();
} // setVisible
/**
* Set Query Data
@ -199,7 +262,11 @@ public class QueryProduct extends PosQuery
}
else if ("Reset".equals(e.getActionCommand()))
{
reset();
f_value.setText(null);
f_name.setText(null);
f_sku.setText(null);
f_upc.setText(null);
setResults(new MWarehousePrice[0]);
return;
}
else if ("Previous".equalsIgnoreCase(e.getActionCommand()))
@ -238,15 +305,24 @@ public class QueryProduct extends PosQuery
public void setResults (MWarehousePrice[] results)
{
m_table.loadTable(results);
if (m_table.getRowCount() >0 )
m_table.setRowSelectionInterval(0, 0);
enableButtons();
} // setResults
/**
* Table selection changed
* @param e event
*/
public void valueChanged (ListSelectionEvent e)
{
if (e.getValueIsAdjusting())
return;
enableButtons();
} // valueChanged
/**
* Enable/Set Buttons and set ID
*/
protected void enableButtons()
private void enableButtons()
{
m_M_Product_ID = -1;
m_ProductName = null;
@ -263,42 +339,48 @@ public class QueryProduct extends PosQuery
m_Price = (BigDecimal)m_table.getValueAt(row, 7);
}
}
f_ok.setEnabled(enabled);
confirm.getOKButton().setEnabled(enabled);
log.fine("M_Product_ID=" + m_M_Product_ID + " - " + m_ProductName + " - " + m_Price);
} // 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
*/
protected void close()
private void close()
{
log.fine("M_Product_ID=" + m_M_Product_ID);
if (m_M_Product_ID > 0)
{
p_posPanel.f_curLine.setM_Product_ID(m_M_Product_ID);
p_posPanel.f_product.setM_Product_ID(m_M_Product_ID);
p_posPanel.f_curLine.setPrice(m_Price);
}
else
{
p_posPanel.f_curLine.setM_Product_ID(0);
p_posPanel.f_product.setM_Product_ID(0);
p_posPanel.f_curLine.setPrice(Env.ZERO);
}
dispose();
p_posPanel.closeQuery(this);
} // close
@Override
public void reset() {
f_value.setText(null);
f_name.setText(null);
f_sku.setText(null);
f_upc.setText(null);
setResults(new MWarehousePrice[0]);
}
} // PosQueryProduct

View File

@ -14,35 +14,36 @@
package org.compiere.pos;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Properties;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.ConfirmPanel;
import org.compiere.grid.ed.VDate;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.minigrid.MiniTable;
import org.compiere.swing.CButton;
import org.compiere.swing.CCheckBox;
import org.compiere.swing.CLabel;
import org.compiere.swing.CPanel;
import org.compiere.swing.CScrollPane;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -60,30 +61,41 @@ import org.compiere.util.Msg;
*
*/
public class QueryTicket extends PosQuery
public class QueryTicket extends PosSubPanel
implements ActionListener, MouseListener, ListSelectionListener
{
/**
*
*/
private static final long serialVersionUID = 7713957495649128816L;
/**
* Constructor
*/
public QueryTicket (PosBasePanel posPanel)
public QueryTicket (PosPanel posPanel)
{
super(posPanel);
} // PosQueryProduct
/** The Table */
private MiniTable m_table;
private PosTextField f_documentno;
private CPanel northPanel;
private CScrollPane centerScroll;
private ConfirmPanel confirm;
private CTextField f_c_order_id;
private CTextField f_documentno;
private VDate f_date;
private int m_c_order_id;
private CCheckBox f_processed;
private CButton f_refresh;
private CButton f_ok;
private CButton f_cancel;
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[]
{
@ -91,94 +103,139 @@ public class QueryTicket extends PosQuery
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),
new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "Name", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Processed"), "Processed", Boolean.class)
new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "Name", String.class)
};
/**
* Set up Panel
*/
@Override
protected void init()
{
CPanel panel = new CPanel();
panel.setLayout(new MigLayout("fill"));
getContentPane().add(panel);
setLayout(new BorderLayout(5,5));
setVisible(false);
// North
northPanel = new CPanel(new MigLayout("fill","", "[50][50][]"));
panel.add (northPanel, "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"));
northPanel.add (ldoc, " growy");
f_documentno = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (ldoc, gbc);
f_documentno = new CTextField(15);
ldoc.setLabelFor(f_documentno);
northPanel.add(f_documentno, "h 30, w 200");
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"));
northPanel.add (ldate, "growy");
gbc.anchor = GridBagConstraints.EAST;
northPanel.add (ldate, gbc);
f_date = new VDate();
f_date.setValue(Env.getContextAsDate(Env.getCtx(), "#Date"));
ldate.setLabelFor(f_date);
northPanel.add(f_date, "h 30, w 200");
gbc.anchor = GridBagConstraints.WEST;
northPanel.add(f_date, gbc);
f_date.addActionListener(this);
f_processed = new CCheckBox(Msg.translate(p_ctx, "Processed"));
f_processed.setSelected(false);
northPanel.add(f_processed, "");
f_refresh = createButtonAction("Refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
northPanel.add(f_refresh, "w 50!, h 50!, wrap, alignx trailing");
//
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, "w 50!, h 50!, span, split 4");
northPanel.add(f_up, gbc);
gbc.weightx = 0;
f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
northPanel.add(f_down, "w 50!, h 50!");
northPanel.add(f_down, gbc);
f_ok = createButtonAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
northPanel.add(f_ok, "w 50!, h 50!");
f_cancel = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
northPanel.add(f_cancel, "w 50!, h 50!");
// Confirm
confirm = new ConfirmPanel (true, true, true, false, false, false, false);
add (confirm, BorderLayout.SOUTH);
confirm.addActionListener(this);
// Center
m_table = new PosTable();
m_table = new MiniTable();
String sql = m_table.prepareTable (s_layout, "C_Order",
"C_POS_ID = " + p_pos.getC_POS_ID()
"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);
panel.add (centerScroll, "growx, growy");
m_table.growScrollbars();
panel.setPreferredSize(new Dimension(800,600));
f_documentno.requestFocus();
pack();
setResults(p_ctx, f_processed.isSelected(), f_documentno.getText(), f_date.getTimestamp());
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
*/
@Override
public void actionPerformed (ActionEvent e)
{
log.info("PosQueryProduct.actionPerformed - " + e.getActionCommand());
if ("Refresh".equals(e.getActionCommand())
|| e.getSource() == f_processed || e.getSource() == f_documentno
|| e.getSource() == f_c_order_id || e.getSource() == f_documentno
|| e.getSource() == f_date)
{
setResults(p_ctx, f_processed.isSelected(), f_documentno.getText(), f_date.getTimestamp());
setResults(p_ctx, f_c_order_id.getText(), f_documentno.getText(), f_date.getTimestamp());
return;
}
else if ("Reset".equals(e.getActionCommand()))
@ -210,11 +267,6 @@ public class QueryTicket extends PosQuery
m_table.getSelectionModel().setSelectionInterval(row, row);
return;
}
else if ("Cancel".equalsIgnoreCase(e.getActionCommand()))
{
dispose();
return;
}
// Exit
close();
} // actionPerformed
@ -223,13 +275,12 @@ public class QueryTicket extends PosQuery
/**
*
*/
@Override
public void reset()
{
f_processed.setSelected(false);
f_c_order_id.setText(null);
f_documentno.setText(null);
f_date.setValue(Env.getContextAsDate(Env.getCtx(), "#Date"));
setResults(p_ctx, f_processed.isSelected(), f_documentno.getText(), f_date.getTimestamp());
setResults(p_ctx, f_c_order_id.getText(), f_documentno.getText(), f_date.getTimestamp());
}
@ -237,40 +288,45 @@ public class QueryTicket extends PosQuery
* Set/display Results
* @param results results
*/
public void setResults (Properties ctx, boolean processed, String doc, Timestamp date)
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, b.Name, o.Processed" +
" FROM C_Order o INNER JOIN C_BPartner b ON o.C_BPartner_ID=b.C_BPartner_ID" +
" WHERE o.C_POS_ID = " + p_pos.getC_POS_ID();
sql += " AND o.Processed = " + ( processed ? "'Y' " : "'N' ");
sql = "SELECT o.C_Order_ID, o.DocumentNo, o.TotalLines, o.GrandTotal, b.Name FROM C_Order o INNER JOIN C_BPartner b ON o.C_BPartner_ID=b.C_BPartner_ID 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 + "'";
if ( date != null )
sql += " AND o.DateOrdered = ? Order By o.DocumentNo DESC";
sql += " AND o.DateOrdered = ? Order By o.DocumentNo";
PreparedStatement pstm = DB.prepareStatement(sql, null);
if ( date != null )
pstm.setTimestamp(1, date);
pstm.setTimestamp(1, date);
ResultSet rs = pstm.executeQuery();
m_table.loadTable(rs);
if ( m_table.getRowCount() > 0 )
m_table.setRowSelectionInterval(0, 0);
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
*/
protected void enableButtons()
private void enableButtons()
{
m_c_order_id = -1;
int row = m_table.getSelectedRow();
@ -283,28 +339,44 @@ public class QueryTicket extends PosQuery
m_c_order_id = ID.intValue();
}
}
f_ok.setEnabled(enabled);
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
*/
@Override
protected void close()
private void close()
{
log.info("C_Order_ID=" + m_c_order_id);
if (m_c_order_id > 0)
{
p_posPanel.setOrder(m_c_order_id);
p_posPanel.f_curLine.setOrder(m_c_order_id);
p_posPanel.updateInfo();
}
dispose();
p_posPanel.closeQuery(this);
} // close
} // PosQueryProduct

View File

@ -0,0 +1,409 @@
/******************************************************************************
* 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.Event;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.KeyStroke;
import javax.swing.border.TitledBorder;
import org.compiere.model.MBPartner;
import org.compiere.model.MBPartnerInfo;
import org.compiere.model.MBPartnerLocation;
import org.compiere.model.MCurrency;
import org.compiere.model.MPriceList;
import org.compiere.model.MPriceListVersion;
import org.compiere.model.MUser;
import org.compiere.swing.CButton;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
/**
* Customer Sub Panel
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> Jorg Janke
* @version $Id: SubBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class SubBPartner extends PosSubPanel
implements ActionListener, FocusListener
{
/**
*
*/
private static final long serialVersionUID = 5895558315889871887L;
/**
* Constructor
* @param posPanel POS Panel
*/
public SubBPartner (PosPanel posPanel)
{
super (posPanel);
} // PosSubCustomer
private CTextField f_name;
private CButton f_bNew;
private CButton f_bEdit;
private CButton f_bSearch;
private CComboBox f_location;
private CComboBox f_user;
/** The Business Partner */
private MBPartner m_bpartner;
/** Price List Version to use */
private int m_M_PriceList_Version_ID = 0;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubBPartner.class);
/**
* Initialize
*/
public void init()
{
// Title
TitledBorder border = new TitledBorder(Msg.translate(p_ctx, "C_BPartner_ID"));
setBorder(border);
// Content
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2;
// --
f_bNew = createButtonAction("New", null);
gbc.gridx = 0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.WEST;
add (f_bNew, gbc);
//
f_bEdit = createButtonAction ("Edit", null);
gbc.gridx = 1;
add (f_bEdit, gbc);
//
f_name = new CTextField("");
f_name.setName("Name");
f_name.addActionListener(this);
f_name.addFocusListener(this);
gbc.gridx = 2;
gbc.gridy = 0;
gbc.gridheight = 1;
gbc.gridwidth = 2;
gbc.weightx = 0.5;
gbc.fill = GridBagConstraints.HORIZONTAL;
add (f_name, gbc);
//
f_location = new CComboBox();
gbc.gridx = 2;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE;
add (f_location, gbc);
//
f_user = new CComboBox();
gbc.gridx = 3;
gbc.gridy = 1;
gbc.anchor = GridBagConstraints.EAST;
add (f_user, gbc);
//
f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK));
gbc.gridx = 4;
gbc.gridy = 0;
gbc.gridheight = 2;
gbc.fill = GridBagConstraints.NONE;
add (f_bSearch, gbc);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
public void dispose()
{
if (f_name != null)
f_name.removeFocusListener(this);
f_name = null;
removeAll();
super.dispose();
} // dispose
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubCustomer - actionPerformed: " + action);
// New
if (action.equals("New"))
p_posPanel.newOrder(); //red1 New POS Order instead - B_Partner already has direct field
// Edit
else if (action.equals("Edit"))
{
f_bEdit.setReadWrite(false);
}
// BPartner
else if (action.equals("BPartner"))
{
p_posPanel.openQuery(p_posPanel.f_queryBPartner);
}
// Name
else if (e.getSource() == f_name)
findBPartner();
p_posPanel.updateInfo();
} // actionPerformed
/**
* Focus Gained
* @param e
*/
public void focusGained (FocusEvent e)
{
} // focusGained
/**
* Focus Lost
* @param e
*/
public void focusLost (FocusEvent e)
{
if (e.isTemporary())
return;
log.info(e.toString());
findBPartner();
} // focusLost
/**
* Find/Set BPartner
*/
private void findBPartner()
{
String query = f_name.getText();
if (query == null || query.length() == 0)
return;
query = query.toUpperCase();
// Test Number
boolean allNumber = true;
boolean noNumber = true;
char[] qq = query.toCharArray();
for (int i = 0; i < qq.length; i++)
{
if (Character.isDigit(qq[i]))
{
noNumber = false;
break;
}
}
try
{
Integer.parseInt(query);
}
catch (Exception e)
{
allNumber = false;
}
String Value = query;
String Name = (allNumber ? null : query);
String EMail = (query.indexOf('@') != -1 ? query : null);
String Phone = (noNumber ? null : query);
String City = null;
//
//TODO: contact have been remove from rv_bpartner
MBPartnerInfo[] results = MBPartnerInfo.find(p_ctx, Value, Name,
/*Contact, */null, EMail, Phone, City);
// Set Result
if (results.length == 0)
{
setC_BPartner_ID(0);
}
else if (results.length == 1)
{
setC_BPartner_ID(results[0].getC_BPartner_ID());
f_name.setText(results[0].getName());
}
else // more than one
{
p_posPanel.f_queryBPartner.setResults (results);
p_posPanel.openQuery(p_posPanel.f_queryBPartner);
}
} // findBPartner
/**************************************************************************
* Set BPartner
* @param C_BPartner_ID id
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
log.fine( "PosSubCustomer.setC_BPartner_ID=" + C_BPartner_ID);
if (C_BPartner_ID == 0)
m_bpartner = null;
else
{
m_bpartner = new MBPartner(p_ctx, C_BPartner_ID, null);
if (m_bpartner.get_ID() == 0)
m_bpartner = null;
}
// Set Info
if (m_bpartner != null)
{
f_name.setText(m_bpartner.getName());
f_bEdit.setReadWrite(false);
}
else
{
f_name.setText(null);
f_bEdit.setReadWrite(false);
}
// Sets Currency
m_M_PriceList_Version_ID = 0;
getM_PriceList_Version_ID();
fillCombos();
p_posPanel.f_curLine.setBPartner(); //added by ConSerTi to update the client in the request
} // setC_BPartner_ID
/**
* Fill Combos (Location, User)
*/
private void fillCombos()
{
Vector<KeyNamePair> locationVector = new Vector<KeyNamePair>();
if (m_bpartner != null)
{
MBPartnerLocation[] locations = m_bpartner.getLocations(false);
for (int i = 0; i < locations.length; i++)
locationVector.add(locations[i].getKeyNamePair());
}
DefaultComboBoxModel locationModel = new DefaultComboBoxModel(locationVector);
f_location.setModel(locationModel);
//
Vector<KeyNamePair> userVector = new Vector<KeyNamePair>();
if (m_bpartner != null)
{
MUser[] users = m_bpartner.getContacts(false);
for (int i = 0; i < users.length; i++)
userVector.add(users[i].getKeyNamePair());
}
DefaultComboBoxModel userModel = new DefaultComboBoxModel(userVector);
f_user.setModel(userModel);
} // fillCombos
/**
* Get BPartner
* @return C_BPartner_ID
*/
public int getC_BPartner_ID ()
{
if (m_bpartner != null)
return m_bpartner.getC_BPartner_ID();
return 0;
} // getC_BPartner_ID
/**
* Get BPartner
* @return BPartner
*/
public MBPartner getBPartner ()
{
return m_bpartner;
} // getBPartner
/**
* Get BPartner Location
* @return C_BPartner_Location_ID
*/
public int getC_BPartner_Location_ID ()
{
if (m_bpartner != null)
{
KeyNamePair pp = (KeyNamePair)f_location.getSelectedItem();
if (pp != null)
return pp.getKey();
}
return 0;
} // getC_BPartner_Location_ID
/**
* Get BPartner Contact
* @return AD_User_ID
*/
public int getAD_User_ID ()
{
if (m_bpartner != null)
{
KeyNamePair pp = (KeyNamePair)f_user.getSelectedItem();
if (pp != null)
return pp.getKey();
}
return 0;
} // getC_BPartner_Location_ID
/**
* Get M_PriceList_Version_ID.
* Set Currency
* @return plv
*/
public int getM_PriceList_Version_ID()
{
if (m_M_PriceList_Version_ID == 0)
{
int M_PriceList_ID = p_pos.getM_PriceList_ID();
if (m_bpartner != null && m_bpartner.getM_PriceList_ID() != 0)
M_PriceList_ID = m_bpartner.getM_PriceList_ID();
//
MPriceList pl = MPriceList.get(p_ctx, M_PriceList_ID, null);
p_posPanel.f_curLine.setCurrency(MCurrency.getISO_Code(p_ctx, pl.getC_Currency_ID()));
f_name.setToolTipText(pl.getName());
//
MPriceListVersion plv = pl.getPriceListVersion (p_posPanel.getToday());
if (plv != null && plv.getM_PriceList_Version_ID() != 0)
m_M_PriceList_Version_ID = plv.getM_PriceList_Version_ID();
}
return m_M_PriceList_Version_ID;
} // getM_PriceList_Version_ID
} // PosSubCustomer

View File

@ -0,0 +1,197 @@
/******************************************************************************
* 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.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.border.TitledBorder;
import org.compiere.swing.CButton;
import org.compiere.util.CLogger;
/**
* Basic Key Sub Panel
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
* @version $Id: SubBasicKeys.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class SubBasicKeys extends PosSubPanel implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 3296839634889851637L;
/**
* Constructor
* @param posPanel POS Panel
*/
public SubBasicKeys (PosPanel posPanel)
{
super (posPanel);
} // PosSubBasicKeys
private CButton f_b1 = null;
private CButton f_b2 = null;
private CButton f_b3 = null;
private CButton f_b4 = null;
private CButton f_b5 = null;
private CButton f_b6 = null;
private CButton f_b7 = null;
private CButton f_b8 = null;
private CButton f_b9 = null;
private CButton f_b0 = null;
private CButton f_bDot = null;
private CButton f_reset = null;
private CButton f_new = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubBasicKeys.class);
/**
* Initialize
*/
public void init()
{
// Title
TitledBorder border = new TitledBorder("#");
setBorder(border);
// Content
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS1;
//
f_b7 = createButton ("7");
gbc.gridx = 0;
gbc.gridy = 0;
add (f_b7, gbc);
//
f_b8 = createButton ("8");
gbc.gridx = 1;
gbc.gridy = 0;
add (f_b8, gbc);
//
f_b9 = createButton ("9");
gbc.gridx = 2;
gbc.gridy = 0;
add (f_b9, gbc);
// --
f_b4 = createButton ("4");
gbc.gridx = 0;
gbc.gridy = 1;
add (f_b4, gbc);
//
f_b5 = createButton ("5");
gbc.gridx = 1;
gbc.gridy = 1;
add (f_b5, gbc);
//
f_b6 = createButton ("6");
gbc.gridx = 2;
gbc.gridy = 1;
add (f_b6, gbc);
// --
f_b1 = createButton ("1");
gbc.gridx = 0;
gbc.gridy = 2;
add (f_b1, gbc);
//
f_b2 = createButton ("2");
gbc.gridx = 1;
gbc.gridy = 2;
add (f_b2, gbc);
//
f_b3 = createButton ("3");
gbc.gridx = 2;
gbc.gridy = 2;
add (f_b3, gbc);
// --
f_b0 = createButton ("0");
Dimension size = f_b0.getPreferredSize();
size.width = (size.width*2) + 2;
gbc.gridx = 0;
gbc.gridy = 3;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.VERTICAL;
add (f_b0, gbc);
//
f_bDot = createButton (".");
gbc.gridx = 2;
gbc.gridy = 3;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
add (f_bDot, gbc);
// --
gbc.gridx = 4;
gbc.insets = new Insets(1,15,1,1);
gbc.gridy = 0;
f_reset = createButtonAction("Reset", null);
add (f_reset, gbc);
//
f_new = createButtonAction("New", null);
gbc.gridy = 3;
add (f_new, gbc);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 3;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
public void dispose()
{
super.dispose();
} // dispose
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubBasicKeys - actionPerformed: " + action);
// Reset
if (action.equals("Reset"))
;
// New
else if (action.equals("New"))
p_posPanel.newOrder();
} // actionPerformed
} // PosSubBasicKeys

View File

@ -24,6 +24,7 @@ import java.math.BigDecimal;
import javax.swing.border.TitledBorder;
import org.compiere.apps.AEnv;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.MOrder;
import org.compiere.print.ReportCtl;
@ -57,12 +58,15 @@ public class SubCheckout extends PosSubPanel implements ActionListener
* Constructor
* @param posPanel POS Panel
*/
public SubCheckout (PosBasePanel posPanel)
public SubCheckout (PosPanel posPanel)
{
super (posPanel);
} // PosSubCheckout
private CButton f_register = null;
private CButton f_summary = null;
private CButton f_process = null;
private CButton f_print = null;
//TODO: credit card
/* private CLabel f_lcreditCardNumber = null;
@ -73,10 +77,13 @@ public class SubCheckout extends PosSubPanel implements ActionListener
private CTextField f_creditCardVV = null;
private CButton f_creditPayment = null;
*/
private CLabel f_lDocumentNo = null;
private CTextField f_DocumentNo;
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 */
@ -90,6 +97,7 @@ public class SubCheckout extends PosSubPanel implements ActionListener
// Content
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2;
// BOX 1 - CASH
gbc.gridx = 0;
@ -102,8 +110,14 @@ public class SubCheckout extends PosSubPanel implements ActionListener
gbc.gridy = 0;
add (cash, gbc);
GridBagConstraints gbc0 = new GridBagConstraints();
gbc0.insets = INSETS2;
// gbc0.anchor = GridBagConstraints.EAST;
//
f_lDocumentNo = new CLabel(Msg.getMsg(Env.getCtx(),"DocumentNo"));
cash.add (f_lDocumentNo, gbc0);
f_DocumentNo = new CTextField("");
f_DocumentNo.setName("DocumentNo");
cash.add (f_DocumentNo, gbc0);
f_lcashGiven = new CLabel(Msg.getMsg(Env.getCtx(),"CashGiven"));
cash.add (f_lcashGiven, gbc0);
f_cashGiven = new VNumber("CashGiven", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "CashGiven"));
@ -118,6 +132,10 @@ public class SubCheckout extends PosSubPanel implements ActionListener
f_cashReturn.setColumns(8, 25);
cash.add (f_cashReturn, gbc0);
f_cashReturn.setValue(Env.ZERO);
f_cashPayment = createButtonAction("Payment", null);
f_cashPayment.setActionCommand("Cash");
gbc0.weightx = 0.1;
cash.add (f_cashPayment, gbc0);
// BOX 2 - UTILS
CPanel utils = new CPanel(new GridBagLayout());
@ -127,6 +145,7 @@ public class SubCheckout extends PosSubPanel implements ActionListener
gbc.weightx = .1;
add (utils, gbc);
GridBagConstraints gbcU = new GridBagConstraints();
gbcU.insets = INSETS2;
gbcU.anchor = GridBagConstraints.EAST;
//CASH FUNCTIONS
f_cashRegisterFunctions = createButtonAction("CashRegisterFunction", null);
@ -135,9 +154,19 @@ public class SubCheckout extends PosSubPanel implements ActionListener
f_cashRegisterFunctions.setMaximumSize(new Dimension(130,37));
f_cashRegisterFunctions.setMinimumSize(new Dimension(130,37));
utils.add(f_cashRegisterFunctions, gbcU);
//SUMMARY
//REGISTER
f_register = createButtonAction("Register", null);
utils.add (f_register, gbcU);
//SUMMARY
f_summary = createButtonAction("Summary", null);
utils.add (f_summary, gbcU);
//PROCESS
f_process = createButtonAction("Process", null);
utils.add (f_process, gbcU);
//PRINT
f_print = createButtonAction("Print", null);
utils.add (f_print, gbcU);
@ -188,6 +217,17 @@ public class SubCheckout extends PosSubPanel implements ActionListener
**/ //fin del comentario para quitar la parte del CreditCard
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
@ -208,19 +248,63 @@ public class SubCheckout extends PosSubPanel implements ActionListener
return;
log.info( "PosSubCheckout - actionPerformed: " + action);
// Register
if (action.equals("Register"))
{
p_posPanel.f_queryTicket.reset();
p_posPanel.openQuery(p_posPanel.f_queryTicket);
}
// Summary
else
if (action.equals("Summary"))
{
//displaySummary();
displaySummary();
}
else if (action.equals("Process"))
{
if (isOrderFullyPay())
{
displaySummary();
//Check if order is completed, if so, print and open drawer, create an empty order and set cashGiven to zero
if(processOrder())
{
printTicket();
openCashDrawer();
p_posPanel.newOrder();
f_cashGiven.setValue(Env.ZERO);
}
}
else
{
p_posPanel.f_status.setStatusLine("PAYMENT NOT FULL.");
}
}
// Print
else if (action.equals("Print"))
{
if (isOrderFullyPay())
{
displaySummary();
printTicket();
openCashDrawer();
}
else
{
p_posPanel.f_status.setStatusLine("Order not fully paid.");
}
}
// Cash (Payment)
else if (action.equals("Cash"))
{
displayReturn();
openCashDrawer();
}
else if (action.equals("CashRegisterFunction"))
{
CashSubFunctions csf = new CashSubFunctions(p_posPanel);
csf.setVisible(true);
p_posPanel.openQuery(p_posPanel.f_cashfunctions);
}
else if (e.getSource() == f_cashGiven)
//displayReturn();
displayReturn();
/* // CreditCard (Payment)
else if (action.equals("CreditCard"))
@ -231,11 +315,197 @@ public class SubCheckout extends PosSubPanel implements ActionListener
p_posPanel.updateInfo();
} // actionPerformed
private void displaySummary() {
p_posPanel.f_status.setStatusLine(p_posPanel.f_curLine.getOrder().getSummary());
displayReturn();
}
/**
* Process Order
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public boolean processOrder()
{
//Returning orderCompleted to check for order completness
boolean orderCompleted = false;
p_posPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
MOrder order = p_posPanel.f_curLine.getOrder();
if (order != null)
// check if order completed OK
if (order.getDocStatus().equals("DR") )
{
order.setDocAction(DocAction.ACTION_Complete);
try
{
if (order.processIt(DocAction.ACTION_Complete) )
{
order.save();
}
else
{
log.info( "SubCheckout - processOrder FAILED");
p_posPanel.f_status.setStatusLine("Order can not be completed.");
}
}
catch (Exception e)
{
log.severe("Order can not be completed - " + e.getMessage());
p_posPanel.f_status.setStatusLine("Error when processing order.");
}
finally
{ // When order failed convert it back to draft so it can be processed
if( order.getDocStatus().equals("IN") )
{
order.setDocStatus("DR");
}
else if( order.getDocStatus().equals("CO") )
{
order = null;
orderCompleted = true;
//p_posPanel.newOrder();
//f_cashGiven.setValue(Env.ZERO);
log.info( "SubCheckout - processOrder OK");
p_posPanel.f_status.setStatusLine("Order completed.");
}
else
{
log.info( "SubCheckout - processOrder - unrecognized DocStatus");
p_posPanel.f_status.setStatusLine("Orden was not completed correctly.");
}
} // try-finally
}
p_posPanel.setCursor(Cursor.getDefaultCursor());
return orderCompleted;
} // processOrder
/**
* Print Ticket
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public void printTicket()
{
MOrder order = p_posPanel.f_curLine.getOrder();
//int windowNo = p_posPanel.getWindowNo();
//Properties m_ctx = p_posPanel.getPropiedades();
if (order != null)
{
try
{
//TODO: to incorporate work from Posterita
/*
if (p_pos.getAD_PrintLabel_ID() != 0)
PrintLabel.printLabelTicket(order.getC_Order_ID(), p_pos.getAD_PrintLabel_ID());
*/
//print standard document
ReportCtl.startDocumentPrint(ReportEngine.ORDER, order.getC_Order_ID(), null, AEnv.getWindowNo(this), true);
}
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 <EFBFBD> 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)
{
f_DocumentNo.setText(order.getDocumentNo());
total = order.getGrandTotal();
}
double cashReturn = given.doubleValue() - total.doubleValue();
f_cashReturn.setValue(new BigDecimal(cashReturn));
}
}
/**
* 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 <EFBFBD> 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 <EFBFBD> ConSerTi
*/
public void openCashDrawer()
{
String puerto = null;
//TODO - to incorporate 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

View File

@ -14,48 +14,27 @@
package org.compiere.pos;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JViewport;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.ADialog;
import org.compiere.grid.ed.VNumber;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.minigrid.MiniTable;
import org.compiere.model.MBPartner;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderTax;
import org.compiere.model.MProduct;
import org.compiere.model.MUOM;
import org.compiere.model.MWarehousePrice;
import org.compiere.model.PO;
import org.compiere.swing.CButton;
import org.compiere.swing.CLabel;
import org.compiere.swing.CScrollPane;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -69,7 +48,7 @@ import org.compiere.util.Msg;
* @version $Id: SubCurrentLine.java,v 1.3 2004/07/24 04:31:52 jjanke Exp $
* red1 - [2093355 ] Small bugs in OpenXpertya POS
*/
public class SubCurrentLine extends PosSubPanel implements ActionListener, FocusListener, ListSelectionListener {
public class SubCurrentLine extends PosSubPanel implements ActionListener {
/**
*
*/
@ -81,146 +60,102 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
* @param posPanel
* POS Panel
*/
public SubCurrentLine(PosBasePanel posPanel) {
public SubCurrentLine(PosPanel posPanel) {
super(posPanel);
} // PosSubCurrentLine
private CButton f_up;
private CButton f_delete;
private CButton f_down;
//
private CButton f_new;
private CButton f_reset;
private CButton f_plus;
private CButton f_minus;
private PosTextField f_price;
private PosTextField f_quantity;
protected PosTextField f_name;
private CButton f_bSearch;
private int orderLineId = 0;
/** The Product */
private MProduct m_product = null;
private CLabel f_currency;
/** Warehouse */
private int m_M_Warehouse_ID;
/** PLV */
private int m_M_PriceList_Version_ID;
private VNumber f_price;
private CLabel f_uom;
private VNumber f_quantity;
private MOrder m_order = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubCurrentLine.class);
/** The Table */
PosTable m_table;
/** The Query SQL */
private String m_sql;
/** Logger */
/** Table Column Layout Info */
private static ColumnInfo[] s_layout = new ColumnInfo[]
{
new ColumnInfo(" ", "C_OrderLine_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Qty"), "QtyOrdered", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "C_UOM_ID"), "UOMSymbol", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "PriceActual"), "PriceActual", BigDecimal.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "LineNetAmt"), "LineNetAmt", BigDecimal.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "C_Tax_ID"), "TaxIndicator", String.class),
};
/** From Clause */
private static String s_sqlFrom = "C_Order_LineTax_v";
/** Where Clause */
private static String s_sqlWhere = "C_Order_ID=? AND LineNetAmt <> 0";
/**
* Initialize
*/
public void init() {
// Title
TitledBorder border = new TitledBorder(Msg.getMsg(Env.getCtx(),
"CurrentLine"));
setBorder(border);
// Content
setLayout(new MigLayout("fill, ins 0 0"));
String buttonSize = "w 50!, h 50!,";
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2;
gbc.gridy = 0;
// --
f_new = createButtonAction("Save", KeyStroke.getKeyStroke(
KeyEvent.VK_INSERT, Event.SHIFT_MASK));
gbc.gridx = 0;
add(f_new, gbc);
//
f_bSearch = createButtonAction ("Product", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK));
add (f_bSearch, buttonSize );
CLabel productLabel = new CLabel(Msg.translate(Env.getCtx(), "M_Product_ID"));
add(productLabel, "split 2, spanx 4, flowy, h 15");
f_name = new PosTextField(Msg.translate(Env.getCtx(), "M_Product_ID"), p_posPanel, p_pos.getOSK_KeyLayout_ID());
f_name.setName("Name");
f_name.addActionListener(this);
f_name.addFocusListener(this);
f_name.requestFocusInWindow();
add (f_name, " growx, h 30:30:, wrap");
m_table = new PosTable();
CScrollPane scroll = new CScrollPane(m_table);
m_sql = m_table.prepareTable (s_layout, s_sqlFrom,
s_sqlWhere, false, "C_Order_LineTax_v")
+ " ORDER BY Line";
// m_table.addMouseListener(this);
m_table.getSelectionModel().addListSelectionListener(this);
m_table.setColumnVisibility(m_table.getColumn(0), false);
m_table.getColumn(1).setPreferredWidth(175);
m_table.getColumn(2).setPreferredWidth(75);
m_table.getColumn(3).setPreferredWidth(30);
m_table.getColumn(4).setPreferredWidth(75);
m_table.getColumn(5).setPreferredWidth(75);
m_table.getColumn(6).setPreferredWidth(30);
m_table.setFocusable(false);
m_table.growScrollbars();
add (scroll, "growx, spanx, growy, pushy, h 200:300:");
f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0));
add (f_up, buttonSize);
f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
add (f_down, buttonSize);
f_delete = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, Event.SHIFT_MASK));
add (f_delete, buttonSize);
f_reset = createButtonAction("Reset", null);
gbc.gridx = GridBagConstraints.RELATIVE;
add(f_reset, gbc);
//
f_currency = new CLabel("---");
gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = .1;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(f_currency, gbc);
//
f_price = new VNumber("PriceActual", false, false, true,
DisplayType.Amount, Msg.translate(Env.getCtx(), "PriceActual"));
f_price.addActionListener(this);
f_price.setColumns(10, 25);
gbc.anchor = GridBagConstraints.WEST;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE;
add(f_price, gbc);
setPrice(Env.ZERO);
// --
f_uom = new CLabel("--");
gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = .1;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(f_uom, gbc);
//
f_minus = createButtonAction("Minus", null);
add(f_minus, buttonSize);
CLabel qtyLabel = new CLabel(Msg.translate(Env.getCtx(), "QtyOrdered"));
add(qtyLabel, "split 2, flowy, h 15");
gbc.anchor = GridBagConstraints.WEST;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE;
add(f_minus, gbc);
//
f_quantity = new PosTextField(Msg.translate(Env.getCtx(), "QtyOrdered"),
p_posPanel,p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Quantity));
f_quantity.setHorizontalAlignment(JTextField.TRAILING);
f_quantity = new VNumber("QtyOrdered", false, false, true,
DisplayType.Quantity, Msg.translate(Env.getCtx(), "QtyOrdered"));
f_quantity.addActionListener(this);
add(f_quantity, "h 30:30:, w 100");
f_quantity.setColumns(5, 25);
add(f_quantity, gbc);
setQty(Env.ONE);
//
f_plus = createButtonAction("Plus", null);
add(f_plus, buttonSize);
CLabel priceLabel = new CLabel(Msg.translate(Env.getCtx(), "PriceActual"));
add(priceLabel, "split 2, flowy, h 15");
//
f_price = new PosTextField(Msg.translate(Env.getCtx(), "PriceActual"),
p_posPanel,p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
f_price.addActionListener(this);
f_price.setHorizontalAlignment(JTextField.TRAILING);
add(f_price, "h 30, w 100, wrap");
setPrice(Env.ZERO);
enableButtons();
add(f_plus, gbc);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints() {
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
@ -239,189 +174,49 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
if (action == null || action.length() == 0)
return;
log.info( "SubCurrentLine - actionPerformed: " + action);
// New / Reset
if (action.equals("Save"))
saveLine();
else if (action.equals("Reset"))
newLine();
// Plus
if (action.equals("Plus"))
{
if ( orderLineId > 0 )
{
MOrderLine line = new MOrderLine(p_ctx, orderLineId, null);
if ( line != null )
{
line.setQty(line.getQtyOrdered().add(Env.ONE));
line.saveEx();
p_posPanel.updateInfo();
}
}
}
else if (action.equals("Plus"))
f_quantity.plus();
// Minus
else if (action.equals("Minus"))
{
if ( orderLineId > 0 )
{
MOrderLine line = new MOrderLine(p_ctx, orderLineId, null);
if ( line != null )
{
line.setQty(line.getQtyOrdered().subtract(Env.ONE));
line.saveEx();
p_posPanel.updateInfo();
}
}
}
f_quantity.minus(1);
// VNumber
else if (e.getSource() == f_price) {
MOrderLine line = new MOrderLine(p_ctx, orderLineId, null);
if ( line != null )
{
line.setQty(new BigDecimal(f_price.getValue().toString()));
line.saveEx();
p_posPanel.updateInfo();
}
}
else if (e.getSource() == f_quantity && orderLineId > 0 )
{
MOrderLine line = new MOrderLine(p_ctx, orderLineId, null);
if ( line != null )
{
line.setQty(new BigDecimal(f_quantity.getValue().toString()));
line.saveEx();
p_posPanel.updateInfo();
}
}
// Product
if (action.equals("Product"))
{
setParameter();
QueryProduct qt = new QueryProduct(p_posPanel);
qt.setQueryData(m_M_PriceList_Version_ID, m_M_Warehouse_ID);
qt.setVisible(true);
findProduct();
}
// Name
else if (e.getSource() == f_name)
findProduct();
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;
}
// Delete
else if (action.equals("Cancel"))
{
int rows = m_table.getRowCount();
if (rows != 0)
{
int row = m_table.getSelectedRow();
if (row != -1)
{
if ( p_posPanel.m_order != null )
p_posPanel.m_order.deleteLine(m_table.getSelectedRowKey());
setQty(null);
setPrice(null);
orderLineId = 0;
}
}
}
else if (e.getSource() == f_price)
f_price.setValue(f_price.getValue());
else if (e.getSource() == f_quantity)
f_quantity.setValue(f_quantity.getValue());
p_posPanel.updateInfo();
} // actionPerformed
/**
* Update Table
* @param order order
*/
public void updateTable (PosOrderModel order)
{
int C_Order_ID = 0;
if (order != null)
C_Order_ID = order.getC_Order_ID();
if (C_Order_ID == 0)
{
p_posPanel.f_curLine.m_table.loadTable(new PO[0]);
p_posPanel.f_order.setSums(null);
}
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (m_sql, null);
pstmt.setInt (1, C_Order_ID);
rs = pstmt.executeQuery ();
m_table.loadTable(rs);
}
catch (Exception e)
{
log.log(Level.SEVERE, m_sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
for ( int i = 0; i < m_table.getRowCount(); i ++ )
{
IDColumn key = (IDColumn) m_table.getModel().getValueAt(i, 0);
if ( key != null && orderLineId > 0 && key.getRecord_ID() == orderLineId )
{
m_table.getSelectionModel().setSelectionInterval(i, i);
break;
}
}
enableButtons();
p_posPanel.f_order.setSums(order);
} // updateTable
private void enableButtons()
{
boolean enabled = true;
if ( m_table == null || m_table.getRowCount() == 0 || m_table.getSelectedRowKey() == null )
{
enabled = false;
}
f_down.setEnabled(enabled);
f_up.setEnabled(enabled);
f_delete.setEnabled(enabled);
f_minus.setEnabled(enabled);
f_plus.setEnabled(enabled);
f_quantity.setEnabled(enabled);
f_price.setEnabled(enabled);
}
/**
* Set Query Parameter
/***************************************************************************
* Set Currency
*
* @param currency
* currency
*/
private void setParameter()
{
// What PriceList ?
m_M_Warehouse_ID = p_pos.getM_Warehouse_ID();
m_M_PriceList_Version_ID = p_posPanel.f_order.getM_PriceList_Version_ID();
} // setParameter
public void setCurrency(String currency) {
if (currency == null)
f_currency.setText("---");
else
f_currency.setText(currency);
} // setCurrency
/**
* Set UOM
*
* @param UOM
*/
public void setUOM(String UOM) {
if (UOM == null)
f_uom.setText("--");
else
f_uom.setText(UOM);
} // setUOM
/**
* Set Price
@ -433,7 +228,7 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
price = Env.ZERO;
f_price.setValue(price);
boolean rw = Env.ZERO.compareTo(price) == 0 || p_pos.isModifyPrice();
f_price.setEditable(rw);
f_price.setReadWrite(rw);
} // setPrice
/**
@ -467,11 +262,9 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
* New Line
*/
public void newLine() {
setM_Product_ID(0);
p_posPanel.f_product.setM_Product_ID(0);
setQty(Env.ONE);
setPrice(Env.ZERO);
orderLineId = 0;
f_name.requestFocusInWindow();
} // newLine
/**
@ -480,208 +273,243 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
* @return true if saved
*/
public boolean saveLine() {
MProduct product = getProduct();
MProduct product = p_posPanel.f_product.getProduct();
if (product == null)
return false;
BigDecimal QtyOrdered = (BigDecimal) f_quantity.getValue();
BigDecimal PriceActual = (BigDecimal) f_price.getValue();
if ( p_posPanel.m_order == null )
{
p_posPanel.m_order = PosOrderModel.createOrder(p_posPanel.p_pos, p_posPanel.f_order.getBPartner());
}
MOrderLine line = null;
if ( p_posPanel.m_order != null )
{
line = p_posPanel.m_order.createLine(product, QtyOrdered, PriceActual);
if (line == null)
return false;
if (!line.save())
return false;
}
orderLineId = line.getC_OrderLine_ID();
setM_Product_ID(0);
MOrderLine line = createLine(product, QtyOrdered, PriceActual);
if (line == null)
return false;
if (!line.save())
return false;
//
newLine();
return true;
} // saveLine
/**
* Get Product
* @return product
/**
* to erase the lines from order
* @return true if deleted
*/
public MProduct getProduct()
{
return m_product;
} // getProduct
public void deleteLine (int row) {
if (m_order != null && row != -1 )
{
MOrderLine[] lineas = m_order.getLines(true, null);
int numLineas = lineas.length;
if (numLineas > row)
{
//delete line from order - true only when DRAFT is not PREPARE-IT()
lineas[row].delete(true);
for (int i = row; i < (numLineas - 1); i++)
lineas[i] = lineas[i + 1];
lineas[numLineas - 1] = null;
}
}
} // deleteLine
/**
* Set Price for defined product
*/
public void setPrice()
{
if (m_product == null)
return;
//
setParameter();
MWarehousePrice result = MWarehousePrice.get (m_product,
m_M_PriceList_Version_ID, m_M_Warehouse_ID, null);
if (result != null)
p_posPanel.f_curLine.setPrice(result.getPriceStd());
else
p_posPanel.f_curLine.setPrice(Env.ZERO);
} // setPrice
* Delete order from database
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
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
/**************************************************************************
* Find/Set Product & Price
/**
* Create new order
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
private void findProduct()
public void newOrder()
{
String query = f_name.getText();
if (query == null || query.length() == 0)
return;
query = query.toUpperCase();
// Test Number
boolean allNumber = true;
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.setAD_Org_ID(p_pos.getAD_Org_ID());
m_order.setIsSOTrx(true);
if (p_pos.getC_DocType_ID() != 0)
m_order.setC_DocTypeTarget_ID(p_pos.getC_DocType_ID());
else
m_order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS);
MBPartner partner = p_posPanel.f_bpartner.getBPartner();
if (partner == null || partner.get_ID() == 0)
partner = p_pos.getBPartner();
if (partner == null || partner.get_ID() == 0) {
log.log(Level.SEVERE, "SubCurrentLine.getOrder - no BPartner");
return null;
}
log.info( "SubCurrentLine.getOrder -" + 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();
if (id != 0)
m_order.setC_BPartner_Location_ID(id);
id = p_posPanel.f_bpartner.getAD_User_ID();
if (id != 0)
m_order.setAD_User_ID(id);
//
m_order.setM_PriceList_ID(p_pos.getM_PriceList_ID());
m_order.setM_Warehouse_ID(p_pos.getM_Warehouse_ID());
m_order.setSalesRep_ID(p_pos.getSalesRep_ID());
m_order.setPaymentRule(MOrder.PAYMENTRULE_Cash);
if (!m_order.save())
{
m_order = null;
log.severe("Unable create Order.");
}
}
return m_order;
} // getHeader
/**
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public void setBPartner()
{
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();
if (order == null)
return null;
if (!order.getDocStatus().equals("DR"))
return null;
//add new line or increase qty
// catch Exceptions at order.getLines()
int numLineas = 0;
MOrderLine[] lineas = null;
try
{
Integer.getInteger(query);
lineas = order.getLines("","");
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];
}
}
}
catch (Exception e)
{
allNumber = false;
log.severe("Order lines cannot be created - " + e.getMessage());
}
String Value = query;
String Name = query;
String UPC = (allNumber ? query : null);
String SKU = (allNumber ? query : null);
MWarehousePrice[] results = null;
setParameter();
//
results = MWarehousePrice.find (p_ctx,
m_M_PriceList_Version_ID, m_M_Warehouse_ID,
Value, Name, UPC, SKU, null);
// Set Result
if (results.length == 0)
{
String message = Msg.translate(p_ctx, "search.product.notfound");
ADialog.warn(0, p_posPanel, message + query);
setM_Product_ID(0);
p_posPanel.f_curLine.setPrice(Env.ZERO);
}
else if (results.length == 1)
{
setM_Product_ID(results[0].getM_Product_ID());
setQty(Env.ONE);
f_name.setText(results[0].getName());
p_posPanel.f_curLine.setPrice(results[0].getPriceStd());
saveLine();
}
else // more than one
{
QueryProduct qt = new QueryProduct(p_posPanel);
qt.setResults(results);
qt.setQueryData(m_M_PriceList_Version_ID, m_M_Warehouse_ID);
qt.setVisible(true);
}
} // findProduct
/**************************************************************************
* Set Product
* @param M_Product_ID id
*/
public void setM_Product_ID (int M_Product_ID)
{
log.fine( "PosSubProduct.setM_Product_ID=" + M_Product_ID);
if (M_Product_ID <= 0)
m_product = null;
else
{
m_product = MProduct.get(p_ctx, M_Product_ID);
if (m_product.get_ID() == 0)
m_product = null;
}
// Set String Info
if (m_product != null)
{
f_name.setText(m_product.getName());
f_name.setToolTipText(m_product.getDescription());
}
else
{
f_name.setText(null);
f_name.setToolTipText(null);
}
} // setM_Product_ID
/**
* Focus Gained
* @param e
*/
public void focusGained (FocusEvent e)
{
} // focusGained
//create new line
MOrderLine line = new MOrderLine(order);
line.setProduct(product);
line.setQty(QtyOrdered);
line.setPrice(); // sets List/limit
line.setPrice(PriceActual);
line.save();
return line;
} // createLine
/**
* Focus Lost
* @param e
* @param m_c_order_id
*/
public void focusLost (FocusEvent e)
public void setOldOrder(int m_c_order_id)
{
if (e.isTemporary())
return;
log.info( "PosSubProduct - focusLost");
findProduct();
deleteOrder();
m_order = new MOrder(p_ctx , m_c_order_id, null);
p_posPanel.updateInfo();
} // focusLost
public void valueChanged(ListSelectionEvent e) {
if ( e.getValueIsAdjusting() )
return;
int row = m_table.getSelectedRow();
if (row != -1 )
{
Object data = m_table.getModel().getValueAt(row, 0);
if ( data != null )
{
Integer id = (Integer) ((IDColumn)data).getRecord_ID();
orderLineId = id;
loadLine(id);
}
}
enableButtons();
}
private void loadLine(int lineId) {
if ( lineId <= 0 )
return;
log.fine("SubCurrentLine - loading line " + lineId);
MOrderLine ol = new MOrderLine(p_ctx, lineId, null);
if ( ol != null )
{
setPrice(ol.getPriceActual());
setQty(ol.getQtyOrdered());
}
/**
* @param m_c_order_id
*/
public void setOrder(int m_c_order_id)
{
m_order = new MOrder(p_ctx , m_c_order_id, null);
}
} // PosSubCurrentLine

View File

@ -14,7 +14,6 @@
package org.compiere.pos;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
@ -24,15 +23,11 @@ import java.awt.event.ActionListener;
import javax.swing.border.TitledBorder;
import net.miginfocom.swing.MigLayout;
import org.compiere.apps.ADialog;
import org.compiere.model.MPOSKey;
import org.compiere.model.MPOSKeyLayout;
import org.compiere.print.MPrintColor;
import org.compiere.swing.CButton;
import org.compiere.swing.CPanel;
import org.compiere.swing.CScrollPane;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -46,7 +41,7 @@ import org.compiere.util.Msg;
* *Copyright (c) Jorg Janke
* @version $Id: SubFunctionKeys.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class SubFunctionKeys extends PosSubPanel implements PosKeyListener
public class SubFunctionKeys extends PosSubPanel implements ActionListener
{
/**
*
@ -57,7 +52,7 @@ public class SubFunctionKeys extends PosSubPanel implements PosKeyListener
* Constructor
* @param posPanel POS Panel
*/
public SubFunctionKeys (PosBasePanel posPanel)
public SubFunctionKeys (PosPanel posPanel)
{
super (posPanel);
} // PosSubFunctionKeys
@ -72,15 +67,77 @@ public class SubFunctionKeys extends PosSubPanel implements PosKeyListener
*/
public void init()
{
// Title
TitledBorder border = new TitledBorder(Msg.translate(Env.getCtx(), "C_POSKeyLayout_ID"));
setBorder(border);
int C_POSKeyLayout_ID = p_pos.getC_POSKeyLayout_ID();
if (C_POSKeyLayout_ID == 0)
return;
MPOSKeyLayout fKeys = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
if (fKeys.get_ID() == 0)
return;
PosKeyPanel panel = new PosKeyPanel(C_POSKeyLayout_ID, this);
this.setLayout(new MigLayout("fill, ins 0"));
add(panel, "growx, growy");
int COLUMNS = 3; // Min Columns
int ROWS = 6; // Min Rows
m_keys = fKeys.getKeys(false);
int noKeys = m_keys.length;
int rows = Math.max (((noKeys-1) / COLUMNS) + 1, ROWS);
int cols = ((noKeys-1) % COLUMNS) + 1;
log.fine( "PosSubFunctionKeys.init - NoKeys=" + noKeys
+ " - Rows=" + rows + ", Cols=" + cols);
// Content
CPanel content = new CPanel (new GridLayout(Math.max(rows, 3), Math.max(cols, 3)));
for (int i = 0; i < m_keys.length; i++)
{
Color keyColor = Color.lightGray;
MPOSKey key = m_keys[i];
StringBuffer buttonHTML = new StringBuffer("<html><p>");
if (key.getAD_PrintColor_ID() != 0)
{
MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
keyColor = color.getColor();
buttonHTML
.append("<table")
.append(">")
.append(key.getName())
.append("</table>");
}
else
buttonHTML.append(key.getName());
buttonHTML.append("</p></html>");
log.fine( "#" + i + " - " + keyColor);
CButton button = new CButton(buttonHTML.toString());
button.setMargin(INSETS1);
button.setBackground(keyColor);
button.setFocusable(false);
button.setActionCommand(String.valueOf(key.getC_POSKey_ID()));
button.addActionListener(this);
content.add (button);
}
for (int i = m_keys.length; i < rows*COLUMNS; i++)
{
CButton button = new CButton("");
button.setFocusable(false);
button.setBackground(Color.cyan);
content.add (button);
}
content.setPreferredSize(new Dimension(cols*80, rows*50));
add (content);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 2;
gbc.gridheight = 3; //added by ConSerTi so that the panel takes up more space
// gbc.fill = GridBagConstraints.HORIZONTAL;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
@ -91,23 +148,35 @@ public class SubFunctionKeys extends PosSubPanel implements PosKeyListener
} // dispose
/**
* Call back from key panel
* Action Listener
* @param e event
*/
public void keyReturned(MPOSKey key) {
// processed order
if ( p_posPanel.m_order != null && p_posPanel.m_order.isProcessed() )
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0 || m_keys == null)
return;
// new line
p_posPanel.f_curLine.setM_Product_ID(key.getM_Product_ID());
p_posPanel.f_curLine.setPrice();
p_posPanel.f_curLine.setQty(key.getQty());
if ( !p_posPanel.f_curLine.saveLine() )
log.info( "PosSubFunctionKeys - actionPerformed: " + action);
try
{
ADialog.error(0, this, "Could not save order line");
int C_POSKey_ID = Integer.parseInt(action);
for (int i = 0; i < m_keys.length; i++)
{
MPOSKey key = m_keys[i];
if (key.getC_POSKey_ID() == C_POSKey_ID)
{
p_posPanel.f_product.setM_Product_ID(key.getM_Product_ID());
p_posPanel.f_product.setPrice();
p_posPanel.f_curLine.setQty(key.getQty());
p_posPanel.f_curLine.saveLine();
p_posPanel.updateInfo();
return;
}
}
}
p_posPanel.updateInfo();
return;
}
catch (Exception ex)
{
}
} // actinPerformed
} // PosSubFunctionKeys

View File

@ -0,0 +1,314 @@
/******************************************************************************
* 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.BorderLayout;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.KeyStroke;
import javax.swing.border.TitledBorder;
import org.compiere.grid.ed.VNumber;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.minigrid.MiniTable;
import org.compiere.model.MOrder;
import org.compiere.model.PO;
import org.compiere.swing.CButton;
import org.compiere.swing.CLabel;
import org.compiere.swing.CPanel;
import org.compiere.swing.CScrollPane;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* All Lines Sub Panel
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
* @version $Id: SubLines.java,v 1.2 2004/07/21 05:37:51 jjanke Exp $
*/
public class SubLines extends PosSubPanel implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = -1536223059244074580L;
/**
* Constructor
* @param posPanel POS Panel
*/
public SubLines (PosPanel posPanel)
{
super (posPanel);
} // PosSubAllLines
/** The Table */
private MiniTable m_table;
/** The Query SQL */
private String m_sql;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubLines.class);
private CButton f_up;
private CButton f_delete;
private CButton f_down;
//
private VNumber f_net;
private VNumber f_tax;
private VNumber f_total;
/** Table Column Layout Info */
private static ColumnInfo[] s_layout = new ColumnInfo[]
{
new ColumnInfo(" ", "C_OrderLine_ID", IDColumn.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Line"), "Line", Integer.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Qty"), "QtyOrdered", Double.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "C_UOM_ID"), "UOMSymbol", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "PriceActual"), "PriceActual", BigDecimal.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "LineNetAmt"), "LineNetAmt", BigDecimal.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "C_Tax_ID"), "TaxIndicator", String.class),
new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "Description", String.class)
};
/** From Clause */
private static String s_sqlFrom = "C_Order_LineTax_v";
/** Where Clause */
private static String s_sqlWhere = "C_Order_ID=? AND LineNetAmt<>0";
/**
* Initialize
*/
public void init()
{
// Title
TitledBorder border = new TitledBorder(Msg.translate(Env.getCtx(), "C_OrderLine_ID"));
setBorder(border);
// Content
setLayout(new BorderLayout(5, 5));
m_table = new MiniTable();
CScrollPane scroll = new CScrollPane(m_table);
m_sql = m_table.prepareTable (s_layout, s_sqlFrom,
s_sqlWhere, false, "C_Order_LineTax_v")
+ " ORDER BY Line";
m_table.setRowSelectionAllowed(true);
m_table.setColumnSelectionAllowed(false);
m_table.setMultiSelection(false);
// m_table.addMouseListener(this);
// m_table.getSelectionModel().addListSelectionListener(this);
scroll.setPreferredSize(new Dimension(100,120));
add (scroll, BorderLayout.CENTER);
// Right side
CPanel right = new CPanel();
add (right, BorderLayout.EAST);
right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS));
//
right.add(Box.createGlue());
f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0));
right.add (f_up);
right.add(Box.createGlue());
f_delete = createButtonAction("Delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, Event.SHIFT_MASK));
right.add (f_delete);
right.add(Box.createGlue());
f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
right.add (f_down);
right.add(Box.createGlue());
// Summary
FlowLayout summaryLayout = new FlowLayout(FlowLayout.LEADING, 2,0);
CPanel summary = new CPanel(summaryLayout);
add (summary, BorderLayout.SOUTH);
//
CLabel lNet = new CLabel (Msg.translate(Env.getCtx(), "TotalLines"));
summary.add(lNet);
f_net = new VNumber("TotalLines", false, true, false, DisplayType.Amount, "TotalLines");
f_net.setColumns(11, 22);
lNet.setLabelFor(f_net);
summary.add(f_net);
f_net.setValue (Env.ZERO);
//
CLabel lTax = new CLabel (Msg.translate(Env.getCtx(), "TaxAmt"));
summary.add(lTax);
f_tax = new VNumber("TaxAmt", false, true, false, DisplayType.Amount, "TaxAmt");
f_tax.setColumns(6, 22);
lTax.setLabelFor(f_tax);
summary.add(f_tax);
f_tax.setValue (Env.ZERO);
//
CLabel lTotal = new CLabel (Msg.translate(Env.getCtx(), "GrandTotal"));
summary.add(lTotal);
f_total = new VNumber("GrandTotal", false, true, false, DisplayType.Amount, "GrandTotal");
f_total.setColumns(11, 22);
lTotal.setLabelFor(f_total);
summary.add(f_total);
f_total.setValue (Env.ZERO);
//
f_delete.setReadWrite(true);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 0.7;
gbc.weighty = 0.7;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
public void dispose()
{
super.dispose();
} // dispose
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubAllLines - actionPerformed: " + action);
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;
}
// 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
/**
* Update Table
* @param order order
*/
public void updateTable (MOrder order)
{
int C_Order_ID = 0;
if (order != null)
C_Order_ID = order.getC_Order_ID();
if (C_Order_ID == 0)
{
m_table.loadTable(new PO[0]);
setSums(null);
}
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (m_sql, null);
pstmt.setInt (1, C_Order_ID);
rs = pstmt.executeQuery ();
m_table.loadTable(rs);
}
catch (Exception e)
{
log.log(Level.SEVERE, m_sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
setSums(order);
} // updateTable
/**
* Set Sums from Table
*/
private void setSums(MOrder order)
{
int noLines = m_table.getRowCount();
p_posPanel.f_status.setStatusDB(noLines);
if (order == null || noLines == 0) //red1 WORKAROUND (noLines == 0) means total and tax in order head is false.
{
f_net.setValue(Env.ZERO);
f_total.setValue(Env.ZERO);
f_tax.setValue(Env.ZERO);
}
else
{
// order.prepareIt(); //red1 Avoid Reserving Inventory until final process and update context directly from DB.
p_posPanel.f_curLine.setOrder(order.getC_Order_ID());
MOrder retValue = p_posPanel.f_curLine.getOrder();
//red1 - end -
f_net.setValue(retValue.getTotalLines());
f_total.setValue(retValue.getGrandTotal());
f_tax.setValue(retValue.getGrandTotal().subtract(retValue.getTotalLines()));
}
} // setSums
} // PosSubAllLines

View File

@ -1,729 +0,0 @@
/******************************************************************************
* 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.Cursor;
import java.awt.Event;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFormattedTextField;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.border.TitledBorder;
import net.miginfocom.swing.MigLayout;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.MBPartner;
import org.compiere.model.MBPartnerInfo;
import org.compiere.model.MBPartnerLocation;
import org.compiere.model.MCurrency;
import org.compiere.model.MOrder;
import org.compiere.model.MPriceList;
import org.compiere.model.MPriceListVersion;
import org.compiere.model.MUser;
import org.compiere.print.ReportCtl;
import org.compiere.print.ReportEngine;
import org.compiere.process.DocAction;
import org.compiere.swing.CButton;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CLabel;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
/**
* Customer Sub Panel
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> Jorg Janke
* @version $Id: SubBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class SubOrder extends PosSubPanel
implements ActionListener, FocusListener
{
/**
*
*/
private static final long serialVersionUID = 5895558315889871887L;
/**
* Constructor
* @param posPanel POS Panel
*/
public SubOrder (PosBasePanel posPanel)
{
super (posPanel);
} // PosSubCustomer
private CButton f_history;
private CTextField f_name;
private CButton f_bNew;
private CButton f_bSearch;
private CComboBox f_location;
private CComboBox f_user;
private CButton f_cashPayment;
private CButton f_process;
private CButton f_print;
private CTextField f_DocumentNo;
private CButton f_logout;
private JFormattedTextField f_net;
private JFormattedTextField f_tax;
private JFormattedTextField f_total;
private CTextField f_RepName;
/** The Business Partner */
private MBPartner m_bpartner;
/** Price List Version to use */
private int m_M_PriceList_Version_ID = 0;
private CTextField f_currency = new CTextField();
private CButton f_bEdit;
private CButton f_bSettings;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubOrder.class);
/**
* Initialize
*/
public void init()
{
// Content
MigLayout layout = new MigLayout("ins 0 0","[fill|fill|fill|fill]","[nogrid]unrel[||]");
setLayout(layout);
Font bigFont = AdempierePLAF.getFont_Field().deriveFont(16f);
String buttonSize = "w 50!, h 50!,";
// NEW
f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2));
add (f_bNew, buttonSize);
// EDIT
f_bEdit = createButtonAction("Edit", null);
add(f_bEdit, buttonSize);
f_bEdit.setEnabled(false);
// HISTORY
f_history = createButtonAction("History", null);
add (f_history, buttonSize);
// CANCEL
f_process = createButtonAction("Cancel", null);
add (f_process, buttonSize);
f_process.setEnabled(false);
// PAYMENT
f_cashPayment = createButtonAction("Payment", null);
f_cashPayment.setActionCommand("Cash");
add (f_cashPayment, buttonSize);
f_cashPayment.setEnabled(false);
//PRINT
f_print = createButtonAction("Print", null);
add (f_print, buttonSize);
f_print.setEnabled(false);
// Settings
f_bSettings = createButtonAction("Preference", null);
add (f_bSettings, buttonSize);
//
f_logout = createButtonAction ("Logout", null);
add (f_logout, buttonSize + ", gapx 25, wrap");
// DOC NO
add (new CLabel(Msg.getMsg(Env.getCtx(),"DocumentNo")), "");
f_DocumentNo = new CTextField("");
f_DocumentNo.setName("DocumentNo");
f_DocumentNo.setEditable(false);
add (f_DocumentNo, "growx, pushx");
CLabel lNet = new CLabel (Msg.translate(Env.getCtx(), "SubTotal"));
add(lNet, "");
f_net = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
f_net.setHorizontalAlignment(JTextField.TRAILING);
f_net.setEditable(false);
f_net.setFocusable(false);
lNet.setLabelFor(f_net);
add(f_net, "wrap, growx, pushx");
f_net.setValue (Env.ZERO);
//
/*
// BPARTNER
f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK));
add (f_bSearch,buttonSize + ", spany 2");
*/
/*
* f_name.setName("Name");
f_name.addActionListener(this);
f_name.addFocusListener(this);
add (f_name, "wrap");
*/
// SALES REP
add(new CLabel(Msg.translate(Env.getCtx(), "SalesRep_ID")), "");
f_RepName = new CTextField("");
f_RepName.setName("SalesRep");
f_RepName.setEditable(false);
add (f_RepName, "growx, pushx");
CLabel lTax = new CLabel (Msg.translate(Env.getCtx(), "TaxAmt"));
add(lTax);
f_tax = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
f_tax.setHorizontalAlignment(JTextField.TRAILING);
f_tax.setEditable(false);
f_tax.setFocusable(false);
lTax.setLabelFor(f_tax);
add(f_tax, "wrap, growx, pushx");
f_tax.setValue (Env.ZERO);
//
/*
f_location = new CComboBox();
add (f_location, " wrap");
*/
// BP
add(new CLabel(Msg.translate(Env.getCtx(), "C_BPartner_ID")), "");
f_name = new CTextField();
f_name.setEditable(false);
f_name.setName("Name");
add (f_name, "growx, pushx");
//
CLabel lTotal = new CLabel (Msg.translate(Env.getCtx(), "GrandTotal"));
lTotal.setFont(bigFont);
add(lTotal, "");
f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
f_total.setHorizontalAlignment(JTextField.TRAILING);f_total.setFont(bigFont);
f_total.setEditable(false);
f_total.setFocusable(false);
lTotal.setLabelFor(f_total);
add(f_total, "growx, pushx");
f_total.setValue (Env.ZERO);
/*
//
f_user = new CComboBox();
add (f_user, "skip 1");
*/
} // init
/**
* Dispose - Free Resources
*/
public void dispose()
{
if (f_name != null)
f_name.removeFocusListener(this);
f_name = null;
removeAll();
super.dispose();
} // dispose
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubCustomer - actionPerformed: " + action);
// New
if (action.equals("New"))
{
p_posPanel.newOrder(); //red1 New POS Order instead - B_Partner already has direct field
return;
}
// Register
if (action.equals("History"))
{
PosQuery qt = new QueryTicket(p_posPanel);
qt.setVisible(true);
return;
}
else if (action.equals("Cancel"))
deleteOrder();
else if (action.equals("Cash"))
payOrder();
else if (action.equals("Print"))
printOrder();
else if (action.equals("BPartner"))
{
PosQuery qt = new QueryBPartner(p_posPanel);
qt.setVisible(true);
}
// Logout
else if (action.equals("Logout"))
{
p_posPanel.dispose();
return;
}
// Name
else if (e.getSource() == f_name)
findBPartner();
p_posPanel.updateInfo();
} // actionPerformed
/**
*
*/
private void printOrder() {
{
if (isOrderFullyPaid())
{
updateOrder();
printTicket();
openCashDrawer();
}
}
}
/**
*
*/
private void payOrder() {
//Check if order is completed, if so, print and open drawer, create an empty order and set cashGiven to zero
if( p_posPanel.m_order != null )
{
if ( !p_posPanel.m_order.isProcessed() && !p_posPanel.m_order.processOrder() )
{
ADialog.warn(0, p_posPanel, "PosOrderProcessFailed");
return;
}
if ( PosPayment.pay(p_posPanel) )
{
printTicket();
p_posPanel.setOrder(0);
}
}
}
/**
*
*/
private void deleteOrder() {
if ( p_posPanel != null && ADialog.ask(0, this, "Delete order?") )
p_posPanel.m_order.deleteOrder();
// p_posPanel.newOrder();
}
/**
* Focus Gained
* @param e
*/
public void focusGained (FocusEvent e)
{
} // focusGained
/**
* Focus Lost
* @param e
*/
public void focusLost (FocusEvent e)
{
if (e.isTemporary())
return;
log.info(e.toString());
findBPartner();
} // focusLost
/**
* Find/Set BPartner
*/
private void findBPartner()
{
String query = f_name.getText();
if (query == null || query.length() == 0)
return;
// unchanged
if ( m_bpartner != null && m_bpartner.getName().equals(query))
return;
query = query.toUpperCase();
// Test Number
boolean allNumber = true;
boolean noNumber = true;
char[] qq = query.toCharArray();
for (int i = 0; i < qq.length; i++)
{
if (Character.isDigit(qq[i]))
{
noNumber = false;
break;
}
}
try
{
Integer.parseInt(query);
}
catch (Exception e)
{
allNumber = false;
}
String Value = query;
String Name = (allNumber ? null : query);
String EMail = (query.indexOf('@') != -1 ? query : null);
String Phone = (noNumber ? null : query);
String City = null;
//
//TODO: contact have been remove from rv_bpartner
MBPartnerInfo[] results = MBPartnerInfo.find(p_ctx, Value, Name,
/*Contact, */null, EMail, Phone, City);
// Set Result
if (results.length == 0)
{
setC_BPartner_ID(0);
}
else if (results.length == 1)
{
setC_BPartner_ID(results[0].getC_BPartner_ID());
f_name.setText(results[0].getName());
}
else // more than one
{
QueryBPartner qt = new QueryBPartner(p_posPanel);
qt.setResults (results);
qt.setVisible(true);
}
} // findBPartner
/**************************************************************************
* Set BPartner
* @param C_BPartner_ID id
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
log.fine( "PosSubCustomer.setC_BPartner_ID=" + C_BPartner_ID);
if (C_BPartner_ID == 0)
m_bpartner = null;
else
{
m_bpartner = new MBPartner(p_ctx, C_BPartner_ID, null);
if (m_bpartner.get_ID() == 0)
m_bpartner = null;
}
// Set Info
if (m_bpartner != null)
{
f_name.setText(m_bpartner.getName());
}
else
{
f_name.setText(null);
}
// Sets Currency
m_M_PriceList_Version_ID = 0;
getM_PriceList_Version_ID();
//fillCombos();
if ( p_posPanel.m_order != null && m_bpartner != null )
p_posPanel.m_order.setBPartner(m_bpartner); //added by ConSerTi to update the client in the request
} // setC_BPartner_ID
/**
* Fill Combos (Location, User)
*/
private void fillCombos()
{
Vector<KeyNamePair> locationVector = new Vector<KeyNamePair>();
if (m_bpartner != null)
{
MBPartnerLocation[] locations = m_bpartner.getLocations(false);
for (int i = 0; i < locations.length; i++)
locationVector.add(locations[i].getKeyNamePair());
}
DefaultComboBoxModel locationModel = new DefaultComboBoxModel(locationVector);
f_location.setModel(locationModel);
//
Vector<KeyNamePair> userVector = new Vector<KeyNamePair>();
if (m_bpartner != null)
{
MUser[] users = m_bpartner.getContacts(false);
for (int i = 0; i < users.length; i++)
userVector.add(users[i].getKeyNamePair());
}
DefaultComboBoxModel userModel = new DefaultComboBoxModel(userVector);
f_user.setModel(userModel);
} // fillCombos
/**
* Get BPartner
* @return C_BPartner_ID
*/
public int getC_BPartner_ID ()
{
if (m_bpartner != null)
return m_bpartner.getC_BPartner_ID();
return 0;
} // getC_BPartner_ID
/**
* Get BPartner
* @return BPartner
*/
public MBPartner getBPartner ()
{
return m_bpartner;
} // getBPartner
/**
* Get BPartner Location
* @return C_BPartner_Location_ID
*/
public int getC_BPartner_Location_ID ()
{
if (m_bpartner != null)
{
KeyNamePair pp = (KeyNamePair)f_location.getSelectedItem();
if (pp != null)
return pp.getKey();
}
return 0;
} // getC_BPartner_Location_ID
/**
* Get BPartner Contact
* @return AD_User_ID
*/
public int getAD_User_ID ()
{
if (m_bpartner != null)
{
KeyNamePair pp = (KeyNamePair)f_user.getSelectedItem();
if (pp != null)
return pp.getKey();
}
return 0;
} // getC_BPartner_Location_ID
/**
* Get M_PriceList_Version_ID.
* Set Currency
* @return plv
*/
public int getM_PriceList_Version_ID()
{
if (m_M_PriceList_Version_ID == 0)
{
int M_PriceList_ID = p_pos.getM_PriceList_ID();
if (m_bpartner != null && m_bpartner.getM_PriceList_ID() != 0)
M_PriceList_ID = m_bpartner.getM_PriceList_ID();
//
MPriceList pl = MPriceList.get(p_ctx, M_PriceList_ID, null);
setCurrency(MCurrency.getISO_Code(p_ctx, pl.getC_Currency_ID()));
f_name.setToolTipText(pl.getName());
//
MPriceListVersion plv = pl.getPriceListVersion (p_posPanel.getToday());
if (plv != null && plv.getM_PriceList_Version_ID() != 0)
m_M_PriceList_Version_ID = plv.getM_PriceList_Version_ID();
}
return m_M_PriceList_Version_ID;
} // getM_PriceList_Version_ID
/***************************************************************************
* Set Currency
*
* @param currency
* currency
*/
public void setCurrency(String currency) {
if (currency == null)
f_currency.setText("---");
else
f_currency.setText(currency);
} // setCurrency
/**
* Print Ticket
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public void printTicket()
{
if ( p_posPanel.m_order == null )
return;
MOrder order = p_posPanel.m_order;
//int windowNo = p_posPanel.getWindowNo();
//Properties m_ctx = p_posPanel.getPropiedades();
if (order != null)
{
try
{
//TODO: to incorporate work from Posterita
/*
if (p_pos.getAD_PrintLabel_ID() != 0)
PrintLabel.printLabelTicket(order.getC_Order_ID(), p_pos.getAD_PrintLabel_ID());
*/
//print standard document
ReportCtl.startDocumentPrint(ReportEngine.ORDER, order.getC_Order_ID(), null, AEnv.getWindowNo(this), true);
}
catch (Exception e)
{
log.severe("PrintTicket - Error Printing Ticket");
}
}
}
/**
* 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 <EFBFBD> ConSerTi
*/
public boolean isOrderFullyPaid()
{
/*TODO
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;
*/
return true;
}
/**
* 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 <EFBFBD> ConSerTi
*/
public void updateOrder()
{
if (p_posPanel != null )
{
MOrder order = p_posPanel.m_order;
if (order != null)
{
f_DocumentNo.setText(order.getDocumentNo());
setC_BPartner_ID(order.getC_BPartner_ID());
f_bNew.setEnabled(order.getLines().length != 0);
f_bEdit.setEnabled(true);
f_history.setEnabled(order.getLines().length != 0);
f_process.setEnabled(true);
f_print.setEnabled(order.isProcessed());
f_cashPayment.setEnabled(order.getLines().length != 0);
}
else
{
f_DocumentNo.setText(null);
setC_BPartner_ID(0);
f_bNew.setEnabled(true);
f_bEdit.setEnabled(false);
f_history.setEnabled(true);
f_process.setEnabled(false);
f_print.setEnabled(false);
f_cashPayment.setEnabled(false);
}
}
}
/**
* Abrir caja
* Abre la caja registradora
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright <EFBFBD> ConSerTi
*/
public void openCashDrawer()
{
String port = "/dev/lp";
byte data[] = new byte[] {0x1B, 0x40, 0x1C};
try {
FileOutputStream m_out = null;
if (m_out == null) {
m_out = new FileOutputStream(port); // No poner append = true.
}
m_out.write(data);
} catch (IOException e) {
}
}
/**
* Set Sums from Table
*/
void setSums(PosOrderModel order)
{
int noLines = p_posPanel.f_curLine.m_table.getRowCount();
if (order == null || noLines == 0)
{
f_net.setValue(Env.ZERO);
f_total.setValue(Env.ZERO);
f_tax.setValue(Env.ZERO);
}
else
{
// order.getMOrder().prepareIt();
f_net.setValue(order.getSubtotal());
f_total.setValue(order.getGrandTotal());
f_tax.setValue(order.getTaxAmt());
}
} // setSums
} // PosSubCustomer

View File

@ -0,0 +1,329 @@
/******************************************************************************
* 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.Event;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import javax.swing.border.TitledBorder;
import org.compiere.model.MProduct;
import org.compiere.model.MWarehousePrice;
import org.compiere.swing.CButton;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Product Sub Panel.
* Responsible for Product Selection and maintaining
* M_Product_ID, Name, UOM
* and setting Price
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
* @version $Id: SubProduct.java,v 1.2 2004/07/24 04:31:52 jjanke Exp $
*/
public class SubProduct extends PosSubPanel
implements ActionListener, FocusListener
{
/**
*
*/
private static final long serialVersionUID = -6626441083848884910L;
/**
* Constructor
* @param posPanel POS Panel
*/
public SubProduct (PosPanel posPanel)
{
super (posPanel);
} // PosSubProduct
protected CTextField f_name;
private CButton f_bSearch;
/** The Product */
private MProduct m_product = null;
/** Warehouse */
private int m_M_Warehouse_ID;
/** PLV */
private int m_M_PriceList_Version_ID;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubProduct.class);
/**
* Initialize
*/
public void init()
{
// Title
TitledBorder border = new TitledBorder(Msg.translate(p_ctx, "M_Product_ID"));
setBorder(border);
// Content
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2;
// --
f_name = new CTextField("");
f_name.setName("Name");
f_name.addActionListener(this);
f_name.addFocusListener(this);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 0.1;
add (f_name, gbc);
//
f_bSearch = createButtonAction ("Product", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK));
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0;
add (f_bSearch, gbc);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
public void dispose()
{
if (f_name != null)
f_name.removeFocusListener(this);
removeAll();
super.dispose();
} // dispose
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubProduct - actionPerformed: " + action);
// Product
if (action.equals("Product"))
{
setParameter();
p_posPanel.openQuery(p_posPanel.f_queryProduct);
}
// Name
else if (e.getSource() == f_name)
findProduct();
p_posPanel.updateInfo();
} // actionPerformed
/**
* Focus Gained
* @param e
*/
public void focusGained (FocusEvent e)
{
} // focusGained
/**
* Focus Lost
* @param e
*/
public void focusLost (FocusEvent e)
{
if (e.isTemporary())
return;
log.info( "PosSubProduct - focusLost");
findProduct();
p_posPanel.updateInfo();
} // focusLost
/**
* Set Query Paramter
*/
private void setParameter()
{
// What PriceList ?
m_M_Warehouse_ID = p_pos.getM_Warehouse_ID();
m_M_PriceList_Version_ID = p_posPanel.f_bpartner.getM_PriceList_Version_ID();
p_posPanel.f_queryProduct.setQueryData(m_M_PriceList_Version_ID, m_M_Warehouse_ID);
} // setParameter
/**************************************************************************
* Find/Set Product & Price
*/
private void findProduct()
{
String query = f_name.getText();
if (query == null || query.length() == 0)
return;
query = query.toUpperCase();
// Test Number
boolean allNumber = true;
try
{
Integer.getInteger(query);
}
catch (Exception e)
{
allNumber = false;
}
String Value = query;
String Name = query;
String UPC = (allNumber ? query : null);
String SKU = (allNumber ? query : null);
MWarehousePrice[] results = null;
setParameter();
//
results = MWarehousePrice.find (p_ctx,
m_M_PriceList_Version_ID, m_M_Warehouse_ID,
Value, Name, UPC, SKU, null);
// Set Result
if (results.length == 0)
{
setM_Product_ID(0);
p_posPanel.f_curLine.setPrice(Env.ZERO);
}
else if (results.length == 1)
{
setM_Product_ID(results[0].getM_Product_ID());
f_name.setText(results[0].getName());
p_posPanel.f_curLine.setPrice(results[0].getPriceStd());
}
else // more than one
{
p_posPanel.f_queryProduct.setResults (results);
p_posPanel.openQuery(p_posPanel.f_queryProduct);
}
} // findProduct
/**
* Set Price for defined product
*/
public void setPrice()
{
if (m_product == null)
return;
//
setParameter();
MWarehousePrice result = MWarehousePrice.get (m_product,
m_M_PriceList_Version_ID, m_M_Warehouse_ID, null);
if (result != null)
p_posPanel.f_curLine.setPrice(result.getPriceStd());
} // setPrice
/**************************************************************************
* Set Product
* @param M_Product_ID id
*/
public void setM_Product_ID (int M_Product_ID)
{
log.fine( "PosSubProduct.setM_Product_ID=" + M_Product_ID);
if (M_Product_ID <= 0)
m_product = null;
else
{
m_product = MProduct.get(p_ctx, M_Product_ID);
if (m_product.get_ID() == 0)
m_product = null;
}
// Set String Info
if (m_product != null)
{
f_name.setText(m_product.getName());
f_name.setToolTipText(m_product.getDescription());
p_posPanel.f_curLine.setUOM(m_product.getUOMSymbol());
}
else
{
f_name.setText(null);
f_name.setToolTipText(null);
p_posPanel.f_curLine.setUOM(null);
}
} // setM_Product_ID
/**
* Get Product
* @return M_Product_ID
*/
public int getM_Product_ID ()
{
if (m_product != null)
return m_product.getM_Product_ID();
return 0;
} // getM_Product_ID
/**
* Get UOM
* @return C_UOM_ID
*/
public int getC_UOM_ID ()
{
if (m_product != null)
return m_product.getC_UOM_ID();
return 0;
} // getC_UOM_ID
/**
* Get Product Name
* @return name of product
*/
public String getProductName()
{
if (m_product != null)
return m_product.getName();
return "";
} // getProductName
/**
* Get Product
* @return product
*/
public MProduct getProduct()
{
return m_product;
} // getProduct
} // PosSubProduct

View File

@ -0,0 +1,127 @@
/******************************************************************************
* 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.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.border.TitledBorder;
import org.compiere.swing.CButton;
import org.compiere.swing.CLabel;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Sales Rep Sub Panel
*
* @author Comunidad de Desarrollo OpenXpertya
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
* *Copyright (c) Jorg Janke
* @version $Id: SubSalesRep.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $
*/
public class SubSalesRep extends PosSubPanel implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 840666209988831145L;
/**
* Constructor
* @param posPanel POS Panel
*/
public SubSalesRep (PosPanel posPanel)
{
super (posPanel);
} // PosSubSalesRep
private CLabel f_label = null;
private CButton f_button = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubSalesRep.class);
/**
* Initialize
*/
public void init()
{
// Title
TitledBorder border = new TitledBorder(Msg.translate(Env.getCtx(), "C_POS_ID"));
setBorder(border);
// Content
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2;
// --
f_label = new CLabel(p_pos.getName(), CLabel.LEADING);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0.5;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
add (f_label, gbc);
//
f_button = new CButton (Msg.getMsg(Env.getCtx(), "Logout"));
f_button.setActionCommand("LogOut");
f_button.setFocusable(false);
f_button.addActionListener(this);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = GridBagConstraints.NONE;
add (f_button, gbc);
} // init
/**
* Get Panel Position
*/
public GridBagConstraints getGridBagConstraints()
{
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
return gbc;
} // getGridBagConstraints
/**
* Dispose - Free Resources
*/
public void dispose()
{
super.dispose();
} // dispose
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubSalesRep - actionPerformed: " + action);
// Logout
p_posPanel.dispose();
} // actinPerformed
} // PosSubSalesRep