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

(-)a/C4/Circulation.pm (-4 / +18 lines)
Lines 3455-3466 sub CalcDateDue { Link Here
3455
          ->truncate( to => 'minute' );
3455
          ->truncate( to => 'minute' );
3456
    }
3456
    }
3457
3457
3458
3458
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3459
    # calculate the datedue as normal
3459
    # calculate the datedue as normal
3460
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3460
    if ( C4::Context->preference('useDaysMode') eq 'Days' )
3461
    {    # ignoring calendar
3461
    {    # ignoring calendar
3462
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3462
        if ( $loanlength->{lengthunit} eq 'hours' ) {
3463
            $datedue->add( hours => $loanlength->{$length_key} );
3463
            $datedue->add( hours => $loanlength->{$length_key} );
3464
        }elsif ($loanlength->{lengthunit} eq 'minutes') {
3465
            $datedue->add( minutes => $loanlength->{$length_key});
3464
        } else {    # days
3466
        } else {    # days
3465
            $datedue->add( days => $loanlength->{$length_key} );
3467
            $datedue->add( days => $loanlength->{$length_key} );
3466
            $datedue->set_hour(23);
3468
            $datedue->set_hour(23);
Lines 3470-3480 sub CalcDateDue { Link Here
3470
        my $dur;
3472
        my $dur;
3471
        if ($loanlength->{lengthunit} eq 'hours') {
3473
        if ($loanlength->{lengthunit} eq 'hours') {
3472
            $dur = DateTime::Duration->new( hours => $loanlength->{$length_key});
3474
            $dur = DateTime::Duration->new( hours => $loanlength->{$length_key});
3473
        }
3475
        }elsif ($loanlength->{lengthunit} eq 'minutes') {
3474
        else { # days
3476
            $dur = DateTime::Duration->new( minutes => $loanlength->{$length_key});
3477
        }else { # days
3475
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3478
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3476
        }
3479
        }
3477
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3478
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3480
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3479
        if ($loanlength->{lengthunit} eq 'days') {
3481
        if ($loanlength->{lengthunit} eq 'days') {
3480
            $datedue->set_hour(23);
3482
            $datedue->set_hour(23);
Lines 3521-3526 sub CalcDateDue { Link Here
3521
        }
3523
        }
3522
    }
3524
    }
3523
3525
3526
    #check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours.
3527
    if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){
3528
        my $dateInfo = $calendar->get_date_info($datedue);
3529
        my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz());
3530
3531
        my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute());
3532
3533
        if(DateTime->compare($datedue, $close_datetime) > 0) {
3534
            $datedue = $close_datetime->clone();
3535
        }
3536
    }
3537
3524
    return $datedue;
3538
    return $datedue;
3525
}
3539
}
3526
3540
(-)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 334-339 $(document).ready(function() { Link Here
334
                      <select name="lengthunit" id="lengthunit">
334
                      <select name="lengthunit" id="lengthunit">
335
                        <option value="days" selected="selected">Days</option>
335
                        <option value="days" selected="selected">Days</option>
336
                        <option value="hours">Hours</option>
336
                        <option value="hours">Hours</option>
337
                        <option value="minutes">Minutes</option>
337
                      </select>
338
                      </select>
338
                    </td>
339
                    </td>
339
                    <td>
340
                    <td>
340
- 

Return to bug 17983