From: Moritz Bunkus
Date: Wed, 13 Dec 2006 12:02:02 +0000 (+0000)
Subject: Datenbankupgrade Buchungsgruppen: Erzeugnisse in einem eigenen Schritt behandeln.
X-Git-Tag: release-2.4.0^2~50
X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a56a4d79bc4045223b864ce75ab5ab611ab6c70b;p=kivitendo-erp.git
Datenbankupgrade Buchungsgruppen: Erzeugnisse in einem eigenen Schritt behandeln.
---
diff --git a/locale/de/Pg-upgrade-2.2.0.33-2.2.0.34 b/locale/de/Pg-upgrade-2.2.0.33-2.2.0.34
index 231c31942..57ecbbb6d 100644
--- a/locale/de/Pg-upgrade-2.2.0.33-2.2.0.34
+++ b/locale/de/Pg-upgrade-2.2.0.33-2.2.0.34
@@ -3,6 +3,7 @@ $self->{texts} = {
};
$self->{subs} = {
+ 'assign_buchungsgruppen_for_assemblies' => 'assign_buchungsgruppen_for_assemblies',
'create_buchungsgruppen' => 'create_buchungsgruppen',
'display_create_bgs_dialog' => 'display_create_bgs_dialog',
'do_update' => 'do_update',
@@ -16,6 +17,7 @@ $self->{subs} = {
'set_ic_links' => 'set_ic_links',
'set_taxzone_ids' => 'set_taxzone_ids',
'update_known_buchungsgruppen' => 'update_known_buchungsgruppen',
+ 'buchungsgruppe_erfassen' => 'create_buchungsgruppen',
};
1;
diff --git a/locale/de/all b/locale/de/all
index 0ba13d724..12ae26978 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -246,6 +246,7 @@ aktualisieren wollen?',
'Could not transfer Inventory!' => 'Konnte Waren nicht umlagern!',
'Could not update prices!' => 'Preise konnten nicht aktualisiert werden!',
'Country' => 'Land',
+ 'Create Buchungsgruppen' => 'Buchungsgruppe erfassen',
'Create Chart of Accounts' => 'Kontenplan anlegen',
'Create Dataset' => 'Datenbank anlegen',
'Credit' => 'Haben',
@@ -352,6 +353,8 @@ gestartet',
'E-mailed' => 'eMail gesendet.',
'ELSTER Export nach Winston' => 'ELSTER Export nach Winston',
'ELSTER-Steuernummer: ' => 'ELSTER-Steuernummer: ',
+ 'EU with VAT ID' => 'EU mit UstId-Nummer',
+ 'EU without VAT ID' => 'EU ohne UstId-Nummer',
'EUER' => 'Einnahmen-/Überschussrechnung',
'EUR' => 'E/Ü-Rechnung',
'Edit' => 'Bearbeiten',
@@ -413,9 +416,11 @@ gestartet',
'Exchangerate Difference' => 'Wechselkursunterschied',
'Exchangerate for payment missing!' => 'Es fehlt der Wechselkurs für die Bezahlung!',
'Exchangerate missing!' => 'Es fehlt der Wechselkurs!',
+ 'Existing Buchungsgruppen' => 'Existierende Buchungsgruppen',
'Existing Datasets' => 'existierende Datenbanken',
'Expense' => 'Aufwandskonto',
'Expense Account' => 'Aufwandskonto',
+ 'Expense accno' => 'Aufwandskonto',
'Expense/Asset' => 'Aufwand/Anlagen',
'Expired licenses' => 'Abgelaufene Lizenzen',
'Expiring in x month(s)' => 'Die in x Monat(en) ablaufen',
@@ -484,6 +489,7 @@ gestartet',
'Include in Report' => 'In Bericht aufnehmen',
'Include in drop-down menus' => 'In Aufklappmenü aufnehmen',
'Income Statement' => 'GuV',
+ 'Income accno' => 'Erlöskonto',
'Incoming Payments' => 'Zahlungseingänge',
'Incorrect Password!' => 'Ungültiges Passwort!',
'Incorrect username or password!' => 'Ungültiger Benutzername oder falsches Passwort!',
@@ -493,6 +499,7 @@ gestartet',
'Input Number Format' => 'Zahlenformat (Eingabe)',
'Interest Rate' => 'Zinssatz',
'Internal Notes' => 'interne Bemerkungen',
+ 'International' => 'Ausland',
'Internet' => 'Internet',
'Introduction of Buchungsgruppen' => 'Einführung von Buchungsgruppen',
'Introduction of units' => 'Einführung von Einheiten',
@@ -505,6 +512,7 @@ gestartet',
'Inventory quantity must be zero before you can set this part obsolete!' => 'Bevor diese Ware als ungültig markiert werden kann, muà das Inventar Null sein!',
'Inventory saved!' => 'Inventar gespeichert.',
'Inventory transferred!' => 'Inventar umgelagert.',
+ 'Invetory' => 'Inventar',
'Invno.' => '',
'Invnumber' => 'Rechnungsnummer',
'Invoice' => 'Rechnung',
@@ -619,7 +627,9 @@ gestartet',
'N/A' => 'N.Z.',
'Name' => 'Name',
'Name missing!' => 'Name fehlt!',
+ 'National' => 'Inand',
'Netto Terms' => 'Zahlungsziel netto',
+ 'New Buchungsgruppe ' => 'Neue Buchungsgruppe ',
'New Templates' => 'neue Vorlagen',
'New unit' => 'Neue Einheit',
'Next Dunning Level' => 'Nächste Mahnstufe',
@@ -887,6 +897,7 @@ gestartet',
'Statements sent to printer!' => 'Sammelrechnungen an Drucker geschickt!',
'Step 1 of 3: Parts' => 'Schritt 1 von 3: Waren',
'Step 2 of 3: Services' => 'Schritt 2 von 3: Dienstleistungen',
+ 'Step 3 of 3: Assemblies' => 'Schritt 3 von 3: Erzeugnisse',
'Step 3 of 3: Default units' => 'Schritt 3 von 3: Standardeinheiten',
'Steuerberater/-in' => 'Steuerberater/-in',
'Steuernummer' => 'Steuernummer',
@@ -933,6 +944,7 @@ gestartet',
'The database upgrade for the introduction of units is now complete.' => 'Das Datenbankupgrade zwecks Einführung von Einheiten ist nun beendet.',
'The factor is missing in row %d.' => 'Der Faktor fehlt in Zeile %d.',
'The factor is missing.' => 'Der Faktor fehlt.',
+ 'The following Buchungsgruppen have already been created:' => 'Die folgenden Buchungsgruppen wurden bereits angelegt:',
'The following Datasets are not in use and can be deleted' => 'Die folgenden Datenbanken sind nicht in Verwendung und können gelöscht werden',
'The following Datasets need to be updated' => 'Folgende Datenbanken müssen aktualisiert werden',
'The following units are unknown.' => 'Die folgenden Einheiten sind unbekannt.',
@@ -949,6 +961,7 @@ gestartet',
'The units have been saved.' => 'Die Einheiten wurden gespeichert.',
'There are four tax zones.' => 'Es gibt vier Steuerzonen.',
'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 is nothing to do in this step.' => 'In diesem Schritt gibt es nichts mehr zu tun.',
'Therefore there\'s no need to create the same article more than once if it is sold or bought in/from another tax zone.' => 'Deswegen muss man den gleichen Artikel nicht mehr mehrmals anlegen, wenn er in verschiedenen Steuerzonen gehandelt werden soll.',
'These units can be based on other units so that Lx-Office can convert prices when the user switches from one unit to another.' => 'Diese Einheiten können auf anderen Einheiten basieren, sodass Lx-Office Preise umrechnen kann, wenn der Benutzer von einer Einheit zu einer anderen Wechselt.',
'This is a preliminary check for existing sources. Nothing will be created or deleted at this stage!' => 'In diesem Schritt werden bestehende Datenbanken gesucht. Es werden noch keine Änderungen vorgenommen!',
diff --git a/sql/Pg-upgrade/Pg-upgrade-2.2.0.33-2.2.0.34.pl b/sql/Pg-upgrade/Pg-upgrade-2.2.0.33-2.2.0.34.pl
index 2b0765f9c..cc4780e1f 100644
--- a/sql/Pg-upgrade/Pg-upgrade-2.2.0.33-2.2.0.34.pl
+++ b/sql/Pg-upgrade/Pg-upgrade-2.2.0.33-2.2.0.34.pl
@@ -1,5 +1,7 @@
#!/usr/bin/perl
+# Datenbankupgrade: Einfuehrung von Buchungsgruppen
+
die("This script cannot be run from the command line.") unless ($main::form);
sub mydberror {
@@ -52,13 +54,18 @@ sub set_ic_links {
sub force_inventory_accno_id_for_parts {
my $query =
- "UPDATE parts SET inventory_accno_id = " .
- "(SELECT bg.inventory_accno_id " .
- " FROM buchungsgruppen bg " .
- " WHERE bg.description = 'Standard 16%') " .
- "WHERE (NOT inventory_accno_id ISNULL) AND (inventory_accno_id > 0)";
+ "SELECT inventory_accno_id " .
+ "FROM buchungsgruppen " .
+ "WHERE description = 'Standard 16%'";
+
+ my ($bg_id) = $dbh->selectrow_array($query);
- $dbh->do($query) || mydberror($query);
+ if ($bg_id) {
+ $query =
+ "UPDATE parts SET inventory_accno_id = $bg_id " .
+ "WHERE (NOT inventory_accno_id ISNULL) AND (inventory_accno_id > 0)";
+ $dbh->do($query) || mydberror($query);
+ }
}
sub retrieve_accounts {
@@ -150,7 +157,7 @@ sub update_known_buchungsgruppen {
my $query =
"SELECT id, inventory_accno_id, income_accno_id, expense_accno_id " .
"FROM parts " .
- "WHERE NOT inventory_accno_id ISNULL AND (inventory_accno_id > 0)";
+ "WHERE NOT inventory_accno_id ISNULL AND (inventory_accno_id > 0) ";
my $sth = $dbh->prepare($query);
$sth->execute() || mydberror($query);
@@ -178,7 +185,8 @@ sub update_known_buchungsgruppen {
my $query =
"SELECT id, inventory_accno_id, income_accno_id, expense_accno_id " .
"FROM parts " .
- "WHERE inventory_accno_id ISNULL OR (inventory_accno_id = 0)";
+ "WHERE (inventory_accno_id ISNULL OR (inventory_accno_id = 0)) AND " .
+ " NOT assembly";
my $sth = $dbh->prepare($query);
$sth->execute() || mydberror($query);
@@ -201,7 +209,7 @@ sub update_known_buchungsgruppen {
sub retrieve_unknown_accno_combinations {
my ($buchungsgruppen) = @_;
- my (@parts, @services, $sth, $query, $ref);
+ my (@parts, @services, @assemblies, $sth, $query, $ref);
$query =
"SELECT DISTINCT " .
@@ -240,10 +248,10 @@ sub retrieve_unknown_accno_combinations {
"c2.accno AS income_accno, c2.description AS income_description, " .
"c3.accno AS expense_accno, c3.description AS expense_description " .
"FROM parts p " .
- "LEFT JOIN chart c1 ON p.inventory_accno_id = c1.id " .
"LEFT JOIN chart c2 ON p.income_accno_id = c2.id " .
"LEFT JOIN chart c3 ON p.expense_accno_id = c3.id " .
- "WHERE inventory_accno_id ISNULL OR (inventory_accno_id = 0)";
+ "WHERE (inventory_accno_id ISNULL OR (inventory_accno_id = 0)) AND " .
+ " NOT assembly";
$sth = $dbh->prepare($query);
$sth->execute() || mydberror($query);
@@ -263,7 +271,23 @@ sub retrieve_unknown_accno_combinations {
}
$sth->finish();
- return (\@parts, \@services);
+ $query =
+ "SELECT DISTINCT " .
+ "p.income_accno_id, " .
+ "c.accno AS income_accno, c.description AS income_description " .
+ "FROM parts p " .
+ "LEFT JOIN chart c ON p.income_accno_id = c.id " .
+ "WHERE p.assembly AND " .
+ " (p.buchungsgruppen_id ISNULL OR (p.buchungsgruppen_id = 0))";
+
+ $sth = $dbh->prepare($query);
+ $sth->execute() || mydberror($query);
+
+ while ($ref = $sth->fetchrow_hashref()) {
+ push(@assemblies, $ref);
+ }
+
+ return (\@parts, \@services, \@assemblies);
}
sub display_create_bgs_dialog {
@@ -278,6 +302,10 @@ sub display_create_bgs_dialog {
$entry->{"eur"} = $main::eur;
}
+ # $form->parse_html_template("dbupgrade/buchungsgruppen_parts")
+ # $form->parse_html_template("dbupgrade/buchungsgruppen_services")
+ # $form->parse_html_template("dbupgrade/buchungsgruppen_assemblies")
+
print($form->parse_html_template("dbupgrade/buchungsgruppen_${type}",
{ "LIST" => $list,
"BUCHUNGSGRUPPEN" => $buchungsgruppen,
@@ -299,15 +327,17 @@ sub create_buchungsgruppen {
$form->{"income_accno_id_3_$i"} &&
$form->{"expense_accno_id_3_$i"});
- my $query =
+ my $query = "SELECT nextval('id')";
+ my ($id) = $dbh->selectrow_array($query);
+ $query =
"INSERT INTO buchungsgruppen (" .
- "description, inventory_accno_id, " .
+ "id, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- my @values = ($form->{"description_$i"});
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ my @values = ($id, $form->{"description_$i"});
foreach my $acc (qw(inventory_accno_id
income_accno_id_0 expense_accno_id_0
@@ -318,8 +348,36 @@ sub create_buchungsgruppen {
}
mydoquery($query, @values);
+
+ $form->{"new_buchungsgruppen_id_$i"} = $id;
+ }
+
+ $dbh->commit();
+ $dbh->begin_work();
+}
+
+sub assign_buchungsgruppen_for_assemblies {
+ my ($query, $sth, $i);
+
+ $query =
+ "UPDATE parts " .
+ "SET buchungsgruppen_id = ? " .
+ "WHERE assembly AND " .
+ "(buchungsgruppen_id ISNULL OR (buchungsgruppen_id = 0)) AND " .
+ "(income_accno_id = ?)";
+ $sth = $dbh->prepare($query);
+
+ for ($i = 1; $i <= $form->{"rowcount"}; $i++) {
+ next unless ($form->{"new_buchungsgruppen_id_$i"});
+
+ my @values = ($form->{"new_buchungsgruppen_id_$i"},
+ $form->{"income_accno_id_0_$i"});
+ $sth->execute(@values) ||
+ mydberror($query . " (" . join(", ", @values) . ")");
}
+ $sth->finish();
+
$dbh->commit();
$dbh->begin_work();
}
@@ -359,6 +417,8 @@ sub retrieve_std_inventory_accno_id {
$sth->finish();
}
+ $inventory_accno_id = 1 unless ($inventory_accno_id);
+
$form->{"std_inventory_accno_id"} = $inventory_accno_id;
}
@@ -367,6 +427,11 @@ sub do_update {
create_buchungsgruppen();
}
+ if ($main::form->{"action2"} eq "create_buchungsgruppen_assemblies") {
+ create_buchungsgruppen();
+ assign_buchungsgruppen_for_assemblies();
+ }
+
retrieve_std_inventory_accno_id();
# Set all taxzone_id columns = 0.
@@ -389,7 +454,8 @@ sub do_update {
# Retrieve all distinct combinations of inventory_accno_id,
# income_accno_id and expense_accno_id for which there's no
# Buchungsgruppe. Then let the user create new ones.
- ($parts, $services) = retrieve_unknown_accno_combinations($buchungsgruppen);
+ ($parts, $services, $assemblies) =
+ retrieve_unknown_accno_combinations($buchungsgruppen);
my ($acc_inventory, $acc_income, $acc_expense) = retrieve_accounts();
@@ -400,6 +466,8 @@ sub do_update {
$acc_inventory, $acc_income, $acc_expense,
$buchungsgruppen);
return 2;
+ } else {
+ print($form->parse_html_template("dbupgrade/buchungsgruppen_parts_done"));
}
if (scalar(@{$services})) {
@@ -407,6 +475,17 @@ sub do_update {
$acc_inventory, $acc_income, $acc_expense,
$buchungsgruppen);
return 2;
+ } else {
+ print($form->parse_html_template("dbupgrade/buchungsgruppen_services_done"));
+ }
+
+ if (scalar(@{$assemblies})) {
+ display_create_bgs_dialog("assemblies", $assemblies,
+ $acc_inventory, $acc_income, $acc_expense,
+ $buchungsgruppen);
+ return 2;
+ } else {
+ print($form->parse_html_template("dbupgrade/buchungsgruppen_assemblies_done"));
}
print($form->parse_html_template("dbupgrade/buchungsgruppen_footer"));
diff --git a/templates/webpages/dbupgrade/buchungsgruppen_assemblies_de.html b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_de.html
new file mode 100644
index 000000000..daf9821ea
--- /dev/null
+++ b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_de.html
@@ -0,0 +1,146 @@
+Schritt 3 von 3: Erzeugnisse
+
+
+
+
+ Neue Buchungsgruppe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/webpages/dbupgrade/buchungsgruppen_assemblies_done_de.html b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_done_de.html
new file mode 100644
index 000000000..088d233ae
--- /dev/null
+++ b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_done_de.html
@@ -0,0 +1,3 @@
+Schritt 3 von 3: Erzeugnisse
+
+In diesem Schritt gibt es nichts mehr zu tun.
diff --git a/templates/webpages/dbupgrade/buchungsgruppen_assemblies_done_master.html b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_done_master.html
new file mode 100644
index 000000000..26af74eff
--- /dev/null
+++ b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_done_master.html
@@ -0,0 +1,3 @@
+Step 3 of 3: Assemblies
+
+There is nothing to do in this step.
diff --git a/templates/webpages/dbupgrade/buchungsgruppen_assemblies_master.html b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_master.html
new file mode 100644
index 000000000..7381b93fb
--- /dev/null
+++ b/templates/webpages/dbupgrade/buchungsgruppen_assemblies_master.html
@@ -0,0 +1,146 @@
+Step 3 of 3: Assemblies
+
+
+
diff --git a/templates/webpages/dbupgrade/buchungsgruppen_parts_de.html b/templates/webpages/dbupgrade/buchungsgruppen_parts_de.html
index 9c2185b59..452047e3b 100644
--- a/templates/webpages/dbupgrade/buchungsgruppen_parts_de.html
+++ b/templates/webpages/dbupgrade/buchungsgruppen_parts_de.html
@@ -1,4 +1,4 @@
-Schritt 1 von 2: Waren
+Schritt 1 von 3: Waren