Upgrade-Script für Steuerfilterung
authorNiclas Zimmermann <niclas@kivitendo-premium.de>
Mon, 29 Apr 2013 13:10:50 +0000 (15:10 +0200)
committerNiclas Zimmermann <niclas@kivitendo-premium.de>
Thu, 2 May 2013 08:31:05 +0000 (10:31 +0200)
Bei Dialogbuchungen kam es in der Vergangenheit oft zu Verwechslungen
mit Vor-/Umsatzsteuer. Daher werden für jede Steuer nun auch alle
Kontoarten gespeichert, bei denen die Steuer angezeigt werden soll.
Dieser Commit enthält das DB-Update, um die Speicherung möglich zu
machen.

Siehe auch #2249.

locale/de/all
sql/Pg-upgrade2/steuerfilterung.pl [new file with mode: 0644]
templates/webpages/dbupgrade/steuerfilterung.html [new file with mode: 0644]

index 9251877..cce6b2d 100755 (executable)
@@ -931,6 +931,7 @@ $self->{texts} = {
   'Fristsetzung'                => 'Fristsetzung',
   'From'                        => 'Von',
   'From Date'                   => 'Von',
+  'From this version on a new feature is available.' => 'Ab dieser Version ist ein neues Feature verfügbar.',
   'From this version on the partnumber of services, articles and assemblies have to be unique.' => 'Ab dieser Version müssen Artikelnummern eindeutig vergeben werden.',
   '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',
@@ -996,6 +997,7 @@ $self->{texts} = {
   'If the database user listed above does not have the right to create a database then enter the name and password of the superuser below:' => 'Falls der oben genannte Datenbankbenutzer nicht die Berechtigung zum Anlegen neuer Datenbanken hat, so k&ouml;nnen Sie hier den Namen und das Passwort des Datenbankadministratoraccounts angeben:',
   'If you chose to let kivitendo do the migration then kivitendo will also remove the old member file after creating a backup copy of it in the directory &quot;#1&quot;.' => 'Falls Sie sich entscheiden, kivitendo die Migration durchführen zu lassen, so wird kivitendo ein Backup der alten Dateien im Verzeichnis "#1" erstellen und die Dateien anschließend löschen.',
   'If you enter values for the part number and / or part description then only those bins containing parts whose part number or part description match your input will be shown.' => 'Wenn Sie f&uuml;r die Artikelnummer und / oder die Beschreibung etwas eingeben, so werden nur die Lagerpl&auml;tze angezeigt, in denen Waren eingelagert sind, die Ihre Suchbegriffe enthalten.',
+  'If you have not chosen for example the category revenue for a tax and you choose an revenue account to create a transfer in the general ledger, this tax will not be displayed in the tax dropdown.' => 'Wenn Sie z.B. die Kategory Erlös für eine Steuer nicht gewählt haben und ein Erlöskonto beim Erstellen einer Dialogbuchung wählen, wird diese Steuer auch nicht im Dropdown-Menü für die Steuern angezeigt.',
   'If you see this message, you most likely just setup your LX-Office and haven\'t added any entry types. If this is the case, the option is accessible for administrators in the System menu.' => 'Wenn Sie diese Meldung sehen haben Sie wahrscheinlich ein frisches LX-Office Setup und noch keine Buchungsgruppen eingerichtet. Ein Administrator kann dies im Systemmen&uuml; erledigen.',
   'If you select a base unit then you also have to enter a factor.' => 'Wenn Sie eine Basiseinheit auswählen, dann müssen Sie auch einen Faktor eingeben.',
   'If you want to change any of these parameters then press the &quot;Back&quot; button, edit the file &quot;config/kivitendo.conf&quot; and login into the admin module again.' => 'Wenn Sie einen der Parameter &auml;ndern wollen, so dr&uuml;cken Sie auf den &quot;Zur&uuml;ck&quot;-Button, bearbeiten Sie die Datei &quot;config/kivitendo.conf&quot;, und melden Sie sich erneut im Administrationsbereich an.',
@@ -1253,6 +1255,7 @@ $self->{texts} = {
   'New bank account'            => 'Neues Bankkonto',
   'New contact'                 => 'Neue Ansprechperson',
   'New customer'                => 'Neuer Kunde',
+  'New filter for tax accounts' => 'Neue Filter für Steuerkonten',
   'New invoice'                 => 'Neue Rechnung',
   'New part'                    => 'Neue Ware',
   'New sales order'             => 'Neuer Auftrag',
@@ -1446,6 +1449,7 @@ $self->{texts} = {
   'Please Check the bank information for each vendor:' => 'Bitte überprüfen Sie die Kontoinformationen der Lieferanten:',
   'Please ask your administrator to create warehouses and bins.' => 'Bitten Sie Ihren Administrator, dass er Lager und Lagerpl&auml;tze anlegt.',
   'Please change the partnumber of the following parts and run the update again:' => 'Bitte ändern Sie daher die Artikelnumer folgender Artikel:',
+  'Please choose for which categories the taxes should be displayed:' => 'Bitte wählen Sie für welche Kontoarten die Steuer angezeigt werden soll:',
   'Please contact your administrator or a service provider.' => 'Bitte kontaktieren Sie Ihren Administrator oder einen Dienstleister.',
   'Please contact your administrator.' => 'Bitte wenden Sie sich an Ihren Administrator.',
   'Please define a taxkey for the following taxes and run the update again:' => 'Bitte definieren Sie einen Steuerschlüssel für die folgenden Steuern und starten Sie dann das Update erneut:',
@@ -1886,6 +1890,7 @@ $self->{texts} = {
   'Tax deleted!'                => 'Steuer gelöscht!',
   'Tax number'                  => 'Steuernummer',
   'Tax paid'                    => 'Vorsteuer',
+  'Tax rate'                    => 'Steuersatz',
   'Tax saved!'                  => 'Steuer gespeichert!',
   'Tax-O-Matic'                 => 'Steuer',
   'Tax-o-matic Account'         => 'Automatikbuchung auf Konto',
@@ -2123,6 +2128,7 @@ $self->{texts} = {
   'This corresponds to kivitendo\'s behavior prior to version 2.4.4.' => 'Dies entspricht kivitendos Verhalten vor Version 2.4.4.',
   'This could have happened for two reasons:' => 'Dies kann aus zwei Gründen geschehen sein:',
   'This customer number is already in use.' => 'Diese Kundennummer wird bereits verwendet.',
+  'This feature especially prevents mistakes by mixing up prior tax and sales tax.' => 'Dieses Feature vermeidet insbesondere Verwechslungen von Umsatz- und Vorsteuer.',
   'This group will be called &quot;Full Access&quot;.' => 'Diese Gruppe wird &quot;Vollzugriff&quot; genannt.',
   'This installation uses an unknown chart of accounts (&quot;#1&quot;). This database upgrade cannot create standard buchungsgruppen automatically.' => 'Diese Installation benutzt einen unbekannten Kontenrahmen (&quot;#1&quot;). Dieses Datenbankupgrade kann die Standardbuchungsgruppen nicht automatisch anlegen.',
   '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 &Auml;nderungen vorgenommen!',
@@ -2320,6 +2326,7 @@ $self->{texts} = {
   'You are logged out!'         => 'Auf Wiedersehen!',
   'You can also create new units now.' => 'Sie k&ouml;nnen jetzt auch neue Einheiten anlegen.',
   'You can also delete this transaction and re-enter it manually.' => 'Alternativ können Sie die Buchung auch mit löschen lassen und sie anschließend neu eingeben.',
+  'You can choose account categories for taxes. Depending on these categories taxes will be displayed for transfers in the general ledger or not.' => 'Sie können Kontoarten für Steuern auswählen. Abhängig von diesen Kontoarten werden dann Steuern bei Dialogbuchungen angezeigt oder nicht.',
   'You can correct this transaction by chosing the correct taxkeys from the drop down boxes and hitting the button "Fix transaction" afterwards.' => 'Sie haben die Möglichkeit, die Buchung zu korrigieren, indem Sie in den Drop-Down-Boxen die richtigen Steuerschlüssel auswählen und anschließend auf den Button "Buchung korrigieren" drücken.',
   'You can create a missing dataset by going back and chosing &quot;Create Dataset&quot;.' => 'Sie k&ouml;nnen eine fehlende Datenbank erstellen, indem Sie jetzt zu&uuml;ck gehen und den Punkt &quot;Neue Datenbank anlegen&quot; w&auml;hlen.',
   'You can create warehouses and bins via the menu "System -> Warehouses".' => 'Sie k&ouml;nnen Lager und Lagerpl&auml;tze &uuml;ber das Men&uuml; "System -> Lager" anlegen.',
diff --git a/sql/Pg-upgrade2/steuerfilterung.pl b/sql/Pg-upgrade2/steuerfilterung.pl
new file mode 100644 (file)
index 0000000..165a779
--- /dev/null
@@ -0,0 +1,56 @@
+# @tag: steuerfilterung
+# @description: Steuern in Dialogbuchungen filtern.
+# @depends: release_3_0_0
+package SL::DBUpgrade2::steuerfilterung;
+
+use strict;
+use utf8;
+
+use parent qw(SL::DBUpgrade2::Base);
+
+sub run {
+  my ($self) = @_;
+
+  if ( $::form->{'continued'} ) {
+    my $update_query = qq|ALTER TABLE tax ADD chart_categories TEXT|;
+    $self->db_query($update_query);
+    my $categories;
+    my $tax_id;
+    foreach my $i (1 .. $::form->{rowcount}) {
+      $tax_id = $::form->{"tax_id_$i"};
+      $categories = '';
+      $categories .= 'A' if $::form->{"asset_$i"};
+      $categories .= 'L' if $::form->{"liability_$i"};
+      $categories .= 'Q' if $::form->{"equity_$i"};
+      $categories .= 'C' if $::form->{"costs_$i"};
+      $categories .= 'I' if $::form->{"revenue_$i"};
+      $categories .= 'E' if $::form->{"expense_$i"};
+      $update_query = qq|UPDATE tax SET chart_categories = '$categories' WHERE id=$tax_id|;
+      $self->db_query($update_query);
+    }
+    $update_query = qq|ALTER TABLE tax ALTER COLUMN chart_categories SET NOT NULL|;
+    $self->db_query($update_query);
+    $self->dbh->commit();
+    return 1;
+  }
+
+  my $query = qq|SELECT taxkey, taxdescription, rate, id AS tax_id FROM tax order by taxkey, rate|;
+
+  my $sth = $self->dbh->prepare($query);
+  $sth->execute || $::form->dberror($query);
+
+  $::form->{PARTS} = [];
+  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+    $ref->{rate} = $::form->format_amount(\%::myconfig, $::form->round_amount($ref->{rate} * 100));
+    push @{ $::form->{PARTS} }, $ref;
+  }
+
+  &print_message;
+  return 2;
+} # end run
+
+sub print_message {
+  print $::form->parse_html_template("dbupgrade/steuerfilterung");
+}
+
+1;
diff --git a/templates/webpages/dbupgrade/steuerfilterung.html b/templates/webpages/dbupgrade/steuerfilterung.html
new file mode 100644 (file)
index 0000000..da4ebf0
--- /dev/null
@@ -0,0 +1,78 @@
+
+[% USE T8 %]
+[% USE HTML %]
+[% USE L %]
+<div class="listtop">[% 'New filter for tax accounts' | $T8 %]</div>
+
+<form name="Form" method="post" action="login.pl">
+<input type="hidden" name="action" value="login">
+<input type="hidden" name="continued" value="1">
+
+<p>[% 'From this version on a new feature is available.' | $T8 %]</p>
+<p>[% 'You can choose account categories for taxes. Depending on these categories taxes will be displayed for transfers in the general ledger or not.' | $T8 %]</p>
+<p>[% 'If you have not chosen for example the category revenue for a tax and you choose an revenue account to create a transfer in the general ledger, this tax will not be displayed in the tax dropdown.' | $T8 %]</p>
+<p>[% 'This feature especially prevents mistakes by mixing up prior tax and sales tax.' | $T8 %]</p>
+<p>[% 'Please choose for which categories the taxes should be displayed:' | $T8 %]</p>
+<table>
+  <tr>
+    <th class="listheading">[% 'Taxkey' | $T8 %]</th>
+    <th class="listheading">[% 'Description' | $T8 %]</th>
+    <th class="listheading">[% 'Tax rate' | $T8 %]</th>
+    <th class="listheading">[% 'Asset' | $T8 %] (A)</th>
+    <th class="listheading">[% 'Liability' | $T8 %] (L)</th>
+    <th class="listheading">[% 'Equity' | $T8 %] (Q)</th>
+    <th class="listheading">[% 'Costs' | $T8 %] (C)</th>
+    <th class="listheading">[% 'Revenue' | $T8 %] (I)</th>
+    <th class="listheading">[% 'Expense' | $T8 %] (E)</th>
+  </tr>
+
+  [% SET row_odd = '1' %][% FOREACH row = PARTS %]
+  <tr class="listrow[% IF row_odd %]1[% SET row_odd = '0' %][% ELSE %]0[% SET row_odd = '1' %][% END %]">
+    <td align="right">[% HTML.escape(row.taxkey) %]</td>
+    <td align="left"> [% HTML.escape(row.taxdescription) %]</a></td>
+    <td align="right">[% HTML.escape(row.rate) %] %</td>
+    <td align="center">[% IF row.taxkey == 0 or row.taxkey == 1 %]
+                     [% L.checkbox_tag('asset_' _ loop.count, value => 1, checked => 1, class => 'checkbox') %]
+                     [% ELSE %]
+                     [% L.checkbox_tag('asset_' _ loop.count, value => 1, checked => 0, class => 'checkbox') %]
+                     [% END %]</td>
+
+    <td align="center">[% IF row.taxkey == 0 or row.taxkey == 1 %]
+                     [% L.checkbox_tag('liability_' _ loop.count, value => 1, checked => 1, class => 'checkbox') %]
+                     [% ELSE %]
+                     [% L.checkbox_tag('liability_' _ loop.count, value => 1, checked => 0, class => 'checkbox') %]
+                     [% END %]</td>
+
+    <td align="center">[% IF row.taxkey == 0 or row.taxkey == 1 %]
+                     [% L.checkbox_tag('equity_' _ loop.count, value => 1, checked => 1, class => 'checkbox') %]
+                     [% ELSE %]
+                     [% L.checkbox_tag('equity_' _ loop.count, value => 1, checked => 0, class => 'checkbox') %]
+                     [% END %]</td>
+
+    <td align="center">[% IF row.taxkey == 0 or row.taxkey == 1 %]
+                     [% L.checkbox_tag('costs_' _ loop.count, value => 1, checked => 1, class => 'checkbox') %]
+                     [% ELSE %]
+                     [% L.checkbox_tag('costs_' _ loop.count, value => 1, checked => 0, class => 'checkbox') %]
+                     [% END %]</td>
+
+    <td align="center">[% IF row.taxkey == 8 or row.taxkey == 9 or row.taxkey == 18 or row.taxkey == 19%]
+                     [% L.checkbox_tag('revenue_' _ loop.count, value => 1, checked => 0, class => 'checkbox') %]
+                     [% ELSE %]
+                     [% L.checkbox_tag('revenue_' _ loop.count, value => 1, checked => 1, class => 'checkbox') %]
+                     [% END %]</td>
+
+    <td align="center">[% IF row.taxkey == 2 or row.taxkey == 3 or row.taxkey == 10 or row.taxkey == 11 or row.taxkey == 12 or row.taxkey == 13 %]
+                     [% L.checkbox_tag('expense_' _ loop.count, value => 1, checked => 0, class => 'checkbox') %]
+                     [% ELSE %]
+                     [% L.checkbox_tag('expense_' _ loop.count, value => 1, checked => 1, class => 'checkbox') %]
+                     [% END %]</td>
+  </tr>
+  <input type="hidden" name="tax_id_[% loop.count %]" value="[% row.tax_id %]">
+  [% SET rowcount = loop.count %]
+  [% END %]
+  <input type="hidden" name="rowcount" value="[% rowcount %]">
+</table>
+
+<input type="submit" value="[% 'Continue' | $T8 %]">
+
+</form>