]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/sepa.pl
Kreditorenbuchungen: In Kopf anzeigen, in welchen SEPA-Exporten der Beleg enthalten ist
[mfinanz.git] / bin / mozilla / sepa.pl
index ac018e2580f4a9fe45430bcf291e600a93009310..1b712a50398a93663e9d6189547a6f468ef27bdc 100755 (executable)
@@ -6,6 +6,7 @@ use POSIX qw(strftime);
 
 use Data::Dumper;
 use SL::DB::BankAccount;
+use SL::DB::SepaExport;
 use SL::Chart;
 use SL::CT;
 use SL::Form;
@@ -208,7 +209,7 @@ sub bank_transfer_list {
 
   my %filter         = map  +( $_ => $form->{"f_${_}"} ),
                        grep  { $form->{"f_${_}"} }
-                             (qw(vc invnumber),
+                             (qw(vc invnumber message_id),
                               map { ("${_}_date_from", "${_}_date_to") }
                                   qw(export requested_execution execution));
   $filter{executed}  = $form->{l_executed} ? 1 : 0 if ($form->{l_executed} != $form->{l_not_executed});
@@ -236,9 +237,10 @@ sub bank_transfer_list {
     'closed'      => { 'text' => $locale->text('Closed'), },
     num_invoices  => { 'text' => $locale->text('Number of invoices'), },
     sum_amounts   => { 'text' => $locale->text('Sum of all amounts'), },
+    message_ids   => { 'text' => $locale->text('SEPA message IDs'), },
   );
 
-  my @columns = qw(selected id export_date employee executed closed invoices netamount);
+  my @columns = qw(selected id export_date employee executed closed num_invoices sum_amounts message_ids);
   my %column_alignment = map { ($_ => 'right') } qw(num_invoices sum_amounts);
 
   foreach my $name (qw(id export_date employee executed closed)) {
@@ -546,6 +548,15 @@ sub bank_transfer_download_sepa_xml {
                                  'date_of_signature' => $item->{mandate_date_of_signature}, });
   }
 
+  # Store the message ID used in each of the entries in order to
+  # facilitate finding them by looking at bank statements.
+  foreach my $id (@ids) {
+    SL::DB::SepaExportMessageId->new(
+      sepa_export_id => $id,
+      message_id     => $message_id,
+    )->save;
+  }
+
   my $xml = $sepa_xml->to_xml();
 
   print $cgi->header('-type'                => 'application/octet-stream',