From 274b11d17f354f9629f4f182f6e6b112d437e5e2 Mon Sep 17 00:00:00 2001
From: Lari Strand <lari.strand@koha-suomi.fi>
Date: Fri, 4 Oct 2024 15:18:29 +0300
Subject: [PATCH] Bug 32934: Correctly honor the no block due date for SIP
 checkout messages

---
 C4/Circulation.pm                  | 10 +++++-----
 C4/SIP/ILS/Transaction/Checkout.pm |  6 ++++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index bd8ecfc58f..266ef57b2b 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -4263,7 +4263,7 @@ sub ProcessOfflineOperation {
     if ( $operation->{action} eq 'return' ) {
         $report = ProcessOfflineReturn( $operation );
     } elsif ( $operation->{action} eq 'issue' ) {
-        $report = ProcessOfflineIssue( $operation );
+        ( $report ) = ProcessOfflineIssue( $operation );
     } elsif ( $operation->{action} eq 'payment' ) {
         $report = ProcessOfflinePayment( $operation );
     }
@@ -4321,15 +4321,15 @@ sub ProcessOfflineIssue {
                 $operation->{timestamp},
             );
         }
-        AddIssue(
+        my $checkout = AddIssue(
             $patron,
-            $operation->{'barcode'},
-            undef,
+            $operation->{barcode},
+            $operation->{due_date},
             undef,
             $operation->{timestamp},
             undef,
         );
-        return "Success.";
+        return ( "Success.", $checkout );
     } else {
         return "Borrower not found.";
     }
diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm
index b27fcbe4ff..78ee828db8 100644
--- a/C4/SIP/ILS/Transaction/Checkout.pm
+++ b/C4/SIP/ILS/Transaction/Checkout.pm
@@ -152,11 +152,13 @@ sub do_checkout {
 
     if ( $no_block_due_date ) {
         $overridden_duedate = $no_block_due_date;
-        ProcessOfflineIssue({
+        my ( $msg, $checkout ) = ProcessOfflineIssue({
             cardnumber => $patron->cardnumber,
             barcode    => $barcode,
-            timestamp  => $no_block_due_date,
+            due_date   => $no_block_due_date,
+            timestamp  => dt_from_string,
         });
+        $self->{due} = $self->duedatefromissue($checkout, $itemnumber);
     } else {
         # can issue
         my $recall_id;
-- 
2.34.1