X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/bc40bcabc425b99f3b79a5544684a6fe8674adfe..3bb3a4a56b0be39fd60f011137ffbadd9dba3fd7:/SL/CP.pm diff --git a/SL/CP.pm b/SL/CP.pm index 3a2952728..dd882ab10 100644 --- a/SL/CP.pm +++ b/SL/CP.pm @@ -36,6 +36,7 @@ package CP; use SL::DBUtils; +use SL::DB; use strict; @@ -66,8 +67,7 @@ sub paymentaccounts { my ($self, $myconfig, $form) = @_; - # connect to database - my $dbh = $form->dbconnect($myconfig); + my $dbh = SL::DB->client->dbh; my $ARAP = $form->{ARAP} eq "AR" ? "AR" : "AP"; @@ -97,8 +97,6 @@ sub paymentaccounts { $query = qq|SELECT closedto FROM defaults|; ($form->{closedto}) = selectrow_query($form, $dbh, $query); - $dbh->disconnect; - $main::lxdebug->leave_sub(); } @@ -107,7 +105,7 @@ sub get_openvc { my ($self, $myconfig, $form) = @_; - my $dbh = $form->dbconnect($myconfig); + my $dbh = SL::DB->client->dbh; my $arap = ($form->{vc} eq 'customer') ? 'ar' : 'ap'; my $vc = $form->{vc} eq "customer" ? "customer" : "vendor"; @@ -127,11 +125,6 @@ sub get_openvc { $form->{"all_$form->{vc}"} = selectall_hashref_query($form, $dbh, $query); } - # aufruf für all_deparments rausgenommen, da die abteilungen nur - # beim buchen der belege (rechnung, fibu) geändert werden und danach - # NICHT mehr überschrieben werden - $dbh->disconnect; - $main::lxdebug->leave_sub(); } @@ -141,7 +134,7 @@ sub get_openinvoices { my ($self, $myconfig, $form) = @_; # connect to database - my $dbh = $form->dbconnect($myconfig); + my $dbh = SL::DB->client->dbh; my $vc = $form->{vc} eq "customer" ? "customer" : "vendor"; @@ -186,19 +179,24 @@ sub get_openinvoices { SQL ($form->{openinvoices_other_currencies}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{"${vc}_id"}), "$form->{currency}"); - $dbh->disconnect; - $main::lxdebug->leave_sub(); } sub process_payment { + my ($self, $myconfig, $form) = @_; $main::lxdebug->enter_sub(); + my $rc = SL::DB->client->with_transaction(\&_process_payment, $self, $myconfig, $form); + + $::lxdebug->leave_sub; + return $rc; +} + +sub _process_payment { my ($self, $myconfig, $form) = @_; my $amount; - # connect to database, turn AutoCommit off - my $dbh = $form->dbconnect_noauto($myconfig); + my $dbh = SL::DB->client->dbh; my ($paymentaccno) = split /--/, $form->{account}; @@ -356,17 +354,8 @@ sub process_payment { # /saving the history } } - my $rc; - # Hier wurden negativen Zahlungseingänge abgefangen - # da Zahlungsein- und ausgänge immer positiv sind - # Besser: in Oberfläche schon prüfen erledigt jb 10.2010 - $rc = $dbh->commit; - - $dbh->disconnect; - $main::lxdebug->leave_sub(); - - return $rc; + return 1; } 1;