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:
Galen Charlton 2014-05-04 19:13:44 +00:00
parent 0519c428ef
commit 13fe2e013d
2 changed files with 17 additions and 22 deletions

View file

@ -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,

View file

@ -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;
}
for my $rd ( @reservedata ) {
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 $onum = $order->{quantity} // 0;
my $rnum = $order->{quantityreceived} // 0;
$rnum >= $onum && next;
$cnt+=$onum; $cnt-=$rnum;
my $cnt = 0;
if (scalar(@orders)) {
for my $order ( @orders ) {
next if $order->{datecancellationprinted};
my $onum = $order->{quantity} // 0;
my $rnum = $order->{quantityreceived} // 0;
next if $rnum >= $onum;
$cnt += ($onum - $rnum);
}
}
$cnt;
return $cnt;
}