From 616bae1fee00099a89f29b0c3b1a11c4535244f3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 25 Sep 2014 11:21:49 +0200 Subject: [PATCH 1/3] 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 | 12 ++++++++++- .../prog/en/modules/acqui/neworderempty.tt | 22 +++++++++++++++++++- .../prog/en/modules/admin/itemtypes.tt | 18 ++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index bfaa44c..79d7cb2 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -112,10 +112,17 @@ if ( $op eq 'add_form' ) { $remote_image = $data->{imageurl}; } + 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'), @@ -144,6 +151,7 @@ elsif ( $op eq 'add_validate' ) { UPDATE itemtypes SET description = ? , rentalcharge = ? + , gstrate = ? , notforloan = ? , imageurl = ? , summary = ? @@ -156,6 +164,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' ? '' : ( @@ -174,7 +183,7 @@ elsif ( $op eq 'add_validate' ) { else { # add a new itemtype & not modif an old my $query = " INSERT INTO itemtypes - (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type) + (itemtype,description,rentalcharge, gstrate, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type) VALUES (?,?,?,?,?,?,?,?,?); "; @@ -184,6 +193,7 @@ elsif ( $op eq 'add_validate' ) { $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 72dfeca..ffd903d 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 %] + }); //]]> @@ -331,7 +351,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 9a691fb..2d93df4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -177,6 +177,19 @@ Item types administration
  • + + +
  • +
  • @@ -262,6 +275,7 @@ Item types administration Description Not for loan Charge + Tax rate Checkin message Actions @@ -280,6 +294,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