Bug 11665: (follow-up) simplify code
This patch replaces some of the logic with more direct Boolean expressions. Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
0519c428ef
commit
13fe2e013d
2 changed files with 17 additions and 22 deletions
|
@ -360,13 +360,10 @@ my @gst_values = map {
|
|||
option => $_ + 0.0
|
||||
}, split( '\|', C4::Context->preference("gist") );
|
||||
|
||||
my $quantity = $data->{'quantity'};
|
||||
{
|
||||
defined($quantity) && last;
|
||||
my $rr_quantity_to_order = $input->param('rr_quantity_to_order');
|
||||
(defined($rr_quantity_to_order) && $rr_quantity_to_order) || last;
|
||||
$quantity = $rr_quantity_to_order;
|
||||
}
|
||||
my $quantity = $input->param('rr_quantity_to_order') ?
|
||||
$input->param('rr_quantity_to_order') :
|
||||
$data->{'quantity'};
|
||||
$quantity //= 0;
|
||||
|
||||
$template->param(
|
||||
existing => $biblionumber,
|
||||
|
|
|
@ -166,13 +166,9 @@ while ( my $data = $sth->fetchrow_hashref ) {
|
|||
);
|
||||
}
|
||||
|
||||
{
|
||||
for my $rd ( @reservedata ) {
|
||||
$rd->{biblionumber} || next;
|
||||
my $pcnt = CountPendingOrdersByBiblionumber( $rd->{biblionumber} );
|
||||
$pcnt || next;
|
||||
$rd->{pendingorders} = $pcnt;
|
||||
}
|
||||
next unless $rd->{biblionumber};
|
||||
$rd->{pendingorders} = CountPendingOrdersByBiblionumber( $rd->{biblionumber} );
|
||||
}
|
||||
|
||||
$template->param(
|
||||
|
@ -189,13 +185,15 @@ output_html_with_http_headers $input, $cookie, $template->output;
|
|||
sub CountPendingOrdersByBiblionumber {
|
||||
my $biblionumber = shift;
|
||||
my @orders = GetOrdersByBiblionumber( $biblionumber );
|
||||
scalar(@orders) || return(0);
|
||||
my $cnt=0; for my $order ( @orders ) {
|
||||
defined($order->{datecancellationprinted}) && $order->{datecancellationprinted} && next;
|
||||
my $cnt = 0;
|
||||
if (scalar(@orders)) {
|
||||
for my $order ( @orders ) {
|
||||
next if $order->{datecancellationprinted};
|
||||
my $onum = $order->{quantity} // 0;
|
||||
my $rnum = $order->{quantityreceived} // 0;
|
||||
$rnum >= $onum && next;
|
||||
$cnt+=$onum; $cnt-=$rnum;
|
||||
next if $rnum >= $onum;
|
||||
$cnt += ($onum - $rnum);
|
||||
}
|
||||
$cnt;
|
||||
}
|
||||
return $cnt;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue