X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FTaxzones.pm;h=1594b9b37376843a48e1e479821c0f8b989eb6da;hb=c7b0defb2a90a8eaa28b9e58ac3c108c27375a77;hp=60b820d4f705af8e576cdd098f9e2c413f9454e1;hpb=bdc944eae9567aa4bd256b56b89f6004890fc585;p=kivitendo-erp.git diff --git a/SL/Controller/Taxzones.pm b/SL/Controller/Taxzones.pm index 60b820d4f..1594b9b37 100644 --- a/SL/Controller/Taxzones.pm +++ b/SL/Controller/Taxzones.pm @@ -72,12 +72,13 @@ sub action_delete { # allow deletion of unused tax zones. Will fail, due to database # constraints, if tax zone is used anywhere - my $db = $self->{config}->db; - $db->do_transaction(sub { - my $taxzone_charts = SL::DB::Manager::TaxzoneChart->get_all(where => [ taxzone_id => $self->config->id ]); - foreach my $taxzonechart ( @{$taxzone_charts} ) { $taxzonechart->delete }; - $self->config->delete(); - flash_later('info', $::locale->text('The tax zone has been deleted.')); + $self->{config}->db->with_transaction(sub { + my $taxzone_charts = SL::DB::Manager::TaxzoneChart->get_all(where => [ taxzone_id => $self->config->id ]); + foreach my $taxzonechart ( @{$taxzone_charts} ) { $taxzonechart->delete }; + $self->config->delete(); + flash_later('info', $::locale->text('The tax zone has been deleted.')); + + 1; }) || flash_later('error', $::locale->text('The tax zone is in use and cannot be deleted.')); $self->redirect_to(action => 'list'); @@ -121,7 +122,7 @@ sub create_or_update { my @errors; my $db = $self->config->db; - $db->do_transaction( sub { + if (!$db->with_transaction(sub { # always allow editing of description and obsolete $self->config->assign_attributes( %{$params} ) ; @@ -146,8 +147,8 @@ sub create_or_update { $income_accno = SL::DB::Manager::Chart->find_by( id => $income_accno_id ) if $income_accno_id; $expense_accno = SL::DB::Manager::Chart->find_by( id => $expense_accno_id ) if $expense_accno_id; - push(@errors, t8('Buchungsgruppe #1 needs a valid income account' , $bg->description)) unless $income_accno; - push(@errors, t8('Buchungsgruppe #1 needs a valid expense account', $bg->description)) unless $expense_accno; + push(@errors, t8('Booking group #1 needs a valid income account' , $bg->description)) unless $income_accno; + push(@errors, t8('Booking group #1 needs a valid expense account', $bg->description)) unless $expense_accno; my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by_or_create(buchungsgruppen_id => $bg->id, taxzone_id => $self->config->id); # if taxzonechart doesn't exist an empty new TaxzoneChart object is @@ -160,9 +161,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 taxzone has been created.') : t8('The taxzone has been saved.')); $self->redirect_to(action => 'list');