Mahnungen: beim erneuten Drucken ggf. auch originale Rechnung mit drucken, …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 17 Mar 2021 15:31:52 +0000 (16:31 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 17 Mar 2021 16:09:37 +0000 (17:09 +0100)
… sofern diese beim Mahnlauf mit gedruckt wurde.

SL/DN.pm
bin/mozilla/dn.pl

index ed196c0..9016aaa 100644 (file)
--- a/SL/DN.pm
+++ b/SL/DN.pm
@@ -342,7 +342,7 @@ sub _save_dunning {
 
   my $q_insert_dunning =
     qq|INSERT INTO dunning (id,  dunning_id, dunning_config_id, dunning_level, trans_id,
-                            fee, interest,   transdate,         duedate)
+                            fee, interest,   transdate,         duedate,       original_invoice_printed)
        VALUES (?, ?, ?,
                (SELECT dunning_level FROM dunning_config WHERE id = ?),
                ?,
@@ -353,7 +353,8 @@ sub _save_dunning {
                  * (SELECT interest_rate FROM dunning_config WHERE id = ?)
                  / 360,
                current_date,
-               current_date + (SELECT payment_terms FROM dunning_config WHERE id = ?))|;
+               current_date + (SELECT payment_terms FROM dunning_config WHERE id = ?),
+               ?)|;
   my $h_insert_dunning = prepare_query($form, $dbh, $q_insert_dunning);
 
   my @invoice_ids;
@@ -387,7 +388,8 @@ sub _save_dunning {
 
     @values = ($row_id,         $dunning_id,     $next_config_id,
                $next_config_id, $invoice_id,     $next_config_id,
-               $invoice_id,     $next_config_id, $next_config_id);
+               $invoice_id,     $next_config_id, $next_config_id,
+               $print_invoice);
     do_statement($form, $h_insert_dunning, $q_insert_dunning, @values);
 
     RecordLinks->create_links(
index 5634c90..376b56e 100644 (file)
@@ -561,6 +561,11 @@ sub print_multiple {
     $form->{dunning_id} = $dunning_id;
     DN->print_invoice_for_fees(\%myconfig, $form, $dunning_id);
     DN->print_dunning(\%myconfig, $form, $dunning_id);
+
+    # print original dunned invoices, if they where printed on dunning run
+    my $dunnings = SL::DB::Manager::Dunning->get_all(where => [dunning_id => $dunning_id, original_invoice_printed => 1]);
+    DN->print_original_invoice(\%myconfig, $form, $_->trans_id) for @$dunnings;
+
     $i++;
   }
   $form->{language_id} = $saved_language_id;