Bug 13178: increase max value of CardnumberLength
[koha.git] / C4 / Overdues.pm
index b56708a..bbde4b8 100644 (file)
@@ -34,8 +34,8 @@ use C4::Accounts;
 use C4::Log; # logaction
 use C4::Debug;
 use Koha::DateUtils;
-use Koha::Account::Line;
 use Koha::Account::Lines;
+use Koha::Account::Offsets;
 use Koha::IssuingRules;
 use Koha::Libraries;
 
@@ -591,6 +591,14 @@ sub UpdateFine {
                     accounttype   => 'FU',
                 }
             )->store();
+
+            Koha::Account::Offset->new(
+                {
+                    debit_id => $accountline->id,
+                    type     => 'Fine Update',
+                    amount   => $diff,
+                }
+            )->store();
         }
     } else {
         if ( $amount ) { # Don't add new fines with an amount of 0
@@ -618,6 +626,14 @@ sub UpdateFine {
                     issue_id          => $issue_id,
                 }
             )->store();
+
+            Koha::Account::Offset->new(
+                {
+                    debit_id => $accountline->id,
+                    type     => 'Fine',
+                    amount   => $amount,
+                }
+            )->store();
         }
     }
     # logging action
@@ -997,7 +1013,6 @@ sub parse_overdues_letter {
     my $patron = Koha::Patrons->find( $params->{borrowernumber} );
 
     my $substitute = $params->{'substitute'} || {};
-    $substitute->{today} ||= output_pref( { dt => dt_from_string, dateonly => 1} );
 
     my %tables = ( 'borrowers' => $params->{'borrowernumber'} );
     if ( my $p = $params->{'branchcode'} ) {
@@ -1032,6 +1047,9 @@ sub parse_overdues_letter {
         branchcode => $params->{'branchcode'},
         lang => $patron->lang,
         tables => \%tables,
+        loops => {
+            overdues => [ map { $_->{items}->{itemnumber} } @item_tables ],
+        },
         substitute => $substitute,
         repeat => { item => \@item_tables },
         message_transport_type => $params->{message_transport_type},