svn commit: r482591 - in /incubator/ofbiz/trunk/specialpurpose/pos: config/ screens/default/dialog/ src/org/ofbiz/pos/ src/org/ofbiz/pos/event/ src/org/ofbiz/pos/screen/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r482591 - in /incubator/ofbiz/trunk/specialpurpose/pos: config/ screens/default/dialog/ src/org/ofbiz/pos/ src/org/ofbiz/pos/event/ src/org/ofbiz/pos/screen/

jleroux@apache.org
Author: jleroux
Date: Tue Dec  5 03:04:17 2006
New Revision: 482591

URL: http://svn.apache.org/viewvc?view=rev&rev=482591
Log:
Replace previous version of Paid In/Out. This version uses a dialog box with an editable ComboBox for reason.
Some miscelaneous refactoring.
I also desesperatly tried to set the focus on Save Sale field (with the aim to generalize in other dialog boxes) but did not succeed even with the help of XUI guys. Nevertheless I kept commented my changes for a future try.
BTW I noticed that BigDecimal is not used in POS at all. I will soon create a Jira issue for this.

Modified:
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/pos.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties
    incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/SelectProduct.xml
    incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/savesale.xml
    incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
    incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/ManagerEvents.java
    incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java
    incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties Tue Dec  5 03:04:17 2006
@@ -84,3 +84,5 @@
 problems_reading_card=PROBLEMS READING SWIPED CARD
 product_not_found=PRODUCT NOT FOUND
 promo_page=This will be the promo page!
+AmountInOut=Amount
+ReasonInOut=Reason
\ No newline at end of file

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties Tue Dec  5 03:04:17 2006
@@ -85,3 +85,5 @@
 problems_reading_card=Probl\u00E8me lors de la lecture de la carte
 product_not_found=Produit inconnu !
 promo_page=Ce sera la page des promotions...
+AmountInOut=Montant
+ReasonInOut=Raison
\ No newline at end of file

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/pos.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/pos.properties?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/pos.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/pos.properties Tue Dec  5 03:04:17 2006
@@ -27,7 +27,7 @@
 CREDNO=Enter Card Number:
 CREDZP=Enter Billing ZipCode:
 DATE=DATE
-DRWR=Till
+DRWR=TILL
 DateFormat=EEE MMM dd
 DateTimeFormat='the' yyyy MMMMM dd 'at'  hh:mm:ss aaa
 EMPL=EMPL
@@ -36,10 +36,6 @@
 ENTCRC=Enter Credit Card Amount:
 ENTGFC=Enter Gift Card Amount:
 ENTOTH=Enter Other Payment Amount:
-ENT_COMM_IN=Enter reason of put in:
-ENT_COMM_OUT=Enter reason of this withdraw:
-ENT_IN=Enter amount to paid in:
-ENT_OUT=Enter amount to withdraw:
 GIFT_CARD=GIFT CARD
 GROSS_SALES=GROSS SALES
 Grand_Total=Grand Total
@@ -75,3 +71,6 @@
 draw=Dr:
 term=Term:
 total_report=TOTALS REPORT
+CreateOrChooseReasonInOut=You have to create or choose a reason
+PaidInTitle=Enter amount to paid in and create or choose a reason
+PaidOutTitle=Enter amount to withdraw and create or choose a reason
\ No newline at end of file

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/pos_fr.properties Tue Dec  5 03:04:17 2006
@@ -27,7 +27,7 @@
 CREDNO=Entrez le n\u00B0 de la carte :
 CREDZP=Entrez le code postal de facturation :
 DATE=Date
-DRWR=Tiroir
+DRWR=Caisse
 DateFormat=EE dd MMM
 DateTimeFormat='le' dd MMMMM yyyy '\u00E0'  HH:mm:ss
 EMPL=Vendeur
@@ -36,10 +36,6 @@
 ENTCRC=Entrez le montant en carte de cr\u00E9dit :
 ENTGFC=Entrez le montant en bon d'achat :
 ENTOTH=Entrez le mt en autre moyen de paiement :
