This was reported by a library running 23.11.03. Sometimes when patrons do renewals via SIP2, the old due date is reported as the new due date. But everything else looks OK, including the staff view and "my profile", which shows the right due date. It looks like this only happens some of the time, or for some patrons, but I have not been able to figure out what the difference is there. I do think I have spotted the problem, though. C4::Circulation::AddIssue() has this code: 1552 my $issue; ... 1571 # find which item we issue 1572 my $item_object = Koha::Items->find({ barcode => $barcode }) 1573 or return; # if we don't get an Item, abort. 1574 my $item_unblessed = $item_object->unblessed; 1575 1576 my $branchcode = _GetCircControlBranch( $item_object, $patron ); 1577 1578 # get actual issuing if there is one 1579 my $actualissue = $item_object->checkout; 1580 1581 # check if we just renew the issue. 1582 if ( $actualissue and $actualissue->borrowernumber eq $patron->borrowernumber 1583 and not $switch_onsite_checkout ) { 1584 $datedue = AddRenewal( 1585 { 1586 borrowernumber => $patron->borrowernumber, 1587 itemnumber => $item_object->itemnumber, 1588 branch => $branchcode, 1589 datedue => $datedue, 1590 lastreneweddate => 1591 $issuedate, # here interpreted as the renewal date 1592 } 1593 ); 1594 $issue = $item_object->checkout; 1595 } We get the $item_object on line 1572. Then we get the active issue/loan/checkout from the $item_object on line 1579. Renewal is done on line 1584 (and testing shows $datedue has the right date due there). But then we update $issue with the active issue/loan/checkout from the same $item_object as earlier, which has not been updated, and contains stale data, including the original date due. I was able to quickfix this by replacing line 1594 with this: my $updated_item_object = my $item_object = Koha::Items->find({ barcode => $barcode }); $issue = $updated_item_object->checkout; But I am far from confident that this is a good fix, so opinions are welcome!
It looks like you can use the get_from_storage method: DB<14> x $item->checkout->unblessed; 0 HASH(0x5624163e5780) 'auto_renew' => 0 'auto_renew_error' => undef 'borrowernumber' => 190 'branchcode' => 'LA' 'date_due' => '2024-06-13 23:59:00' 'issue_id' => 208 'issuedate' => '2024-06-13 15:38:17' 'issuer_id' => undef 'itemnumber' => 310173 'lastreneweddate' => undef 'note' => undef 'notedate' => undef 'noteseen' => undef 'onsite_checkout' => 0 'renewals_count' => 0 'returndate' => undef 'timestamp' => '2024-06-13 15:38:17' 'unseen_renewals' => 0 DB<15> x $item->checkout->get_from_storage->unblessed; 0 HASH(0x5624163e36c0) 'auto_renew' => 0 'auto_renew_error' => undef 'borrowernumber' => 190 'branchcode' => 'LA' 'date_due' => '2024-06-13 23:59:00' 'issue_id' => 208 'issuedate' => '2024-06-13 15:38:17' 'issuer_id' => undef 'itemnumber' => 310173 'lastreneweddate' => '2024-06-13 15:40:00' 'note' => undef 'notedate' => undef 'noteseen' => undef 'onsite_checkout' => 0 'renewals_count' => 1 'returndate' => undef 'timestamp' => '2024-06-13 15:40:00' 'unseen_renewals' => 0
Created attachment 167688 [details] [review] Bug 37016: Invalid due date in SIP renew response Test plan using koha-testing-docker: 1) Make sure SIP is running. You may need to edit /etc/koha/sites/SIPconfig.xml and remove the 8023 connector and restart the SIP-server (koha-sip --restart kohadev) 2) Find a patron, say 23529000197047 3) Set a password by selecting "change password", set it to "Password1234" 4) Find a book, say 39999000000856 5) Issue book to patron with sip-client: sudo koha-shell -c "/usr/share/koha/bin/sip_cli_emulator.pl \ --address localhost --port 6001 -t cr \ --su term1 --sp term1 --message checkout \ --location CPL --item 39999000000856 \ --patron 23529000197047 --password Password1234"\ kohadev 6) Note the AH-header in the response which for example: 'AH20240619 235900' 7) Make a renewal with: sudo koha-shell -c "/usr/share/koha/bin/sip_cli_emulator.pl \ --address localhost --port 6001 -t cr \ --su term1 --sp term1 --message renew \ --location CPL --item 39999000000856 \ --patron 23529000197047 --password Password1234"\ kohadev 8) Make sure the AH-header in the response is different from the response to the checkout, for example: 'AH20240624 235900'
Created attachment 167712 [details] [review] Bug 37016: Invalid due date in SIP renew response Test plan using koha-testing-docker: 1) Make sure SIP is running. You may need to edit /etc/koha/sites/SIPconfig.xml and remove the 8023 connector and restart the SIP-server (koha-sip --restart kohadev) 2) Find a patron, say 23529000197047 3) Set a password by selecting "change password", set it to "Password1234" 4) Find a book, say 39999000000856 5) Issue book to patron with sip-client: sudo koha-shell -c "/usr/share/koha/bin/sip_cli_emulator.pl \ --address localhost --port 6001 -t cr \ --su term1 --sp term1 --message checkout \ --location CPL --item 39999000000856 \ --patron 23529000197047 --password Password1234"\ kohadev 6) Note the AH-header in the response which for example: 'AH20240619 235900' 7) Make a renewal with: sudo koha-shell -c "/usr/share/koha/bin/sip_cli_emulator.pl \ --address localhost --port 6001 -t cr \ --su term1 --sp term1 --message renew \ --location CPL --item 39999000000856 \ --patron 23529000197047 --password Password1234"\ kohadev 8) Make sure the AH-header in the response is different from the response to the checkout, for example: 'AH20240624 235900' Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Created attachment 168152 [details] [review] Bug 37016: Unit tests Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 168153 [details] [review] Bug 37016: Invalid due date in SIP renew response Test plan using koha-testing-docker: 1) Make sure SIP is running. You may need to edit /etc/koha/sites/SIPconfig.xml and remove the 8023 connector and restart the SIP-server (koha-sip --restart kohadev) 2) Find a patron, say 23529000197047 3) Set a password by selecting "change password", set it to "Password1234" 4) Find a book, say 39999000000856 5) Issue book to patron with sip-client: sudo koha-shell -c "/usr/share/koha/bin/sip_cli_emulator.pl \ --address localhost --port 6001 -t cr \ --su term1 --sp term1 --message checkout \ --location CPL --item 39999000000856 \ --patron 23529000197047 --password Password1234"\ kohadev 6) Note the AH-header in the response which for example: 'AH20240619 235900' 7) Make a renewal with: sudo koha-shell -c "/usr/share/koha/bin/sip_cli_emulator.pl \ --address localhost --port 6001 -t cr \ --su term1 --sp term1 --message renew \ --location CPL --item 39999000000856 \ --patron 23529000197047 --password Password1234"\ kohadev 8) Make sure the AH-header in the response is different from the response to the checkout, for example: 'AH20240624 235900' Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Test plan is really nice, but please also include a little summary about the problem and the solution :)
Pushed for 24.11! Well done everyone, thank you!
Backported to 24.05.x for upcoming 24.05.02
Pushed to 23.11.x for 23.11.07
Not backporting to 23.05.x unless requested