+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;
+}
+