]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/io.pl
ZUGFeRD: Validierung diverser nötiger Parameter
[mfinanz.git] / bin / mozilla / io.pl
index 1ee0d2c090ff61bf1d7ce80f4f8dedb6fe846a18..0cde59cec08488435662692efba1846a271afd84 100644 (file)
@@ -2122,17 +2122,23 @@ sub _maybe_attach_zugferd_data {
 
   return if !$record || !$record->can('create_pdf_a_print_options') || !$record->can('create_zugferd_data');
 
-  my $xmlfile = File::Temp->new;
-  $xmlfile->print($record->create_zugferd_data);
-  $xmlfile->close;
-
-  $form->{TEMPLATE_DRIVER_OPTIONS}->{pdf_a}           = $record->create_pdf_a_print_options(zugferd_xmp_data => $record->create_zugferd_xmp_data);
-  $form->{TEMPLATE_DRIVER_OPTIONS}->{pdf_attachments} = [
-    { source       => $xmlfile,
-      name         => 'ZUGFeRD-invoice.xml',
-      description  => $::locale->text('ZUGFeRD invoice'),
-      relationship => '/Alternative',
-      mime_type    => 'text/xml',
-    }
-  ];
+  eval {
+    my $xmlfile = File::Temp->new;
+    $xmlfile->print($record->create_zugferd_data);
+    $xmlfile->close;
+
+    $form->{TEMPLATE_DRIVER_OPTIONS}->{pdf_a}           = $record->create_pdf_a_print_options(zugferd_xmp_data => $record->create_zugferd_xmp_data);
+    $form->{TEMPLATE_DRIVER_OPTIONS}->{pdf_attachments} = [
+      { source       => $xmlfile,
+        name         => 'ZUGFeRD-invoice.xml',
+        description  => $::locale->text('ZUGFeRD invoice'),
+        relationship => '/Alternative',
+        mime_type    => 'text/xml',
+      }
+    ];
+  };
+
+  if (my $e = SL::X::ZUGFeRDValidation->caught) {
+    $::form->error($e->message);
+  }
 }