Fixed bug 20764 Currency selected appear in the organization screen
authorSandra Huguet <sandra.huguet@openbravo.com>
Fri, 15 Jun 2012 12:27:54 +0200
changeset 17955 59a32d16a80f
parent 17954 38acdd74058a
child 17956 245c366769f7
Fixed bug 20764 Currency selected appear in the organization screen
src/org/openbravo/erpCommon/businessUtility/InitialOrgSetup.java
src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java
--- a/src/org/openbravo/erpCommon/businessUtility/InitialOrgSetup.java	Fri Sep 14 12:13:37 2012 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/InitialOrgSetup.java	Fri Jun 15 12:27:54 2012 +0200
@@ -44,6 +44,7 @@
 import org.openbravo.model.ad.utility.DataSet;
 import org.openbravo.model.ad.utility.Tree;
 import org.openbravo.model.ad.utility.TreeNode;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.enterprise.OrganizationType;
 import org.openbravo.model.common.geography.Location;
@@ -135,7 +136,7 @@
 
     log4j.debug("createOrganization() - Creating organization.");
     obResult = insertOrganization((strOrgName == null || strOrgName.equals("")) ? "newOrg"
-        : strOrgName, strOrgType, strParentOrg, strcLocationId);
+        : strOrgName, strOrgType, strParentOrg, strcLocationId, strCurrency);
     if (!obResult.getType().equals(OKTYPE))
       return obResult;
     obResult.setType(ERRORTYPE);
@@ -638,7 +639,7 @@
   }
 
   private OBError insertOrganization(String strOrgName, String strOrgType, String strParentOrg,
-      String strcLocationId) {
+      String strcLocationId, String strCurrency) {
 
     OBError obResult = new OBError();
     obResult.setType(ERRORTYPE);
@@ -648,7 +649,7 @@
 
     try {
       org = InitialSetupUtility.insertOrganization(strOrgName, getOrgType(strOrgType),
-          strcLocationId, client);
+          strcLocationId, client, getCurencyType(strCurrency));
       if (org == null)
         return logErrorAndRollback("@CreateOrgFailed@",
             "createOrganization() - ERROR - Organization creation process failed.", null);
@@ -698,6 +699,10 @@
     return OBDal.getInstance().get(OrganizationType.class, strOrgType);
   }
 
+  private Currency getCurencyType(String strCurrency) {
+    return OBDal.getInstance().get(Currency.class, strCurrency);
+  }
+
   public String getLog() {
     return strHeaderLog.append(NEW_LINE).append(STRSEPARATOR).append(NEW_LINE + NEW_LINE)
         .append(strLog).toString();
--- a/src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java	Fri Sep 14 12:13:37 2012 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java	Fri Jun 15 12:27:54 2012 +0200
@@ -1810,6 +1810,12 @@
 
   public static Organization insertOrganization(String strOrgName, OrganizationType orgType,
       String strcLocationId, Client client) throws Exception {
+    return insertOrganization(strOrgName, orgType, strcLocationId, client, null);
+
+  }
+
+  public static Organization insertOrganization(String strOrgName, OrganizationType orgType,
+      String strcLocationId, Client client, Currency strCurrency) throws Exception {
     log4j.debug("InitialSetupUtility - insertOrganization() - name = " + strOrgName);
     OBContext.setAdminMode();
     try {
@@ -1818,6 +1824,7 @@
       newOrg.setName(strOrgName);
       newOrg.setSearchKey(strOrgName);
       newOrg.setOrganizationType(orgType);
+      newOrg.setCurrency(strCurrency);
       OBDal.getInstance().save(newOrg);
       OBDal.getInstance().flush();
       return newOrg;