summaryrefslogtreecommitdiff
path: root/LedgerSMB/Form.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-01 23:14:41 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-01 23:14:41 +0000
commit85ef0d4ff19e2284c61803ec12b04488b941b7ac (patch)
tree3fdc10f0f186666efb545966f788c061ceef3464 /LedgerSMB/Form.pm
parentb1d3c56e3824b123e09bf807ee1cd9a71ca43efc (diff)
Fixing some aspects of the AR Transaction report.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1494 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Form.pm')
-rw-r--r--LedgerSMB/Form.pm24
1 files changed, 14 insertions, 10 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index f1c873d0..dcdca9a6 100644
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -1694,8 +1694,8 @@ sub all_vc {
}
my $query = qq|SELECT count(*) FROM entity_credit_account where entity_class = ?|;
my $where;
- my @queryargs = ($self->{vc_class});
-
+ my @queryargs2 = ($self->{vc_class});
+ my @queryargs;
if ($transdate) {
$query .= qq| AND (startdate IS NULL OR startdate <= ?)
AND (enddate IS NULL OR enddate >= ?)|;
@@ -1703,13 +1703,14 @@ sub all_vc {
AND (enddate IS NULL OR enddate >= ?)
AND entity_class = ?|;
push (@queryargs, $transdate, $transdate, $self->{vc_class});
+ push (@queryargs2, $transdate, $transdate);
} else {
$where = " true";
}
$sth = $dbh->prepare($query);
- $sth->execute(@queryargs);
+ $sth->execute(@queryargs2);
my ($count) = $sth->fetchrow_array;
@@ -1735,7 +1736,6 @@ sub all_vc {
WHERE id = ?
ORDER BY name|;
- shift @queryargs;
push( @queryargs, $self->{"${vc}_id"} );
$sth = $dbh->prepare($query);
@@ -2141,21 +2141,25 @@ sub create_links {
$query = qq|
SELECT a.invnumber, a.transdate,
- a.${vc}_id, a.datepaid, a.duedate, a.ordnumber,
+ a.entity_id, a.datepaid, a.duedate, a.ordnumber,
a.taxincluded, a.curr AS currency, a.notes,
- a.intnotes, c.name AS $vc, a.department_id,
+ a.intnotes, ce.name AS $vc, a.department_id,
d.description AS department,
a.amount AS oldinvtotal, a.paid AS oldtotalpaid,
a.employee_id, e.name AS employee,
c.language_code, a.ponumber, a.reverse
FROM $arap a
- JOIN $vc c ON (a.${vc}_id = c.id)
- LEFT JOIN employee e ON (e.id = a.employee_id)
+ JOIN entity_credit_account c USING (entity_id)
+ JOIN entity ce ON (e.id = c.entity_id)
+ LEFT JOIN employee er ON (er.entity_id = a.person_id)
+ LEFT JOIN entity e ON (er.entity_id = e.entity_id)
LEFT JOIN department d ON (d.id = a.department_id)
- WHERE a.id = ?|;
+ WHERE a.id = ? AND c.entity_class =
+ (select id FROM entity_class
+ WHERE class ilike ?)|;
$sth = $dbh->prepare($query);
- $sth->execute( $self->{id} ) || $self->dberror($query);
+ $sth->execute( $self->{id}, $self->{vc} ) || $self->dberror($query);
$ref = $sth->fetchrow_hashref(NAME_lc);
$self->db_parse_numeric(sth=>$sth, hashref=>$ref);