related to issue 20931: expense sheet is created with line net amount 0
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 30 Aug 2012 10:04:37 +0200
changeset 17811 1549d7119a63
parent 17810 78585c145c1f
child 17812 2b882d173e1f
related to issue 20931: expense sheet is created with line net amount 0
src-db/database/sourcedata/AD_AUXILIARINPUT.xml
src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java
--- a/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Wed Aug 29 12:04:22 2012 +0200
+++ b/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Thu Aug 30 10:04:37 2012 +0200
@@ -1109,6 +1109,17 @@
 <!--42599C834F074611AF7AF4B638D73342-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--42599C834F074611AF7AF4B638D73342--></AD_AUXILIARINPUT>
 
+<!--47F42EA77ACD4026AF7F41C2D90146C4--><AD_AUXILIARINPUT>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <AD_AUXILIARINPUT_ID><![CDATA[47F42EA77ACD4026AF7F41C2D90146C4]]></AD_AUXILIARINPUT_ID>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <AD_TAB_ID><![CDATA[413]]></AD_TAB_ID>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <NAME><![CDATA[lastNetUnitPrice]]></NAME>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <CODE><![CDATA[N]]></CODE>
+<!--47F42EA77ACD4026AF7F41C2D90146C4-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--47F42EA77ACD4026AF7F41C2D90146C4--></AD_AUXILIARINPUT>
+
 <!--485726718FCD47AFB101C59FC1BD365E--><AD_AUXILIARINPUT>
 <!--485726718FCD47AFB101C59FC1BD365E-->  <AD_AUXILIARINPUT_ID><![CDATA[485726718FCD47AFB101C59FC1BD365E]]></AD_AUXILIARINPUT_ID>
 <!--485726718FCD47AFB101C59FC1BD365E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java	Wed Aug 29 12:04:22 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java	Thu Aug 30 10:04:37 2012 +0200
@@ -54,10 +54,15 @@
       String strChanged = vars.getStringParameter("inpLastFieldChanged");
       String strTabId = vars.getStringParameter("inpTabId");
       String strInvPrice = vars.getNumericParameter("inpinvoiceprice");
+      String strWindowId = vars.getStringParameter("inpwindowId");
+      String strlastNetUnitPrice = vars.getSessionValue(strWindowId + "|lastNetUnitPrice");
 
+      if (strlastNetUnitPrice.equals("N")) {
+        strlastNetUnitPrice = strInvPrice;
+      }
       try {
         printPage(response, vars, strDateexpense, strmProductId, strsTimeexpenseId, strqty,
-            strcCurrencyId, strInvPrice, strChanged, strTabId);
+            strcCurrencyId, strInvPrice, strChanged, strTabId, strWindowId, strlastNetUnitPrice);
       } catch (ServletException ex) {
         pageErrorCallOut(response);
       }
@@ -67,8 +72,8 @@
 
   private void printPage(HttpServletResponse response, VariablesSecureApp vars,
       String strDateexpense, String strmProductId, String strsTimeexpenseId, String strqty,
-      String strcCurrencyId, String strInvPrice, String strChanged, String strTabId)
-      throws IOException, ServletException {
+      String strcCurrencyId, String strInvPrice, String strChanged, String strTabId,
+      String strWindowId, String strlastNetUnitPrice) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
@@ -88,7 +93,8 @@
           .today(this) : SEExpenseProductData.selectReportDate(this, strsTimeexpenseId);
     }
 
-    if (strInvPrice.equals("")) {
+    if (strInvPrice.equals("")
+        || (strChanged.equals("inpmProductId") && strInvPrice.equals(strlastNetUnitPrice))) {
       for (int i = 0; data != null && i < data.length && noPrice; i++) {
         if (data[i].validfrom == null || data[i].validfrom.equals("")
             || !DateTimeData.compare(this, strDateexpense, data[i].validfrom).equals("-1")) {
@@ -120,6 +126,7 @@
           }
         }
       }
+      vars.setSessionValue(strWindowId + "|lastNetUnitPrice", priceActual);
     } else {
       priceActual = strInvPrice;
     }