Revision 34101eee
Von Tamino Steinert vor 4 Monaten hinzugefügt
SL/DB/EmailJournal.pm | ||
---|---|---|
return !!scalar @{$self->linked_records};
|
||
}
|
||
|
||
sub process_attachments_as_purchase_invoices {
|
||
my ($self) = @_;
|
||
|
||
my $attachments = $self->attachments_sorted;
|
||
foreach my $attachment (@$attachments) {
|
||
my $ap_invoice = $attachment->create_ap_invoice();
|
||
next unless $ap_invoice;
|
||
|
||
# link to email journal
|
||
$self->link_to_record($ap_invoice);
|
||
|
||
# copy file to webdav folder
|
||
if ($::instance_conf->get_webdav_documents) {
|
||
my $webdav = SL::Webdav->new(
|
||
type => 'accounts_payable',
|
||
number => $ap_invoice->invnumber,
|
||
);
|
||
my $webdav_file = SL::Webdav::File->new(
|
||
webdav => $webdav,
|
||
filename => $attachment->name,
|
||
);
|
||
eval {
|
||
$webdav_file->store(data => \$attachment->content);
|
||
1;
|
||
} or do {
|
||
die 'Storing the ZUGFeRD file to the WebDAV folder failed: ' . $@;
|
||
};
|
||
}
|
||
# copy file to doc storage
|
||
if ($::instance_conf->get_doc_storage) {
|
||
eval {
|
||
SL::File->save(
|
||
object_id => $ap_invoice->id,
|
||
object_type => 'purchase_invoice',
|
||
mime_type => 'application/pdf',
|
||
source => 'uploaded',
|
||
file_type => 'document',
|
||
file_name => $attachment->name,
|
||
file_contents => $attachment->content,
|
||
);
|
||
1;
|
||
} or do {
|
||
die 'Storing the ZUGFeRD file in the storage backend failed: ' . $@;
|
||
};
|
||
}
|
||
}
|
||
|
||
my $new_ext_status = join('_', $self->extended_status, 'processed');
|
||
$self->update({ extended_status => $new_ext_status});
|
||
}
|
||
|
||
1;
|
||
|
||
__END__
|
Auch abrufbar als: Unified diff
S:D:EmailJournal: entferne toten Code