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

(-)a/C4/Circulation.pm (-4 / +18 lines)
Lines 3487-3498 sub CalcDateDue { Link Here
3487
          ->truncate( to => 'minute' );
3487
          ->truncate( to => 'minute' );
3488
    }
3488
    }
3489
3489
3490
3490
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3491
    # calculate the datedue as normal
3491
    # calculate the datedue as normal
3492
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3492
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3493
    {    # ignoring calendar
3493
    {    # ignoring calendar
3494
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3494
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3495
            $datedue->add( hours => $loanlength->{$length_key} );
3495
            $datedue->add( hours => $loanlength->{$length_key} );
3496
        }elsif ($loanlength->{lengthunit} eq 'minutes') {
3497
            $datedue->add( minutes => $loanlength->{$length_key});
3496
        } else {    # days
3498
        } else {    # days
3497
            $datedue->add( days => $loanlength->{$length_key} );
3499
            $datedue->add( days => $loanlength->{$length_key} );
3498
            $datedue->set_hour(23);
3500
            $datedue->set_hour(23);
Lines 3502-3512 sub CalcDateDue { Link Here
3502
        my $dur;
3504
        my $dur;
3503
        if ($loanlength->{lengthunit} eq 'hours') {
3505
        if ($loanlength->{lengthunit} eq 'hours') {
3504
            $dur = DateTime::Duration->new( hours => $loanlength->{$length_key});
3506
            $dur = DateTime::Duration->new( hours => $loanlength->{$length_key});
3505
        }
3507
        }elsif ($loanlength->{lengthunit} eq 'minutes') {
3506
        else { # days
3508
            $dur = DateTime::Duration->new( minutes => $loanlength->{$length_key});
3509
        }else { # days
3507
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3510
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3508
        }
3511
        }
3509
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3510
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3512
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3511
        if ($loanlength->{lengthunit} eq 'days') {
3513
        if ($loanlength->{lengthunit} eq 'days') {
3512
            $datedue->set_hour(23);
3514
            $datedue->set_hour(23);
Lines 3546-3551 sub CalcDateDue { Link Here
3546
        }
3548
        }
3547
    }
3549
    }
3548
3550
3551
    #check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours.
3552
    if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){
3553
        my $dateInfo = $calendar->get_date_info($datedue);
3554
        my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz());
3555
3556
        my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute());
3557
3558
        if(DateTime->compare($datedue, $close_datetime) > 0) {
3559
            $datedue = $close_datetime->clone();
3560
        }
3561
    }
3562
3549
    return $datedue;
3563
    return $datedue;
3550
}
3564
}
3551
3565
(-)a/C4/Overdues.pm (-2 / +12 lines)
Lines 308-315 sub get_chargeable_units { Link Here
308
            return 1;
308
            return 1;
309
        }
309
        }
310
        return $charge_duration->in_units('hours');
310
        return $charge_duration->in_units('hours');
311
    }
311
    }elsif($unit eq 'minutes'){
312
    else { # days
312
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
313
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
314
            $charge_duration = $calendar->open_minutes_between( $date_due, $date_returned );
315
        } else {
316
            $charge_duration = $date_returned->delta_ms( $date_due );
317
        }
318
        if($charge_duration->in_units('minutes') == 0 && $charge_duration->in_units('seconds') > 0){
319
            return 1;
320
        }
321
        return $charge_duration->in_units('minutes');
322
    }else { # days
313
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
323
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
314
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
324
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
315
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
325
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +1 lines)
Lines 320-325 $(document).ready(function() { Link Here
320
                      <select name="lengthunit" id="lengthunit">
320
                      <select name="lengthunit" id="lengthunit">
321
                        <option value="days" selected="selected">Days</option>
321
                        <option value="days" selected="selected">Days</option>
322
                        <option value="hours">Hours</option>
322
                        <option value="hours">Hours</option>
323
                        <option value="minutes">Minutes</option>
323
                      </select>
324
                      </select>
324
                    </td>
325
                    </td>
325
                    <td>
326
                    <td>
326
- 

Return to bug 17983