Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0010574Openbravo ERP00. Application dictionarypublic2009-09-11 18:092009-11-11 12:28
networkb 
harikrishnan 
urgentmajoralways
closedfixed 
5
2.40MP8 
2.40MP102.50MP9 
Core
No
0010574: The converion rate table has to save the rates with more decimals
The converion rate table has to save the rates with more decimals, because in other case the accounting is not correct.
The accounting process works well but the problem is that the multiplier rate and divide rate use only two decimals when they have to use 5, that is how
the conversions are defined.
See the attached document but the problem is not the process, but only the definition of the conversions.
No tags attached.
depends on backport 00106082.40MP10 closed jeneivemalarkodi The converion rate table has to save the rates with more decimals 
has duplicate feature request 0011028 closed rafaroda Currency Exchange Rate 
has duplicate defect 0011183 closed rafaroda Currency Exchange Rate 
related to feature request 0010887 new iciordia Numeric references should declare its own format (from format.xml) instead of being hardcoded in WAD 
related to defect 0010941 closed harikrishnan API check build 171 fails - part2 
related to defect 00116402.50MP10 closed rafaroda In some tables the columns MultiplyRate and DivideRate are Number 
? steps_to_reproduce.odt (745,071) 2009-09-11 18:09
https://issues.openbravo.com/file_download.php?file_id=1743&type=bug
Issue History
2009-09-11 18:09networkbNew Issue
2009-09-11 18:09networkbAssigned To => rafaroda
2009-09-11 18:09networkbFile Added: steps_to_reproduce.odt
2009-09-14 11:31networkbTarget Version => 2.40MP10
2009-09-15 11:00rafarodaStatusnew => acknowledged
2009-09-15 11:42psarobeStatusacknowledged => scheduled
2009-09-15 11:42psarobefix_in_branch => pi
2009-09-15 15:07rafarodaPriorityimmediate => urgent
2009-09-15 15:07rafarodafix_in_branchpi =>
2009-09-16 15:23harikrishnanAssigned Torafaroda => harikrishnan
2009-09-24 07:01harikrishnanNote Added: 0020327
2009-09-24 07:01harikrishnanStatusscheduled => feedback
2009-09-25 08:48networkbNote Added: 0020355
2009-09-25 08:48networkbStatusfeedback => new
2009-09-25 10:03rafarodaNote Added: 0020357
2009-09-25 10:03rafarodaAssigned Toharikrishnan => iciordia
2009-09-25 10:03rafarodaStatusnew => acknowledged
2009-09-30 07:59rafarodaNote Added: 0020574
2009-09-30 16:27rafarodaNote Added: 0020602
2009-10-06 20:27iciordiaNote Added: 0020797
2009-10-06 20:28iciordiaAssigned Toiciordia => rafaroda
2009-10-07 06:57rafarodaStatusacknowledged => scheduled
2009-10-07 06:57rafarodaAssigned Torafaroda => jeneivemalarkodi
2009-10-07 06:57rafarodafix_in_branch => pi
2009-10-07 07:01rafarodaRelationship addedrelated to 0010887
2009-10-07 10:38networkbNote Added: 0020819
2009-10-08 09:43hgbotCheckin
2009-10-08 09:43hgbotNote Added: 0020867
2009-10-08 09:43hgbotStatusscheduled => resolved
2009-10-08 09:43hgbotResolutionopen => fixed
2009-10-08 09:43hgbotFixed in SCM revision => http://code.openbravo.com/erp/stable/2.40/rev/53d63d9df25d5f8f99e97a517e14b282a04c5721 [^]
2009-10-08 15:27rafarodaNote Deleted: 0020867
2009-10-08 15:49hgbotCheckin
2009-10-08 15:49hgbotNote Added: 0020879
2009-10-08 15:49hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/stable/2.40/rev/53d63d9df25d5f8f99e97a517e14b282a04c5721 [^] => http://code.openbravo.com/erp/devel/pi/rev/39e29fcb1883d49a7d2cb3d0281fc55fecabc6b2 [^]
2009-10-13 10:21sureshbabuStatusresolved => closed
2009-10-13 10:21sureshbabuNote Added: 0020965
2009-10-13 10:21sureshbabuFixed in Version => 2.50MP7
2009-10-13 10:46shuehnerRelationship addedrelated to 0010941
2009-10-14 00:00anonymoussf_bug_id0 => 2878312
2009-10-19 10:30rafarodaRelationship addedhas duplicate 0011028
2009-10-19 18:48williams-tegikNote Added: 0021190
2009-10-20 14:43iciordiaNote Added: 0021209
2009-10-20 16:03williams-tegikNote Added: 0021214
2009-10-21 09:03hgbotCheckin
2009-10-21 09:03hgbotNote Added: 0021241
2009-10-21 09:03hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/39e29fcb1883d49a7d2cb3d0281fc55fecabc6b2 [^] => http://code.openbravo.com/erp/devel/pi/rev/8000c4d08283e3653847808b95e6fee55a5dd024 [^]
2009-10-21 09:08rafarodaAssigned Tojeneivemalarkodi => rafaroda
2009-10-21 09:08rafarodaStatusclosed => new
2009-10-21 09:08rafarodaResolutionfixed => open
2009-10-21 09:08rafarodaNote Added: 0021243
2009-10-21 09:09rafarodaFixed in Version2.50MP7 =>
2009-10-22 07:29rafarodaNote Added: 0021296
2009-10-22 07:29rafarodaAssigned Torafaroda => iciordia
2009-10-22 07:29rafarodaStatusnew => acknowledged
2009-10-22 07:31rafarodaNote Added: 0021297
2009-10-22 19:43iciordiaNote Added: 0021348
2009-10-22 19:48iciordiaNote Added: 0021349
2009-10-27 09:24harikrishnanAssigned Toiciordia => harikrishnan
2009-10-27 09:57hgbotCheckin
2009-10-27 09:57hgbotNote Added: 0021405
2009-10-27 09:57hgbotStatusacknowledged => resolved
2009-10-27 09:57hgbotResolutionopen => fixed
2009-10-27 09:57hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/8000c4d08283e3653847808b95e6fee55a5dd024 [^] => http://code.openbravo.com/erp/devel/pi/rev/b41bbb3be75a859e5f9cec15aef87fc9add4f7a6 [^]
2009-10-30 06:01rafarodaRelationship addedhas duplicate 0011183
2009-11-11 12:28sureshbabuStatusresolved => closed
2009-11-11 12:28sureshbabuNote Added: 0021717
2009-11-11 12:28sureshbabuFixed in Version => 2.50MP9
2009-12-14 10:16rafarodaRelationship addedrelated to 0011640

