details:   /erp/stable/2.50/rev/c4c88d99ee94
changeset: 9422:c4c88d99ee94
user:      Javier Etxarri <javier.echarri <at> openbravo.com>
date:      Thu May 12 13:19:06 2011 +0200
summary:   fixes issue 17114: Initial Client/Org. Setup must import two new 
columns in CSV file

diffstat:

 src-db/database/sourcedata/AD_MESSAGE.xml                            |  11 ++
 src/org/openbravo/erpCommon/businessUtility/COAData.java             |  53 
++++-----
 src/org/openbravo/erpCommon/businessUtility/COAUtility.java          |  34 
++++++-
 src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java |  30 
+++++
 4 files changed, 100 insertions(+), 28 deletions(-)

diffs (233 lines):

diff -r 52182678428a -r c4c88d99ee94 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Thu May 12 16:51:05 2011 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Thu May 12 13:19:06 2011 +0200
@@ -34466,6 +34466,17 @@
 <!--FA5C4E4CAED74DEFA58E298F8771E547-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--FA5C4E4CAED74DEFA58E298F8771E547--></AD_MESSAGE>
 
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F--><AD_MESSAGE>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  
<AD_MESSAGE_ID><![CDATA[FA6C67EC99DD41F4B66FDCDEBFBE3C0F]]></AD_MESSAGE_ID>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  
<VALUE><![CDATA[ValueIgnoredImportingAccount]]></VALUE>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  <MSGTEXT><![CDATA[The account %s does 
not have the correct value in the column %s. The account has been imported 
ignoring this value.]]></MSGTEXT>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FA6C67EC99DD41F4B66FDCDEBFBE3C0F--></AD_MESSAGE>
+
 <!--FB074AB5BE884C2FAEE6159575A47F09--><AD_MESSAGE>
 <!--FB074AB5BE884C2FAEE6159575A47F09-->  
<AD_MESSAGE_ID><![CDATA[FB074AB5BE884C2FAEE6159575A47F09]]></AD_MESSAGE_ID>
 <!--FB074AB5BE884C2FAEE6159575A47F09-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 52182678428a -r c4c88d99ee94 
src/org/openbravo/erpCommon/businessUtility/COAData.java
--- a/src/org/openbravo/erpCommon/businessUtility/COAData.java  Thu May 12 
16:51:05 2011 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/COAData.java  Thu May 12 
13:19:06 2011 +0200
@@ -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 Openbravo SLU
+ * All portions are Copyright (C) 2010-2011 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -48,6 +48,8 @@
   String balanceSheetName = "";
   String uS1120BalanceSheet = "";
   String uS1120BalanceSheetName = "";
+  String showValueCond = "";
+  String titleNode = "";
 
   public void setAccountValue(String accountValue) {
     this.accountValue = accountValue;
@@ -133,6 +135,14 @@
     this.cashFlowName = cashFlowName;
   }
 
+  public void setShowValueCond(String showValueCond) {
+    this.showValueCond = showValueCond;
+  }
+
+  public void setTitleNode(String titleNode) {
+    this.titleNode = titleNode;
+  }
+
   String profitAndLoss = "";
   String profitAndLossName = "";
   String uS1120IncomeStatement = "";
@@ -246,6 +256,14 @@
     return cElementValueId;
   }
 
+  public String getShowValueCond() {
+    return showValueCond;
+  }
+
+  public String getTitleNode() {
+    return titleNode;
+  }
+
   public void setCElementValueId(String elementValueId) {
     cElementValueId = elementValueId;
   }
@@ -307,6 +325,11 @@
     else if (fieldName.equalsIgnoreCase("C_ELEMENT_VALUE_ID")
         || fieldName.equalsIgnoreCase("CELEMENTVALUEID"))
       return cElementValueId;
+    else if (fieldName.equalsIgnoreCase("SHOW_VALUE_COND")
+        || fieldName.equalsIgnoreCase("showValueCond"))
+      return showValueCond;
+    else if (fieldName.equalsIgnoreCase("TITLE_NODE") || 
fieldName.equalsIgnoreCase("titleNode"))
+      return titleNode;
     else {
       log4j.debug("COAData - getField - Field does not exist: " + fieldName);
       return null;
@@ -381,34 +404,10 @@
         coaData.setOperands(text);
         break;
       case 11:
-        coaData.setBalanceSheet(text);
+        coaData.setShowValueCond(text);
         break;
       case 12:
-        coaData.setBalanceSheetName(text);
-        break;
-      case 13:
-        coaData.setUS1120BalanceSheet(text);
-        break;
-      case 14:
-        coaData.setUS1120BalanceSheetName(text);
-        break;
-      case 15:
-        coaData.setProfitAndLoss(text);
-        break;
-      case 16:
-        coaData.setProfitAndLossName(text);
-        break;
-      case 17:
-        coaData.setUS1120IncomeStatement(text);
-        break;
-      case 18:
-        coaData.setUS1120IncomeStatementName(text);
-        break;
-      case 19:
-        coaData.setCashFlow(text);
-        break;
-      case 20:
-        coaData.setCashFlowName(text);
+        coaData.setTitleNode(text);
         break;
       }
       previous = next + 1;
