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

(-)a/C4/Overdues.pm (-6 / +9 lines)
Lines 282-296 C<$branchcode> is the branch whose calendar to use for finding holidays. Link Here
282
=cut
282
=cut
283
283
284
sub _get_chargeable_units {
284
sub _get_chargeable_units {
285
    my ($unit, $dt1, $dt2, $branchcode) = @_;
285
    my ($unit, $date_due, $date_returned, $branchcode) = @_;
286
287
    # If the due date is later than the return date
288
    return 0 unless ( $date_returned > $date_due );
289
286
    my $charge_units = 0;
290
    my $charge_units = 0;
287
    my $charge_duration;
291
    my $charge_duration;
288
    if ($unit eq 'hours') {
292
    if ($unit eq 'hours') {
289
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
293
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
290
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
294
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
291
            $charge_duration = $calendar->hours_between( $dt1, $dt2 );
295
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
292
        } else {
296
        } else {
293
            $charge_duration = $dt2->delta_ms( $dt1 );
297
            $charge_duration = $date_returned->delta_ms( $date_due );
294
        }
298
        }
295
        if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){
299
        if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){
296
            return 1;
300
            return 1;
Lines 300-308 sub _get_chargeable_units { Link Here
300
    else { # days
304
    else { # days
301
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
305
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
302
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
306
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
303
            $charge_duration = $calendar->days_between( $dt1, $dt2 );
307
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
304
        } else {
308
        } else {
305
            $charge_duration = $dt2->delta_days( $dt1 );
309
            $charge_duration = $date_returned->delta_days( $date_due );
306
        }
310
        }
307
        return $charge_duration->in_units('days');
311
        return $charge_duration->in_units('days');
308
    }
312
    }
309
- 

Return to bug 12596