Bug 9374

Summary: In baskets, prices between 0 and 1 are displayed in red
Product: Koha Reporter: Mathieu Saby <mathsabypro>
Component: AcquisitionsAssignee: Mathieu Saby <mathsabypro>
Status: CLOSED FIXED QA Contact: Jonathan Druart <jonathan.druart>
Severity: minor    
Priority: P5 - low CC: cedric.vita, gmcharlt, jonathan.druart, tomascohen, tredok.pierre
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: [PATCH] Bug 9374: Only 0.00 prices must have class error in basket.tt
Bug 9374: Only 0.00 prices must have class error in basket.tt
Bug 9374: Only 0.00 prices must have class error in basket.tt
Bug 9374: The color should manage all zero format.
pic of a basket with several prices

Description Mathieu Saby 2013-01-09 15:55:34 UTC
Very cosmetic bug : 

In a basket, if some prices are between 0 and 1, they are displayed in red, with class = "number error".
For example, a VAT of 0.89 euros is displayed in red.
In don't think it is normal.
this behavior was introduced by http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7112

M. Saby
Rennes 2 university
Comment 1 Mathieu Saby 2013-09-15 11:16:09 UTC Comment hidden (obsolete)
Comment 2 cedric.vita 2013-09-19 13:49:59 UTC
Signing patches on sandbox (test1) did not work.
Thank you to "Sign-off" on.
Comment 3 Jonathan Druart 2013-09-19 14:37:24 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2013-09-20 07:43:29 UTC
Created attachment 21265 [details] [review]
Bug 9374: Only 0.00 prices must have class error in basket.tt

A regexp '^0' in basket.tt is used to give the class "error" to null prices.
It is wrong, because it matches prices like "0.15". It should only match "0.00".

To test :
- apply the patch
- display a basket with an order with a price between 0 and 1 (like "0.50") and an order with a price stricty null ("0.00")
- only the "0.00" price should be displayed in red

Signed-off-by: Cedric Vita <cedric.vita@dracenie.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 5 Jonathan Druart 2013-09-20 07:43:34 UTC
Created attachment 21266 [details] [review]
Bug 9374: The color should manage all zero format.

The format of prices in Koha is discuted in some bugs (e.g. 9410).
The good way will be to introduce a syspref in order to deal with the
number of decimal.
The previous patch is too restrictive, we should deal with other zero
format.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 6 Mathieu Saby 2013-09-20 07:46:21 UTC
I did not know bug 9410...
As you rewrite the patch, I suppose it need an other sign off ?

Mathieu
Comment 7 Jonathan Druart 2013-09-20 07:47:05 UTC
Created attachment 21268 [details]
pic of a basket with several prices
Comment 8 Galen Charlton 2013-09-21 21:32:34 UTC
Bugs 10792 and 10929 are somewhat related, as they touch on the general problem of  displaying monetary amounts.

Jonathan's follow-up patch bandaids the situation, but would become awkward if (say) the currency symbol started being displayed in the table.

The approach I'm proposing in my WIP branch for bug 10929 would instead just pass the numeric currency amount to the template and rely on TT filters to format it for display.  This, in turn, would mean that rather than having to use delicate regexes to see if an amount is zero, the template could simply do a numeric test.

I'll probably push the patches for this bug as is, but slap a FIXME on them, as the currency formatting revamp will simplify the template logic.
Comment 9 Jonathan Druart 2013-10-25 10:01:11 UTC
(In reply to Galen Charlton from comment #8)
> Bugs 10792 and 10929 are somewhat related, as they touch on the general
> problem of  displaying monetary amounts.

For information, I proposed a similar way in bug 9410.
Comment 10 Galen Charlton 2013-11-01 00:09:14 UTC
Pushed to master, along with a follow-up adding the promised FIXME.  Thanks, Mathieu!
Comment 11 Tomás Cohen Arazi (tcohen) 2013-12-05 19:02:08 UTC
This patch has been pushed to 3.12.x, will be in 3.12.8.

Thanks Mathieu!