X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FBuchungsgruppen.pm;h=0de9d0c0fa1a9487c43f625d39cd3bd4d3d6ffdd;hb=54746051d506e6e6c76c77b85d381cae4bf86b89;hp=3ecba1369e45605938c5e6a4ce2956191571d9e6;hpb=058d70b8ae5406a40ce5ddba2d11cc8563d06751;p=kivitendo-erp.git diff --git a/SL/Controller/Buchungsgruppen.pm b/SL/Controller/Buchungsgruppen.pm index 3ecba1369..0de9d0c0f 100644 --- a/SL/Controller/Buchungsgruppen.pm +++ b/SL/Controller/Buchungsgruppen.pm @@ -8,7 +8,6 @@ use SL::DB::TaxZone; use SL::Helper::Flash; use SL::Locale::String; use SL::DB::TaxzoneChart; -use SL::Controller::ClientConfig; use SL::DB::Default; use Rose::Object::MakeMethods::Generic ( @@ -53,22 +52,18 @@ sub show_form { my ($self, %params) = @_; $self->render('buchungsgruppen/form', %params, - TAXZONES => SL::DB::Manager::TaxZone->get_all_sorted(), - ACCOUNTS => SL::Controller::ClientConfig->init_accounts(), - account_label => sub { "$_[0]{accno}--$_[0]{description}" }); + TAXZONES => SL::DB::Manager::TaxZone->get_all_sorted()); } sub action_edit { my ($self) = @_; - # Allow editing of Buchungsgruppe if it isn't assigned to any parts. The - # variable is checked in the template, which toggles between L.select_tag and - # text. - - my $number_of_parts_with_buchungsgruppe = SL::DB::Manager::Part->get_objects_count(where => [ buchungsgruppen_id => $self->config->id]); + # Allow editing of the charts of the Buchungsgruppe if it isn't assigned to + # any parts. This is checked inside the template via the Buchungsgruppen + # orphaned method, where an IF-ELSE statement toggles between L.select_tag + # and text. $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)); } @@ -91,7 +86,7 @@ sub action_delete { # constraint, if Buchungsgruppe is connected to a part my $db = $self->{config}->db; - $db->do_transaction(sub { + $db->do_transaction(sub { my $taxzone_charts = SL::DB::Manager::TaxzoneChart->get_all(where => [ buchungsgruppen_id => $self->config->id ]); foreach my $taxzonechart ( @{$taxzone_charts} ) { $taxzonechart->delete }; $self->config->delete(); @@ -147,11 +142,8 @@ sub create_or_update { $self->config->save; - # 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) { + # Save or update taxzone_charts for new or unused Buchungsgruppen + if ($is_new or $self->config->orphaned) { my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted(); foreach my $tz (@{ $taxzones }) {