merge
authorAdrián Romero <adrianromero@openbravo.com>
Thu, 14 Oct 2010 18:51:38 +0200
changeset 8555 ff88423ee721
parent 8554 53f73a88a984 (current diff)
parent 8552 661f42233527 (diff)
child 8556 8f1e3114223e
merge
src-db/database/sourcedata/AD_COLUMN.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Wed Oct 13 15:56:23 2010 +0200
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Oct 14 18:51:38 2010 +0200
@@ -1555,6 +1555,7 @@
               FROM C_DEBT_PAYMENT DP
               WHERE C_BPartner_ID=v_BPartner_ID
                 AND C_Debt_Payment_Status(C_Settlement_Cancel_ID, Cancel_Processed, Generate_Processed, IsPaid, IsValid, C_Cashline_ID, C_BankstatementLine_ID)='P'
+                AND ISRECEIPT=v_IsSOTrx
                 AND (-1) *Amount=v_paymentAmount
                 AND c_currency_ID=v_Currency_ID
                 AND C_SETTLEMENT_GENERATE_ID IS NOT NULL
--- a/src-db/database/model/functions/MRP_PURCHASEORDER.xml	Wed Oct 13 15:56:23 2010 +0200
+++ b/src-db/database/model/functions/MRP_PURCHASEORDER.xml	Thu Oct 14 18:51:38 2010 +0200
@@ -51,6 +51,8 @@
   v_PriceStd NUMBER;
   v_TaxId varchar2(32);
   v_ProductName NVARCHAR2(90);
+  v_IsAPRMinstalled NUMBER;
+  v_DefaultPaymentRule VARCHAR2(60):=null;
 
   v_Count NUMBER;
 
@@ -133,6 +135,13 @@
           AND ISBILLTO='Y'
           AND C_BPARTNER_ID=Cur_workproposal.C_BPARTNER_ID;
 