-ENT_IN=Entrez le montant \u00E0 remettre en caisse :
-ENT_COMM_IN=Entrez la raison de cette entr\u00E9e :
-ENT_OUT=Entrez le montant \u00E0 retirer :
-ENT_COMM_OUT=Entrez la raison de ce retrait :
 GIFT_CARD=Bon(s) d'achat
 GROSS_SALES=Total
 Grand_Total=Total
@@ -51,6 +47,7 @@
 LoadSaleListDblClickTip=Vous pouvez utiliser le double clic pour remplacer la vente en cours et supprimer celle ci
 OPDRAM=Contenu initial du tiroir :
 OTHER=Autres
+PaidInOut=Entrez le montant et créer ou choisissez une raison pour ce mouvement de caisse
 PAYFIN=Appuyez sur [Fin] pour terminer la vente !
 Processing=Traitement du paiement...
 QTY=Nb
@@ -75,3 +72,6 @@
 draw=Tiroir :
 term=Terminal :
 total_report=TOTAUX
+CreateOrChooseReasonInOut=Vous devez créer ou choisir une raison pour ce mouvement de caisse
+PaidInTitle=Entrez le montant \u00E0 remettre en caisse et créer ou choisissez une raison
+PaidOutTitle=Entrez le montant \u00E0 retirer et créer ou choisissez une raison
\ No newline at end of file

