From: G. Richardson Date: Mon, 2 Oct 2017 08:37:03 +0000 (+0200) Subject: DATEV-Export: Personenkontenoption nur anzeigen wenn Konten passen X-Git-Tag: release-3.5.4~737 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=69b298a0f814b3e21d85d3958d198f15001ed6f1;p=kivitendo-erp.git DATEV-Export: Personenkontenoption nur anzeigen wenn Konten passen Die Option "als Personenkonten exportieren" wird nur angezeigt, wenn alle Kunden- und Lieferantennummern in das DATEV-Kontonummerschema passen. Anhaken muß man die Checkbox allerdings trotzdem noch. Besser wäre eine zentrale Konfiguration "DATEV-Export mit Personenkonten exportieren" die dann auch beim Speichern/Anlegen von Konten immer prüft, ob das Kontenschema eingehalten wird. --- diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 426788ab0..b0e9936e7 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -1460,6 +1460,22 @@ sub _csv_buchungsexport_to_file { return { download_token => $self->download_token, filenames => $params{filename} }; } + +sub check_vcnumbers_are_valid_pk_numbers { + my ($self) = @_; + + my $length_of_accounts = length(SL::DB::Manager::Chart->get_first(where => [charttype => 'A'])->accno) // 4; + my $pk_length = $length_of_accounts + 1; + my $query = <<"SQL"; + SELECT customernumber AS vcnumber FROM customer WHERE customernumber !~ '^[[:digit:]]{$pk_length}\$' + UNION + SELECT vendornumber AS vcnumber FROM vendor WHERE vendornumber !~ '^[[:digit:]]{$pk_length}\$' + LIMIT 1; +SQL + my ($has_non_pk_accounts) = selectrow_query($::form, SL::DB->client->dbh, $query); + return defined $has_non_pk_accounts ? 0 : 1; +} + sub DESTROY { clean_temporary_directories(); } @@ -1685,6 +1701,19 @@ Generates a CSV-file with the same encodings as defined in DATEV Format CSV 2015 Usage: _csv_buchungsexport_to_file($self, data => $self->csv_buchungsexport); +=item check_vcnumbers_are_valid_pk_numbers + +Returns 1 if all vcnumbers are suitable for the DATEV export, 0 if not. + +Finds the default length of charts (e.g. 4), adds 1 for the pk chart length +(e.g. 5), and checks the database for any customers or vendors whose customer- +or vendornumber doesn't consist of only numbers with exactly that length. E.g. +for a chart length of four "10001" would be ok, but not "10001b" or "1000". + +All vcnumbers are checked, obsolete customers or vendors aren't exempt. + +There is also no check for the typical customer range 10000-69999 and the +typical vendor range 70000-99999. =back diff --git a/bin/mozilla/datev.pl b/bin/mozilla/datev.pl index d34f0e32d..dbbd28232 100644 --- a/bin/mozilla/datev.pl +++ b/bin/mozilla/datev.pl @@ -78,6 +78,7 @@ sub export_bewegungsdaten { $::form->header; $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted; + $::form->{show_pk_option} = SL::DATEV->new->check_vcnumbers_are_valid_pk_numbers; print $::form->parse_html_template('datev/export_bewegungsdaten'); $::lxdebug->leave_sub; diff --git a/templates/webpages/datev/export_bewegungsdaten.html b/templates/webpages/datev/export_bewegungsdaten.html index e10aa7932..f46f526d8 100644 --- a/templates/webpages/datev/export_bewegungsdaten.html +++ b/templates/webpages/datev/export_bewegungsdaten.html @@ -88,6 +88,7 @@
[% END %] + [% IF show_pk_option %] @@ -102,6 +103,7 @@ + [% END %]