Bug 22115

Summary: Table of checkouts doesn't respect CurrencyFormat setting
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: CirculationAssignee: Katrin Fischer <katrin.fischer>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: david, gmcharlt, jonathan.druart, kyle.m.hall, lucas
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28874
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00
Bug Depends on:    
Bug Blocks: 22112    
Attachments: Bug 22115: Format prices in table of checkouts according to CurrencyFormat setting
Bug 22115: Format prices in table of checkouts according to CurrencyFormat setting
Bug 22115: Format prices in table of checkouts according to CurrencyFormat setting
Bug 22115: (QA follow-up) prevent wrap on price columns

Description Katrin Fischer 2019-01-12 07:50:16 UTC
The table of checkouts on the checkouts and details tabs in the patron account can display the columns Charge, Price and Fine. Those columns are not formatted according to the CurrencyFormat systme preference.

I don't know how to fix this. It appears the formatting is currently done in checkouts.js using toFixed(2):

Example:
                    "mDataProp": function ( oObj ) {
                        if ( ! oObj.charge ) oObj.charge = 0;
                        return '<span style="text-align: right; display: block;">' + parseFloat(oObj.charge).toFixed(2) + '<span>';
                    }
Comment 1 Owen Leonard 2021-10-07 16:29:31 UTC
Would it make sense to format the price in svc/checkouts?

e.g.

charge => Koha::Number::Price->new( $charge )->format_for_editing,

Not sure if that is correct, copied from Price.pm.
Comment 2 Jonathan Druart 2021-10-08 12:54:43 UTC
Ideally we need a JS function that copies what format_for_editing does.
Comment 3 Jonathan Druart 2022-02-11 12:28:13 UTC
We already have
koha-tmpl/intranet-tmpl/prog/en/includes/format_price.inc:    Number.prototype.format_price = function( value, params ) {
Comment 4 Katrin Fischer 2022-09-20 21:23:53 UTC
Created attachment 140807 [details] [review]
Bug 22115: Format prices in table of checkouts according to CurrencyFormat setting

In the patron account in the staff interface, all amounts in the
checkouts table should be formatted according to the CurrencyFormat
system preference setting.

To test:
* Edit some items, setting the replacement cost
* Make sure one of the item type is set to charge a rental charge
* Check out items
* Verify the checkouts table displays on both checkouts and details
  tabs correctly
* Try different settings of CurrencyFormat and verify all amounts
  display correctly
Comment 5 David Nind 2022-09-20 22:45:51 UTC
Created attachment 140811 [details] [review]
Bug 22115: Format prices in table of checkouts according to CurrencyFormat setting

In the patron account in the staff interface, all amounts in the
checkouts table should be formatted according to the CurrencyFormat
system preference setting.

To test:
* Edit some items, setting the replacement cost
* Make sure one of the item type is set to charge a rental charge
* Check out items
* Verify the checkouts table displays on both checkouts and details
  tabs correctly
* Try different settings of CurrencyFormat and verify all amounts
  display correctly

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2022-09-20 22:49:30 UTC
The only edge case I noticed was if the charge or replacement price is 1,000.00 or greater and the currency is FR, then because of the space instead of the , it appears in the columns for check out and details tabs as:
     1
000,00
Comment 7 Nick Clemens (kidclamp) 2022-10-03 11:39:33 UTC
Created attachment 141256 [details] [review]
Bug 22115: Format prices in table of checkouts according to CurrencyFormat setting

In the patron account in the staff interface, all amounts in the
checkouts table should be formatted according to the CurrencyFormat
system preference setting.

To test:
* Edit some items, setting the replacement cost
* Make sure one of the item type is set to charge a rental charge
* Check out items
* Verify the checkouts table displays on both checkouts and details
  tabs correctly
* Try different settings of CurrencyFormat and verify all amounts
  display correctly

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens (kidclamp) 2022-10-03 11:39:37 UTC
Created attachment 141257 [details] [review]
Bug 22115: (QA follow-up) prevent wrap on price columns

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Tomás Cohen Arazi 2022-10-03 15:41:38 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 10 Lucas Gass 2022-12-05 15:58:19 UTC
Doesn't apply cleanly to 22.05.x, no backport