Revision 1795164f
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
SL/DB/EmailJournalAttachment.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
use XML::LibXML; |
|
6 |
|
|
7 |
use SL::ZUGFeRD; |
|
8 |
|
|
9 | 5 |
use SL::DB::PurchaseInvoice; |
10 | 6 |
use SL::DB::MetaSetup::EmailJournalAttachment; |
11 | 7 |
use SL::DB::Manager::EmailJournalAttachment; |
... | ... | |
13 | 9 |
|
14 | 10 |
__PACKAGE__->meta->initialize; |
15 | 11 |
|
16 |
sub create_ap_invoice { |
|
17 |
my ($self) = @_; |
|
18 |
|
|
19 |
my $content = $self->content; # scalar ref |
|
20 |
|
|
21 |
return unless $content =~ m/^%PDF/; |
|
22 |
|
|
23 |
my $zugferd_info = SL::ZUGFeRD->extract_from_pdf($content); |
|
24 |
return unless $zugferd_info->{result} == SL::ZUGFeRD::RES_OK(); |
|
25 |
|
|
26 |
my $zugferd_xml = XML::LibXML->load_xml(string => $zugferd_info->{invoice_xml}); |
|
27 |
|
|
28 |
return SL::DB::PurchaseInvoice->create_from_zugferd_xml($zugferd_xml)->save(); |
|
29 |
} |
|
30 |
|
|
31 | 12 |
1; |
Auch abrufbar als: Unified diff
ImportRecordEmails: BJ zum importieren von Emails als Beleg-Grundlage