details:   https://code.openbravo.com/erp/devel/pi/rev/260c5c24d114
changeset: 14734:260c5c24d114
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Fri Nov 25 09:18:43 2011 +0100
summary:   Fixes issue 18718: [trigger] invoice line without product and 
without glitem but with line amt <>0

details:   https://code.openbravo.com/erp/devel/pi/rev/30d88df05940
changeset: 14735:30d88df05940
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Fri Nov 25 10:34:59 2011 +0100
summary:   Fixes issue 19074: Enable user1/user2 acct dimensions in 
Payment/Transaction/Reconciliation

diffstat:

 src-db/database/model/triggers/C_INVLINE_CHK_RESTRICTIONS_TRG.xml      |   5 +
 src-db/database/sourcedata/AD_MESSAGE.xml                              |  11 ++
 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java      |  36 
+++++++-
 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction_data.xsql |  32 
++++++
 src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java                |  25 
++++-
 src/org/openbravo/erpCommon/ad_forms/DocFINPayment_data.xsql           |  32 
++++++
 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java         |  46 
++++++++++
 7 files changed, 178 insertions(+), 9 deletions(-)

diffs (truncated from 315 to 300 lines):

diff -r 6b5adb255b23 -r 30d88df05940 
src-db/database/model/triggers/C_INVLINE_CHK_RESTRICTIONS_TRG.xml
--- a/src-db/database/model/triggers/C_INVLINE_CHK_RESTRICTIONS_TRG.xml Fri Nov 
25 13:21:03 2011 +0100
+++ b/src-db/database/model/triggers/C_INVLINE_CHK_RESTRICTIONS_TRG.xml Fri Nov 
25 10:34:59 2011 +0100
@@ -83,6 +83,11 @@
     IF (:NEW.ISEDITLINENETAMT='Y' AND ROUND(TO_NUMBER(:NEW.QTYINVOICED) * 
TO_NUMBER(:NEW.PRICEACTUAL),v_Prec)!=TO_NUMBER(:NEW.LINENETAMT)) THEN
       RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
     END IF;
+
+    IF (:NEW.account_id is null AND :NEW.m_product_id is null AND 
:NEW.linenetamt <> 0) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@InvoiceLineAmountMustBeZero@') ;
+    END IF;
+    
   END IF;
 END C_INVLINE_CHK_RESTRICTIONS_TRG
 ]]></body>
diff -r 6b5adb255b23 -r 30d88df05940 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Fri Nov 25 13:21:03 2011 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Fri Nov 25 10:34:59 2011 +0100
@@ -17954,6 +17954,17 @@
 <!--A6688A1ACA9F47D0B86C54890D41C2E2-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--A6688A1ACA9F47D0B86C54890D41C2E2--></AD_MESSAGE>
 
+<!--A68484EF93CE4EA5BC44B3A871F88691--><AD_MESSAGE>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  
<AD_MESSAGE_ID><![CDATA[A68484EF93CE4EA5BC44B3A871F88691]]></AD_MESSAGE_ID>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  
<VALUE><![CDATA[InvoiceLineAmountMustBeZero]]></VALUE>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  <MSGTEXT><![CDATA[Line amount must be 
zero when no product nor G/L Item is selected.]]></MSGTEXT>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--A68484EF93CE4EA5BC44B3A871F88691-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--A68484EF93CE4EA5BC44B3A871F88691--></AD_MESSAGE>
+
 <!--A68C3053E180449ABF364A71CBAC9CF0--><AD_MESSAGE>
 <!--A68C3053E180449ABF364A71CBAC9CF0-->  
