Revision aa38f2e3
Von Tamino Steinert vor 11 Monaten hinzugefügt
SL/Controller/EmailJournal.pm | ||
---|---|---|
397 | 397 |
); |
398 | 398 |
} |
399 | 399 |
|
400 |
sub action_zugferd_import_with_attachment {
|
|
400 |
sub action_ap_transaction_template_with_zugferd_import {
|
|
401 | 401 |
my ($self) = @_; |
402 | 402 |
my $email_journal_id = $::form->{email_journal_id}; |
403 |
my $attachment_id = $::form->{attachment_id}; |
|
404 | 403 |
die "no 'email_journal_id' was given" unless $email_journal_id; |
405 |
die t8("No attachment is selected") unless $attachment_id; |
|
406 | 404 |
|
407 | 405 |
my $record_id = $::form->{"record_id"}; |
408 | 406 |
my $record_type = $::form->{"record_type"}; |
409 | 407 |
die "ZUGFeRD-Import only implemented for ap transaction templates" unless $record_type == 'ap_transaction'; |
410 |
my $attachment = SL::DB::EmailJournalAttachment->new(id => $attachment_id)->load(); |
|
411 | 408 |
|
412 |
my $content = $attachment->content; # scalar ref
|
|
409 |
my $attachment_id = $::form->{attachment_id};
|
|
413 | 410 |
|
414 |
die t8("can only parse a pdf or xml file") unless $content =~ m/^%PDF|<\?xml/; |
|
411 |
my $form_defaults; |
|
412 |
if ($attachment_id) { |
|
413 |
my $attachment = SL::DB::EmailJournalAttachment->new(id => $attachment_id)->load(); |
|
414 |
my $content = $attachment->content; # scalar ref |
|
415 | 415 |
|
416 |
my %res; |
|
417 |
if ( $content =~ m/^%PDF/ ) { |
|
418 |
%res = %{SL::ZUGFeRD->extract_from_pdf($content)}; |
|
419 |
} else { |
|
420 |
%res = %{SL::ZUGFeRD->extract_from_xml($content)}; |
|
421 |
} |
|
416 |
if ($content =~ m/^%PDF|<\?xml/) { |
|
422 | 417 |
|
423 |
unless ($res{'result'} == SL::ZUGFeRD::RES_OK()) { |
|
424 |
die(t8("Could not extract Factur-X/ZUGFeRD data, data and error message:") . " $res{'message'}"); |
|
425 |
} |
|
418 |
my %res; |
|
419 |
if ( $content =~ m/^%PDF/ ) { |
|
420 |
%res = %{SL::ZUGFeRD->extract_from_pdf($content)}; |
|
421 |
} else { |
|
422 |
%res = %{SL::ZUGFeRD->extract_from_xml($content)}; |
|
423 |
} |
|
424 |
|
|
425 |
if ($res{'result'} == SL::ZUGFeRD::RES_OK()) { |
|
426 |
my $ap_template = SL::DB::RecordTemplate->new(id => $record_id)->load(); |
|
427 |
my $vendor = $ap_template->vendor; |
|
426 | 428 |
|
427 |
my $vendor; |
|
428 |
if ($record_id) { |
|
429 |
my $ap_template = SL::DB::RecordTemplate->new(id => $record_id)->load(); |
|
430 |
$vendor = $ap_template->vendor; |
|
429 |
$form_defaults = SL::Controller::ZUGFeRD->build_ap_transaction_form_defaults(\%res, vendor => $vendor); |
|
430 |
flash_later('info', |
|
431 |
t8("The ZUGFeRD/Factur-X invoice '#1' has been loaded.", $attachment->name)); |
|
432 |
} |
|
433 |
} |
|
431 | 434 |
} |
432 | 435 |
|
433 |
my $form_defaults = SL::Controller::ZUGFeRD->build_ap_transaction_form_defaults(\%res, vendor => $vendor); |
|
434 | 436 |
$form_defaults->{email_journal_id} = $email_journal_id; |
435 | 437 |
$form_defaults->{email_attachment_id} = $attachment_id; |
436 | 438 |
$form_defaults->{callback} = $::form->{back_to}; |
437 | 439 |
|
438 |
flash_later('info', |
|
439 |
t8("The ZUGFeRD/Factur-X invoice '#1' has been loaded.", $attachment->name)); |
|
440 | 440 |
$self->redirect_to( |
441 | 441 |
controller => 'ap.pl', |
442 | 442 |
action => 'load_zugferd', |
SL/Presenter/Record.pm | ||
---|---|---|
654 | 654 |
if ($record_type eq 'ap_transaction' && ref $_[0] eq 'SL::DB::RecordTemplate') { |
655 | 655 |
return is_escaped( |
656 | 656 |
button_tag( |
657 |
"kivi.EmailJournal.apply_action_with_attachment( |
|
658 |
'$id', '$record_type');", |
|
659 |
$::locale->text('Select'), |
|
660 |
) |
|
661 |
. " " . |
|
662 |
button_tag( |
|
663 |
"kivi.EmailJournal.zugferd_import_with_attachment( |
|
657 |
"kivi.EmailJournal.ap_transaction_template_with_zugferd_import( |
|
664 | 658 |
'$id', '$record_type');", |
665 |
$::locale->text('Factur-X/ZUGFeRD import'),
|
|
659 |
$::locale->text('Select (with Factur-X/ZUGFeRD import)'),
|
|
666 | 660 |
) |
667 | 661 |
); |
668 | 662 |
} else { |
config/kivitendo.conf.default | ||
---|---|---|
195 | 195 |
# More configuration is possible in the data field of the BJ, for more see |
196 | 196 |
# SL::BackgroundJob::ImportRecordEmails |
197 | 197 |
[record_emails_imap] |
198 |
enabled = 0 |
|
199 | 198 |
hostname = localhost |
200 | 199 |
username = |
201 | 200 |
password = |
js/kivi.EmailJournal.js | ||
---|---|---|
56 | 56 |
$.post("controller.pl", data, kivi.eval_json_result); |
57 | 57 |
} |
58 | 58 |
|
59 |
ns.zugferd_import_with_attachment = function(record_id, record_type) {
|
|
59 |
ns.ap_transaction_template_with_zugferd_import = function(record_id, record_type) {
|
|
60 | 60 |
let data = $('#record_action_form').serializeArray(); |
61 |
data.push({ name: 'action', value: 'EmailJournal/zugferd_import_with_attachment' });
|
|
61 |
data.push({ name: 'action', value: 'EmailJournal/ap_transaction_template_with_zugferd_import' });
|
|
62 | 62 |
data.push({ name: 'record_id', value: record_id }); |
63 | 63 |
data.push({ name: 'record_type', value: record_type }); |
64 | 64 |
|
locale/de/all | ||
---|---|---|
2482 | 2482 |
'No articles have been added yet.' => 'Es wurden noch keine Artikel hinzugefügt.', |
2483 | 2483 |
'No assembly has been selected yet.' => 'Es wurde noch kein Erzeugnis ausgewahlt.', |
2484 | 2484 |
'No attachment' => 'Kein Anhang', |
2485 |
'No attachment is selected' => 'Kein Anhang ausgewählt', |
|
2486 | 2485 |
'No background job has been created yet.' => 'Es wurden noch keine Hintergrund-Jobs angelegt.', |
2487 | 2486 |
'No bank account chosen!' => 'Kein Bankkonto ausgewählt!', |
2488 | 2487 |
'No bank account configured for bank code/BIC #1, account number/IBAN #2.' => 'Kein Bankkonto für BLZ/BIC #1, Kontonummer/IBAN #2 konfiguriert.', |
... | ... | |
3485 | 3484 |
'Sections that are not assigned to any of the items above will be added as new positions.' => 'Abschnitte, die keiner der oben aufgeführten Positionen zugeordnet sind, werden als neue Positionen ergänzt.', |
3486 | 3485 |
'See various menu entries intended for developers' => 'Entwickler-Tools anzeigen', |
3487 | 3486 |
'Select' => 'auswählen', |
3487 |
'Select (with Factur-X/ZUGFeRD import)' => 'auswählen (mit Factur-X/ZUGFeRD-Import)', |
|
3488 | 3488 |
'Select Contact' => 'Ansprechperson auswählen', |
3489 | 3489 |
'Select Deliveries' => 'Lieferungen auswählen', |
3490 | 3490 |
'Select Mulit-Item Options' => 'Multi-Treffer Auswahlliste', |
locale/en/all | ||
---|---|---|
2481 | 2481 |
'No articles have been added yet.' => '', |
2482 | 2482 |
'No assembly has been selected yet.' => '', |
2483 | 2483 |
'No attachment' => '', |
2484 |
'No attachment is selected' => '', |
|
2485 | 2484 |
'No background job has been created yet.' => '', |
2486 | 2485 |
'No bank account chosen!' => '', |
2487 | 2486 |
'No bank account configured for bank code/BIC #1, account number/IBAN #2.' => '', |
... | ... | |
3484 | 3483 |
'Sections that are not assigned to any of the items above will be added as new positions.' => '', |
3485 | 3484 |
'See various menu entries intended for developers' => '', |
3486 | 3485 |
'Select' => '', |
3486 |
'Select (with Factur-X/ZUGFeRD import)' => '', |
|
3487 | 3487 |
'Select Contact' => '', |
3488 | 3488 |
'Select Deliveries' => '', |
3489 | 3489 |
'Select Mulit-Item Options' => '', |
Auch abrufbar als: Unified diff
EmailJournal: Workflow Kreditoren-BV: immer versuchen ZUGFeRD-Daten zuladen