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

(-)a/C4/Circulation.pm (-2 / +19 lines)
Lines 3438-3449 sub CalcDateDue { Link Here
3438
          ->truncate( to => 'minute' );
3438
          ->truncate( to => 'minute' );
3439
    }
3439
    }
3440
3440
3441
3441
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3442
    # calculate the datedue as normal
3442
    # calculate the datedue as normal
3443
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3443
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3444
    {    # ignoring calendar
3444
    {    # ignoring calendar
3445
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3445
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3446
            $datedue->add( hours => $loanlength->{$length_key} );
3446
            $datedue->add( hours => $loanlength->{$length_key} );
3447
        } elsif ( $loanlength->{lengthunit} eq 'minutes' ) {
3448
            $datedue->add( minutes => $loanlength->{$length_key});
3447
        } else {    # days
3449
        } else {    # days
3448
            $datedue->add( days => $loanlength->{$length_key} );
3450
            $datedue->add( days => $loanlength->{$length_key} );
3449
            $datedue->set_hour(23);
3451
            $datedue->set_hour(23);
Lines 3454-3463 sub CalcDateDue { Link Here
3454
        if ($loanlength->{lengthunit} eq 'hours') {
3456
        if ($loanlength->{lengthunit} eq 'hours') {
3455
            $dur = DateTime::Duration->new( hours => $loanlength->{$length_key});
3457
            $dur = DateTime::Duration->new( hours => $loanlength->{$length_key});
3456
        }
3458
        }
3459
        elsif ($loanlength->{lengthunit} eq 'minutes') {
3460
            $dur = DateTime::Duration->new( minutes => $loanlength->{$length_key});
3461
        }
3457
        else { # days
3462
        else { # days
3458
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3463
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3459
        }
3464
        }
3460
        my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branch });
3461
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3465
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3462
        if ($loanlength->{lengthunit} eq 'days') {
3466
        if ($loanlength->{lengthunit} eq 'days') {
3463
            $datedue->set_hour(23);
3467
            $datedue->set_hour(23);
Lines 3503-3508 sub CalcDateDue { Link Here
3503
          }
3507
          }
3504
        }
3508
        }
3505
    }
3509
    }
3510
3511
    #check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours.
3512
    if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){
3513
        my $dateInfo = $calendar->get_date_info($datedue);
3514
        my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz());
3515
3516
        my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute());
3517
3518
        if(DateTime->compare($datedue, $close_datetime) > 0) {
3519
            $datedue = $close_datetime->clone();
3520
        }
3521
    }
3522
3506
    return $datedue;
3523
    return $datedue;
3507
}
3524
}
3508
3525
(-)a/C4/Overdues.pm (+12 lines)
Lines 304-309 sub get_chargeable_units { Link Here
304
        }
304
        }
305
        return $charge_duration->in_units('hours');
305
        return $charge_duration->in_units('hours');
306
    }
306
    }
307
    elsif($unit eq 'minutes'){
308
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
309
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
310
            $charge_duration = $calendar->open_minutes_between( $date_due, $date_returned );
311
        } else {
312
            $charge_duration = $date_returned->delta_ms( $date_due );
313
        }
314
        if($charge_duration->in_units('minutes') == 0 && $charge_duration->in_units('seconds') > 0){
315
            return 1;
316
        }
317
        return $charge_duration->in_units('minutes');
318
    }
307
    else { # days
319
    else { # days
308
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
320
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
309
            my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode });
321
            my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branchcode });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +1 lines)
Lines 245-250 Link Here
245
                      <select name="lengthunit" id="lengthunit">
245
                      <select name="lengthunit" id="lengthunit">
246
                        <option value="days" selected="selected">Days</option>
246
                        <option value="days" selected="selected">Days</option>
247
                        <option value="hours">Hours</option>
247
                        <option value="hours">Hours</option>
248
                        <option value="minutes">Minutes</option>
248
                      </select>
249
                      </select>
249
                    </td>
250
                    </td>
250
                    <td>
251
                    <td>
251
- 

Return to bug 17983