From e6ae63e6316a5b01607c74b722829851af1167d5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Oct 2021 12:48:23 +0000 Subject: [PATCH] Bug 29184: Fix warn about undefined replacecost MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch simply sets the cost to 0 if undefined To test: 1 - Create a new item with no replacement cost set 2 - Check the item out to a patron 3 - Mark the item lost 4 - Note in plack-intranet-error.log: [2021/10/06 12:43:26] [WARN] Use of uninitialized value $replacementprice in numeric gt (>) at /kohadevbox/koha/C4/Accounts.pm line 114. 5 - Apply patch 6 - Repeat 7 - No warn Signed-off-by: David Nind Signed-off-by: Joonas Kylmälä Signed-off-by: Tomas Cohen Arazi --- C4/Accounts.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index e5b7c441d8..ad4bd86d76 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -69,15 +69,15 @@ FIXME : if no replacement price, borrower just doesn't get charged? sub chargelostitem { my $dbh = C4::Context->dbh(); - my ($borrowernumber, $itemnumber, $amount, $description) = @_; + my ($borrowernumber, $itemnumber, $replacementprice, $description) = @_; my $item = Koha::Items->find($itemnumber); my $itype = $item->itemtype; - my $replacementprice = $amount; + $replacementprice //= 0; my $defaultreplacecost = $itype->defaultreplacecost; my $processfee = $itype->processfee; my $usedefaultreplacementcost = C4::Context->preference("useDefaultReplacementCost"); my $processingfeenote = C4::Context->preference("ProcessingFeeNote"); - if ($usedefaultreplacementcost && $amount == 0 && $defaultreplacecost){ + if ($usedefaultreplacementcost && $replacementprice == 0 && $defaultreplacecost){ $replacementprice = $defaultreplacecost; } my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber }); -- 2.20.1