diff -r 52182678428a -r c4c88d99ee94 
src/org/openbravo/erpCommon/businessUtility/COAUtility.java
--- a/src/org/openbravo/erpCommon/businessUtility/COAUtility.java       Thu May 
12 16:51:05 2011 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/COAUtility.java       Thu May 
12 13:19:06 2011 +0200
@@ -51,6 +51,7 @@
 import org.openbravo.model.financialmgmt.accounting.coa.ElementValueOperand;
 import org.openbravo.model.financialmgmt.calendar.Calendar;
 import org.openbravo.model.financialmgmt.calendar.Year;
+import org.openbravo.service.db.DalConnectionProvider;
 
 /**
  * @author David Alsasua
@@ -499,6 +500,12 @@
       dataAux.setCElementValueId(data[i].getField("cElementValueId"));
       log4j.debug("parseData() - dataAux.cElementValueId: " + 
dataAux.getCElementValueId());
       vec.addElement(dataAux);
+
+      dataAux.setShowValueCond(data[i].getField("showValueCond"));
+      log4j.debug("parseData() - showValueCond: " + 
dataAux.getShowValueCond());
+      dataAux.setTitleNode(data[i].getField("titleNode"));
+      log4j.debug("parseData() - dataAux.accountValue: " + 
dataAux.getTitleNode());
+
     }
     log4j.debug("parseData() - All elements processed correctly.");
     result = new COAData[vec.size()];
@@ -665,6 +672,31 @@
       Boolean IsSummary = data[i].getAccountSummary().equals("Yes");
       String C_ElementValue_ID = data[i].getCElementValueId();
       String accountType = setAccountType(data[i]);
+      String showValueCond = data[i].getShowValueCond();
+      String titleNode = data[i].getTitleNode();
+      OBContext.setAdminMode();
+      try {
+        String language = OBContext.getOBContext().getLanguage().getLanguage();
+
+        if (!"".equals(showValueCond) && !showValueCond.equals("P") && 
!showValueCond.equals("N")
+            && !showValueCond.equals("A")) {
+          showValueCond = null;
+          logEvent(String
+              .format(Utility.messageBD(new DalConnectionProvider(),
+                  "ValueIgnoredImportingAccount", language), 
data[i].getAccountValue(),
+                  "ShowValueCond"));
+        }
+
+        if (!"".equals(titleNode) && !titleNode.equals("Y") && 
!titleNode.equals("N")) {
+          titleNode = null;
+          logEvent(String.format(Utility.messageBD(new DalConnectionProvider(),
+              "ValueIgnoredImportingAccount", language), 
data[i].getAccountValue(), "TitleNode"));
+        }
+
+      } finally {
+        OBContext.restorePreviousMode();
+      }
+
       if (accountType == null) {
         logError("@CreateAccountingFailed@",
             "insertElementValuesInDB() - Account type could not be stablished 
for account "
@@ -689,7 +721,7 @@
           elementValue = InitialSetupUtility.insertElementValue(element, 
organization, data[i]
               .getAccountName(), data[i].getAccountValue(), 
data[i].getAccountDescription(),
               accountType, accountSign, IsDocControlled, IsSummary, 
data[i].getElementLevel(),
-              false);
+              false, showValueCond, titleNode);
         } catch (Exception e) {
           return logError("@CreateAccountingFailed@",
               "insertElementValuesInDB() - Not inserted account with value: "
diff -r 52182678428a -r c4c88d99ee94 
src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java
--- a/src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java      
Thu May 12 16:51:05 2011 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java      
Thu May 12 13:19:06 2011 +0200
@@ -679,6 +679,32 @@
       String name, String value, String description, String accountType, 
String accountSign,
       boolean isDocControlled, boolean isSummary, String elementLevel, boolean 
doFlush)
       throws Exception {
+    return insertElementValue(element, orgProvided, name, value, description, 
accountType,
+        accountSign, isDocControlled, isSummary, elementLevel, doFlush, null, 
null);
+  }
+
+  /**
+   * 
+   * @param element
+   * @param orgProvided
+   * @param name
+   * @param value
+   * @param description
+   * @param accountType
+   * @param accountSign
+   * @param isDocControlled
+   * @param isSummary
+   * @param elementLevel
+   * @param doFlush
+   * @param a
+   * @param b
+   * @return
+   * @throws Exception
+   */
+  public static ElementValue insertElementValue(Element element, Organization 
orgProvided,
+      String name, String value, String description, String accountType, 
String accountSign,
+      boolean isDocControlled, boolean isSummary, String elementLevel, boolean 
doFlush,
+      String showValueCond, String titleNode) throws Exception {
     try {
       OBContext.setAdminMode();
 
@@ -701,6 +727,10 @@
       newElementValue.setDocumentControlled(isDocControlled);
       newElementValue.setSummaryLevel(isSummary);
       newElementValue.setElementLevel(elementLevel);
+      if (showValueCond != null && !"".equals(showValueCond))
+        newElementValue.setShowValueCondition(showValueCond);
+      if (titleNode != null && !"".equals(titleNode))
+        newElementValue.setTitleNode("Y".equals(titleNode));
       OBDal.getInstance().save(newElementValue);
       if (doFlush)
         OBDal.getInstance().flush();

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to