Attached Files | reportsWithCurrency.png [^] (120,730 bytes) 2015-10-14 11:23
30782.diff [^] (20,844 bytes) 2015-10-19 18:02 [Show Content] [Hide Content]diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJR.java b/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJR.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJR.java
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJR.java
@@ -44,6 +44,7 @@
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.LeftTabsBar;
import org.openbravo.erpCommon.utility.NavigationBar;
+import org.openbravo.erpCommon.utility.OBCurrencyUtils;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.PropertyException;
import org.openbravo.erpCommon.utility.ToolBar;
@@ -293,6 +294,16 @@
strShown, strDateFromRef, strDateToRef, strDateFromRef2, strDateToRef2, strDateFromRef3,
strDateToRef3, strOrg, strsalesrepId, strcProjectId, strProducttype, strcDocTypeId,
strOrder, strMayor, strMenor, strPartnerSalesrepId, strCurrencyId, strVoid, "xls");
+ } else if (vars.commandIn("CUR")) {
+ String orgId = vars.getStringParameter("inpOrg");
+ String strOrgCurrencyId = OBCurrencyUtils.getOrgCurrency(orgId);
+ if (StringUtils.isEmpty(strOrgCurrencyId)) {
+ strOrgCurrencyId = strUserCurrencyId;
+ }
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ out.print(strOrgCurrencyId);
+ out.close();
} else
pageErrorPopUp(response);
}
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJRFilter.html b/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJRFilter.html
--- a/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJRFilter.html
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJRFilter.html
@@ -94,6 +94,31 @@
return true;
}
+function callback(paramXMLParticular, XMLHttpRequestObj) {
+ var strText = "";
+ if (getReadyStateHandler(XMLHttpRequestObj)) {
+ try {
+ if (XMLHttpRequestObj.responseText) {
+ strText = XMLHttpRequestObj.responseText;
+ if (strText) {
+ document.getElementById('inpCurrencyId').value = strText;
+ }
+ }
+ } catch (e) {
+ }
+ }
+ return true;
+}
+
+function setDefaultCurrency() {
+ try {
+ var paramXMLReq = null;
+ return submitXmlHttpRequest(callback, document.frmMain, "CUR", "ReportInvoiceCustomerDimensionalAnalysesJRFilter.html", false, null, paramXMLReq);
+ } catch (e) {
+ alert(e);
+ }
+}
+
function onloadFunctions() {
}
</script>
@@ -114,6 +139,7 @@
updateMenuIcon('buttonMenu');
setWindowElementFocus('firstElement');
+ setDefaultCurrency();
var f = getFrame('LayoutMDI');
if (f.OB.PropertyStore.get('ShowVoidCheckboxSalesInvoiceDimensionalReport') == 'Y') {
@@ -505,7 +531,7 @@
</tr>
<tr>
<td class="TitleCell"><span class="LabelText">Organization</span></td>
- <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="ComboKey Combo_TwoCells_width" required="true">
+ <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="ComboKey Combo_TwoCells_width" required="true" onChange="setDefaultCurrency();">
<option value=""> <div id="reportAD_ORGID"></div></option>
</select></td>
<td class="ContentCell"></td>
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesFilterJR.html b/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesFilterJR.html
--- a/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesFilterJR.html
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesFilterJR.html
@@ -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-2011 Openbravo SLU
+ * All portions are Copyright (C) 2001-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -87,6 +87,31 @@
return true;
}
+function callback(paramXMLParticular, XMLHttpRequestObj) {
+ var strText = "";
+ if (getReadyStateHandler(XMLHttpRequestObj)) {
+ try {
+ if (XMLHttpRequestObj.responseText) {
+ strText = XMLHttpRequestObj.responseText;
+ if (strText) {
+ document.getElementById('inpCurrencyId').value = strText;
+ }
+ }
+ } catch (e) {
+ }
+ }
+ return true;
+}
+
+function setDefaultCurrency() {
+ try {
+ var paramXMLReq = null;
+ return submitXmlHttpRequest(callback, document.frmMain, "CUR", "ReportMaterialDimensionalAnalysesFilterJR.html", false, null, paramXMLReq);
+ } catch (e) {
+ alert(e);
+ }
+}
+
function onloadFunctions() {
}
</script>
@@ -107,6 +132,7 @@
updateMenuIcon('buttonMenu');
setWindowElementFocus('firstElement');
+ setDefaultCurrency();
}
function onResizeDo(){
@@ -388,7 +414,7 @@
</tr>
<tr>
<td class="TitleCell"><span class="LabelText">Organization</span></td>
- <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="Combo Combo_TwoCells_width">
+ <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="Combo Combo_TwoCells_width" onChange="setDefaultCurrency();">
<option value=""> <div id="reportAD_ORGID"></div></option>
</select></td>
<td class="ContentCell"></td>
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesJR.java b/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesJR.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesJR.java
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesJR.java
@@ -27,6 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.StringUtils;
import org.openbravo.base.filter.IsIDFilter;
import org.openbravo.base.filter.IsPositiveIntFilter;
import org.openbravo.base.secureApp.HttpSecureAppServlet;
@@ -39,6 +40,7 @@
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.LeftTabsBar;
import org.openbravo.erpCommon.utility.NavigationBar;
+import org.openbravo.erpCommon.utility.OBCurrencyUtils;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.ToolBar;
import org.openbravo.erpCommon.utility.Utility;
@@ -54,6 +56,7 @@
// Get user Client's base currency
String strUserCurrencyId = Utility.stringBaseCurrencyId(this, vars.getClient());
+
if (vars.commandIn("DEFAULT", "DEFAULT_COMPARATIVE")) {
String strDateFrom = vars.getGlobalVariable("inpDateFrom",
"ReportMaterialDimensionalAnalysesJR|dateFrom", "");
@@ -162,6 +165,16 @@
strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strNotShown,
strShown, strDateFromRef, strDateToRef, strOrg, strOrder, strMayor, strMenor,
strCurrencyId, "pdf");
+ } else if (vars.commandIn("CUR")) {
+ String orgId = vars.getStringParameter("inpOrg");
+ String strOrgCurrencyId = OBCurrencyUtils.getOrgCurrency(orgId);
+ if (StringUtils.isEmpty(strOrgCurrencyId)) {
+ strOrgCurrencyId = strUserCurrencyId;
+ }
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ out.print(strOrgCurrencyId);
+ out.close();
} else
pageErrorPopUp(response);
}
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java b/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java
@@ -28,6 +28,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.StringUtils;
import org.openbravo.base.filter.IsIDFilter;
import org.openbravo.base.filter.IsPositiveIntFilter;
import org.openbravo.base.secureApp.HttpSecureAppServlet;
@@ -40,6 +41,7 @@
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.LeftTabsBar;
import org.openbravo.erpCommon.utility.NavigationBar;
+import org.openbravo.erpCommon.utility.OBCurrencyUtils;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.ToolBar;
import org.openbravo.erpCommon.utility.Utility;
@@ -181,6 +183,16 @@
strPartnerGroup, strcBpartnerId, strProductCategory, strmProductId, strmWarehouseId,
strNotShown, strShown, strDateFromRef, strDateToRef, strOrg, strsalesrepId, strOrder,
strMayor, strMenor, strPartnerSalesrepId, strCurrencyId, "pdf");
+ } else if (vars.commandIn("CUR")) {
+ String orgId = vars.getStringParameter("inpOrg");
+ String strOrgCurrencyId = OBCurrencyUtils.getOrgCurrency(orgId);
+ if (StringUtils.isEmpty(strOrgCurrencyId)) {
+ strOrgCurrencyId = strUserCurrencyId;
+ }
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ out.print(strOrgCurrencyId);
+ out.close();
} else
pageErrorPopUp(response);
}
@@ -317,9 +329,8 @@
}
try {
ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR", "AD_Org_ID", "",
- "", Utility.getContext(this, vars, "#User_Org",
- "ReportSalesDimensionalAnalyzeJR"), Utility.getContext(this, vars, "#User_Client",
- "ReportSalesDimensionalAnalyzeJR"), 0);
+ "", Utility.getContext(this, vars, "#User_Org", "ReportSalesDimensionalAnalyzeJR"),
+ Utility.getContext(this, vars, "#User_Client", "ReportSalesDimensionalAnalyzeJR"), 0);
Utility.fillSQLParameters(this, vars, null, comboTableData,
"ReportSalesDimensionalAnalyzeJR", strOrg);
xmlDocument.setData("reportAD_ORGID", "liststructure", comboTableData.select(false));
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJRFilter.html b/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJRFilter.html
--- a/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJRFilter.html
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJRFilter.html
@@ -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-2012 Openbravo SLU
+ * All portions are Copyright (C) 2001-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -91,6 +91,31 @@
return true;
}
+function callback(paramXMLParticular, XMLHttpRequestObj) {
+ var strText = "";
+ if (getReadyStateHandler(XMLHttpRequestObj)) {
+ try {
+ if (XMLHttpRequestObj.responseText) {
+ strText = XMLHttpRequestObj.responseText;
+ if (strText) {
+ document.getElementById('inpCurrencyId').value = strText;
+ }
+ }
+ } catch (e) {
+ }
+ }
+ return true;
+}
+
+function setDefaultCurrency() {
+ try {
+ var paramXMLReq = null;
+ return submitXmlHttpRequest(callback, document.frmMain, "CUR", "ReportSalesDimensionalAnalyzeJRFilter.html", false, null, paramXMLReq);
+ } catch (e) {
+ alert(e);
+ }
+}
+
function onloadFunctions() {
}
</script>
@@ -111,6 +136,7 @@
updateMenuIcon('buttonMenu');
setWindowElementFocus('firstElement');
+ setDefaultCurrency();
}
function onResizeDo(){
@@ -405,7 +431,7 @@
</tr>
<tr>
<td class="TitleCell"><span class="LabelText">Organization</span></td>
- <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="Combo Combo_TwoCells_width">
+ <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="Combo Combo_TwoCells_width" onChange="setDefaultCurrency();">
<option value=""> <div id="reportAD_ORGID"></div></option>
</select></td>
<td class="TitleCell"><span class="LabelText">Warehouse</span></td>
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJR.java b/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJR.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJR.java
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJR.java
@@ -27,6 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.StringUtils;
import org.openbravo.base.filter.IsIDFilter;
import org.openbravo.base.filter.IsPositiveIntFilter;
import org.openbravo.base.secureApp.HttpSecureAppServlet;
@@ -39,6 +40,7 @@
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.LeftTabsBar;
import org.openbravo.erpCommon.utility.NavigationBar;
+import org.openbravo.erpCommon.utility.OBCurrencyUtils;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.ToolBar;
import org.openbravo.erpCommon.utility.Utility;
@@ -189,6 +191,16 @@
strNotShown, strShown, strDateFromRef, strDateToRef, strOrg, strsalesrepId, strOrder,
strMayor, strMenor, strPartnerSalesrepId, strCurrencyId, "xls");
}
+ } else if (vars.commandIn("CUR")) {
+ String orgId = vars.getStringParameter("inpOrg");
+ String strOrgCurrencyId = OBCurrencyUtils.getOrgCurrency(orgId);
+ if (StringUtils.isEmpty(strOrgCurrencyId)) {
+ strOrgCurrencyId = strUserCurrencyId;
+ }
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ out.print(strOrgCurrencyId);
+ out.close();
} else
pageErrorPopUp(response);
}
diff --git a/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJRFilter.html b/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJRFilter.html
--- a/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJRFilter.html
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportShipmentDimensionalAnalyzeJRFilter.html
@@ -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-2011 Openbravo SLU
+ * All portions are Copyright (C) 2001-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -98,6 +98,31 @@
return true;
}
+function callback(paramXMLParticular, XMLHttpRequestObj) {
+ var strText = "";
+ if (getReadyStateHandler(XMLHttpRequestObj)) {
+ try {
+ if (XMLHttpRequestObj.responseText) {
+ strText = XMLHttpRequestObj.responseText;
+ if (strText) {
+ document.getElementById('inpCurrencyId').value = strText;
+ }
+ }
+ } catch (e) {
+ }
+ }
+ return true;
+}
+
+function setDefaultCurrency() {
+ try {
+ var paramXMLReq = null;
+ return submitXmlHttpRequest(callback, document.frmMain, "CUR", "ReportShipmentDimensionalAnalyzeJRFilter.html", false, null, paramXMLReq);
+ } catch (e) {
+ alert(e);
+ }
+}
+
function onloadFunctions() {
}
</script>
@@ -118,6 +143,7 @@
updateMenuIcon('buttonMenu');
setWindowElementFocus('firstElement');
+ setDefaultCurrency();
}
function onResizeDo(){
@@ -412,7 +438,7 @@
</tr>
<tr>
<td class="TitleCell"><span class="LabelText">Organization</span></td>
- <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="Combo Combo_TwoCells_width">
+ <td class="Combo_ContentCell" colspan="2"> <select name="inpOrg" id="inpOrg" class="Combo Combo_TwoCells_width" onChange="setDefaultCurrency();">
<option value=""> <div id="reportAD_ORGID"></div></option>
</select></td>
<td class="ContentCell"></td>
diff --git a/src/org/openbravo/erpCommon/utility/OBCurrencyUtils.java b/src/org/openbravo/erpCommon/utility/OBCurrencyUtils.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/erpCommon/utility/OBCurrencyUtils.java
@@ -0,0 +1,80 @@
+/*
+ *************************************************************************
+ * 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) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.erpCommon.utility;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.service.db.DalConnectionProvider;
+
+/**
+ * Utilities to get Currency
+ */
+public class OBCurrencyUtils {
+ private static Logger log4j = Logger.getLogger(OBCurrencyUtils.class);
+
+ /**
+ * Returns the currency id for the given organization id.
+ *
+ * If the org id is empty, it returns null. If the given organization has no currency, it tries to
+ * get its legal entity's currency. If not found, it returns the organization client's currency
+ *
+ * @param orgId
+ * Organization Id whose currency is needed
+ *
+ * @return String currencyId currency id for the given organization. Null if not found
+ */
+ public static String getOrgCurrency(String orgId) {
+ if (StringUtils.isBlank(orgId)) {
+ return null;
+ }
+
+ OBContext.setAdminMode(true);
+ try {
+ final Organization org = OBDal.getInstance().get(Organization.class, orgId);
+ if (org == null) {
+ // No organization
+ return null;
+ } else if (org.getCurrency() != null) {
+ // Get currency of organization
+ return org.getCurrency().getId();
+ } else {
+ final Organization legalEntity = OBContext.getOBContext()
+ .getOrganizationStructureProvider().getLegalEntity(org);
+ if (legalEntity != null && legalEntity.getCurrency() != null) {
+ // Get currency from legal entity of organization
+ return legalEntity.getCurrency().getId();
+ } else {
+ // Get client base currency
+ return Utility.stringBaseCurrencyId(new DalConnectionProvider(false), StringUtils.equals(
+ orgId, "0") ? OBContext.getOBContext().getCurrentClient().getId() : org.getClient()
+ .getId());
+ }
+ }
+ } catch (Exception e) {
+ log4j.error("Impossible to get currency for organization id " + orgId, e);
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+
+ return null;
+ }
+}
|