Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 44292086

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 44292086ceab9611635d6438e3bed808df38ac99
  • Vorgänger f05c4f4d
  • Nachfolger f29e8f1c

EmailJournal: ZUGFeRD-Emailanhänge in Kreditorenbuchen konvertieren

Unterschiede anzeigen:

SL/DB/EmailJournal.pm
use strict;
use SL::Webdav;
use SL::File;
use SL::DB::MetaSetup::EmailJournal;
use SL::DB::Manager::EmailJournal;
use SL::DB::Helper::AttrSorted;
use SL::DB::Helper::LinkedRecords;
__PACKAGE__->meta->add_relationship(
attachments => {
......
return $result || ($self->id <=> $other->id);
}
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