Bug 22116: Add price formatting to rental charge and replacement price on items tab...
authorKatrin Fischer <katrin.fischer.83@web.de>
Sat, 5 Jan 2019 06:45:05 +0000 (06:45 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 12 Feb 2019 13:19:49 +0000 (13:19 +0000)
Adds formatting to replacement price and rental charge on items
tab.

To test:
- Add a rental charge to one or more of your item types
- Edit a record with some items, add replacement cost to some
- Find or create a record with your rental charged itemtype (MARC21:942$c)
- Go to the staff detail page of those records
- Check "Items" tab for
  - Rental charge on top
  - Replacement price for items
- Verify information is displayed correctly when toggling CurrencyFormat
  system preference

Signed-off-by: Jack Kelliher <jke0429@stacmail.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 89ae6cc3bfea81dea8d6995965a44b92c34764aa)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

catalogue/moredetail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt

index ba59937..6adcca9 100755 (executable)
@@ -128,7 +128,7 @@ my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_l
 
 $data->{'itemtypename'} = $itemtypes->{ $data->{'itemtype'} }->{'translated_description'}
   if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
-$data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} || 0); # Price formatting should be done template-side
+$data->{'rentalcharge'} = $data->{'rentalcharge'};
 foreach ( keys %{$data} ) {
     $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
 }
@@ -138,7 +138,7 @@ foreach my $item (@items){
     $item->{object} = Koha::Items->find( $item->{itemnumber} );
     $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
     $item->{'itype'}                   = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} };
-    $item->{'replacementprice'}        = sprintf( "%.2f", $item->{'replacementprice'} || 0 ); # Price formatting should be done template-side
+    $item->{'replacementprice'}        = $item->{'replacementprice'};
     if ( defined $item->{'copynumber'} ) {
         $item->{'displaycopy'} = 1;
         if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
index 4474432..dcf37b7 100644 (file)
@@ -2,6 +2,7 @@
 [% USE Asset %]
 [% USE Koha %]
 [% USE Branches %]
+[% USE Price %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Catalog &rsaquo; Item details for [% title | html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %]</title>
@@ -32,7 +33,7 @@
         [% UNLESS ( item_level_itypes ) %]
         <li><span class="label">Item type:</span> [% itemtypename | html %]&nbsp;</li>
         [% END %]
-        [% IF ( rentalcharge ) %]<li><span class="label">Rental charge:</span>[% rentalcharge | html %]&nbsp;</li>[% END %]
+        [% IF ( rentalcharge ) %]<li><span class="label">Rental charge:</span>[% rentalcharge | $Price %]&nbsp;</li>[% END %]
         <li><span class="label">ISBN:</span> [% isbn | html %]&nbsp;</li>
         <li><span class="label">Publisher:</span>[% place | html %] [% publishercode | html %] [% publicationyear | html %]&nbsp;</li>
         [% IF ( volumeddesc ) %]<li><span class="label">Volume:</span> [% volumeddesc | html %]</li>[% END %]
@@ -62,7 +63,7 @@
             [% IF ( ITEM_DAT.collection ) %]<li><span class="label">Collection:</span> [% ITEM_DAT.collection | html %]</li> [% END %]
             <li><span class="label">Item callnumber:</span> [% ITEM_DAT.itemcallnumber | html %]&nbsp;</li>
             [% IF ( ITEM_DAT.displaycopy ) %]<li><span class="label">Copy number:</span> [% ITEM_DAT.copyvol | html %]&nbsp;</li> [% END %]
-            [% IF ( ITEM_DAT.replacementprice ) %]<li><span class="label">Replacement price:</span> [% ITEM_DAT.replacementprice | html %]&nbsp;</li> [% END %]
+            [% IF ( ITEM_DAT.replacementprice ) %]<li><span class="label">Replacement price:</span> [% ITEM_DAT.replacementprice | $Price %]&nbsp;</li> [% END %]
            [% IF ITEM_DAT.materials %]<li><span class="label">Materials specified:</span> [% ITEM_DAT.materials | html %] </li> [% END %]
             </ol></div>
            <div class="listgroup"><h4>Statuses [% IF ( ITEM_DAT.status_advisory ) %](