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

(-)a/C4/Circulation.pm (-15 / +6 lines)
Lines 3945-3959 sub CalcDateDue { Link Here
3945
            if ( $potential_datedue > $library_close and $todayhours->close_time and $tomorrowhours->open_time ) {
3945
            if ( $potential_datedue > $library_close and $todayhours->close_time and $tomorrowhours->open_time ) {
3946
                if ( $considerlibraryhours eq 'close' ) {
3946
                if ( $considerlibraryhours eq 'close' ) {
3947
                    # datedue will be after the library closes on that day
3947
                    # datedue will be after the library closes on that day
3948
                    # shorten loan period to end when library closes
3948
                    # shorten loan period to end when library closes by hardcoding due time
3949
                    $dur = $potential_datedue->delta_ms( $library_close );
3949
                    $datedue->set( hour => $close[0], minute => $close[1] );
3950
                    $sethours = $considerlibraryhours;
3951
                } elsif ( $considerlibraryhours eq 'open' ) {
3950
                } elsif ( $considerlibraryhours eq 'open' ) {
3952
                    # datedue will be after the library closes on that day
3951
                    # datedue will be after the library closes on that day
3953
                    # extend loan period to when library opens following day
3952
                    # extend loan period to when library opens following day by hardcoding due time for next open day
3954
                    my $library_open = $datedue->clone->set( hour => $open[0], minute => $open[1] );
3953
                    $dur = DateTime::Duration->new( days => 1 );
3955
                    $dur = $potential_datedue->delta_ms( $library_open )->add( days => 1 );
3954
                    $datedue->set( hour => $open[0], minute => $open[1] );
3956
                    $sethours = $considerlibraryhours;
3957
                } else {
3955
                } else {
3958
                    # ignore library open hours
3956
                    # ignore library open hours
3959
                    $dur = DateTime::Duration->new( hours => $loanlength->{$length_key} );
3957
                    $dur = DateTime::Duration->new( hours => $loanlength->{$length_key} );
Lines 3967-3982 sub CalcDateDue { Link Here
3967
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key} );
3965
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key} );
3968
        }
3966
        }
3969
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode );
3967
        my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $daysmode );
3970
        $datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} );
3968
        $datedue = $calendar->addDuration( $datedue, $dur, $loanlength->{lengthunit} ) if $dur;
3971
        if ($loanlength->{lengthunit} eq 'days') {
3969
        if ($loanlength->{lengthunit} eq 'days') {
3972
            $datedue->set_hour(23);
3970
            $datedue->set_hour(23);
3973
            $datedue->set_minute(59);
3971
            $datedue->set_minute(59);
3974
        } else {
3975
            if ( $sethours and $sethours eq 'close' ) {
3976
                $datedue->set( hour => $close[0], minute => $close[1] );
3977
            } elsif ( $sethours and $sethours eq 'open' ) {
3978
                $datedue->set( hour => $open[0], minute => $open[1] );
3979
            }
3980
        }
3972
        }
3981
    }
3973
    }
3982
3974
3983
- 

Return to bug 6796