From: Niclas Zimmermann Date: Fri, 22 Feb 2013 13:58:36 +0000 (+0100) Subject: Merge branch 'tax_festsetzen' X-Git-Tag: release-3.1.0beta1~608^2 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/7ff9fa05e670aa2e5fa76b9d8d0b39ea66a74dd1?hp=21daf701fac24bbc753abae8d8f5f6b8bcf984f7 Merge branch 'tax_festsetzen' --- 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 d9548a5ae..d88e2ec70 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1863,6 +1863,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 4d4aa5354..3424a0158 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1816,6 +1816,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 %]
[% 'tax_taxkey' | $T8 %]
[% 'tax_percent' | $T8 %] % %