From 236d34f13fd3b194e6251c8281da87126e004537 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Mar 2014 10:40:50 +0100 Subject: [PATCH] Bug 11733: gist can be multi-valued The gist syspref should always be treated as multi-value. In basketgroup.pl, parcel.pl and invoice.pl it is treated as single-value. The invoice.pl script will be fixed by bug 10613. If the pref contains several values, the first one is the default one (according to the syspref description). Test plan: No regression should be found on displaying total basketgroup for a vendor with 'list prices' don't include tax and 'invoice prices' include tax. No regression should be found on generating pdf. If no gstrate is defined for the vendor, the gstrate used should be the first one defined in the gist syspref. On parcel.pl, this patch only removes dead code. The $gst variable is not used. --- acqui/basketgroup.pl | 17 +++++++++++++---- acqui/parcel.pl | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index c050967..5ab12fd 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -77,9 +77,13 @@ sub BasketTotal { my @orders = GetOrders($basketno); for my $order (@orders){ $total = $total + ( $order->{ecost} * $order->{quantity} ); - if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{gstrate} // C4::Context->preference("gist") )) { - my $gst = $bookseller->{gstrate} // C4::Context->preference("gist"); - $total = $total * ( $gst / 100 +1); + if ( $bookseller->{invoiceincgst} && !$bookseller->{listincgst} ) { + my $gst = $bookseller->{gstrate}; + unless ( defined $gst ) { + ($gst) = split /\|/, C4::Context->preference("gist"); + } + $gst //= 0; + $total = $total * ( $gst / 100 + 1 ); } } $total .= " " . ($bookseller->{invoiceprice} // 0); @@ -225,7 +229,12 @@ sub printbasketgrouppdf{ -type => 'application/pdf', -attachment => ( $basketgroup->{name} || $basketgroupid ) . '.pdf' ); - my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} // C4::Context->preference("gist")) || die "pdf generation failed"; + my $gstrate = $bookseller->{gstrate}; + unless ( defined $gstrate ) { + ( $gstrate ) = split /\|/, C4::Context->preference("gist"); + } + + my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $gstrate) || die "pdf generation failed"; print $pdf; } diff --git a/acqui/parcel.pl b/acqui/parcel.pl index b45155c..04285fe 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -146,7 +146,6 @@ unless( $invoiceid and $invoice->{invoiceid} ) { my $booksellerid = $invoice->{booksellerid}; my $bookseller = GetBookSellerFromId($booksellerid); -my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; my $datereceived = C4::Dates->new(); my $cfstr = "%.2f"; # currency format string -- could get this from currency table. -- 1.7.10.4