details:   /erp/devel/pi/rev/709920f14732
changeset: 11810:709920f14732
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Fri Apr 29 12:38:54 2011 +0200
summary:   Reverted back Import Orders (POS sync)

details:   /erp/devel/pi/rev/34a5bf415f29
changeset: 11811:34a5bf415f29
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Fri Apr 29 12:44:06 2011 +0200
summary:   Merge from PI

diffstat:

 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
                     |    30 +-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
                 |    35 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/example/JSExecuteCalloutExample.java
    |    40 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |    27 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                      |     6 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                      |    21 +-
 referencedata/sampledata/F_B_International_Group.xml                           
                                       |   444 +-
 referencedata/sampledata/QA_Testing.xml                                        
                                       |    67 +-
 src-db/database/model/functions/C_INVOICE_POST.xml                             
                                       |     4 +-
 src-db/database/model/functions/C_ORDER_POST1.xml                              
                                       |     4 +-
 src-db/database/model/tables/I_BPARTNER.xml                                    
                                       |   214 +
 src-db/database/model/triggers/C_ELEMENTVALUE_TRG.xml                          
                                       |    18 +-
 src-db/database/model/triggers/M_WAREHOUSE_TRG.xml                             
                                       |     3 +-
 src-db/database/sourcedata/AD_COLUMN.xml                                       
                                       |  1497 +++++++++
 src-db/database/sourcedata/AD_FIELD.xml                                        
                                       |  1658 ++++++++++
 src-db/database/sourcedata/AD_MENU.xml                                         
                                       |    13 +
 src-db/database/sourcedata/AD_MESSAGE.xml                                      
                                       |    11 +
 src-db/database/sourcedata/AD_MODEL_OBJECT.xml                                 
                                       |    12 +
 src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml                         
                                       |    10 +
 src-db/database/sourcedata/AD_PROCESS.xml                                      
                                       |    21 +
 src-db/database/sourcedata/AD_PROCESS_PARA.xml                                 
                                       |    81 +
 src-db/database/sourcedata/AD_TAB.xml                                          
                                       |    24 +
 src-db/database/sourcedata/AD_TABLE.xml                                        
                                       |    20 +
 src-db/database/sourcedata/AD_TREENODE.xml                                     
                                       |    11 +
 src-db/database/sourcedata/AD_WINDOW.xml                                       
                                       |    16 +
 src/org/openbravo/erpCommon/ad_process/BPartnerLocation_data.xsql              
                                       |    55 +
 src/org/openbravo/erpCommon/ad_process/BPartner_data.xsql                      
                                       |    59 +
 src/org/openbravo/erpCommon/ad_process/COrderLine_data.xsql                    
                                       |    83 +
 src/org/openbravo/erpCommon/ad_process/COrder_data.xsql                        
                                       |   109 +
 src/org/openbravo/erpCommon/ad_process/ImportOrder.java                        
                                       |   943 +++++
 src/org/openbravo/erpCommon/ad_process/ImportOrderServlet.html                 
                                       |   199 +
 src/org/openbravo/erpCommon/ad_process/ImportOrderServlet.java                 
                                       |   119 +
 src/org/openbravo/erpCommon/ad_process/ImportOrderServlet.xml                  
                                       |    36 +
 src/org/openbravo/erpCommon/ad_process/ImportOrderServlet_data.xsql            
                                       |    34 +
 src/org/openbravo/erpCommon/ad_process/ImportOrder_data.xsql                   
                                       |  1606 +++++++++
 src/org/openbravo/erpCommon/ad_process/ImportProcess.java                      
                                       |   235 +
 src/org/openbravo/erpCommon/ad_process/ImportProcess_data.xsql                 
                                       |   137 +
 src/org/openbravo/erpCommon/ad_process/Import_data.xsql                        
                                       |    36 +
 src/org/openbravo/erpCommon/ad_process/Location_data.xsql                      
                                       |    60 +
 src/org/openbravo/erpCommon/ad_process/ProductPrice_data.xsql                  
                                       |   101 +
 src/org/openbravo/erpCommon/ad_process/User_data.xsql                          
                                       |    57 +
 
src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJRFilter.html
                          |     2 +-
 
src/org/openbravo/erpCommon/ad_reports/ReportInvoiceVendorDimensionalAnalysesFilterJR.html
                            |     2 +-
 
src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesFilterJR.html
                                 |     2 +-
 
src/org/openbravo/erpCommon/ad_reports/ReportPurchaseDimensionalAnalysesFilterJR.html
                                 |     2 +-
 
src/org/openbravo/erpCommon/ad_reports/ReportRefundSalesDimensionalAnalysesFilter.html
                                |     2 +-
 
src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJRFilter.html
                                     |     2 +-
 
