11 |
11 |
use File::Copy qw(move);
|
12 |
12 |
use List::MoreUtils qw(uniq);
|
13 |
13 |
use List::Util qw(first);
|
|
14 |
use Scalar::Util qw(blessed);
|
14 |
15 |
use String::ShellQuote ();
|
15 |
16 |
|
16 |
17 |
use SL::Common;
|
... | ... | |
20 |
21 |
use SL::System::Process;
|
21 |
22 |
use SL::Template;
|
22 |
23 |
use SL::Template::LaTeX;
|
|
24 |
use SL::X;
|
23 |
25 |
|
24 |
26 |
use Exporter 'import';
|
25 |
27 |
our @EXPORT_OK = qw(create_pdf merge_pdfs find_template);
|
... | ... | |
69 |
71 |
$form->{tmpfile} = $tmpfile;
|
70 |
72 |
(undef, undef, $form->{template_meta}{tmpfile}) = File::Spec->splitpath($tmpfile);
|
71 |
73 |
|
|
74 |
my %driver_options;
|
|
75 |
eval {
|
|
76 |
%driver_options = _maybe_attach_zugferd_data($params{record});
|
|
77 |
};
|
|
78 |
|
|
79 |
if (my $e = SL::X::ZUGFeRDValidation->caught) {
|
|
80 |
$form->cleanup;
|
|
81 |
die $e->message;
|
|
82 |
}
|
|
83 |
|
72 |
84 |
my $parser = SL::Template::create(
|
73 |
85 |
type => ($params{template_type} || 'LaTeX'),
|
74 |
86 |
source => $form->{IN},
|
... | ... | |
76 |
88 |
myconfig => \%::myconfig,
|
77 |
89 |
userspath => $tmpdir,
|
78 |
90 |
variable_content_types => $params{variable_content_types},
|
|
91 |
%driver_options,
|
79 |
92 |
);
|
80 |
93 |
|
81 |
94 |
my $result = $parser->parse($temp_fh);
|
... | ... | |
250 |
263 |
return wantarray ? ($template, @template_files) : $template;
|
251 |
264 |
}
|
252 |
265 |
|
|
266 |
sub _maybe_attach_zugferd_data {
|
|
267 |
my ($record) = @_;
|
|
268 |
|
|
269 |
return if !blessed($record)
|
|
270 |
|| !$record->can('customer')
|
|
271 |
|| !$record->customer
|
|
272 |
|| !$record->can('create_pdf_a_print_options')
|
|
273 |
|| !$record->can('create_zugferd_data')
|
|
274 |
|| !$record->customer->create_zugferd_invoices_for_this_customer;
|
|
275 |
|
|
276 |
my $xmlfile = File::Temp->new;
|
|
277 |
$xmlfile->print($record->create_zugferd_data);
|
|
278 |
$xmlfile->close;
|
|
279 |
|
|
280 |
my %driver_options = (
|
|
281 |
pdf_a => $record->create_pdf_a_print_options(zugferd_xmp_data => $record->create_zugferd_xmp_data),
|
|
282 |
pdf_attachments => [
|
|
283 |
{ source => $xmlfile,
|
|
284 |
name => 'ZUGFeRD-invoice.xml',
|
|
285 |
description => $::locale->text('ZUGFeRD invoice'),
|
|
286 |
relationship => '/Alternative',
|
|
287 |
mime_type => 'text/xml',
|
|
288 |
}
|
|
289 |
],
|
|
290 |
);
|
|
291 |
|
|
292 |
return %driver_options;
|
|
293 |
}
|
|
294 |
|
253 |
295 |
1;
|
254 |
296 |
__END__
|
255 |
297 |
|
ZUGFeRD: auch wiederkehrende Rechnungen mit ZUGFeRD-Infos erzeugen