From 7521bec267e58d309373f530385e44a53b2cf0ff Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@biblibre.com> Date: Fri, 24 Feb 2012 16:24:05 +0100 Subject: [PATCH 1/1] BZ5335: More granular VAT --- C4/Acquisition.pm | 12 +- acqui/addorder.pl | 45 +--- acqui/addorderiso2709.pl | 18 +- acqui/basket.pl | 240 ++++++++++---------- acqui/finishreceive.pl | 74 +++++-- acqui/neworderempty.pl | 38 ++-- acqui/orderreceive.pl | 91 +++++--- acqui/parcel.pl | 144 ++++++++---- acqui/supplier.pl | 19 +- acqui/updatesupplier.pl | 9 +- installer/data/mysql/kohastructure.sql | 3 +- installer/data/mysql/updatedatabase.pl | 15 ++ koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 52 ++--- .../prog/en/modules/acqui/addorderiso2709.tt | 2 +- .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 148 ++++++++----- .../prog/en/modules/acqui/neworderempty.tt | 89 ++++---- .../prog/en/modules/acqui/orderreceive.tt | 6 +- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 75 ++---- .../prog/en/modules/acqui/supplier.tt | 17 +- .../en/modules/admin/preferences/acquisitions.pref | 4 +- .../prog/en/modules/serials/subscription-detail.tt | 34 +++ serials/subscription-detail.pl | 27 +++ 22 files changed, 673 insertions(+), 489 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index bebc3a8..2fb6ce8 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -918,7 +918,7 @@ Else, the upcoming July 1st is used. =item defaults entrydate to Now -The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "biblioitemnumber", "rrp", "ecost", "gst", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "bookfundid". +The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "biblioitemnumber", "rrp", "ecost", "gstrate", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "bookfundid". =back @@ -1137,7 +1137,7 @@ C<$ordernumber>. sub ModReceiveOrder { my ( - $biblionumber, $ordernumber, $quantrec, $user, $cost, + $biblionumber, $ordernumber, $quantrec, $user, $cost, $ecost, $invoiceno, $freight, $rrp, $budget_id, $datereceived ) = @_; @@ -1168,10 +1168,11 @@ sub ModReceiveOrder { , unitprice=? , freight=? , rrp=? + , ecost=? , quantity=? WHERE biblionumber=? AND ordernumber=?"); - $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber); + $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$ecost,$quantrec,$biblionumber,$ordernumber); $sth->finish; # create a new order for the remaining items, and set its bookfund. @@ -1184,9 +1185,9 @@ sub ModReceiveOrder { } else { $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?, - unitprice=?,freight=?,rrp=? + unitprice=?,freight=?,rrp=?,ecost=? where biblionumber=? and ordernumber=?"); - $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber); + $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$ecost,$biblionumber,$ordernumber); $sth->finish; } return $datereceived; @@ -1336,6 +1337,7 @@ sub GetParcel { aqorders.listprice, aqorders.rrp, aqorders.ecost, + aqorders.gstrate, biblio.title FROM aqorders LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 279084b..d741eba 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -153,39 +153,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $orderinfo = $input->Vars; $orderinfo->{'list_price'} ||= 0; $orderinfo->{'uncertainprice'} ||= 0; -#my $ordernumber = $input->param('ordernumber'); -#my $basketno = $input->param('basketno'); -#my $booksellerid = $input->param('booksellerid'); -#my $existing = $input->param('existing'); # existing biblio, (not basket or order) -#my $title = $input->param('title'); -#my $author = $input->param('author'); -#my $publicationyear= $input->param('publicationyear'); -#my $isbn = $input->param('ISBN'); -#my $itemtype = $input->param('format'); -#my $quantity = $input->param('quantity'); # FIXME: else ERROR! -#my $branch = $input->param('branch'); -#my $series = $input->param('series'); -#my $notes = $input->param('notes'); -#my $budget_id = $input->param('budget_id'); -#my $sort1 = $input->param('sort1'); -#my $sort2 = $input->param('sort2'); -#my $rrp = $input->param('rrp'); -#my $ecost = $input->param('ecost'); -#my $gst = $input->param('GST'); -#my $budget = $input->param('budget'); -#my $cost = $input->param('cost'); -#my $sub = $input->param('sub'); -#my $purchaseorder = $input->param('purchaseordernumber'); -#my $invoice = $input->param('invoice'); -#my $publishercode = $input->param('publishercode'); -#my $suggestionid = $input->param('suggestionid'); -#my $biblionumber = $input->param('biblionumber'); -#my $uncertainprice = $input->param('uncertainprice'); -#my $import_batch_id= $input->param('import_batch_id'); -# -#my $createbibitem = $input->param('createbibitem'); -# -my $user = $input->remote_user; + +my $user = $input->remote_user; + # create, modify or delete biblio # create if $quantity>=0 and $existing='no' # modify if $quantity>=0 and $existing='yes' @@ -207,6 +177,13 @@ if ( $orderinfo->{quantity} ne '0' ) { "biblio.copyrightdate" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "", "biblioitems.itemtype" => $$orderinfo{itemtype} ? $$orderinfo{itemtype} : "", "biblioitems.editionstatement"=> $$orderinfo{editionstatement} ? $$orderinfo{editionstatement} : "", + "aqorders.branchcode" => $$orderinfo{branchcode} ? $$orderinfo{branchcode} : "", + "aqorders.quantity" => $$orderinfo{quantity} ? $$orderinfo{quantity} : "", + "aqorders.listprice" => $$orderinfo{listprice} ? $$orderinfo{listprice} : "", + "aqorders.uncertainprice" => $$orderinfo{uncertainprice} ? $$orderinfo{uncertainprice} : "", + "aqorders.rrp" => $$orderinfo{rrp} ? $$orderinfo{rrp} : "", + "aqorders.ecost" => $$orderinfo{ecost} ? $$orderinfo{ecost} : "", + "aqorders.discount" => $$orderinfo{discount} ? $$orderinfo{discount} : "", }); # create the record in catalogue, with framework '' @@ -219,6 +196,8 @@ if ( $orderinfo->{quantity} ne '0' ) { $orderinfo->{biblionumber}=$biblionumber; } + $orderinfo->{unitprice} = $orderinfo->{ecost} if not defined $orderinfo->{unitprice} or $orderinfo->{unitprice} eq ''; + # if we already have $ordernumber, then it's an ordermodif if ($$orderinfo{ordernumber}) { ModOrder( $orderinfo); diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index 8d9c0e3..7b0227b 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -207,10 +207,12 @@ if ($op eq ""){ # we suppose the currency is correct, as we have no possibilities to get it. my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour')); if ($price){ + # in France, the cents separator is the , but sometimes, ppl use a . + # in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation + $price =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR"; $price = $num->unformat_number($price); } if ($price){ - $orderinfo{'listprice'} = $price; eval { require C4::Acquisition; import C4::Acquisition qw/GetBasket/; @@ -227,13 +229,19 @@ if ($op eq ""){ } my $basket = GetBasket( $orderinfo{basketno} ); my $bookseller = GetBookSellerFromId( $basket->{booksellerid} ); - my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0; - $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) ); - $orderinfo{'ecost'} = $orderinfo{unitprice}; + $orderinfo{gstrate} = $bookseller->{gstrate}; + if ( $bookseller->{listincgst} ) { + $orderinfo{ecost} = $price; + } else { + $orderinfo{ecost} = $price * ( 1 + $orderinfo{gstrate} ); + } + $orderinfo{rrp} = ( $orderinfo{ecost} * 100 ) / ( 100 - $bookseller->{discount} ); + $orderinfo{listprice} = $orderinfo{rrp}; + $orderinfo{unitprice} = $orderinfo{ecost}; + $orderinfo{total} = $orderinfo{ecost}; } else { $orderinfo{'listprice'} = 0; } - $orderinfo{'rrp'} = $orderinfo{'listprice'}; # remove uncertainprice flag if we have found a price in the MARC record $orderinfo{uncertainprice} = 0 if $orderinfo{listprice}; diff --git a/acqui/basket.pl b/acqui/basket.pl index de66891..80dea5c 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -231,121 +231,47 @@ if ( $op eq 'delete_confirm' ) { "loggedinuser: $loggedinuser; creationdate: %s; authorisedby: %s", $basket->{creationdate}, $basket->{authorisedby}; - #to get active currency - my $cur = GetCurrency(); + #to get active currency + my $cur = GetCurrency(); my @results = GetOrders( $basketno ); - - my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; - $gist = 0 if $gist == 0.0000; - my $discount = $bookseller->{'discount'} / 100; - my $total_rrp = 0; # RRP Total, its value will be assigned to $total_rrp_gsti or $total_rrp_gste depending of $bookseller->{'listincgst'} - my $total_rrp_gsti = 0; # RRP Total, GST included - my $total_rrp_gste = 0; # RRP Total, GST excluded - my $gist_rrp = 0; - my $total_rrp_est = 0; - - my $qty_total; my @books_loop; - my $suggestion; - for my $order ( @results ) { - my $rrp = $order->{'listprice'} || 0; - my $qty = $order->{'quantity'} || 0; - if (!defined $order->{quantityreceived}) { - $order->{quantityreceived} = 0; - } - for ( qw(rrp ecost quantityreceived)) { - if (!defined $order->{$_}) { - $order->{$_} = 0; - } - } - - my $budget = GetBudget( $order->{'budget_id'} ); - $rrp = ConvertCurrency( $order->{'currency'}, $rrp ); - - $total_rrp += $qty * $order->{'rrp'}; - my $line_total = $qty * $order->{'ecost'}; - $total_rrp_est += $qty * $order->{'ecost'}; - # FIXME: what about the "actual cost" field? - $qty_total += $qty; - my %line = %{ $order }; - my $biblionumber = $order->{'biblionumber'}; - my $countbiblio = CountBiblioInOrders($biblionumber); - my $ordernumber = $order->{'ordernumber'}; - my @subscriptions = GetSubscriptionsId ($biblionumber); - my $itemcount = GetItemsCount($biblionumber); - my $holds = GetHolds ($biblionumber); - my @items = GetItemnumbersFromOrder( $ordernumber ); - my $itemholds; - foreach my $item (@items){ - my $nb = GetItemHolds($biblionumber, $item); - if ($nb){ - $itemholds += $nb; - } - } - # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 - $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); - $line{items} = ($itemcount) - (scalar @items); - $line{left_item} = 1 if $line{items} >= 1; - $line{left_biblio} = 1 if $countbiblio > 1; - $line{biblios} = $countbiblio - 1; - $line{left_subscription} = 1 if scalar @subscriptions >= 1; - $line{subscriptions} = scalar @subscriptions; - ($holds >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0; - $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); - $line{holds} = $holds; - $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; - $line{order_received} = ( $qty == $order->{'quantityreceived'} ); - $line{basketno} = $basketno; - $line{budget_name} = $budget->{budget_name}; - $line{rrp} = sprintf( "%.2f", $line{'rrp'} ); - $line{ecost} = sprintf( "%.2f", $line{'ecost'} ); - $line{line_total} = sprintf( "%.2f", $line_total ); - if ($line{uncertainprice}) { + my @book_foot_loop; + my %foot; + my $total_quantity = 0; + my $total_gste = 0; + my $total_gsti = 0; + my $total_gstvalue = 0; + for my $order (@results) { + my $line = get_order_infos( $order, $bookseller); + if ( $line->{uncertainprice} ) { $template->param( uncertainprices => 1 ); - $line{rrp} .= ' (Uncertain)'; } - if ($line{'title'}){ - my $volume = $order->{'volume'}; - my $seriestitle = $order->{'seriestitle'}; - $line{'title'} .= " / $seriestitle" if $seriestitle; - $line{'title'} .= " / $volume" if $volume; - } else { - $line{'title'} = "Deleted bibliographic notice, can't find title."; - } - - $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); - $line{suggestionid} = $suggestion->{suggestionid}; - $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; - $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; - - push @books_loop, \%line; + + push @books_loop, $line; + + $foot{$$line{gstgsti}}{gstgsti} = $$line{gstgsti}; + $foot{$$line{gstgsti}}{gstvalue} += $$line{gstvalue}; + $total_gstvalue += $$line{gstvalue}; + $foot{$$line{gstgsti}}{quantity} += $$line{quantity}; + $total_quantity += $$line{quantity}; + $foot{$$line{gstgsti}}{totalgste} += $$line{totalgste}; + $total_gste += $$line{totalgste}; + $foot{$$line{gstgsti}}{totalgsti} += $$line{totalgsti}; + $total_gsti += $$line{totalgsti}; } -my $total_est_gste; - my $total_est_gsti; - my $gist_est; - if ($gist){ # if we have GST - if ( $bookseller->{'listincgst'} ) { # if prices already includes GST - $total_rrp_gsti = $total_rrp; # we know $total_rrp_gsti - $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 ); # and can reverse compute other values - $gist_rrp = $total_rrp_gsti - $total_rrp_gste; # - $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount ); - $total_est_gsti = $total_rrp_est; - } else { # if prices does not include GST - $total_rrp_gste = $total_rrp; # then we use the common way to compute other values - $gist_rrp = $total_rrp_gste * $gist; # - $total_rrp_gsti = $total_rrp_gste + $gist_rrp; # - $total_est_gste = $total_rrp_est; - $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount ); - } - $gist_est = $gist_rrp - ( $gist_rrp * $discount ); - } else { - $total_rrp_gsti = $total_rrp; - $total_est_gsti = $total_rrp_est; -} + push @book_foot_loop, map {$_} values %foot; + + # Get cancelled orders + @results = GetCancelledOrders($basketno); + my @cancelledorders_loop; + for my $order (@results) { + my $line = get_infos( $order, $bookseller); + push @cancelledorders_loop, $line; + } my $contract = &GetContract($basket->{contractnumber}); my @orders = GetOrders($basketno); @@ -382,18 +308,14 @@ my $total_est_gste; booksellerid => $bookseller->{'id'}, name => $bookseller->{'name'}, books_loop => \@books_loop, + book_foot_loop => \@book_foot_loop, cancelledorders_loop => \@cancelledorders, - gist_rate => sprintf( "%.2f", $gist * 100 ) . '%', - total_rrp_gste => sprintf( "%.2f", $total_rrp_gste ), - total_est_gste => sprintf( "%.2f", $total_est_gste ), - gist_est => sprintf( "%.2f", $gist_est ), - gist_rrp => sprintf( "%.2f", $gist_rrp ), - total_rrp_gsti => sprintf( "%.2f", $total_rrp_gsti ), - total_est_gsti => sprintf( "%.2f", $total_est_gsti ), -# currency => $bookseller->{'listprice'}, - currency => $cur->{'currency'}, - qty_total => $qty_total, - GST => $gist, + total_quantity => $total_quantity, + total_gste => sprintf( "%.2f", $total_gste ), + total_gsti => sprintf( "%.2f", $total_gsti ), + total_gstvalue => sprintf( "%.2f", $total_gstvalue ), + currency => $cur->{'currency'}, + listincgst => $bookseller->{listincgst}, basketgroups => $basketgroups, grouped => $basket->{basketgroupid}, unclosable => @orders ? 0 : 1, @@ -401,4 +323,88 @@ my $total_est_gste; ); } +sub get_order_infos { + my $order = shift; + my $bookseller = shift; + my $qty = $order->{'quantity'} || 0; + if ( !defined $order->{quantityreceived} ) { + $order->{quantityreceived} = 0; + } + my $budget = GetBudget( $order->{'budget_id'} ); + + my %line = %{ $order }; + $line{order_received} = ( $qty == $order->{'quantityreceived'} ); + $line{basketno} = $basketno; + $line{budget_name} = $budget->{budget_name}; + $line{rrp} = ConvertCurrency( $order->{'currency'}, $line{rrp} ); # FIXME from comm + if ( $bookseller->{'listincgst'} ) { + $line{rrpgsti} = sprintf( "%.2f", $line{rrp} ); + $line{gstgsti} = sprintf( "%.2f", $line{gstrate} * 100 ); + $line{rrpgste} = sprintf( "%.2f", $line{rrp} / ( 1 + ( $line{gstgsti} / 100 ) ) ); + $line{gstgste} = sprintf( "%.2f", $line{gstgsti} / ( 1 + ( $line{gstgsti} / 100 ) ) ); + $line{ecostgsti} = sprintf( "%.2f", $line{ecost} ); + $line{ecostgste} = sprintf( "%.2f", $line{ecost} / ( 1 + ( $line{gstgsti} / 100 ) ) ); + $line{gstvalue} = sprintf( "%.2f", ( $line{ecostgsti} - $line{ecostgste} ) * $line{quantity}); + $line{totalgste} = sprintf( "%.2f", $order->{quantity} * $line{ecostgste} ); + $line{totalgsti} = sprintf( "%.2f", $order->{quantity} * $line{ecostgsti} ); + } else { + $line{rrpgsti} = sprintf( "%.2f", $line{rrp} * ( 1 + ( $line{gstrate} ) ) ); + $line{rrpgste} = sprintf( "%.2f", $line{rrp} ); + $line{gstgsti} = sprintf( "%.2f", $line{gstrate} * 100 ); + $line{gstgste} = sprintf( "%.2f", $line{gstrate} * 100 ); + $line{ecostgsti} = sprintf( "%.2f", $line{ecost} * ( 1 + ( $line{gstrate} ) ) ); + $line{ecostgste} = sprintf( "%.2f", $line{ecost} ); + $line{gstvalue} = sprintf( "%.2f", ( $line{ecostgsti} - $line{ecostgste} ) * $line{quantity}); + $line{totalgste} = sprintf( "%.2f", $order->{quantity} * $line{ecostgste} ); + $line{totalgsti} = sprintf( "%.2f", $order->{quantity} * $line{ecostgsti} ); + } + + if ( $line{uncertainprice} ) { + $line{rrpgste} .= ' (Uncertain)'; + } + if ( $line{'title'} ) { + my $volume = $order->{'volume'}; + my $seriestitle = $order->{'seriestitle'}; + $line{'title'} .= " / $seriestitle" if $seriestitle; + $line{'title'} .= " / $volume" if $volume; + } else { + $line{'title'} = "Deleted bibliographic notice, can't find title."; + } + + my $biblionumber = $order->{'biblionumber'}; + my $countbiblio = CountBiblioInOrders($biblionumber); + my $ordernumber = $order->{'ordernumber'}; + my @subscriptions = GetSubscriptionsId ($biblionumber); + my $itemcount = GetItemsCount($biblionumber); + my $holds = GetHolds ($biblionumber); + my @items = GetItemnumbersFromOrder( $ordernumber ); + my $itemholds; + foreach my $item (@items){ + my $nb = GetItemHolds($biblionumber, $item); + if ($nb){ + $itemholds += $nb; + } + } + # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 + $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); + $line{items} = ($itemcount) - (scalar @items); + $line{left_item} = 1 if $line{items} >= 1; + $line{left_biblio} = 1 if $countbiblio > 1; + $line{biblios} = $countbiblio - 1; + $line{left_subscription} = 1 if scalar @subscriptions >= 1; + $line{subscriptions} = scalar @subscriptions; + ($holds >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0; + $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); + $line{holds} = $holds; + $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; + + + my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); + $line{suggestionid} = $$suggestion{suggestionid}; + $line{surnamesuggestedby} = $$suggestion{surnamesuggestedby}; + $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby}; + + return \%line; +} + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index d09a40a..ed006c8 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -28,6 +28,7 @@ use C4::Output; use C4::Context; use C4::Acquisition; use C4::Biblio; +use C4::Bookseller; use C4::Items; use C4::Search; use List::MoreUtils qw/any/; @@ -37,24 +38,25 @@ my $flagsrequired = {acquisition => 'order_receive'}; checkauth($input, 0, $flagsrequired, 'intranet'); -my $user=$input->remote_user; -my $biblionumber = $input->param('biblionumber'); -my $biblioitemnumber=$input->param('biblioitemnumber'); -my $ordernumber=$input->param('ordernumber'); -my $origquantityrec=$input->param('origquantityrec'); -my $quantityrec=$input->param('quantityrec'); -my $quantity=$input->param('quantity'); -my $unitprice=$input->param('cost'); -my $invoiceno=$input->param('invoice'); -my $datereceived=$input->param('datereceived'); -my $replacement=$input->param('rrp'); -my $gst=$input->param('gst'); -my $freight=$input->param('freight'); -my $booksellerid = $input->param('booksellerid'); -my $cnt=0; +my $user = $input->remote_user; +my $biblionumber = $input->param('biblionumber'); +my $biblioitemnumber = $input->param('biblioitemnumber'); +my $ordernumber = $input->param('ordernumber'); +my $origquantityrec = $input->param('origquantityrec'); +my $quantityrec = $input->param('quantityrec'); +my $quantity = $input->param('quantity'); +my $unitprice = $input->param('cost'); +my $invoiceno = $input->param('invoice'); +my $datereceived = $input->param('datereceived'); +my $freight = $input->param('freight'); +my $booksellerid = $input->param('booksellerid'); +my $cnt = 0; my $error_url_str; -my $ecost = $input->param('ecost'); -my $note = $input->param("note"); +my $ecost = $input->param('ecost'); +my $rrp = $input->param('rrp'); +my $note = $input->param("note"); +my $order = GetOrder($ordernumber); +my $unitprice = $input->param('cost'); #need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME if ($quantityrec > $origquantityrec ) { @@ -94,14 +96,44 @@ if ($quantityrec > $origquantityrec ) { NewOrderItem($itemnumber, $ordernumber); } } - + + $order->{rrp} = $rrp; + $order->{ecost} = $ecost; + $order->{unitprice} = $unitprice; + my $bookseller = C4::Bookseller::GetBookSellerFromId($booksellerid); + if ( $bookseller->{listincgst} ) { + if ( not $bookseller->{invoiceincgst} ) { + $order->{rrp} = $order->{rrp} * ( 1 + $order->{gstrate} ); + $order->{ecost} = $order->{ecost} * ( 1 + $order->{gstrate} ); + $order->{unitprice} = $order->{unitprice} * ( 1 + $order->{gstrate} ); + } + } else { + if ( $bookseller->{invoiceincgst} ) { + $order->{rrp} = $order->{rrp} / ( 1 + $order->{gstrate} ); + $order->{ecost} = $order->{ecost} / ( 1 + $order->{gstrate} ); + $order->{unitprice} = $order->{unitprice} / ( 1 + $order->{gstrate} ); + } + } + # save the quantity received. - $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived); + $datereceived = ModReceiveOrder( + $biblionumber, + $ordernumber, + $quantityrec, + $user, + $order->{unitprice}, + $order->{ecost}, + $invoiceno, + $freight, + $order->{rrp}, + undef, + $datereceived + ); } update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber ); -print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&booksellerid=$booksellerid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str"); +print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&booksellerid=$booksellerid&freight=$freight&datereceived=$datereceived$error_url_str"); ################################ End of script ################################ @@ -112,7 +144,7 @@ sub update_item { booksellerid => $booksellerid, dateaccessioned => $datereceived, price => $unitprice, - replacementprice => $replacement, + replacementprice => $rrp, replacementpricedate => $datereceived, }, $biblionumber, $itemnumber ); } diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index d482554..804b045 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -332,6 +332,13 @@ $template->param( budget_name => $budget_name ) if ($close); +# get option values for gist syspref +my @gst_values = map { + option => $_ +}, split( '\|', C4::Context->preference("gist") ); + +my $cur = GetCurrency(); + $template->param( existing => $biblionumber, ordernumber => $ordernumber, @@ -351,18 +358,21 @@ $template->param( suggestionid => $suggestion->{suggestionid}, surnamesuggestedby => $suggestion->{surnamesuggestedby}, firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, - biblionumber => $biblionumber, - uncertainprice => $data->{'uncertainprice'}, - authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'}, - biblioitemnumber => $data->{'biblioitemnumber'}, - discount_2dp => sprintf( "%.2f", $bookseller->{'discount'}) , # for display - discount => $bookseller->{'discount'}, + biblionumber => $biblionumber, + uncertainprice => $data->{'uncertainprice'}, + authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'}, + biblioitemnumber => $data->{'biblioitemnumber'}, + discount_2dp => sprintf( "%.2f", $bookseller->{'discount'} ) , # for display + discount => $bookseller->{'discount'}, + orderdiscount_2dp => sprintf( "%.2f", $data->{'discount'} || 0 ), + orderdiscount => $data->{'discount'}, listincgst => $bookseller->{'listincgst'}, invoiceincgst => $bookseller->{'invoiceincgst'}, name => $bookseller->{'name'}, cur_active_sym => $active_currency->{'symbol'}, cur_active => $active_currency->{'currency'}, loop_currencies => \@loop_currency, + currency_rate => $cur->{rate}, orderexists => ( $new eq 'yes' ) ? 0 : 1, title => $data->{'title'}, author => $data->{'author'}, @@ -375,19 +385,17 @@ $template->param( quantity => $data->{'quantity'}, quantityrec => $data->{'quantity'}, rrp => $data->{'rrp'}, - listprice => sprintf("%.2f", $data->{'listprice'}||$data->{'price'}||$listprice), - total => sprintf("%.2f", ($data->{'ecost'}||0)*($data->{'quantity'}||0) ), - ecost => $data->{'ecost'}, - unitprice => sprintf("%.2f", $data->{'unitprice'}), + gst_values => \@gst_values, + gstrate => $data->{gstrate} ? $data->{gstrate}+0.0 : $bookseller->{gstrate} ? $bookseller->{gstrate}+0.0 : 0, + gstreg => $bookseller->{'gstreg'}, + listprice => sprintf( "%.2f", $data->{listprice} || $data->{price} || $listprice), + total => sprintf( "%.2f", ($data->{ecost} || 0) * ($data->{'quantity'} || 0) ), + ecost => sprintf( "%.2f", $data->{ecost} || 0), + unitprice => sprintf( "%.2f", $data->{unitprice} || 0), notes => $data->{'notes'}, publishercode => $data->{'publishercode'}, barcode_subfield => $barcode_subfield, - import_batch_id => $import_batch_id, - -# CHECKME: gst-stuff needs verifing, mason. - gstrate => $bookseller->{'gstrate'} // C4::Context->preference("gist") // 0, - gstreg => $bookseller->{'gstreg'}, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 2b59698..2347689 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -81,8 +81,8 @@ use C4::Suggestions; my $input = new CGI; my $dbh = C4::Context->dbh; -my $booksellerid = $input->param('booksellerid'); -my $ordernumber = $input->param('ordernumber'); +my $booksellerid = $input->param('booksellerid'); +my $ordernumber = $input->param('ordernumber'); my $search = $input->param('receive'); my $invoice = $input->param('invoice'); my $freight = $input->param('freight'); @@ -92,16 +92,14 @@ my $datereceived = $input->param('datereceived'); $datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new(); my $bookseller = GetBookSellerFromId($booksellerid); -my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst')); -my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0; my $results = SearchOrder($ordernumber,$search); - my $count = scalar @$results; -my $order = GetOrder($ordernumber); +my $order = GetOrder($ordernumber); +my $gstrate = $order->{gstrate} || $bookseller->{gstrate} || C4::Context->preference("gist") || 0; -my $date = @$results[0]->{'entrydate'}; +my $date = $order->{entrydate}; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -128,42 +126,63 @@ if ( $count == 1 ) { ); } - if ( @$results[0]->{'quantityreceived'} == 0 ) { - @$results[0]->{'quantityreceived'} = ''; - } - if ( @$results[0]->{'unitprice'} == 0 ) { - @$results[0]->{'unitprice'} = ''; - } + $order->{quantityreceived} = '' if $order->{quantityreceived} == 0; + $order->{unitprice} = '' if $order->{unitprice} == 0; + + my $rrp; + my $ecost; + my $unitprice; + if ( $bookseller->{listincgst} ) { + if ( $bookseller->{invoiceincgst} ) { + $rrp = $order->{rrp}; + $ecost = $order->{ecost}; + $unitprice = $order->{unitprice}; + } else { + $rrp = $order->{rrp} / ( 1 + $order->{gstrate} ); + $ecost = $order->{ecost} / ( 1 + $order->{gstrate} ); + $unitprice = $order->{unitprice} / ( 1 + $order->{gstrate} ); + } + } else { + if ( $bookseller->{invoiceincgst} ) { + $rrp = $order->{rrp} * ( 1 + $order->{gstrate} ); + $ecost = $order->{ecost} * ( 1 + $order->{gstrate} ); + $unitprice = $order->{unitprice} * ( 1 + $order->{gstrate} ); + } else { + $rrp = $order->{rrp}; + $ecost = $order->{ecost}; + $unitprice = $order->{unitprice}; + } + } - my $suggestion = GetSuggestionInfoFromBiblionumber(@$results[0]->{'biblionumber'}); + my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); - my $authorisedby = @$results[0]->{'authorisedby'}; + my $authorisedby = $order->{authorisedby}; my $member = GetMember( borrowernumber => $authorisedby ); - my $budget = GetBudget( @$results[0]->{'budget_id'} ); + my $budget = GetBudget( $order->{budget_id} ); $template->param( count => 1, - biblionumber => @$results[0]->{'biblionumber'}, - ordernumber => @$results[0]->{'ordernumber'}, - biblioitemnumber => @$results[0]->{'biblioitemnumber'}, - booksellerid => @$results[0]->{'booksellerid'}, + biblionumber => $order->{biblionumber}, + ordernumber => $order->{ordernumber}, + biblioitemnumber => $order->{biblioitemnumber}, + booksellerid => $booksellerid, freight => $freight, - gst => $gst, - name => $bookseller->{'name'}, + gstrate => $gstrate, + name => $bookseller->{name}, date => format_date($date), - title => @$results[0]->{'title'}, - author => @$results[0]->{'author'}, - copyrightdate => @$results[0]->{'copyrightdate'}, - isbn => @$results[0]->{'isbn'}, - seriestitle => @$results[0]->{'seriestitle'}, - bookfund => $budget->{budget_name}, - quantity => @$results[0]->{'quantity'}, - quantityreceivedplus1 => @$results[0]->{'quantityreceived'} + 1, - quantityreceived => @$results[0]->{'quantityreceived'}, - rrp => @$results[0]->{'rrp'}, - ecost => @$results[0]->{'ecost'}, - unitprice => @$results[0]->{'unitprice'}, + title => $order->{title}, + author => $order->{author}, + copyrightdate => $order->{copyrightdate}, + isbn => $order->{isbn}, + seriestitle => $order->{seriestitle}, + bookfund => $budget->{budget_name}, # FIXME OR $order->{'bookfundid'}, ? + quantity => $order->{quantity}, + quantityreceivedplus1 => $order->{quantityreceived} + 1, + quantityreceived => $order->{quantityreceived}, + rrp => sprintf( "%.2f", $rrp ), + ecost => sprintf( "%.2f", $ecost ), + unitprice => $unitprice, memberfirstname => $member->{firstname} || "", membersurname => $member->{surname} || "", invoice => $invoice, @@ -183,10 +202,10 @@ else { $line{invoice} = $invoice; $line{datereceived} = $datereceived->output(); $line{freight} = $freight; - $line{gst} = $gst; + $line{gstrate} = $gstrate; $line{title} = @$results[$i]->{'title'}; $line{author} = @$results[$i]->{'author'}; - $line{booksellerid} = $booksellerid; + $line{booksellerid} = $booksellerid; push @loop, \%line; } diff --git a/acqui/parcel.pl b/acqui/parcel.pl index 5d0d164..a6e578b 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -76,8 +76,10 @@ my $bookseller=GetBookSellerFromId($booksellerid); my $invoice=$input->param('invoice') || ''; my $freight=$input->param('freight'); -my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst')); -my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0; + +#my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst')); # FIXME from comm +#my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0; + my $datereceived = ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) : C4::Dates->new($input->param('datereceived'), 'iso') ; $datereceived = C4::Dates->new() unless $datereceived; @@ -90,16 +92,53 @@ my $resultsperpage = $input->param('resultsperpage'); $resultsperpage = 20 unless ($resultsperpage); $startfrom=0 unless ($startfrom); +sub get_value_with_gst_params { + my $value = shift; + my $gstrate = shift; + my $bookseller = shift; + if ( $bookseller->{listincgst} ) { + if ( $bookseller->{invoiceincgst} ) { + return $value; + } else { + return $value / ( 1 + $gstrate ); + } + } else { + if ( $bookseller->{invoiceincgst} ) { + return $value * ( 1 + $gstrate ); + } else { + return $value; + } + } +} + +sub get_gste { + my $value = shift; + my $gstrate = shift; + my $bookseller = shift; + return $bookseller->{invoiceincgst} + ? $value / ( 1 + $gstrate ) + : $value; +} + +sub get_gst { + my $value = shift; + my $gstrate = shift; + my $bookseller = shift; + return $bookseller->{invoiceincgst} + ? $value / ( 1 + $gstrate ) * $gstrate + : $value * ( 1 + $gstrate ) - $value; +} + if($input->param('format') eq "json"){ my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "acqui/ajax.tmpl", query => $input, - type => "intranet", + type => "intranet", authnotrequired => 0, flagsrequired => {acquisition => 'order_receive'}, debug => 1, }); - + my @datas; my $search = $input->param('search') || ''; my $supplier = $input->param('booksellerid') || ''; @@ -110,7 +149,8 @@ if($input->param('format') eq "json"){ foreach my $order (@$orders){ if($order->{quantityreceived} < $order->{quantity}){ my $data = {}; - + my $ecost = get_value_with_gst_params( $order->{ecost}, $order->{gstrate}, $bookseller ); + $data->{basketno} = $order->{basketno}; $data->{ordernumber} = $order->{ordernumber}; $data->{title} = $order->{title}; @@ -120,12 +160,12 @@ if($input->param('format') eq "json"){ $data->{biblionumber} = $order->{biblionumber}; $data->{freight} = $order->{freight}; $data->{quantity} = $order->{quantity}; - $data->{ecost} = $order->{ecost}; - $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity}); + $data->{ecost} = sprintf( "%.2f", $ecost ); + $data->{ordertotal} = sprintf( "%.2f", $ecost * $order->{quantity} ); push @datas, $data; } } - + my $json_text = to_json(\@datas); $template->param(return => $json_text); output_html_with_http_headers $input, $cookie, $template->output; @@ -135,7 +175,7 @@ if($input->param('format') eq "json"){ my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "acqui/parcel.tmpl", query => $input, - type => "intranet", + type => "intranet", authnotrequired => 0, flagsrequired => {acquisition => 'order_receive'}, debug => 1, @@ -156,44 +196,57 @@ if( scalar(@rcv_err) ) { my $cfstr = "%.2f"; # currency format string -- could get this from currency table. my @parcelitems = GetParcel($booksellerid, $invoice, $datereceived->output('iso')); -my $countlines = scalar @parcelitems; +#my $countlines = scalar @parcelitems; FIXME from comm, it's used ? my $totalprice = 0; my $totalfreight = 0; my $totalquantity = 0; my $total; my $tototal; my @loop_received = (); - -for (my $i = 0 ; $i < $countlines ; $i++) { - - #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) - $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) - $parcelitems[$i]->{'unitprice'} += 0; +my @book_foot_loop; +my %foot; +my $total_quantity = 0; +my $total_gste = 0; +my $total_gsti = 0; + +for my $item ( @parcelitems ) { + $item->{unitprice} = get_value_with_gst_params( $item->{unitprice}, $item->{gstrate}, $bookseller ); + $total = ( $item->{'unitprice'} ) * $item->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) + $item->{'unitprice'} += 0; my %line; - %line = %{ $parcelitems[$i] }; + %line = %{ $item }; + my $ecost = get_value_with_gst_params( $line{ecost}, $line{gstrate}, $bookseller ); + $line{ecost} = sprintf( "%.2f", $ecost ); $line{invoice} = $invoice; - $line{gst} = $gst; $line{total} = sprintf($cfstr, $total); $line{booksellerid} = $booksellerid; - push @loop_received, \%line; - $totalprice += $parcelitems[$i]->{'unitprice'}; - $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); + $totalprice += $item->{'unitprice'}; + $line{unitprice} = sprintf( $cfstr, $item->{'unitprice'} ); + my $gste = get_gste( $line{total}, $line{gstrate}, $bookseller ); + my $gst = get_gst( $line{total}, $line{gstrate}, $bookseller ); + $foot{$line{gstrate}}{gstrate} = $line{gstrate}; + $foot{$line{gstrate}}{value} += sprintf( "%.2f", $gst ); + $total_quantity += $line{quantity}; + $total_gste += $gste; + $total_gsti += $gste + $gst; my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); $line{suggestionid} = $suggestion->{suggestionid}; $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; - #double FIXME - totalfreight is redefined later. + $totalfreight = $item->{'freight'}; + $totalquantity += $item->{'quantityreceived'}; -# FIXME - each order in a parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget.. - if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) { - warn "FREIGHT CHARGE MISMATCH!!"; - } - $totalfreight = $parcelitems[$i]->{'freight'}; - $totalquantity += $parcelitems[$i]->{'quantityreceived'}; $tototal += $total; -} + + my $budget = GetBudget( $line{budget_id} ); + $line{budget_name} = $budget->{'budget_name'}; + + push @loop_received, \%line; + } + +push @book_foot_loop, map { $_ } values %foot; my $pendingorders = GetPendingOrders($booksellerid); my $countpendings = scalar @$pendingorders; @@ -205,23 +258,23 @@ my @loop_orders = (); for (my $i = 0 ; $i < $countpendings ; $i++) { my %line; %line = %{$pendingorders->[$i]}; - + + my $ecost = get_value_with_gst_params( $line{ecost}, $line{gstrate}, $bookseller ); + $line{unitprice} = get_value_with_gst_params( $line{unitprice}, $line{gstrate}, $bookseller ); $line{quantity}+=0; $line{quantityreceived}+=0; $line{unitprice}+=0; $totalPunitprice += $line{unitprice}; $totalPquantity +=$line{quantity}; $totalPqtyrcvd +=$line{quantityreceived}; - $totalPecost += $line{ecost}; - $line{ecost} = sprintf("%.2f",$line{ecost}); - $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); + $totalPecost += $ecost; + $line{ecost} = sprintf( "%.2f", $ecost ); + $line{ordertotal} = sprintf( "%.2f", $ecost * $line{quantity} ); $line{unitprice} = sprintf("%.2f",$line{unitprice}); $line{invoice} = $invoice; - $line{gst} = $gst; - $line{total} = $total; $line{booksellerid} = $booksellerid; - $ordergrandtotal += $line{ecost} * $line{quantity}; - + $ordergrandtotal += $ecost * $line{quantity}; + my $biblionumber = $line{'biblionumber'}; my $countbiblio = CountBiblioInOrders($biblionumber); my $ordernumber = $line{'ordernumber'}; @@ -242,6 +295,9 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; + my $budget = GetBudget( $line{budget_id} ); + $line{budget_name} = $budget->{'budget_name'}; + # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680 $line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); $line{items} = ($itemcount) - (scalar @items); @@ -254,8 +310,7 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); $line{holds} = $holds; $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; - - + push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); } $freight = $totalfreight unless $freight; @@ -293,7 +348,6 @@ if ($count>$resultsperpage){ ); } -#$totalfreight=$freight; $tototal = $tototal + $freight; $template->param( @@ -303,25 +357,25 @@ $template->param( formatteddatereceived => $datereceived->output(), name => $bookseller->{'name'}, booksellerid => $booksellerid, - gst => $gst, freight => $freight, invoice => $invoice, - countreceived => $countlines, loop_received => \@loop_received, - countpending => $countpendings, loop_orders => \@loop_orders, + book_foot_loop => \@book_foot_loop, totalprice => sprintf($cfstr, $totalprice), totalfreight => $totalfreight, totalquantity => $totalquantity, tototal => sprintf($cfstr, $tototal), ordergrandtotal => sprintf($cfstr, $ordergrandtotal), - gst => $gst, - grandtot => sprintf($cfstr, $tototal + $gst), + grandtot => sprintf($cfstr, $tototal ), totalPunitprice => sprintf("%.2f", $totalPunitprice), totalPquantity => $totalPquantity, totalPqtyrcvd => $totalPqtyrcvd, totalPecost => sprintf("%.2f", $totalPecost), resultsperpage => $resultsperpage, + total_quantity => $total_quantity, + total_gste => sprintf( "%.2f", $total_gste ), + total_gsti => sprintf( "%.2f", $total_gsti ), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/supplier.pl b/acqui/supplier.pl index 0e2ab40..df417c0 100755 --- a/acqui/supplier.pl +++ b/acqui/supplier.pl @@ -67,12 +67,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( debug => 1, } ); -my $seller_gstrate = $supplier->{'gstrate'}; -# ensure the scalar isn't flagged as a string -$seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : undef; -my $tax_rate = $seller_gstrate // C4::Context->preference('gist') // 0; -$tax_rate *= 100; #build array for currencies if ( $op eq 'display' ) { @@ -102,12 +97,11 @@ if ( $op eq 'display' ) { gstreg => $supplier->{'gstreg'}, listincgst => $supplier->{'listincgst'}, invoiceincgst => $supplier->{'invoiceincgst'}, + gstrate => $supplier->{'gstrate'} + 0.0, discount => $supplier->{'discount'}, deliverytime => $supplier->{deliverytime}, invoiceprice => $supplier->{'invoiceprice'}, listprice => $supplier->{'listprice'}, - GST => $tax_rate, - default_tax => defined($seller_gstrate), basketcount => $supplier->{'basketcount'}, subscriptioncount => $supplier->{'subscriptioncount'}, contracts => $contracts, @@ -141,9 +135,11 @@ if ( $op eq 'display' ) { }; } - my $default_gst_rate = (C4::Context->preference('gist') * 100) || '0.0'; + # get option values from gist syspref + my @gst_values = map { + option => $_ + }, split( '\|', C4::Context->preference("gist") ); - my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : ''; $template->param( booksellerid => $booksellerid, name => $supplier->{'name'}, @@ -169,13 +165,12 @@ if ( $op eq 'display' ) { gstreg => $supplier->{'gstreg'}, listincgst => $supplier->{'listincgst'}, invoiceincgst => $supplier->{'invoiceincgst'}, - gstrate => $gstrate, + gstrate => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0, + gst_values => \@gst_values, discount => $supplier->{'discount'}, deliverytime => $supplier->{deliverytime}, loop_currency => $loop_currency, - GST => $tax_rate, enter => 1, - default_gst_rate => $default_gst_rate, ); } diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl index 3dc6964..7b3bf9d 100755 --- a/acqui/updatesupplier.pl +++ b/acqui/updatesupplier.pl @@ -100,13 +100,8 @@ $data{'gstreg'}=$input->param('gst'); $data{'listincgst'}=$input->param('list_gst'); $data{'invoiceincgst'}=$input->param('invoice_gst'); #have to transform this into fraction so it's easier to use -my $gstrate = $input->param('gstrate'); -if ($gstrate eq '') { - $data{'gstrate'} = undef; -} else { - $data{'gstrate'} = $input->param('gstrate')/100; -} -$data{'discount'}=$input->param('discount'); +$data{'gstrate'} = $input->param('gstrate'); +$data{'discount'} = $input->param('discount'); $data{deliverytime} = $input->param('deliverytime'); $data{'active'}=$input->param('status'); if($data{'name'}) { diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 4912e19..60fe317 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2731,7 +2731,8 @@ CREATE TABLE `aqorders` ( `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `rrp` decimal(13,2) default NULL, `ecost` decimal(13,2) default NULL, - `gst` decimal(13,2) default NULL, + gstrate decimal(6,4) default NULL, + discount float(6,4) default NULL, `budget_id` int(11) NOT NULL, `budgetgroup_id` int(11) NOT NULL, `budgetdate` date default NULL, diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 503c8ee..a75acd2 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5146,6 +5146,21 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } + +$DBversion = "3.07.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE aqorders CHANGE COLUMN gst gstrate DECIMAL(6,4) DEFAULT NULL"); + print "Upgrade to $DBversion done (Change column name in aqorders gst --> gstrate)\n"; + SetVersion($DBversion); +} + +$DBversion = "3.07.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE aqorders ADD discount float(6,4) DEFAULT NULL AFTER gstrate"); + print "Upgrade to $DBversion done (Add discount field in aqorders table)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index b137f59..34a4a2d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -646,46 +646,22 @@ function messenger(X,Y,etc){ // FIXME: unused? // NEXT BLOCK IS USED BY NEWORDERBEMPTY -function calcNeworderTotal(){ - //collect values - var f = document.getElementById('Aform'); - var quantity = new Number(f.quantity.value); - var discount = new Number(f.discount.value); - var listinc = new Number (f.listinc.value); - //var currency = f.currency.value; - var applygst = new Number (f.applygst.value); - var listprice = new Number(f.listprice.value); - var invoiceingst = new Number (f.invoiceincgst.value); -// var exchangerate = new Number(f.elements[currency].value); //get exchange rate - var currcode = new String(document.getElementById('currency').value); - var exchangerate = new Number(document.getElementById(currcode).value); - - var gst_on=(!listinc && invoiceingst); - - //do real stuff - var rrp = new Number(listprice*exchangerate); - var ecost = new Number(Math.floor(rrp * (100 - discount ))/100); - var GST = new Number(0); - if (gst_on) { - rrp=rrp * (1+f.gstrate.value / 100); - GST=ecost * f.gstrate.value / 100; - } - - var total = new Number( (ecost + GST) * quantity); +function updateCosts(){ + var quantity = new Number($("#quantity").val()); + var discount = new Number($("#discount").val()); + var applygst = new Number ($("#applygst").val()); + var listprice = new Number($("#listprice").val()); + var exchangerate = new Number($("#currency_rate").val()); + var gst_on=false; - f.rrp.value = rrp.toFixed(2); - -// f.rrp.value = rrp -// f.rrp.value = 'moo' - - f.ecost.value = ecost.toFixed(2); - f.total.value = total.toFixed(2); - f.listprice.value = listprice.toFixed(2); + var rrp = new Number(listprice*exchangerate); + var ecost = new Number(Math.floor(rrp * (100 - discount )) / 100); + var total = new Number( ecost * quantity); + $("#rrp").val(rrp.toFixed(2)); + $("#ecost").val(ecost.toFixed(2)); + $("#total").val(total.toFixed(2)); + $("listprice").val(listprice.toFixed(2)); -// gst-stuff needs verifing, mason. - if (f.GST) { - f.GST.value=GST; - } return true; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt index 3fdd631..a8dc7ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt @@ -159,7 +159,7 @@ [% ELSE %] <li> <label for="currency">Currency:</label> - <select name="currency" id="currency" onchange="calcNeworderTotal();"> + <select name="currency" id="currency"> [% FOREACH loop_currencie IN loop_currencies %] [% IF ( loop_currencie.selected ) %]<option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>[% ELSE %]<option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>[% END %][% END %] </select> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 0cf7ff6..0f959a6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -2,19 +2,41 @@ [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Acquisitions › [% UNLESS ( basketno ) %]New [% END %][% IF ( delete_confirm ) %]Delete [% END %]Basket [% basketname|html %] ([% basketno %]) for [% name|html %]</title> [% INCLUDE 'doc-head-close.inc' %] + +<script type="text/javascript"> +//<![CDATA[ + function updateColumnsVisibility(visible) { + if ( visible ) { + $("table .gste, .gsti").show(); + } else { + [% IF ( listincgst ) %] + $("table .gste").hide(); + [% ELSE %] + $("table .gsti").hide(); + [% END %] + } + } + + $(document).ready(function() { + $("#show_all_details").click(function(){ + updateColumnsVisibility($(this+":checked").val()); + }); + + $("#show_all_details").attr('checked', false); + updateColumnsVisibility(false); + }); +//]]> +</script> + [% UNLESS ( closedate ) %] <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function() { - $("#orders").tablesorter({ - headers: { - 9: { sorter: false }, - 10: { sorter: false } - } - }); + $("#orders").tablesorter({}); $("#cancelledorderst").tablesorter(); }); + function confirm_close() { var is_confirmed = confirm(_('Are you sure you want to close this basket?')); if (is_confirmed) { @@ -215,16 +237,25 @@ [% UNLESS ( delete_confirm ) %] <div id="acqui_basket_content" class="yui-g"> + <label for="show_all_details"> + <input type="checkbox" style="vertical-align: middle;" id="show_all_details" /> + Show all details + </label> <h2>Order Details</h2> [% IF ( books_loop ) %] <table id="orders"> <thead> <tr> <th>Order</th> - <th>RRP</th> - <th>Est.</th> + <th class="gste">RRP tax exc.</th> + <th class="gste">ecost tax exc.</th> + <th class="gsti">RRP tax inc.</th> + <th class="gsti">ecost tax inc.</th> <th>Qty.</th> - <th>Total</th> + <th class="gste">Total tax exc. ([% currency %])</th> + <th class="gsti">Total tax inc. ([% currency %])</th> + <th>GST %</th> + <th>GST</th> <th>Fund</th> [% IF ( active ) %] [% UNLESS ( closedate ) %] @@ -235,44 +266,38 @@ </tr> </thead> <tfoot> - [% IF ( GST ) %] - <tr> - <th scope="row">Total tax exc.</th> - <td>[% total_rrp_gste %]</td> - <td> </td> - <td>[% qty_total %]</td> - <td>[% total_est_gste %]</td> - [% IF ( active ) %] - [% IF ( closedate ) %] - <td colspan="1" rowspan="3"> </td> - [% ELSE %] - <td colspan="3" rowspan="3"> </td> + [% FOREACH foot_loo IN book_foot_loop %] + <tr> + <th>Total (GST [% foot_loo.gstgsti %])</th> + <th class="gste"/><th class="gste"/><th class="gsti"/><th class="gsti"/> + <th>[% foot_loo.quantity %]</th> + <th class="gste">[% foot_loo.totalgste %]</th> + <th class="gsti">[% foot_loo.totalgsti %]</th> + <th/> + <th>[% foot_loo.gstvalue %]</th> + <th/> + [% IF ( foot_loo.active ) %] + [% UNLESS ( foot_loo.closedate ) %] + <th/> <th/> [% END %] [% END %] - </tr> - <tr> - <th scope="row">Tax ([% gist_rate %])</th> - <td>[% gist_rrp %]</td> - <td> </td> - <td> </td> - <td>[% gist_est %]</td> - </tr> - <tr> - <th scope="row">Total tax inc. ([% currency %])</th> - <td>[% total_rrp_gsti %]</td> - <td> </td> - <td>[% qty_total %]</td> - <td>[% total_est_gsti %]</td> - </tr> - [% ELSE %] + </tr> + [% END %] <tr> - <th scope="row">Total ([% currency %])</th> - <td>[% total_rrp_gsti %]</td> - <td> </td> - <td>[% qty_total %]</td> - <td>[% total_est_gsti %]</td> + <th>Total ([% currency %])</th> + <th class="gste"/><th class="gste"/><th class="gsti"/><th class="gsti"/> + <th>[% total_quantity %]</th> + <th class="gste">[% total_gste %]</th> + <th class="gsti">[% total_gsti %]</th> + <th/> + <th>[% total_gstvalue %]</th> + <th/> + [% IF ( books_loo.active ) %] + [% UNLESS ( books_loo.closedate ) %] + <th/> <th/> + [% END %] + [% END %] </tr> - [% END %] </tfoot> <tbody> [% FOREACH books_loo IN books_loop %] @@ -298,10 +323,15 @@ [% END %] </p> </td> - <td class="number">[% books_loo.rrp %]</td> - <td class="number">[% books_loo.ecost %]</td> + <td class="number gste">[% books_loo.rrpgste %]</td> + <td class="number gste">[% books_loo.ecostgste %]</td> + <td class="number gsti">[% books_loo.rrpgsti %]</td> + <td class="number gsti">[% books_loo.ecostgsti %]</td> <td class="number">[% books_loo.quantity %]</td> - <td class="number">[% books_loo.line_total %]</td> + <td class="number gste">[% books_loo.totalgste %]</td> + <td class="number gsti">[% books_loo.totalgsti %]</td> + <td class="number">[% books_loo.gstgsti %]</td> + <td class="number">[% books_loo.gstvalue %]</td> <td>[% books_loo.budget_name %]</td> [% IF ( active ) %] [% UNLESS ( closedate ) %] @@ -353,10 +383,15 @@ <thead> <tr> <th>Order</th> - <th>RRP</th> - <th>Est.</th> + <th class="gste">RRP tax exc.</th> + <th class="gste">ecost tax exc.</th> + <th class="gsti">RRP tax inc.</th> + <th class="gsti">ecost tax inc.</th> <th>Qty.</th> - <th>Total</th> + <th class="gste">Total tax exc. ([% currency %])</th> + <th class="gsti">Total tax inc. ([% currency %])</th> + <th>GST %</th> + <th>GST</th> <th>Fund</th> </tr> </thead> @@ -379,11 +414,16 @@ [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %] </p> </td> - <td><p>[% order.rrp %]</p></td> - <td><p>[% order.ecost %]</p></td> - <td><p>[% order.quantity %]</p></td> - <td><p>[% order.line_total %]</p></td> - <td><p>[% order.budget_name %]</p></td> + <td class="number gste">[% order.rrpgste %]</td> + <td class="number gste">[% order.ecostgste %]</td> + <td class="number gsti">[% order.rrpgsti %]</td> + <td class="number gsti">[% order.ecostgsti %]</td> + <td class="number">[% order.quantity %]</td> + <td class="number gste">[% order.totalgste %]</td> + <td class="number gsti">[% order.totalgsti %]</td> + <td class="number">[% order.gstgsti %]</td> + <td class="number">[% order.gstvalue %]</td> + <td>[% order.budget_name %] </tr> [% END %] </tbody> 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 8aec465..28f5db7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -138,7 +138,7 @@ $(document).ready(function() //]]> </script> </head> -<body id="acq_neworderempty" class="acq"> +<body id="acq_neworderempty" class="acq" onload="updateCosts()"> [% INCLUDE 'header.inc' %] [% INCLUDE 'acquisitions-search.inc' %] @@ -217,18 +217,13 @@ $(document).ready(function() <input type="hidden" name="booksellerid" value="[% booksellerid %]" /> <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" /> - <input type="hidden" name="discount" value="[% discount %]" /> - <input type="hidden" name="listinc" value="[% listincgst %]" /> -<!-- <input type="hidden" name="currency" value="[% currency %]" />--> - <input type="hidden" name="applygst" value="[% gstreg %]" /> - <input type="hidden" name="invoiceincgst" value="[% invoiceincgst %]" /> - <input type="hidden" name="gstrate" value="[% gstrate %]" /> + <input type="hidden" name="listinc" id="listinc" value="[% listincgst %]" /> + <input type="hidden" name="applygst" id="applygst" value="[% gstreg %]" /> + <input type="hidden" name="invoiceincgst" id="invoiceincgst" value="[% invoiceincgst %]" /> <input type="hidden" name="suggestionid" value="[% suggestionid %]" /> <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" /> + <input type="hidden" name="currency_rate" id="currency_rate" value="[% currency_rate %]" /> - [% FOREACH loop_currencie IN loop_currencies %] - <input type="hidden" id="[% loop_currencie.currcode %]" name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" /> - [% END %] <ol><li> [% IF ( biblionumber ) %] <span class="label">Title</span> @@ -378,7 +373,7 @@ $(document).ready(function() [% IF (AcqCreateItemOrdering) %] <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" onchange="updateCosts();" /> [% ELSE %] - <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" /> + <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" /> [% END %] [% END %] <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order --> @@ -412,7 +407,7 @@ $(document).ready(function() <input type="hidden" size="10" name="currency" id="currency" value="[% currency %]" />[% currency %] [% ELSE %] <label for="currency">Currency:</label> - <select name="currency" id="currency" onchange="calcNeworderTotal();"> + <select name="currency" id="currency" onchange="updateCosts();"> [% FOREACH loop_currencie IN loop_currencies %] [% IF ( loop_currencie.selected ) %]<option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>[% ELSE %]<option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>[% END %][% END %] </select> @@ -420,11 +415,11 @@ $(document).ready(function() </li> <li> [% IF ( close ) %] - <span class="label">Vendor price: </span> + <span class="label">Vendor price: </span> <input type="hidden" size="20" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %] [% ELSE %] <label for="listprice">Vendor price: </label> - <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="calcNeworderTotal()" /> + <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="updateCosts()" /> [% END %] </li> [% UNLESS ( close ) %] @@ -437,53 +432,69 @@ $(document).ready(function() [% END %] </li> [% END %] - <li> + <li> [% IF ( close ) %] - <span class="label">Replacement cost: </span> - <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %] + <span class="label">gstrate: </span> + <input type="hidden" size="20" name="gstrate" id="gstrate" value="[% gstrate %]" />[% gstrate %]% [% ELSE %] - <label for="rrp">Replacement cost: </label> - <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %]) + <label for="gst">gstrate: </label> + <select name="gstrate" id="gstrate" onchange="updateCosts();"> + [% FOREACH gst IN gst_values %] + <option value="[% gst.option %]"[% IF ( gst.option == gstrate ) %] selected="selected"[% END %]>[% gst.option * 100 | format("%.1f") %]%</option> + [% END %] + </select> [% END %] </li> <li> + <label for="discount">Discount: </label> [% IF ( close ) %] - <label for="ecost">Budgeted cost: </label> - <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly" /> + [% IF ( orderdiscount ) %] + <input type="hidden" name="discount" id="discount" value="[% orderdiscount %]" />[% orderdiscount_2dp %]% + [% ELSE %] + <input type="hidden" name="discount" id="discount" value="[% discount %]" />[% discount_2dp %]% + [% END %] [% ELSE %] - <label for="ecost">Budgeted cost: </label> - <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /> + [% IF ( orderdiscount ) %] + <input type="text" size="6" name="discount" id="discount" value="[% orderdiscount %]" onchange="updateCosts();" />% + [% ELSE %] + <input type="text" size="6" name="discount" id="discount" value="[% discount %]" onchange="updateCosts();" />% + [% END %] [% END %] - [% IF ( discount_2dp ) %] (adjusted for [% discount_2dp %]% discount) [% END %] - </li> - [% IF ( GST ) %] <li> [% IF ( close ) %] - <label for="GST">Budgeted GST: </label> - <input type="text" id="" size="20" name="gst" value="" id="GST" readonly="readonly" /> + <span class="label">Replacement cost: </span> + <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %] [% ELSE %] - <label for="GST">Budgeted GST: </label> - <input type="text" size="20" name="gst" id="GST" value="" /> + <label for="rrp">Replacement cost: </label> + <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %]) + [% END %] + </li> + <li> + [% IF ( close ) %] + <label for="ecost">Budgeted cost: </label> + <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly" /> + [% ELSE %] + <label for="ecost">Budgeted cost: </label> + <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /> [% END %] </li> - [% END %] <li> [% IF ( close ) %] - <label for="total">Total: </label> - <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" /> + <label for="total">Total: </label> + <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" /> [% ELSE %] - <label for="total">Total: </label> - <input type="text" id="total" size="20" name="total" value="[% total %]" /> (budgeted cost * quantity) + <label for="total">Total: </label> + <input type="text" id="total" size="20" name="total" value="[% total %]" /> (budgeted cost * quantity) [% END %] </li> <li> [% IF ( close ) %] - <label for="cost">Actual cost: </label> - <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" /> + <label for="unitprice">Actual cost: </label> + <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" /> [% ELSE %] - <label for="cost">Actual cost: </label> - <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" /> + <label for="unitprice">Actual cost: </label> + <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" /> [% END %] </li> <li> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 97a7223..3a1d02b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -134,7 +134,7 @@ <input type="hidden" name="booksellerid" value="[% booksellerid %]" /> <input type="hidden" name="datereceived" value="[% datereceived_iso %]" /> <input type="hidden" name="freight" value="[% freight %]" /> - <input type="hidden" name="gst" value="[% gst %]" /> + <input type="hidden" name="gstrate" value="[% gstrate %]" /> </div> <div class="yui-u"> <fieldset class="rows"> @@ -191,7 +191,7 @@ </div> </div><div class="yui-g"><fieldset class="action"> <input type="submit" value="Save" /> - <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&invoice=[% invoice %]&gst=[% gst %]&freight=[% freight %]">Cancel</a> + <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&invoice=[% invoice %]&gst=rate[% gstrate %]&freight=[% freight %]">Cancel</a> </fieldset></div> </form> [% ELSE %] <div id="acqui_acquire_orderlist"> @@ -208,7 +208,7 @@ <tr> <td>[% loo.basketno %]</td> <td>[% loo.isbn %]</td> - <td><a href="orderreceive.pl?datereceived=[% loo.datereceived %]&receive=[% loo.ordernumber %]&biblio=[% loo.biblionumber %]&invoice=[% loo.invoice %]&freight=[% loo.freight %]&gst=[% loo.gst %]&id=[% loo.id %]">[% loo.title |html %]</a></td> + <td><a href="orderreceive.pl?datereceived=[% loo.datereceived %]&receive=[% loo.ordernumber %]&biblio=[% loo.biblionumber %]&invoice=[% loo.invoice %]&freight=[% loo.freight %]&gstrate=[% loo.gstrate %]&id=[% loo.id %]">[% loo.title |html %]</a></td> <td>[% loo.author %]</td> <td>[% loo.quantity %]</td> <td>[% loo.quantityreceived %]</td> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index a5d3e1a..aab6be2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -19,7 +19,7 @@ $(document).ready(function(){ $("#pendingt").tablesorter({ - headers: { 2: { sorter: 'articles' },3: { sorter: false },7:{sorter:false}} + headers: { 2: { sorter: 'articles' },3: { sorter: false },8:{sorter:false}} }); rowCountPending = $("#pendingt tbody.filterclass tr").length; @@ -44,7 +44,7 @@ $("#pendingcollapserow").remove(); $("#pendingt tr").show(); $("#pendingt tbody.filterclass tr:gt(" + (rowsToCollapse-1) + ")").hide(); - $("#pendingt").before("<p id=\"pendingcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + "<a href=\"javascript:pendingExpand();\">" + _("Click here to show all ") + rowCountPending + _(" items") + "<\/a>.<\/p>"); + $("#pendingt").before("<p id=\"pendingcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + " <a href=\"javascript:pendingExpand();\">" + _("Click here to show all ") + rowCountPending + _(" items") + "<\/a>.<\/p>"); } @@ -53,21 +53,21 @@ $("#pendingcollapserow").remove(); $("#pendingt tr").show(); $("#pendingt tbody.filterclass tr.orderfound").remove(); - $("#pendingt").before("<p id=\"pendingcollapserow\">" + rowCountPending + _(" items are displayed.") + "<a href=\"javascript:pendingCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>"); + $("#pendingt").before("<p id=\"pendingcollapserow\">" + rowCountPending + _(" items are displayed.") + " <a href=\"javascript:pendingCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>"); } // Collapse already received items table function receivedCollapse() { $("#receivedcollapserow").remove(); $("#receivedt tbody.filterclass tr:gt(" + (rowsToCollapse-1) + ")").hide(); - $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + "<a href=\"javascript:receivedExpand();\">" + _("Click here to show all ") + rowCountReceived + _(" items") + "<\/a>.<\/p>"); + $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + " <a href=\"javascript:receivedExpand();\">" + _("Click here to show all ") + rowCountReceived + _(" items") + "<\/a>.<\/p>"); } // Expand already received items table function receivedExpand() { $("#receivedcollapserow").remove(); $("#receivedt tr").show(); - $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("All ") + rowCountReceived + _(" items are displayed.") + "<a href=\"javascript:receivedCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>"); + $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("All ") + rowCountReceived + _(" items are displayed.") + " <a href=\"javascript:receivedCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>"); } // Launch filtering @@ -89,7 +89,6 @@ var callback = { success: function(o) { var jsonString = o.responseText; - var gst = "[% gst %]"; try { var orders = YAHOO.lang.JSON.parse(jsonString); var foundCount = orders.length; @@ -106,7 +105,7 @@ + '<td>' + order.ecost + '</td>' + '<td>' + order.ordertotal + '</td>' + '<td>' - + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&datereceived=[% invoicedatereceived %]&invoice=[% invoice %]&gst=' + gst + '&freight=' + order.freight + '&booksellerid=[% booksellerid %]">Receive</a> /' + + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&datereceived=[% invoicedatereceived %]&invoice=[% invoice %]&freight=' + order.freight + '&booksellerid=[% booksellerid %]">Receive</a> /' + '<a href="parcel.pl?type=intra&ordernumber=' + order.ordernumber + '&biblionumber=' + order.biblionumber + '&action=cancelorder&booksellerid=[% booksellerid %]&datereceived=[% invoicedatereceived %]&invoice=[% invoice %]" onclick="return confirm(\'' + _('Are you sure you want to cancel this order?') + '\');">Cancel</a>' + '</td></tr>').appendTo("table#pendingt"); } @@ -214,19 +213,11 @@ <th>Quantity</th> <th>Unit cost</th> <th>Order cost</th> + <th>Fund</th> <th> </th> <th> </th> </tr> </thead> - <tfoot> - <tr><td colspan="4" class="total">TOTAL</td> - <td> [% totalPquantity %] </td> - <td> </td> - <td>[% ordergrandtotal %]</td> - <td> </td> - <td> </td> - </tr> - </tfoot> <tbody class="filterclass"> [% FOREACH loop_order IN loop_orders %] [% UNLESS ( loop.odd ) %] @@ -257,8 +248,9 @@ <td>[% loop_order.quantity %]</td> <td>[% loop_order.ecost %]</td> <td>[% loop_order.ordertotal %]</td> + <td>[% loop_order.budget_name %]</td> <td> - <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&datereceived=[% loop_order.invoicedatereceived %]&invoice=[% loop_order.invoice %]&gst=[% loop_order.gst %]&freight=[% loop_order.freight %]&booksellerid=[% loop_order.booksellerid %]">Receive</a> + <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&datereceived=[% loop_order.invoicedatereceived %]&invoice=[% loop_order.invoice %]&freight=[% loop_order.freight %]&booksellerid=[% loop_order.booksellerid %]">Receive</a> </td> <td> @@ -324,40 +316,21 @@ <th>TOTAL</th> </tr> </thead> -<tfoot> - <tr> - <td colspan="4" class="total">SUBTOTAL</td> - <td colspan="2"> </td> - <td>[% totalprice %]</td> - <td>[% tototal %]</td> - </tr> - - [% IF ( totalfreight ) %] - <tr> - <td colspan="6"> - </td> - <td>Shipping</td> - <td>[% totalfreight %]</td> - </tr> - [% END %] - [% IF ( gst ) %] - <tr> - <td colspan="6"> - <p class="message"> - <b>HELP</b><br /> - The total at the bottom of the page should be within a few cents of the total for the invoice. - </p> - </td> - <td><b>Tax rate</b></td> - <td>[% gst %]</td> - </tr> - [% END %] - <tr> - <td colspan="4" class="total">TOTAL</td> - <td>[% totalquantity %]</td> - <td colspan="2"> </td> - <td>[% grandtot %]</td> - </tr> + <tfoot> + <tr> + <th colspan="7" class="total">Total tax exc.</th> + <th>[% total_gste %]</th> + </tr> + [% FOREACH book_foot IN book_foot_loop %] + <tr> + <th colspan="7">Total (GST [% book_foot.gstrate * 100 | format ("%.1f") %]%)</th> + <th>[% book_foot.value %]</th> + </tr> + [% END %] + <tr> + <th colspan="7" class="total">Total tax inc.</th> + <th>[% total_gsti %]</th> + </tr> </tfoot> <tbody class="filterclass"> [% FOREACH loop_receive IN loop_received %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt index 25b52ea..9cb8db0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt @@ -107,7 +107,7 @@ if (f.company.value == "") { </li> </ol> <ol class="radio"> - <li><label for="gstyes" class="radio">Tax Number Registered:</label> + <li><label for="gstyes" class="radio">Tax number registered:</label> [% IF ( gstreg ) %] <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" checked="checked" /> <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" /> @@ -134,10 +134,19 @@ if (f.company.value == "") { <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" checked="checked" /> [% END %]</li> </ol> + <ol> + <li> + <label for="gst">Tax rate</label> + <select name="gstrate" id="gstrate"> + [% FOREACH gst IN gst_values %] + <option value="[% gst.option %]"[% IF ( gstrate == gst.option ) %] selected="selected"[% END %]>[% gst.option * 100 | format ("%.1f") %] %</option> + [% END %] + </select> + </li> + </ol> <ol> <li><label for="discount">Discount</label> <input type="text" size="6" id="discount" name="discount" value="[% discount %]" />%</li> - <li><label for="gstrate">Tax rate</label><input type="text" name="gstrate" id="gstrate" size="6" value="[% gstrate %]"/>% (leave blank for default tax of [% default_gst_rate %]%)</li> <li> <label for="deliverytime">Delivery time</label> <input type="text" size="2" id="deliverytime" name="deliverytime" value="[% deliverytime %]" /> days @@ -192,7 +201,7 @@ if (f.company.value == "") { [% END %]</p> <p><strong>List prices are: </strong>[% listprice %]</p> <p><strong>Invoice prices are: </strong>[% invoiceprice %]</p> - [% IF ( GST ) %]<p><strong>Tax number registered: </strong> + [% IF ( gstrate ) %]<p><strong>Tax number registered: </strong> [% IF ( gstreg ) %]Yes[% ELSE %]No[% END %]</p> <p><strong>List item price includes tax: </strong> [% IF ( listincgst ) %]Yes[% ELSE %]No[% END %]</p> @@ -201,7 +210,7 @@ if (f.company.value == "") { <p><strong>Discount: </strong> [% discount %] %</p> <p><strong>Tax rate: </strong> - [% GST %]%[% UNLESS ( default_tax ) %] (default)[% END %]</p> + [% 0 + gstrate * 100 | format("%.1f") %]%</p> [% IF deliverytime.defined %] <p><strong>Delivery time: </strong> [% deliverytime %] days</p> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index cf8fcf0..02c4167 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -32,9 +32,9 @@ Acquisitions: US: 360,000.00 (US) FR: 360 000,00 (FR) - - - The default tax rate is + - Default tax rates are - pref: gist - - (enter in numeric form, 0.12 for 12%) + - (enter in numeric form, 0.12 for 12%. First is the default. If you want more than 1 value, please separe with |) Printing: - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index 1c34482..ac3a023 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -122,6 +122,40 @@ $(document).ready(function() { </div> </div> </div> + [% IF ( show_acquisition_details ) %] + <div id="acquisition_details"> + <h2>Acquisition details</h2> + <table> + <thead> + <tr><th></th><th>Price exc. taxes</th><th>Price inc. taxes</th><th>fund</th><th></th></tr> + </thead> + <tbody> + <tr> + <td>Ordered amount</td> + <td>[% valuegste_ordered %]</td> + <td>[% valuegsti_ordered %]</td> + <td>[% budget_name_ordered %]</td> + <td> + [% IF ( ordered_exists ) %] + <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">See basket informations</a> + [% END %] + </td> + </tr> + <tr> + <td>Spent amount</td> + <td>[% valuegste_spent %]</td> + <td>[% valuegsti_spent %]</td> + <td>[% budget_name_spent %]</td> + <td> + [% IF ( spent_exists ) %] + <a href="/cgi-bin/koha/acqui/invoice.pl?invoicenumber=[% invoicenumber %]">See invoice informations</a> + [% END %] + </td> + </tr> + </tbody> + </table> + </div> + <!-- /TMPL_IF --> <div id="subscription_planning"> <div class="yui-g"> <div class="rows"> diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index f6d7884..fde311a 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -119,6 +119,33 @@ if (! $subs->{periodicity}) { $subs->{periodicity} = '0'; } my $default_bib_view = get_default_view(); + +my ( $order, $bookseller, $tmpl_infos ); +if ( defined $subscriptionid ) { + my $lastOrderNotReceived = GetLastOrderNotReceivedFromSubscriptionid $subscriptionid; + my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid; + if ( defined $lastOrderNotReceived ) { + my $basket = GetBasket $$lastOrderNotReceived{basketno}; + my $bookseller = GetBookSellerFromId $$basket{booksellerid}; + ( $$tmpl_infos{valuegsti_ordered}, $$tmpl_infos{valuegste_ordered} ) = get_value_with_gst_params ( $$lastOrderNotReceived{ecost}, $$lastOrderNotReceived{gstrate}, $bookseller ); + $$tmpl_infos{valuegsti_ordered} = sprintf( "%.2f", $$tmpl_infos{valuegsti_ordered} ); + $$tmpl_infos{valuegste_ordered} = sprintf( "%.2f", $$tmpl_infos{valuegste_ordered} ); + $$tmpl_infos{budget_name_ordered} = GetBudgetName $$lastOrderNotReceived{budget_id}; + $$tmpl_infos{basketno} = $$lastOrderNotReceived{basketno}; + $$tmpl_infos{ordered_exists} = 1; + } + if ( defined $lastOrderReceived ) { + my $basket = GetBasket $$lastOrderReceived{basketno}; + my $bookseller = GetBookSellerFromId $$basket{booksellerid}; + ( $$tmpl_infos{valuegsti_spent}, $$tmpl_infos{valuegste_spent} ) = get_value_with_gst_params ( $$lastOrderReceived{unitprice}, $$lastOrderReceived{gstrate}, $bookseller ); + $$tmpl_infos{valuegsti_spent} = sprintf( "%.2f", $$tmpl_infos{valuegsti_spent} ); + $$tmpl_infos{valuegste_spent} = sprintf( "%.2f", $$tmpl_infos{valuegste_spent} ); + $$tmpl_infos{budget_name_spent} = GetBudgetName $$lastOrderReceived{budget_id}; + $$tmpl_infos{invoicenumber} = $$lastOrderReceived{booksellerinvoicenumber}; + $$tmpl_infos{spent_exists} = 1; + } +} + $template->param( subscriptionid => $subscriptionid, serialslist => \@serialslist, -- 1.7.7.3