Created attachment 17667 [details]
Set active currency in order page, total become "NaN"
I have "NaN" value in my replacement cost, budgeted cost and total when I change the currency in order page to my active currency.
I've set the same active currency for admin/currency & exchange rate and vendor, the basket page also displayed the active currency. but the default currency in my order page was other currency, the calculation is correct for this non-active currency, but the value for replacement cost, budgeted cost and total become "NaN" when I change the currency to my active currency.
I think this is due to the updateCosts() function in acq.js which cannot handle whitespace in the currency code. The problem exists even in the latest stable.
For existing system, since the staff interface does not allow changing the currency code, it can be changed directly in the database table. For example, to change code 'US Dollars' to 'USD' use this query:
SQL> update currency set currency = 'USD' where currency = 'US Dollars';
This effectively solves this problem. But I'm not sure if it affects any other areas (say reports or old orders/budgets). Let someone confirm it.
Cannot recreate on current master, I can get values as NaN if I put letters into price, but I am prevented from saving.
Closing this report
If it still shows "NaN" in current master it just proves the bug, not resolves in my opinion.
(In reply to Saiful Amin from comment #3)
> If it still shows "NaN" in current master it just proves the bug, not
> resolves in my opinion.
It only shows 'NaN' if I enter values that are not numbers - and I cannot save until I fix them
I think highlighting an error in entry is the correct behaviour
If I understand the bug report correctly, it is about calculation not happening automatically. Manual fixing of final amount is always an option. It is the 'automatic calculation' that breaks in some cases. In my tests in the past, currency with white-space is an issue that results in this behavior.
I have not tested this in recent versions, but I always advise everyone not to have white-space in the currency code. It just avoids the problem.