From b9ff74bd3d765f2e2e9b85a36336ec16eb1123c7 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Thu, 9 Jun 2016 16:48:07 +0000
Subject: [PATCH] Bug 14048: [QA Followup]

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jason Robb <jrobb@sekls.org>

Signed-off-by: Jennifer Schmidt <jschmidt@switchinc.org>

Signed-off-by: Margaret Thrasher <p.thrasher@dover.nh.gov>
---
 C4/Circulation.pm | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 7fa77da..08081fc 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -1439,13 +1439,18 @@ sub AddIssue {
 
         ## If item was lost, it has now been found, reverse any list item charges if necessary.
         if ( $item->{'itemlost'} ) {
-            if ( Koha::RefundLostItemFeeRules->should_refund(
-                    current_branch => C4::Context->userenv->{ branch },
-                    patron_branch  => $borrower->{ branchcode },
-                    item_home_branch => $item->{ homebranch },
-                    item_holding_branch => $item->{ holdingbranch }
-                 ) ) {
-                _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, $item->{'barcode'} );
+            if (
+                Koha::RefundLostItemFeeRules->should_refund(
+                    {
+                        current_branch      => C4::Context->userenv->{branch},
+                        item_home_branch    => $item->{homebranch},
+                        item_holding_branch => $item->{holdingbranch}
+                    }
+                )
+              )
+            {
+                _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef,
+                    $item->{'barcode'} );
             }
         }
 
@@ -2118,12 +2123,16 @@ sub AddReturn {
         $messages->{'WasLost'} = 1;
 
         if ( $item->{'itemlost'} ) {
-            if ( Koha::RefundLostItemFeeRules->should_refund(
-                    current_branch => C4::Context->userenv->{ branch },
-                    patron_branch  => $borrower->{ branchcode },
-                    item_home_branch => $item->{ homebranch },
-                    item_holding_branch => $item->{ holdingbranch }
-                 ) ) {
+            if (
+                Koha::RefundLostItemFeeRules->should_refund(
+                    {
+                        current_branch      => C4::Context->userenv->{branch},
+                        item_home_branch    => $item->{homebranch},
+                        item_holding_branch => $item->{holdingbranch}
+                    }
+                )
+              )
+            {
                 _FixAccountForLostAndReturned( $item->{'itemnumber'}, $borrowernumber, $barcode );
                 $messages->{'LostItemFeeRefunded'} = 1;
             }
-- 
2.1.4