From 6eb084e14b467162c400400dc04b702020b9a40f Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Thu, 17 Sep 2020 12:59:11 +0100
Subject: [PATCH] Bug 25261: (QA follow-up) Catch attepts to return via SCO

This patch adds a block to capture attempts to return items with
attached materials when checking in via the self checkout when the
relevant system preference is set.
---
 opac/sco/sco-main.pl | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl
index c4042b2d26..f87ed7f250 100755
--- a/opac/sco/sco-main.pl
+++ b/opac/sco/sco-main.pl
@@ -135,8 +135,20 @@ if ($op eq "logout") {
     $query->param( patronid => undef, patronlogin => undef, patronpw => undef );
 }
 elsif ( $op eq "returnbook" && $allowselfcheckreturns ) {
-    my ($doreturn) = AddReturn( $barcode, $branch );
-    $template->param( returned => $doreturn );
+    my $success        = 0;
+    my $human_required = 0;
+    if ( C4::Context->preference("CircConfirmItemParts") ) {
+        my $item = Koha::Items->find( { barcode => $barcode } );
+        if ( defined($item)
+            && $item->materials )
+        {
+            $human_required = 1;
+        }
+    }
+
+    ($success) = AddReturn( $barcode, $branch )
+      unless $human_required;
+    $template->param( returned => $success );
 }
 elsif ( $patron && ( $op eq 'checkout' || $op eq 'renew' ) ) {
     my $impossible  = {};
-- 
2.20.1