Integrate changes from red1 done on branches/JavaPOS
IDEMPIERE-61
This commit is contained in:
parent
ccd8bfac2f
commit
3ce0b68ddf
|
@ -174,6 +174,12 @@ public final class ALogin extends CDialog
|
|||
private void jbInit() throws Exception
|
||||
{
|
||||
this.setName("Login");
|
||||
//red1 - giving names to input fields for UISpec4J calling during tests
|
||||
orgCombo.setName("orgCombo");
|
||||
clientCombo.setName("clientCombo");
|
||||
userTextField.setName("userTextField");
|
||||
passwordField.setName("passwordField");
|
||||
//red1 - end -
|
||||
titleLabel.setFont(new java.awt.Font("Serif", 2, 10));
|
||||
titleLabel.setForeground(Color.blue);
|
||||
titleLabel.setRequestFocusEnabled(false);
|
||||
|
|
|
@ -343,6 +343,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
|
|||
if (action.equals("displayInitialChange"))
|
||||
{
|
||||
cmd_displayInitialChange();
|
||||
cInitial.setVisible(false);
|
||||
}
|
||||
// to display panel with cash closing
|
||||
else if (action.equals("CashClosing"))
|
||||
|
@ -403,8 +404,10 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
|
|||
*/
|
||||
private void cmd_displayInitialChange()
|
||||
{
|
||||
cScrutiny.setVisible(false);
|
||||
c.setVisible(false);
|
||||
if (cScrutiny.isVisible())
|
||||
cScrutiny.setVisible(false);
|
||||
if (c.isVisible())
|
||||
c.setVisible(false);
|
||||
cInitial.setVisible(true);
|
||||
|
||||
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||
|
@ -429,8 +432,10 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
|
|||
*/
|
||||
private void cmd_displayCashScrutiny()
|
||||
{
|
||||
cInitial.setVisible(false);
|
||||
c.setVisible(false);
|
||||
if (cInitial.isVisible())
|
||||
cInitial.setVisible(false);
|
||||
if (c.isVisible())
|
||||
c.setVisible(false);
|
||||
cScrutiny.setVisible(true);
|
||||
|
||||
// calculate total until the moment and shows it in scrutiny panel
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//red1 -- use for POS GUI Testing in Fitnesse with UISpec4J.
|
||||
package org.compiere.pos;
|
||||
|
||||
import java.awt.KeyboardFocusManager;
|
||||
|
@ -16,24 +17,19 @@ 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();
|
||||
// Splash splash = Splash.getSplash(); -- red1 -- not mandatory, so its removed for faster GUI testing
|
||||
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);
|
||||
ALogin login = new ALogin(frame);
|
||||
if (!login.initLogin()) // no automatic login
|
||||
{
|
||||
// Center the window
|
||||
|
@ -44,22 +40,14 @@ public class PosApplication {
|
|||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (!login.isConnected() || !login.isOKpressed())
|
||||
if (!login.isConnected()) // '|| !login.isOKpressed()' -- red1 -- can't work during UISpec4J testing
|
||||
AEnv.exit(1);
|
||||
}
|
||||
|
||||
// Check Build
|
||||
if (!DB.isBuildOK(m_ctx))
|
||||
if (!DB.isBuildOK(m_ctx)) // red1 - m_ctx seems null
|
||||
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());
|
||||
|
||||
//
|
||||
Env.setContext( Env.getCtx(), "#M_Warehouse_ID", 104 ); //red1 - presetting to Store Central for GUI Testing
|
||||
if (!Adempiere.startupEnvironment(true)) // Load Environment
|
||||
System.exit(1);
|
||||
MSession.get (Env.getCtx(), true); // Start Session
|
||||
|
@ -88,8 +76,8 @@ public class PosApplication {
|
|||
PosBasePanel pos = new PosBasePanel();
|
||||
pos.init(0,frame);
|
||||
frame.pack();
|
||||
splash.dispose();
|
||||
splash = null;
|
||||
// splash.dispose();
|
||||
// splash = null;
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,18 +50,18 @@ import org.compiere.util.Msg;
|
|||
public class PosBasePanel extends CPanel
|
||||
//implements FormPanel
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3010214392188209281L;
|
||||
|
||||
private static final long serialVersionUID = 7477837683408198860L;
|
||||
|
||||
public static String trxName = null; //Trx.createTrxName("GUIPOSTesting_"); --red1 won't persist trx for recall in display
|
||||
//trxName for not committing test so tests does not impact DB.. temporary halt due to above issue.
|
||||
/**
|
||||
* Constructor - see init
|
||||
*/
|
||||
public PosBasePanel()
|
||||
{
|
||||
|
||||
super (new MigLayout(" fill","[500!]10[300:350:, fill]",""));
|
||||
originalKeyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
m_focusMgr = new PosKeyboardFocusManager();
|
||||
|
@ -105,6 +105,10 @@ public class PosBasePanel extends CPanel
|
|||
private CFrame frame;
|
||||
private HashMap<Integer, POSKeyboard> keyboards = new HashMap<Integer, POSKeyboard>();
|
||||
|
||||
|
||||
public String getTrxName(){
|
||||
return trxName;
|
||||
}
|
||||
/**
|
||||
* Initialize Panel
|
||||
* @param WindowNo window
|
||||
|
@ -231,7 +235,7 @@ public class PosBasePanel extends CPanel
|
|||
add (f_order, "split 2, flowy, growx, spany");
|
||||
//
|
||||
f_curLine = new SubCurrentLine (this);
|
||||
add (f_curLine, "h 300, growx, growy, gaptop 30");
|
||||
add (f_curLine, "h 300, growx, growy, gaptop 10");
|
||||
|
||||
f_functionKeys = new SubFunctionKeys (this);
|
||||
add (f_functionKeys, "aligny top, h 500, growx, growy, flowy, split 2");
|
||||
|
@ -310,7 +314,7 @@ public class PosBasePanel extends CPanel
|
|||
log.info( "PosPanel.newOrder");
|
||||
f_order.setC_BPartner_ID(0);
|
||||
m_order = null;
|
||||
m_order = PosOrderModel.createOrder(p_pos, f_order.getBPartner());
|
||||
m_order = PosOrderModel.createOrder(p_pos, f_order.getBPartner(), trxName);
|
||||
f_curLine.newLine();
|
||||
f_curLine.f_name.requestFocusInWindow();
|
||||
updateInfo();
|
||||
|
@ -362,7 +366,7 @@ public class PosBasePanel extends CPanel
|
|||
if ( m_c_order_id == 0 )
|
||||
m_order = null;
|
||||
else
|
||||
m_order = new PosOrderModel(m_ctx , m_c_order_id, null, p_pos);
|
||||
m_order = new PosOrderModel(m_ctx , m_c_order_id, trxName, p_pos);
|
||||
updateInfo();
|
||||
}
|
||||
|
||||
|
@ -374,7 +378,7 @@ public class PosBasePanel extends CPanel
|
|||
if ( m_c_order_id == 0 )
|
||||
m_order = null;
|
||||
else
|
||||
m_order = new PosOrderModel(m_ctx , m_c_order_id, null, p_pos);
|
||||
m_order = new PosOrderModel(m_ctx , m_c_order_id, trxName, p_pos);
|
||||
}
|
||||
|
||||
public POSKeyboard getKeyboard(int keyLayoutId) {
|
||||
|
|
|
@ -44,8 +44,11 @@ public class PosOrderModel extends MOrder {
|
|||
|
||||
private MPOS m_pos;
|
||||
|
||||
private String trxName;
|
||||
|
||||
public PosOrderModel(Properties ctx, int C_Order_ID, String trxName, MPOS pos) {
|
||||
super(ctx, C_Order_ID, trxName);
|
||||
this.trxName = trxName;
|
||||
m_pos = pos;
|
||||
}
|
||||
|
||||
|
@ -54,9 +57,9 @@ public class PosOrderModel extends MOrder {
|
|||
*
|
||||
* @return order or null
|
||||
*/
|
||||
public static PosOrderModel createOrder(MPOS pos, MBPartner partner) {
|
||||
public static PosOrderModel createOrder(MPOS pos, MBPartner partner, String trxName) {
|
||||
|
||||
PosOrderModel order = new PosOrderModel(Env.getCtx(), 0, null, pos);
|
||||
PosOrderModel order = new PosOrderModel(Env.getCtx(), 0, trxName, pos);
|
||||
order.setAD_Org_ID(pos.getAD_Org_ID());
|
||||
order.setIsSOTrx(true);
|
||||
order.setC_POS_ID(pos.getC_POS_ID());
|
||||
|
@ -86,9 +89,9 @@ public class PosOrderModel extends MOrder {
|
|||
|
||||
|
||||
/**
|
||||
* @author Comunidad de Desarrollo OpenXpertya
|
||||
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
|
||||
* *Copyright <EFBFBD> ConSerTi
|
||||
* @author Community Development OpenXpertya
|
||||
* *Based on Modified Original Code, Revised and Optimized:
|
||||
* *Copyright ConSerTi
|
||||
*/
|
||||
public void setBPartner(MBPartner partner)
|
||||
{
|
||||
|
@ -174,7 +177,7 @@ public class PosOrderModel extends MOrder {
|
|||
*
|
||||
* @author Comunidad de Desarrollo OpenXpertya
|
||||
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
|
||||
* *Copyright <EFBFBD> ConSerTi
|
||||
* *Copyright ConSerTi
|
||||
*/
|
||||
public boolean deleteOrder () {
|
||||
if (getDocStatus().equals("DR"))
|
||||
|
@ -187,7 +190,7 @@ public class PosOrderModel extends MOrder {
|
|||
for (int i = numLines - 1; i >= 0; i--)
|
||||
{
|
||||
if (lines[i] != null)
|
||||
deleteLine(lines[i].getC_Order_ID());
|
||||
deleteLine(lines[i].getC_OrderLine_ID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,12 +203,16 @@ public class PosOrderModel extends MOrder {
|
|||
{
|
||||
if (taxs[i] != null)
|
||||
taxs[i].delete(true);
|
||||
taxs[i].saveEx();
|
||||
taxs[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
getLines(true, null); // requery order
|
||||
return delete(true);
|
||||
setDocStatus("VO");//delete(true); red1 -- should not delete but void the order
|
||||
setProcessed(true); //red1 -- to avoid been in history during query
|
||||
save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // deleteOrder
|
||||
|
@ -222,6 +229,7 @@ public class PosOrderModel extends MOrder {
|
|||
if ( line.getC_OrderLine_ID() == C_OrderLine_ID )
|
||||
{
|
||||
line.delete(true);
|
||||
line.saveEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +354,7 @@ public class PosOrderModel extends MOrder {
|
|||
String cardNo, String cvc, String cardtype)
|
||||
{
|
||||
|
||||
MPayment payment = createPayment(MPayment.TENDERTYPE_Check);
|
||||
MPayment payment = createPayment(MPayment.TENDERTYPE_CreditCard);
|
||||
payment.setAmount(getC_Currency_ID(), amt);
|
||||
payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID());
|
||||
payment.setCreditCard(MPayment.TRXTYPE_Sales, cardtype,
|
||||
|
@ -364,7 +372,7 @@ public class PosOrderModel extends MOrder {
|
|||
|
||||
private MPayment createPayment(String tenderType)
|
||||
{
|
||||
MPayment payment = new MPayment(getCtx(), 0, null);
|
||||
MPayment payment = new MPayment(getCtx(), 0, trxName);
|
||||
payment.setAD_Org_ID(m_pos.getAD_Org_ID());
|
||||
payment.setTenderType(tenderType);
|
||||
payment.setC_Order_ID(getC_Order_ID());
|
||||
|
|
|
@ -24,7 +24,10 @@ import java.beans.PropertyVetoException;
|
|||
import java.beans.VetoableChangeListener;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
|
@ -62,19 +65,31 @@ 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;
|
||||
private static final long serialVersionUID = -1961758117289056671L;
|
||||
|
||||
NumberFormat formatter = new DecimalFormat("#0.00"); //red1 - parser to remove commas or dots separator for above '000s.
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.getDefault()); // make locale-specific
|
||||
|
||||
@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() );
|
||||
//red1 - remove commas from thousand value
|
||||
BigDecimal tender = Env.ZERO;
|
||||
BigDecimal pay = Env.ZERO;
|
||||
try
|
||||
{
|
||||
tender = new BigDecimal(formatter.format((nf.parse(fTenderAmt.getText())).floatValue()));
|
||||
pay = new BigDecimal(formatter.format((nf.parse(fPayAmt.getText())).floatValue()));
|
||||
}
|
||||
catch (ParseException n)
|
||||
{
|
||||
n.printStackTrace();
|
||||
}
|
||||
if ( tender.compareTo(Env.ZERO) != 0 )
|
||||
{
|
||||
fReturnAmt.setValue(tender.subtract(pay));
|
||||
|
@ -88,6 +103,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang
|
|||
}
|
||||
if ( e.getSource().equals(f_bCancel))
|
||||
{
|
||||
paid = false;
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
|
@ -102,7 +118,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang
|
|||
try {
|
||||
|
||||
String tenderType = ((ValueNamePair) tenderTypePick.getValue()).getID();
|
||||
BigDecimal amt = new BigDecimal(fPayAmt.getText());
|
||||
BigDecimal amt = new BigDecimal(formatter.format((nf.parse(fPayAmt.getText())).floatValue()));;
|
||||
|
||||
if ( tenderType.equals(MPayment.TENDERTYPE_Cash) )
|
||||
{
|
||||
|
@ -253,6 +269,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang
|
|||
|
||||
tenderTypePick.setFont(font);
|
||||
tenderTypePick.addActionListener(this);
|
||||
tenderTypePick.setName("tenderTypePick"); //red1 for ID purpuse during testing
|
||||
tenderTypePick.setRenderer(new ListCellRenderer() {
|
||||
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
|
||||
|
||||
|
@ -323,6 +340,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang
|
|||
ValueNamePair[] ccs = p_order.getCreditCards((BigDecimal) fPayAmt.getValue());
|
||||
// Set Selection
|
||||
fCCardType = new CComboBox(ccs);
|
||||
fCCardType.setName("cardType"); //red1 Id for testing
|
||||
fCCardType.setRenderer(new ListCellRenderer() {
|
||||
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
|
||||
|
||||
|
@ -347,6 +365,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang
|
|||
|
||||
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"));
|
||||
fCCardNo.setName("cardNo");
|
||||
mainPanel.add(lCCardNo, "growx");
|
||||
mainPanel.add(fCCardNo, "wrap, growx");
|
||||
fCCardNo.setFont(font);
|
||||
|
@ -361,6 +380,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang
|
|||
|
||||
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"));
|
||||
fCCardMonth.setName("expiry");
|
||||
mainPanel.add(lCCardMonth, "growx");
|
||||
mainPanel.add(fCCardMonth, "wrap, w 75!");
|
||||
fCCardMonth.setFont(font);
|
||||
|
|
|
@ -21,8 +21,12 @@ import java.util.Properties;
|
|||
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.AppsAction;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MPOS;
|
||||
import org.compiere.print.ReportCtl;
|
||||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.swing.CButton;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -40,7 +44,7 @@ public abstract class PosSubPanel extends CPanel
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -158167614949876569L;
|
||||
private static final long serialVersionUID = -8112502747494990955L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -61,6 +65,7 @@ public abstract class PosSubPanel extends CPanel
|
|||
/** Context */
|
||||
protected Properties p_ctx = Env.getCtx();
|
||||
|
||||
protected static CButton f_cashPayment;
|
||||
|
||||
/** Button Width = 50 */
|
||||
private static final int WIDTH = 50;
|
||||
|
@ -123,5 +128,38 @@ public abstract class PosSubPanel extends CPanel
|
|||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
} // actionPerformed
|
||||
/**
|
||||
* Print Ticket
|
||||
* @author Comunidad de Desarrollo OpenXpertya
|
||||
* *Basado en Codigo Original Modificado, Revisado y Optimizado de:
|
||||
* *Copyright 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
} // PosSubPanel
|
||||
|
|
|
@ -109,6 +109,7 @@ public class QueryProduct extends PosQuery
|
|||
CLabel lvalue = new CLabel(Msg.translate(p_ctx, "Value"));
|
||||
northPanel.add (lvalue, "growy");
|
||||
f_value = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
|
||||
f_value.setName("ProductKey"); //red1 for UISpec4J testing call
|
||||
lvalue.setLabelFor(f_value);
|
||||
northPanel.add(f_value, "h 30, w 200");
|
||||
f_value.addActionListener(this);
|
||||
|
@ -123,6 +124,7 @@ public class QueryProduct extends PosQuery
|
|||
CLabel lname = new CLabel(Msg.translate(p_ctx, "Name"));
|
||||
northPanel.add (lname, "growy");
|
||||
f_name = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID());
|
||||
f_name.setName("ProductName"); //red1 for UISpec4J testing call
|
||||
lname.setLabelFor(f_name);
|
||||
northPanel.add(f_name, "h 30, w 200");
|
||||
f_name.addActionListener(this);
|
||||
|
@ -167,7 +169,6 @@ public class QueryProduct extends PosQuery
|
|||
m_table.getColumn(7).setPreferredWidth(75);
|
||||
enableButtons();
|
||||
m_table.setFillsViewportHeight( true ); //@Trifon
|
||||
// m_table.setFocusable( true ); //@Trifon
|
||||
m_table.growScrollbars();
|
||||
centerScroll = new CScrollPane(m_table);
|
||||
panel.add (centerScroll, "growx, growy,south");
|
||||
|
|
|
@ -60,7 +60,9 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8998584388380857134L;
|
||||
private static final long serialVersionUID = 8348032740580968638L;
|
||||
|
||||
private String trxName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -69,6 +71,7 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
*/
|
||||
public SubCurrentLine(PosBasePanel posPanel) {
|
||||
super(posPanel);
|
||||
trxName = posPanel.getTrxName();
|
||||
}
|
||||
|
||||
private CButton f_up;
|
||||
|
@ -129,18 +132,26 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
String buttonSize = "w 50!, h 50!,";
|
||||
//
|
||||
f_bSearch = createButtonAction ("Product", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK));
|
||||
f_bSearch.setName("ProductSearch");
|
||||
add (f_bSearch, buttonSize );
|
||||
|
||||
CLabel productLabel = new CLabel(Msg.translate(Env.getCtx(), "M_Product_ID"));
|
||||
add(productLabel, "split 2, spanx 4, flowy, h 15");
|
||||
add(productLabel, ", 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.setName("ProductInput");
|
||||
f_name.addActionListener(this);
|
||||
f_name.addFocusListener(this);
|
||||
f_name.requestFocusInWindow();
|
||||
|
||||
add (f_name, " growx, h 30:30:, wrap");
|
||||
add (f_name, "spanx 3, growx, pushx, h 25!");
|
||||
|
||||
// PAYMENT
|
||||
add (new CLabel(),"");
|
||||
f_cashPayment = createButtonAction("Payment", null);
|
||||
f_cashPayment.setActionCommand("Payment");
|
||||
add (f_cashPayment, "w 75!, h 50!, pushx, wrap");
|
||||
f_cashPayment.setEnabled(false);
|
||||
|
||||
m_table = new PosTable();
|
||||
CScrollPane scroll = new CScrollPane(m_table);
|
||||
|
@ -238,7 +249,6 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
p_posPanel.updateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Minus
|
||||
else if (action.equals("Minus"))
|
||||
|
@ -255,6 +265,9 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
}
|
||||
|
||||
}
|
||||
else if (action.equals("Payment"))
|
||||
payOrder();
|
||||
|
||||
// VNumber
|
||||
else if (e.getSource() == f_price) {
|
||||
MOrderLine line = new MOrderLine(p_ctx, orderLineId, null);
|
||||
|
@ -286,7 +299,7 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
|
||||
int row = m_table.getSelectedRow();
|
||||
if (row < 0) row = 0;
|
||||
m_table.getSelectionModel().setSelectionInterval(row, row);
|
||||
// m_table.getSelectionModel().setSelectionInterval(row, row); --red1 - use product window first will gives out of bound error
|
||||
// https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3121975&group_id=176962
|
||||
m_table.scrollRectToVisible(m_table.getCellRect(row, 1, true)); //@Trifon - BF[3121975]
|
||||
}
|
||||
|
@ -341,6 +354,30 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
}
|
||||
p_posPanel.updateInfo();
|
||||
} // actionPerformed
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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 ) //red1 wrong action flow below
|
||||
{
|
||||
if (!PosPayment.pay(p_posPanel) )
|
||||
return; //red1 not paid (cancelled) cannot continue process the order.
|
||||
|
||||
if (!p_posPanel.m_order.isProcessed() && !p_posPanel.m_order.processOrder() )
|
||||
{
|
||||
ADialog.warn(0, p_posPanel, "PosOrderProcessFailed");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
printTicket();
|
||||
p_posPanel.setOrder(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Table
|
||||
|
@ -483,7 +520,7 @@ public class SubCurrentLine extends PosSubPanel implements ActionListener, Focus
|
|||
|
||||
if ( p_posPanel.m_order == null )
|
||||
{
|
||||
p_posPanel.m_order = PosOrderModel.createOrder(p_posPanel.p_pos, p_posPanel.f_order.getBPartner());
|
||||
p_posPanel.m_order = PosOrderModel.createOrder(p_posPanel.p_pos, p_posPanel.f_order.getBPartner(),trxName);
|
||||
}
|
||||
|
||||
MOrderLine line = null;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package org.compiere.pos;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Event;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -34,7 +35,6 @@ import net.miginfocom.swing.MigLayout;
|
|||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MBPartnerInfo;
|
||||
import org.compiere.model.MBPartnerLocation;
|
||||
|
@ -43,8 +43,6 @@ 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.swing.CButton;
|
||||
import org.compiere.swing.CComboBox;
|
||||
import org.compiere.swing.CLabel;
|
||||
|
@ -70,7 +68,7 @@ public class SubOrder extends PosSubPanel
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5895558315889871887L;
|
||||
private static final long serialVersionUID = -2985454173868605178L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -82,12 +80,11 @@ public class SubOrder extends PosSubPanel
|
|||
} // PosSubCustomer
|
||||
|
||||
private CButton f_history;
|
||||
private CTextField f_name;
|
||||
private PosTextField 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;
|
||||
|
@ -95,7 +92,6 @@ public class SubOrder extends PosSubPanel
|
|||
private JFormattedTextField f_net;
|
||||
private JFormattedTextField f_tax;
|
||||
private JFormattedTextField f_total;
|
||||
private CTextField f_RepName;
|
||||
|
||||
/** The Business Partner */
|
||||
private MBPartner m_bpartner;
|
||||
|
@ -116,33 +112,28 @@ public class SubOrder extends PosSubPanel
|
|||
MigLayout layout = new MigLayout("ins 0 0","[fill|fill|fill|fill]","[nogrid]unrel[||]");
|
||||
setLayout(layout);
|
||||
|
||||
Font bigFont = AdempierePLAF.getFont_Field().deriveFont(16f);
|
||||
Font bigFont = AdempierePLAF.getFont_Field().deriveFont(20f);
|
||||
|
||||
String buttonSize = "w 50!, h 50!,";
|
||||
// NEW
|
||||
f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2));
|
||||
add (f_bNew, buttonSize);
|
||||
|
||||
// EDIT
|
||||
|
||||
// HISTORY
|
||||
f_history = createButtonAction("History", null);
|
||||
add (f_history, 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);
|
||||
f_process = createButtonAction("Delete", 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);
|
||||
|
@ -156,44 +147,36 @@ public class SubOrder extends PosSubPanel
|
|||
f_logout = createButtonAction ("Logout", null);
|
||||
add (f_logout, buttonSize + ", gapx 25, wrap");
|
||||
|
||||
// DOC NO
|
||||
// SALES REP
|
||||
add(new CLabel(Msg.translate(Env.getCtx(), "Cashier")), "");
|
||||
CLabel cashiername = new CLabel((p_ctx.getProperty("#AD_User_Name")).toUpperCase());
|
||||
cashiername.setFont(bigFont);
|
||||
cashiername.setFontBold(true);
|
||||
cashiername.setForeground(Color.RED);
|
||||
add (cashiername, "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");
|
||||
|
||||
// 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);
|
||||
|
@ -212,22 +195,25 @@ public class SubOrder extends PosSubPanel
|
|||
*/
|
||||
|
||||
// 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");
|
||||
add(new CLabel(Msg.translate(Env.getCtx(), "Customer")), "");
|
||||
f_name =new PosTextField(Msg.translate(Env.getCtx(), "C_Partner_ID"), p_posPanel, p_pos.getOSK_KeyLayout_ID());
|
||||
f_name.setEditable(true); //red1
|
||||
f_name.setName("BPartner");
|
||||
f_name.addActionListener(this);
|
||||
f_name.addFocusListener(this);
|
||||
add (f_name, " flowy, pushx, h 20!");
|
||||
|
||||
//
|
||||
CLabel lTotal = new CLabel (Msg.translate(Env.getCtx(), "GrandTotal"));
|
||||
CLabel lTotal = new CLabel (Msg.translate(Env.getCtx(), "TOTAL"));
|
||||
lTotal.setFont(bigFont);
|
||||
add(lTotal, "");
|
||||
f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
|
||||
f_total.setHorizontalAlignment(JTextField.TRAILING);f_total.setFont(bigFont);
|
||||
f_total.setHorizontalAlignment(JTextField.TRAILING);f_total.setFont(bigFont);f_total.setForeground(Color.BLUE);
|
||||
f_total.setEditable(false);
|
||||
f_total.setFocusable(false);
|
||||
f_total.setName("GrandTotal");
|
||||
lTotal.setLabelFor(f_total);
|
||||
add(f_total, "growx, pushx");
|
||||
add(f_total, "spanx 3, growx, pushx");
|
||||
f_total.setValue (Env.ZERO);
|
||||
/*
|
||||
//
|
||||
|
@ -272,10 +258,18 @@ public class SubOrder extends PosSubPanel
|
|||
qt.setVisible(true);
|
||||
return;
|
||||
}
|
||||
else if (action.equals("Cancel"))
|
||||
deleteOrder();
|
||||
else if (action.equals("Cash"))
|
||||
payOrder();
|
||||
else if (action.equals("Delete")) //red1 more apt description
|
||||
{
|
||||
deleteOrder();
|
||||
p_posPanel.m_order = null;
|
||||
p_posPanel.f_curLine.newLine();
|
||||
p_posPanel.f_curLine.f_name.requestFocusInWindow();
|
||||
}
|
||||
else if (action.equals("Preference"))
|
||||
{
|
||||
CashSubFunctions csf = new CashSubFunctions(p_posPanel);
|
||||
csf.setVisible(true);
|
||||
}
|
||||
else if (action.equals("Print"))
|
||||
printOrder();
|
||||
else if (action.equals("BPartner"))
|
||||
|
@ -310,28 +304,7 @@ public class SubOrder extends PosSubPanel
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -577,41 +550,7 @@ public class SubOrder extends PosSubPanel
|
|||
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
|
||||
|
@ -656,7 +595,6 @@ public class SubOrder extends PosSubPanel
|
|||
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);
|
||||
|
@ -667,7 +605,6 @@ public class SubOrder extends PosSubPanel
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue