summaryrefslogtreecommitdiff
path: root/LedgerSMB/RP.pm
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB/RP.pm')
-rw-r--r--LedgerSMB/RP.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/LedgerSMB/RP.pm b/LedgerSMB/RP.pm
index 0697675c..4bdd4360 100644
--- a/LedgerSMB/RP.pm
+++ b/LedgerSMB/RP.pm
@@ -1603,14 +1603,15 @@ sub aging {
# select outstanding vendors or customers, depends on $ct
$query = qq|
- SELECT DISTINCT ct.id, ct.name, ct.language_code
+ SELECT DISTINCT ct.id, e.name, ct.language_code
FROM $form->{ct} ct
- JOIN $form->{arap} a ON (a.$form->{ct}_id = ct.id)
+ JOIN $form->{arap} a USING (entity_id)
+ JOIN entity e ON (ct.entity_id = e.id)
WHERE $where AND a.paid != a.amount
AND (a.$transdate <= ?)
- ORDER BY ct.name|;
+ ORDER BY e.name|;
my $sth = $dbh->prepare($query);
- $sth->execute( $form->{todate} ) || $form->dberror;
+ $sth->execute( $form->{todate} ) || $form->dberror($query);
my @ot = ();
while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {