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 = ? |;
$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
$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'));
}
'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',
'Taxes' => '',
'Taxkey' => '',
'Taxkey missing!' => '',
+ 'Taxkey 0 is reserved for rate 0' => '',
'Taxkey_coa' => '',
'Taxkeys and Taxreport Preferences' => '',
'Taxlink_coa' => '',
<table width="100%">
<tr>
<td>[% 'tax_taxkey' | $T8 %]</td>
- <td><input name="taxkey" size="2" value="[% HTML.escape(taxkey) %]"></td>
+ <td><input name="taxkey" size="2" value="[% HTML.escape(taxkey) %]" [% readonly %]></td>
</tr>
<tr>
<tr>
<td>[% 'tax_percent' | $T8 %]</td>
- <td><input name="rate" size="10" value="[% HTML.escape(rate) %]"> %</td>
+ <td><input name="rate" size="10" value="[% HTML.escape(rate) %]" [% readonly %]> %</td>
</tr>
<tr>
<input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]">
- [% IF orphaned %]
+ [% IF orphaned AND NOT tax_already_used %]
<input type="submit" class="submit" name="action" value="[% 'Delete' | $T8 %]">
[% END %]