- my @numbers = ();
- for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
- my $highlight=0;
- ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
- push @numbers, { number => $i,
- highlight => $highlight ,
- startfrom => ($i-1)*$resultsperpage};
+ if ( $bookseller->invoiceincgst ) {
+ $order->{ecost} = $order->{ecost_tax_included};
+ } else {
+ $order->{ecost} = $order->{ecost_tax_excluded};
+ }
+ $order->{total} = get_rounded_price($order->{ecost}) * $order->{quantity};
+
+ my %line = %$order;
+
+ $line{invoice} = $invoice;
+ $line{booksellerid} = $booksellerid;
+
+ my $biblionumber = $line{'biblionumber'};
+ my $biblio = Koha::Biblios->find( $biblionumber );
+ my $countbiblio = CountBiblioInOrders($biblionumber);
+ my $ordernumber = $line{'ordernumber'};
+ my $order_object = Koha::Acquisition::Orders->find($ordernumber);
+ my $cnt_subscriptions = $biblio ? $biblio->subscriptions->count: 0;
+ my $itemcount = $biblio ? $biblio->items->count : 0;
+ my $holds_count = $biblio ? $biblio->holds->count : 0;
+ my @itemnumbers = $order_object->items->get_column('itemnumber');
+ my $itemholds = $biblio ? $biblio->holds->search({ itemnumber => { -in => \@itemnumbers } })->count : 0;
+
+ my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber});
+ $line{suggestionid} = $suggestion->{suggestionid};
+ $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby};
+ $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
+
+ # 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 @itemnumbers && !($cnt_subscriptions) && !($holds_count);
+ $line{items} = ($itemcount) - (scalar @itemnumbers);
+ $line{left_item} = 1 if $line{items} >= 1;
+ $line{left_biblio} = 1 if $countbiblio > 1;
+ $line{biblios} = $countbiblio - 1;
+ $line{left_subscription} = 1 if $cnt_subscriptions;
+ $line{subscriptions} = $cnt_subscriptions;
+ $line{left_holds} = ($holds_count >= 1) ? 1 : 0;
+ $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
+ $line{holds} = $holds_count;
+ $line{holds_on_order} = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
+ $line{basket} = Koha::Acquisition::Baskets->find( $line{basketno} );
+
+ my $budget_name = GetBudgetName( $line{budget_id} );
+ $line{budget_name} = $budget_name;
+
+ push @loop_orders, \%line;