From 1672583af0518aaa1b73d3fb0a7e4a07d5329ffc Mon Sep 17 00:00:00 2001 From: Niclas Zimmermann Date: Thu, 21 Feb 2013 11:58:38 +0100 Subject: [PATCH] Steuern festsetzen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Dieser Commit macht Steuern unveränderbar, wenn mit diesen schon gebucht wurde, d.h. ein Eintrag in der acc_trans steht. Man kann nur noch Namen und Automatikkonten verändern. Weiterhin findet eine Prüfung statt, ob Steuerschlüssel 0 ohne Steuern gespeichert wird. Die Abfrage isblank war leider fehlerhaft und wurde ebenfalls ersetzt. Bisher lieferte kivitendo auch Fehler, wenn man Namen von Konten mit Steuerschlüssel 0 ändert. Das sollte nicht so sein. --- SL/AM.pm | 4 +++- bin/mozilla/am.pl | 14 +++++++++++--- locale/de/all | 1 + locale/en/all | 1 + templates/webpages/am/edit_tax.html | 6 +++--- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index c7a88d2df..5645c4dd7 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1779,7 +1779,9 @@ sub get_tax { taxkey, taxdescription, round(rate * 100, 2) AS rate, - chart_id + chart_id, + (id IN (SELECT tax_id + FROM acc_trans)) AS tax_already_used FROM tax WHERE id = ? |; diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 2b7cdf8ee..bcb39d258 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -1491,7 +1491,11 @@ sub edit_tax { $form->header(); + #set readonly if the there are entries in acc_trans with the tax + my $readonly = $form->{tax_already_used} ? 'readonly' : ''; + my $parameters_ref = { + readonly => $readonly, }; # Ausgabe des Templates @@ -1552,12 +1556,16 @@ sub save_tax { $main::auth->assert('config'); - $form->isblank("rate", $locale->text('Taxrate missing!')); - $form->isblank("taxdescription", $locale->text('Taxdescription missing!')); - $form->isblank("taxkey", $locale->text('Taxkey missing!')); + $form->error($locale->text('Taxkey missing!')) unless length($form->{taxkey}) != 0; + $form->error($locale->text('Taxdescription missing!')) unless length($form->{taxdescription}) != 0; + $form->error($locale->text('Taxrate missing!')) unless length($form->{rate}) != 0; $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate}); + if ($form->{taxkey} == 0 and $form->{rate} > 0) { + $form->error($locale->text('Taxkey 0 is reserved for rate 0')); + } + if ( $form->{rate} < 0 || $form->{rate} >= 100 ) { $form->error($locale->text('Tax Percent is a number between 0 and 100')); } diff --git a/locale/de/all b/locale/de/all index 9e7f46f0a..1e8bbdd92 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1858,6 +1858,7 @@ $self->{texts} = { 'Taxes' => 'Steuern', 'Taxkey' => 'Steuerschlüssel', 'Taxkey missing!' => 'Steuerschlüssel fehlt!', + 'Taxkey 0 is reserved for rate 0' => 'Der Steuerschlüssel 0 darf keinen Steuersatz über 0 haben.', 'Taxkey_coa' => 'Steuerschlüssel', 'Taxkeys and Taxreport Preferences' => 'Steuerautomatik und UStVA', 'Taxlink_coa' => 'Steuerautomatik', diff --git a/locale/en/all b/locale/en/all index 7734f90cf..d39b9aeb1 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1814,6 +1814,7 @@ $self->{texts} = { 'Taxes' => '', 'Taxkey' => '', 'Taxkey missing!' => '', + 'Taxkey 0 is reserved for rate 0' => '', 'Taxkey_coa' => '', 'Taxkeys and Taxreport Preferences' => '', 'Taxlink_coa' => '', diff --git a/templates/webpages/am/edit_tax.html b/templates/webpages/am/edit_tax.html index 832bd0f2b..e153d2f83 100644 --- a/templates/webpages/am/edit_tax.html +++ b/templates/webpages/am/edit_tax.html @@ -9,7 +9,7 @@ - + @@ -19,7 +19,7 @@ - + @@ -42,7 +42,7 @@ - [% IF orphaned %] + [% IF orphaned AND NOT tax_already_used %] [% END %] -- 2.20.1
[% 'tax_taxkey' | $T8 %]
[% 'tax_percent' | $T8 %] % %