Bug 37937 - Budgeted cost tax exc. in basket page isn't honoring OrderPriceRounding
Summary: Budgeted cost tax exc. in basket page isn't honoring OrderPriceRounding
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 36049
Blocks:
  Show dependency treegraph
 
Reported: 2024-09-17 02:22 UTC by Victor Grousset/tuxayo
Modified: 2024-09-22 20:38 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Grousset/tuxayo 2024-09-17 02:22:07 UTC
To test:
1) Enable syspref OrderPriceRounding
2) in acquisitions, search vendors, pick one, look for an existing basket
3) Create an order line in acquisitions with vendor price 18.90 and a
   discount of 5 %.
4) After creation your are back to the basket page
5) Verify that the "Budgeted cost tax exc." in the order table on the basket
   page is 17.95. => this is wrong, it should be 17.96
6) Just like "Total tax exc. (USD)" (after Bug 36049 is merged)
Comment 1 Victor Grousset/tuxayo 2024-09-17 02:29:07 UTC
"Total tax exc. (USD)" is using Koha::Number::Price->round() and "Budgeted cost tax exc." isn't.
Comment 2 Victor Grousset/tuxayo 2024-09-17 02:33:30 UTC
So the fix is different from bug 36049 which is why it's better to do it separately.

But it still depend on bug 36049 to have Koha::Number::Price->round() work as expected.
Comment 3 Victor Grousset/tuxayo 2024-09-17 03:08:13 UTC
> "Total tax exc. (USD)" is using Koha::Number::Price->round() and "Budgeted cost tax exc." isn't.

Likely it shouldn't. And instead should just use "Total tax exc. (USD)" and sum it with "GST" instead of the internal value.
Having "Budgeted cost tax exc." also do it's own rounding(if syspref is on) from the internal value might have both be inconsistent: if one has the right value to be rounded and the other has not. Then "Total tax exc. (USD)" + "GST" sum will be different from "Budgeted cost tax exc.".

As of now. It's clear from the example it's using the internal value without rounding.

In the end it might need rounding after doing "Total tax exc. (USD)" + "GST".

We need to be sure how it's supposed to work.

------


Likely "GST" also has this issue of not following OrderPriceRounding. So a separate value to test would be useful.

Maybe vendor price = 18.90 also works?

18.90*0.95*0.1965 = 3.5281575

But then with OrderPriceRounding off it should round 3.52 with OrderPriceRounding off or should it not? Because it's always rounding to 3.53
Comment 4 Raphael Straub 2024-09-18 07:33:26 UTC
The problem here is in the updateCosts() function in acq.js. The financial calculations there should be done with a decimal datatype like Big of big.js (https://github.com/MikeMcl/big.js).
Comment 5 Victor Grousset/tuxayo 2024-09-22 20:38:34 UTC
Thanks for checking, I wrongly assumed that it was done in Perl like "Total tax exc".