From 2c86cb0ad16866113be6e6d8dff239623b77a576 Mon Sep 17 00:00:00 2001 From: Niclas Zimmermann Date: Tue, 22 Jan 2013 11:34:08 +0100 Subject: [PATCH] =?utf8?q?Update-Script=20f=C3=BCr=20fehlende=20Steuerschl?= =?utf8?q?=C3=BCssel?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bisher gab es noch sehr viele Konten, für die kein Eintrag in der Tabelle taxkeys und damit kein Steuerschlüssel vorhanden war. Dieses Update erstellt für jedes Konto ohne Steuerschlüssel einen in der taxkeys, s.d. solche Konten den Steuerschlüssel 0 haben. Hierfür ist unbedingt erforderlich, dass der Steuerschlüssel 0 existiert (also in tax vorhanden ist) und dieser Eintrag den Steuersatz 0% hat. Existiert der Steuerschlüssel 0 nicht, so wird er angelegt. Existiert ein Steuerschlüssel 0 mit mehr als 0% Steuern, so wird das Update mit Fehlermeldung abgebrochen. Siehe hierzu auch die Tickets #2028, #2029. --- locale/de/all | 7 ++ locale/en/all | 3 + sql/Pg-upgrade2/charts_without_taxkey.pl | 64 +++++++++++++++++++ .../webpages/dbupgrade/taxkey_update.html | 15 +++++ 4 files changed, 89 insertions(+) create mode 100644 sql/Pg-upgrade2/charts_without_taxkey.pl create mode 100644 templates/webpages/dbupgrade/taxkey_update.html diff --git a/locale/de/all b/locale/de/all index 387fde77d..0dd29a98f 100644 --- a/locale/de/all +++ b/locale/de/all @@ -651,6 +651,7 @@ $self->{texts} = { 'Display' => 'Anzeigen', 'Display file' => 'Datei anzeigen', 'Display options' => 'Anzeigeoptionen', + 'Do not change the tax rate of taxkey 0.' => 'Ändern Sie nicht den Steuersatz vom Steuerschlüssel 0.', 'Do not check for duplicates' => 'Nicht nach Dubletten suchen', 'Do not set default buchungsgruppe' => 'Nie Standardbuchungsgruppe setzen', 'Do you really want to close the following SEPA exports? No payment will be recorded for bank collections that haven\'t been marked as executed yet.' => 'Wollen Sie wirklich die folgenden SEPA-Exporte abschließen? Für Überweisungen, die noch nicht gebucht wurden, werden dann keine Zahlungen verbucht.', @@ -699,6 +700,7 @@ $self->{texts} = { 'Dunnings' => 'Mahnungen', 'Duplicate in CSV file' => 'Duplikat in CSV-Datei', 'Duplicate in database' => 'Duplikat in Datenbank', + 'During the next update a taxkey 0 with tax rate of 0 will automatically created.' => 'Beim nächsten Ausführen des Updates wird ein Steuerschlüssel 0 mit einem Steuersatz von 0% automatisch erzeugt.', 'During this user migration kivitendo can create such a group for you and grant all users access to all of kivitendo\'s functions.' => 'Im Rahmen dieser Benutzerdatenmigration kann kivitendo eine solche Gruppe für Sie anlegen und allen Benutzern Zugriff auf alle kivitendo-Funktionen gewähren.', 'E-mail' => 'eMail', 'E-mail Statement to' => 'Fälligkeitsabrechnung als eMail an', @@ -912,6 +914,7 @@ $self->{texts} = { 'Fristsetzung' => 'Fristsetzung', 'From' => 'Von', 'From Date' => 'Von', + 'From this version on the taxkey 0 must have a tax rate of 0 (for DATEV compatibility).' => 'Ab dieser Version muss der Steuerschlüssel 0 einen Steuersatz von 0% haben (auf Grund der DATEV-Kompatibilität).', 'Full Access' => 'Vollzugriff', 'Full Preview' => 'Alles', 'Full access to all functions' => 'Vollzugriff auf alle Funktionen', @@ -2054,6 +2057,7 @@ $self->{texts} = { 'There are still entries in the database for which no unit has been assigned.' => 'Es gibt noch Einträge in der Datenbank, für die keine Einheit zugeordnet ist.', 'There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?' => 'Einige der Lagerbewegungen sind nicht vollständig und Lagerbewegungen können nachträglich nicht mehr verändert werden. Wollen Sie wirklich fortfahren?', 'There are usually three ways to install Perl modules.' => 'Es gibt normalerweise drei Arten, ein Perlmodul zu installieren.', + 'There is already a taxkey 0 with tax rate not 0.' => 'Es existiert bereits ein Steuerschlüssel mit Steuersatz ungleich 0%.', 'There is at least one sales or purchase invoice for which kivitendo recorded an inventory transaction with taxkeys even though no tax was recorded.' => 'Es gibt mindestens eine Verkaufs- oder Einkaufsrechnung, für die kivitendo eine Warenbestandsbuchung ohne dazugehörige Steuerbuchung durchgeführt hat.', 'There is at least one transaction for which the user has chosen a logically wrong taxkey.' => 'Es gibt mindestens eine Buchung, bei der ein logisch nicht passender Steuerschlüssel ausgewählt wurde.', 'There is not enough available of \'#1\' at warehouse \'#2\', bin \'#3\', #4, #5, for the transfer of #6.' => 'Von \'#1\' ist in Lager \'#2\', Lagerplatz \'#3\', #4, #5, nicht genügend eingelagert, um insgesamt #6 auszulagern.', @@ -2094,6 +2098,7 @@ $self->{texts} = { 'To (time)' => 'Bis', 'To Date' => 'Bis', 'To add a user to a group edit a name, change the login name and save. A new user with the same variables will then be saved under the new login name.' => 'Um einer Gruppe einen neuen Benutzer hinzuzufügen, ändern und speichern Sie am einfachsten einen bestehenden Benutzernamen. Unter dem neuen Namen wird dann ein Benutzer mit denselben Einstellungen angelegt.', + 'To continue please change the taxkey 0 to another value.' => 'Um fortzufahren, ändern Sie bitte den Steuerschlüssel 0 auf einen anderen Wert.', 'Top' => 'Oben', 'Top (CSS)' => 'Oben (mit CSS)', 'Top (Javascript)' => 'Oben (mit Javascript)', @@ -2486,6 +2491,8 @@ $self->{texts} = { 'tax_taxdescription' => 'Steuername', 'tax_taxkey' => 'Steuerschlüssel', 'taxincluded checked' => '"Steuer im Preis inbegriffen" vorwählen', + 'taxkey 0 is already allocated.' => 'Steuerschlüssel 0 ist bereits vergeben.', + 'taxkey 0 with taxrate 0 was created.' => 'Steuerschl&ssel 0 wurde angelegt.', 'taxnumber' => 'Automatikkonto', 'terminated' => 'gekündigt', 'to (date)' => 'bis', diff --git a/locale/en/all b/locale/en/all index 5e5d092db..7734f90cf 100644 --- a/locale/en/all +++ b/locale/en/all @@ -893,9 +893,11 @@ $self->{texts} = { 'Fristsetzung' => '', 'From' => '', 'From Date' => '', + 'From this version on the taxkey 0 is reserved for tax rate 0.' => '', 'Full Access' => '', 'Full Preview' => '', 'Full access to all functions' => '', + 'Furthermore you should define a taxkey for all accounts, because this update cannot be executed.' => '', 'Fwd' => 'Forward', 'GL Transaction' => '', 'GL transactions changeable' => '', @@ -1989,6 +1991,7 @@ $self->{texts} = { 'There are still entries in the database for which no unit has been assigned.' => '', 'There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?' => '', 'There are usually three ways to install Perl modules.' => '', + 'There is already a taxkey 0 with tax rate not 0.' => '', 'There is at least one sales or purchase invoice for which kivitendo recorded an inventory transaction with taxkeys even though no tax was recorded.' => '', 'There is at least one transaction for which the user has chosen a logically wrong taxkey.' => '', 'There is not enough available of \'#1\' at warehouse \'#2\', bin \'#3\', #4, #5, for the transfer of #6.' => '', diff --git a/sql/Pg-upgrade2/charts_without_taxkey.pl b/sql/Pg-upgrade2/charts_without_taxkey.pl new file mode 100644 index 000000000..8f4841a80 --- /dev/null +++ b/sql/Pg-upgrade2/charts_without_taxkey.pl @@ -0,0 +1,64 @@ +# @tag: charts_without_taxkey +# @description: Fügt für jedes Konto, was keien Steuerschlüssel hat, den Steuerschlüssel 0 hinzu +# @depends: +# @charset: UTF-8 + +use utf8; +use strict; +use SL::Locale; + +die("This script cannot be run from the command line.") unless ($main::form); + +sub mydberror { + my ($msg) = @_; + die($dbup_locale->text("Database update error:") . "
$msg
" . $DBI::errstr); +} + +sub do_query { + my ($query, $may_fail) = @_; + + if (!$dbh->do($query)) { + mydberror($query) unless ($may_fail); + $dbh->rollback(); + $dbh->begin_work(); + } +} + + +sub do_update { + my ($taxkey0_with_taxes_exists) = $dbh->selectrow_array("SELECT COUNT(*) FROM tax WHERE taxkey=0 AND NOT rate=0;"); + + if ($taxkey0_with_taxes_exists > 0){ + print_error_message(); + return 0; + } + + my ($taxkey0_exists) = $dbh->selectrow_array("SELECT COUNT(*) FROM tax WHERE taxkey=0"); + + if ($taxkey0_exists == 0){ + my $insert_taxkey0 = <text("taxkey 0 with taxrate 0 was created."); + }; + + my $insert_taxkeys = <parse_html_template("dbupgrade/taxkey_update"); +}; + +return do_update(); diff --git a/templates/webpages/dbupgrade/taxkey_update.html b/templates/webpages/dbupgrade/taxkey_update.html new file mode 100644 index 000000000..12f1369a7 --- /dev/null +++ b/templates/webpages/dbupgrade/taxkey_update.html @@ -0,0 +1,15 @@ +[%- USE T8 %] +[% USE HTML %]
[% 'taxkey 0 is already allocated.' | $T8 %]
+ +
+ + +

[% 'There is already a taxkey 0 with tax rate not 0.' | $T8 %]

+

[% 'From this version on the taxkey 0 must have a tax rate of 0 (for DATEV compatibility).' | $T8 %]

+

[% 'To continue please change the taxkey 0 to another value.' | $T8 %]

+

[% 'Do not change the tax rate of taxkey 0.' | $T8 %]

+

[% 'During the next update a taxkey 0 with tax rate of 0 will automatically created.' | $T8 %]

+

[% 'Please contact your administrator.' | $T8 %]

+ +
+ -- 2.20.1