Notes
(0020327)
harikrishnan   
2009-09-24 07:01   
To increase the decimal points we have to follow the steps.
Step 1.
Edit Format.xml(openbravocodebase/config/Format.xml)
   Change decimal point in formatOutput and formatInternal attribute of euroEdition.
      <Number name="euroEdition" decimal="." grouping=","
      formatOutput="#0.0000000"formatInternal="#0.0000000" />
Step 2.

Run Ant task

   ant compile.complete

Hence if now look in to conversion rate the field displays seven decimal point.
(0020355)
networkb   
2009-09-25 08:48   
The solution changes the number of decimals that are euro fiels,
what is not correct because the invoices in spain has to be presented
with only two decimals, by law.
Besides although in the conversion rates is possible to save more decimals
there is a callout that round both values so the value saved have only two decimals.

Other problem in 2.50 is that the core mustn't be modified so how to implement this change using modularity?

A proposal solution could be to create a new reference in order to use more decimals to be assigned only to this two fields.
(0020357)
rafaroda   
2009-09-25 10:03   
1) You are right, the solution proposed is not valid since it changes all the euroEdition formatted fields.

2) Forget about the callout, this is not the problem:
* Type in Multiplier Rate field: 0.666666667 This value is rounded to 0.67

3) The code that makes this rounding starts in line 187 of WADNumber.java https://code.openbravo.com/erp/devel/main/file/600c52248c85/src-wad/src/org/openbravo/wad/controls/WADNumber.java#l187 [^] Decimal numbers are rounded based on euroEdition field of Format.xml file, which does not seems very correct.

Issue passed to Platform in order that they decide if a new entry has to be added into Format.xml file for decimal numbers.
(0020574)
rafaroda   
2009-09-30 07:59   
Current Format.xml.template file https://code.openbravo.com/erp/devel/pi/file/7d24f94b2a5e/config/Format.xml.template [^]
(0020602)
rafaroda   
2009-09-30 16:27   
The new solution proposed is to change the reference to GeneralQuantity (ad_reference_id = '800019') for these 2 columns. This way, the format taken from Format.xml will be generalQtyRelation and generalQtyEdition. If this is set to the number of decimals that we want, it will work.

