X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=bcb39d258f066a65813f4ca81a272541914ae4be;hb=067e94571b0f00cbb77c6b6fbeb1ed5e1e31402e;hp=500547597816ee5a1f0bd441d284ffec3736e242;hpb=781c16772f3c80cc827f11815bfb07b8318621f0;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 500547597..bcb39d258 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -144,7 +144,7 @@ sub account_header { rate => '', taxkey_id => '', pos_ustva => '', - startdate => '', + startdate => $form->{account_exists} ? '' : DateTime->new(year => 1970, month => 1, day => 1)->to_lxoffice, }; push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref; @@ -394,6 +394,17 @@ sub save_account { if ($form->{charttype} eq 'A'){ $form->isblank("category", $locale->text('Account Type missing!')); + + my $found_valid_taxkey = 0; + foreach my $i (0 .. 10) { # 10 is maximum count of taxkeys in form + if ($form->{"taxkey_startdate_$i"} and !$form->{"taxkey_del_$i"}) { + $found_valid_taxkey = 1; + last; + } + } + if ($found_valid_taxkey == 0) { + $form->error($locale->text('A valid taxkey is missing!')); + } } $form->redirect($locale->text('Account saved!')) @@ -1062,7 +1073,7 @@ sub config { } $form->{STYLESHEETS} = []; - foreach my $item (qw(lx-office-erp.css Win2000.css Mobile.css kivitendo.css)) { + foreach my $item (qw(lx-office-erp.css Mobile.css kivitendo.css)) { push @{ $form->{STYLESHEETS} }, { 'name' => $item, 'value' => $item, @@ -1480,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 @@ -1541,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')); }