From 9df5bd727acd137e086ee3bf5020868224797a71 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 4 Dec 2006 16:06:34 +0000 Subject: [PATCH] Datenbankupgrade: Standardbuchungsgruppen mit 16% und 7% fuer SKR03 und SKR04 anlegen. --- locale/de/Pg-upgrade-2.2.0.25-2.2.0.26 | 2 +- locale/de/Pg-upgrade-2.2.0.27-2.2.0.28 | 2 +- locale/de/Pg-upgrade-2.2.0.28-2.2.0.29 | 13 ++ locale/de/all | 2 +- .../Pg-upgrade-2.2.0.28-2.2.0.29.pl | 206 ++++++++++++++++++ .../std_buchungsgruppen_unknown_coa_de.html | 23 ++ ...td_buchungsgruppen_unknown_coa_master.html | 25 +++ 7 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 locale/de/Pg-upgrade-2.2.0.28-2.2.0.29 create mode 100644 sql/Pg-upgrade/Pg-upgrade-2.2.0.28-2.2.0.29.pl create mode 100644 templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_de.html create mode 100644 templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_master.html diff --git a/locale/de/Pg-upgrade-2.2.0.25-2.2.0.26 b/locale/de/Pg-upgrade-2.2.0.25-2.2.0.26 index 885311336..71899dc6f 100644 --- a/locale/de/Pg-upgrade-2.2.0.25-2.2.0.26 +++ b/locale/de/Pg-upgrade-2.2.0.25-2.2.0.26 @@ -1,6 +1,6 @@ $self{texts} = { 'A unit with this name does already exist.' => 'Eine Einheit mit diesem Namen existiert bereits.', - 'Database update error:' => 'Database update error:', + 'Database update error:' => 'Fehler beim Datenbankupgrade:', 'The base unit does not exist.' => 'Die Basiseinheit existiert nicht.', 'The factor is missing.' => 'Der Faktor fehlt.', 'The name is missing.' => 'Der Name fehlt.', diff --git a/locale/de/Pg-upgrade-2.2.0.27-2.2.0.28 b/locale/de/Pg-upgrade-2.2.0.27-2.2.0.28 index 4375fec51..2b678236c 100644 --- a/locale/de/Pg-upgrade-2.2.0.27-2.2.0.28 +++ b/locale/de/Pg-upgrade-2.2.0.27-2.2.0.28 @@ -1,5 +1,5 @@ $self{texts} = { - 'Database update error:' => 'Database update error:', + 'Database update error:' => 'Fehler beim Datenbankupgrade:', }; $self{subs} = { diff --git a/locale/de/Pg-upgrade-2.2.0.28-2.2.0.29 b/locale/de/Pg-upgrade-2.2.0.28-2.2.0.29 new file mode 100644 index 000000000..0d2074d8c --- /dev/null +++ b/locale/de/Pg-upgrade-2.2.0.28-2.2.0.29 @@ -0,0 +1,13 @@ +$self{texts} = { + 'Database update error:' => 'Fehler beim Datenbankupgrade:', +}; + +$self{subs} = { + 'create_standard_buchungsgruppen' => 'create_standard_buchungsgruppen', + 'create_standard_buchungsgruppen_skr03' => 'create_standard_buchungsgruppen_skr03', + 'create_standard_buchungsgruppen_skr04' => 'create_standard_buchungsgruppen_skr04', + 'mydberror' => 'mydberror', + 'myshowerror' => 'myshowerror', +}; + +1; diff --git a/locale/de/all b/locale/de/all index 0029a37f1..1650d6e1d 100644 --- a/locale/de/all +++ b/locale/de/all @@ -284,7 +284,7 @@ aktualisieren wollen?', 'Database Driver not checked!' => 'Kein Datenbanktreiber ausgewählt!', 'Database Host' => 'Datenbankcomputer', 'Database User missing!' => 'Datenbankbenutzer fehlt!', - 'Database update error:' => '', + 'Database update error:' => 'Fehler beim Datenbankupgrade:', 'Dataset' => 'Datenbank', 'Dataset missing!' => 'Datenbank fehlt!', 'Dataset updated!' => 'Datenbank erneuert!', diff --git a/sql/Pg-upgrade/Pg-upgrade-2.2.0.28-2.2.0.29.pl b/sql/Pg-upgrade/Pg-upgrade-2.2.0.28-2.2.0.29.pl new file mode 100644 index 000000000..209a6168a --- /dev/null +++ b/sql/Pg-upgrade/Pg-upgrade-2.2.0.28-2.2.0.29.pl @@ -0,0 +1,206 @@ +#!/usr/bin/perl + +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 myshowerror { + my ($msg) = @_; + + print($main::form->parse_html_template("dbupgrade/units_error", + { "message" => $msg })); + return 2; +} + +sub create_standard_buchungsgruppen_skr03 { + my $query; + + $query = "SELECT COUNT(*) FROM buchungsgruppen " . + "WHERE description = 'Standard 16%'"; + my ($count) = $dbh->selectrow_array($query); + + if (!$count) { + $query = + "INSERT INTO buchungsgruppen " . + "(description, inventory_accno_id, " . + " income_accno_id_0, expense_accno_id_0, " . + " income_accno_id_1, expense_accno_id_1, " . + " income_accno_id_2, expense_accno_id_2, " . + " income_accno_id_3, expense_accno_id_3) " . + "VALUES " . + "('Standard 16%', " . + ($main::eur ? + "(SELECT id FROM chart WHERE link = 'IC' " . + " ORDER BY id ASC LIMIT 1), " + : + # 3980: Bestand Waren + " (SELECT id FROM chart WHERE accno = '3980'), ") . + # 8400: Erlöse 16% USt. + # 3400: Wareneingang 16% Vorsteuer + " (SELECT id FROM chart WHERE accno = '8400'), " . + " (SELECT id FROM chart WHERE accno = '3400'), " . + # 8125: Steuerfrei innergem. Lieferungen §41bUStG + # 3550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '8125'), " . + " (SELECT id FROM chart WHERE accno = '3550'), " . + # 8400: Erlöse 16% USt. + # 3400: Wareneingang 16% Vorsteuer + " (SELECT id FROM chart WHERE accno = '8400'), " . + " (SELECT id FROM chart WHERE accno = '3400'), " . + # 8120: Steuerfreie Umsätze §4Nr.1a UstG + # 3550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '8120'), " . + " (SELECT id FROM chart WHERE accno = '3550'))"; + $dbh->do($query) || mydberror($query); + } + + $query = "SELECT COUNT(*) FROM buchungsgruppen " . + "WHERE description = 'Standard 7%'"; + my ($count) = $dbh->selectrow_array($query); + + if (!$count) { + $query = + "INSERT INTO buchungsgruppen " . + "(description, inventory_accno_id, " . + " income_accno_id_0, expense_accno_id_0, " . + " income_accno_id_1, expense_accno_id_1, " . + " income_accno_id_2, expense_accno_id_2, " . + " income_accno_id_3, expense_accno_id_3) " . + "VALUES " . + "('Standard 7%', " . + ($main::eur ? + "(SELECT id FROM chart WHERE link = 'IC' " . + " ORDER BY id ASC LIMIT 1), " + : + # 3980: Bestand Waren + " (SELECT id FROM chart WHERE accno = '3980'), ") . + # 8300: Erlöse 7% USt. + # 3300: Wareneingang 7% Vorsteuer + " (SELECT id FROM chart WHERE accno = '8300'), " . + " (SELECT id FROM chart WHERE accno = '3300'), " . + # 8125: Steuerfrei innergem. Lieferungen §41bUStG + # 3550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '8125'), " . + " (SELECT id FROM chart WHERE accno = '3550'), " . + # 8300: Erlöse 7% USt. + # 3420: Innergemein.Erwerb 7% VorSt u. Ust + " (SELECT id FROM chart WHERE accno = '8300'), " . + " (SELECT id FROM chart WHERE accno = '3420'), " . + # 8120: Steuerfreie Umsätze §4Nr.1a UstG + # 3300: Wareneingang 7% Vorsteuer + " (SELECT id FROM chart WHERE accno = '8120'), " . + " (SELECT id FROM chart WHERE accno = '3300'))"; + $dbh->do($query) || mydberror($query); + } + + return 1; +} + +sub create_standard_buchungsgruppen_skr04 { + my $query; + + $query = "SELECT COUNT(*) FROM buchungsgruppen " . + "WHERE description = 'Standard 16%'"; + my ($count) = $dbh->selectrow_array($query); + + if (!$count) { + $query = + "INSERT INTO buchungsgruppen " . + "(description, inventory_accno_id, " . + " income_accno_id_0, expense_accno_id_0, " . + " income_accno_id_1, expense_accno_id_1, " . + " income_accno_id_2, expense_accno_id_2, " . + " income_accno_id_3, expense_accno_id_3) " . + "VALUES " . + "('Standard 16%', " . + ($main::eur ? + "(SELECT id FROM chart WHERE link = 'IC' " . + " ORDER BY id ASC LIMIT 1), " + : + # 1140: Bestand Waren + " (SELECT id FROM chart WHERE accno = '1140'), ") . + # 4400: Erlöse 16% USt. + # 5400: Wareneingang 16% Vorsteuer + " (SELECT id FROM chart WHERE accno = '4400'), " . + " (SELECT id FROM chart WHERE accno = '5400'), " . + # 4125: Steuerfrei innergem. Lieferungen §41bUStG + # 5550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '4125'), " . + " (SELECT id FROM chart WHERE accno = '5550'), " . + # 4315: Erlös Inland stpfl.EG-Lieferung 16% + # 5425: Innergem.Erwerb 16% VorSt u. Ust + " (SELECT id FROM chart WHERE accno = '4315'), " . + " (SELECT id FROM chart WHERE accno = '5425'), " . + # 4150: Sonstige steuerfreie Umsätze §42-7UStG + # 5550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '4150'), " . + " (SELECT id FROM chart WHERE accno = '5550'))"; + $dbh->do($query) || mydberror($query); + } + + $query = "SELECT COUNT(*) FROM buchungsgruppen " . + "WHERE description = 'Standard 7%'"; + my ($count) = $dbh->selectrow_array($query); + + if (!$count) { + $query = + "INSERT INTO buchungsgruppen " . + "(description, inventory_accno_id, " . + " income_accno_id_0, expense_accno_id_0, " . + " income_accno_id_1, expense_accno_id_1, " . + " income_accno_id_2, expense_accno_id_2, " . + " income_accno_id_3, expense_accno_id_3) " . + "VALUES " . + "('Standard 7%', " . + ($main::eur ? + "(SELECT id FROM chart WHERE link = 'IC' " . + " ORDER BY id ASC LIMIT 1), " + : + # 1140: Bestand Waren + " (SELECT id FROM chart WHERE accno = '1140'), ") . + # 4300: Erlöse 7%USt + # 5300: Wareneingang 7% Vorsteuer + " (SELECT id FROM chart WHERE accno = '4300'), " . + " (SELECT id FROM chart WHERE accno = '5300'), " . + # 4125: Steuerfrei innergem. Lieferungen §41bUStG + # 5550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '4125'), " . + " (SELECT id FROM chart WHERE accno = '5550'), " . + # 4310: Erlöse Inland stpfl. EG-Lieferung7% + # 5420: Innergemein.Erwerb 7% VorSt u. Ust + " (SELECT id FROM chart WHERE accno = '4310'), " . + " (SELECT id FROM chart WHERE accno = '5420'), " . + # 4150: Sonstige steuerfreie Umsätze §42-7UStG + # 5550: Steuerfreier innergem.Erwerb + " (SELECT id FROM chart WHERE accno = '4150'), " . + " (SELECT id FROM chart WHERE accno = '5550'))"; + $dbh->do($query) || mydberror($query); + } + + return 1; +} + +sub create_standard_buchungsgruppen { + my $form = $main::form; + + my $query = "SELECT coa FROM defaults"; + my ($coa) = $dbh->selectrow_array($query); + + if ($coa eq "Germany-DATEV-SKR03EU") { + return create_standard_buchungsgruppen_skr03(); + } elsif ($coa eq "Germany-DATEV-SKR04EU") { + return create_standard_buchungsgruppen_skr04(); + } + + print($form->parse_html_template("dbupgrade/" . + "std_buchungsgruppen_unknown_coa", + { "coa" => $coa })); + + return 1; +} + +return create_standard_buchungsgruppen(); diff --git a/templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_de.html b/templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_de.html new file mode 100644 index 000000000..9924d54d1 --- /dev/null +++ b/templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_de.html @@ -0,0 +1,23 @@ +
Unbekannter Kontenrahmen
+ +
+ + + + + + + + +

+
+ +

+ Hinweis: + Diese Installation benutzt einen unbekannten Kontenrahmen (""). Dieses Datenbankupgrade kann die Standardbuchungsgruppen nicht automatisch anlegen. +

+ +
+ +
+ diff --git a/templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_master.html b/templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_master.html new file mode 100644 index 000000000..ea13345f7 --- /dev/null +++ b/templates/webpages/dbupgrade/std_buchungsgruppen_unknown_coa_master.html @@ -0,0 +1,25 @@ +
Unknown chart of accounts
+ +
+ + + + + + + + +

+
+ +

+ Note: + This installation uses an unknown chart of accounts + (""). This database upgrade + cannot create standard buchungsgruppen automatically. +

+ +
+ +
+ -- 2.20.1