X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FBuchungsgruppen.pm;h=4776bd6406f33796889a07151471377ee84e7ece;hb=2a7f7f23f9bf349b0329ef7216037935686a1325;hp=daaf94f5c38a7266dd13d4bdcf02074d577d7323;hpb=504fcaf11d8cbf10f353fb22990f559b36f5478c;p=kivitendo-erp.git diff --git a/SL/Controller/Buchungsgruppen.pm b/SL/Controller/Buchungsgruppen.pm index daaf94f5c..4776bd640 100644 --- a/SL/Controller/Buchungsgruppen.pm +++ b/SL/Controller/Buchungsgruppen.pm @@ -85,12 +85,13 @@ sub action_delete { # allow deletion of unused Buchungsgruppen. Will fail, due to database # constraint, if Buchungsgruppe is connected to a part - my $db = $self->{config}->db; - $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(); - flash_later('info', $::locale->text('The booking group has been deleted.')); + $self->{config}->db->with_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(); + flash_later('info', $::locale->text('The booking group has been deleted.')); + + 1; }) || flash_later('error', $::locale->text('The booking group is in use and cannot be deleted.')); $self->redirect_to(action => 'list'); @@ -133,7 +134,7 @@ sub create_or_update { my @errors; my $db = $self->config->db; - $db->do_transaction( sub { + if (!$db->with_transaction(sub { $self->config->assign_attributes(%{ $params }); # assign description and inventory_accno_id @@ -169,9 +170,13 @@ sub create_or_update { $taxzone_chart->save; } } - } ) || die @errors ? join("\n", @errors) . "\n" : $db->error . "\n"; - # die with rollback of taxzone save if saving of any of the taxzone_charts fails - # only show the $db->error if we haven't already identified the likely error ourselves + + 1; + })) { + die @errors ? join("\n", @errors) . "\n" : $db->error . "\n"; + # die with rollback of taxzone save if saving of any of the taxzone_charts fails + # only show the $db->error if we haven't already identified the likely error ourselves + } flash_later('info', $is_new ? t8('The booking group has been created.') : t8('The booking group has been saved.')); $self->redirect_to(action => 'list');