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

(-)a/C4/Circulation.pm (-15 / +6 lines)
Lines 3898-3912 sub CalcDateDue { Link Here
3898
            if ( $potential_datedue > $library_close and $todayhours->close_time and $tomorrowhours->open_time ) {
3898
            if ( $potential_datedue > $library_close and $todayhours->close_time and $tomorrowhours->open_time ) {
3899
                if ( $considerlibraryhours eq 'close' ) {
3899
                if ( $considerlibraryhours eq 'close' ) {
3900
                    # datedue will be after the library closes on that day
3900
                    # datedue will be after the library closes on that day
3901
                    # shorten loan period to end when library closes
3901
                    # shorten loan period to end when library closes by hardcoding due time
3902
                    $dur = $potential_datedue->delta_ms( $library_close );
3902
                    $datedue->set( hour => $close[0], minute => $close[1] );
3903
                    $sethours = $considerlibraryhours;
3904
                } elsif ( $considerlibraryhours eq 'open' ) {
3903
                } elsif ( $considerlibraryhours eq 'open' ) {
3905
                    # datedue will be after the library closes on that day
3904
                    # datedue will be after the library closes on that day
3906
                    # extend loan period to when library opens following day
3905
                    # extend loan period to when library opens following day by hardcoding due time for next open day
3907
                    my $library_open = $datedue->clone->set( hour => $open[0], minute => $open[1] );
3906
                    $dur = DateTime::Duration->new( days => 1 );
3908
                    $dur = $potential_datedue->delta_ms( $library_open )->add( days => 1 );
3907
                    $datedue->set( hour => $open[0], minute => $open[1] );
3909
                    $sethours = $considerlibraryhours;
3910
                } else {
3908
                } else {
3911
                    # ignore library open hours
3909
                    # ignore library open hours
3912
                    $dur = DateTime::Duration->new( hours => $loanlength->{$length_key} );
3910
                    $dur = DateTime::Duration->new( hours => $loanlength->{$length_key} );
Lines 3920-3935 sub CalcDateDue { Link Here
3920
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key} );
3918
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key} );
3921
        }
3919
        }
3922
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode );
3920
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode );
3923
        $datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} );
3921
        $datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} ) if $dur;
3924
        if ($loanlength->{lengthunit} eq 'days') {
3922
        if ($loanlength->{lengthunit} eq 'days') {
3925
            $datedue->set_hour(23);
3923
            $datedue->set_hour(23);
3926
            $datedue->set_minute(59);
3924
            $datedue->set_minute(59);
3927
        } else {
3928
            if ( $sethours and $sethours eq 'close' ) {
3929
                $datedue->set( hour => $close[0], minute => $close[1] );
3930
            } elsif ( $sethours and $sethours eq 'open' ) {
3931
                $datedue->set( hour => $open[0], minute => $open[1] );
3932
            }
3933
        }
3925
        }
3934
    }
3926
    }
3935
3927
3936
- 

Return to bug 6796