+        SELECT COUNT(1) INTO v_IsAPRMinstalled
+        FROM ad_preference
+        WHERE property = 'FinancialManagement' AND ad_module_id <> '0';
+        IF (v_IsAPRMinstalled > 0) THEN
+          v_DefaultPaymentRule := 'P';
+        END IF;
+
         INSERT INTO C_Order
           (C_ORDER_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE,
            CREATED, CREATEDBY, UPDATED, UPDATEDBY,
@@ -150,7 +159,7 @@
          'N', v_DocumentNo,  'DR', 'CO','N',
           v_CDocTypeID, v_CDocTypeID, v_Description,
           v_DateDoc,v_DateDoc, Cur_workproposal.C_BPartner_ID,v_BillTo_ID,
-          v_BPartner_Location_ID, Cur_workproposal.C_Currency_ID, Cur_workproposal.paymentrule, Cur_workproposal.C_PAYMENTTERM_ID,
+          v_BPartner_Location_ID, Cur_workproposal.C_Currency_ID, COALESCE(Cur_workproposal.paymentrule, v_DefaultPaymentRule), Cur_workproposal.C_PAYMENTTERM_ID,
           'D', 'A', 'I',COALESCE(Cur_workproposal.DeliveryViaRule,'D'),
           '5',0,0,
           v_M_Warehouse_ID, Cur_workproposal.PO_PRICELIST_ID, 'N', v_DateDoc,
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Wed Oct 13 15:56:23 2010 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Thu Oct 14 18:51:38 2010 +0200
@@ -34076,7 +34076,7 @@
 <!--2225-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--2225-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--2225-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--2225-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--2225-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--2225-->  <COLUMNNAME><![CDATA[QtyReserved]]></COLUMNNAME>
 <!--2225-->  <AD_TABLE_ID><![CDATA[260]]></AD_TABLE_ID>
 <!--2225-->  <AD_REFERENCE_ID><![CDATA[29]]></AD_REFERENCE_ID>
@@ -71161,7 +71161,7 @@
 <!--4367-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--4367-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--4367-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--4367-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--4367-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--4367-->  <COLUMNNAME><![CDATA[QtyReserved]]></COLUMNNAME>
 <!--4367-->  <AD_TABLE_ID><![CDATA[360]]></AD_TABLE_ID>
 <!--4367-->  <AD_REFERENCE_ID><![CDATA[29]]></AD_REFERENCE_ID>
@@ -175753,7 +175753,7 @@
 <!--800656-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--800656-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--800656-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--800656-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--800656-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--800656-->  <COLUMNNAME><![CDATA[QtyReserved]]></COLUMNNAME>
 <!--800656-->  <AD_TABLE_ID><![CDATA[800037]]></AD_TABLE_ID>
 <!--800656-->  <AD_REFERENCE_ID><![CDATA[29]]></AD_REFERENCE_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Oct 13 15:56:23 2010 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Thu Oct 14 18:51:38 2010 +0200
@@ -3692,7 +3692,7 @@
 <!--532-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--532-->  <PRINTNAME><![CDATA[Reserved Qty]]></PRINTNAME>
 <!--532-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--532-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--532-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--532-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--532--></AD_ELEMENT>
 
--- a/src-db/database/sourcedata/AD_FIELD.xml	Wed Oct 13 15:56:23 2010 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Thu Oct 14 18:51:38 2010 +0200
@@ -14468,7 +14468,7 @@
 <!--1131-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--1131-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--1131-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--1131-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--1131-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--1131-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--1131-->  <AD_TAB_ID><![CDATA[187]]></AD_TAB_ID>
 <!--1131-->  <AD_COLUMN_ID><![CDATA[2225]]></AD_COLUMN_ID>
@@ -34896,7 +34896,7 @@
 <!--3048-->  <AD_TAB_ID><![CDATA[132]]></AD_TAB_ID>
 <!--3048-->  <AD_COLUMN_ID><![CDATA[3898]]></AD_COLUMN_ID>
 <!--3048-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--3048-->  <DISPLAYLOGIC><![CDATA[@ElementType@='A' & @IsBankAccount@='Y']]></DISPLAYLOGIC>
+<!--3048-->  <DISPLAYLOGIC><![CDATA[@ElementType@='A' & @IsBankAccount@='Y' & @FinancialManagement@='']]></DISPLAYLOGIC>
 <!--3048-->  <DISPLAYLENGTH><![CDATA[44]]></DISPLAYLENGTH>
 <!--3048-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--3048-->  <SEQNO><![CDATA[180]]></SEQNO>
@@ -34920,7 +34920,7 @@
 <!--3049-->  <AD_TAB_ID><![CDATA[132]]></AD_TAB_ID>
 <!--3049-->  <AD_COLUMN_ID><![CDATA[3897]]></AD_COLUMN_ID>
 <!--3049-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--3049-->  <DISPLAYLOGIC><![CDATA[@ElementType@='A']]></DISPLAYLOGIC>
+<!--3049-->  <DISPLAYLOGIC><![CDATA[@ElementType@='A' & @FinancialManagement@='']]></DISPLAYLOGIC>
 <!--3049-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--3049-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--3049-->  <SEQNO><![CDATA[170]]></SEQNO>
@@ -39633,7 +39633,7 @@
 <!--3390-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3390-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--3390-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--3390-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--3390-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--3390-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--3390-->  <AD_TAB_ID><![CDATA[293]]></AD_TAB_ID>
 <!--3390-->  <AD_COLUMN_ID><![CDATA[2225]]></AD_COLUMN_ID>
@@ -114489,7 +114489,7 @@
 <!--800348-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--800348-->  <NAME><![CDATA[Reserved Quantity]]></NAME>
 <!--800348-->  <DESCRIPTION><![CDATA[Reserved Quantity]]></DESCRIPTION>
-<!--800348-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for other orders.]]></HELP>
+<!--800348-->  <HELP><![CDATA[The Reserved Quantity indicates the quantity of a product that is currently reserved for this order.]]></HELP>
 <!--800348-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--800348-->  <AD_TAB_ID><![CDATA[800022]]></AD_TAB_ID>
 <!--800348-->  <AD_COLUMN_ID><![CDATA[2225]]></AD_COLUMN_ID>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Oct 13 15:56:23 2010 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Oct 14 18:51:38 2010 +0200
@@ -8887,6 +8887,18 @@
 <!--4B320699808A4088930E96843DCBAF6D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--4B320699808A4088930E96843DCBAF6D--></AD_REF_LIST>
 