src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJRFilter.html
                                  |     2 +-
 48 files changed, 7836 insertions(+), 334 deletions(-)

diffs (truncated from 9021 to 300 lines):

diff -r b2b6acc6f87b -r 34a5bf415f29 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
 Thu Apr 28 18:08:25 2011 +0200
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
 Fri Apr 29 12:44:06 2011 +0200
@@ -589,29 +589,17 @@
    */
   public static void updatePaymentScheduleAmounts(FIN_PaymentSchedule 
paymentSchedule,
       BigDecimal amount, BigDecimal writeOffAmount) {
-    BigDecimal totalPaid = amount;
-    BigDecimal outstanding = paymentSchedule.getOutstandingAmount();
+    paymentSchedule.setPaidAmount(paymentSchedule.getPaidAmount().add(amount));
+    
paymentSchedule.setOutstandingAmount(paymentSchedule.getOutstandingAmount().subtract(amount));
     if (writeOffAmount != null && writeOffAmount.compareTo(BigDecimal.ZERO) != 
0) {
-      totalPaid = amount.add(writeOffAmount);
+      
paymentSchedule.setPaidAmount(paymentSchedule.getPaidAmount().add(writeOffAmount));
+      
paymentSchedule.setOutstandingAmount(paymentSchedule.getOutstandingAmount().subtract(
+          writeOffAmount));
     }
-    // (totalPaid > 0 && totalPaid <= outstanding) || (totalPaid < 0 && 
totalPaid >= outstanding)
-    if ((totalPaid.compareTo(BigDecimal.ZERO) == 1 && 
totalPaid.compareTo(outstanding) <= 0)
-        || (totalPaid.compareTo(BigDecimal.ZERO) == -1 && 
totalPaid.compareTo(outstanding) >= 0)) {
-      
paymentSchedule.setPaidAmount(paymentSchedule.getPaidAmount().add(amount));
-      
paymentSchedule.setOutstandingAmount(paymentSchedule.getOutstandingAmount().subtract(amount));
-      if (writeOffAmount != null && writeOffAmount.compareTo(BigDecimal.ZERO) 
!= 0) {
-        
paymentSchedule.setPaidAmount(paymentSchedule.getPaidAmount().add(writeOffAmount));
-        
paymentSchedule.setOutstandingAmount(paymentSchedule.getOutstandingAmount().subtract(
-            writeOffAmount));
-      }
-      OBDal.getInstance().save(paymentSchedule);
-      if (paymentSchedule.getInvoice() != null) {
-        updateInvoicePaymentMonitor(paymentSchedule.getInvoice(), 
paymentSchedule.getDueDate(),
-            amount, writeOffAmount);
-      }
-    } else {
-      throw new 
OBException(String.format(FIN_Utility.messageBD("APRM_AmountOutOfRange"), 
totalPaid
-          .toString(), paymentSchedule.getOutstandingAmount().toString()));
+    OBDal.getInstance().save(paymentSchedule);
+    if (paymentSchedule.getInvoice() != null) {
+      updateInvoicePaymentMonitor(paymentSchedule.getInvoice(), 
paymentSchedule.getDueDate(),
+          amount, writeOffAmount);
     }
   }
 
diff -r b2b6acc6f87b -r 34a5bf415f29 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
     Thu Apr 28 18:08:25 2011 +0200
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
     Fri Apr 29 12:44:06 2011 +0200
@@ -29,6 +29,7 @@
 import org.openbravo.advpaymentmngt.dao.TransactionsDao;
 import org.openbravo.advpaymentmngt.exception.NoExecutionProcessFoundException;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
@@ -114,6 +115,8 @@
               if (paymentScheduleDetail.getInvoicePaymentSchedule() != null) {
                 
invoiceDocNos.add(paymentScheduleDetail.getInvoicePaymentSchedule().getInvoice()
                     .getDocumentNo());
+                
validateAmount(paymentScheduleDetail.getInvoicePaymentSchedule(), paymentDetail
+                    .getAmount(), paymentDetail.getWriteoffAmount());
                 
FIN_AddPayment.updatePaymentScheduleAmounts(paymentScheduleDetail
                     .getInvoicePaymentSchedule(), paymentDetail.getAmount(), 
paymentDetail
                     .getWriteoffAmount());
@@ -123,6 +126,8 @@
               if (paymentScheduleDetail.getOrderPaymentSchedule() != null) {
                 
orderDocNos.add(paymentScheduleDetail.getOrderPaymentSchedule().getOrder()
                     .getDocumentNo());
+                
validateAmount(paymentScheduleDetail.getOrderPaymentSchedule(), paymentDetail
+                    .getAmount(), paymentDetail.getWriteoffAmount());
                 
FIN_AddPayment.updatePaymentScheduleAmounts(paymentScheduleDetail
                     .getOrderPaymentSchedule(), paymentDetail.getAmount(), 
paymentDetail
                     .getWriteoffAmount());
@@ -430,4 +435,34 @@
       }
     }
   }
