From d8312333558c34d722ccacd3ccc4af28154bf112 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 25 Sep 2014 11:21:49 +0200 Subject: [PATCH] Bug 12993: Add a default tax rate on item types This enhancement permits to set a default tax rate for item types. If a default tax rate is defined for an item type, the tax rate will be automatically selected when the librarian choose the type of the item to order. Test plan: 0/ Execute the updatedb entry. 1/ Define a default tax rate for some item types. 2/ Create an order and verify the tax rate is selected after you have chosen the item type. Note that the item type is only displayed if defined at the biblio level. Signed-off-by: Paola Rossi --- admin/itemtypes.pl | 15 ++++++++++--- .../prog/en/modules/acqui/neworderempty.tt | 22 +++++++++++++++++++- .../prog/en/modules/admin/itemtypes.tt | 18 ++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 9e2fdfe..f393b56 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -122,10 +122,16 @@ if ( $op eq 'add_form' ) { my $searchcategory = GetAuthorisedValues("ITEMTYPECAT", $data->{'searchcategory'}); + my @gst_values = map { + option => $_ + 0.0 + }, split( '\|', C4::Context->preference("gist") ); + $template->param( itemtype => $itemtype, description => $data->{'description'}, rentalcharge => sprintf( "%.2f", $data->{'rentalcharge'} ), + gstrate => $data->{gstrate} ? $data->{gstrate}+0.0 : undef, + gst_values => \@gst_values, notforloan => $data->{'notforloan'}, imageurl => $data->{'imageurl'}, template => C4::Context->preference('template'), @@ -155,6 +161,7 @@ elsif ( $op eq 'add_validate' ) { UPDATE itemtypes SET description = ? , rentalcharge = ? + , gstrate = ? , notforloan = ? , imageurl = ? , summary = ? @@ -169,6 +176,7 @@ elsif ( $op eq 'add_validate' ) { $sth->execute( $input->param('description'), $input->param('rentalcharge'), + $input->param('gstrate'), ( $input->param('notforloan') ? 1 : 0 ), ( $input->param('image') eq 'removeImage' ? '' : ( @@ -189,16 +197,17 @@ elsif ( $op eq 'add_validate' ) { elsif ( not $already_exists and not $is_a_modif ) { my $query = " INSERT INTO itemtypes - (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type, hideinopac, searchcategory) + (itemtype,description,rentalcharge, gstrate, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type, hideinopac, searchcategory) VALUES - (?,?,?,?,?,?,?,?,?,?,?); + (?,?,?,?,?,?,?,?,?,?,?,?); "; my $sth = $dbh->prepare($query); - my $image = $input->param('image'); + my $image = $input->param('image'); $sth->execute( $input->param('itemtype'), $input->param('description'), $input->param('rentalcharge'), + $input->param('gstrate'), $input->param('notforloan') ? 1 : 0, $image eq 'removeImage' ? '' : $image eq 'remoteImage' ? $input->param('remoteImage') : diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index 7638f02..87edff2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -159,6 +159,26 @@ $(document).ready(function() getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 ); }); $("#budget_id").change(); + + // Select the gstrate function of the itemtype + [% IF itemtypeloop %] + var itemtype_gstrate_map = {}; + [% FOREACH itemtype IN itemtypeloop %] + [% IF itemtype.gstrate.length > 0 %] + itemtype_gstrate_map['[%itemtype.itemtype%]'] = [% itemtype.gstrate %]; + [% END %] + [% END %] + + $("#itemtype").change(function(){ + var gstrate = itemtype_gstrate_map[$(this).val()]; + if ( gstrate != undefined ) { + $("#gstrate option[value='"+gstrate+"']").attr('selected', 'selected'); + $("#gstrate").change(); + } + }); + $("#itemtype").change(); + [% END %] + }); function UserSearchPopup(f) { @@ -386,7 +406,7 @@ $(document).ready(function() [% IF ( itemtypeloop ) %]
  • Item type: - [% FOREACH itemtype IN itemtypeloop %] [% IF ( itemtype.selected ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index 6b2ab05..eaf4cef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -223,6 +223,19 @@ Item types administration
  • + + +
  • +
  • @@ -310,6 +323,7 @@ Item types administration Not for loan Hide in OPAC Charge + Tax rate Checkin message Actions @@ -344,6 +358,10 @@ Item types administration [% loo.rentalcharge %] [% END %] + + [% IF loo.gstrate.length > 0 %] + [% loo.gstrate * 100 | format("%.1f") %]% + [% END %] [% loo.checkinmsg | html_line_break %] Edit -- 1.7.10.4