details: https://code.openbravo.com/erp/devel/pi/rev/c7962cc9055b
changeset: 20655:c7962cc9055b
user: Sandra Huguet <sandra.huguet <at> openbravo.com>
date: Wed Jun 26 19:00:12 2013 +0200
summary: Fixed bug 24202 calculate the currency properly
diffstat:
src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Amount.java | 21 ++++++++-
src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java | 23
+++++++++-
2 files changed, 42 insertions(+), 2 deletions(-)
diffs (88 lines):
diff -r ac7af24d4f0b -r c7962cc9055b
src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Amount.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Amount.java Thu Jun
27 08:40:41 2013 +0530
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Amount.java Wed Jun
26 19:00:12 2013 +0200
@@ -29,6 +29,7 @@
import org.openbravo.base.secureApp.HttpSecureAppServlet;
import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.security.OrganizationStructureProvider;
import org.openbravo.dal.service.OBDal;
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.OBError;
@@ -73,7 +74,12 @@
"org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument();
final Organization org = OBDal.getInstance()
.get(org.openbravo.model.timeandexpense.Sheet.class,
strTimeExpenseId).getOrganization();
- String c_Currency_To_ID = org.getCurrency().getId();
+ String c_Currency_To_ID = getCurrency(org.getId());
+ if (c_Currency_To_ID == null) {
+ c_Currency_To_ID = OBDal.getInstance()
+ .get(org.openbravo.model.timeandexpense.Sheet.class,
strTimeExpenseId).getClient()
+ .getCurrency().toString();
+ }
// Checks if there is a conversion rate for each of the transactions of
// the report
@@ -143,4 +149,17 @@
out.println(xmlDocument.print());
out.close();
}
+
+ private static String getCurrency(String org) {
+ if (org.equals("0")) {
+ return null;
+ } else {
+ Organization organization = OBDal.getInstance().get(Organization.class,
org);
+ if (organization.getCurrency() != null) {
+ return organization.getCurrency().getId();
+ } else {
+ return getCurrency(new
OrganizationStructureProvider().getParentOrg(org));
+ }
+ }
+ }
}
diff -r ac7af24d4f0b -r c7962cc9055b
src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java Thu Jun
27 08:40:41 2013 +0530
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_Product.java Wed Jun
26 19:00:12 2013 +0200
@@ -29,6 +29,7 @@
import org.openbravo.base.secureApp.HttpSecureAppServlet;
import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.security.OrganizationStructureProvider;
import org.openbravo.dal.service.OBDal;
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.OBError;
@@ -171,7 +172,13 @@
resultado.append(", new Array(\"inpexpenseamt\", " +
amount.toPlainString() + ")");
resultado.append(", new Array(\"inpinvoiceprice\", "
+ (priceActual.equals("") ? "\"\"" : priceActual) + ")");
- String c_Currency_To_ID = org.getCurrency().getId();
+
+ String c_Currency_To_ID = getCurrency(org.getId());
+ if (c_Currency_To_ID == null) {
+ c_Currency_To_ID = OBDal.getInstance()
+ .get(org.openbravo.model.timeandexpense.Sheet.class,
strsTimeexpenseId).getClient()
+ .getCurrency().getId();
+ }
// Checks if there is a conversion rate for each of the transactions of
// the report
@@ -223,4 +230,18 @@
out.println(xmlDocument.print());
out.close();
}
+
+ private static String getCurrency(String org) {
+ if (org.equals("0")) {
+ return null;
+ } else {
+ Organization organization = OBDal.getInstance().get(Organization.class,
org);
+ if (organization.getCurrency() != null) {
+ return organization.getCurrency().getId();
+ } else {
+ return getCurrency(new
OrganizationStructureProvider().getParentOrg(org));
+ }
+ }
+ }
+
}
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits