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

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

Return to bug 6796