From d8124b753d1b9357379480100397cc2e062809a5 Mon Sep 17 00:00:00 2001
From: Eric Garcia <cubingguy714@gmail.com>
Date: Tue, 6 Aug 2024 19:01:00 +0000
Subject: [PATCH] Bug 33641: Code changes

To test:

1. Apply patch, restart_all, updatedatabase
2. Check out an item to a patron
3. Query the database
    - select return_branch from issues;     should return NULL
    - select branchcode from issues;        should return the branchcode of the library you checkout the item out from
    - select return_branch from old_issues; should match the branchcode from the previous query

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 C4/Circulation.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index c15a8b3e96c..54d2feafa13 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -2646,6 +2646,7 @@ sub MarkIssueReturned {
             $issue->returndate( \'NOW()' )->store->discard_changes; # update and refetch
         }
 
+        $issue->return_branch(C4::Context->userenv->{'branch'});
         # Create the old_issues entry
         my $old_checkout = Koha::Old::Checkout->new($issue->unblessed)->store;
 
-- 
2.39.5