Modified: incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/SelectProduct.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/SelectProduct.xml?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/SelectProduct.xml (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/SelectProduct.xml Tue Dec  5 03:04:17 2006
@@ -17,7 +17,7 @@
 -->
 <XPage class="net.xoetrope.swing.XDialog">
     <Components>
-        <Panel name="salesPanel" x="0" y="0" w="680" h="420" style="menu">
+        <Panel name="SelectProduct" x="0" y="0" w="680" h="420" style="menu">
             <ScrollPane name="scroolList" x="20" y="20" w="400" h="372">
                 <List name="productsList" x="0" y="0" w="400" h="400" style="editAndList"/>
             </ScrollPane>

Modified: incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/savesale.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/savesale.xml?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/savesale.xml (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/savesale.xml Tue Dec  5 03:04:17 2006
@@ -15,7 +15,8 @@
     License for the specific language governing permissions and limitations
     under the License.
 -->
-<XPage class="net.xoetrope.swing.XDialog">
+<!--XPage class="org.ofbiz.pos.screen.XFocusDialog"-->
+<XPage class="net.xoetrope.swing.XDialog">    
     <Components>
         <Panel name="salePanel" x="0" y="0" w="680" h="320" style="menu">
             <Edit name="saleName"  x="20" y="20" w="400" h="44" style="editAndList"/>

Modified: incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Tue Dec  5 03:04:17 2006
@@ -54,6 +54,7 @@
 import org.ofbiz.pos.screen.LoadSale;
 import org.ofbiz.pos.screen.PosScreen;
 import org.ofbiz.pos.screen.SaveSale;
+import org.ofbiz.pos.screen.PaidInOut;
 import org.ofbiz.product.store.ProductStoreWorker;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;

Modified: incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/ManagerEvents.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/ManagerEvents.java?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/ManagerEvents.java (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/ManagerEvents.java Tue Dec  5 03:04:17 2006
@@ -34,6 +34,8 @@
 import org.ofbiz.pos.device.DeviceLoader;
 import org.ofbiz.pos.device.impl.Receipt;
 import org.ofbiz.pos.screen.PosScreen;
+import org.ofbiz.pos.screen.PaidInOut;
+import org.ofbiz.pos.screen.SaveSale;
 import org.ofbiz.pos.PosTransaction;
 import org.ofbiz.pos.adaptor.SyncCallbackAdaptor;
 import org.ofbiz.pos.component.Input;
@@ -416,61 +418,42 @@
             pos.showDialog("dialog/error/terminalclosed");
             return;
         }
-        Output output = pos.getOutput();
-        Input input = pos.getInput();
-        if (input.isFunctionSet("PAID_" + type)) {
-            String[] func = input.getFunction("PAID_" + type);
-            String lastValue = input.value();
-            if (UtilValidate.isNotEmpty(lastValue)) {
-                String[] paidInfo = new String[0];
-                switch (func[1].split("\\|").length) {
-                    case 1:
-                        try {
-                            double dbl = Double.parseDouble(lastValue);
-                            dbl = dbl / 100;
-                            lastValue = UtilFormatOut.formatPrice(dbl);
-                        } catch (NumberFormatException e) {
-                            Debug.logError(e, module);
-                        }
-                        func[1] = func[1] + "|";
-                        func[1] = func[1] + lastValue;
-                        input.setFunction("PAID_" + type, func[1]);
-                        output.print(UtilProperties.getMessage("pos","ENT_COMM_" + type, Locale.getDefault()));
-                        break;                        
-                    case 2:
-                        func[1] = func[1] + "|";
-                        func[1] = func[1] + lastValue;
-                        paidInfo = func[1].split("\\|");            
-                        GenericValue internTx = pos.getSession().getDelegator().makeValue("PosTerminalInternTx", null);
-                        internTx.set("posTerminalLogId", trans.getTerminalLogId());                        
-                        try
-                        {
-                            internTx.set("paidAmount", new Double(priceDecimalFormat.parse(paidInfo[1]).doubleValue()));
-                        }
-                        catch (ParseException pe)
-                        {
-                            Debug.logError(pe, module);
-                        }
-                        internTx.set("reasonComment", paidInfo[2]);
-                        try {
-                            internTx.create();
-                        } catch (GenericEntityException e) {
-                            Debug.logError(e, module);
-                            pos.showDialog("dialog/error/exception", e.getMessage());
-                        }                        
-                        //save the TX Log
-                        trans.paidInOut(type);              
-                        NavagationEvents.showPosScreen(pos);                        
-                        break;
-                }
+        
+        PaidInOut PaidInOut = new PaidInOut(trans, pos, type);
+        Map mapInOut = PaidInOut.openDlg();
+        if (null != mapInOut.get("amount")) {
+            String amount = (String) mapInOut.get("amount");
+            try {
+                double dbl = Double.parseDouble(amount);
+            } catch (NumberFormatException e) {
+                Debug.logError(e, module);
+                return;
             }
-        } else {
-            trans.popDrawer();
-            input.clear();
-            input.setFunction("PAID_" + type);
-            output.print(UtilProperties.getMessage("pos","ENT_" + type, Locale.getDefault()));
-        }
-    }    
+
+            GenericValue internTx = pos.getSession().getDelegator().makeValue("PosTerminalInternTx", null);
+            internTx.set("posTerminalLogId", trans.getTerminalLogId());                        
+            try
+            {
+                internTx.set("paidAmount", new Double(priceDecimalFormat.parse(amount).doubleValue() / 100));
+            }
+            catch (ParseException pe)
+            {
+                Debug.logError(pe, module);
+                return;
+            }
+            internTx.set("reasonComment", mapInOut.get("reason"));
+            try {
+                internTx.create();
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);
+                pos.showDialog("dialog/error/exception", e.getMessage());
+                return;
+            }                        
+            //save the TX Log
+            trans.paidInOut(type);              
+            NavagationEvents.showPosScreen(pos);                                    
+        }    
+    }
     
     private static void printTotals(PosScreen pos, GenericValue state, boolean runBalance) {
         PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());

