projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Mahnungen: Typo in query
[kivitendo-erp.git]
/
SL
/
CP.pm
diff --git
a/SL/CP.pm
b/SL/CP.pm
index
91e032f
..
dc52af8
100644
(file)
--- a/
SL/CP.pm
+++ b/
SL/CP.pm
@@
-25,7
+25,8
@@
# 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
# 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
#======================================================================
#
# Check and receipt printing payment module backend routines
@@
-36,6
+37,7
@@
package CP;
use SL::DBUtils;
package CP;
use SL::DBUtils;
+use SL::DB;
use strict;
use strict;
@@
-66,8
+68,7
@@
sub paymentaccounts {
my ($self, $myconfig, $form) = @_;
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";
my $ARAP = $form->{ARAP} eq "AR" ? "AR" : "AP";
@@
-76,7
+77,7
@@
sub paymentaccounts {
qq|FROM chart | .
qq|WHERE link LIKE ? |.
qq|ORDER BY accno|;
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"} = ();
$form->{PR}{ $form->{ARAP} } = ();
$form->{PR}{"$form->{ARAP}_paid"} = ();
@@
-97,8
+98,6
@@
sub paymentaccounts {
$query = qq|SELECT closedto FROM defaults|;
($form->{closedto}) = selectrow_query($form, $dbh, $query);
$query = qq|SELECT closedto FROM defaults|;
($form->{closedto}) = selectrow_query($form, $dbh, $query);
- $dbh->disconnect;
-
$main::lxdebug->leave_sub();
}
$main::lxdebug->leave_sub();
}
@@
-107,7
+106,7
@@
sub get_openvc {
my ($self, $myconfig, $form) = @_;
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";
my $arap = ($form->{vc} eq 'customer') ? 'ar' : 'ap';
my $vc = $form->{vc} eq "customer" ? "customer" : "vendor";
@@
-127,11
+126,6
@@
sub get_openvc {
$form->{"all_$form->{vc}"} = selectall_hashref_query($form, $dbh, $query);
}
$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();
}
$main::lxdebug->leave_sub();
}
@@
-141,22
+135,29
@@
sub get_openinvoices {
my ($self, $myconfig, $form) = @_;
# connect to database
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";
my $buysell = $form->{vc} eq 'customer' ? "buy" : "sell";
my $arap = $form->{arap} eq "ar" ? "ar" : "ap";
my $vc = $form->{vc} eq "customer" ? "customer" : "vendor";
my $buysell = $form->{vc} eq 'customer' ? "buy" : "sell";
my $arap = $form->{arap} eq "ar" ? "ar" : "ap";
+ my @values = (conv_i($form->{"${vc}_id"}), "$form->{currency}");
+ my $whereinvoice = '';
+ if ($::form->{invnumber}) {
+ $whereinvoice = ' AND a.invnumber LIKE ? ';
+ push @values, $::form->{invnumber};
+ }
+
my $query =
my $query =
- qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, cu.curr | .
+ qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, cu.
name AS
curr | .
qq|FROM $arap a | .
qq|FROM $arap a | .
- qq|LEFT JOIN currencies cu ON (cu.id=a.curr)| .
- qq|WHERE (a.${vc}_id = ?) AND cu.curr = ? AND NOT (a.amount = a.paid)| .
+ qq|LEFT JOIN currencies cu ON (cu.id=a.currency_id)| .
+ qq|WHERE (a.${vc}_id = ?) AND cu.name = ? AND NOT (a.amount = a.paid)| .
+ $whereinvoice .
qq|ORDER BY a.id|;
qq|ORDER BY a.id|;
- my $sth = prepare_execute_query($form, $dbh, $query,
- conv_i($form->{"${vc}_id"}),
- "$form->{currency}");
+
+ my $sth = prepare_execute_query($form, $dbh, $query, @values);
$form->{PR} = [];
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
$form->{PR} = [];
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
@@
-174,24
+175,29
@@
sub get_openinvoices {
SELECT COUNT(*)
FROM $arap
WHERE (${vc}_id = ?)
SELECT COUNT(*)
FROM $arap
WHERE (${vc}_id = ?)
- AND ((SELECT cu.
curr FROM currencies cu WHERE cu.id=${arap}.curr
) <> ?)
+ AND ((SELECT cu.
name FROM currencies cu WHERE cu.id=${arap}.currency_id
) <> ?)
AND (amount <> paid)
SQL
($form->{openinvoices_other_currencies}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{"${vc}_id"}), "$form->{currency}");
AND (amount <> paid)
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 {
$main::lxdebug->leave_sub();
}
sub process_payment {
+ my ($self, $myconfig, $form) = @_;
$main::lxdebug->enter_sub();
$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;
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};
my ($paymentaccno) = split /--/, $form->{account};
@@
-250,7
+256,7
@@
sub process_payment {
qq|SELECT $buysell | .
qq|FROM exchangerate e | .
qq|JOIN ${arap} a ON (a.transdate = e.transdate) | .
qq|SELECT $buysell | .
qq|FROM exchangerate e | .
qq|JOIN ${arap} a ON (a.transdate = e.transdate) | .
- qq|WHERE (e.curr
= (SELECT id FROM currencies WHERE curr
= ?)) AND (a.id = ?)|;
+ qq|WHERE (e.curr
ency_id = (SELECT id FROM currencies WHERE name
= ?)) AND (a.id = ?)|;
my ($exchangerate) =
selectrow_query($form, $dbh, $query,
$form->{currency}, $form->{"id_$i"});
my ($exchangerate) =
selectrow_query($form, $dbh, $query,
$form->{currency}, $form->{"id_$i"});
@@
-341,24
+347,16
@@
sub process_payment {
# saving the history
$form->{id} = $form->{"id_$i"};
if(!exists $form->{addition}) {
# saving the history
$form->{id} = $form->{"id_$i"};
if(!exists $form->{addition}) {
- $form->{snumbers} = qq|invnumber_| . $form->{"invnumber_$i"};
- $form->{addition} = "POSTED";
+ $form->{snumbers} = qq|invnumber_| . $form->{"invnumber_$i"};
+ $form->{what_done} = "invoice";
+ $form->{addition} = "PAYMENT POSTED";
$form->save_history;
}
# /saving the history
}
}
$form->save_history;
}
# /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;
}
1;