From 446e81b6fba796b2b9b2dcdbb7db441805f6c1bf 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 | 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 9effa7e..2c61fd9 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 29018ac..80c9437 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) { @@ -387,7 +407,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 2e61a16..d76736f 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 -- 2.1.0