Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0046309 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [Openbravo ERP] 09. Financial management | major | always | 2021-04-20 16:45 | 2021-04-21 11:59 | |||
Reporter | gsuarez | View Status | public | |||||
Assigned To | Triage Omni OMS | |||||||
Priority | high | Resolution | no change required | Fixed in Version | ||||
Status | closed | Fix in branch | Fixed in SCM revision | |||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Review Assigned To | vmromanos | |||||||
Web browser | ||||||||
Modules | Advanced Payables and Receivables Mngmt | |||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0046309: Error in getConversionRate function of FIN_Utility class that belongs to org.openbravo.advpaymentmngt module | |||||||
Description | In a custom process we use this function to get the conversion rate between 2 differents currencies. Openbravo only has records of conversion rate at organization 0 (*), but this function returns null when the organization is 0. I copy the function: public static ConversionRate getConversionRate(Currency fromCurrency, Currency toCurrency, Date conversionDate, Organization org) { java.util.List<ConversionRate> conversionRateList; ConversionRate conversionRate; OBContext.setAdminMode(true); try { final OBCriteria<ConversionRate> obcConvRate = OBDal.getInstance() .createCriteria(ConversionRate.class); obcConvRate.setFilterOnReadableOrganization(false); obcConvRate.add(Restrictions.eq(ConversionRate.PROPERTY_ORGANIZATION, org)); obcConvRate.add(Restrictions.eq(ConversionRate.PROPERTY_CURRENCY, fromCurrency)); obcConvRate.add(Restrictions.eq(ConversionRate.PROPERTY_TOCURRENCY, toCurrency)); obcConvRate.add(Restrictions.le(ConversionRate.PROPERTY_VALIDFROMDATE, conversionDate)); long oneDay = 24 * 60 * 60 * 1000; obcConvRate.add(Restrictions.ge(ConversionRate.PROPERTY_VALIDTODATE, new Date(conversionDate.getTime() - oneDay))); conversionRateList = obcConvRate.list(); if ((conversionRateList != null) && (conversionRateList.size() != 0)) { conversionRate = conversionRateList.get(0); } else { if ("0".equals(org.getId())) { conversionRate = null; } else { return getConversionRate(fromCurrency, toCurrency, conversionDate, OBDal.getInstance() .get(Organization.class, OBContext.getOBContext() .getOrganizationStructureProvider() .getParentOrg(org.getId()))); } } } catch (Exception e) { log4j.error("Error getting conversion rate", e); return null; } finally { OBContext.restorePreviousMode(); } return conversionRate; } | |||||||
Steps To Reproduce | In a custom process, try to get a conversion rate using this function. | |||||||
Tags | No tags attached. | |||||||
Attached Files | ||||||||
Relationships [ Relation Graph ] [ Dependency Graph ] | |
Notes | |
(0127412) vmromanos (manager) 2021-04-21 11:59 |
Although Openbravo only allows to define conversion rates at * level, the method is ready to support conversion rates defined in any other organization. Let's see what it does: 1. It searches for a conversion rate defined for the organization passed as parameter. 2. If it is found it is returned and the process ends, otherwise the process continues.. 3. If it is not found it tries to search **recursively** through the parent tree till it finds a conversion rate and then returns it. 4. If it is not found and the organization is '0', it means that we have checked all the possibilities, so we return null. To return null when organization is '0' is the exit point of this recursive method. We can't remove it. And besides that, it's not necessary to change anything in this method because it already supports what you're expecting. Rejected as no change required. |
Issue History | |||
Date Modified | Username | Field | Change |
2021-04-20 16:45 | gsuarez | New Issue | |
2021-04-20 16:45 | gsuarez | Assigned To | => Triage Finance |
2021-04-20 16:45 | gsuarez | Modules | => Advanced Payables and Receivables Mngmt |
2021-04-20 16:45 | gsuarez | Resolution time | => 1620684000 |
2021-04-20 16:45 | gsuarez | Triggers an Emergency Pack | => No |
2021-04-21 11:59 | vmromanos | Review Assigned To | => vmromanos |
2021-04-21 11:59 | vmromanos | Note Added: 0127412 | |
2021-04-21 11:59 | vmromanos | Status | new => closed |
2021-04-21 11:59 | vmromanos | Resolution | open => no change required |
Copyright © 2000 - 2009 MantisBT Group |