# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# Check and receipt printing payment module backend routines
package CP;
use SL::DBUtils;
+use SL::DB;
use strict;
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";
qq|FROM chart | .
qq|WHERE link LIKE ? |.
qq|ORDER BY accno|;
- my $sth = prepare_execute_query($form, $dbh, $query, '%' . $ARAP . '%');
+ my $sth = prepare_execute_query($form, $dbh, $query, like($ARAP));
$form->{PR}{ $form->{ARAP} } = ();
$form->{PR}{"$form->{ARAP}_paid"} = ();
$query = qq|SELECT closedto FROM defaults|;
($form->{closedto}) = selectrow_query($form, $dbh, $query);
- $dbh->disconnect;
-
- $main::lxdebug->leave_sub();
-}
-
-sub get_openvc {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form) = @_;
-
- my $dbh = $form->dbconnect($myconfig);
-
- my $arap = ($form->{vc} eq 'customer') ? 'ar' : 'ap';
- my $vc = $form->{vc} eq "customer" ? "customer" : "vendor";
- my $query =
- qq|SELECT count(*) | .
- qq|FROM $vc ct, $arap a | .
- qq|WHERE (a.${vc}_id = ct.id) AND (a.amount != a.paid)|;
- my ($count) = selectrow_query($form, $dbh, $query);
-
- # build selection list
- if ($count < $myconfig->{vclimit}) {
- $query =
- qq|SELECT DISTINCT ct.id, ct.name | .
- qq|FROM $vc ct, $arap a | .
- qq|WHERE (a.${vc}_id = ct.id) AND (a.amount != a.paid) | .
- qq|ORDER BY ct.name|;
- $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();
}
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";
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};
# /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;
-