From 254ef1b288fe55a17d10468ba776b43661594269 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 2 Nov 2017 12:51:04 +0100 Subject: [PATCH] =?utf8?q?DATEV:=20Nummernkreisl=C3=A4nge=20muss=20konstan?= =?utf8?q?t=20sein.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Entsprechende Prüfung am Anfang des Exports --- SL/DATEV.pm | 23 +++++++++++++++++++++++ bin/mozilla/datev.pl | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 0b24d4898..1b2f42672 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -1417,6 +1417,23 @@ SQL return defined $has_non_pk_accounts ? 0 : 1; } + +sub check_valid_length_of_accounts { + my ($self) = @_; + + my $query = <<"SQL"; + SELECT DISTINCT char_length (accno) FROM chart WHERE charttype='A' AND id in (select chart_id from acc_trans); +SQL + + my $accno_length = selectall_hashref_query($::form, SL::DB->client->dbh, $query); + if (1 < keys $accno_length) { + $::form->error(t8("Invalid combination of ledger account number length." . + " Mismatch length of #1 with length of #2. Please check your account settings. ", + $accno_length->[0]->{char_length}, $accno_length->[1]->{char_length})); + } + return 1; +} + sub DESTROY { clean_temporary_directories(); } @@ -1656,6 +1673,12 @@ 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. +=item check_valid_length_of_accounts + +Returns 1 if all currently booked accounts have only one common number length domain (e.g. 4 or 6). +Will throw an error if more than one distinct size is detected. +The error message gives a short hint with the value of the (at least) +two mismatching number length domains. =back =head1 ATTRIBUTES diff --git a/bin/mozilla/datev.pl b/bin/mozilla/datev.pl index dbbd28232..28043e174 100644 --- a/bin/mozilla/datev.pl +++ b/bin/mozilla/datev.pl @@ -79,6 +79,10 @@ 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; + + # check if we have mismatching number length domains + SL::DATEV->new->check_valid_length_of_accounts; + print $::form->parse_html_template('datev/export_bewegungsdaten'); $::lxdebug->leave_sub; -- 2.20.1