projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Typo in GuV Gruppenüberschrift
[kivitendo-erp.git]
/
SL
/
CP.pm
diff --git
a/SL/CP.pm
b/SL/CP.pm
index
91e032f
..
e2b9f48
100644
(file)
--- a/
SL/CP.pm
+++ b/
SL/CP.pm
@@
-148,15
+148,22
@@
sub get_openinvoices {
my $buysell = $form->{vc} eq 'customer' ? "buy" : "sell";
my $arap = $form->{arap} eq "ar" ? "ar" : "ap";
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,7
+181,7
@@
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}");
@@
-250,7
+257,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"});