+
+  /**
+   * Checks if the amount to pay/receive fits with the outstanding amount in 
the invoice or order.
+   * 
+   * @param paymentSchedule
+   *          Payment plan of the order or invoice where the outstanding 
amount is specified.
+   * @param amount
+   *          Amount to by paid or received.
+   * @param writeOffAmount
+   *          Write off amount.
+   * @return True if the amount is valid.
+   * @throws OBException
+   *           Exception explaining why the amount is not valid.
+   */
+  private boolean validateAmount(FIN_PaymentSchedule paymentSchedule, 
BigDecimal amount,
+      BigDecimal writeOffAmount) throws OBException {
+    BigDecimal totalPaid = amount;
+    BigDecimal outstanding = paymentSchedule.getOutstandingAmount();
+    if (writeOffAmount != null && writeOffAmount.compareTo(BigDecimal.ZERO) != 
0) {
+      totalPaid = amount.add(writeOffAmount);
+    }
+    // (totalPaid > 0 && totalPaid <= outstanding) || (totalPaid < 0 && 
totalPaid >= outstanding)
+    if ((totalPaid.compareTo(BigDecimal.ZERO) == 1 && 
totalPaid.compareTo(outstanding) <= 0)
+        || (totalPaid.compareTo(BigDecimal.ZERO) == -1 && 
totalPaid.compareTo(outstanding) >= 0)) {
+      return true;
+    } else {
+      throw new 
OBException(String.format(FIN_Utility.messageBD("APRM_AmountOutOfRange"), 
totalPaid
+          .toString(), paymentSchedule.getOutstandingAmount().toString()));
+    }
+  }
 }
diff -r b2b6acc6f87b -r 34a5bf415f29 
modules/org.openbravo.client.application/src/org/openbravo/client/application/example/JSExecuteCalloutExample.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/example/JSExecuteCalloutExample.java
        Fri Apr 29 12:44:06 2011 +0200
@@ -0,0 +1,40 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.client.application.example;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.erpCommon.ad_callouts.SimpleCallout;
+
+/**
+ * 
+ * @author iperdomo
+ */
+public class JSExecuteCalloutExample extends SimpleCallout {
+
+  private static final long serialVersionUID = 1L;
+  private static final String JSEXECUTE = "JSEXECUTE";
+
+  @Override
+  protected void execute(CalloutInfo info) throws ServletException {
+    // info.addResult(JSEXECUTE, "debugger;isc.say('hello world');");
+    info.addResult(JSEXECUTE, "isc.say('hello world');");
+  }
+
+}
diff -r b2b6acc6f87b -r 34a5bf415f29 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Thu Apr 28 18:08:25 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Fri Apr 29 12:44:06 2011 +0200
@@ -123,6 +123,7 @@
       List<String> changeEventCols = new ArrayList<String>();
       Map<String, List<String>> columnsInValidation = new HashMap<String, 
List<String>>();
       List<String> calloutMessages = new ArrayList<String>();
+      List<String> jsExcuteCode = new ArrayList<String>();
 
       log.debug("Form Initialization Component Execution. Tab Name: " + 
tab.getWindow().getName()
           + "." + tab.getName() + " Tab Id:" + tab.getId());
@@ -201,7 +202,7 @@
       // Execution of callouts
       long t6 = System.currentTimeMillis();
       List<String> changedCols = executeCallouts(mode, tab, columnValues, 
changedColumn,
-          calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols);
+          calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols, 
jsExcuteCode);
 
       if (changedCols.size() > 0) {
         RequestContext.get().setRequestParameter("donotaddcurrentelement", 
"true");
@@ -216,7 +217,7 @@
       // Construction of the final JSONObject
       long t7 = System.currentTimeMillis();
       JSONObject finalObject = buildJSONObject(mode, tab, columnValues, row, 
changeEventCols,
-          calloutMessages);
+          calloutMessages, jsExcuteCode);
       long t8 = System.currentTimeMillis();
       log.debug("Elapsed time: " + (System.currentTimeMillis() - iniTime) + 
"(" + (t2 - t1) + ","
           + (t3 - t2) + "," + (t4 - t3) + "," + (t5 - t4) + "," + (t6 - t5) + 
"," + (t7 - t6) + ","
@@ -237,7 +238,8 @@
   }
 
   private JSONObject buildJSONObject(String mode, Tab tab, Map<String, 
JSONObject> columnValues,
-      BaseOBObject row, List<String> changeEventCols, List<String> 
calloutMessages) {
+      BaseOBObject row, List<String> changeEventCols, List<String> 
calloutMessages,
+      List<String> jsExcuteCode) {
     JSONObject finalObject = new JSONObject();
     try {
       if (mode.equals("NEW") || mode.equals("CHANGE")) {
@@ -325,7 +327,9 @@
           }
         }
       }
