]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/am.pl
Bugfix für 1648 - bebuchte Konten sollten nicht in Überschriften umgewandelt werden...
[mfinanz.git] / bin / mozilla / am.pl
index 73a2133d24c02c786da6309cbee690e37e44a240..2dacb6f98245760af9c5100b25384bf59ca5f525 100644 (file)
@@ -328,21 +328,18 @@ sub account_header {
   }
 
   # preselection chart type
-  my $select_charttype = q{};
-
-  my %charttype = (
-      'A'  => $locale->text('Account'),
-      'H'  => $locale->text('Heading'),
-  );
+  my @all_charttypes = ({'name' => $locale->text('Account'), 'value' => 'A'},
+                        {'name' => $locale->text('Heading'), 'value' => 'H'},
+    );
+  my $selected_charttype = $form->{charttype};
 
-  foreach my $item ( sort({ $a <=> $b } keys %charttype) ) {
-    if ($item eq $form->{charttype}) {
-      $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
 
-    } else {
-      $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
+  # account where AR_tax or AP_tax is set are not orphaned if they are used as
+  # tax-o-matic account
+  if ( $form->{id} && !$form->{orphaned} && ($form->{link} =~ m/(AP_tax|AR_tax)/) ) {
+    if (SL::DB::Manager::Tax->find_by(chart_id => $form->{id})) {
+      $form->{orphaned} = 0;
     }
-
   }
 
   my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
@@ -354,7 +351,8 @@ sub account_header {
     ChartTypeIsAccount         => $ChartTypeIsAccount,
     AccountIsPosted            => $AccountIsPosted,
     select_category            => $select_category,
-    select_charttype           => $select_charttype,
+    all_charttypes             => \@all_charttypes,
+    selected_charttype         => $selected_charttype,
     select_bwa                 => $select_bwa,
     select_bilanz              => $select_bilanz,
     select_eur                 => $select_eur,