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

(-)a/misc/cronjobs/holds/cancel_expired_holds.pl (-1 / +1 lines)
Lines 81-86 pod2usage(1) if $help; Link Here
81
81
82
cronlogaction({ info => $command_line_options });
82
cronlogaction({ info => $command_line_options });
83
83
84
C4::Reserves::CancelExpiredReserves($reason, $notify);
84
C4::Reserves::CancelExpiredReserves( $reason, $notify );
85
85
86
cronlogaction({ action => 'End', info => "COMPLETED" });
86
cronlogaction({ action => 'End', info => "COMPLETED" });
(-)a/reserve/modrequest.pl (-16 / +13 lines)
Lines 51-81 my $count=@rank; Link Here
51
@biblionumber = uniq @biblionumber;
51
@biblionumber = uniq @biblionumber;
52
52
53
# Cancel or modify the queue list of reserves (without item linked)
53
# Cancel or modify the queue list of reserves (without item linked)
54
if( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) {
54
if ( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) {
55
    for (my $i=0;$i<$count;$i++){
55
    for ( my $i = 0 ; $i < $count ; $i++ ) {
56
        undef $itemnumber[$i] if !$itemnumber[$i];
56
        undef $itemnumber[$i] if !$itemnumber[$i];
57
        my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] );
57
        my $suspend_until              = $query->param( "suspend_until_" . $reserve_id[$i] );
58
        my $cancellation_reason = $query->param("cancellation-reason");
58
        my $cancellation_reason        = $query->param("cancellation-reason");
59
        my $cancellation_notify_patron = $query->param("cancellation-notify-patron");
59
        my $cancellation_notify_patron = $query->param("cancellation-notify-patron");
60
60
61
        my $params = {
61
        my $params = {
62
            rank => $rank[$i],
62
            rank           => $rank[$i],
63
            reserve_id => $reserve_id[$i],
63
            reserve_id     => $reserve_id[$i],
64
            expirationdate => $expirationdates[$i] || undef,
64
            expirationdate => $expirationdates[$i] || undef,
65
            branchcode => $branch[$i],
65
            branchcode     => $branch[$i],
66
            itemnumber => $itemnumber[$i],
66
            itemnumber     => $itemnumber[$i],
67
            defined $suspend_until ? ( suspend_until => $suspend_until ) : (),
67
            defined $suspend_until ? ( suspend_until => $suspend_until ) : (),
68
            cancellation_reason => $cancellation_reason,
68
            cancellation_reason => $cancellation_reason,
69
            notify_patron => $cancellation_notify_patron,
69
            notify_patron       => $cancellation_notify_patron,
70
        };
70
        };
71
        if (C4::Context->preference('AllowHoldDateInFuture')) {
71
        if ( C4::Context->preference('AllowHoldDateInFuture') ) {
72
            $params->{reservedate} = $reservedates[$i] || undef;
72
            $params->{reservedate} = $reservedates[$i] || undef;
73
        }
73
        }
74
74
75
        try {
75
        try {
76
            ModReserve($params);
76
            ModReserve($params);
77
        } catch {
77
        } catch {
78
            if ($_->isa('Koha::Exceptions::ObjectNotFound')){
78
            if ( $_->isa('Koha::Exceptions::ObjectNotFound') ) {
79
                warn $_;
79
                warn $_;
80
            } else {
80
            } else {
81
                $_->rethrow;
81
                $_->rethrow;
Lines 97-107 if( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) { Link Here
97
        }
97
        }
98
    }
98
    }
99
    my @biblio_ids = uniq @biblionumber;
99
    my @biblio_ids = uniq @biblionumber;
100
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
100
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => \@biblio_ids } )
101
        {
101
        if C4::Context->preference('RealTimeHoldsQueue');
102
            biblio_ids => \@biblio_ids
103
        }
104
    ) if C4::Context->preference('RealTimeHoldsQueue');
