[Koha-patches] [PATCH] bug_7420: code reindent and comment

Srdjan Jankovic srdjan at catalyst.net.nz
Tue Feb 21 05:12:45 CET 2012


---
 C4/Overdues.pm |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/C4/Overdues.pm b/C4/Overdues.pm
index 03192c0..0f7914c 100644
--- a/C4/Overdues.pm
+++ b/C4/Overdues.pm
@@ -515,25 +515,29 @@ sub UpdateFine {
     my $data;
     my $total_amount_other = 0.00;
     my $due_qr = qr/$due/;
+    # Cycle through the fines and
+    # - find line that relates to the requested $itemnum
+    # - accumulate fines for other items
+    # so we can update $itemnum fine taking in account fine caps
     while (my $rec = $sth->fetchrow_hashref) {
-      if ($rec->{itemnumber} == $itemnum && $rec->{description} =~ /$due_qr/) {
-        if ($data) {
-          warn "Not a unique accountlines record for item $itemnum borrower $borrowernumber";
-        } else {
-          $data = $rec;
-          next;
+        if ($rec->{itemnumber} == $itemnum && $rec->{description} =~ /$due_qr/) {
+            if ($data) {
+                warn "Not a unique accountlines record for item $itemnum borrower $borrowernumber";
+            } else {
+                $data = $rec;
+                next;
+            }
         }
-      }
-      $total_amount_other += $rec->{'amount'};
+        $total_amount_other += $rec->{'amount'};
     }
     if (my $maxfine = C4::Context->preference('MaxFine')) {
-      if ($total_amount_other + $amount > $maxfine) {
-        my $new_amount = $maxfine - $total_amount_other;
-        warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached";
-        return if $new_amount <= 0.00;
-        
-        $amount = $new_amount;
-      }
+        if ($total_amount_other + $amount > $maxfine) {
+            my $new_amount = $maxfine - $total_amount_other;
+            warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached";
+            return if $new_amount <= 0.00;
+
+            $amount = $new_amount;
+        }
     }
 
     if ( $data ) {
-- 
1.6.5



More information about the Koha-patches mailing list