Bug 29051: Update svc api to allow seen renewals
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 11 May 2022 15:21:48 +0000 (16:21 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 8 Jul 2022 18:31:39 +0000 (15:31 -0300)
This patch updates the svc/renew api endpoint to allow seen renewals
when appropriate

Signed-off-by: Caroline <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
svc/renew

index 91f7958..470c02e 100755 (executable)
--- a/svc/renew
+++ b/svc/renew
@@ -67,10 +67,12 @@ if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference
     $data->{error} = undef;
 }
 
-if ( $data->{renew_okay} ) {
+if ( $data->{renew_okay} || ( $seen && $data->{error} eq 'too_unseen') ) {
     try{
         $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due, undef, undef, $seen );
         $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
+        $data->{renew_okay} = 1;
+        $data->{error} = undef;
     } catch {
         if ( ref($_) eq 'Koha::Exceptions::Checkout::FailedRenewal' ) {
             $data->{error} = 'renewal_failed';