105
}
102
}
106
103
107
my $from=$query->param('from');
104
my $from=$query->param('from');
(-)a/t/db_dependent/Koha/Hold.t (-12 / +14 lines)
Lines 1101-1110 subtest 'cancel() tests' => sub { Link Here
1101
    # Mock GetPreparedLetter so it raises a warning we can look for
1101
    # Mock GetPreparedLetter so it raises a warning we can look for
1102
    # and returns undef, so no call to EnqueueLetter happens
1102
    # and returns undef, so no call to EnqueueLetter happens
1103
    my $mocked_letter = Test::MockModule->new("C4::Letters");
1103
    my $mocked_letter = Test::MockModule->new("C4::Letters");
1104
    $mocked_letter->mock( 'GetPreparedLetter', sub {
1104
    $mocked_letter->mock(
1105
        $get_prepared_letter_called = 1;
1105
        'GetPreparedLetter',
1106
        return;
1106
        sub {
1107
    });
1107
            $get_prepared_letter_called = 1;
1108
            return;
1109
        }
1110
    );
1108
1111
1109
    my $hold = $builder->build_object(
1112
    my $hold = $builder->build_object(
1110
        {
1113
        {
Lines 1119-1125 subtest 'cancel() tests' => sub { Link Here
1119
1122
1120
    # leave this things out of the test
1123
    # leave this things out of the test
1121
    t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', 0 );
1124
    t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', 0 );
1122
    t::lib::Mocks::mock_preference( 'HoldsLog', 0 );
1125
    t::lib::Mocks::mock_preference( 'HoldsLog',                           0 );
1123
1126
1124
    $hold = $builder->build_object(
1127
    $hold = $builder->build_object(
1125
        {
1128
        {
Lines 1133-1143 subtest 'cancel() tests' => sub { Link Here
1133
    );
1136
    );
1134
1137
1135
    $get_prepared_letter_called = 0;
1138
    $get_prepared_letter_called = 0;
1136
    $hold->cancel({ cancellation_reason => 'Some reason' });
1139
    $hold->cancel( { cancellation_reason => 'Some reason' } );
1137
    ok( !$get_prepared_letter_called, 'GetPreparedLetter not called' );
1140
    ok( !$get_prepared_letter_called, 'GetPreparedLetter not called' );
1138
1141
1139
    isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' );
1142
    isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' );
1140
    is( $hold->priority, 0, 'priority gets set to 0' );
1143
    is( $hold->priority,            0,             'priority gets set to 0' );
1141
    is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' );
1144
    is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' );
1142
1145
1143
    $hold = $builder->build_object(
1146
    $hold = $builder->build_object(
Lines 1152-1162 subtest 'cancel() tests' => sub { Link Here
1152
    );
1155
    );
1153
1156
1154
    $get_prepared_letter_called = 0;
1157
    $get_prepared_letter_called = 0;
1155
    $hold->cancel({ cancellation_reason => 'Some reason', notify_patron => 1 });
1158
    $hold->cancel( { cancellation_reason => 'Some reason', notify_patron => 1 } );
1156
    ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron and cancellation_reason passed' );
1159
    ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron and cancellation_reason passed' );
1157
1160
1158
    isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' );
1161
    isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' );
1159
    is( $hold->priority, 0, 'priority gets set to 0' );
1162
    is( $hold->priority,            0,             'priority gets set to 0' );
1160
    is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' );
1163
    is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' );
1161
1164
1162
    $hold = $builder->build_object(
1165
    $hold = $builder->build_object(
Lines 1171-1179 subtest 'cancel() tests' => sub { Link Here
1171
    );
1174
    );
1172
1175
1173
    $get_prepared_letter_called = 0;
1176
    $get_prepared_letter_called = 0;
1174
    $hold->cancel({ notify_patron => 1 });
1177
    $hold->cancel( { notify_patron => 1 } );
1175
    isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' );
1178
    isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' );
1176
    is( $hold->priority, 0, 'priority gets set to 0' );
1179
    is( $hold->priority,            0,     'priority gets set to 0' );
1177
    is( $hold->cancellation_reason, undef, 'cancellation_reason not passed' );
1180
    is( $hold->cancellation_reason, undef, 'cancellation_reason not passed' );
1178
1181
1179
    $schema->storage->txn_rollback;
1182
    $schema->storage->txn_rollback;
1180
- 

Return to bug 26282