bug 7849 Instant Fine Calculation\n Adds functionality of calculate fines instantly...
[koha.git] / C4 / Overdues.pm
index 23e75f5..c7430c9 100644 (file)
@@ -255,7 +255,8 @@ sub CalcFine {
     my ( $item, $bortype, $branchcode, $due_dt, $end_date  ) = @_;
     my $start_date = $due_dt->clone();
     # get issuingrules (fines part will be used)
-    my $data = C4::Circulation::GetIssuingRule($bortype, $item->{itemtype}, $branchcode);
+    my $itemtype = $item->{itemtype} || $item->{itype};
+    my $data = C4::Circulation::GetIssuingRule($bortype, $itemtype, $branchcode);
     my $fine_unit = $data->{lengthunit};
     $fine_unit ||= 'days';
 
@@ -300,6 +301,9 @@ sub _get_chargeable_units {
         } else {
             $charge_duration = $dt2->delta_ms( $dt1 );
         }
+        if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){
+            return 1;
+        }
         return $charge_duration->in_units('hours');
     }
     else { # days