I have some doubts:

1) Number (ad_reference_id = '22') seems the correct Reference for these 2 columns: why change it to GeneralQuantity?

SELECT t.name AS TABLE_NAME, c.name AS COLUMN_NAME, r.name AS REFERENCE_NAME
FROM ad_table t, ad_column c, ad_reference r
WHERE r.ad_reference_id IN ('22')
AND c.ad_table_id = t.ad_table_id
AND r.ad_reference_id = c.ad_reference_id
ORDER BY r.name, t.name, c.name;

2) Currently there are no columns defined with reference GeneralQuantity in Openbravo ERP.

SELECT t.name AS TABLE_NAME, c.name AS COLUMN_NAME, r.name AS REFERENCE_NAME
FROM ad_table t, ad_column c, ad_reference r
WHERE r.ad_reference_id IN ('800019')
AND c.ad_table_id = t.ad_table_id
AND r.ad_reference_id = c.ad_reference_id
ORDER BY r.name, t.name, c.name;

I keep thinking that the problem is in the Format.xml. See wadUtility.java https://code.openbravo.com/erp/devel/pi/file/c6b4fe83c065/src-wad/src/org/openbravo/wad/WadUtility.java#l2120 [^]

Why both Amount (ad_reference_id = '12') and Number (ad_reference_id = '22') are considered decimal numbers in the same way? Normally one wants amounts to be formatted in a currency style which differs many times to the style that we want for decimal numbers (multipliers with several decimals).

I think that a better solution would be:

1) In WadUtility.java, change:
public static boolean isDecimalNumber(String reference) {
    if (reference == null || reference.equals(""))
      return false;
    return (reference.equals("12") || reference.equals("22"));
  }

by

public static boolean isAmountNumber(String reference) {
    if (reference == null || reference.equals(""))
      return false;
    return (reference.equals("12"));
  }

public static boolean isDecimalNumber(String reference) {
    if (reference == null || reference.equals(""))
      return false;
    return (reference.equals("22"));
  }

2) In WADNumber.java, change:
 if (WadUtility.isDecimalNumber(getData("AD_Reference_ID"))) {
      xmlDocument.setParameter("columnFormat", "euroEdition");
      xmlDocument.setParameter("outputFormat", "euroEdition");
    }

by

 if (WadUtility.isAmountNumber(getData("AD_Reference_ID"))) {
      xmlDocument.setParameter("columnFormat", "euroEdition");
      xmlDocument.setParameter("outputFormat", "euroEdition");
    } else if (WadUtility.isDecimalNumber(getData("AD_Reference_ID"))) {
      xmlDocument.setParameter("columnFormat", "decimalEdition");
      xmlDocument.setParameter("outputFormat", "decimalEdition");
    }

3) In Format.xml.template file, add:
 <Number name="decimalRelation"
       decimal="." grouping="," formatOutput="#,##0.00" formatInternal="#0.000000" />
   <Number name="decimalEdition"
       decimal="." grouping="," formatOutput="#0.00" formatInternal="#0.000000" />
   <Number name="decimalExcel"
       decimal="," grouping="." formatOutput="#,##0.##" formatInternal="#0.000000" />
(0020797)
iciordia   
2009-10-06 20:27   
Rafa,

