Bug 21427

Summary: Format prices on ordered/spent lists
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: AcquisitionsAssignee: Katrin Fischer <katrin.fischer>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: bklein, jonathan.druart, katrin.fischer, martin.renvoize, nick
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18736
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 21282    
Bug Blocks: 22112    
Attachments: Bug 21427: Format prices on ordered/spent lists
Bug 21427: Format prices on ordered/spent lists consistently
Bug 21427: Format prices on ordered/spent lists consistently
Bug 21427: Format prices on ordered/spent lists consistently
Bug 21427: (QA follow-up) Fix for tabs

Description Martin Renvoize 2018-09-27 11:53:19 UTC
On bug 19271 we decided that the work to fix the prices should be split out into it's own bug.

Leaving all credit to Katrin for spotting the issue and the initial patch.
Comment 1 Martin Renvoize 2018-09-27 11:53:57 UTC
Created attachment 79485 [details] [review]
Bug 21427: Format prices on ordered/spent lists

 Improvements to the display of lists of ordered and received orders:
 - Format prices according to CurrencyFormat system preference

 To test:
 - Make sure you have some pending and received orders
 - Access the Spent and Ordered pages by clicking on the
   amount ordered or spent on the acq start page
   - Verify that
     - All price information is shown according to CurrencyFormat

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 2 Martin Renvoize 2018-09-27 11:57:05 UTC
Copying across Jonathans issue with this implimentation:

(Jonathan Druart from comment #5)
> I would not format the prices in the same patch/bug report, I am expecting
> regressions here: sum of round numbers (sprintf %.2f) vs round of sum (if it
> makes sense...)

(Jonathan Druart from comment #7)
> use Modern::Perl;
> my $x = 12.344;
> my $y = 67.213;
> say sprintf("%.2f", $x)+sprintf("%.2f", $y);
> say sprintf("%.2f", $x+$y);'
> 
> 79.55
> 79.56

(Martin Renvoize from comment #8)
> Man that's upsetting, but I have to agree with Jonathan here..  the totals
> shouldn't really be calculated in this script in my opinion.  But because
> they are, we can't make this change here.
> 
> Could we perhaps split into two bugs please Katrin?
Comment 3 Katrin Fischer 2018-09-27 22:16:12 UTC
Is it possible that this will not be a regression but a bug fix? It seems wrong that we added up the truncated prices int he first place?
Comment 4 Martin Renvoize 2018-09-28 08:36:38 UTC
I agree it's likely a bugfix.. however, I'm not sure about its implementation here.. I'd like to get Nicks opinion as it's overlapping with bug 18736 round errors.  Ok, so in this case it's only at display time, but it's at display time that users will actually see the end results of the calculations and so those displayed numbers are what end users will expect are used throughout calculations within the system.

My point really is that 'different' isn't necessarily wrong.. but I'm not qualified to argue for or against moving to it.
Comment 5 Martin Renvoize 2018-09-28 08:38:14 UTC
Also.. in reality I'd be more comfortable with these calculations being shifted up a level into the objects rather than in the display scripts.. that way the same calculations would be shared system-wide rather than risking them being re-implemented elsewhere in a different way.
Comment 6 Nick Clemens 2018-09-28 13:07:51 UTC
Talked to Katrin - I think we can do as she suggested on bug 19271 - don't touch the scripts and simply add the price filter on display
Comment 7 Martin Renvoize 2018-10-02 09:44:56 UTC
I'm game for that :)
Comment 8 Katrin Fischer 2018-11-01 11:58:43 UTC
21282 adds a bit of filters. Waiting for that one.
Comment 9 Brian 2018-11-01 20:00:55 UTC
what's the status of bug 21427?

Carnegie Stout Team
Comment 10 Katrin Fischer 2019-01-11 21:59:18 UTC
Created attachment 83831 [details] [review]
Bug 21427: Format prices on ordered/spent lists consistently

Some price information on the spent and ordered list already
used the $Price filter. With this patch all amounts should be
formatted according to the CurrencyFormat system preference.

1) Switch CurrencyFormat to FR
2) Make sure you have
  - Pending orders
  - An open invoice with shipment cost and
    adjustment with "encumber while open" checked
  - A received order
  - A closed invoice with shipment cost and
    adjustment
3) View the "oder" and "spent" lists clicking on the
   amounts in the budget and funds table on the acq
   start page
4) Verify all price information is formatted wit
   decimal comma
5) Switch CurrencyFormat to other settings and verify
   display changes accordingly
Comment 11 Katrin Fischer 2019-01-11 22:01:40 UTC
(In reply to Brian from comment #9)
> what's the status of bug 21427?
> 
> Carnegie Stout Team

Hi Carnegie Stout, took me a bit to get back to this. New patch added, would be easy to test with sandboxes (https://wiki.koha-community.org/wiki/Sandboxes) ;)
Comment 12 Jack 2019-01-17 22:15:50 UTC
Created attachment 84168 [details] [review]
Bug 21427: Format prices on ordered/spent lists consistently

Some price information on the spent and ordered list already
used the $Price filter. With this patch all amounts should be
formatted according to the CurrencyFormat system preference.

Signed-off-by: Jack Kelliher <jke0429@stacmail.net>
Comment 13 Martin Renvoize 2019-02-08 16:55:38 UTC
Created attachment 84886 [details] [review]
Bug 21427: Format prices on ordered/spent lists consistently

Some price information on the spent and ordered list already
used the $Price filter. With this patch all amounts should be
formatted according to the CurrencyFormat system preference.

Signed-off-by: Jack Kelliher <jke0429@stacmail.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Martin Renvoize 2019-02-08 16:55:41 UTC
Created attachment 84887 [details] [review]
Bug 21427: (QA follow-up) Fix for tabs

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 15 Martin Renvoize 2019-02-08 16:56:25 UTC
Added tab fixing followup.

Nice to see this one working it's way through.. happy to pass qa now.
Comment 16 Nick Clemens 2019-02-19 14:01:54 UTC
Awesome work all!

Pushed to master for 19.05
Comment 17 Nick Clemens 2019-02-19 14:35:44 UTC
Awesome work all!

Pushed to master for 19.05
Comment 18 Martin Renvoize 2019-02-26 09:04:08 UTC
Pushed to 18.11.x for 18.11.04