+<!--4BED47D608B841EC8016441CFA05F2FA--><AD_REF_LIST>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <AD_REF_LIST_ID><![CDATA[4BED47D608B841EC8016441CFA05F2FA]]></AD_REF_LIST_ID>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <VALUE><![CDATA[ForcedLoginURL]]></VALUE>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <NAME><![CDATA[Forced Login URL]]></NAME>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <DESCRIPTION><![CDATA[If this property is set and the Openbravo login page is accessed using a different URL, it will be redirected to this one. Value for this property should be assigned at system level.]]></DESCRIPTION>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--4BED47D608B841EC8016441CFA05F2FA-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--4BED47D608B841EC8016441CFA05F2FA--></AD_REF_LIST>
+
 <!--4C6B4B638FC74B72AD5646519F92AB57--><AD_REF_LIST>
 <!--4C6B4B638FC74B72AD5646519F92AB57-->  <AD_REF_LIST_ID><![CDATA[4C6B4B638FC74B72AD5646519F92AB57]]></AD_REF_LIST_ID>
 <!--4C6B4B638FC74B72AD5646519F92AB57-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Wed Oct 13 15:56:23 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Thu Oct 14 18:51:38 2010 +0200
@@ -688,9 +688,24 @@
   /**
    * Get Document Confirmation
    * 
-   * not used
    */
   public boolean getDocumentConfirmation(ConnectionProvider conn, String strRecordId) {
+    DocInvoiceData[] data = null;
+    try {
+      data = DocInvoiceData.selectFinInvCount(conn, strRecordId);
+      if (data.length > 0) {
+        if (Integer.parseInt(data[0].fininvcount) == 0)
+          return true;
+        else if (Integer.parseInt(data[0].fininvcount) == Integer.parseInt(data[0].finacctcount))
+          return true;
+        else {
+          setStatus(STATUS_Error);
+          return false;
+        }
+      }
+    } catch (ServletException e) {
+      log4jDocInvoice.error("Exception in getDocumentConfirmation method: " + e);
+    }
     return true;
   }
 
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql	Wed Oct 13 15:56:23 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql	Thu Oct 14 18:51:38 2010 +0200
@@ -35,7 +35,8 @@
         '' AS GRANDTOTAL, '' AS M_PRICELIST_ID, '' AS ISTAXINCLUDED, '' AS C_CAMPAIGN_ID, '' AS C_PROJECT_ID, '' AS C_ACTIVITY_ID,
         '' AS ISPAID, '' AS CREATEFROM, '' AS GENERATETO, '' AS SENDEMAIL, '' AS AD_USER_ID, '' AS COPYFROM, '' AS ISSELFSERVICE,
         '' AS AD_ORGTRX_ID, '' AS USER1_ID, '' AS USER2_ID, '' as AMOUNT, '' AS STATUS, '' AS ISRECEIPT, '' AS ISMANUAL, '' AS WRITEOFFAMT,
-        '' AS C_DEBT_PAYMENT_ID, '' AS P_REVENUE_ACCT, '' AS P_EXPENSE_ACCT, '' as FIN_PAYMENT_SCHEDULE_ID, '' as FIN_PAYMENTMETHOD_ID, '' AS PREPAIDAMT
+        '' AS C_DEBT_PAYMENT_ID, '' AS P_REVENUE_ACCT, '' AS P_EXPENSE_ACCT, '' as FIN_PAYMENT_SCHEDULE_ID, '' as FIN_PAYMENTMETHOD_ID, '' AS PREPAIDAMT,
+        '' AS FININVCOUNT, '' AS FINACCTCOUNT
         FROM C_Tax t, C_InvoiceTax it
         WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Invoice_ID=?
      ]]>
@@ -154,4 +155,20 @@
     <Parameter name="taxId"/>
     <Parameter name="invoiceId"/>
    </SqlMethod>
+   <SqlMethod name="selectFinInvCount" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT (SELECT COUNT(*) FROM C_INVOICELINE WHERE FINANCIAL_INVOICE_LINE='Y'
+        AND C_INVOICE_ID=?) AS FININVCOUNT, 
+        (SELECT COUNT(*) FROM C_INVOICELINE invln LEFT JOIN C_GLITEM_ACCT glact ON 
+        invln.ACCOUNT_ID = glact.C_GLITEM_ID WHERE invln.FINANCIAL_INVOICE_LINE='Y' AND 
+        invln.C_INVOICE_ID=? AND 
+        glact.GLITEM_DEBIT_ACCT IS NOT NULL AND 
+        glact.GLITEM_CREDIT_ACCT IS NOT NULL) AS FINACCTCOUNT FROM DUAL
+     ]]>
+     </Sql>
+     <Parameter name="invoiceId"/>
+     <Parameter name="invoiceId"/>
+   </SqlMethod>
 </SqlClass>
