[open close period] Merge with pi
authorDavid Miguelez <david.miguelez@openbravo.com>
Mon, 18 Mar 2013 11:15:21 +0100
changeset 19983 d9ff9aee8bce
parent 19982 485930036c1b (current diff)
parent 19928 73b8312f9699 (diff)
child 19984 4dd0c12150c1
[open close period] Merge with pi
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_MENU.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_PROCESS.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_TABLE.xml
src-db/database/sourcedata/AD_TREENODE.xml
src-db/database/sourcedata/OBUIAPP_PROCESS.xml
--- a/.classpath.template	Fri Mar 15 20:18:02 2013 +0100
+++ b/.classpath.template	Mon Mar 18 11:15:21 2013 +0100
@@ -4,7 +4,7 @@
 	<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
 	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/OpenbravoTrl"/>
 	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/OpenbravoWAD"/>
-	<classpathentry including="**/*.ext|**/*.java|**/*.oaw|**/*.properties|**/*.xml|**/*.xpt|**/*.xslt" kind="src" path="src"/>
+	<classpathentry including="**/*.ext|**/*.ftl|**/*.java|**/*.oaw|**/*.properties|**/*.xml|**/*.xpt|**/*.xslt" kind="src" path="src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.client.widgets/src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.client.htmlwidget/src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.base.weld/src"/>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -19780,7 +19780,7 @@
 <!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--FAC2D0F2487F4FF499EA3BEEDEABFAB5-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  Enterprise Intelligence Systems (http://www.eintel.com.au).
  *************************************************************************
@@ -1700,7 +1700,7 @@
         .getFinancialMgmtPaymentExecutionProcessParameterList();
     for (PaymentExecutionProcessParameter parameter : parameters) {
       if ("CONSTANT".equals(parameter.getParameterType())
-          && parameter.getDefaultTextValue() != null && parameter.getDefaultTextValue() != "")
+          && StringUtils.isBlank(parameter.getDefaultTextValue()))
         return false;
       else if ("IN".equals(parameter.getParameterType())) {
         if ("CHECK".equals(parameter.getInputType())
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/FIN_Utilities.js	Fri Mar 15 20:18:02 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/FIN_Utilities.js	Mon Mar 18 11:15:21 2013 +0100
@@ -246,7 +246,11 @@
 
 function compareWithSign(number1, operator, number2) {
   if (compare(number1, '<', 0) && compare(number2, '<', 0)) {
-    return formattedNumberOpTemp(abs(number1), operator, abs(number2), globalMaskNumeric, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
+    if (operator === '<' || operator === '>' || operator === '<=' || operator === '>=') {
+      return formattedNumberOpTemp(abs(number2), operator, abs(number1), globalMaskNumeric, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
+    } else {
+      return formattedNumberOpTemp(abs(number1), operator, abs(number2), globalMaskNumeric, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
+    }
   } else {
     return formattedNumberOpTemp(number1, operator, number2, globalMaskNumeric, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
   }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelServlet.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelServlet.java	Mon Mar 18 11:15:21 2013 +0100
@@ -105,7 +105,9 @@
       if (component instanceof BaseComponent && ((BaseComponent) component).bypassAuthentication()) {
         bypassAuthentication = true;
         OBContext context = OBContext.getOBContext();
-        sessionForThisRequest = context == null;
+
+        sessionForThisRequest = context == null
+            || request.getSession().getAttribute("#Authenticated_user") == null;
 
         HttpSession session = request.getSession(true);
         if (sessionForThisRequest) {
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/SelectorUIReference.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/SelectorUIReference.java	Mon Mar 18 11:15:21 2013 +0100
@@ -202,7 +202,12 @@
           String parentFieldName = fieldName;
           String name = ((fieldName != null && !fieldName.equals("")) ? fieldName : comboTableData
               .getObjectName());
-
+          if (name.startsWith("EM_")) {
+            // For external module fields use the column field in selector to avoid comparing
+            // fields with EM_fieldname which will not be present in the current table.
+            // Refer issue https://issues.openbravo.com/view.php?id=23267
+            name = selector.getColumn().getDBColumnName();
+          }
           String tableDirName;
           if (name.equalsIgnoreCase("createdby") || name.equalsIgnoreCase("updatedby")) {
             tableDirName = "AD_User";
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Mar 15 20:18:02 2013 +0100
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Mon Mar 18 11:15:21 2013 +0100
@@ -31,6 +31,19 @@
 
 isc.DataSource.serializeTimeAsDatetime = true;
 
+isc.DataSource.addProperties({
+  compareDates: function (date1, date2, fieldName, otherFieldName) {
+    var field = this.getField(fieldName),
+        otherField = otherFieldName ? this.getField(otherFieldName) : null;
+    if ((field && (field.type === "datetime" || field.type === "_id_24")) || (otherField && (otherField.type === "datetime" || otherField.type === "_id_24"))) {
+      return Date.compareDates(date1, date2);
+    } else {
+      return Date.compareLogicalDates(date1, date2);
+    }
+  }
+});
+
+
 isc.Canvas.addProperties({
 
   // make sure that the datasources are also destroyed
--- a/src-db/database/model/functions/AD_COLUMN_IDENTIFIER_REF_SQL.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/model/functions/AD_COLUMN_IDENTIFIER_REF_SQL.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -92,6 +92,13 @@
     ELSE
       v_TableDir:=SUBSTR(p_ColumnName, 1, LENGTH(p_ColumnName) -3) ;
     END IF;
+  ELSIF p_Reference_ID IN ('95E2A8B50A254B2AAE6774B8C2F28120') THEN --UISelector
+     SELECT t.TABLENAME
+      INTO v_TableDir
+      FROM OBUISEL_SELECTOR s,
+        AD_TABLE t
+      WHERE UPPER(s.AD_REFERENCE_ID)=UPPER(p_Reference_Value_ID)
+      AND s.AD_TABLE_ID=t.AD_TABLE_ID;
   ELSE
     SELECT c.ISTRANSLATED
     INTO v_IsTranslated
@@ -131,7 +138,7 @@
       v_SQL:='TO_CHAR(COALESCE(TO_CHAR('||p_TableRef||'.'|| p_ColumnName||'),''''))';
     END IF;
   END IF;
-  IF p_Reference_ID IN('19', '32', '30', '31', '35', '25', '800011') THEN
+  IF p_Reference_ID IN('19', '32', '30', '31', '35', '25', '800011','95E2A8B50A254B2AAE6774B8C2F28120') THEN
     DECLARE
       v_PartialDisplay VARCHAR2(2000) ;
       v_KeyName        VARCHAR2(50) ;
--- a/src-db/database/model/tables/AD_USER.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/model/tables/AD_USER.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -153,6 +153,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="GRANT_PORTAL_ACCESS" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_ORG" name="AD_USER_AD_ORGTRX">
         <reference local="AD_ORGTRX_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
--- a/src-db/database/model/tables/FACT_ACCT.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/model/tables/FACT_ACCT.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -201,6 +201,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="ISMODIFY" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_ORG" name="AD_ORG_FACT_ACCT">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
--- a/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -1941,6 +1941,17 @@
 <!--69B122EAEF3B42398D27D5FF0F44AD40-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--69B122EAEF3B42398D27D5FF0F44AD40--></AD_AUXILIARINPUT>
 
+<!--6BDE684AC58045218FAEB2A11221911B--><AD_AUXILIARINPUT>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <AD_AUXILIARINPUT_ID><![CDATA[6BDE684AC58045218FAEB2A11221911B]]></AD_AUXILIARINPUT_ID>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <AD_TAB_ID><![CDATA[496]]></AD_TAB_ID>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <NAME><![CDATA[isPortalRolePresent]]></NAME>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <CODE><![CDATA[@SQL=SELECT COUNT(*) FROM AD_ROLE WHERE ISPORTAL='Y']]></CODE>
+<!--6BDE684AC58045218FAEB2A11221911B-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BDE684AC58045218FAEB2A11221911B--></AD_AUXILIARINPUT>
+
 <!--6DDE5291DEB245BAB84FFD042AE66D4C--><AD_AUXILIARINPUT>
 <!--6DDE5291DEB245BAB84FFD042AE66D4C-->  <AD_AUXILIARINPUT_ID><![CDATA[6DDE5291DEB245BAB84FFD042AE66D4C]]></AD_AUXILIARINPUT_ID>
 <!--6DDE5291DEB245BAB84FFD042AE66D4C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -25022,7 +25022,7 @@
 <!--1792-->  <HELP><![CDATA[The Currency Conversion Rate indicates the rate to use when converting the source currency to the accounting currency]]></HELP>
 <!--1792-->  <COLUMNNAME><![CDATA[CurrencyRate]]></COLUMNNAME>
 <!--1792-->  <AD_TABLE_ID><![CDATA[224]]></AD_TABLE_ID>
-<!--1792-->  <AD_REFERENCE_ID><![CDATA[22]]></AD_REFERENCE_ID>
+<!--1792-->  <AD_REFERENCE_ID><![CDATA[800019]]></AD_REFERENCE_ID>
 <!--1792-->  <FIELDLENGTH><![CDATA[22]]></FIELDLENGTH>
 <!--1792-->  <DEFAULTVALUE><![CDATA[1]]></DEFAULTVALUE>
 <!--1792-->  <ISKEY><![CDATA[N]]></ISKEY>
@@ -279276,7 +279276,7 @@
 <!--87731FFC3B7145BABDD2C6A030450A99-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--87731FFC3B7145BABDD2C6A030450A99-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--87731FFC3B7145BABDD2C6A030450A99-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--87731FFC3B7145BABDD2C6A030450A99-->  <POSITION><![CDATA[39]]></POSITION>
+<!--87731FFC3B7145BABDD2C6A030450A99-->  <POSITION><![CDATA[38]]></POSITION>
 <!--87731FFC3B7145BABDD2C6A030450A99-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--87731FFC3B7145BABDD2C6A030450A99-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--87731FFC3B7145BABDD2C6A030450A99-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -280639,6 +280639,43 @@
 <!--8B2E63CA996311DD9BA3001D09C4A2FE-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--8B2E63CA996311DD9BA3001D09C4A2FE--></AD_COLUMN>
 
+<!--8B434D9D1B7B4757B66B35C9940FFA9D--><AD_COLUMN>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_COLUMN_ID><![CDATA[8B434D9D1B7B4757B66B35C9940FFA9D]]></AD_COLUMN_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <NAME><![CDATA[Grant_Portal_Access]]></NAME>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <DESCRIPTION><![CDATA[Grants to this user access to portal]]></DESCRIPTION>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <HELP><![CDATA[Grants to this user access to one of the available portal roles and resets the password for this user.]]></HELP>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <COLUMNNAME><![CDATA[Grant_Portal_Access]]></COLUMNNAME>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_TABLE_ID><![CDATA[114]]></AD_TABLE_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_REFERENCE_ID><![CDATA[28]]></AD_REFERENCE_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <SEQNO><![CDATA[121]]></SEQNO>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_ELEMENT_ID><![CDATA[20FFC00DFEFE4868B65A09EBFEBF022D]]></AD_ELEMENT_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <POSITION><![CDATA[39]]></POSITION>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D-->  <EM_OBUIAPP_PROCESS_ID><![CDATA[97FFD59B991D49BFB5153C309B009272]]></EM_OBUIAPP_PROCESS_ID>
+<!--8B434D9D1B7B4757B66B35C9940FFA9D--></AD_COLUMN>
+
 <!--8B53A1513DB3DD41E040007F01011767--><AD_COLUMN>
 <!--8B53A1513DB3DD41E040007F01011767-->  <AD_COLUMN_ID><![CDATA[8B53A1513DB3DD41E040007F01011767]]></AD_COLUMN_ID>
 <!--8B53A1513DB3DD41E040007F01011767-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -313626,6 +313663,40 @@
 <!--EE8A77D46BED44A29CE8A3584B7924AF-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--EE8A77D46BED44A29CE8A3584B7924AF--></AD_COLUMN>
 
+<!--EECD6A394731478384E40BB783D4FC6D--><AD_COLUMN>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_COLUMN_ID><![CDATA[EECD6A394731478384E40BB783D4FC6D]]></AD_COLUMN_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <NAME><![CDATA[Modify]]></NAME>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <COLUMNNAME><![CDATA[Ismodify]]></COLUMNNAME>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_TABLE_ID><![CDATA[270]]></AD_TABLE_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <SEQNO><![CDATA[111]]></SEQNO>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_ELEMENT_ID><![CDATA[B1F585B76FE045F382BCC513B4C34B6E]]></AD_ELEMENT_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <POSITION><![CDATA[51]]></POSITION>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--EECD6A394731478384E40BB783D4FC6D-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--EECD6A394731478384E40BB783D4FC6D--></AD_COLUMN>
+
 <!--EF00CB8D2A6C4724AD902C18A5964BDE--><AD_COLUMN>
 <!--EF00CB8D2A6C4724AD902C18A5964BDE-->  <AD_COLUMN_ID><![CDATA[EF00CB8D2A6C4724AD902C18A5964BDE]]></AD_COLUMN_ID>
 <!--EF00CB8D2A6C4724AD902C18A5964BDE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -21134,6 +21134,20 @@
 <!--20D54DC47FFA4A80AFA6063D303A7715-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--20D54DC47FFA4A80AFA6063D303A7715--></AD_ELEMENT>
 
+<!--20FFC00DFEFE4868B65A09EBFEBF022D--><AD_ELEMENT>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <AD_ELEMENT_ID><![CDATA[20FFC00DFEFE4868B65A09EBFEBF022D]]></AD_ELEMENT_ID>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <COLUMNNAME><![CDATA[Grant_Portal_Access]]></COLUMNNAME>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <NAME><![CDATA[Grant Portal Access]]></NAME>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <PRINTNAME><![CDATA[Grant Portal Access]]></PRINTNAME>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <DESCRIPTION><![CDATA[Grants to this user access to portal]]></DESCRIPTION>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <HELP><![CDATA[Grants to this user access to one of the available portal roles and resets the password for this user.]]></HELP>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--20FFC00DFEFE4868B65A09EBFEBF022D--></AD_ELEMENT>
+
 <!--227C67C05861481E803697C2153404AA--><AD_ELEMENT>
 <!--227C67C05861481E803697C2153404AA-->  <AD_ELEMENT_ID><![CDATA[227C67C05861481E803697C2153404AA]]></AD_ELEMENT_ID>
 <!--227C67C05861481E803697C2153404AA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -29089,6 +29103,18 @@
 <!--B1EB4BB84F52592AE040A8C028010F07-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--B1EB4BB84F52592AE040A8C028010F07--></AD_ELEMENT>
 
+<!--B1F585B76FE045F382BCC513B4C34B6E--><AD_ELEMENT>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <AD_ELEMENT_ID><![CDATA[B1F585B76FE045F382BCC513B4C34B6E]]></AD_ELEMENT_ID>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <COLUMNNAME><![CDATA[Ismodify]]></COLUMNNAME>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <NAME><![CDATA[Modify]]></NAME>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <PRINTNAME><![CDATA[Modify]]></PRINTNAME>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--B1F585B76FE045F382BCC513B4C34B6E-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--B1F585B76FE045F382BCC513B4C34B6E--></AD_ELEMENT>
+
 <!--B1FA47C8408A44F6A23CFE48F7E8EB3D--><AD_ELEMENT>
 <!--B1FA47C8408A44F6A23CFE48F7E8EB3D-->  <AD_ELEMENT_ID><![CDATA[B1FA47C8408A44F6A23CFE48F7E8EB3D]]></AD_ELEMENT_ID>
 <!--B1FA47C8408A44F6A23CFE48F7E8EB3D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -181618,7 +181618,7 @@
 <!--18A7B8734F4D4954A809EF7ED93BE54A-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--18A7B8734F4D4954A809EF7ED93BE54A-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--18A7B8734F4D4954A809EF7ED93BE54A-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--18A7B8734F4D4954A809EF7ED93BE54A-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--18A7B8734F4D4954A809EF7ED93BE54A-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--18A7B8734F4D4954A809EF7ED93BE54A-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--18A7B8734F4D4954A809EF7ED93BE54A-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--18A7B8734F4D4954A809EF7ED93BE54A-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -183782,7 +183782,7 @@
 <!--207E2426BEBA4F2CAAC4310C5032E89B-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--207E2426BEBA4F2CAAC4310C5032E89B-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--207E2426BEBA4F2CAAC4310C5032E89B-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--207E2426BEBA4F2CAAC4310C5032E89B-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--207E2426BEBA4F2CAAC4310C5032E89B-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--207E2426BEBA4F2CAAC4310C5032E89B-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--207E2426BEBA4F2CAAC4310C5032E89B-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--207E2426BEBA4F2CAAC4310C5032E89B-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -187821,7 +187821,7 @@
 <!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--2E6B68F1E15D4D328B3EE84FEF227D04-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -188186,7 +188186,7 @@
 <!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--2F678387E60745C1ABBC7BFCCDACF5CE-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -199159,7 +199159,7 @@
 <!--5392B9EB93884EAF85FDFBE3F8B60412-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--5392B9EB93884EAF85FDFBE3F8B60412-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--5392B9EB93884EAF85FDFBE3F8B60412-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--5392B9EB93884EAF85FDFBE3F8B60412-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--5392B9EB93884EAF85FDFBE3F8B60412-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--5392B9EB93884EAF85FDFBE3F8B60412-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--5392B9EB93884EAF85FDFBE3F8B60412-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--5392B9EB93884EAF85FDFBE3F8B60412-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -229050,7 +229050,7 @@
 <!--871C2B60A9374EF0BFF063B85896A94D-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--871C2B60A9374EF0BFF063B85896A94D-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--871C2B60A9374EF0BFF063B85896A94D-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--871C2B60A9374EF0BFF063B85896A94D-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--871C2B60A9374EF0BFF063B85896A94D-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--871C2B60A9374EF0BFF063B85896A94D-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--871C2B60A9374EF0BFF063B85896A94D-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--871C2B60A9374EF0BFF063B85896A94D-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -237878,7 +237878,7 @@
 <!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--9CA351D4BB3443C2A6E1B6F782DDAA63-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -242496,7 +242496,7 @@
 <!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--ADFD27F6CE6F4A9294F07437646ABCE0-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -256828,7 +256828,7 @@
 <!--C0A0F0B037094A51B5C8D862E07A6454-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--C0A0F0B037094A51B5C8D862E07A6454-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--C0A0F0B037094A51B5C8D862E07A6454-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--C0A0F0B037094A51B5C8D862E07A6454-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--C0A0F0B037094A51B5C8D862E07A6454-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--C0A0F0B037094A51B5C8D862E07A6454-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--C0A0F0B037094A51B5C8D862E07A6454-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--C0A0F0B037094A51B5C8D862E07A6454-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -257042,6 +257042,36 @@
 <!--C1409CCF75F7442FBAB156A0C175E19F-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--C1409CCF75F7442FBAB156A0C175E19F--></AD_FIELD>
 
+<!--C1953BF25C6A436AAA555742B4B254DE--><AD_FIELD>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <AD_FIELD_ID><![CDATA[C1953BF25C6A436AAA555742B4B254DE]]></AD_FIELD_ID>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <NAME><![CDATA[Grant Portal Access]]></NAME>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <DESCRIPTION><![CDATA[Grants to this user access to portal]]></DESCRIPTION>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <HELP><![CDATA[Grants to this user access to one of the available portal roles and resets the password for this user.]]></HELP>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <AD_TAB_ID><![CDATA[496]]></AD_TAB_ID>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <AD_COLUMN_ID><![CDATA[8B434D9D1B7B4757B66B35C9940FFA9D]]></AD_COLUMN_ID>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <DISPLAYLOGIC><![CDATA[@isPortalRolePresent@!0]]></DISPLAYLOGIC>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <SEQNO><![CDATA[240]]></SEQNO>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <GRID_SEQNO><![CDATA[0]]></GRID_SEQNO>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--C1953BF25C6A436AAA555742B4B254DE-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--C1953BF25C6A436AAA555742B4B254DE--></AD_FIELD>
+
 <!--C1C3F60280D611DDA899AF0F4F5119E1--><AD_FIELD>
 <!--C1C3F60280D611DDA899AF0F4F5119E1-->  <AD_FIELD_ID><![CDATA[C1C3F60280D611DDA899AF0F4F5119E1]]></AD_FIELD_ID>
 <!--C1C3F60280D611DDA899AF0F4F5119E1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -272152,7 +272182,7 @@
 <!--EE59928C5A3248CB90D38E1F53E7B345-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--EE59928C5A3248CB90D38E1F53E7B345-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--EE59928C5A3248CB90D38E1F53E7B345-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--EE59928C5A3248CB90D38E1F53E7B345-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--EE59928C5A3248CB90D38E1F53E7B345-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--EE59928C5A3248CB90D38E1F53E7B345-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--EE59928C5A3248CB90D38E1F53E7B345-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--EE59928C5A3248CB90D38E1F53E7B345-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -273027,7 +273057,7 @@
 <!--F0D8B508CD3C468B802DC57CFC905508-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--F0D8B508CD3C468B802DC57CFC905508-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--F0D8B508CD3C468B802DC57CFC905508-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--F0D8B508CD3C468B802DC57CFC905508-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--F0D8B508CD3C468B802DC57CFC905508-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--F0D8B508CD3C468B802DC57CFC905508-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--F0D8B508CD3C468B802DC57CFC905508-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--F0D8B508CD3C468B802DC57CFC905508-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -274682,7 +274712,7 @@
 <!--F7422E9AD10144C787EF4AB1033AB446-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--F7422E9AD10144C787EF4AB1033AB446-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--F7422E9AD10144C787EF4AB1033AB446-->  <DISPLAYLENGTH><![CDATA[255]]></DISPLAYLENGTH>
-<!--F7422E9AD10144C787EF4AB1033AB446-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--F7422E9AD10144C787EF4AB1033AB446-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--F7422E9AD10144C787EF4AB1033AB446-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--F7422E9AD10144C787EF4AB1033AB446-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--F7422E9AD10144C787EF4AB1033AB446-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
--- a/src-db/database/sourcedata/AD_MENU.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_MENU.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -1373,8 +1373,8 @@
 <!--307-->  <AD_MENU_ID><![CDATA[307]]></AD_MENU_ID>
 <!--307-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--307-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--307-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--307-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--307-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--307-->  <NAME><![CDATA[Reset Accounting Old]]></NAME>
 <!--307-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
 <!--307-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
 <!--307-->  <ACTION><![CDATA[P]]></ACTION>
@@ -4693,6 +4693,19 @@
 <!--C62EBC52C8DF463B9B720D52F250A8CF-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--C62EBC52C8DF463B9B720D52F250A8CF--></AD_MENU>
 
+<!--CC8E287A0B0743D69C53D8F678F9AD41--><AD_MENU>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_MENU_ID><![CDATA[CC8E287A0B0743D69C53D8F678F9AD41]]></AD_MENU_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <ACTION><![CDATA[P]]></ACTION>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41--></AD_MENU>
+
 <!--D13B4DBDCBF747BB9A91B17CBC6D1AA5--><AD_MENU>
 <!--D13B4DBDCBF747BB9A91B17CBC6D1AA5-->  <AD_MENU_ID><![CDATA[D13B4DBDCBF747BB9A91B17CBC6D1AA5]]></AD_MENU_ID>
 <!--D13B4DBDCBF747BB9A91B17CBC6D1AA5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -14607,6 +14607,17 @@
 <!--05B3B100FC1449908A9F42901B72185F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--05B3B100FC1449908A9F42901B72185F--></AD_MESSAGE>
 
+<!--060D241DDB65468BAEBB414B899DB599--><AD_MESSAGE>
+<!--060D241DDB65468BAEBB414B899DB599-->  <AD_MESSAGE_ID><![CDATA[060D241DDB65468BAEBB414B899DB599]]></AD_MESSAGE_ID>
+<!--060D241DDB65468BAEBB414B899DB599-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--060D241DDB65468BAEBB414B899DB599-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--060D241DDB65468BAEBB414B899DB599-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--060D241DDB65468BAEBB414B899DB599-->  <VALUE><![CDATA[Portal_UserGranted]]></VALUE>
+<!--060D241DDB65468BAEBB414B899DB599-->  <MSGTEXT><![CDATA[User has been successfully granted with the Portal Role and password has been reset. An email with credentials information has been sent to the user.]]></MSGTEXT>
+<!--060D241DDB65468BAEBB414B899DB599-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--060D241DDB65468BAEBB414B899DB599-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--060D241DDB65468BAEBB414B899DB599--></AD_MESSAGE>
+
 <!--0647DAB48B604FB99CE5AC4339762854--><AD_MESSAGE>
 <!--0647DAB48B604FB99CE5AC4339762854-->  <AD_MESSAGE_ID><![CDATA[0647DAB48B604FB99CE5AC4339762854]]></AD_MESSAGE_ID>
 <!--0647DAB48B604FB99CE5AC4339762854-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -14662,6 +14673,17 @@
 <!--090396763E4C41C99BEFF7BB82D03A41-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--090396763E4C41C99BEFF7BB82D03A41--></AD_MESSAGE>
 
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146--><AD_MESSAGE>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <AD_MESSAGE_ID><![CDATA[09E0CFCE33BA42D1A29CFF9F6E1A0146]]></AD_MESSAGE_ID>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <VALUE><![CDATA[ErrorInEmail]]></VALUE>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <MSGTEXT><![CDATA[Email couldn't be sent. %0]]></MSGTEXT>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--09E0CFCE33BA42D1A29CFF9F6E1A0146--></AD_MESSAGE>
+
 <!--0A04D7BA3A1D466A82B15AE10CFFE252--><AD_MESSAGE>
 <!--0A04D7BA3A1D466A82B15AE10CFFE252-->  <AD_MESSAGE_ID><![CDATA[0A04D7BA3A1D466A82B15AE10CFFE252]]></AD_MESSAGE_ID>
 <!--0A04D7BA3A1D466A82B15AE10CFFE252-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -14893,6 +14915,17 @@
 <!--10E779E8F227496B86B3136A09EB6043-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--10E779E8F227496B86B3136A09EB6043--></AD_MESSAGE>
 
+<!--110CD48D1DE14238AD30B6E1CB388B32--><AD_MESSAGE>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <AD_MESSAGE_ID><![CDATA[110CD48D1DE14238AD30B6E1CB388B32]]></AD_MESSAGE_ID>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <VALUE><![CDATA[Portal_PasswordChanged]]></VALUE>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <MSGTEXT><![CDATA[%0 Customer Portal – Password Changed]]></MSGTEXT>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--110CD48D1DE14238AD30B6E1CB388B32-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--110CD48D1DE14238AD30B6E1CB388B32--></AD_MESSAGE>
+
 <!--11314163807C4401B2964F93256597EA--><AD_MESSAGE>
 <!--11314163807C4401B2964F93256597EA-->  <AD_MESSAGE_ID><![CDATA[11314163807C4401B2964F93256597EA]]></AD_MESSAGE_ID>
 <!--11314163807C4401B2964F93256597EA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -16497,6 +16530,17 @@
 <!--3C038964A7A5479A822B42C2A1FE018C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--3C038964A7A5479A822B42C2A1FE018C--></AD_MESSAGE>
 
+<!--3C800651A0964C86BC535FCBA973A61B--><AD_MESSAGE>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <AD_MESSAGE_ID><![CDATA[3C800651A0964C86BC535FCBA973A61B]]></AD_MESSAGE_ID>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <VALUE><![CDATA[Portal_AccountCancelledSubject]]></VALUE>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <MSGTEXT><![CDATA[%0 Customer Portal – Account Expiration]]></MSGTEXT>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--3C800651A0964C86BC535FCBA973A61B-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--3C800651A0964C86BC535FCBA973A61B--></AD_MESSAGE>
+
 <!--3D3CCBA5FE3643C8BF38071DD57C6261--><AD_MESSAGE>
 <!--3D3CCBA5FE3643C8BF38071DD57C6261-->  <AD_MESSAGE_ID><![CDATA[3D3CCBA5FE3643C8BF38071DD57C6261]]></AD_MESSAGE_ID>
 <!--3D3CCBA5FE3643C8BF38071DD57C6261-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -17870,6 +17914,17 @@
 <!--6B8F2914B8BB4AE6891AE3E45CF79A57-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--6B8F2914B8BB4AE6891AE3E45CF79A57--></AD_MESSAGE>
 
+<!--6C26F9C7266749748F0B2DEE4B86CA1F--><AD_MESSAGE>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <AD_MESSAGE_ID><![CDATA[6C26F9C7266749748F0B2DEE4B86CA1F]]></AD_MESSAGE_ID>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <VALUE><![CDATA[DESC_EDITED]]></VALUE>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <MSGTEXT><![CDATA[Some accounting entries description has been modified. If you unpost the document you will lose the changes in the description.]]></MSGTEXT>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6C26F9C7266749748F0B2DEE4B86CA1F--></AD_MESSAGE>
+
 <!--6C48721B109F41ADB5C346CE329405EB--><AD_MESSAGE>
 <!--6C48721B109F41ADB5C346CE329405EB-->  <AD_MESSAGE_ID><![CDATA[6C48721B109F41ADB5C346CE329405EB]]></AD_MESSAGE_ID>
 <!--6C48721B109F41ADB5C346CE329405EB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -19474,6 +19529,17 @@
 <!--9DEDEDDC6E44428A8DC45444FCB9A1DD-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--9DEDEDDC6E44428A8DC45444FCB9A1DD--></AD_MESSAGE>
 
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7--><AD_MESSAGE>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <AD_MESSAGE_ID><![CDATA[9E28C2ECFB6F4EBEB05B90F4A71DBBC7]]></AD_MESSAGE_ID>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <VALUE><![CDATA[Portal_UserGrantedNoEmail]]></VALUE>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <MSGTEXT><![CDATA[There was an error sending the email to the user to notify about new credentials.]]></MSGTEXT>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--9E28C2ECFB6F4EBEB05B90F4A71DBBC7--></AD_MESSAGE>
+
 <!--9E7F116DBB424386BB82CCD76514D4EE--><AD_MESSAGE>
 <!--9E7F116DBB424386BB82CCD76514D4EE-->  <AD_MESSAGE_ID><![CDATA[9E7F116DBB424386BB82CCD76514D4EE]]></AD_MESSAGE_ID>
 <!--9E7F116DBB424386BB82CCD76514D4EE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -20490,6 +20556,17 @@
 <!--BCB10A144F40465993D15709F8C057F2-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--BCB10A144F40465993D15709F8C057F2--></AD_MESSAGE>
 
+<!--BCC9F209EA734696A13FE9B7C5B60851--><AD_MESSAGE>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <AD_MESSAGE_ID><![CDATA[BCC9F209EA734696A13FE9B7C5B60851]]></AD_MESSAGE_ID>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <VALUE><![CDATA[Portal_UserWithoutEmail]]></VALUE>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <MSGTEXT><![CDATA[Please set first user's email to send the credentials once they are set.]]></MSGTEXT>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--BCC9F209EA734696A13FE9B7C5B60851-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--BCC9F209EA734696A13FE9B7C5B60851--></AD_MESSAGE>
+
 <!--BD222E1149554DAEA579AD5ECB7AD70F--><AD_MESSAGE>
 <!--BD222E1149554DAEA579AD5ECB7AD70F-->  <AD_MESSAGE_ID><![CDATA[BD222E1149554DAEA579AD5ECB7AD70F]]></AD_MESSAGE_ID>
 <!--BD222E1149554DAEA579AD5ECB7AD70F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -21053,6 +21130,17 @@
 <!--CFE6932D251A4631A5223E845D4A4891-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--CFE6932D251A4631A5223E845D4A4891--></AD_MESSAGE>
 
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA--><AD_MESSAGE>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <AD_MESSAGE_ID><![CDATA[CFFCDC177B244DBEAAA656CCF8E8C0AA]]></AD_MESSAGE_ID>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <VALUE><![CDATA[EmailConfigurationNotFound]]></VALUE>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <MSGTEXT><![CDATA[Email server is not configured.]]></MSGTEXT>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--CFFCDC177B244DBEAAA656CCF8E8C0AA--></AD_MESSAGE>
+
 <!--D0692F1D88A14444AC768A7C13785E03--><AD_MESSAGE>
 <!--D0692F1D88A14444AC768A7C13785E03-->  <AD_MESSAGE_ID><![CDATA[D0692F1D88A14444AC768A7C13785E03]]></AD_MESSAGE_ID>
 <!--D0692F1D88A14444AC768A7C13785E03-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -21541,6 +21629,17 @@
 <!--DF777D45AE3C4750A423C8B6C19B3AF0-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--DF777D45AE3C4750A423C8B6C19B3AF0--></AD_MESSAGE>
 
+<!--DFC014DED7A24F549320160632DD1FE5--><AD_MESSAGE>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <AD_MESSAGE_ID><![CDATA[DFC014DED7A24F549320160632DD1FE5]]></AD_MESSAGE_ID>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <VALUE><![CDATA[Portal_UserWelcomeSubject]]></VALUE>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <MSGTEXT><![CDATA[Welcome to the %0 Customer Portal]]></MSGTEXT>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--DFC014DED7A24F549320160632DD1FE5-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--DFC014DED7A24F549320160632DD1FE5--></AD_MESSAGE>
+
 <!--E0711757A1314E6C95581C889FD3E3A3--><AD_MESSAGE>
 <!--E0711757A1314E6C95581C889FD3E3A3-->  <AD_MESSAGE_ID><![CDATA[E0711757A1314E6C95581C889FD3E3A3]]></AD_MESSAGE_ID>
 <!--E0711757A1314E6C95581C889FD3E3A3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -21828,6 +21927,17 @@
 <!--E8E6AAC0FDFE4761A99130A4D945D95A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--E8E6AAC0FDFE4761A99130A4D945D95A--></AD_MESSAGE>
 
+<!--EA1F44C7C18C426DA88E24606F6B4962--><AD_MESSAGE>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <AD_MESSAGE_ID><![CDATA[EA1F44C7C18C426DA88E24606F6B4962]]></AD_MESSAGE_ID>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <VALUE><![CDATA[Portal_ErrorGrantingPortalAccess]]></VALUE>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <MSGTEXT><![CDATA[There was an error while granting access to portal. %0]]></MSGTEXT>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--EA1F44C7C18C426DA88E24606F6B4962-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--EA1F44C7C18C426DA88E24606F6B4962--></AD_MESSAGE>
+
 <!--EA5B6DBA836D479FBECFD34D6CEE95DC--><AD_MESSAGE>
 <!--EA5B6DBA836D479FBECFD34D6CEE95DC-->  <AD_MESSAGE_ID><![CDATA[EA5B6DBA836D479FBECFD34D6CEE95DC]]></AD_MESSAGE_ID>
 <!--EA5B6DBA836D479FBECFD34D6CEE95DC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -4184,6 +4184,18 @@
 <!--BAA507E4C79F498DE040007F010077E2-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--BAA507E4C79F498DE040007F010077E2--></AD_MODEL_OBJECT>
 
+<!--BB0F6F0167694601A4D521F13B5D4F1E--><AD_MODEL_OBJECT>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_MODEL_OBJECT_ID><![CDATA[BB0F6F0167694601A4D521F13B5D4F1E]]></AD_MODEL_OBJECT_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <ACTION><![CDATA[P]]></ACTION>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.ad_process.ResetAccountingProcess]]></CLASSNAME>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--BB0F6F0167694601A4D521F13B5D4F1E--></AD_MODEL_OBJECT>
+
 <!--BB540F2CEA514936B5E60216ACE844B3--><AD_MODEL_OBJECT>
 <!--BB540F2CEA514936B5E60216ACE844B3-->  <AD_MODEL_OBJECT_ID><![CDATA[BB540F2CEA514936B5E60216ACE844B3]]></AD_MODEL_OBJECT_ID>
 <!--BB540F2CEA514936B5E60216ACE844B3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -1243,9 +1243,9 @@
 <!--176-->  <AD_PROCESS_ID><![CDATA[176]]></AD_PROCESS_ID>
 <!--176-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--176-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--176-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--176-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
 <!--176-->  <VALUE><![CDATA[Fact_Acct_Reset DELETE]]></VALUE>
-<!--176-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--176-->  <NAME><![CDATA[Reset Accounting Old]]></NAME>
 <!--176-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
 <!--176-->  <HELP><![CDATA[The reset accounting process allows to totally or partially remove the ledger entries of an organization. The ledger entries can be massively re-created again by using the "Accounting Server Process" or the "G/L Posting by DB Tables" process. ]]></HELP>
 <!--176-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
@@ -6446,6 +6446,28 @@
 <!--DFC78024B1F54CBB95DC73425BA6687F-->  <PREVENTCONCURRENT><![CDATA[N]]></PREVENTCONCURRENT>
 <!--DFC78024B1F54CBB95DC73425BA6687F--></AD_PROCESS>
 
+<!--E264309FF8244A94936502BF51829109--><AD_PROCESS>
+<!--E264309FF8244A94936502BF51829109-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--E264309FF8244A94936502BF51829109-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E264309FF8244A94936502BF51829109-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E264309FF8244A94936502BF51829109-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E264309FF8244A94936502BF51829109-->  <VALUE><![CDATA[Reset Accounting]]></VALUE>
+<!--E264309FF8244A94936502BF51829109-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--E264309FF8244A94936502BF51829109-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
+<!--E264309FF8244A94936502BF51829109-->  <HELP><![CDATA[The reset accounting process allows to totally or partially remove the ledger entries of an organization. The ledger entries can be massively re-created again by using the "Accounting Server Process" or the "G/L Posting by DB Tables" process. If some accounting entries description has been modified when running this process you will lose the changes in the description.]]></HELP>
+<!--E264309FF8244A94936502BF51829109-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
+<!--E264309FF8244A94936502BF51829109-->  <ISUSERSTARTABLE><![CDATA[N]]></ISUSERSTARTABLE>
+<!--E264309FF8244A94936502BF51829109-->  <ISREPORT><![CDATA[N]]></ISREPORT>
+<!--E264309FF8244A94936502BF51829109-->  <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
+<!--E264309FF8244A94936502BF51829109-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--E264309FF8244A94936502BF51829109-->  <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--E264309FF8244A94936502BF51829109-->  <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
+<!--E264309FF8244A94936502BF51829109-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E264309FF8244A94936502BF51829109-->  <UIPATTERN><![CDATA[S]]></UIPATTERN>
+<!--E264309FF8244A94936502BF51829109-->  <ISADVANCEDFEATURE><![CDATA[N]]></ISADVANCEDFEATURE>
+<!--E264309FF8244A94936502BF51829109-->  <PREVENTCONCURRENT><![CDATA[N]]></PREVENTCONCURRENT>
+<!--E264309FF8244A94936502BF51829109--></AD_PROCESS>
+
 <!--E5BE98DCF4514A18B571F21183B397DD--><AD_PROCESS>
 <!--E5BE98DCF4514A18B571F21183B397DD-->  <AD_PROCESS_ID><![CDATA[E5BE98DCF4514A18B571F21183B397DD]]></AD_PROCESS_ID>
 <!--E5BE98DCF4514A18B571F21183B397DD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -4043,6 +4043,26 @@
 <!--208021A9537641BAB0AFC4294453D59F-->  <AD_ELEMENT_ID><![CDATA[275]]></AD_ELEMENT_ID>
 <!--208021A9537641BAB0AFC4294453D59F--></AD_PROCESS_PARA>
 
+<!--33829BDE12A849CE8CF9CBF773DE556A--><AD_PROCESS_PARA>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_PROCESS_PARA_ID><![CDATA[33829BDE12A849CE8CF9CBF773DE556A]]></AD_PROCESS_PARA_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <NAME><![CDATA[Table]]></NAME>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <DESCRIPTION><![CDATA[A dictionary table used for this tab that points to the database table.]]></DESCRIPTION>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <HELP><![CDATA[The Table indicates the table in which a field or fields reside.]]></HELP>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <SEQNO><![CDATA[30]]></SEQNO>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_REFERENCE_ID><![CDATA[18]]></AD_REFERENCE_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_REFERENCE_VALUE_ID><![CDATA[800022]]></AD_REFERENCE_VALUE_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <COLUMNNAME><![CDATA[AD_Table_ID]]></COLUMNNAME>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_ELEMENT_ID><![CDATA[126]]></AD_ELEMENT_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A--></AD_PROCESS_PARA>
+
 <!--3401DE925FBB4A3AAC72E914595E1C71--><AD_PROCESS_PARA>
 <!--3401DE925FBB4A3AAC72E914595E1C71-->  <AD_PROCESS_PARA_ID><![CDATA[3401DE925FBB4A3AAC72E914595E1C71]]></AD_PROCESS_PARA_ID>
 <!--3401DE925FBB4A3AAC72E914595E1C71-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4298,6 +4318,27 @@
 <!--83BBC36B706642A39448DD2342B291F3-->  <AD_ELEMENT_ID><![CDATA[800632]]></AD_ELEMENT_ID>
 <!--83BBC36B706642A39448DD2342B291F3--></AD_PROCESS_PARA>
 
+<!--959B501B597940E8AC00F9587D83CB2D--><AD_PROCESS_PARA>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_PROCESS_PARA_ID><![CDATA[959B501B597940E8AC00F9587D83CB2D]]></AD_PROCESS_PARA_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <NAME><![CDATA[Client]]></NAME>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <DESCRIPTION><![CDATA[Client for this installation.]]></DESCRIPTION>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <HELP><![CDATA[A Client is a company or a legal entity. You cannot share data between Clients.]]></HELP>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_VAL_RULE_ID><![CDATA[103]]></AD_VAL_RULE_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <COLUMNNAME><![CDATA[AD_Client_ID]]></COLUMNNAME>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <DEFAULTVALUE><![CDATA[@AD_Client_ID@]]></DEFAULTVALUE>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_ELEMENT_ID><![CDATA[102]]></AD_ELEMENT_ID>
+<!--959B501B597940E8AC00F9587D83CB2D--></AD_PROCESS_PARA>
+
 <!--97266E0DF6A24EC0BC6845B9E305F307--><AD_PROCESS_PARA>
 <!--97266E0DF6A24EC0BC6845B9E305F307-->  <AD_PROCESS_PARA_ID><![CDATA[97266E0DF6A24EC0BC6845B9E305F307]]></AD_PROCESS_PARA_ID>
 <!--97266E0DF6A24EC0BC6845B9E305F307-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4589,6 +4630,83 @@
 <!--E15C3460969D4583BD954308E715C5D4-->  <AD_ELEMENT_ID><![CDATA[800653]]></AD_ELEMENT_ID>
 <!--E15C3460969D4583BD954308E715C5D4--></AD_PROCESS_PARA>
 
+<!--EAE447CD0ACE4C3B9D037847B5B5571C--><AD_PROCESS_PARA>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_PROCESS_PARA_ID><![CDATA[EAE447CD0ACE4C3B9D037847B5B5571C]]></AD_PROCESS_PARA_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <NAME><![CDATA[Delete existing Accounting Entries]]></NAME>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <DESCRIPTION><![CDATA[The selected accounting entries will be deleted!  DANGEROUS !!!]]></DESCRIPTION>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <HELP><![CDATA[The selected accounting entries will be deleted!  DANGEROUS !!!]]></HELP>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <SEQNO><![CDATA[40]]></SEQNO>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <COLUMNNAME><![CDATA[DeletePosting]]></COLUMNNAME>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_ELEMENT_ID><![CDATA[1692]]></AD_ELEMENT_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C--></AD_PROCESS_PARA>
+
+<!--EC9EAD40499A41E6956E7A0DC9269E0A--><AD_PROCESS_PARA>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_PROCESS_PARA_ID><![CDATA[EC9EAD40499A41E6956E7A0DC9269E0A]]></AD_PROCESS_PARA_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <NAME><![CDATA[Starting Date]]></NAME>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <DESCRIPTION><![CDATA[A parameter stating the starting time range related to a specified request.]]></DESCRIPTION>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <HELP><![CDATA[The Date From indicates the starting date of a range.]]></HELP>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <SEQNO><![CDATA[50]]></SEQNO>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <COLUMNNAME><![CDATA[datefrom]]></COLUMNNAME>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_ELEMENT_ID><![CDATA[1581]]></AD_ELEMENT_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A--></AD_PROCESS_PARA>
+
+<!--F072C56439FA47418C156337644F3CB5--><AD_PROCESS_PARA>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_PROCESS_PARA_ID><![CDATA[F072C56439FA47418C156337644F3CB5]]></AD_PROCESS_PARA_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F072C56439FA47418C156337644F3CB5-->  <NAME><![CDATA[Organization]]></NAME>
+<!--F072C56439FA47418C156337644F3CB5-->  <DESCRIPTION><![CDATA[Organizational entity within client]]></DESCRIPTION>
+<!--F072C56439FA47418C156337644F3CB5-->  <HELP><![CDATA[An organization is a unit of your client or legal entity - examples are store, department. You can share data between organizations.]]></HELP>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_VAL_RULE_ID><![CDATA[4A2C613871134B76899BA0464F3CBF76]]></AD_VAL_RULE_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <COLUMNNAME><![CDATA[AD_Org_ID]]></COLUMNNAME>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F072C56439FA47418C156337644F3CB5-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_ELEMENT_ID><![CDATA[113]]></AD_ELEMENT_ID>
+<!--F072C56439FA47418C156337644F3CB5--></AD_PROCESS_PARA>
+
+<!--F6B5EF335B25411CA5499D224BA4C3F3--><AD_PROCESS_PARA>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_PROCESS_PARA_ID><![CDATA[F6B5EF335B25411CA5499D224BA4C3F3]]></AD_PROCESS_PARA_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <NAME><![CDATA[Ending Date]]></NAME>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <DESCRIPTION><![CDATA[A parameter stating the ending time range related for a specified request, query, etc.]]></DESCRIPTION>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <HELP><![CDATA[The Date To indicates the end date of a range (inclusive)]]></HELP>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <COLUMNNAME><![CDATA[dateto]]></COLUMNNAME>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_ELEMENT_ID><![CDATA[1582]]></AD_ELEMENT_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3--></AD_PROCESS_PARA>
+
 <!--F6C130E3B2DD4414A162FC6BA4F2808E--><AD_PROCESS_PARA>
 <!--F6C130E3B2DD4414A162FC6BA4F2808E-->  <AD_PROCESS_PARA_ID><![CDATA[F6C130E3B2DD4414A162FC6BA4F2808E]]></AD_PROCESS_PARA_ID>
 <!--F6C130E3B2DD4414A162FC6BA4F2808E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REFERENCE.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_REFERENCE.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -4629,6 +4629,18 @@
 <!--4452E6997DD14363AB4387B06939871A-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--4452E6997DD14363AB4387B06939871A--></AD_REFERENCE>
 
+<!--467CA50808444F9890E23536FDE10405--><AD_REFERENCE>
+<!--467CA50808444F9890E23536FDE10405-->  <AD_REFERENCE_ID><![CDATA[467CA50808444F9890E23536FDE10405]]></AD_REFERENCE_ID>
+<!--467CA50808444F9890E23536FDE10405-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--467CA50808444F9890E23536FDE10405-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--467CA50808444F9890E23536FDE10405-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--467CA50808444F9890E23536FDE10405-->  <NAME><![CDATA[Portal Role Selector]]></NAME>
+<!--467CA50808444F9890E23536FDE10405-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--467CA50808444F9890E23536FDE10405-->  <ISBASEREFERENCE><![CDATA[N]]></ISBASEREFERENCE>
+<!--467CA50808444F9890E23536FDE10405-->  <PARENTREFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></PARENTREFERENCE_ID>
+<!--467CA50808444F9890E23536FDE10405-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--467CA50808444F9890E23536FDE10405--></AD_REFERENCE>
+
 <!--47209D76F3EE4B6D84222C5BDF170AA2--><AD_REFERENCE>
 <!--47209D76F3EE4B6D84222C5BDF170AA2-->  <AD_REFERENCE_ID><![CDATA[47209D76F3EE4B6D84222C5BDF170AA2]]></AD_REFERENCE_ID>
 <!--47209D76F3EE4B6D84222C5BDF170AA2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -11809,6 +11809,17 @@
 <!--EA7231981AC74EBD97ADAD008C0C5530-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--EA7231981AC74EBD97ADAD008C0C5530--></AD_REF_LIST>
 
+<!--EB17F419F24C4F95B1ED8B5555B55CDF--><AD_REF_LIST>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <AD_REF_LIST_ID><![CDATA[EB17F419F24C4F95B1ED8B5555B55CDF]]></AD_REF_LIST_ID>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <VALUE><![CDATA[PortalContactEmail]]></VALUE>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <NAME><![CDATA[Portal Contact Email]]></NAME>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--EB17F419F24C4F95B1ED8B5555B55CDF--></AD_REF_LIST>
+
 <!--EB95653FBFD14F54BCA979E2A3AA0F0A--><AD_REF_LIST>
 <!--EB95653FBFD14F54BCA979E2A3AA0F0A-->  <AD_REF_LIST_ID><![CDATA[EB95653FBFD14F54BCA979E2A3AA0F0A]]></AD_REF_LIST_ID>
 <!--EB95653FBFD14F54BCA979E2A3AA0F0A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -11820,6 +11831,17 @@
 <!--EB95653FBFD14F54BCA979E2A3AA0F0A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--EB95653FBFD14F54BCA979E2A3AA0F0A--></AD_REF_LIST>
 
+<!--EBA343EA62C34016B8ACF2F24EF5C29D--><AD_REF_LIST>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <AD_REF_LIST_ID><![CDATA[EBA343EA62C34016B8ACF2F24EF5C29D]]></AD_REF_LIST_ID>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <VALUE><![CDATA[PortalURL]]></VALUE>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <NAME><![CDATA[Portal URL]]></NAME>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--EBA343EA62C34016B8ACF2F24EF5C29D--></AD_REF_LIST>
+
 <!--EC4EEB435A82481C8ACA229F31EA3F36--><AD_REF_LIST>
 <!--EC4EEB435A82481C8ACA229F31EA3F36-->  <AD_REF_LIST_ID><![CDATA[EC4EEB435A82481C8ACA229F31EA3F36]]></AD_REF_LIST_ID>
 <!--EC4EEB435A82481C8ACA229F31EA3F36-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_TABLE.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_TABLE.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -1321,6 +1321,7 @@
 <!--224-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--224-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--224-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E54B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--224-->  <ACCTDATE_COLUMN_ID><![CDATA[1635]]></ACCTDATE_COLUMN_ID>
 <!--224--></AD_TABLE>
 
 <!--225--><AD_TABLE>
@@ -1591,6 +1592,7 @@
 <!--259-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--259-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--259-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1D94B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--259-->  <ACCTDATE_COLUMN_ID><![CDATA[2183]]></ACCTDATE_COLUMN_ID>
 <!--259--></AD_TABLE>
 
 <!--260--><AD_TABLE>
@@ -2391,6 +2393,7 @@
 <!--318-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--318-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--318-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1D84B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--318-->  <ACCTDATE_COLUMN_ID><![CDATA[3508]]></ACCTDATE_COLUMN_ID>
 <!--318--></AD_TABLE>
 
 <!--319--><AD_TABLE>
@@ -2414,6 +2417,7 @@
 <!--319-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--319-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--319-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--319-->  <ACCTDATE_COLUMN_ID><![CDATA[3794]]></ACCTDATE_COLUMN_ID>
 <!--319--></AD_TABLE>
 
 <!--320--><AD_TABLE>
@@ -2459,6 +2463,7 @@
 <!--321-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--321-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--321-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--321-->  <ACCTDATE_COLUMN_ID><![CDATA[3552]]></ACCTDATE_COLUMN_ID>
 <!--321--></AD_TABLE>
 
 <!--322--><AD_TABLE>
@@ -2503,6 +2508,7 @@
 <!--323-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--323-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--323-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--323-->  <ACCTDATE_COLUMN_ID><![CDATA[3579]]></ACCTDATE_COLUMN_ID>
 <!--323--></AD_TABLE>
 
 <!--324--><AD_TABLE>
@@ -2548,6 +2554,7 @@
 <!--325-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--325-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--325-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--325-->  <ACCTDATE_COLUMN_ID><![CDATA[3608]]></ACCTDATE_COLUMN_ID>
 <!--325--></AD_TABLE>
 
 <!--326--><AD_TABLE>
@@ -2894,6 +2901,7 @@
 <!--392-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--392-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--392-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E44B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--392-->  <ACCTDATE_COLUMN_ID><![CDATA[4918]]></ACCTDATE_COLUMN_ID>
 <!--392--></AD_TABLE>
 
 <!--393--><AD_TABLE>
@@ -3068,6 +3076,7 @@
 <!--407-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--407-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--407-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E44B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--407-->  <ACCTDATE_COLUMN_ID><![CDATA[5253]]></ACCTDATE_COLUMN_ID>
 <!--407--></AD_TABLE>
 
 <!--408--><AD_TABLE>
@@ -3433,6 +3442,7 @@
 <!--472-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--472-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--472-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F84B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--472-->  <ACCTDATE_COLUMN_ID><![CDATA[6508]]></ACCTDATE_COLUMN_ID>
 <!--472--></AD_TABLE>
 
 <!--473--><AD_TABLE>
@@ -3456,6 +3466,7 @@
 <!--473-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--473-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--473-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F84B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--473-->  <ACCTDATE_COLUMN_ID><![CDATA[6524]]></ACCTDATE_COLUMN_ID>
 <!--473--></AD_TABLE>
 
 <!--475--><AD_TABLE>
@@ -3609,6 +3620,7 @@
 <!--486-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--486-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--486-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1FC4B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--486-->  <ACCTDATE_COLUMN_ID><![CDATA[6838]]></ACCTDATE_COLUMN_ID>
 <!--486--></AD_TABLE>
 
 <!--487--><AD_TABLE>
@@ -4305,6 +4317,7 @@
 <!--623-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--623-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--623-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F94B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--623-->  <ACCTDATE_COLUMN_ID><![CDATA[9859]]></ACCTDATE_COLUMN_ID>
 <!--623--></AD_TABLE>
 
 <!--800000--><AD_TABLE>
@@ -4673,6 +4686,7 @@
 <!--800019-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800019-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800019-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E64B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800019-->  <ACCTDATE_COLUMN_ID><![CDATA[800470]]></ACCTDATE_COLUMN_ID>
 <!--800019--></AD_TABLE>
 
 <!--800020--><AD_TABLE>
@@ -5227,6 +5241,7 @@
 <!--800060-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800060-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800060-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E24B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800060-->  <ACCTDATE_COLUMN_ID><![CDATA[801079]]></ACCTDATE_COLUMN_ID>
 <!--800060--></AD_TABLE>
 
 <!--800061--><AD_TABLE>
@@ -6532,6 +6547,7 @@
 <!--800168-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800168-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800168-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800168-->  <ACCTDATE_COLUMN_ID><![CDATA[802758]]></ACCTDATE_COLUMN_ID>
 <!--800168--></AD_TABLE>
 
 <!--800169--><AD_TABLE>
@@ -6669,6 +6685,7 @@
 <!--800176-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800176-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800176-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E64B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800176-->  <ACCTDATE_COLUMN_ID><![CDATA[802948]]></ACCTDATE_COLUMN_ID>
 <!--800176--></AD_TABLE>
 
 <!--800177--><AD_TABLE>
--- a/src-db/database/sourcedata/AD_TREENODE.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/AD_TREENODE.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -3351,7 +3351,7 @@
 <!--52118BF1A3614D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A3614D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A3614D84E040007F01005FEC-->  <PARENT_ID><![CDATA[0]]></PARENT_ID>
-<!--52118BF1A3614D84E040007F01005FEC-->  <SEQNO><![CDATA[170]]></SEQNO>
+<!--52118BF1A3614D84E040007F01005FEC-->  <SEQNO><![CDATA[180]]></SEQNO>
 <!--52118BF1A3614D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A3624D84E040007F01005FEC--><AD_TREENODE>
@@ -3593,7 +3593,7 @@
 <!--52118BF1A3784D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A3784D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A3784D84E040007F01005FEC-->  <PARENT_ID><![CDATA[0]]></PARENT_ID>
-<!--52118BF1A3784D84E040007F01005FEC-->  <SEQNO><![CDATA[180]]></SEQNO>
+<!--52118BF1A3784D84E040007F01005FEC-->  <SEQNO><![CDATA[190]]></SEQNO>
 <!--52118BF1A3784D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A3794D84E040007F01005FEC--><AD_TREENODE>
@@ -3746,7 +3746,7 @@
 <!--52118BF1A5C94D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A5C94D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A5C94D84E040007F01005FEC-->  <PARENT_ID><![CDATA[0]]></PARENT_ID>
-<!--52118BF1A5C94D84E040007F01005FEC-->  <SEQNO><![CDATA[160]]></SEQNO>
+<!--52118BF1A5C94D84E040007F01005FEC-->  <SEQNO><![CDATA[170]]></SEQNO>
 <!--52118BF1A5C94D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A5CA4D84E040007F01005FEC--><AD_TREENODE>
@@ -4046,6 +4046,17 @@
 <!--8CB53124C58211DDB9A9001D09C4A2FE-->  <SEQNO><![CDATA[50]]></SEQNO>
 <!--8CB53124C58211DDB9A9001D09C4A2FE--></AD_TREENODE>
 
+<!--8E286E545FC6433F8BADCF02254A8C14--><AD_TREENODE>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_TREENODE_ID><![CDATA[8E286E545FC6433F8BADCF02254A8C14]]></AD_TREENODE_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <NODE_ID><![CDATA[CC8E287A0B0743D69C53D8F678F9AD41]]></NODE_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <PARENT_ID><![CDATA[800254]]></PARENT_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--8E286E545FC6433F8BADCF02254A8C14--></AD_TREENODE>
+
 <!--A14B428C6EF34B70B51C278E26BFDD43--><AD_TREENODE>
 <!--A14B428C6EF34B70B51C278E26BFDD43-->  <AD_TREENODE_ID><![CDATA[A14B428C6EF34B70B51C278E26BFDD43]]></AD_TREENODE_ID>
 <!--A14B428C6EF34B70B51C278E26BFDD43-->  <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<data>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB--><OBCLKER_TEMPLATE>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <OBCLKER_TEMPLATE_ID><![CDATA[A61FEA84D87A4A95A0CCCFA6FAFE53DB]]></OBCLKER_TEMPLATE_ID>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <NAME><![CDATA[New Portal User Email Body]]></NAME>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <TEMPLATECLASSPATHLOCATION><![CDATA[/org/openbravo/portal/templates/email-new-user.ftl]]></TEMPLATECLASSPATHLOCATION>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <TEMPLATE_LANGUAGE><![CDATA[OBCLFRE_Freemarker]]></TEMPLATE_LANGUAGE>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <COMPONENT_TYPE><![CDATA[OBSERDS_Datasource]]></COMPONENT_TYPE>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A61FEA84D87A4A95A0CCCFA6FAFE53DB--></OBCLKER_TEMPLATE>
+
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7--><OBCLKER_TEMPLATE>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <OBCLKER_TEMPLATE_ID><![CDATA[E5D5653B19734DA5AE3BEB7019B3D1E7]]></OBCLKER_TEMPLATE_ID>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <NAME><![CDATA[Account Cancelled Email Body]]></NAME>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <TEMPLATECLASSPATHLOCATION><![CDATA[/org/openbravo/portal/templates/email-account-cancelled.ftl]]></TEMPLATECLASSPATHLOCATION>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <TEMPLATE_LANGUAGE><![CDATA[OBCLFRE_Freemarker]]></TEMPLATE_LANGUAGE>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <COMPONENT_TYPE><![CDATA[OBSERDS_Datasource]]></COMPONENT_TYPE>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E5D5653B19734DA5AE3BEB7019B3D1E7--></OBCLKER_TEMPLATE>
+
+</data>
--- a/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -149,6 +149,26 @@
 <!--A079FC63513445C1BBD1FAE0B92C59DD-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
 <!--A079FC63513445C1BBD1FAE0B92C59DD--></OBUIAPP_PARAMETER>
 
+<!--C09B482527EC4D93B3E41CE7F37F3F57--><OBUIAPP_PARAMETER>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <OBUIAPP_PARAMETER_ID><![CDATA[C09B482527EC4D93B3E41CE7F37F3F57]]></OBUIAPP_PARAMETER_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <NAME><![CDATA[Portal Role]]></NAME>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <AD_REFERENCE_VALUE_ID><![CDATA[467CA50808444F9890E23536FDE10405]]></AD_REFERENCE_VALUE_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <COLUMNNAME><![CDATA[portalRole]]></COLUMNNAME>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <ISCENTRALLYMAINTAINED><![CDATA[N]]></ISCENTRALLYMAINTAINED>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <OBUIAPP_PROCESS_ID><![CDATA[97FFD59B991D49BFB5153C309B009272]]></OBUIAPP_PROCESS_ID>
+<!--C09B482527EC4D93B3E41CE7F37F3F57-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--C09B482527EC4D93B3E41CE7F37F3F57--></OBUIAPP_PARAMETER>
+
 <!--EBAC5A44ECF3491A9B4281C8902A3B02--><OBUIAPP_PARAMETER>
 <!--EBAC5A44ECF3491A9B4281C8902A3B02-->  <OBUIAPP_PARAMETER_ID><![CDATA[EBAC5A44ECF3491A9B4281C8902A3B02]]></OBUIAPP_PARAMETER_ID>
 <!--EBAC5A44ECF3491A9B4281C8902A3B02-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -76,6 +76,23 @@
 <!--7372662B059D4E01A80E5599B500A2D2-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
 <!--7372662B059D4E01A80E5599B500A2D2--></OBUIAPP_PROCESS>
 
+<!--97FFD59B991D49BFB5153C309B009272--><OBUIAPP_PROCESS>
+<!--97FFD59B991D49BFB5153C309B009272-->  <OBUIAPP_PROCESS_ID><![CDATA[97FFD59B991D49BFB5153C309B009272]]></OBUIAPP_PROCESS_ID>
+<!--97FFD59B991D49BFB5153C309B009272-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--97FFD59B991D49BFB5153C309B009272-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--97FFD59B991D49BFB5153C309B009272-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--97FFD59B991D49BFB5153C309B009272-->  <VALUE><![CDATA[GrantPortalAccess]]></VALUE>
+<!--97FFD59B991D49BFB5153C309B009272-->  <NAME><![CDATA[Grant Portal Access]]></NAME>
+<!--97FFD59B991D49BFB5153C309B009272-->  <DESCRIPTION><![CDATA[Grants to this user access to portal]]></DESCRIPTION>
+<!--97FFD59B991D49BFB5153C309B009272-->  <HELP><![CDATA[Grants to this user access to one of the available portal roles and resets the password for this user.]]></HELP>
+<!--97FFD59B991D49BFB5153C309B009272-->  <ACCESSLEVEL><![CDATA[7]]></ACCESSLEVEL>
+<!--97FFD59B991D49BFB5153C309B009272-->  <CLASSNAME><![CDATA[org.openbravo.portal.GrantPortalAccessProcess]]></CLASSNAME>
+<!--97FFD59B991D49BFB5153C309B009272-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--97FFD59B991D49BFB5153C309B009272-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--97FFD59B991D49BFB5153C309B009272-->  <UIPATTERN><![CDATA[OBUIAPP_PickAndExecute]]></UIPATTERN>
+<!--97FFD59B991D49BFB5153C309B009272-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
+<!--97FFD59B991D49BFB5153C309B009272--></OBUIAPP_PROCESS>
+
 <!--A832A5DA28FB4BB391BDE883E928DFC5--><OBUIAPP_PROCESS>
 <!--A832A5DA28FB4BB391BDE883E928DFC5-->  <OBUIAPP_PROCESS_ID><![CDATA[A832A5DA28FB4BB391BDE883E928DFC5]]></OBUIAPP_PROCESS_ID>
 <!--A832A5DA28FB4BB391BDE883E928DFC5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUISEL_SELECTOR.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/OBUISEL_SELECTOR.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -84,6 +84,23 @@
 <!--2E64F551C7C4470C80C29DBA24B34A5F-->  <CUSTOM_QUERY><![CDATA[N]]></CUSTOM_QUERY>
 <!--2E64F551C7C4470C80C29DBA24B34A5F--></OBUISEL_SELECTOR>
 
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D--><OBUISEL_SELECTOR>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <OBUISEL_SELECTOR_ID><![CDATA[3F43145FED1B4EC08A4797BFCB4F1C6D]]></OBUISEL_SELECTOR_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <NAME><![CDATA[Portal Role Selector]]></NAME>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <AD_REFERENCE_ID><![CDATA[467CA50808444F9890E23536FDE10405]]></AD_REFERENCE_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <AD_TABLE_ID><![CDATA[156]]></AD_TABLE_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <AD_COLUMN_ID><![CDATA[531]]></AD_COLUMN_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <WHERECLAUSE><![CDATA[e.forPortalUsers=true]]></WHERECLAUSE>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <OBCLKER_TEMPLATE_ID><![CDATA[9314DE8599AD44E7BFC4CC50699042AB]]></OBCLKER_TEMPLATE_ID>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <SUGGESTIONTEXTMATCHSTYLE><![CDATA[startsWith]]></SUGGESTIONTEXTMATCHSTYLE>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <POPUPTEXTMATCHSTYLE><![CDATA[startsWith]]></POPUPTEXTMATCHSTYLE>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D-->  <CUSTOM_QUERY><![CDATA[N]]></CUSTOM_QUERY>
+<!--3F43145FED1B4EC08A4797BFCB4F1C6D--></OBUISEL_SELECTOR>
+
 <!--4028E61131FB4B1B0131FB5307F1000C--><OBUISEL_SELECTOR>
 <!--4028E61131FB4B1B0131FB5307F1000C-->  <OBUISEL_SELECTOR_ID><![CDATA[4028E61131FB4B1B0131FB5307F1000C]]></OBUISEL_SELECTOR_ID>
 <!--4028E61131FB4B1B0131FB5307F1000C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/referencedData/AD_USER.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src-db/database/sourcedata/referencedData/AD_USER.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -9,6 +9,7 @@
 <!--0-->  <SUPERVISOR_ID><![CDATA[100]]></SUPERVISOR_ID>
 <!--0-->  <USERNAME><![CDATA[System]]></USERNAME>
 <!--0-->  <ISLOCKED><![CDATA[N]]></ISLOCKED>
+<!--0-->  <GRANT_PORTAL_ACCESS><![CDATA[N]]></GRANT_PORTAL_ACCESS>
 <!--0--></AD_USER>
 
 <!--100--><AD_USER>
@@ -22,6 +23,7 @@
 <!--100-->  <FIRSTNAME><![CDATA[Openbravo]]></FIRSTNAME>
 <!--100-->  <USERNAME><![CDATA[Openbravo]]></USERNAME>
 <!--100-->  <ISLOCKED><![CDATA[N]]></ISLOCKED>
+<!--100-->  <GRANT_PORTAL_ACCESS><![CDATA[N]]></GRANT_PORTAL_ACCESS>
 <!--100--></AD_USER>
 
 </data>
--- a/src/build.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/build.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -13,7 +13,7 @@
  * 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) 2005-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2005-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s): Openbravo S.L.U.
  ************************************************************************
@@ -478,6 +478,9 @@
     <copy todir="${build}">
       <fileset dir="${basedir}" includes="**/*.hbm.xml" />
     </copy>
+    <copy todir="${build}">
+      <fileset dir="${basedir}" includes="**/*.ftl" />
+    </copy>
     <copy todir="${base.design}/design">
       <fileset dir="${basedir}" includes="**/*.xml" />
     </copy>
--- a/src/org/openbravo/authentication/AuthenticationManager.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/authentication/AuthenticationManager.java	Mon Mar 18 11:15:21 2013 +0100
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2001-2012 Openbravo S.L.U.
+ * Copyright (C) 2001-2013 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -19,6 +19,7 @@
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.StringUtils;
@@ -283,6 +284,12 @@
       dbSessionId = createDBSession(request, username, userId, successSessionType);
       if (setSession) {
         vars.setSessionValue("#AD_SESSION_ID", dbSessionId);
+        if (userId != null) {
+          HttpSession session = request.getSession(false);
+          if (session != null) {
+            session.setAttribute("#Authenticated_user", userId);
+          }
+        }
       }
     }
     return dbSessionId;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/email/EmailEventContentGenerator.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,92 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+
+package org.openbravo.email;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Classes implementing this interface will be listening to email events. In case the event is valid
+ * for them ({@link EmailEventContentGenerator#isValidEvent(String, Object)} returns
+ * <code>true</code>) they are in charge of generating the content for the email.
+ * 
+ * <code>event</code> in all methods is a <code>String</code> that identifies the event.
+ * 
+ * @author alostale
+ * @see EmailEventManager
+ * 
+ */
+public interface EmailEventContentGenerator {
+
+  /**
+   * Checks if an email should be generated for the <code>event</code>. Same class can be listening
+   * to several events.
+   * 
+   * @param event
+   *          Event to check
+   * @param data
+   *          Data the email will be generated for (this can also determine whether the email must
+   *          be sent)
+   * @return <code>true</code> if the email must be sent, <code>false</code> if not.
+   */
+  public boolean isValidEvent(String event, Object data);
+
+  /**
+   * Returns the email subject for the event and data.
+   */
+  public String getSubject(Object data, String event);
+
+  /**
+   * Returns the email body for the event and data.
+   */
+  public String getBody(Object data, String event);
+
+  /**
+   * Returns the type of content of the email. Tipically <code>"text/html; charset=utf-8"</code> or
+   * <code>"text/plain; charset=utf-8"</code>
+   */
+  public String getContentType();
+
+  /**
+   * When there are several classes listening to the same event, the order the emails are sent is
+   * based on this value.
+   * 
+   * @see EmailEventContentGenerator#preventsOthersExecution()
+   */
+  public int getPriority();
+
+  /**
+   * In case there are several classes listening to the same event, when this method returns
+   * <code>true</code>, other emails with lower priority that might exist, will not be sent.
+   * 
+   */
+  public boolean preventsOthersExecution();
+
+  /**
+   * Asynchronous emails are sent in a separate thread not waiting them to finish to continue the
+   * rest of the execution flow.
+   */
+  public boolean isAsynchronous();
+
+  /**
+   * Returns the list of files to be attached to the email. Return null for no attachments
+   */
+  public List<File> getAttachments(Object data, String event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/email/EmailEventException.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,39 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+
+package org.openbravo.email;
+
+/**
+ * Exception thrown in case of failure sending email.
+ * 
+ * @author asier
+ * @see EmailEventManager
+ * 
+ */
+public class EmailEventException extends Exception {
+  private static final long serialVersionUID = 1L;
+
+  public EmailEventException(String message) {
+    super(message);
+  }
+
+  public EmailEventException(Exception e) {
+    super(e);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/email/EmailEventManager.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,207 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+
+package org.openbravo.email;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.erpCommon.utility.poc.EmailManager;
+import org.openbravo.model.common.enterprise.EmailServerConfiguration;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.utils.FormatUtilities;
+
+/**
+ * This singleton class, is in charge of generating events to send emails.
+ * 
+ * @author asier
+ * @see EmailEventContentGenerator
+ * 
+ */
+@ApplicationScoped
+public class EmailEventManager {
+
+  private static final Logger log = Logger.getLogger(EmailEventManager.class);
+
+  @Inject
+  @Any
+  private Instance<EmailEventContentGenerator> emailGenerators;
+
+  /**
+   * This method is invoked when an event for sending emails is generated. It looks for all
+   * {@link EmailEventContentGenerator} classes listening to this event and generates an email using
+   * them.
+   * 
+   * @param event
+   *          Name of the event to send emails for
+   * @param recipient
+   *          Email address of the email's recipient
+   * @param data
+   *          Object that the EmailEventContentGenerator will receive to generate the email
+   * @return <code>true</code> in case at least one email has been sent
+   * @throws EmailEventException
+   *           is thrown in case of problems sending the email or getting the email server
+   *           configuration
+   * 
+   * @see EmailEventContentGenerator
+   */
+  public boolean sendEmail(String event, final String recipient, Object data)
+      throws EmailEventException {
+    // Retrieves the Email Server configuration
+    final EmailServerConfiguration mailConfig = getEmailConfiguration();
+
+    if (mailConfig == null) {
+      log.warn("Couldn't find email configuarion");
+      throw new EmailEventException(OBMessageUtils.getI18NMessage("EmailConfigurationNotFound",
+          null));
+    }
+
+    try {
+      final String username = mailConfig.getSmtpServerAccount();
+      final String password = FormatUtilities.encryptDecrypt(mailConfig.getSmtpServerPassword(),
+          false);
+      final String connSecurity = mailConfig.getSmtpConnectionSecurity();
+      final int port = mailConfig.getSmtpPort().intValue();
+      final String senderAddress = mailConfig.getSmtpServerSenderAddress();
+      final String host = mailConfig.getSmtpServer();
+      final boolean auth = mailConfig.isSMTPAuthentification();
+
+      boolean sent = false;
+      for (EmailEventContentGenerator gen : getEmailGenerators(event, data)) {
+        sent = true;
+        log.debug("sending email for event " + event + " with generator " + gen);
+
+        if (gen.isAsynchronous()) {
+          final String subject = gen.getSubject(data, event);
+          final String body = gen.getBody(data, event);
+          final String type = gen.getContentType();
+          final List<File> attachments = gen.getAttachments(data, event);
+          Thread thread = new Thread(new Runnable() {
+            @Override
+            public void run() {
+              try {
+                EmailManager.sendEmail(host, auth, username, password, connSecurity, port,
+                    senderAddress, recipient, null, null, null, subject, body, type, attachments,
+                    null, null);
+              } catch (Exception e) {
+                log.error(e.getMessage(), e);
+              }
+            }
+          });
+          thread.start();
+        } else {
+          EmailManager.sendEmail(host, auth, username, password, connSecurity, port, senderAddress,
+              recipient, null, null, null, gen.getSubject(data, event), gen.getBody(data, event),
+              gen.getContentType(), gen.getAttachments(data, event), null, null);
+        }
+      }
+      if (!sent) {
+        log.warn("No email generator found for event " + event);
+      }
+      return sent;
+    } catch (Exception e) {
+      log.error(e.getMessage(), e);
+      throw new EmailEventException(e);
+    }
+  }
+
+  private List<EmailEventContentGenerator> getEmailGenerators(String event, Object data) {
+    // find valid events
+    List<EmailEventContentGenerator> validGenerators = new ArrayList<EmailEventContentGenerator>();
+    Iterator<EmailEventContentGenerator> i = emailGenerators.iterator();
+    while (i.hasNext()) {
+      EmailEventContentGenerator gen = i.next();
+      if (gen.isValidEvent(event, data)) {
+        validGenerators.add(gen);
+      }
+    }
+
+    // sort them by priority
+    Collections.sort(validGenerators, new Comparator<EmailEventContentGenerator>() {
+      @Override
+      public int compare(EmailEventContentGenerator o1, EmailEventContentGenerator o2) {
+        return o1.getPriority() - o2.getPriority();
+      }
+    });
+
+    // if some of them prevents following execution, stop chain
+    List<EmailEventContentGenerator> generators = new ArrayList<EmailEventContentGenerator>();
+    for (EmailEventContentGenerator gen : validGenerators) {
+      generators.add(gen);
+      if (gen.preventsOthersExecution()) {
+        break;
+      }
+    }
+
+    return generators;
+  }
+
+  /**
+   * First search for the current organization (and use the first returned one), then for
+   * organization '0' (and use the first returned one) and then for any other of the organization
+   * tree where current organization belongs to (and use the first returned one)
+   */
+  private EmailServerConfiguration getEmailConfiguration() {
+    // TODO: this should be centralized and improved, see issue #23198
+
+    Organization currenctOrg = OBContext.getOBContext().getCurrentOrganization();
+    EmailServerConfiguration mailConfig = null;
+
+    OBCriteria<EmailServerConfiguration> mailConfigCriteria = OBDal.getInstance().createCriteria(
+        EmailServerConfiguration.class);
+    mailConfigCriteria.addOrderBy("client.id", false);
+    final List<EmailServerConfiguration> mailConfigList = mailConfigCriteria.list();
+
+    if (mailConfigList.size() == 0) {
+      return null;
+    }
+    for (EmailServerConfiguration currentOrgConfig : mailConfigList) {
+      if (currenctOrg.getId().equals(currentOrgConfig.getOrganization().getId())) {
+        mailConfig = currentOrgConfig;
+        break;
+      }
+    }
+    if (mailConfig == null) {
+      for (EmailServerConfiguration zeroOrgConfig : mailConfigList) {
+        if ("0".equals(zeroOrgConfig.getOrganization().getId())) {
+          mailConfig = zeroOrgConfig;
+          break;
+        }
+      }
+    }
+    if (mailConfig == null) {
+      mailConfig = mailConfigList.get(0);
+    }
+    return mailConfig;
+  }
+}
--- a/src/org/openbravo/erpCommon/ad_actionButton/Posted.html	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/Posted.html	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -26,6 +26,7 @@
   <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
   <script language="JavaScript" src="../../../../../web/js/ajax.js" type="text/javascript"></script>
   <script language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></script>
+  <script language="JavaScript" src="../../../../../web/js/default/MessageBox.js" type="text/javascript"></script>
   <script language="JavaScript" type="text/javascript" id="paramLanguage">defaultLang = "en_US";</script>
   <script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
   <script language="JavaScript" src="../../../../../web/js/appStatus.js" type="text/javascript"></script>
@@ -45,22 +46,43 @@
     return true;
   }
   </script>
-	<script language="JavaScript" type="text/javascript">
-	function onLoadDo(){
-	    setProcessingMode('popup', false);
-		this.windowTables = new Array(
-		  new windowTableId('client', 'buttonOK')
-		);
-		setWindowTableParentElement();
-		enableShortcuts('popup');
-		setBrowserAutoComplete(false);
+    <script language="JavaScript" type="text/javascript">
+    function onLoadDo(){
+        setProcessingMode('popup', false);
+        this.windowTables = new Array(
+          new windowTableId('client', 'buttonOK')
+        );
+        setWindowTableParentElement();
+        enableShortcuts('popup');
+        setBrowserAutoComplete(false);
 
-		setWindowElementFocus('firstElement');
-	}
+        setWindowElementFocus('firstElement');
+    }
 
-	function onResizeDo(){
-	}
-	</script>
+    function onResizeDo(){
+    }
+    function descFactAcct(){
+         var frm = document.frmMain;
+         if (frm.inpdelete.value===""){
+             frm.inpdelete.value="Y";  
+         }
+         if ((frm.inpmodify.value==="Y") && (frm.inpdelete.value==="Y")){
+             showJSMessage('DESC_EDITED');
+         }
+         else{
+             document.getElementById("messageBoxID").setAttribute("class", "MessageBoxHIDDEN");
+         }
+         if (frm.inpdelete.value==="Y"){
+             frm.inpdelete.value="N";   
+         }   
+         else{
+             frm.inpdelete.value="Y";   
+         }   
+    }
+    
+    
+    
+    </script>
 </head>
 
 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="onLoadDo();" onresize="onResizeDo();">
@@ -76,7 +98,8 @@
   <input type="hidden" name="inpProcessId" value="" id="paramProcess"></input> 
   <input type="hidden" name="inpPath" value="" id="paramPath"></input>
   <input type="hidden" name="inpTabName" value="" id="paramTabName"></input>
-
+  <input type="hidden" name="inpmodify" value="" id="modify"></input>
+    <input type="hidden" name="inpdelete" value="" id="modify"></input>
   <div class="Popup_ContentPane_CircleLogo">
     <div class="Popup_WindowLogo">
       <img class="Popup_WindowLogo_Icon Popup_WindowLogo_Icon_process" src="../../../../../web/images/blank.gif" border=0/></img>
@@ -126,7 +149,108 @@
         </table>
       </td>
     </tr>
+    <tr>
+    <td>
+     <table cellpadding="0" cellspacing="0" id="messageBoxID" class="MessageBoxyy">
+            <tbody>
+            <tr class="MessageBox_TopMargin">
+              <td class="MessageBox_LeftMargin"></td>
+              <td></td>
+              <td class="MessageBox_RightMargin"></td>
+            </tr>
+            <tr>
+              <td class="MessageBox_LeftMargin"></td>
+              <td>
 
+                <table cellpadding="0" cellspacing="0" class="MessageBox_Container">
+                  <tbody>
+                  <tr>
+                    <td class="MessageBox_LeftTrans">
+                      <table style="width: 100%; height: 100%" cellpadding="0" cellspacing="0">
+                        <tbody>
+                        <tr>
+                          <td class="MessageBox_TopLeft"></td>
+                        </tr>
+                        <tr>
+                          <td class="MessageBox_Left"></td>
+                        </tr>
+                        </tbody>
+                      </table>
+                    </td>
+                    <td class="MessageBox_bg">
+
+                      <table class="MessageBox_Top">
+                      <tbody>
+                        <tr>
+                          <td>
+                            <span>
+                            <table cellpadding="0" cellspacing="0" class="MessageBox_Body_ContentCell">
+                              <tbody>
+                              <tr>
+                                <td class="MessageBox_Icon_ContentCell">
+                                  <div class="MessageBox_Icon"></div>
+                                </td>
+                                <td style="vertical-align: top;" id="messageBoxIDContent">
+                                  <span>
+                                    <div class="MessageBox_TextTitle" id="messageBoxIDTitle">
+                                      xxInfo: AccessTableWithNoView
+                                    </div>
+                                    <div class="MessageBox_TextDescription" id="messageBoxIDMessage">
+                                      xxThe current information is empty.
+                                    </div>
+                                    <div class="MessageBox_TextSeparator"></div>
+                                  </span>
+                                </td>
+                              </tr>
+                              </tbody>
+                            </table>
+                            </span>
+                          </td>
+                        </tr>
+                        </tbody>
+                      </table>
+
+                    </td>
+                    <td class="MessageBox_RightTrans">
+                      <table style="width: 100%; height: 100%" cellpadding="0" cellspacing="0">
+                        <tbody>
+                        <tr>
+                          <td class="MessageBox_TopRight"></td>
+                        </tr>
+                        <tr>
+                          <td class="MessageBox_Right"></td>
+                        </tr>
+                        </tbody>
+                      </table>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td rowspan="2" class="MessageBox_BottomLeft">
+                    </td>
+                    <td class="MessageBox_BottomTrans MessageBox_bg">
+                    </td>
+                    <td rowspan="2" class="MessageBox_BottomRight">
+                    </td>
+                  </tr>
+                  <tr>
+                    <td class="MessageBox_Bottom">
+                    </td>
+                  </tr>
+                  </tbody>
+                </table>
+
+              </td>
+              <td class="MessageBox_RightMargin"></td>
+            </tr>
+            <tr class="MessageBox_BottomMargin">
+              <td class="MessageBox_LeftMargin"></td>
+              <td></td>
+              <td class="MessageBox_RightMargin"></td>
+            </tr>
+            </tbody>
+          </table>
+    </td>
+    </tr>
     <tr>
       <td>
         <div class="Popup_ContentPane_Client" style="overflow: auto;" id="client">
@@ -143,7 +267,7 @@
               <td class="TitleCell">
                 <span class="LabelText" id="Delete_lbl">Delete accounting entry</span>
               <td colspan="3" class="Radio_Check_ContentCell">
-                <input type="checkbox" name="inpEliminar" value="Y"></input>
+                <input type="checkbox" name="inpEliminar"  value='Y' onchange="descFactAcct();" ></input>
               </td>
             </tr>
 
--- a/src/org/openbravo/erpCommon/ad_actionButton/Posted.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/Posted.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2012 Openbravo SLU
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -21,23 +21,26 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.sql.Connection;
+import java.util.HashMap;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.ad_forms.AcctServer;
-import org.openbravo.erpCommon.reference.ActionButtonData;
-import org.openbravo.erpCommon.reference.PInstanceProcessData;
 import org.openbravo.erpCommon.utility.OBError;
-import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.financial.ResetAccounting;
 import org.openbravo.model.ad.ui.Process;
+import org.openbravo.model.financialmgmt.accounting.AccountingFact;
 import org.openbravo.xmlEngine.XmlDocument;
 
 public class Posted extends HttpSecureAppServlet {
@@ -68,9 +71,21 @@
       String strForcedTableId = vars.getGlobalVariable("inpforcedTableId", strWindowId
           + "|FORCED_TABLE_ID", "");
       String strTabName = vars.getGlobalVariable("inpTabName", "Posted|tabName", "");
+      String strModify = "N";
+      if (strPosted.equals("Y")) {
+        final OBCriteria<AccountingFact> fact = OBDal.getInstance().createCriteria(
+            AccountingFact.class);
+        fact.add(Restrictions.eq(AccountingFact.PROPERTY_RECORDID, strKey));
+        for (AccountingFact fa : fact.list()) {
+          if (fa.isModify()) {
+            strModify = "Y";
+
+          }
+        }
+      }
 
       printPage(response, vars, strKey, strWindowId, strTabId, strProcessId, strTableId,
-          strForcedTableId, strPath, strTabName, strPosted);
+          strForcedTableId, strPath, strTabName, strPosted, strModify);
     } else if (vars.commandIn("SAVE")) {
       String strKey = vars.getRequiredGlobalVariable("inpKey", "Posted|key");
       String strTableId = vars.getRequiredGlobalVariable("inpTableId", "Posted|tableId");
@@ -206,7 +221,25 @@
         } else {
           if (log4j.isDebugEnabled())
             log4j.debug("SAVE, delete");
-          OBError myMessage = processButtonDelete(vars, strKey, strTableId);
+          Long inicio = System.currentTimeMillis();
+          OBError myMessage = new OBError();
+          myMessage.setType("Success");
+          PostedData[] data = PostedData.select(this, strKey, strTableId);
+          try {
+            HashMap<String, Integer> hm = ResetAccounting.delete(data[0].client, data[0].org,
+                strTableId, strKey, "", "");
+            myMessage.setMessage(Utility.parseTranslation(
+                this,
+                vars,
+                vars.getLanguage(),
+                "@UnpostedDocuments@ = " + hm.get("updated") + ", @DeletedEntries@ = "
+                    + hm.get("deleted")));
+          } catch (OBException e) {
+            myMessage.setType("Error");
+            myMessage.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(),
+                e.getMessage()));
+          }
+          System.out.println("Total deleting /milis: " + (System.currentTimeMillis() - inicio));
           vars.setMessage(strTabId, myMessage);
           printPageClosePopUp(response, vars);
         }
@@ -259,44 +292,9 @@
     return myMessage;
   }
 
-  private OBError processButtonDelete(VariablesSecureApp vars, String strKey, String strTableId)
-      throws ServletException {
-    OBError myMessage = null;
-
-    try {
-
-      String strClient = PostedData.selectClient(this,
-          PostedData.selectTableName(this, strTableId), strKey);
-      String pinstance = SequenceIdData.getUUID();
-      PInstanceProcessData.insertPInstance(this, pinstance, "176", strKey, "N", vars.getUser(),
-          vars.getClient(), vars.getOrg());
-      PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "AD_Client_ID", strClient,
-          vars.getClient(), vars.getOrg(), vars.getUser());
-      PInstanceProcessData.insertPInstanceParam(this, pinstance, "20", "AD_Table_ID", strTableId,
-          vars.getClient(), vars.getOrg(), vars.getUser());
-      PInstanceProcessData.insertPInstanceParam(this, pinstance, "30", "DeletePosting", "Y",
-          vars.getClient(), vars.getOrg(), vars.getUser());
-      if (log4j.isDebugEnabled())
-        log4j.debug("delete, pinstance " + pinstance);
-      ActionButtonData.process176(this, pinstance);
-
-      PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
-      myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
-    } catch (ServletException ex) {
-      myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
-    }
-    if (myMessage == null) {
-      myMessage = new OBError();
-      myMessage.setType("Success");
-      myMessage.setTitle("");
-      myMessage.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
-    }
-    return myMessage;
-  }
-
   private void printPage(HttpServletResponse response, VariablesSecureApp vars, String strKey,
       String windowId, String strTab, String strProcessId, String strTableId,
-      String strForcedTableId, String strPath, String strTabName, String strPosted)
+      String strForcedTableId, String strPath, String strTabName, String strPosted, String strModify)
       throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: Button process Posted");
@@ -347,6 +345,7 @@
     xmlDocument.setParameter("theme", vars.getTheme());
     xmlDocument.setParameter("description", strDescription);
     xmlDocument.setParameter("help", strHelp);
+    xmlDocument.setParameter("modify", strModify);
 
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
--- a/src/org/openbravo/erpCommon/ad_actionButton/Posted.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/Posted.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -40,5 +40,7 @@
 	<PARAMETER id="messageBoxID" name="messageType" attribute="class" replace="yy" default="HIDDEN"/>
 	<PARAMETER id="messageBoxIDTitle" name="messageTitle" default=""/>
 	<PARAMETER id="messageBoxIDMessage" name="messageMessage" default=""/>
+    <PARAMETER id="modify" name="modify"  attribute="value" default=""/>
 	<DISCARD id="discard"/>
 </REPORT>
+
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * 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) 2001-2012 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2013 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -29,6 +29,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.Vector;
 
 import javax.servlet.ServletException;
@@ -377,17 +378,13 @@
       log4j.debug("AcctServer.run - AD_Client_ID: " + AD_Client_ID);
 
       AcctServerData[] data = null;
+      final Set<String> orgSet = OBContext.getOBContext().getOrganizationStructureProvider()
+          .getChildTree(AD_Org_ID, true);
+      String strOrgs = Utility.getInStrSet(orgSet);
 
-      if ((strDateFrom == null && strDateTo == null)
-          || (strDateFrom.equals("") && strDateTo.equals(""))) {
-        data = AcctServerData.select(connectionProvider, tableName, AD_Client_ID, AD_Org_ID,
-            strDateColumn, 0, Integer.valueOf(batchSize).intValue());
-      } else {
+      data = AcctServerData.select(connectionProvider, tableName, strDateColumn, AD_Client_ID,
+          strOrgs, strDateFrom, strDateTo, 0, Integer.valueOf(batchSize).intValue());
 
-        data = AcctServerData.selectFilterDates(connectionProvider, tableName, AD_Client_ID,
-            AD_Org_ID, strDateColumn, strDateFrom, strDateTo);
-
-      }
       if (data != null && data.length > 0) {
         if (log4j.isDebugEnabled()) {
           log4j.debug("AcctServer - Run -Select inicial realizada N = " + data.length + " - Key: "
@@ -2089,16 +2086,33 @@
   }
 
   public boolean checkDocuments() throws ServletException {
+    return checkDocuments(null, null);
+  }
+
+  public boolean checkDocuments(String dateFrom, String dateTo) throws ServletException {
     if (m_as.length == 0)
       return false;
     AcctServerData[] docTypes = AcctServerData.selectDocTypes(connectionProvider, AD_Table_ID,
         AD_Client_ID);
     // if (log4j.isDebugEnabled())
     // log4j.debug("AcctServer - AcctSchema length-" + (this.m_as).length);
+    final Set<String> orgSet = OBContext.getOBContext().getOrganizationStructureProvider()
+        .getChildTree(AD_Org_ID, true);
+    String strorgs = Utility.getInStrSet(orgSet);
+
+    String rownum = "0", oraLimit1 = null, oraLimit2 = null, pgLimit = null;
+    if (connectionProvider.getRDBMS().equalsIgnoreCase("ORACLE")) {
+      oraLimit1 = "2";
+      oraLimit2 = "1 AND 2";
+      rownum = "ROWNUM";
+    } else {
+      pgLimit = "2";
+    }
+
     for (int i = 0; i < docTypes.length; i++) {
-      AcctServerData data = AcctServerData.selectDocuments(connectionProvider, tableName,
-          AD_Client_ID, AD_Org_ID, docTypes[i].name, strDateColumn);
-
+      AcctServerData data = AcctServerData.selectDocumentsDates(connectionProvider, rownum,
+          tableName, strDateColumn, AD_Client_ID, strorgs, docTypes[i].name, dateFrom, dateTo,
+          pgLimit, oraLimit1, oraLimit2);
       if (data != null) {
         if (data.id != null && !data.id.equals("")) {
           if (log4j.isDebugEnabled()) {
@@ -2119,6 +2133,7 @@
         AD_Client_ID);
     // if (log4j.isDebugEnabled())
     // log4j.debug("AcctServer - AcctSchema length-" + (this.m_as).length);
+
     for (int i = 0; i < docTypes.length; i++) {
       AcctServerData data = AcctServerData.filterDatesSelectDocuments(connectionProvider,
           tableName, AD_Client_ID, AD_Org_ID, docTypes[i].name, strDateColumn, dateFrom, dateTo);
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql	Mon Mar 18 11:15:21 2013 +0100
@@ -12,7 +12,7 @@
  * 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) 2001-2012 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2013 Openbravo S.L.U.
  ******************************************************************************
 -->
 
@@ -38,21 +38,24 @@
         '' 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 CONVERTED, '' AS PERIOD, '' AS C_INVOICELINE_ID,'' AS M_INOUTLINE_ID, '' AS M_PRODUCT_ID,
         '' AS DATETRX1, '' AS DATETRX2, '' AS QTY1, '' AS QTY2, '' AS ACCOUNT_ID, '' AS C_INVOICE_ID, '' AS NAME, '' AS CLASSNAME,
-        '' AS ACCTDATECOLUMN, '' AS TABLENAME, '' AS ACCTCLASSNAME, '' as ISREVERSAL, '' as ISRETURN
+        '' AS ACCTDATECOLUMN, '' AS TABLENAME, '' AS ACCTCLASSNAME, '' as ISREVERSAL, '' as ISRETURN,   a.DATEACCT as da, '' AS RN1
         FROM C_INVOICE a, ad_org WHERE a.AD_CLIENT_ID=?
-        AND ad_org.ad_org_id=a.ad_org_id
-        AND AD_ISORGINCLUDED(ad_org.ad_org_id, ?, ad_org.ad_client_id)<>-1
+        and a.ad_org_id in ('1')
         AND PROCESSED='Y'
         AND (PROCESSING='N' OR PROCESSING IS NULL)
         AND POSTED='N'
         ORDER BY a.CREATED) A
+        where 1=1
      ]]>
      </Sql>
      <Parameter name="tableName" type="replace" optional="true" after="SELECT  a." text="C_INVOICE"/>
+     <Parameter name="dateColumn" type="replace" optional="true" after=",   a." text="DATEACCT"/>
      <Parameter name="tableName" type="replace" optional="true" after="FROM " text="C_INVOICE"/>
      <Parameter name="client"/>
-     <Parameter name="org"/>
+     <Parameter name="StrOrg" type="replace" optional="true" after="a.ad_org_id in (" text="'1'"/>
      <Parameter name="dateColumn" type="replace" optional="true" after="ORDER BY a." text="CREATED"/>
+     <Parameter name="dateFrom" optional="true" after="where 1=1"><![CDATA[ AND a.da >= TO_DATE(?)]]></Parameter>
+     <Parameter name="dateTo" optional="true" after="where 1=1"><![CDATA[ AND a.da < TO_DATE(?)]]></Parameter>
    </SqlMethod>
   <SqlMethod name="update" type="preparedStatement" return="rowCount">
     <SqlMethodComment></SqlMethodComment>
@@ -520,7 +523,7 @@
       </Sql>
       <Parameter name="adUserClient" type="replace" optional="true" after="AD_Org.AD_Client_ID IN (" text="'1'"/>
    </SqlMethod>
-   <SqlMethod name="selectDocuments" type="preparedStatement" return="single">
+    <SqlMethod name="selectDocuments" type="preparedStatement" return="single">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
       <![CDATA[
@@ -552,6 +555,48 @@
       <Parameter name="dateColumn" type="replace" optional="true" after="and    a." text="dateacct"/>
       <Parameter name="dateColumn" type="replace" optional="true" after="and     a." text="dateacct"/>
    </SqlMethod>
+   <SqlMethod name="selectDocumentsDates" type="preparedStatement" return="single">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql>
+      <![CDATA[
+      select d.*
+      FROM ( SELECT '0' AS RN1, c.* 
+      FROM (                       
+          select min(id) as id, min(da) as da 
+          from (
+            select a.C_INVOICE_ID as id, a.dateacct as da, a.ad_client_id, a.ad_org_id
+            from   c_invoice a
+            where  a.ad_client_id = ?
+            and a.ad_org_id in ('1')
+            and a.posted = 'N'
+            and a.processed = 'Y'
+            and (a.processing = 'N' or a.processing is null)) b
+        where exists (select 1
+              from c_periodcontrol, c_period
+              where c_periodcontrol.c_period_id = c_period.c_period_id
+              and c_periodcontrol.docbasetype = ?
+              and c_periodcontrol.periodstatus = 'O'
+              and ad_org_getperiodcontrolallow(b.ad_org_id) = c_periodcontrol.ad_org_id
+              and b.da >= c_period.StartDate
+              and b.da < c_period.EndDate + 1)
+        and 1=1
+       )c ) d 
+        where 2=2
+      ]]>
+      </Sql>
+      <Parameter name="rownum" type="replace" optional="true" after="FROM ( SELECT " text="'0'" />
+      <Parameter name="tableName" type="replace" optional="true" after="select a." text="C_INVOICE"/>
+      <Parameter name="dateColumn" type="replace" optional="true" after="as id, a." text="dateacct"/>
+      <Parameter name="tableName" type="replace" optional="true" after="from   " text="c_invoice"/>
+      <Parameter name="adClientId" />
+      <Parameter name="StrOrg" type="replace" optional="true" after="a.ad_org_id in (" text="'1'"/>
+      <Parameter name="docbasetype"/>
+      <Parameter name="dateFrom" optional="true" after="and 1=1"><![CDATA[ AND b.da >= TO_DATE(?)]]></Parameter>
+      <Parameter name="dateTo" optional="true" after="and 1=1"><![CDATA[ AND b.da < TO_DATE(?)]]></Parameter>
+      <Parameter name="pgLimit" type="argument" optional="true" after="and 1=1"><![CDATA[LIMIT ]]></Parameter>
+      <Parameter name="oraLimit1" type="argument" optional="true" after=")c "><![CDATA[ WHERE ROWNUM <= ]]></Parameter>
+      <Parameter name="oraLimit2" type="argument" optional="true" after="where 2=2"><![CDATA[AND RN1 BETWEEN ]]></Parameter>
+   </SqlMethod>
    <SqlMethod name="filterDatesSelectDocuments" type="preparedStatement" return="single">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
--- a/src/org/openbravo/erpCommon/ad_forms/CallAcctServer.html	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/CallAcctServer.html	Mon Mar 18 11:15:21 2013 +0100
@@ -13,7 +13,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -34,52 +34,76 @@
 <script language="JavaScript" src="../../../../../web/js/shortcuts.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
-<script language="JavaScript" src="../../../../../web/js/appStatus.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/searchs.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/ajax.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/default/MessageBox.js" type="text/javascript"></script>
 <script language="JavaScript" src="../../../../../web/js/messages.js" type="text/javascript"></script>
 <script language="JavaScript" src="../utility/DynamicJS.js" type="text/javascript"></script>
+<script language="JavaScript" src="../../../../../web/js/jscalendar/calendar.js" type="text/javascript"></script>
+<script language="JavaScript" src="../../../../../web/js/jscalendar/lang/calendar-es.js" type="text/javascript" id="fieldCalendar"></script>
+<script language="JavaScript" src="../../../../../web/js/default/DateTextBox.js" type="text/javascript"></script>
+<script language="JavaScript" src="../../../../../web/js/dojoConfig.js" type="text/javascript"></script>
+<script language="JavaScript" src="../../../../../web/js/dojo/dojo.js" type="text/javascript"></script>
+<script language="JavaScript" src="../../../../../web/js/appStatus.js" type="text/javascript"></script>
+<script type="text/javascript"> 
+      //all dojo.require above this line
+      dojo.hostenv.writeIncludes(); //makes debugging in Venkman possible
+</script> 
+<script language="JavaScript" type="text/javascript">
+function validate(action)
+{
+    var frm = document.frmMain;
+    if (frm.inpdatefrom.value == null || frm.inpdatefrom.value == "") {
+        setWindowElementFocus(frm.inpdatefrom);
+        showJSMessage(7);
+        return false;
+    } else if (frm.inpdateto.value == null || frm.inpdateto.value == ""){
+        setWindowElementFocus(frm.inpdateto);
+        showJSMessage(7);
+        return false;
+    }
+    return true;
+}
+ 
 
 
-<script language="JavaScript" type="text/javascript">
 function onloadFunctions() {
 }
 </script>
-	<script language="JavaScript" type="text/javascript">
-	function onLoadDo(){
-		setProcessingMode('window',false);
-		this.windowTables = new Array(
-		  new windowTableId('client', 'buttonOK')
-		);
-		setWindowTableParentElement();
-		this.tabsTables = new Array(
-		  new tabTableId('tdtopTabs')
-		);
-		setTabTableParentElement();
-		enableShortcuts('edition');
-		setBrowserAutoComplete(false);
-		
-		try {
-		  onloadFunctions();
-		} catch (e) {}
-		resizeArea();
-		updateMenuIcon('buttonMenu');
-		xx();
+    <script language="JavaScript" type="text/javascript">
+    function onLoadDo(){
+        setProcessingMode('window',false);
+        this.windowTables = new Array(
+          new windowTableId('client', 'buttonOK')
+        );
+        setWindowTableParentElement();
+        this.tabsTables = new Array(
+          new tabTableId('tdtopTabs')
+        );
+        setTabTableParentElement();
+        enableShortcuts('edition');
+        setBrowserAutoComplete(false);
+        
+        try {
+          onloadFunctions();
+        } catch (e) {}
+        resizeArea();
+        updateMenuIcon('buttonMenu');
+        xx();
 
-		setWindowElementFocus('firstElement');
-	}
+        setWindowElementFocus('firstElement');
+    }
 
-	function onResizeDo(){
-		resizeArea();
-	}
-	</script>
+    function onResizeDo(){
+        resizeArea();
+    }
+    </script>
 </head>
 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="onLoadDo();" onresize="onResizeDo();" id="paramBody">
-<form name="frmMain" method="post" action="CallAcctServer.html">
-	<input type="hidden" name="Command"></input>
-
-	<table height="100%" border="0" cellpadding="0" cellspacing="0" id="main">
+<form id="form" name="frmMain" method="post" action="CallAcctServer.html">
+    <input type="hidden" name="Command"></input>
+   <input type="hidden" name="inpLastFieldChanged" value="">
+    <table height="100%" border="0" cellpadding="0" cellspacing="0" id="main">
     <tr>
       <td valign="top" id="tdleftTabs"></td>
       <td valign="top">
@@ -222,7 +246,7 @@
                     </select>
                   </td>                 
                 </tr>
-				<tr>
+                <tr>
                   <td class="TitleCell"><span class="LabelText">Table</span></td>
                   <td class="Combo_ContentCell" colspan="2"><select name="inpadTableId" id="inpadTableId" class="Combo Combo_TwoCells_width">
                       <option value=""></option><div id="reportTable_M"></div>
@@ -232,10 +256,59 @@
                   <td class="TitleCell"></td>
                   <td class="TitleCell">
                 </tr>
-				<tr>
-                  <td class="TitleCell"></td>
+                <tr>
                   
-                  <td class="Button_RightAlign_ContentCell">
+                  
+                  <tr>
+              <td class="TitleCell"><span class="LabelText">From Date</span></td>
+              <td class="TextBox_btn_ContentCell">
+                <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                  <tr>
+                    <td class="TextBox_ContentCell">
+                      <input dojoType="openbravo:DateTextbox" lowerThan="paramDateTo" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateFrom" id="paramDateFrom" size="10" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateFrom");</script>
+                    </td>
+                    <td class="FieldButton_ContentCell">
+                      <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;" onclick="showCalendar('frmMain.inpDateFrom', document.frmMain.inpDateFrom.value, false);return false;">
+                        <table class="FieldButton"  onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                          <tr>
+                            <td class="FieldButton_bg">
+                              <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
+                            </td>
+                          </tr>
+                        </table>
+                      </a>
+                    </td>
+                  </tr>
+                </table>
+              </td>
+                </tr>
+            <tr>
+
+              <td class="TitleCell"><span class="LabelText">To Date</span></td>
+              <td class="TextBox_btn_ContentCell">
+                <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                  <tr>
+                    <td class="TextBox_ContentCell">
+                      <input dojoType="openbravo:DateTextbox" greaterThan="paramDateFrom" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateTo" id="paramDateTo" size="10" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateTo");</script>
+                    </td>
+                    <td class="FieldButton_ContentCell">
+                      <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;" onclick="showCalendar('frmMain.inpDateTo', document.frmMain.inpDateTo.value, false);return false;">
+                        <table class="FieldButton"  onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                          <tr>
+                            <td class="FieldButton_bg">
+                              <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
+                            </td>
+                          </tr>
+                        </table>
+                      </a>
+                    </td>
+                  </tr>
+                </table>
+              </td>
+            </tr>
+            <tr>
+             <td class="TitleCell"></td>
+                  <td>
                     <div>
                       <button type="button" 
                         id="buttonOK" 
@@ -260,14 +333,14 @@
                       </button>
                     </div>
                   </td>
-				  <td class="ContentCell"></td>
+                  <td class="ContentCell"></td>
                   <td class="Button_LeftAlign_ContentCell">
                     
                   </td>
                   <td class="TitleCell"></td>
                   <td class="ContentCell"></td>
                 </tr>
-	</table>
+    </table>
 
                       <!-- USER CONTROLS -->
                 </td>
@@ -294,4 +367,4 @@
   </table>
 </form>
 </body>
-</html>
+</html>
\ No newline at end of file
--- a/src/org/openbravo/erpCommon/ad_forms/CallAcctServer.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/CallAcctServer.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -27,6 +27,7 @@
 
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.businessUtility.WindowTabs;
 import org.openbravo.erpCommon.reference.PInstanceProcessData;
 import org.openbravo.erpCommon.utility.LeftTabsBar;
@@ -57,10 +58,14 @@
     if (vars.commandIn("DEFAULT")) {
       String strTableId = vars.getStringParameter("inpadTableId", "");
       String strAdOrgId = vars.getStringParameter("inpadOrgId");
-      printPage(response, vars, strTableId, strAdOrgId, "");
+      String strDateFrom = vars.getGlobalVariable("inpDateFrom", "CallAcctServer|dateFrom", "");
+      String strDateTo = vars.getGlobalVariable("inpDateTo", "CallAcctServer|dateTo", "");
+      printPage(response, vars, strTableId, strAdOrgId, "", strDateFrom, strDateTo);
     } else if (vars.commandIn("CANCELAR")) {
       String strTableId = vars.getStringParameter("inpadTableId", "");
       String strAdOrgId = vars.getStringParameter("inpadOrgId");
+      String strDateFrom = vars.getStringParameter("inpDateFrom");
+      String strDateTo = vars.getStringParameter("inpDateTo");
       if (data.length > 0 && data[0].status.equals(org.openbravo.scheduling.Process.SCHEDULED)) {
         try {
           OBScheduler.getInstance().unschedule(data[0].id, new ProcessContext(vars));
@@ -69,22 +74,28 @@
         }
       }
       // acctServer.cancelDirectProcess();
-      printPage(response, vars, strTableId, strAdOrgId, "");
+      printPage(response, vars, strTableId, strAdOrgId, "", strDateFrom, strDateTo);
     } else if (vars.commandIn("REFRESH_INFO")) {
     } else if (vars.commandIn("RUN")) {
       String strTableId = vars.getStringParameter("inpadTableId");
       String strAdOrgId = vars.getStringParameter("inpadOrgId");
+      // String strDateFrom = vars.getStringParameter("inpDateFrom");
+      // String strDateTo = vars.getStringParameter("inpDateTo");
+      String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom", "CallAcctServer|dateFrom");
+      String strDateTo = vars.getRequestGlobalVariable("inpDateTo", "CallAcctServer|dateTo");
       if (strAdOrgId == null || strAdOrgId.equals(""))
         strAdOrgId = "0";
       if (log4j.isDebugEnabled())
         log4j.debug(strTableId);
-      runProcess(response, vars, strTableId, strAdOrgId, adProcessId);
+      runProcess(response, vars, strTableId, strAdOrgId, adProcessId, strDateFrom, strDateTo,
+          this.myPool);
     } else
       pageError(response);
   }
 
   private void printPage(HttpServletResponse response, VariablesSecureApp vars, String strTableId,
-      String strOrgId, String strMessage) throws IOException, ServletException {
+      String strOrgId, String strMessage, String strDateFrom, String strDateTo) throws IOException,
+      ServletException {
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
         "org/openbravo/erpCommon/ad_forms/CallAcctServer").createXmlDocument();
 
@@ -146,6 +157,15 @@
 
       xmlDocument.setParameter("adOrgId", strOrgId);
 
+      // xmlDocument.setParameter("datefrom", vars.getStringParameter("inpdatefrom"));
+      xmlDocument.setParameter("datefrom", strDateFrom);
+      xmlDocument.setParameter("dateFromdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+      xmlDocument.setParameter("dateFromsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+      // xmlDocument.setParameter("dateto", vars.getStringParameter("inpdateto"));
+      xmlDocument.setParameter("dateto", strDateTo);
+      xmlDocument.setParameter("dateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+      xmlDocument.setParameter("dateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+
       response.setContentType("text/html; charset=UTF-8");
       PrintWriter out = response.getWriter();
       out.println(xmlDocument.print());
@@ -154,7 +174,8 @@
   }
 
   private void runProcess(HttpServletResponse response, VariablesSecureApp vars, String strTableId,
-      String strOrgId, String adProcessId) throws IOException, ServletException {
+      String strOrgId, String adProcessId, String strDateFrom, String strDateTo,
+      ConnectionProvider myPool) throws IOException, ServletException {
     OBError myMessage = new OBError();
     myMessage.setTitle("");
     boolean scheduled = false;
@@ -179,6 +200,10 @@
             strTableId, vars.getClient(), vars.getOrg(), vars.getUser());
         PInstanceProcessData.insertPInstanceParam(this, adPinstanceId, "20", "AD_Org_ID", strOrgId,
             vars.getClient(), vars.getOrg(), vars.getUser());
+        PInstanceProcessData.insertPInstanceParam(this, adPinstanceId, "30", "DateFrom",
+            strDateFrom, vars.getClient(), vars.getOrg(), vars.getUser());
+        PInstanceProcessData.insertPInstanceParam(this, adPinstanceId, "40", "DateTo", strDateTo,
+            vars.getClient(), vars.getOrg(), vars.getUser());
 
         ProcessBundle bundle = new ProcessBundle(adProcessId, vars).init(this);
         bundle.getParams().put(ProcessBundle.PINSTANCE, adPinstanceId);
@@ -195,7 +220,7 @@
       log4j.error(e.getMessage());
     } finally {
       vars.setMessage("CallAcctServer", myMessage);
-      printPage(response, vars, strTableId, strOrgId, "");
+      printPage(response, vars, strTableId, strOrgId, "", strDateFrom, strDateTo);
     }
   }
 
--- a/src/org/openbravo/erpCommon/ad_forms/CallAcctServer.xml	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/CallAcctServer.xml	Mon Mar 18 11:15:21 2013 +0100
@@ -12,33 +12,41 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
 -->
 <REPORT>
-	<template file="CallAcctServer.html"/>
-	<PARAMETER id="paramToolBar" name="toolbar" default=""/>
-	<PARAMETER id="paramDirectory" name="directory"/>
-	<PARAMETER id="paramCSS" name="theme" attribute="href" replace="Default"/>
-  	<PARAMETER id="tdleftTabs" name="leftTabs" default=""/>
- 	<PARAMETER id="paramParentTabContainer" name="parentTabContainer" default=" "/>
-  	<PARAMETER id="paramMainTabContainer" name="mainTabContainer" default=" "/>
-  	<PARAMETER id="paramChildTabContainer" name="childTabContainer" default=" "/>
-  	<PARAMETER id="tdtopButtons" name="navigationBar" default=""/>
-  	<PARAMETER id="messageBoxID" name="messageType" attribute="class" replace="yy" default="HIDDEN"/>
-  	<PARAMETER id="messageBoxIDTitle" name="messageTitle" default=""/>
-  	<PARAMETER id="messageBoxIDMessage" name="messageMessage" default=""/>
-	<PARAMETER id="paramLanguage" name="language"/>
-	<PARAMETER id="paramBody" name="body" attribute="onload" replace="xx();"/>
-	<PARAMETER id="adTableId" name="adTableId" attribute="value"/>
-	<SUBREPORT id="reportTable_M" name="reportadTableId" report="org/openbravo/erpCommon/reference/List">
-		<ARGUMENT name="parameterListSelected" withId="adTableId"/>
-	</SUBREPORT>
-	<PARAMETER id="adOrgId" name="adOrgId" attribute="value"/>
-	<SUBREPORT id="reportOrg_M" name="reportadOrgId" report="org/openbravo/erpCommon/reference/List">
-		<ARGUMENT name="parameterListSelected" withId="adOrgId"/>
-	</SUBREPORT>
-	<DISCARD id="discard"/>
+    <template file="CallAcctServer.html"/>
+    <PARAMETER id="paramToolBar" name="toolbar" default=""/>
+    <PARAMETER id="fieldCalendar" name="calendar" attribute="src" replace="es" default="en"/>
+    <PARAMETER id="paramDirectory" name="directory"/>
+    <PARAMETER id="paramLanguage" name="paramLanguage" default=""/>
+    <PARAMETER id="paramCSS" name="theme" attribute="href" replace="Default"/>
+    <PARAMETER id="tdleftTabs" name="leftTabs" default=""/>
+    <PARAMETER id="paramParentTabContainer" name="parentTabContainer" default=" "/>
+    <PARAMETER id="paramMainTabContainer" name="mainTabContainer" default=" "/>
+    <PARAMETER id="paramChildTabContainer" name="childTabContainer" default=" "/>
+    <PARAMETER id="tdtopButtons" name="navigationBar" default=""/>
+    <PARAMETER id="messageBoxID" name="messageType" attribute="class" replace="yy" default="HIDDEN"/>
+    <PARAMETER id="messageBoxIDTitle" name="messageTitle" default=""/>
+    <PARAMETER id="messageBoxIDMessage" name="messageMessage" default=""/>
+    <PARAMETER id="paramLanguage" name="language"/>
+    <PARAMETER id="paramBody" name="body" attribute="onload" replace="xx();"/>
+    <PARAMETER id="adTableId" name="adTableId" attribute="value"/>
+    <PARAMETER id="paramDateFrom" name="datefrom" attribute="value" />
+    <PARAMETER id="paramDateFrom" name="dateFromdisplayFormat" attribute="displayformat" replace="xx"/>
+    <PARAMETER id="paramDateFrom" name="dateFromsaveFormat" attribute="saveformat" replace="yy"/>
+    <PARAMETER id="paramDateTo" name="dateto" attribute="value" />
+    <PARAMETER id="paramDateTo" name="dateTodisplayFormat" attribute="displayformat" replace="xx"/>
+    <PARAMETER id="paramDateTo" name="dateTosaveFormat" attribute="saveformat" replace="yy"/>
+    <SUBREPORT id="reportTable_M" name="reportadTableId" report="org/openbravo/erpCommon/reference/List">
+        <ARGUMENT name="parameterListSelected" withId="adTableId"/>
+    </SUBREPORT>
+    <PARAMETER id="adOrgId" name="adOrgId" attribute="value"/>
+    <SUBREPORT id="reportOrg_M" name="reportadOrgId" report="org/openbravo/erpCommon/reference/List">
+        <ARGUMENT name="parameterListSelected" withId="adOrgId"/>
+    </SUBREPORT>
+    <DISCARD id="discard"/>
 </REPORT>
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,12 +11,14 @@
  * 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) 2001-2012 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2013 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
 
 import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
 import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.Date;
@@ -32,6 +34,7 @@
 import org.openbravo.erpCommon.utility.AccDefUtility;
 import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.SequenceIdData;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.financialmgmt.calendar.Period;
 
 public class DocInvoice extends AcctServer {
@@ -804,7 +807,10 @@
     ArrayList<HashMap<String, String>> plan = new ArrayList<HashMap<String, String>>();
     int i = 1;
     BigDecimal total = BigDecimal.ZERO;
-    BigDecimal periodAmount = amount.divide(new BigDecimal(periodNumber), BigDecimal.ROUND_HALF_UP);
+    int stdPrecision = OBDal.getInstance().get(Currency.class, this.C_Currency_ID)
+        .getStandardPrecision().intValue();
+    BigDecimal periodAmount = amount.divide(new BigDecimal(periodNumber),
+        new MathContext(32, RoundingMode.HALF_UP)).setScale(stdPrecision, BigDecimal.ROUND_HALF_UP);
     while (i <= periodNumber) {
       if (!OBDateUtils.formatDate(date).equals(DateAcct)) {
         HashMap<String, String> hm = new HashMap<String, String>();
--- a/src/org/openbravo/erpCommon/ad_process/AcctServerProcess.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/AcctServerProcess.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2009-2011 Openbravo SLU
+ * All portions are Copyright (C) 2009-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,9 +33,9 @@
 import org.openbravo.erpCommon.ad_forms.AcctServer;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.scheduling.ProcessBundle;
+import org.openbravo.scheduling.ProcessBundle.Channel;
 import org.openbravo.scheduling.ProcessContext;
 import org.openbravo.scheduling.ProcessLogger;
-import org.openbravo.scheduling.ProcessBundle.Channel;
 import org.openbravo.service.db.DalBaseProcess;
 
 public class AcctServerProcess extends DalBaseProcess {
@@ -134,10 +134,14 @@
     String strTable = "";
     // If it is the background process, we use 0
     String strOrg = "0";
+    String strDateFrom = "";// "01-01-2012";
+    String strDateTo = "";// "01-04-2012";
     // if called by 'Posting by DB tables' get params from ad_pinstance
     if (isDirect) {
       strTable = AcctServerProcessData.selectTable(connection, pinstanceId);
       strOrg = AcctServerProcessData.selectOrg(connection, pinstanceId);
+      strDateFrom = AcctServerProcessData.selectDateFrom(connection, pinstanceId);
+      strDateTo = AcctServerProcessData.selectDateTo(connection, pinstanceId);
     }
     if (!strTable.equals("")) {
       tables = new String[1];
@@ -156,7 +160,7 @@
       strTableDesc = AcctServerProcessData.selectDescription(connection, ctx.getLanguage(),
           acct.AD_Table_ID);
       int total = 0;
-      while (acct.checkDocuments()) {
+      while (acct.checkDocuments(strDateFrom, strDateTo)) {
 
         if (total == 0) {
           if (isDirect)
@@ -171,7 +175,7 @@
         }
 
         try {
-          acct.run(vars);
+          acct.run(vars, strDateFrom, strDateTo);
         } catch (final Exception ex) {
           log4j.error(ex.getMessage(), ex);
           return;
@@ -216,5 +220,4 @@
           .append("</span><br>");
     }
   }
-
 }
--- a/src/org/openbravo/erpCommon/ad_process/AcctServerProcess_data.xsql	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/AcctServerProcess_data.xsql	Mon Mar 18 11:15:21 2013 +0100
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2011 Openbravo SLU
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -81,4 +81,22 @@
      ]]></Sql>
      <Parameter name="adPinstanceId"/>
    </SqlMethod>
+     <SqlMethod name="selectDateFrom" type="preparedStatement" return="String" default="">
+     <SqlMethodComment></SqlMethodComment>
+     <Sql><![CDATA[
+       SELECT P_STRING FROM AD_PINSTANCE_PARA
+       WHERE AD_PINSTANCE_ID = ?
+       AND PARAMETERNAME = 'DateFrom'
+     ]]></Sql>
+     <Parameter name="adPinstanceId"/>
+   </SqlMethod>
+     <SqlMethod name="selectDateTo" type="preparedStatement" return="String" default="">
+     <SqlMethodComment></SqlMethodComment>
+     <Sql><![CDATA[
+       SELECT P_STRING FROM AD_PINSTANCE_PARA
+       WHERE AD_PINSTANCE_ID = ?
+       AND PARAMETERNAME = 'DateTo'
+     ]]></Sql>
+     <Parameter name="adPinstanceId"/>
+   </SqlMethod>
 </SqlClass>
--- a/src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal.java	Mon Mar 18 11:15:21 2013 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -106,8 +106,8 @@
               data[i].postingtype, data[i].glCategoryId, data[i].datedoc, data[i].dateacct,
               data[i].cPeriodId, data[i].cCurrencyId, data[i].currencyratetype,
               data[i].currencyrate, strKey, data[i].controlamt, strDocumentNo, "N", "N", "N",
-              data[i].user1Id,data[i].user2Id, data[i].cCampaignId, data[i].cProjectId,
-              data[i].aAssetId, data[i].cCostcenterId, data[i].cBpartnerId , data[i].mProductId  ) == 0)
+              data[i].user1Id, data[i].user2Id, data[i].cCampaignId, data[i].cProjectId,
+              data[i].aAssetId, data[i].cCostcenterId, data[i].cBpartnerId, data[i].mProductId) == 0)
             log4j.warn("Save: GLJournal record " + i + " not inserted. Sequence = " + strSequence);
         } catch (ServletException ex) {
           myError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
@@ -128,7 +128,9 @@
                 dataLines[j].cValidcombinationId, dataLines[j].user1Id, dataLines[j].user2Id,
                 dataLines[j].cCampaignId, dataLines[j].cProjectId, dataLines[j].cActivityId,
                 dataLines[j].cSalesregionId, dataLines[j].mProductId, dataLines[j].cBpartnerId,
-                dataLines[j].aAssetId,dataLines[j].cCostcenterId) == 0)
+                dataLines[j].aAssetId, dataLines[j].cCostcenterId, dataLines[j].openItems,
+                dataLines[j].finFinancialAccountId, dataLines[j].finPaymentmethodId,
+                dataLines[j].cGlitemId, dataLines[j].paymentdate, dataLines[j].finPaymentId) == 0)
               log4j.warn("Save: GLJournalLine record " + j + " not inserted. Sequence = "
                   + strLineSequence);
           } catch (ServletException ex) {
--- a/src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal_data.xsql	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/CopyFromGLJournal_data.xsql	Mon Mar 18 11:15:21 2013 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -39,7 +39,8 @@
         '' AS TOTALDR, '' AS TOTALCR, '' AS PROCESSING, '' AS PROCESSED, '' AS POSTED,
         (SELECT GL2.AD_ORG_ID FROM GL_JOURNALBATCH GL2 WHERE GL2.GL_JOURNALBATCH_ID = ?) AS AD_ORG_ID, USER1_ID, USER2_ID, 
         C_CAMPAIGN_ID,  C_PROJECT_ID, '' AS C_ACTIVITY_ID, '' AS C_SALESREGION_ID,   M_PRODUCT_ID,  C_BPARTNER_ID,
-        A_ASSET_ID, C_COSTCENTER_ID   
+        A_ASSET_ID, C_COSTCENTER_ID, 
+        '' as OPEN_ITEMS, '' as FIN_FINANCIAL_ACCOUNT_ID, '' as FIN_PAYMENTMETHOD_ID,  '' as C_GLITEM_ID, '' as PAYMENTDATE, '' as FIN_PAYMENT_ID
         FROM GL_JOURNAL GL
         WHERE GL.GL_JOURNALBATCH_ID = ?
       ]]>
@@ -60,7 +61,8 @@
 		coalesce(gll.C_CAMPAIGN_ID, gl.C_CAMPAIGN_ID) as C_CAMPAIGN_ID , coalesce(gll.C_PROJECT_ID,gl.C_PROJECT_ID) as C_PROJECT_ID,  
 		gll.C_ACTIVITY_ID , gll.C_SALESREGION_ID , 
 		coalesce(gll.M_PRODUCT_ID,gl.M_PRODUCT_ID) as M_PRODUCT_ID, coalesce(gll.C_BPARTNER_ID,gl.C_BPARTNER_ID) as C_BPARTNER_ID, 
-		gll.AD_ORG_ID, coalesce(gll.A_ASSET_ID,gl.A_ASSET_ID) as A_ASSET_ID, coalesce(gll.C_COSTCENTER_ID,gl.C_COSTCENTER_ID) as C_COSTCENTER_ID   
+		gll.AD_ORG_ID, coalesce(gll.A_ASSET_ID,gl.A_ASSET_ID) as A_ASSET_ID, coalesce(gll.C_COSTCENTER_ID,gl.C_COSTCENTER_ID) as C_COSTCENTER_ID,
+		gll.OPEN_ITEMS, gll.FIN_FINANCIAL_ACCOUNT_ID, gll.FIN_PAYMENTMETHOD_ID,  gll.C_GLITEM_ID, gll.PAYMENTDATE, gll.FIN_PAYMENT_ID   
 		FROM GL_JOURNALLINE gll, GL_JOURNAL gl
 		WHERE gl.gl_journal_id=gll.gl_journal_id
         AND gll.GL_JOURNAL_ID = ?
@@ -152,9 +154,11 @@
         INSERT INTO GL_JOURNALLINE (GL_JOURNALLINE_ID, AD_CLIENT_ID, AD_ORG_ID, CREATED, CREATEDBY, 
         UPDATED, UPDATEDBY, GL_JOURNAL_ID,LINE, ISGENERATED, DESCRIPTION,AMTSOURCEDR, AMTSOURCECR, C_CURRENCY_ID, 
         CURRENCYRATETYPE, CURRENCYRATE, DATEACCT,AMTACCTDR, AMTACCTCR, C_UOM_ID,QTY, C_VALIDCOMBINATION_ID,
-        USER1_ID, USER2_ID, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, C_SALESREGION_ID, M_PRODUCT_ID, C_BPARTNER_ID,  A_ASSET_ID,  C_COSTCENTER_ID) 
+        USER1_ID, USER2_ID, C_CAMPAIGN_ID, C_PROJECT_ID, C_ACTIVITY_ID, C_SALESREGION_ID, M_PRODUCT_ID, C_BPARTNER_ID,  A_ASSET_ID,  C_COSTCENTER_ID,
+        OPEN_ITEMS, FIN_FINANCIAL_ACCOUNT_ID, FIN_PAYMENTMETHOD_ID,  C_GLITEM_ID, PAYMENTDATE, FIN_PAYMENT_ID) 
         VALUES (?,?,?,now(),?,now(),?,?,TO_NUMBER(?),?,?,TO_NUMBER(?),TO_NUMBER(?),?,?,TO_NUMBER(?),now(),TO_NUMBER(?),
-        TO_NUMBER(?),?,TO_NUMBER(?), ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)
+        TO_NUMBER(?),?,TO_NUMBER(?), ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,
+        ?,?,?,?,TO_DATE(?), ?)
       ]]>
     </Sql>
     <Parameter name="gl_journalline_id"/>
@@ -186,5 +190,11 @@
     <Parameter name="c_bpartner_id"/>
     <Parameter name="a_asset_id"/>
     <Parameter name="c_costcenter_id"/>
+    <Parameter name="Open_Items"/>
+    <Parameter name="FIN_Financial_Account_ID"/>
+    <Parameter name="fin_Paymentmethod_ID"/>
+    <Parameter name="C_Glitem_ID"/>
+    <Parameter name="Paymentdate"/>
+    <Parameter name="FIN_Payment_ID"/>
   </SqlMethod>
 </SqlClass>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_process/ResetAccountingProcess.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,85 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.erpCommon.ad_process;
+
+import java.util.HashMap;
+
+import org.openbravo.base.exception.OBException;
+import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.financial.ResetAccounting;
+import org.openbravo.scheduling.ProcessBundle;
+import org.openbravo.scheduling.ProcessLogger;
+import org.openbravo.service.db.DalBaseProcess;
+import org.quartz.JobExecutionException;
+
+public class ResetAccountingProcess extends DalBaseProcess {
+
+  private ProcessLogger logger;
+
+  public void doExecute(ProcessBundle bundle) throws Exception {
+    logger = bundle.getLogger();
+    try {
+      String adClientId = (String) bundle.getParams().get("adClientId");
+      String adOrgId = (String) bundle.getParams().get("adOrgId");
+      String deletePosting = (String) bundle.getParams().get("deleteposting");
+      String adTableId = (String) bundle.getParams().get("adTableId");
+      String recordId = (String) bundle.getParams().get("recordId");
+      String datefrom = (String) bundle.getParams().get("datefrom");
+      String dateto = (String) bundle.getParams().get("dateto");
+      HashMap<String, Integer> results = new HashMap<String, Integer>();
+      Long totalupdate = 0l;
+      Long inicioupdate = 0l;
+      Long finupdate = 0l;
+      inicioupdate = System.currentTimeMillis();
+      if ("Y".equals(deletePosting)) {
+        results = ResetAccounting
+            .delete(adClientId, adOrgId, adTableId, recordId, datefrom, dateto);
+      } else {
+        if (!"".equals(adTableId)) {
+          results = ResetAccounting.restore(adClientId, adOrgId, adTableId, datefrom, dateto);
+        } else {
+          results = ResetAccounting.restore(adClientId, adOrgId, datefrom, dateto);
+        }
+      }
+      finupdate = System.currentTimeMillis();
+      totalupdate = totalupdate + finupdate - inicioupdate;
+      int counter = results.get("updated");
+      int counterDeleted = results.get("deleted");
+      System.out.println("Records updated: " + counter + "\n");
+      System.out.println("Records deleted: " + counterDeleted + "\n");
+      System.out.println("totalupdate /milis:" + totalupdate);
+      OBError myError = new OBError();
+      myError.setType("Success");
+      myError.setTitle("@Success@");
+      myError.setMessage(Utility.parseTranslation(bundle.getConnection(), bundle.getContext()
+          .toVars(), bundle.getContext().toVars().getLanguage(), "@UnpostedDocuments@ = " + counter
+          + ", @DeletedEntries@ = " + counterDeleted));
+
+      bundle.setResult(myError);
+    } catch (OBException e) {
+      throw e;
+    } catch (Exception e) {
+      // catch any possible exception and throw it as a Quartz
+      // JobExecutionException
+      throw new JobExecutionException(e.getMessage(), e);
+    }
+
+  }
+}
\ No newline at end of file
--- a/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl.html	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl.html	Mon Mar 18 11:15:21 2013 +0100
@@ -86,6 +86,13 @@
 	function onResizeDo(){
 		resizeArea();
 	}
+	
+	function openMovementTab(recordId, tab) {
+      var myframe = getFrame('LayoutMDI') || top.opener;
+	  if (myframe) {
+	    myframe.OB.Utilities.openDirectTab(tab, recordId, 'DIRECT');
+	  }
+    }
 	</script>
 </head>
 
@@ -342,7 +349,7 @@
                   <div id="sectionDescription"> 
                     <table cellspacing="0" cellpadding="0" width="100%" class="DataGrid_Header_Table DataGrid_Body_Table" style="table-layout: auto;">
                       <tr class="DataGrid_Body_Row">
-                        <th colspan="4" class="DataGrid_Header_Cell">Movement type<span>:&nbsp;&nbsp;</span><a href="#" onclick="submitCommandFormParameter('DIRECT', document.frmSecondary.zz, 'xx', false, document.frmSecondary, 'yy', null, false, true);return false;" onmouseover="window.status='Shipment edition';return true;" onmouseout="window.status='';return true;" class="LabelLink" id="fieldId"> 
+                        <th colspan="4" class="DataGrid_Header_Cell">Movement type<span>:&nbsp;&nbsp;</span><a href="#" onclick="openMovementTab('xx', 'yy');return false;" onmouseover="window.status='Shipment edition';return true;" onmouseout="window.status='';return true;" class="LabelLink" id="fieldId"> 
                           <span id="fieldDescription">xxiva16%</span></a></th> 
                       </tr>
                       <tr class="DataGrid_Body_Row">
--- a/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl_data.xsql	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportWarehouseControl_data.xsql	Mon Mar 18 11:15:21 2013 +0100
@@ -30,23 +30,23 @@
     <![CDATA[
       SELECT A.DESCRIPTION, M_PRODUCT.NAME AS PRODUCTNAME, 
       SUBSTR(M_ATTRIBUTESETINSTANCE.DESCRIPTION, 2, (LENGTH(M_ATTRIBUTESETINSTANCE.DESCRIPTION)-1)) AS REFERENTIAL, M_TRANSACTION.MOVEMENTDATE, SUM(M_TRANSACTION.MOVEMENTQTY) AS MOVEMENTQTY, A.UBICATION, A.ID, A.INP, C_UOM.NAME AS UOM
-      FROM (SELECT (M_INOUT.DOCUMENTNO||' '||M_INOUT.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_INOUT.M_INOUT_ID AS ID, '../'|| (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN 'GoodsShipment' ELSE 'GoodsReceipt' END) || '/' || 'Header_Relation.html' AS UBICATION, 'inpmInoutId' AS INP
+      FROM (SELECT (M_INOUT.DOCUMENTNO||' '||M_INOUT.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_INOUT.M_INOUT_ID AS ID, (CASE M_INOUT.ISSOTRX WHEN 'Y' THEN '257' ELSE '296' END) AS UBICATION, 'inpmInoutId' AS INP
       FROM M_TRANSACTION, M_INOUTLINE, M_INOUT left join C_PROJECT on M_INOUT.C_PROJECT_ID = C_PROJECT.C_PROJECT_ID
       WHERE M_TRANSACTION.M_INOUTLINE_ID = M_INOUTLINE.M_INOUTLINE_ID
       AND M_INOUTLINE.M_INOUT_ID = M_INOUT.M_INOUT_ID
       UNION
-      SELECT (M_PRODUCTION.NAME||' '||M_PRODUCTION.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_PRODUCTION.M_PRODUCTION_ID AS ID, '../BillofMaterialsProduction/BOMProduction_Edition.html' AS UBICATION, 'inpmProductionId' AS INP
+      SELECT (M_PRODUCTION.NAME||' '||M_PRODUCTION.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_PRODUCTION.M_PRODUCTION_ID AS ID, '319'  AS UBICATION, 'inpmProductionId' AS INP
       FROM M_TRANSACTION, M_PRODUCTIONLINE, M_PRODUCTIONPLAN, M_PRODUCTION left join C_PROJECT on M_PRODUCTION.C_PROJECT_ID = C_PROJECT.C_PROJECT_ID
       WHERE M_TRANSACTION.M_PRODUCTIONLINE_ID = M_PRODUCTIONLINE.M_PRODUCTIONLINE_ID
       AND M_PRODUCTIONLINE.M_PRODUCTIONPLAN_ID = M_PRODUCTIONPLAN.M_PRODUCTIONPLAN_ID
       AND M_PRODUCTIONPLAN.M_PRODUCTION_ID = M_PRODUCTION.M_PRODUCTION_ID
       UNION
-      SELECT (M_INVENTORY.NAME||' '||M_INVENTORY.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_INVENTORY.M_INVENTORY_ID AS ID, '../PhysicalInventory/Header_Edition.html' AS UBICATION, 'inpmInventoryId' AS INP
+      SELECT (M_INVENTORY.NAME||' '||M_INVENTORY.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_INVENTORY.M_INVENTORY_ID AS ID, '255' AS UBICATION, 'inpmInventoryId' AS INP
       FROM M_TRANSACTION, M_INVENTORYLINE, M_INVENTORY left join C_PROJECT on M_INVENTORY.C_PROJECT_ID = C_PROJECT.C_PROJECT_ID
       WHERE M_TRANSACTION.M_INVENTORYLINE_ID = M_INVENTORYLINE.M_INVENTORYLINE_ID
       AND M_INVENTORYLINE.M_INVENTORY_ID = M_INVENTORY.M_INVENTORY_ID
       UNION
-      SELECT (M_MOVEMENT.NAME||' '||M_MOVEMENT.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_MOVEMENT.M_MOVEMENT_ID AS ID, '../GoodsMovements/Header_Edition.html' AS UBICATION, 'inpmMovementId' AS INP
+      SELECT (M_MOVEMENT.NAME||' '||M_MOVEMENT.MOVEMENTDATE||' '||COALESCE(TO_CHAR(C_PROJECT.VALUE), '')) AS DESCRIPTION, M_TRANSACTION.M_TRANSACTION_ID, M_MOVEMENT.M_MOVEMENT_ID AS ID, '259' AS UBICATION, 'inpmMovementId' AS INP
       FROM M_TRANSACTION, M_MOVEMENTLINE, M_MOVEMENT left join C_PROJECT on M_MOVEMENT.C_PROJECT_ID = C_PROJECT.C_PROJECT_ID
       WHERE M_TRANSACTION.M_MOVEMENTLINE_ID = M_MOVEMENTLINE.M_MOVEMENTLINE_ID
       AND M_MOVEMENTLINE.M_MOVEMENT_ID = M_MOVEMENT.M_MOVEMENT_ID) A, M_TRANSACTION, M_PRODUCT, M_ATTRIBUTESETINSTANCE, C_UOM
--- a/src/org/openbravo/erpCommon/utility/WindowTree.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/utility/WindowTree.java	Mon Mar 18 11:15:21 2013 +0100
@@ -39,6 +39,7 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.data.Sqlc;
+import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.utils.Replace;
 import org.openbravo.xmlEngine.XmlDocument;
 
@@ -226,26 +227,20 @@
     String entityName = null, hqlWhereClause = null;
     try {
       OBContext.setAdminMode();
-      OBQuery<org.openbravo.model.ad.ui.Tab> tab = OBDal.getInstance().createQuery(
-          org.openbravo.model.ad.ui.Tab.class, "id='" + strTabId + "'");
-      if (tab.count() != 0) {
-        ScrollableResults tabResults = tab.scroll(ScrollMode.FORWARD_ONLY);
-        while (tabResults.next()) {
-          org.openbravo.model.ad.ui.Tab tabData = (org.openbravo.model.ad.ui.Tab) tabResults.get()[0];
-
-          entityName = tabData.getTable().getName();
-          tabData.getTable().getName();
-          hqlWhereClause = tabData.getHqlwhereclause();
-        }
+      Tab tabData = OBDal.getInstance().get(org.openbravo.model.ad.ui.Tab.class, strTabId);
+      if (tabData != null) {
+        entityName = tabData.getTable().getName();
+        hqlWhereClause = tabData.getHqlwhereclause();
       }
     } catch (Exception e) {
+      log4j.error("Exception while retrieving hqlWhereClause " + e);
     } finally {
       OBContext.restorePreviousMode();
     }
 
     List<WindowTreeData> newSubList = new ArrayList<WindowTreeData>();
-    if ((hqlWhereClause != null && !("".equals(hqlWhereClause)))) {
-      hqlWhereClause = (hqlWhereClause != null && !(" ".equals(hqlWhereClause))) ? hqlWhereClause
+    if (hqlWhereClause != null && !hqlWhereClause.trim().isEmpty()) {
+      hqlWhereClause = (hqlWhereClause != null && !hqlWhereClause.trim().isEmpty()) ? hqlWhereClause
           : "1=1";
       hqlWhereClause = hqlWhereClause.replace("e.", "");
       OBQuery<BaseOBObject> entityResults = OBDal.getInstance().createQuery("" + entityName + "",
@@ -273,10 +268,6 @@
       for (WindowTreeData elem : subList) {
         if (nodeIdList.contains(elem.nodeId)) {
           newSubList.add(elem);
-        } else {
-          if ("Y".equals(elem.issummary)) {
-            TreeUtility utils = new TreeUtility();
-          }
         }
       }
     } else {
--- a/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java	Fri Mar 15 20:18:02 2013 +0100
+++ b/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java	Mon Mar 18 11:15:21 2013 +0100
@@ -43,11 +43,13 @@
 import org.apache.commons.fileupload.FileItem;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.criterion.Restrictions;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.OrganizationStructureProvider;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.utility.OBError;
@@ -65,6 +67,7 @@
 import org.openbravo.erpCommon.utility.reporting.TemplateInfo.EmailDefinition;
 import org.openbravo.exception.NoConnectionAvailableException;
 import org.openbravo.model.common.enterprise.EmailServerConfiguration;
+import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.utils.FormatUtilities;
 import org.openbravo.xmlEngine.XmlDocument;
 
@@ -915,28 +918,12 @@
         throw new ServletException("No Poc configuration found for this client.");
       }
 
-      // TODO: There should be a mechanism to select the desired Email server configuration, until
-      // then, first search for the current organization (and use the first returned one), then for
-      // organization '0' (and use the first returned one) and then for any other of the
-      // organization tree where current organization belongs to (and use the first returned one).
-      EmailServerConfiguration mailConfig = null;
+      EmailServerConfiguration mailConfig = getEmailConfiguration(OBDal.getInstance().get(
+          Organization.class, vars.getOrg()));
 
-      for (EmailServerConfiguration currentOrgConfig : mailConfigList) {
-        if (vars.getOrg().equals(currentOrgConfig.getOrganization().getId())) {
-          mailConfig = currentOrgConfig;
-          break;
-        }
-      }
       if (mailConfig == null) {
-        for (EmailServerConfiguration zeroOrgConfig : mailConfigList) {
-          if ("0".equals(zeroOrgConfig.getOrganization().getId())) {
-            mailConfig = zeroOrgConfig;
-            break;
-          }
-        }
-      }
-      if (mailConfig == null) {
-        mailConfig = mailConfigList.get(0);
+        throw new ServletException(
+            "No sender defined: Please go to client configuration to complete the email configuration.");
       }
 
       fromEmail = mailConfig.getSmtpServerSenderAddress();
@@ -1142,6 +1129,42 @@
     out.close();
   }
 
+  private EmailServerConfiguration getEmailConfiguration(Organization organization) {
+    EmailServerConfiguration emailConfiguration = null;
+    try {
+      if (organization != null) {
+        OBCriteria<EmailServerConfiguration> mailConfigCriteria = OBDal.getInstance()
+            .createCriteria(EmailServerConfiguration.class);
+        mailConfigCriteria.addOrderBy("client.id", false);
+        mailConfigCriteria.add(Restrictions.eq(EmailServerConfiguration.PROPERTY_ORGANIZATION,
+            organization));
+        List<EmailServerConfiguration> mailConfigList = null;
+        // if the current organization is *, return email configuration if present, else return
+        // null
+        if (organization.getId().equals("0")) {
+          mailConfigList = mailConfigCriteria.list();
+          if (mailConfigList.size() != 0) {
+            emailConfiguration = mailConfigList.get(0);
+            return emailConfiguration;
+          } else {
+            return null;
+          }
+        } else {
+          mailConfigList = mailConfigCriteria.list();
+          if (mailConfigList.size() == 0) {
+            OrganizationStructureProvider orgStructure = new OrganizationStructureProvider();
+            return getEmailConfiguration(orgStructure.getParentOrg(organization));
+          } else {
+            emailConfiguration = mailConfigList.get(0);
+          }
+        }
+      }
+    } catch (Exception e) {
+      log4j.error("Exception while retrieving email configuration" + e);
+    }
+    return emailConfiguration;
+  }
+
   private boolean moreThanOneLenguageDefined(Map<String, Report> reports) throws ReportingException {
     @SuppressWarnings("rawtypes")
     Iterator itRep = reports.values().iterator();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/event/FaccAcctModifyEventHandler.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,55 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.event;
+
+import javax.enterprise.event.Observes;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
+import org.openbravo.base.model.Property;
+import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
+import org.openbravo.client.kernel.event.EntityUpdateEvent;
+import org.openbravo.model.financialmgmt.accounting.AccountingFact;
+
+public class FaccAcctModifyEventHandler extends EntityPersistenceEventObserver {
+  private static Entity[] entities = { ModelProvider.getInstance().getEntity(
+      AccountingFact.ENTITY_NAME) };
+  protected Logger logger = Logger.getLogger(this.getClass());
+
+  @Override
+  protected Entity[] getObservedEntities() {
+    return entities;
+  }
+
+  public void onUpdate(@Observes
+  EntityUpdateEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    final AccountingFact acctfact = (AccountingFact) event.getTargetInstance();
+    if (!acctfact.isModify()) {
+      final Entity faEntity = ModelProvider.getInstance().getEntity(AccountingFact.ENTITY_NAME);
+      final Property modifyProperty = faEntity.getProperty(AccountingFact.PROPERTY_MODIFY);
+      event.setCurrentState(modifyProperty, true);
+    }
+
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/financial/ResetAccounting.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,512 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.financial;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.OrganizationStructureProvider;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
+import org.openbravo.model.ad.datamodel.Table;
+import org.openbravo.model.ad.system.Client;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.accounting.AccountingFact;
+import org.openbravo.model.financialmgmt.calendar.Period;
+
+public class ResetAccounting {
+  final static int FETCH_SIZE = 1000;
+  static Logger log4j = Logger.getLogger(ResetAccounting.class);
+
+  @SuppressWarnings("unchecked")
+  public static HashMap<String, Integer> delete(String adClientId, String adOrgId,
+      String adTableId, String recordId, String strdatefrom, String strdateto) throws OBException {
+    if (recordId == null) {
+      recordId = "";
+    }
+    Long totalProcess = System.currentTimeMillis();
+    Long inicio = 0l;
+    Long fin = 0l;
+    Long totalselect = 0l;
+    int deleted = 0;
+    int updated = 0;
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", new Integer(0));
+    results.put("updated", new Integer(0));
+    results.put("totaldeleted", new Integer(0));
+    results.put("totalupdated", new Integer(0));
+    List<String> clients = getClients(adClientId);
+    List<String> tables = getTables(adTableId);
+    try {
+      for (String client : clients) {
+        Set<String> orgIds = new OrganizationStructureProvider().getNaturalTree(adOrgId);
+        for (String table : tables) {
+          List<String> docbasetypes = getDocbasetypes(client, table, recordId);
+          String myQuery = "select distinct e.recordID from FinancialMgmtAccountingFact e where e.organization.id in (:orgIds) and e.client.id = :clientId and e.table.id = :tableId";
+          if (recordId != null && !"".equals(recordId)) {
+            myQuery = myQuery + " and e.recordID = :recordId ";
+          }
+          for (String dbt : docbasetypes) {
+            List<Date[]> periods = new ArrayList<Date[]>();
+            String calendarId = getCalendarId(adOrgId);
+            periods = getPeriodsDates(getOpenPeriods(client, dbt, orgIds, calendarId, table,
+                recordId, strdatefrom, strdateto));
+            int docUpdated = 0;
+            int docDeleted = 0;
+            for (Date[] p : periods) {
+              StringBuffer consDate = new StringBuffer();
+              consDate.append(" and e.documentCategory = '" + dbt + "'");
+              consDate.append(" and e.accountingDate >= :dateFrom and e.accountingDate <= :dateTo");
+              String exceptionsSql = myQuery + consDate.toString();
+              consDate
+                  .append(" and not exists (select a from FinancialMgmtAccountingFact a where a.recordID = e.recordID and a.table.id = e.table.id and (a.accountingDate < :dateFrom or a.accountingDate > :dateTo))");
+              final Query query = OBDal.getInstance().getSession()
+                  .createQuery(myQuery + consDate.toString());
+              if (recordId != null && !"".equals(recordId)) {
+                query.setString("recordId", recordId);
+              }
+              query.setParameterList("orgIds", orgIds);
+              query.setString("clientId", client);
+              query.setString("tableId", table);
+              query.setDate("dateFrom", p[0]);
+              query.setDate("dateTo", p[1]);
+              if (recordId != null && !"".equals(recordId)) {
+                query.setFetchSize(1);
+              } else {
+                query.setFetchSize(FETCH_SIZE);
+              }
+              inicio = System.currentTimeMillis();
+              List<String> transactions = query.list();
+              fin = System.currentTimeMillis();
+              totalselect = totalselect + fin - inicio;
+              while (transactions.size() > 0) {
+                HashMap<String, Integer> partial = delete(transactions, table, client);
+                deleted = deleted + partial.get("deleted");
+                updated = updated + partial.get("updated");
+                docUpdated = docUpdated + partial.get("updated");
+                docDeleted = docDeleted + partial.get("deleted");
+                inicio = System.currentTimeMillis();
+                transactions = query.list();
+                fin = System.currentTimeMillis();
+                totalselect = totalselect + fin - inicio;
+              }
+              // Documents with postings in different periods are treated separately to validate all
+              // dates are within an open period
+              HashMap<String, Integer> partial = treatExceptions(exceptionsSql, recordId, table,
+                  orgIds, client, p[0], p[1], calendarId, strdatefrom, strdateto);
+              deleted = deleted + partial.get("deleted");
+              updated = updated + partial.get("updated");
+              docUpdated = docUpdated + partial.get("updated");
+              docDeleted = docDeleted + partial.get("deleted");
+            }
+            log4j.debug("docBaseType: " + dbt);
+            log4j.debug("updated: " + docUpdated);
+            log4j.debug("deleted: " + docDeleted);
+          }
+        }
+      }
+    } catch (OBException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new OBException("Delete failed", e);
+    }
+    results.put("deleted", deleted);
+    results.put("updated", updated);
+    log4j.debug("total totalProcess (milies): " + (System.currentTimeMillis() - totalProcess));
+    if (recordId != null && !"".equals(recordId) && deleted == 0 && updated == 0) {
+      throw new OBException("@PeriodClosedForUnPosting@");
+    }
+    return results;
+  }
+
+  private static HashMap<String, Integer> delete(List<String> transactions, String tableId,
+      String client) throws OBException {
+    HashMap<String, Integer> result = new HashMap<String, Integer>();
+    if (transactions.size() == 0) {
+      result.put("deleted", new Integer(0));
+      result.put("updated", new Integer(0));
+      return result;
+    }
+    String tableName = "";
+    OBContext.setAdminMode(false);
+    try {
+      Table table = OBDal.getInstance().get(Table.class, tableId);
+      tableName = table.getName();
+      String strUpdate = "update "
+          + tableName
+          + " set posted='N', processNow=false where (posted<>'N' or posted is null or processNow = false) and id in (:transactions) ";
+      String strDelete = "delete from FinancialMgmtAccountingFact where table.id = :tableId and recordID in (:transactions) and client.id=:clientId";
+      final Query update = OBDal.getInstance().getSession().createQuery(strUpdate);
+      update.setParameterList("transactions", transactions);
+      int updated = update.executeUpdate();
+      final Query delete = OBDal.getInstance().getSession().createQuery(strDelete);
+      delete.setString("tableId", tableId);
+      delete.setParameterList("transactions", transactions);
+      delete.setString("clientId", client);
+      int deleted = delete.executeUpdate();
+      result.put("deleted", new Integer(deleted));
+      result.put("updated", new Integer(updated));
+      OBDal.getInstance().getConnection().commit();
+      OBDal.getInstance().getSession().clear();
+      return result;
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      throw new OBException("Error Deleting Accounting", e);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  public static HashMap<String, Integer> restore(String clientId, String adOrgId, String datefrom,
+      String dateto) throws OBException {
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", new Integer(0));
+    results.put("updated", new Integer(0));
+    List<String> tableIds = getActiveTables(clientId, adOrgId);
+    for (String tableId : tableIds) {
+      HashMap<String, Integer> partial = restore(clientId, adOrgId, tableId, datefrom, dateto);
+      results.put("deleted", results.get("deleted") + partial.get("deleted"));
+      results.put("updated", results.get("updated") + partial.get("updated"));
+
+    }
+    log4j.debug("deleted: " + results.get("deleted"));
+    log4j.debug("updated: " + results.get("updated"));
+    return results;
+  }
+
+  public static HashMap<String, Integer> restore(String clientId, String adOrgId, String tableId,
+      String datefrom, String dateto) throws OBException {
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", new Integer(0));
+    results.put("updated", new Integer(0));
+    String tableName = "";
+    String tableDate = "";
+    OBContext.setAdminMode(false);
+    try {
+      Table table = OBDal.getInstance().get(Table.class, tableId);
+      tableName = table.getName();
+      tableDate = lowerCaseFirst(camelCaseIt(table.getAcctdateColumn().getName()));
+      String strUpdate = "update "
+          + tableName
+          + " set posted='N', processNow=false where posted not in ('N','Y') and processed = 'Y' and organization.id in (:orgIds)  ";
+      if (!("".equals(datefrom))) {
+        strUpdate = strUpdate + " and " + tableDate + " >= :dateFrom ";
+      }
+      if (!("".equals(dateto))) {
+        strUpdate = strUpdate + " and " + tableDate + " <= :dateTo ";
+      }
+
+      Query update = OBDal.getInstance().getSession().createQuery(strUpdate);
+      update
+          .setParameterList("orgIds", new OrganizationStructureProvider().getNaturalTree(adOrgId));
+      try {
+        if (!("".equals(datefrom))) {
+          update.setDate("dateFrom", OBDateUtils.getDate(datefrom));
+        }
+        if (!("".equals(dateto))) {
+          update.setDate("dateTo", OBDateUtils.getDate(dateto));
+        }
+      } catch (ParseException e) {
+        // TODO Auto-generated catch block
+        log4j.debug(e);
+      }
+
+      int updated = update.executeUpdate();
+      results.put("updated", new Integer(updated));
+      OBDal.getInstance().getConnection().commit();
+      OBDal.getInstance().getSession().clear();
+      return results;
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      throw new OBException("Error Reseting Accounting", e);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getClients(String clientId) {
+    String myQuery = "select e.id from ADClient e where e.id = :clientId";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    return query.list();
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getTables(String adTableId) {
+    OBContext.setAdminMode(false);
+    try {
+      List<String> accountingTables = new ArrayList<String>();
+      if (!"".equals(adTableId)) {
+        Table myTable = OBDal.getInstance().get(Table.class, adTableId);
+        accountingTables.add(myTable.getId());
+        return accountingTables;
+      }
+      String myQuery = "select distinct e.table.id from FinancialMgmtAccountingFact e where e.table.id <> '145'";
+      accountingTables = OBDal.getInstance().getSession().createQuery(myQuery).list();
+      return accountingTables;
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  @SuppressWarnings("unused")
+  private static List<Organization> getOrganizations(Client client, Set<String> orgIds) {
+    final String CLIENT_SYSTEM = "0";
+    OBCriteria<Organization> obc = OBDal.getInstance().createCriteria(Organization.class);
+    if (!CLIENT_SYSTEM.equals(client.getId())) {
+      obc.add(Restrictions.eq(Organization.PROPERTY_CLIENT, client));
+    }
+    obc.add(Restrictions.in(Organization.PROPERTY_ID, orgIds));
+    obc.setFilterOnReadableClients(false);
+    obc.setFilterOnReadableOrganization(false);
+    return obc.list();
+  }
+
+  private static List<String> getDocbasetypes(String clientId, String tableId, String recordId) {
+    String myQuery = "select distinct e.documentCategory from FinancialMgmtAccountingFact e where e.client.id = :clientId and e.table.id = :tableId ";
+    if (!"".equals(recordId)) {
+      myQuery = myQuery + "and e.recordID=:recordId";
+    }
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    query.setString("tableId", tableId);
+    if (!"".equals(recordId)) {
+      query.setString("recordId", recordId);
+      query.setFetchSize(1);
+    }
+    @SuppressWarnings("unchecked")
+    List<String> docbasetypes = query.list();
+    return docbasetypes;
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<Period> getOpenPeriods(String clientId, String docBaseType,
+      Set<String> orgIds, String calendarId, String tableId, String recordId, String datefrom,
+      String dateto) {
+    if (!"".equals(recordId)) {
+      List<Period> periods = new ArrayList<Period>();
+      periods.add(getDocumentPeriod(clientId, tableId, recordId));
+      return periods;
+    }
+    String myQuery = "select distinct p from FinancialMgmtPeriodControl e left join e.period p left join p.year y left join y.calendar c where c.id = :calendarId and e.client.id = :clientId and e.documentCategory = :docbasetype and e.periodStatus = 'O'";
+
+    if (!("".equals(datefrom))) {
+      myQuery = myQuery + " and p.startingDate >= :dateFrom";
+    }
+    if (!("".equals(dateto))) {
+      myQuery = myQuery + " and p.endingDate <=  :dateTo";
+    }
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    // TODO: Review orgIds
+    // query.setParameterList("orgIds", orgIds);
+    query.setString("calendarId", calendarId);
+    query.setString("clientId", clientId);
+    query.setString("docbasetype", docBaseType);
+    try {
+      if (!("".equals(datefrom))) {
+        query.setDate("dateFrom", OBDateUtils.getDate(datefrom));
+      }
+      if (!("".equals(dateto))) {
+        query.setDate("dateTo", OBDateUtils.getDate(dateto));
+      }
+    } catch (ParseException e) {
+      // TODO Auto-generated catch block
+      log4j.debug(e);
+    }
+    return query.list();
+  }
+
+  private static Period getDocumentPeriod(String clientId, String tableId, String recordId) {
+    String myQuery = "select distinct e.period from FinancialMgmtAccountingFact e , FinancialMgmtPeriodControl p where p.period=e.period and p.periodStatus = 'O' and e.client.id = :clientId and e.table.id = :tableId and e.recordID=:recordId";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    query.setString("tableId", tableId);
+    query.setString("recordId", recordId);
+    query.setFetchSize(1);
+    @SuppressWarnings("unchecked")
+    List<Period> periods = query.list();
+    if (periods.isEmpty()) {
+      throw new OBException("@PeriodClosedForUnPosting@");
+    }
+    return periods.get(0);
+  }
+
+  private static List<Date[]> getPeriodsDates(List<Period> periods) {
+    List<Date[]> result = new ArrayList<Date[]>();
+    for (Period period : periods) {
+      Date[] dates = new Date[2];
+      dates[0] = period.getStartingDate();
+      dates[1] = period.getEndingDate();
+      result.add(dates);
+    }
+    return result;
+  }
+
+  private static String getCalendarId(String adOrgId) {
+    Organization organization = OBDal.getInstance().get(Organization.class, adOrgId);
+    if (organization.getCalendar() != null) {
+      return organization.getCalendar().getId();
+    } else {
+      return getCalendarId(new OrganizationStructureProvider().getParentOrg(adOrgId));
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getActiveTables(String clientId, String adOrgId) {
+    String myQuery = "select distinct table.id from FinancialMgmtAcctSchemaTable where accountingSchema.id in (:accountingSchemaIds) and client.id = :clientId and active= true";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    List<String> accountingSchemaIds = getAccountingSchemaIds(clientId, adOrgId);
+    query.setParameterList("accountingSchemaIds", accountingSchemaIds);
+    query.setString("clientId", clientId);
+    return query.list();
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getAccountingSchemaIds(String clientId, String orgIg) {
+    String myQuery = "select distinct accountingSchema.id from OrganizationAcctSchema where client.id = :clientId and active= true and organization.id in (:orgIds)";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    query.setParameterList("orgIds", new OrganizationStructureProvider().getNaturalTree(orgIg));
+    return query.list();
+
+  }
+
+  /**
+   * 
+   * @param myQuery
+   * @param recordId
+   * @param table
+   * @param orgIds
+   * @param client
+   * @param dateFrom
+   * @param dateTo
+   */
+  private static HashMap<String, Integer> treatExceptions(String myQuery, String recordId,
+      String table, Set<String> orgIds, String client, Date dateFrom, Date dateTo,
+      String calendarId, String datefrom, String dateto) {
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", 0);
+    results.put("updated", 0);
+    final Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    if (recordId != null && !"".equals(recordId)) {
+      query.setString("recordId", recordId);
+    }
+    query.setParameterList("orgIds", orgIds);
+    query.setString("clientId", client);
+    query.setString("tableId", table);
+    query.setDate("dateFrom", dateFrom);
+    query.setDate("dateTo", dateTo);
+    if (recordId != null && !"".equals(recordId)) {
+      query.setFetchSize(1);
+    }
+    @SuppressWarnings("unchecked")
+    List<String> transactions = query.list();
+    for (String transaction : transactions) {
+      OBCriteria<AccountingFact> factCrit = OBDal.getInstance()
+          .createCriteria(AccountingFact.class);
+      factCrit.add(Restrictions.eq(AccountingFact.PROPERTY_RECORDID, transaction));
+      factCrit.add(Restrictions.eq(AccountingFact.PROPERTY_TABLE,
+          OBDal.getInstance().get(Table.class, table)));
+      factCrit.add(Restrictions.eq(AccountingFact.PROPERTY_CLIENT,
+          OBDal.getInstance().get(Client.class, client)));
+      List<AccountingFact> facts = factCrit.list();
+      Set<Date> exceptionDates = new HashSet<Date>();
+      for (AccountingFact fact : facts) {
+        if (dateFrom.compareTo(fact.getAccountingDate()) != 0
+            || dateTo.compareTo(fact.getAccountingDate()) != 0) {
+          exceptionDates.add(fact.getAccountingDate());
+        }
+      }
+      if (checkDates(exceptionDates, client, orgIds, facts.get(0).getDocumentCategory(),
+          calendarId, datefrom, dateto)) {
+        List<String> toDelete = new ArrayList<String>();
+        toDelete.add(transaction);
+        results = delete(toDelete, table, client);
+      } else {
+        if (recordId != null && !"".equals(recordId)) {
+          throw new OBException("@PeriodClosedForUnPosting@");
+        }
+      }
+    }
+    return results;
+  }
+
+  private static boolean checkDates(Set<Date> exceptionDates, String clientId, Set<String> orgIds,
+      String documentCategory, String calendarId, String datefrom, String dateto) {
+    List<Period> openPeriods = getOpenPeriods(clientId, documentCategory, orgIds, calendarId, "",
+        "", datefrom, dateto);
+    int validDates = 0;
+    for (Period period : openPeriods) {
+      for (Date date : exceptionDates) {
+        if (date.compareTo(period.getStartingDate()) >= 0
+            && date.compareTo(period.getEndingDate()) <= 0) {
+          validDates++;
+        }
+      }
+    }
+    if (exceptionDates.size() != validDates) {
+      return false;
+    }
+    return true;
+  }
+
+  private static String camelCaseIt(String mappingName) {
+    String localMappingName = mappingName.replaceAll("_", " ");
+    String separator = " ";
+    // strip _ at the end
+    while (localMappingName.endsWith(separator)) {
+      localMappingName = localMappingName.substring(0, localMappingName.length() - 1);
+    }
+    // strip _ at the beginning
+    while (localMappingName.startsWith(separator)) {
+      localMappingName = localMappingName.substring(1);
+    }
+
+    // "CamelCasing"
+    int pos = localMappingName.indexOf(separator);
+    while (pos != -1) {
+      final String leftPart = localMappingName.substring(0, pos);
+      final String camelLetter = String.valueOf(localMappingName.charAt(pos + 1)).toUpperCase();
+      final String rightPart = localMappingName.substring(pos + 2);
+      localMappingName = leftPart + camelLetter + rightPart;
+      pos = localMappingName.indexOf(separator);
+    }
+    return localMappingName;
+  }
+
+  private static String lowerCaseFirst(String value) {
+    if (value.length() > 1) {
+      return value.substring(0, 1).toLowerCase() + value.substring(1);
+    }
+    return value;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/AccountCancelledEmailBody.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,52 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+
+package org.openbravo.portal;
+
+import org.openbravo.client.kernel.Template;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.access.User;
+
+/**
+ * Generates the body for {@link AccountCancelledEmailGenerator}
+ * 
+ * @author asier
+ * 
+ */
+public class AccountCancelledEmailBody extends PortalEmailBody {
+  private User user;
+
+  @Override
+  protected Template getComponentTemplate() {
+    return OBDal.getInstance().get(Template.class, "E5D5653B19734DA5AE3BEB7019B3D1E7");
+  }
+
+  public void setData(User data) {
+    this.user = data;
+  }
+
+  public User getUser() {
+    return this.user;
+  }
+
+  @Override
+  public Object getData() {
+    return this;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/AccountCancelledEmailGenerator.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,84 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.portal;
+
+import java.io.File;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.openbravo.email.EmailEventContentGenerator;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.ad.access.User;
+
+/**
+ * Email generator for {@link AccountChangeObserver#EVT_ACCOUNT_CANCELLED} event which is triggered
+ * when a portal user is set as inactive.
+ * 
+ * @author asier
+ * 
+ */
+public class AccountCancelledEmailGenerator implements EmailEventContentGenerator {
+  @Inject
+  private AccountCancelledEmailBody body;
+
+  @Override
+  public String getSubject(Object data, String event) {
+    return OBMessageUtils.getI18NMessage("Portal_AccountCancelledSubject",
+        new String[] { ((User) data).getClient().getName() });
+  }
+
+  @Override
+  public String getBody(Object data, String event) {
+    body.setData((User) data);
+    return body.generate();
+  }
+
+  @Override
+  public String getContentType() {
+    return "text/html; charset=utf-8";
+  }
+
+  @Override
+  public boolean isValidEvent(String event, Object data) {
+    return AccountChangeObserver.EVT_ACCOUNT_CANCELLED.equals(event);
+  }
+
+  @Override
+  public int getPriority() {
+    return 100;
+  }
+
+  @Override
+  public boolean preventsOthersExecution() {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  @Override
+  public boolean isAsynchronous() {
+    return true;
+  }
+
+  @Override
+  public List<File> getAttachments(Object data, String event) {
+    return null;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/AccountChangeObserver.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,94 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.portal;
+
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
+import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
+import org.openbravo.client.kernel.event.EntityUpdateEvent;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBQuery;
+import org.openbravo.email.EmailEventManager;
+import org.openbravo.model.ad.access.Role;
+import org.openbravo.model.ad.access.User;
+
+/**
+ * Observes cancellation (active is set to false) of users with access to portal and sends an email
+ * to the user informing the account is expired.
+ * 
+ * @see AccountCancelledEmailGenerator
+ * @author alostale
+ * 
+ */
+public class AccountChangeObserver extends EntityPersistenceEventObserver {
+  private final static Entity userEntity = ModelProvider.getInstance().getEntity(User.ENTITY_NAME);
+  private final static Entity[] entities = { userEntity };
+  private final static Logger log = Logger.getLogger(AccountChangeObserver.class);
+  public static final String EVT_ACCOUNT_CANCELLED = "accountCancelled";
+
+  @Inject
+  private EmailEventManager emailManager;
+
+  @Override
+  protected Entity[] getObservedEntities() {
+    return entities;
+  }
+
+  public void onUpdateActive(@Observes EntityUpdateEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+
+    // account cancellation
+    Boolean wasActive = (Boolean) event.getPreviousState(userEntity
+        .getProperty(User.PROPERTY_ACTIVE));
+    Boolean isActive = (Boolean) event
+        .getCurrentState(userEntity.getProperty(User.PROPERTY_ACTIVE));
+    if (wasActive && !isActive) {
+      OBContext.setAdminMode(false);
+      try {
+        final User user = (User) event.getTargetInstance();
+
+        // check if user has access to portal
+        String where = "as r " + //
+            "where forPortalUsers = true " + //
+            "  and exists (from ADUserRoles ur " + //
+            "              where ur.userContact = :user " + //
+            "               and ur.role = r" + //
+            "               and ur.active = true)";
+        OBQuery<Role> qPortal = OBDal.getInstance().createQuery(Role.class, where);
+        qPortal.setNamedParameter("user", user);
+        if (StringUtils.isNotEmpty(user.getEmail()) && qPortal.count() > 0) {
+          emailManager.sendEmail(EVT_ACCOUNT_CANCELLED, user.getEmail(), user);
+        }
+      } catch (Exception e) {
+        // in case of fail, continue not to stop saving
+        log.error("Error sending email for cancelled account", e);
+      } finally {
+        OBContext.restorePreviousMode();
+      }
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/GrantPortalAccessProcess.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,157 @@
+/*
+ *************************************************************************
+ * 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) 2013 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.portal;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.provider.OBProvider;
+import org.openbravo.client.application.process.BaseProcessActionHandler;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.email.EmailEventManager;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.ad.access.Role;
+import org.openbravo.model.ad.access.User;
+import org.openbravo.model.ad.access.UserRoles;
+import org.openbravo.utils.CryptoSHA1BASE64;
+
+/**
+ * This process grants the user the given role and resets her password
+ * 
+ * @author alostale
+ * 
+ */
+public class GrantPortalAccessProcess extends BaseProcessActionHandler {
+
+  private static final Logger log = Logger.getLogger(GrantPortalAccessProcess.class);
+  public static final String EVT_NEW_USER = "newUser";
+  private static final int PASSWORD_LENGHT = 6;
+
+  @Inject
+  private EmailEventManager emailManager;
+
+  @Override
+  protected JSONObject doExecute(Map<String, Object> parameters, String content) {
+    OBContext.setAdminMode(true);
+    try {
+      JSONObject context = new JSONObject(content);
+      JSONObject params = context.getJSONObject("_params");
+
+      Role role = OBDal.getInstance().get(Role.class, params.getString("portalRole"));
+      User user = OBDal.getInstance().get(User.class, context.getString("AD_User_ID"));
+
+      if (StringUtils.isEmpty(user.getEmail())) {
+        JSONObject msg = new JSONObject();
+        JSONObject result = new JSONObject();
+        msg.put("severity", "error");
+        msg.put("text", OBMessageUtils.getI18NMessage("Portal_UserWithoutEmail", null));
+        result.put("message", msg);
+        return result;
+      }
+
+      OBCriteria<UserRoles> checkRoleIsPresent = OBDal.getInstance()
+          .createCriteria(UserRoles.class);
+      checkRoleIsPresent.add(Restrictions.eq(UserRoles.PROPERTY_USERCONTACT, user));
+      checkRoleIsPresent.add(Restrictions.eq(UserRoles.PROPERTY_ROLE, role));
+      if (checkRoleIsPresent.count() == 0) {
+        UserRoles newUserRole = OBProvider.getInstance().get(UserRoles.class);
+        newUserRole.setUserContact(user);
+        newUserRole.setRole(role);
+        OBDal.getInstance().save(newUserRole);
+        log.info(user + " is granted to " + role);
+      } else {
+        log.info(user + " already is granted to role " + role);
+      }
+
+      user.setDefaultRole(role);
+
+      if (user.getUsername() == null) {
+        String userName = "";
+        if (!StringUtils.isEmpty(user.getFirstName())) {
+          userName += user.getFirstName().toLowerCase();
+        }
+
+        if (!StringUtils.isEmpty(user.getLastName())) {
+          userName += StringUtils.isEmpty(userName) ? "" : ".";
+          userName += user.getLastName().toLowerCase();
+        }
+
+        user.setUsername(userName);
+        log.info("Setting " + userName + " username to " + user);
+      }
+
+      String newPassword = RandomStringUtils.randomAlphanumeric(PASSWORD_LENGHT);
+      user.setPassword(CryptoSHA1BASE64.hash(newPassword));
+      System.out.println("new password " + newPassword);
+
+      // flushing changes in admin mode
+      OBDal.getInstance().flush();
+
+      Map<String, Object> emailData = new HashMap<String, Object>();
+      emailData.put("user", user);
+      emailData.put("password", newPassword);
+      JSONObject msg = new JSONObject();
+      try {
+        boolean emailSent = emailManager.sendEmail(EVT_NEW_USER, user.getEmail(), emailData);
+
+        if (emailSent) {
+          msg.put("severity", "success");
+          msg.put("text", OBMessageUtils.getI18NMessage("Portal_UserGranted", null));
+          user.setGrantPortalAccess(true);
+        } else {
+          msg.put("severity", "warning");
+          msg.put("text", OBMessageUtils.getI18NMessage("Portal_UserGrantedNoEmail", null));
+        }
+      } catch (Exception e) {
+        log.error("Error sending email", e);
+        msg.put("severity", "warning");
+        msg.put("text",
+            OBMessageUtils.getI18NMessage("ErrorInEmail", new String[] { e.getMessage() }));
+      }
+
+      JSONObject result = new JSONObject();
+      result.put("message", msg);
+      return result;
+
+    } catch (Exception e) {
+      log.error("Error granting access to portal", e);
+      JSONObject result = new JSONObject();
+      JSONObject msg = new JSONObject();
+      try {
+        msg.put("severity", "warning");
+        msg.put("text",
+            OBMessageUtils.getI18NMessage("ErrorInEmail", new String[] { e.getMessage() }));
+        result.put("message", msg);
+      } catch (JSONException e1) {
+        log.error("Couldn't genereate error msg", e1);
+      }
+      return result;
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/NewUserEmailBody.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,58 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+
+package org.openbravo.portal;
+
+import java.util.Map;
+
+import org.openbravo.client.kernel.Template;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.access.User;
+
+/**
+ * Generates the body for {@link NewUserEmailGenerator}
+ * 
+ * @author asier
+ * 
+ */
+public class NewUserEmailBody extends PortalEmailBody {
+  private Map<String, Object> data;
+
+  @Override
+  protected Template getComponentTemplate() {
+    return OBDal.getInstance().get(Template.class, "A61FEA84D87A4A95A0CCCFA6FAFE53DB");
+  }
+
+  void setData(Map<String, Object> data) {
+    this.data = data;
+  }
+
+  @Override
+  public Object getData() {
+    return this;
+  }
+
+  public User getUser() {
+    return (User) this.data.get("user");
+  }
+
+  public String getPassword() {
+    return (String) this.data.get("password");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/NewUserEmailGenerator.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,94 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.portal;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.email.EmailEventContentGenerator;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.ad.access.User;
+
+/**
+ * Email generator for {@link GrantPortalAccessProcess#EVT_NEW_USER} event which is triggered when a
+ * user is granted with portal privileges.
+ * 
+ * @author asier
+ * 
+ */
+public class NewUserEmailGenerator implements EmailEventContentGenerator {
+
+  @Inject
+  private NewUserEmailBody body;
+
+  @Override
+  public String getSubject(Object data, String event) {
+    String msg;
+    @SuppressWarnings("unchecked")
+    User user = (User) ((Map<String, Object>) data).get("user");
+    if (user.isGrantPortalAccess()) {
+      msg = "Portal_PasswordChanged";
+    } else {
+      msg = "Portal_UserWelcomeSubject";
+    }
+    return OBMessageUtils.getI18NMessage(msg, new String[] { OBContext.getOBContext()
+        .getCurrentClient().getName() });
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public String getBody(Object data, String event) {
+    body.setData((Map<String, Object>) data);
+    return body.generate();
+  }
+
+  @Override
+  public String getContentType() {
+    return "text/html; charset=utf-8";
+  }
+
+  @Override
+  public boolean isValidEvent(String event, Object data) {
+    return GrantPortalAccessProcess.EVT_NEW_USER.equals(event);
+  }
+
+  @Override
+  public int getPriority() {
+    return 100;
+  }
+
+  @Override
+  public boolean preventsOthersExecution() {
+    return false;
+  }
+
+  @Override
+  public boolean isAsynchronous() {
+    return false;
+  }
+
+  @Override
+  public List<File> getAttachments(Object data, String event) {
+    return null;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/PortalEmailBody.java	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,62 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.portal;
+
+import org.openbravo.client.kernel.BaseTemplateComponent;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.email.EmailEventContentGenerator;
+import org.openbravo.erpCommon.businessUtility.Preferences;
+import org.openbravo.erpCommon.utility.PropertyException;
+
+/**
+ * Convenience class that provides a set of common utilities for templates of emails sent by portal
+ * events.
+ * 
+ * @see EmailEventContentGenerator
+ * @author asier
+ * 
+ */
+public abstract class PortalEmailBody extends BaseTemplateComponent {
+  public String getClientName() {
+    return OBContext.getOBContext().getCurrentClient().getName();
+  }
+
+  public String getUrl() {
+    String url = "";
+    try {
+      url = Preferences.getPreferenceValue("PortalURL", true, OBContext.getOBContext()
+          .getCurrentClient(), OBContext.getOBContext().getCurrentOrganization(), null, null, null);
+    } catch (PropertyException e) {
+      // no preference set, ignore it
+    }
+    return url;
+  }
+
+  public String getContactEmail() {
+    String email = "";
+    try {
+      email = Preferences.getPreferenceValue("PortalContactEmail", true, OBContext.getOBContext()
+          .getCurrentClient(), OBContext.getOBContext().getCurrentOrganization(), null, null, null);
+    } catch (PropertyException e) {
+      // no preference set, ignore it
+    }
+    return email;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/templates/email-account-cancelled.ftl	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,32 @@
+<#--
+/*
+ *************************************************************************
+ * 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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+*/
+
+-->
+
+<p>Dear ${data.user.firstName} ${data.user.lastName},</p>
+<p>
+Your access to the ${data.clientName} Online Customer Portal Account has expired.
+<#if data.contactEmail != "">
+<p>If you have any questions, comments or concerns, please <a href="mailto:${data.contactEmail}">contact us</a>.</p>
+</#if>
+<p>
+Sincerely,<br>
+The ${data.clientName} Crew
+</p>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/portal/templates/email-new-user.ftl	Mon Mar 18 11:15:21 2013 +0100
@@ -0,0 +1,44 @@
+<#--
+/*
+ *************************************************************************
+ * 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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+*/
+
+-->
+
+<p>Dear ${data.user.firstName} ${data.user.lastName},</p>
+
+<p>
+<#if !data.user.grantPortalAccess>
+You have been granted access to the ${data.clientName} Online Customer Portal.
+<#else>
+We have noticed that you have recently updated your password.
+</#if> 
+Below is your login
+information:</p>
+<p>Username: ${data.user.username}<br>
+Password: ${data.password}</p>
+<#if data.url != "">
+<p>Please use this information to <a href="${data.url}">log in</a> to your personalized account.</p>
+</#if>
+<#if data.contactEmail != "">
+<p>If you have any questions, comments or concerns, please <a href="mailto:${data.contactEmail}">contact us</a>.</p>
+</#if>
+<p>
+Sincerely,<br>
+The ${data.clientName} Crew
+</p>
\ No newline at end of file