I agree with the rational in your proposed solution but some details are wrong (eg. formatOutput for decimal should be ###,##0.###### if we want to solve this issue). But this way it requires to review all current columns using reference number (182 columns) because many of them should be amount instead. Also take into account that updating instances after this change might lead to changes in behaviour (number columns will show more decimal positions than before).

Because of this I've created a feature request (https://issues.openbravo.com/view.php?id=10887 [^]) to properly address this problem. As you can see this is not a simple request and should be managed as a project.

In the meantime you should fix the issue as originally proposed (changing reference to generalQuantity).

Ismael
(0020819)
networkb   
2009-10-07 10:38   
Changing reference to generalQuantity is good because in this way
the user is able to save the conversion with six decimals what is enough
(0020879)
hgbot   
2009-10-08 15:49   
Repository: erp/devel/pi
Changeset: 39e29fcb1883d49a7d2cb3d0281fc55fecabc6b2
Author: Jeneive malarkodi <jeneive.malarkodi <at> openbravo.com>
Date: Thu Oct 08 19:17:48 2009 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/39e29fcb1883d49a7d2cb3d0281fc55fecabc6b2 [^]

Fixed Issue 10574: The conversion rate table with more decimals

---
M src-db/database/sourcedata/AD_COLUMN.xml
---
(0020965)
sureshbabu   
2009-10-13 10:21   
Tested, right the conversion table with maximum of 6 decimals
(0021190)
williams-tegik   
2009-10-19 18:48   
The problem for us , was that you in the Openbravo UI, the rate it was rounded, but the rate in the database is stored exactle the way you entered.

I.E.
1. You type 13.4879 and click save
2. You see 13.49
3. The databse stores 13.4879 , and this is the the number is used.

This is not wrong, but it caused our customer a lot of problem when they created the inverse rate and they just wrote 13.49 instead of 13.4879... so this caused a big discrepancy in the rounding account, when working with this rate/day.

Our solution:
We have created a trigger so when they create a rate convertion the system creates the inverse automatically, this is up to the customer trough a check box.
If you like this solution, we are open to contribute it.

Best,
Eduardo Williams
Partner: Tegik
(0021209)
iciordia   
2009-10-20 14:43   
Hi Eduardo,

be careful with your proposed fix: your are right that first time you save database stores 13.4879

But if you do another change in that record (any other field) and save again then the database will store 13.49

In any case your solution to automatically calculate the inverse is interesting, I let Rafa to manage the contribution.

Thanks,

Ismael
(0021214)
williams-tegik   
2009-10-20 16:03   
Hi Ismael,
This explains a lot of things then, Probably our customer writes it down the good way, but sometimes the make a change and this happens... This cause big problems in the accounting..
what would you recommend us to do ??
(0021241)
hgbot   
2009-10-21 09:03   
Repository: erp/devel/pi
Changeset: 8000c4d08283e3653847808b95e6fee55a5dd024
Author: Harikrishnan Raja <harikrishnan.raja <at> openbravo.com>
Date: Wed Oct 21 12:29:02 2009 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/8000c4d08283e3653847808b95e6fee55a5dd024 [^]

Fixes Issue 0010941 Issue 0010574 resolves API break by reverting the change.

---
M src-db/database/sourcedata/AD_COLUMN.xml
---
(0021243)
rafaroda   
2009-10-21 09:08   
Change in pi has been reverted and waiting for new solution proposed.
(0021296)
rafaroda   
2009-10-22 07:29   
Isma,

Will 0010887 be implemented in order to properly fix this issue?

Thanks.
(0021297)
rafaroda   
2009-10-22 07:31   
Eduardo,

Please contact me [1] since your feature for avoiding to type the inverse conversion rate sounds very interesting :)

Cheers.

[1] http://forge.openbravo.com/users/rafaroda [^]
(0021348)
iciordia   
2009-10-22 19:43   
Eduardo,

my recomendation is to change the reference of multiplyRate and divideRate from Number to GeneralQty. It will be done in Openbravo core in MP10 (before we do it we need to solve a problem with wrong mapping for reference number, you will see in short in our forums). But you can do this change in advance since you don't have problems with stable API. GeneralQty reference has big precision and will remove the problem.

Ismael
(0021349)
iciordia   
2009-10-22 19:48   
Rafa,

next steps:
1.- Solve wrong mapping for reference number (change from float to BigDecimal) and manage change in public API
2.- Solve this issue by my original proposal (change reference to GeneralQty) without the need to address 10887 (after 1 there will not be API change)
3.- Support for extensible references, including FR10887

Ismael
(0021405)
hgbot   
2009-10-27 09:57   
Repository: erp/devel/pi
Changeset: b41bbb3be75a859e5f9cec15aef87fc9add4f7a6
Author: Harikrishnan Raja <harikrishnan.raja <at> openbravo.com>
Date: Tue Oct 27 14:23:06 2009 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/b41bbb3be75a859e5f9cec15aef87fc9add4f7a6 [^]

Fixes Issue 10574: The conversion rate table has to save the rates with more decimals.

---
M src-db/database/sourcedata/AD_COLUMN.xml
---
(0021717)
sureshbabu   
2009-11-11 12:28   
Retested working fine, as per the developer comments