<AD_MESSAGE_ID><![CDATA[A68C3053E180449ABF364A71CBAC9CF0]]></AD_MESSAGE_ID>
 <!--A68C3053E180449ABF364A71CBAC9CF0-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 6b5adb255b23 -r 30d88df05940 
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Fri Nov 
25 13:21:03 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Fri Nov 
25 10:34:59 2011 +0100
@@ -52,6 +52,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
+import org.openbravo.service.db.DalConnectionProvider;
 
 public class DocFINFinAccTransaction extends AcctServer {
   /** Transaction type - Financial Account */
@@ -210,6 +211,18 @@
             .getFINPaymentScheduleDetailList().get(0).getSalesRegion() != null 
? paymentDetails
             
.get(i).getFINPaymentScheduleDetailList().get(0).getSalesRegion().getId() : "");
         FieldProviderFactory.setField(data[i], "lineno", 
transaction.getLineNo().toString());
+
+        try { // Get User1_ID and User2_ID using xsql
+          ConnectionProvider conn = new DalConnectionProvider(false);
+          DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+              transaction.getId());
+          if (trxInfo.length > 0) {
+            FieldProviderFactory.setField(data[i], "user1Id", 
trxInfo[0].user1Id);
+            FieldProviderFactory.setField(data[i], "user2Id", 
trxInfo[0].user2Id);
+          }
+        } catch (Exception e) {
+          log4j.error("Error while retreiving user1 and user2 - ", e);
+        }
       }
     } finally {
       OBContext.restorePreviousMode();
@@ -245,6 +258,19 @@
         FieldProviderFactory.setField(data[0], "cCampaignId", 
transaction.getSalesCampaign()
             .getId());
       FieldProviderFactory.setField(data[0], "lineno", 
transaction.getLineNo().toString());
+
+      try { // Get User1_ID and User2_ID using xsql
+        ConnectionProvider conn = new DalConnectionProvider(false);
+        DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+            transaction.getId());
+        if (trxInfo.length > 0) {
+          FieldProviderFactory.setField(data[0], "user1Id", 
trxInfo[0].user1Id);
+          FieldProviderFactory.setField(data[0], "user2Id", 
trxInfo[0].user2Id);
+        }
+      } catch (Exception e) {
+        log4j.error("Error while retreiving user1 and user2 - ", e);
+      }
+
     } finally {
       OBContext.restorePreviousMode();
     }
@@ -835,9 +861,13 @@
       FieldProviderFactory.setField(data[0], "C_SalesRegion_ID",
           transaction.getSalesRegion() != null ? 
transaction.getSalesRegion().getId() : "");
       FieldProviderFactory.setField(data[0], "lineno", 
transaction.getLineNo().toString());
-      // This lines can be uncommented when User1 and User2 are implemented
-      // FieldProviderFactory.setField(data[0], "User1_ID", 
transaction.getNdDimension().getId());
-      // FieldProviderFactory.setField(data[0], "User2_ID", 
transaction.getNdDimension().getId());
+      // User1_ID and User2_ID
+      DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+          transaction.getId());
+      if (trxInfo.length > 0) {
+        FieldProviderFactory.setField(data[0], "User1_ID", trxInfo[0].user1Id);
+        FieldProviderFactory.setField(data[0], "User2_ID", trxInfo[0].user2Id);
+      }
       FieldProviderFactory.setField(data[0], "FIN_Payment_ID",
           transaction.getFinPayment() != null ? 
transaction.getFinPayment().getId() : "");
       final String cBPartnerId;
