Created attachment 6134 [details] actual cost on receipt page When receiving the actual cost is showing a whole lot more decimal points than it needs to. See attached.
Created attachment 7305 [details] [review] Added a sprintf to format the actual cost.
Simple change to add string formatting to numeric values. Marking Signed off and Passed QA in one go.
patch pushed, but this kind of display is a good candidate for : http://wiki.koha-community.org/wiki/Generalise_the_use_Template_Toolkit_plugins !
Resetting to Passed QA (by way of ASSIGNED, Needs Signoff, and Signed Off), since this patch does not appear to have been pushed.
This patch does not apply anymore (since bug 7175)
oups, mistake in the status...
Created attachment 10030 [details] [review] Bug 7129: Added a sprintf to format the actual cost. Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Rebased to current master, please test.
Tried to test this patch in a sandbox but could not put any items to the basket because a mandatory field was set to readonly and could not be edited. Should have nothing to do with this patch but can't signoff because can't test it.
Hi Mirko, try clicking the "Add link" at the end of the item form. Quantity will go up if you do that.
My bad, it works now and fixes the problem, thanks Katrin.
Created attachment 10216 [details] [review] [SIGNED-OFF] Bug 7129: Added a sprintf to format the actual cost. Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Rebased to current master, please test. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 10300 [details] [review] [PASSED QA] Bug 7129: Added a sprintf to format the actual cost. Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Rebased to current master, please test. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Ian Walls <koha.sekjal@gmail.com> QA note: changed call to use $order instead of @$results[0], for consistency with surrounding variables
Same work that passed QA the first time, just updated to reflect new variable names.
Patch pushed, but, in the long term, I'd love to see a "currency display" T::T plugin (I would be surprised if it does not exist already, as it's a very common need)
Does not apply for 3.8.x please reformat for 3.8.x
Created attachment 13735 [details] [review] Bug 7129 [3.8.x] actual cost showing too many zeros Reimplemented for 3.8.x: Added a sprintf to format the actual cost
Heres an approach using TT to format money amounts. At the top of the template declare [% USE money=format('%.2f') -%] then in the body of the template when you want to display e.g. price use [% money(price) %] It takes the display logic out of the the cgi scripts ( a good thing) and you've got an easier to maintain template
There are many existing examples in master of doing it this way: [% total | format('%.2f') %] ...which is a little more verbose if you have a lot of instances. It might be something we should have a guideline for. Since the patch I just submitted was a reworking for 3.8.x, I didn't want to re-do it in a different way. I can resubmit if the TT version is preferable.
I think it would be awesome if we had a plugin doing that, because it would allow us to extend the formatting options for different currencies later on.
Yeah a custom filter plugin would be good, since quite a few currencies format differently to 2dp, the plugin could do the right thing following the syspref, like KohaDates does.
Pushed to 3.8.x will be in 3.8.8
We must revert this patch, it introduces a bug if the unitprice is 0.0000. Instead of showing in this case the 'ecost' if there is not 'unitprice', it shows 0.00 and the 'Actual cost' must be manually entered. The line : if ( @$results[0]->{'unitprice'} == 0 ) { @$results[0]->{'unitprice'} = ''; was wrote in this perspective. But sprintf ( "%.2f", with '' or 0 or any string will return 0.00 and then, in the .tt 'unitprice' exists so we have the bad result. I have made a quick patch to just resolve this problem, but I think that the Colin's idea is nice, I will create a new patch to work in this way in the .tt page. I join the quick patch, but I think it would be better to make one with the Colin's idea. I am waiting for advises.
Created attachment 15337 [details] [review] transitional patch
Hello We have just discovered the problem, and I agree with Christophe Croullebois, it must be solved. I will test transitional patch tomorrow. M. Saby Rennes 2 university
Your corrective patch works : - before your patch : If unitprice = 0 in database, in receipt page, the value of "Actual cost" is 0 - before your patch : If unitprice = 0 in database, in receipt page, the value of "Actual cost" is ecost I sign it off. M. Saby
Created attachment 15990 [details] [review] [SIGNED-OFF] transitional patch
Created attachment 16300 [details] [review] (MT #11060) correction of a bug due to bz 7129 See comments in the patch Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
QA comment: * passes koha-qa.pl * small patch, I made some changes in the comment, for a better readability passed QA
What is this patch? If this is fixing a bug caused by 7129 it should be moved to a new bug, which can be set straight to "Passed QA."
Setting to In Discussion for review and probable patch movement by the author.
Ok Jared, I have created bz 9923 in "passed QA" Thx
follow-up in bug 9923