View | Details | Raw Unified | Return to bug 26457
Collapse All | Expand All

(-)a/C4/Circulation.pm (+6 lines)
Lines 59-64 use Koha::Charges::Fees; Link Here
59
use Koha::Util::SystemPreferences;
59
use Koha::Util::SystemPreferences;
60
use Koha::Checkouts::ReturnClaims;
60
use Koha::Checkouts::ReturnClaims;
61
use Koha::SearchEngine::Indexer;
61
use Koha::SearchEngine::Indexer;
62
use Koha::Exceptions::Checkout;
62
use Carp;
63
use Carp;
63
use List::MoreUtils qw( uniq any );
64
use List::MoreUtils qw( uniq any );
64
use Scalar::Util qw( looks_like_number );
65
use Scalar::Util qw( looks_like_number );
Lines 3085-3090 sub AddRenewal { Link Here
3085
        );
3086
        );
3086
3087
3087
        $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber );
3088
        $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber );
3089
        if ( $sth->err ){
3090
            Koha::Exceptions::Checkout::FailedRenewal->throw(
3091
                error => 'Update of issue# ' . $issue->issue_id . ' failed with error: ' . $sth->errstr
3092
            );
3093
        }
3088
3094
3089
        # Update the renewal count on the item, and tell zebra to reindex
3095
        # Update the renewal count on the item, and tell zebra to reindex
3090
        $renews = ( $item_object->renewals || 0 ) + 1;
3096
        $renews = ( $item_object->renewals || 0 ) + 1;
(-)a/Koha/Exceptions/Checkout.pm (+15 lines)
Line 0 Link Here
1
package Koha::Exceptions::Checkout;
2
3
use Modern::Perl;
4
5
use Exception::Class (
6
    'Koha::Exceptions::Checkout' => {
7
        description => "Something went wrong!"
8
    },
9
    'Koha::Exceptions::Checkout::FailedRenewal' => {
10
        isa         => 'Koha::Exceptions::Checkout',
11
        description => "Renewing checkout failed"
12
    },
13
);
14
15
1;
(-)a/svc/renew (-3 / +11 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use CGI;
22
use CGI;
23
use JSON qw(to_json);
23
use JSON qw(to_json);
24
use Try::Tiny;
24
25
25
use C4::Circulation;
26
use C4::Circulation;
26
use C4::Context;
27
use C4::Context;
Lines 67-74 if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference Link Here
67
}
68
}
68
69
69
if ( $data->{renew_okay} ) {
70
if ( $data->{renew_okay} ) {
70
    $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due, undef, undef, $seen );
71
    try{
71
    $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
72
        $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due, undef, undef, $seen );
73
        $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
74
    } catch {
75
        if ( ref($_) eq 'Koha::Exceptions::Checkout::FailedRenewal' ) {
76
            $data->{error} = 'renewal_failed';
77
        } else {
78
            $_->rethrow;
79
        }
80
    };
72
}
81
}
73
82
74
print to_json($data);
83
print to_json($data);
75
- 

Return to bug 26457