X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=acqui%2Fbasketgroup.pl;h=b2ed7db5543d5f6c8c876ae0f7273650bc5851bb;hb=49f2837b2e75511becd09059db99d209917647a7;hp=cdb392d7218ee7ddbe719e21d7798a1a86903555;hpb=2dab2cc22334ee49b7eb2e67252ca484e63cb6cb;p=koha.git diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index cdb392d721..b2ed7db554 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -8,18 +8,18 @@ # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -47,22 +47,21 @@ use strict; use warnings; use Carp; -use C4::Input; use C4::Auth; use C4::Output; -use CGI; +use CGI qw ( -utf8 ); -use C4::Bookseller qw/GetBookSellerFromId/; use C4::Budgets qw/ConvertCurrency/; use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/; -use C4::Bookseller qw/GetBookSellerFromId/; use C4::Branch qw/GetBranches/; use C4::Members qw/GetMember/; +use Koha::Acquisition::Bookseller; + our $input=new CGI; our ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "acqui/basketgroup.tmpl", + = get_template_and_user({template_name => "acqui/basketgroup.tt", query => $input, type => "intranet", authnotrequired => 0, @@ -144,7 +143,7 @@ sub printbasketgrouppdf{ } my $basketgroup = GetBasketgroup($basketgroupid); - my $bookseller = GetBookSellerFromId($basketgroup->{'booksellerid'}); + my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basketgroup->{booksellerid} }); my $baskets = GetBasketsByBasketgroup($basketgroupid); my %orders; @@ -169,28 +168,7 @@ sub printbasketgrouppdf{ croak $@; } - $ord->{rrp} = ConvertCurrency( $ord->{'currency'}, $ord->{rrp} ); - if ( $bookseller->{'listincgst'} ) { - $ord->{rrpgsti} = sprintf( "%.2f", $ord->{rrp} ); - $ord->{gstgsti} = sprintf( "%.2f", $ord->{gstrate} * 100 ); - $ord->{rrpgste} = sprintf( "%.2f", $ord->{rrp} / ( 1 + ( $ord->{gstgsti} / 100 ) ) ); - $ord->{gstgste} = sprintf( "%.2f", $ord->{gstgsti} / ( 1 + ( $ord->{gstgsti} / 100 ) ) ); - $ord->{ecostgsti} = sprintf( "%.2f", $ord->{ecost} ); - $ord->{ecostgste} = sprintf( "%.2f", $ord->{ecost} / ( 1 + ( $ord->{gstgsti} / 100 ) ) ); - $ord->{gstvalue} = sprintf( "%.2f", ( $ord->{ecostgsti} - $ord->{ecostgste} ) * $ord->{quantity}); - $ord->{totalgste} = sprintf( "%.2f", $ord->{quantity} * $ord->{ecostgste} ); - $ord->{totalgsti} = sprintf( "%.2f", $ord->{quantity} * $ord->{ecostgsti} ); - } else { - $ord->{rrpgsti} = sprintf( "%.2f", $ord->{rrp} * ( 1 + ( $ord->{gstrate} ) ) ); - $ord->{rrpgste} = sprintf( "%.2f", $ord->{rrp} ); - $ord->{gstgsti} = sprintf( "%.2f", $ord->{gstrate} * 100 ); - $ord->{gstgste} = sprintf( "%.2f", $ord->{gstrate} * 100 ); - $ord->{ecostgsti} = sprintf( "%.2f", $ord->{ecost} * ( 1 + ( $ord->{gstrate} ) ) ); - $ord->{ecostgste} = sprintf( "%.2f", $ord->{ecost} ); - $ord->{gstvalue} = sprintf( "%.2f", ( $ord->{ecostgsti} - $ord->{ecostgste} ) * $ord->{quantity}); - $ord->{totalgste} = sprintf( "%.2f", $ord->{quantity} * $ord->{ecostgste} ); - $ord->{totalgsti} = sprintf( "%.2f", $ord->{quantity} * $ord->{ecostgsti} ); - } + $ord = C4::Acquisition::populate_order_with_prices({ order => $ord, booksellerid => $bookseller->{id}, ordering => 1 }); my $bib = GetBiblioData($ord->{biblionumber}); my $itemtypes = GetItemTypes(); @@ -212,17 +190,11 @@ sub printbasketgrouppdf{ } } - my $ba_order = { - isbn => ($ord->{isbn} ? $ord->{isbn} : undef), - itemtype => ( $ord->{itemtype} and $bib->{itemtype} ? $itemtypes->{$bib->{itemtype}}->{description} : undef ), - en => ( $en ? $en : undef ), - edition => ( $edition ? $edition : undef ), - }; - for my $key ( qw/ gstrate author title itemtype publishercode copyrightdate publicationyear discount quantity rrpgsti rrpgste gstgsti gstgste ecostgsti ecostgste gstvalue totalgste totalgsti order_vendornote / ) { - $ba_order->{$key} = $ord->{$key}; - } + $ord->{itemtype} = ( $ord->{itemtype} and $bib->{itemtype} ) ? $itemtypes->{$bib->{itemtype}}->{description} : undef; + $ord->{en} = $en ? $en : undef; + $ord->{edition} = $edition ? $edition : undef; - push(@ba_orders, $ba_order); + push(@ba_orders, $ord); } $orders{$basket->{basketno}} = \@ba_orders; } @@ -255,7 +227,7 @@ if ( $op eq "add" ) { # else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid # the template will know if basketgroup must be displayed or edited, depending on the value of closed key # - my $bookseller = &GetBookSellerFromId($booksellerid); + my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); my $basketgroupid = $input->param('basketgroupid'); my $billingplace; my $deliveryplace; @@ -382,7 +354,7 @@ if ( $op eq "add" ) { # FIXME } }else{ - # we create a new basketgroup (whith a closed basket) + # we create a new basketgroup (with a closed basket) $basketgroup = { name => $basketgroupname, booksellerid => $booksellerid, @@ -402,7 +374,7 @@ if ( $op eq "add" ) { }else{ # no param : display the list of all basketgroups for a given vendor my $basketgroups = &GetBasketgroups($booksellerid); - my $bookseller = &GetBookSellerFromId($booksellerid); + my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); my $baskets = &GetBasketsByBookseller($booksellerid); displaybasketgroups($basketgroups, $bookseller, $baskets);