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

(-)a/C4/Overdues.pm (-6 / +10 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
    ## FIXME: Add unit test
290
286
    my $charge_units = 0;
291
    my $charge_units = 0;
287
    my $charge_duration;
292
    my $charge_duration;
288
    if ($unit eq 'hours') {
293
    if ($unit eq 'hours') {
289
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
294
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
290
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
295
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
291
            $charge_duration = $calendar->hours_between( $dt1, $dt2 );
296
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
292
        } else {
297
        } else {
293
            $charge_duration = $dt2->delta_ms( $dt1 );
298
            $charge_duration = $date_returned->delta_ms( $date_due );
294
        }
299
        }
295
        if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){
300
        if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){
296
            return 1;
301
            return 1;
Lines 300-308 sub _get_chargeable_units { Link Here
300
    else { # days
305
    else { # days
301
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
306
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
302
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
307
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
303
            $charge_duration = $calendar->days_between( $dt1, $dt2 );
308
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
304
        } else {
309
        } else {
305
            $charge_duration = $dt2->delta_days( $dt1 );
310
            $charge_duration = $date_returned->delta_days( $date_due );
306
        }
311
        }
307
        return $charge_duration->in_units('days');
312
        return $charge_duration->in_units('days');
308
    }
313
    }
309
- 

Return to bug 12596