X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/31378f48eb1742809789dd2e9670f8564850cce1..d32410ac096b:/SL/File/Backend/Webdav.pm diff --git a/SL/File/Backend/Webdav.pm b/SL/File/Backend/Webdav.pm index 871b61f58..c457080af 100644 --- a/SL/File/Backend/Webdav.pm +++ b/SL/File/Backend/Webdav.pm @@ -73,7 +73,7 @@ sub get_mtime { die "no dbfile" unless $params{dbfile}; $main::lxdebug->message(LXDebug->DEBUG2(), "version=" .$params{version}); my ($path, undef, undef) = $self->webdav_path($params{dbfile}); - die "no file found in backend" if !-f $path; + die "No file found in Backend: " . $path unless -f $path; my @st = stat($path); my $dt = DateTime->from_epoch(epoch => $st[9])->clone(); $main::lxdebug->message(LXDebug->DEBUG2(), "dt=" .$dt); @@ -84,7 +84,7 @@ sub get_filepath { my ($self, %params) = @_; die "no dbfile" unless $params{dbfile}; my ($path, undef, undef) = $self->webdav_path($params{dbfile}); - die "no file" if !-f $path; + die "No file found in Backend: " . $path unless -f $path; return $path; } @@ -105,8 +105,7 @@ sub sync_from_backend { } sub enabled { - return 0 unless $::instance_conf->get_doc_webdav; - return 1; + return $::instance_conf->get_doc_webdav; } # @@ -131,6 +130,8 @@ my %type_to_path = ( gl_transaction => 'dialogbuchungen', accounts_payable => 'kreditorenbuchungen', shop_image => 'shopbilder', + customer => 'kunden', + vendor => 'lieferanten', ); my %type_to_model = ( @@ -151,6 +152,8 @@ my %type_to_model = ( gl_transaction => 'GLTransaction', accounts_payable => 'GLTransaction', shop_image => 'Part', + customer => 'Customer', + vendor => 'Vendor', ); my %model_to_number = ( @@ -162,6 +165,8 @@ my %model_to_number = ( Letter => 'letternumber', GLTransaction => 'reference', ShopImage => 'partnumber', + Customer => 'customernumber', + Vendor => 'vendornumber', ); sub webdav_path { @@ -181,18 +186,17 @@ sub webdav_path { } $main::lxdebug->message(LXDebug->DEBUG2(), "file_name=" . $dbfile->file_name ." number=".$number); - my @fileparts = split(/_/, $dbfile->file_name); - my $number_ext = pop @fileparts; - my ($maynumber, $ext) = split(/\./, $number_ext, 2); - push @fileparts, $maynumber if $maynumber ne $number; - - my $basename = join('_', @fileparts); - my $path = File::Spec->catdir($self->get_rootdir, "webdav", $::auth->client->{id}, $type, $number); if (!-d $path) { File::Path::make_path($path, { chmod => 0770 }); } - my $fname = $basename . '_' . $number . '_' . $dbfile->itime->strftime('%Y%m%d_%H%M%S'); + # simply add the timestring before the last . + # fails for .tar.gz but the number extraction algorithm failed for all + # '123 Storno zu 456' cases and doubled the name like: + # Rechnung_123_Storno_zu_456_202113104 Storno zu 456_20211123_113023 + # TODO extension should be part of the File Model (filetype) + my ($filename, $ext) = split(/\.([^\.]+)$/, $dbfile->file_name); + my $fname = $filename . '_' . $dbfile->itime->strftime('%Y%m%d_%H%M%S'); $fname .= '.' . $ext if $ext; $main::lxdebug->message(LXDebug->DEBUG2(), "webdav path=" . $path . " filename=" . $fname);