my ($self) = @_;
 
   my $buchungsgruppen = SL::DB::Manager::Buchungsgruppe->get_all_sorted();
-  my $taxzones        = SL::DB::Manager::TaxZone->get_all_sorted();
+  my $taxzones        = SL::DB::Manager::TaxZone->get_all_sorted(query => [ obsolete => 0 ]);
 
   my %chartlist = ();
   foreach my $gruppe (@{ $buchungsgruppen }) {
 sub action_edit {
   my ($self) = @_;
 
+  # check whether buchungsgruppe is assigned to any parts
+  my $number_of_parts_with_buchungsgruppe = SL::DB::Manager::Part->get_objects_count(where => [ buchungsgruppen_id => $self->config->id]);
+
   $self->show_form(title     => t8('Edit Buchungsgruppe'),
+                   linked_parts  => $number_of_parts_with_buchungsgruppe,
                    CHARTLIST => SL::DB::TaxzoneChart->get_all_accounts_by_buchungsgruppen_id($self->config->id));
 }
 
 
   $self->config->save;
 
-  #Save taxzone_charts:
-  if ($is_new) {
+  # check whether there are any assigned parts 
+  my $number_of_parts_with_buchungsgruppe = SL::DB::Manager::Part->get_objects_count(where => [ buchungsgruppen_id => $self->config->id]);
+
+  # Save or update taxzone_charts:
+  if ($is_new or $number_of_parts_with_buchungsgruppe == 0) {
     my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted();
 
     foreach my $tz (@{ $taxzones }) {
 
 sub action_edit {
   my ($self) = @_;
 
-  $self->show_form(title     => t8('Edit custom variable'),
+  $self->show_form(title     => t8('Edit taxzone'),
                    CHARTLIST => SL::DB::TaxzoneChart->get_all_accounts_by_taxzone_id($self->config->id));
 }
 
   }
 
   $self->config->save;
+  $self->config->obsolete($::form->{"obsolete"});
 
   #Save taxzone_charts for new taxzones:
   if ($is_new) {
 
 __PACKAGE__->meta->columns(
   description => { type => 'text' },
   id          => { type => 'integer', not_null => 1, sequence => 'id' },
+  obsolete    => { type => 'boolean', default => 'false' },
   sortkey     => { type => 'integer', not_null => 1 },
 );
 
 
   my ($self, $dbh, $key) = @_;
 
   $key = "all_taxzones" unless ($key);
+  my $tzfilter = "";
+  $tzfilter = "WHERE obsolete is FALSE" if $key eq 'ALL_ACTIVE_TAXZONES'; 
 
-  my $query = qq|SELECT * FROM tax_zones ORDER BY sortkey|;
+  my $query = qq|SELECT * FROM tax_zones $tzfilter ORDER BY sortkey|;
 
   $self->{$key} = selectall_hashref_query($self, $dbh, $query);
 
 
 
   $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
 
-  $form->get_lists("taxzones"      => "ALL_TAXZONES",
+  $form->get_lists("taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
                    "currencies"    => "ALL_CURRENCIES",
                    "customers"     => "ALL_CUSTOMERS",
                    "departments"   => "all_departments",
 
 
   my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
 
-  # project ids
-  $form->get_lists("taxzones"      => "ALL_TAXZONES",
+  $form->get_lists("taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
                    "payments"      => "ALL_PAYMENTS",
                    "currencies"    => "ALL_CURRENCIES",
                    "departments"   => "ALL_DEPARTMENTS",
 
--- /dev/null
+-- @tag: tax_zones_obsolete
+-- @description: Steuerzonen auf ungültig setzen können
+-- @depends: change_taxzone_id_0
+ALTER TABLE tax_zones ADD COLUMN obsolete boolean DEFAULT FALSE;
 
   </tr>
   <tr>
     <th align="right">[% 'Inventory account' | $T8 %]</th>
-    [%- IF SELF.config.id %]
+    [%- IF SELF.config.id AND linked_parts != 0 %]
     <td>[%- CHARTLIST.inventory_accno %] -- [%- CHARTLIST.inventory_accno_description %]</td>
     [%- ELSE %]
     <td>[%- L.select_tag("config.inventory_accno_id", ACCOUNTS.ic, title_sub=\account_label, default=SELF.config.inventory_accno_id) %]</td>
 [%- FOREACH tz = TAXZONES %]
   <tr>
     <th align="right">[% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %]</th>
-    [%- IF SELF.config.id %]
+    [%- IF SELF.config.id AND linked_parts != 0 %]
     <td>[% CHARTLIST.${tz.id}.income_accno %] -- [% CHARTLIST.${tz.id}.income_accno_description %]</td>
     [%- ELSE %]
     <td>[%- L.select_tag('income_accno_id_' _ tz.id, ACCOUNTS.ic_income, title_sub=\account_label, default=CHARTLIST.${tz.id}.income_accno_id) %]</td>
   </tr>
   <tr>
     <th align="right">[% 'Expense' | $T8 %] [% HTML.escape(tz.description) %]</th>
-    [%- IF SELF.config.id %]
+    [%- IF SELF.config.id AND linked_parts != 0 %]
     <td>[% CHARTLIST.${tz.id}.expense_accno %] -- [% CHARTLIST.${tz.id}.expense_accno_description %]</td>
     [%- ELSE %]
     <td>[%- L.select_tag('expense_accno_id_' _ tz.id, ACCOUNTS.ic_expense, title_sub=\account_label, default=CHARTLIST.${tz.id}.expense_accno_id) %]</td>
 
         <tr>
           <th align="right">[% 'Steuersatz' | $T8 %]</th>
           <td>
-            [% L.select_tag('taxzone_id', ALL_TAXZONES, default = taxzone_id, title_key = 'description', disabled = (id ? 1 : 0), style='width: 250px', onchange = "document.getElementById('update_button').click();") %]
+            [% L.select_tag('taxzone_id', ( id ? ALL_TAXZONES : ALL_ACTIVE_TAXZONES) , default = taxzone_id, title_key = 'description', disabled = (id ? 1 : 0), style='width: 250px', onchange = "document.getElementById('update_button').click();") %]
   [%- IF id %]
           <input type='hidden' name='taxzone_id' value='[% taxzone_id %]'>
   [%- END %]
 
                   <tr>
                     <th align="right">[% 'Steuersatz' | $T8 %]</th>
                     <td>
-                      [% L.select_tag('taxzone_id', ALL_TAXZONES, default=taxzone_id, title_key='description', style='width: 250px') %]
+                      [% L.select_tag('taxzone_id', ( id ? ALL_TAXZONES : ALL_ACTIVE_TAXZONES), default=taxzone_id, title_key='description', style='width: 250px') %]
                     </td>
                   </tr>
 [%- IF ALL_DEPARTMENTS %]
 
 [%- END %]
 </table>
 
+[% LxERP.t8('Obsolete') %]: [% L.checkbox_tag('config.obsolete', checked = SELF.config.obsolete, for_submit=1) %]
+
  <p>
   [% L.hidden_tag("action", "Taxzones/dispatch") %]
   [% L.submit_tag("action_" _  (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %]