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

(-)a/misc/cronjobs/recalls/expire_recalls.pl (-9 / +11 lines)
Lines 40-49 my $command_line_options = join(" ",@ARGV); Link Here
40
cronlogaction({ info => $command_line_options });
40
cronlogaction({ info => $command_line_options });
41
41
42
my $recalls = Koha::Recalls->search({ completed => 0 });
42
my $recalls = Koha::Recalls->search({ completed => 0 });
43
my $today = dt_from_string()->truncate( to  => 'day' );
43
while( my $recall = $recalls->next ) {
44
while( my $recall = $recalls->next ) {
44
    if ( ( $recall->requested or $recall->overdue ) and $recall->expiration_date and dt_from_string( $recall->expiration_date ) < dt_from_string() ){
45
    if ( ( $recall->requested or $recall->overdue ) and $recall->expiration_date ) {
45
        # recall is requested or overdue and has surpassed the specified expiration date
46
        my $expiration_date = dt_from_string( $recall->expiration_date )->truncate( to  => 'day' );
46
        $recall->set_expired({ interface => 'COMMANDLINE' });
47
        if ( $expiration_date < $today ){
48
            # recall is requested or overdue and has surpassed the specified expiration date
49
            $recall->set_expired({ interface => 'COMMANDLINE' });
50
        }
47
    }
51
    }
48
    if ( $recall->waiting ) {
52
    if ( $recall->waiting ) {
49
        my $recall_shelf_time = Koha::CirculationRules->get_effective_rule({
53
        my $recall_shelf_time = Koha::CirculationRules->get_effective_rule({
Lines 52-67 while( my $recall = $recalls->next ) { Link Here
52
            branchcode => $recall->pickup_library_id,
56
            branchcode => $recall->pickup_library_id,
53
            rule_name => 'recall_shelf_time',
57
            rule_name => 'recall_shelf_time',
54
        });
58
        });
55
        my $waitingdate = dt_from_string( $recall->waiting_date );
59
        my $waitingdate = dt_from_string( $recall->waiting_date )->truncate( to  => 'day' );
56
        my $now = dt_from_string();
60
        my $days_waiting = $today->subtract_datetime( $waitingdate );
57
        my $days_waiting = $now->subtract_datetime( $waitingdate );
61
        if ( defined $recall_shelf_time and $recall_shelf_time->rule_value >= 0 ) {
58
        if ( defined $recall_shelf_time and $recall_shelf_time->rule_value > 0 ) {
59
            if ( $days_waiting->days > $recall_shelf_time->rule_value ) {
62
            if ( $days_waiting->days > $recall_shelf_time->rule_value ) {
60
                # recall has been awaiting pickup for longer than the circ rules allow
63
                # recall has been awaiting pickup for longer than the circ rules allow
61
                $recall->set_expired({ interface => 'COMMANDLINE' });
64
                $recall->set_expired({ interface => 'COMMANDLINE' });
62
            }
65
            }
63
        } else {
66
        } else {
64
            if ( $days_waiting->days > C4::Context->preference('RecallsMaxPickUpDelay') ) {
67
            if ( $days_waiting->days >= C4::Context->preference('RecallsMaxPickUpDelay') ) {
65
                # recall has been awaiting pickup for longer than the syspref allows
68
                # recall has been awaiting pickup for longer than the syspref allows
66
                $recall->set_expired({ interface => 'COMMANDLINE' });
69
                $recall->set_expired({ interface => 'COMMANDLINE' });
67
            }
70
            }
68
- 

Return to bug 33992