--- a/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java	Wed Oct 13 15:56:23 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java	Thu Oct 14 18:51:38 2010 +0200
@@ -31,6 +31,8 @@
 import org.openbravo.base.filter.IsIDFilter;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.erpCommon.businessUtility.Preferences;
 import org.openbravo.erpCommon.businessUtility.Tree;
 import org.openbravo.erpCommon.businessUtility.WindowTabs;
 import org.openbravo.erpCommon.businessUtility.WindowTabsData;
@@ -40,6 +42,8 @@
 import org.openbravo.erpCommon.utility.LeftTabsBar;
 import org.openbravo.erpCommon.utility.NavigationBar;
 import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.PropertyException;
+import org.openbravo.erpCommon.utility.PropertyNotFoundException;
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.ToolBar;
 import org.openbravo.erpCommon.utility.Utility;
@@ -468,7 +472,8 @@
             strOrderDate, strVendor, RequisitionToOrderData.cBPartnerLocationId(this, strVendor),
             RequisitionToOrderData.billto(this, strVendor).equals("") ? RequisitionToOrderData
                 .cBPartnerLocationId(this, strVendor) : RequisitionToOrderData.billto(this,
-                strVendor), cCurrencyId, data1[0].paymentrulepo, data1[0].poPaymenttermId,
+                strVendor), cCurrencyId, isAlternativeFinancialFlow() ? "P"
+                : data1[0].paymentrulepo, data1[0].poPaymenttermId,
             data1[0].invoicerule.equals("") ? "I" : data1[0].invoicerule, data1[0].deliveryrule
                 .equals("") ? "A" : data1[0].deliveryrule, "I",
             data1[0].deliveryviarule.equals("") ? "D" : data1[0].deliveryviarule, strWarehouse,
@@ -592,6 +597,26 @@
     return myMessage;
   }
 
+  /**
+   * Checks if the any module implements and alternative Financial Management preference. It should
+   * be the Advanced Payables and Receivables module.
+   * 
+   * @return true if any module implements and alternative Financial Management preference.
+   */
+  private boolean isAlternativeFinancialFlow() {
+    try {
+      try {
+        Preferences.getPreferenceValue("FinancialManagement", true, null, null, OBContext
+            .getOBContext().getUser(), null, null);
+      } catch (PropertyNotFoundException e) {
+        return false;
+      }
+    } catch (PropertyException e) {
+      return false;
+    }
+    return true;
+  }
+
   public String getServletInfo() {
     return "Servlet RequisitionToOrder.";
   } // end of getServletInfo() method
--- a/src/org/openbravo/erpCommon/security/Login.java	Wed Oct 13 15:56:23 2010 +0200
+++ b/src/org/openbravo/erpCommon/security/Login.java	Thu Oct 14 18:51:38 2010 +0200
@@ -29,6 +29,8 @@
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.businessUtility.Preferences;
+import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.xmlEngine.XmlDocument;
@@ -76,6 +78,26 @@
     } else if (vars.commandIn("LOGO")) {
       printPageLogo(response, vars);
     } else {
+      // Look for forced login URL property and redirect in case it is set and the login is accessed
+      // through a different URL
+      try {
+        String forcedLoginUrl = Preferences.getPreferenceValue("ForcedLoginURL", true, null, null,
+            null, null, null);
+        log4j.debug("Forced URL: " + forcedLoginUrl);
+        if (forcedLoginUrl != null && !forcedLoginUrl.isEmpty()
+            && !request.getRequestURL().toString().startsWith(forcedLoginUrl)) {
+          log4j.info("Redireting login from " + request.getRequestURL().toString()
+              + " to forced login URL " + forcedLoginUrl);
+          response.sendRedirect(forcedLoginUrl);
+          return;
+        }
+      } catch (PropertyException e) {
+        // Ignore and continue with the standard login. PropertyException is raised in case property
+        // is not defined (standard case) or in case of conflict.
+        log4j.debug("Exception getting ForcedLoginURL", e);
+      }
+
+      // Standard login
       String textDirection = vars.getSessionValue("#TextDirection", "LTR");
       printPageFrameIdentificacion(response, "Login_Welcome.html?Command=WELCOME",
           "Login_F1.html?Command=LOGIN", textDirection);