From 7ae54f1b063559f98a5d84520d0c82403a9f9bc4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 5 Feb 2020 14:29:44 +0100 Subject: [PATCH] Bug 24595: Silent warnings from Circulation.t --- C4/Circulation.pm | 15 ++++++++++++--- C4/Overdues.pm | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 813c064fd6..09389eca81 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -959,7 +959,7 @@ sub CanBookBeIssued { } else { my $itemtype = Koha::ItemTypes->find($biblioitem->itemtype); - if ( $itemtype and $itemtype->notforloan == 1){ + if ( $itemtype && defined $itemtype->notforloan && $itemtype->notforloan == 1){ if (!C4::Context->preference("AllowNotForLoanOverride")) { $issuingimpossible{NOT_FOR_LOAN} = 1; $issuingimpossible{itemtype_notforloan} = $effective_itemtype; @@ -2294,7 +2294,7 @@ sub _calculate_new_debar_dt { if ( $deltadays->subtract($grace)->is_positive() ) { my $suspension_days = $deltadays * $finedays; - if ( $issuing_rule->{suspension_chargeperiod} > 1 ) { + if ( defined $issuing_rule->{suspension_chargeperiod} && $issuing_rule->{suspension_chargeperiod} > 1 ) { # No need to / 1 and do not consider / 0 $suspension_days = DateTime::Duration->new( days => floor( $suspension_days->in_units('days') / $issuing_rule->{suspension_chargeperiod} ) @@ -3784,7 +3784,16 @@ sub LostItem{ defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!"; # zero is OK, check defined if (C4::Context->preference('WhenLostChargeReplacementFee')){ - C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "$issues->{'title'} $issues->{'barcode'} $issues->{'itemcallnumber'}"); + C4::Accounts::chargelostitem( + $borrowernumber, + $itemnumber, + $issues->{'replacementprice'}, + sprintf( "%s %s %s", + $issues->{'title'} || q{}, + $issues->{'barcode'} || q{}, + $issues->{'itemcallnumber'} || q{}, + ), + ); #FIXME : Should probably have a way to distinguish this from an item that really was returned. #warn " $issues->{'borrowernumber'} / $itemnumber "; } diff --git a/C4/Overdues.pm b/C4/Overdues.pm index 62012081fa..8a9f7ffb33 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -268,7 +268,7 @@ sub CalcFine { my $charge_periods = $units / $issuing_rule->{chargeperiod}; # If chargeperiod_charge_at = 1, we charge a fine at the start of each charge period # if chargeperiod_charge_at = 0, we charge at the end of each charge period - $charge_periods = $issuing_rule->{chargeperiod_charge_at} == 1 ? ceil($charge_periods) : floor($charge_periods); + $charge_periods = defined $issuing_rule->{chargeperiod_charge_at} && $issuing_rule->{chargeperiod_charge_at} == 1 ? ceil($charge_periods) : floor($charge_periods); $amount = $charge_periods * $issuing_rule->{fine}; } # else { # a zero (or null) chargeperiod or negative units_minus_grace value means no charge. } @@ -527,7 +527,7 @@ sub UpdateFine { my $itemnum = $params->{itemnumber}; my $borrowernumber = $params->{borrowernumber}; my $amount = $params->{amount}; - my $due = $params->{due}; + my $due = $params->{due} // q{}; $debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, due => $due, issue_id => $issue_id})"; -- 2.11.0