Modified: incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java Tue Dec  5 03:04:17 2006
@@ -60,18 +60,16 @@
     }
 
     public void openDlg() {
-        XDialog dlg = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/loadsale");
-        m_dialog = dlg;
-        dlg.setCaption(UtilProperties.getMessage("pos", "LoadASale", Locale.getDefault()));
-        //dlg.setModal(true);
-        m_salesList = (XList) dlg.findComponent("salesList");
-        addMouseHandler(m_salesList, "SaleDoubleClick");
+        m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/loadsale");
+        m_dialog.setCaption(UtilProperties.getMessage("pos", "LoadASale", Locale.getDefault()));
+        m_salesList = (XList) m_dialog.findComponent("salesList");
+        addMouseHandler(m_salesList, "saleDoubleClick");
 
-        m_cancel = (XButton) dlg.findComponent("BtnCancel");
-        m_add = (XButton) dlg.findComponent("BtnAdd");
-        m_replace = (XButton) dlg.findComponent("BtnReplace");
-        m_delete = (XButton) dlg.findComponent("BtnDelete");
-        m_replaceAndDelete = (XButton) dlg.findComponent("BtnReplaceAndDelete");
+        m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
+        m_add = (XButton) m_dialog.findComponent("BtnAdd");
+        m_replace = (XButton) m_dialog.findComponent("BtnReplace");
+        m_delete = (XButton) m_dialog.findComponent("BtnDelete");
+        m_replaceAndDelete = (XButton) m_dialog.findComponent("BtnReplaceAndDelete");
         addMouseHandler(m_cancel, "cancel");
         addMouseHandler(m_add, "addSale");
         addMouseHandler(m_replace, "replaceSale");
@@ -91,11 +89,12 @@
         m_salesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
         m_salesList.setToolTipText(UtilProperties.getMessage("pos", "LoadSaleListDblClickTip", Locale.getDefault()));
 
-        dlg.pack();
-        dlg.showDialog(this);
+        m_dialog.pack();
+        m_salesList.requestFocusInWindow();
+        m_dialog.showDialog(this);
     }
 
-    public synchronized void SaleDoubleClick() {
+    public synchronized void saleDoubleClick() {
         if (wasMouseDoubleClicked()) {
             String sale = selectedSale();
             if (null != sale) {

Modified: incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java?view=diff&rev=482591&r1=482590&r2=482591
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java Tue Dec  5 03:04:17 2006
@@ -20,8 +20,9 @@
 import java.util.Locale;
 
 import net.xoetrope.swing.XButton;
-import net.xoetrope.swing.XDialog;
+//import org.ofbiz.pos.screen.XFocusDialog;
 import net.xoetrope.swing.XEdit;
+import net.xoetrope.swing.XDialog;
 import net.xoetrope.xui.XPage;
 
 import org.ofbiz.base.util.Debug;
@@ -52,23 +53,22 @@
     }
 
     public void openDlg() {
-        XDialog dlg = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/savesale");
-        m_dialog = dlg;
-        dlg.setModal(true);
-        dlg.setCaption(UtilProperties.getMessage("pos", "SaveASale", Locale.getDefault()));
-        m_saleName = (XEdit) dlg.findComponent("saleName");
+        m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/savesale");
+        m_saleName = (XEdit) m_dialog.findComponent("saleName");        
+        //m_dialog.setM_focused(m_saleName);
         m_saleName.setText(m_pos.session.getUserId() + " " + sdf.format(new Date()));
+        m_dialog.setCaption(UtilProperties.getMessage("pos", "SaveASale", Locale.getDefault()));
 
-        m_cancel = (XButton) dlg.findComponent("BtnCancel");
-        m_save = (XButton) dlg.findComponent("BtnSave");
-        m_saveAndClear = (XButton) dlg.findComponent("BtnSaveAndClear");
+        m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
+        m_save = (XButton) m_dialog.findComponent("BtnSave");
+        m_saveAndClear = (XButton) m_dialog.findComponent("BtnSaveAndClear");
 
         addMouseHandler(m_cancel, "cancel");
         addMouseHandler(m_save, "save");
         addMouseHandler(m_saveAndClear, "saveAndClear");
 
-        dlg.pack();
-        dlg.showDialog(this);
+        m_dialog.pack();
+        m_dialog.showDialog(this);
     }
 
     public synchronized void cancel()