[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1530] trunk/LedgerSMB/RP.pm
- Subject: SF.net SVN: ledger-smb: [1530] trunk/LedgerSMB/RP.pm
- From: ..hidden..
- Date: Fri, 07 Sep 2007 09:59:11 -0700
Revision: 1530
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1530&view=rev
Author: einhverfr
Date: 2007-09-07 09:59:11 -0700 (Fri, 07 Sep 2007)
Log Message:
-----------
Applying patch 1789541 to correct Aging report.
Modified Paths:
--------------
trunk/LedgerSMB/RP.pm
Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm 2007-09-07 01:54:59 UTC (rev 1529)
+++ trunk/LedgerSMB/RP.pm 2007-09-07 16:59:11 UTC (rev 1530)
@@ -1564,6 +1564,10 @@
sub aging {
my ( $self, $myconfig, $form ) = @_;
+
+ my $ref;
+ my $department_id;
+ my $null;
my $dbh = $form->{dbh};
my $invoice = ( $form->{arap} eq 'ar' ) ? 'is' : 'ir';
@@ -1579,46 +1583,12 @@
( $form->{todate} ) = $dbh->selectrow_array($query);
}
- my $where = "1 = 1";
- my $name;
- my $null;
- my $ref;
my $transdate = ( $form->{overdue} ) ? "duedate" : "transdate";
- if ( $form->{"$form->{ct}_id"} ) {
- $where .= qq| AND ct.id = | . $dbh->quote( $form->{"$form->{ct}_id"} );
- }
- else {
- if ( $form->{ $form->{ct} } ne "" ) {
- $name = $dbh->quote( $form->like( lc $form->{ $form->{ct} } ) );
- $where .= qq| AND lower(ct.name) LIKE $name|
- if $form->{ $form->{ct} };
- }
- }
-
if ( $form->{department} ) {
( $null, $department_id ) = split /--/, $form->{department};
- $where .= qq| AND a.department_id = | . $dbh->quote($department_id);
}
- # select outstanding vendors or customers, depends on $ct
- $query = qq|
- SELECT DISTINCT ct.id, e.name, ct.language_code
- FROM $form->{ct} ct
- 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 e.name|;
- my $sth = $dbh->prepare($query);
- $sth->execute( $form->{todate} ) || $form->dberror($query);
-
- my @ot = ();
- while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
- push @ot, $ref;
- }
- $sth->finish;
-
my $buysell = ( $form->{arap} eq 'ar' ) ? 'buy' : 'sell';
my $todate = $dbh->quote( $form->{todate} );
@@ -1632,7 +1602,11 @@
# for each company that has some stuff outstanding
$form->{currencies} ||= ":";
- $where = qq|a.paid != a.amount AND c.id = ? AND a.curr = ?|;
+ $where = qq|a.paid != a.amount|;
+
+ if ( $form->{"$form->{ct}_id"} ) {
+ $where .= qq| AND c.entity_id = | . $dbh->quote( $form->{"$form->{ct}_id"} );
+ }
if ($department_id) {
$where .= qq| AND a.department_id = | . $dbh->quote($department_id);
@@ -1676,13 +1650,13 @@
AND e.transdate = a.transdate)
AS exchangerate
FROM $form->{arap} a
- JOIN entity_credit_account c USING (entity_id)|;
+ JOIN entity_credit_account c USING (entity_id)
+ WHERE $where|;
$query .= qq| ORDER BY ctid, curr, $transdate, invnumber|;
$sth = $dbh->prepare($query) || $form->dberror($query);
- my @var = ();
- $sth->execute(@var);
+ $sth->execute();
while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
$form->db_parse_numeric(sth=>$sth, hashref=>$ref);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.