-
+      if (!jsExcuteCode.isEmpty()) {
+        finalObject.put("jscode", new JSONArray(jsExcuteCode));
+      }
       log.debug(finalObject.toString(1));
       return finalObject;
     } catch (JSONException e) {
@@ -833,7 +837,7 @@
 
   private List<String> executeCallouts(String mode, Tab tab, Map<String, 
JSONObject> columnValues,
       String changedColumn, List<String> calloutsToCall, List<String> 
lastfieldChanged,
-      List<String> messages, List<String> dynamicCols) {
+      List<String> messages, List<String> dynamicCols, List<String> 
jsExecuteCode) {
 
     // In CHANGE mode, we will add the initial callout call for the changed 
column, if there is
     // one
@@ -855,13 +859,13 @@
       return new ArrayList<String>();
     }
     return runCallouts(columnValues, tab, calledCallouts, calloutsToCall, 
lastfieldChanged,
-        messages, dynamicCols);
+        messages, dynamicCols, jsExecuteCode);
 
   }
 
   private List<String> runCallouts(Map<String, JSONObject> columnValues, Tab 
tab,
       List<String> calledCallouts, List<String> calloutsToCall, List<String> 
lastfieldChangedList,
-      List<String> messages, List<String> dynamicCols) {
+      List<String> messages, List<String> dynamicCols, List<String> 
jsExecuteCode) {
 
     // flush&commit to release lock in db which otherwise interfere with 
callouts which run in their
     // own jdbc connection (i.e. lock on AD_Sequence when using with Sales 
Invoice window)
@@ -938,6 +942,12 @@
               if (name.equals("MESSAGE")) {
                 log.debug("Callout message: " + element.get(1, null));
                 messages.add(element.get(1, null).toString());
+              } else if (name.equals("JSEXECUTE")) {
+                // The code on a JSEXECUTE command is sent directly to the 
client for eval()
+                String code = (String) element.get(1, null);
+                if (code != null) {
+                  jsExecuteCode.add(code);
+                }
               } else if (name.equals("EXECUTE")) {
                 String js = element.get(1, null) == null ? null : 
element.get(1, null).toString();
                 if (js != null && !js.equals("")) {
@@ -1025,8 +1035,7 @@
                           rq.setRequestParameter(colId, 
jsonobj.getString("classicValue"));
                         }
                       } else {
-                        log
-                            .debug("Column value didn't change. We do not 
attempt to execute any additional callout");
+                        log.debug("Column value didn't change. We do not 
attempt to execute any additional callout");
                       }
                     }
                     if (changed && col.getCallout() != null) {
diff -r b2b6acc6f87b -r 34a5bf415f29 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Thu Apr 28 18:08:25 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Fri Apr 29 12:44:06 2011 +0200
@@ -588,6 +588,12 @@
       OB.Utilities.callAction(editValues.actionAfterFicReturn);
       delete editValues.actionAfterFicReturn;
     }
+
+    if(data.jscode) {
+      for(i = 0; i < data.jscode.length; i++) {
+        eval(data.jscode[i]);
+      }
+    }
   },
   
   setDisabled: function(state) {
diff -r b2b6acc6f87b -r 34a5bf415f29 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Apr 28 18:08:25 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Fri Apr 29 12:44:06 2011 +0200
@@ -570,6 +570,8 @@
   refreshGrid: function(callback){
     if (this.getSelectedRecord()) {
       this.targetRecordId = this.getSelectedRecord()[OB.Constants.ID];
+      // as the record is already selected it is already in the filter
+      this.notRemoveFilter = true;
     }
     this.actionAfterDataArrived = callback;
     this.invalidateCache();
@@ -584,6 +586,8 @@
     if (this.body) {
       // don't need it anymore
       delete this.targetRecordId;
+      delete this.notRemoveFilter;
+
       var gridRecord = data.find(OB.Constants.ID, tmpTargetRecordId);
       
       // no grid record found, stop here
@@ -741,8 +745,10 @@
       // add a dummy criteria to force a fetch
       criteria.criteria.push(isc.OBRestDataSource.getDummyCriterion());
       
-      // remove the filter clause we don't want to use
-      this.filterClause = null;
+      if (!this.notRemoveFilter) {
+        // remove the filter clause we don't want to use it anymore
+        this.filterClause = null;
+      }
     } else {
       // remove the _dummy
       for (i = 0; i < criteria.criteria.length; i++) {
@@ -820,8 +826,10 @@
     

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to