Bug 10113 - Currency and cost calculation problem in acquisition
Summary: Currency and cost calculation problem in acquisition
Status: CLOSED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-25 07:20 UTC by shalomchong
Modified: 2020-06-04 20:32 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Set active currency in order page, total become "NaN" (299.95 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2013-04-25 07:20 UTC, shalomchong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description shalomchong 2013-04-25 07:20:24 UTC
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.
Comment 1 Saiful Amin 2014-12-11 08:11:58 UTC
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.

I don't know enough javascript to fix it. But, an easy way to avoid this problem is not having any whitespace in the currency code (e.g., use 'USD' instead of 'US Dollars').

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.
Comment 2 Nick Clemens 2019-06-12 10:51:57 UTC
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
Comment 3 Saiful Amin 2019-06-12 11:07:49 UTC
If it still shows "NaN" in current master it just proves the bug, not resolves in my opinion.
Comment 4 Nick Clemens 2019-06-12 11:20:28 UTC
(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
Comment 5 Saiful Amin 2019-06-12 15:03:23 UTC
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.