diff -r 6b5adb255b23 -r 30d88df05940 
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction_data.xsql
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction_data.xsql    
Fri Nov 25 10:34:59 2011 +0100
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ******************************************************************************
+ * The contents of this file are subject to the   Compiere License  Version 1.1
+ * ("License"); You may not use this file except in compliance with the License
+ * You may obtain a copy of the License at http://www.compiere.org/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                  Compiere  ERP & CRM  Business Solution
+ * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
+ * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
+ * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
+ * Contributor(s): Openbravo SLU
+ * Contributions are Copyright (C) 2011 Openbravo S.L.U.
+ ******************************************************************************
+-->
+
+<SqlClass name="DocFINFinAccTransactionData" 
package="org.openbravo.erpCommon.ad_forms">
+  <SqlClassComment></SqlClassComment>
+  <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT user1_id, user2_id
+        FROM fin_finacc_transaction
+        WHERE fin_finacc_transaction_id = ?
+      ]]>
+    </Sql>
+    <Parameter name="transactionId"/>
+  </SqlMethod>
+</SqlClass>
diff -r 6b5adb255b23 -r 30d88df05940 
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java   Fri Nov 25 
13:21:03 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java   Fri Nov 25 
10:34:59 2011 +0100
@@ -49,6 +49,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
+import org.openbravo.service.db.DalConnectionProvider;
 
 public class DocFINPayment extends AcctServer {
   private static final long serialVersionUID = 1L;
@@ -175,9 +176,17 @@
         FieldProviderFactory.setField(data[i], "cSalesregionId", 
paymentDetails.get(i)
             .getFINPaymentScheduleDetailList().get(0).getSalesRegion() != null 
? paymentDetails
             
.get(i).getFINPaymentScheduleDetailList().get(0).getSalesRegion().getId() : "");
-        // This lines can be uncommented when User1 and User2 are implemented
-        // FieldProviderFactory.setField(data[0], "User1_ID", 
payment.getStDimension().getId());
-        // FieldProviderFactory.setField(data[0], "User2_ID", 
payment.getNdDimension().getId());
+
+        try { // Get User1_ID and User2_ID using xsql
+          ConnectionProvider conn = new DalConnectionProvider(false);
+          DocFINPaymentData[] paymentInfo = DocFINPaymentData.select(conn, 
payment.getId());
+          if (paymentInfo.length > 0) {
+            FieldProviderFactory.setField(data[i], "user1Id", 
paymentInfo[0].user1Id);
+            FieldProviderFactory.setField(data[i], "user2Id", 
paymentInfo[0].user2Id);
+          }
+        } catch (Exception e) {
+          log4j.error("Error while retreiving user1 and user2 - ", e);
+        }
 
       }
     } finally {
@@ -470,9 +479,13 @@
         payment.getSalesCampaign() != null ? 
payment.getSalesCampaign().getId() : "");
     FieldProviderFactory.setField(data[0], "C_Activity_ID", 
payment.getActivity() != null ? payment
         .getActivity().getId() : "");
-    // This lines can be uncommented when User1 and User2 are implemented
-    // FieldProviderFactory.setField(data[0], "User1_ID", 
payment.getStDimension().getId());
-    // FieldProviderFactory.setField(data[0], "User2_ID", 
payment.getNdDimension().getId());
+    // User1_ID and User2_ID
+    DocFINPaymentData[] paymentInfo = DocFINPaymentData.select(conn, 
payment.getId());
+    if (paymentInfo.length > 0) {
+      FieldProviderFactory.setField(data[0], "User1_ID", 
paymentInfo[0].user1Id);
+      FieldProviderFactory.setField(data[0], "User2_ID", 
paymentInfo[0].user2Id);
+    }
+
     setObjectFieldProvider(data);
   }
 
diff -r 6b5adb255b23 -r 30d88df05940 
src/org/openbravo/erpCommon/ad_forms/DocFINPayment_data.xsql
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment_data.xsql      Fri Nov 
25 10:34:59 2011 +0100
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ******************************************************************************
+ * The contents of this file are subject to the   Compiere License  Version 1.1
+ * ("License"); You may not use this file except in compliance with the License
+ * You may obtain a copy of the License at http://www.compiere.org/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                  Compiere  ERP & CRM  Business Solution
+ * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
+ * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
+ * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
+ * Contributor(s): Openbravo SLU
+ * Contributions are Copyright (C) 2011 Openbravo S.L.U.
+ ******************************************************************************
+-->
+
+<SqlClass name="DocFINPaymentData" package="org.openbravo.erpCommon.ad_forms">
+  <SqlClassComment></SqlClassComment>
+  <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT user1_id, user2_id
+        FROM fin_payment
+        WHERE fin_payment_id = ?
+      ]]>
+    </Sql>
+    <Parameter name="paymentId"/>
+  </SqlMethod>
+</SqlClass>
diff -r 6b5adb255b23 -r 30d88df05940 
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Fri Nov 
25 13:21:03 2011 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Fri Nov 
25 10:34:59 2011 +0100
@@ -61,6 +61,7 @@
 import org.openbravo.model.financialmgmt.payment.FIN_Reconciliation;
 import org.openbravo.model.financialmgmt.payment.FIN_ReconciliationLine_v;
 import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
