Revision 834abeb4
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
SL/Controller/ZUGFeRD.pm | ||
---|---|---|
7 | 7 |
use SL::Helper::DateTime; |
8 | 8 |
use SL::VATIDNr; |
9 | 9 |
use SL::ZUGFeRD; |
10 |
use SL::SessionFile; |
|
10 | 11 |
|
11 | 12 |
use XML::LibXML; |
12 | 13 |
|
... | ... | |
16 | 17 |
sub action_upload_zugferd { |
17 | 18 |
my ($self, %params) = @_; |
18 | 19 |
|
19 |
$self->setup_zugferd_action_bar;
|
|
20 |
$self->pre_render();
|
|
20 | 21 |
$self->render('zugferd/form', title => $::locale->text('Factur-X/ZUGFeRD import')); |
21 | 22 |
} |
22 | 23 |
|
23 | 24 |
sub action_import_zugferd { |
24 | 25 |
my ($self, %params) = @_; |
26 |
my $file = $::form->{file}; |
|
27 |
my $file_name = $::form->{file_name}; |
|
25 | 28 |
|
26 |
die t8("missing file for action import") unless $::form->{file};
|
|
27 |
die t8("can only parse a pdf file") unless $::form->{file} =~ m/^%PDF/;
|
|
29 |
die t8("missing file for action import") unless $file;
|
|
30 |
die t8("can only parse a pdf file") unless $file =~ m/^%PDF/;
|
|
28 | 31 |
|
29 |
my $info = SL::ZUGFeRD->extract_from_pdf($::form->{file});
|
|
32 |
my $info = SL::ZUGFeRD->extract_from_pdf($file);
|
|
30 | 33 |
|
31 | 34 |
if ($info->{result} != SL::ZUGFeRD::RES_OK()) { |
32 | 35 |
# An error occurred; log message from parser: |
... | ... | |
126 | 129 |
my $ibanmessage; |
127 | 130 |
$ibanmessage = $iban ne $vendor->iban ? "Record IBAN $iban doesn't match vendor IBAN " . $vendor->iban : $iban if $iban; |
128 | 131 |
|
129 |
my $url = $self->url_for( |
|
132 |
# save the zugferd file to session file for reuse in ap.pl |
|
133 |
my $session_file = SL::SessionFile->new($file_name, mode => 'w'); |
|
134 |
$session_file->fh->print($file); |
|
135 |
$session_file->fh->close; |
|
136 |
|
|
137 |
$self->redirect_to( |
|
130 | 138 |
controller => 'ap.pl', |
131 | 139 |
action => 'load_record_template', |
132 | 140 |
id => $template_ap->id, |
... | ... | |
138 | 146 |
'form_defaults.paid_1_suggestion' => $::form->format_amount(\%::myconfig, $total, 2), |
139 | 147 |
'form_defaults.notes' => "ZUGFeRD Import. Type: $type\nIBAN: " . $ibanmessage, |
140 | 148 |
'form_defaults.taxincluded' => 0, |
141 |
'form_defaults.direct_debit' => $direct_debit, |
|
149 |
'form_defaults.direct_debit' => $direct_debit, |
|
150 |
'form_defaults.zugferd_session_file' => $file_name, |
|
142 | 151 |
); |
143 | 152 |
|
144 |
$self->redirect_to($url); |
|
145 |
|
|
146 | 153 |
} |
147 | 154 |
|
148 | 155 |
sub check_auth { |
... | ... | |
162 | 169 |
} |
163 | 170 |
} |
164 | 171 |
|
172 |
sub pre_render { |
|
173 |
my ($self) = @_; |
|
174 |
|
|
175 |
$::request->{layout}->use_javascript("${_}.js") for qw( |
|
176 |
kivi.ZUGFeRD |
|
177 |
); |
|
178 |
|
|
179 |
$self->setup_zugferd_action_bar; |
|
180 |
} |
|
181 |
|
|
165 | 182 |
|
166 | 183 |
1; |
167 | 184 |
__END__ |
Auch abrufbar als: Unified diff
ZUGFeRD: speicher ZUGFeRD-Datei zur erstellten Kreditorenbuchung