+import org.openbravo.service.db.DalConnectionProvider;
 
 public class DocFINReconciliation extends AcctServer {
   /** Transaction type - Financial Account */
@@ -274,6 +275,16 @@
             .getFINPaymentScheduleDetailList().get(0).getSalesRegion() != null 
? paymentDetails
             
.get(i).getFINPaymentScheduleDetailList().get(0).getSalesRegion().getId() : "");
         FieldProviderFactory.setField(data[i], "lineno", 
transaction.getLineNo().toString());
+        try { // Get User1_ID and User2_ID using xsql
+          ConnectionProvider conn = new DalConnectionProvider(false);
+          DocFINPaymentData[] paymentInfo = DocFINPaymentData.select(conn, 
payment.getId());
+          if (paymentInfo.length > 0) {
+            FieldProviderFactory.setField(data[i], "user1Id", 
paymentInfo[0].user1Id);
+            FieldProviderFactory.setField(data[i], "user2Id", 
paymentInfo[0].user2Id);
+          }
+        } catch (Exception e) {
+          log4j.error("Error while retreiving user1 and user2 - ", e);
+        }
       }
     } finally {
       OBContext.restorePreviousMode();
@@ -331,6 +342,17 @@
           FieldProviderFactory.setField(data[0], "cSalesregionId", 
transaction.getSalesRegion()
               .getId());
         FieldProviderFactory.setField(data[i], "lineno", 
transaction.getLineNo().toString());
+        try { // Get User1_ID and User2_ID using xsql
+          ConnectionProvider conn = new DalConnectionProvider(false);
+          DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+              transaction.getId());
+          if (trxInfo.length > 0) {
+            FieldProviderFactory.setField(data[i], "user1Id", 
trxInfo[0].user1Id);
+            FieldProviderFactory.setField(data[i], "user2Id", 
trxInfo[0].user2Id);
+          }
+        } catch (Exception e) {
+          log4j.error("Error while retreiving user1 and user2 - ", e);
+        }
       }
     } finally {
       OBContext.restorePreviousMode();
@@ -375,6 +397,17 @@
         FieldProviderFactory.setField(data[0], "cSalesregionId", 
transaction.getSalesRegion()
             .getId());
       FieldProviderFactory.setField(data[0], "lineno", 
transaction.getLineNo().toString());
+      try { // Get User1_ID and User2_ID using xsql
+        ConnectionProvider conn = new DalConnectionProvider(false);
+        DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+            transaction.getId());
+        if (trxInfo.length > 0) {
+          FieldProviderFactory.setField(data[0], "user1Id", 
trxInfo[0].user1Id);
+          FieldProviderFactory.setField(data[0], "user2Id", 
trxInfo[0].user2Id);
+        }
+      } catch (Exception e) {
+        log4j.error("Error while retreiving user1 and user2 - ", e);
+      }
     } finally {
       OBContext.restorePreviousMode();
     }
@@ -410,6 +443,17 @@
         FieldProviderFactory.setField(data[0], "cCampaignId", 
transaction.getSalesCampaign()
             .getId());
       FieldProviderFactory.setField(data[0], "lineno", 
transaction.getLineNo().toString());
+      try { // Get User1_ID and User2_ID using xsql
+        ConnectionProvider conn = new DalConnectionProvider(false);
+        DocFINFinAccTransactionData[] trxInfo = 
DocFINFinAccTransactionData.select(conn,
+            transaction.getId());
+        if (trxInfo.length > 0) {
+          FieldProviderFactory.setField(data[0], "user1Id", 
trxInfo[0].user1Id);
+          FieldProviderFactory.setField(data[0], "user2Id", 
trxInfo[0].user2Id);
+        }

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to