[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3750] branches/1.3/LedgerSMB/AA.pm



Revision: 3750
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3750&view=rev
Author:   ehuelsmann
Date:     2011-09-26 21:56:05 +0000 (Mon, 26 Sep 2011)
Log Message:
-----------
Improve (but not completely fix) AR Outstanding report.

Modified Paths:
--------------
    branches/1.3/LedgerSMB/AA.pm

Modified: branches/1.3/LedgerSMB/AA.pm
===================================================================
--- branches/1.3/LedgerSMB/AA.pm	2011-09-25 23:25:49 UTC (rev 3749)
+++ branches/1.3/LedgerSMB/AA.pm	2011-09-26 21:56:05 UTC (rev 3750)
@@ -927,8 +927,10 @@
             $query = qq|
 		   SELECT a.id, a.invnumber, a.ordnumber, a.transdate,
 		          a.duedate, a.netamount, a.amount::numeric(20,$p), 
-                          a.amount::numeric(20,$p) 
-                          - sum(acs.amount::numeric(20,$p)) AS paid,
+		          sum(a.amount::numeric(20,$p)) 
+                             - (sum(acs.amount::numeric(20,$p)) 
+                                * CASE WHEN '$table' = 'ar' THEN -1 ELSE 1 END)
+                          AS paid,
 		          a.invoice, a.datepaid, a.terms, a.notes,
 		          a.shipvia, a.shippingpoint, 
 		          vce.name, vc.meta_number,
@@ -942,7 +944,8 @@
 		     JOIN entity_credit_account vc ON (a.entity_credit_account = vc.id)
 		     JOIN acc_trans acs ON (acs.trans_id = a.id)
 		     JOIN entity vce ON (vc.entity_id = vce.id)
-		     JOIN chart c ON (acs.chart_id = c.id)
+		     JOIN chart c ON (acs.chart_id = c.id
+                                      AND charttype='A')
 		LEFT JOIN exchangerate ex ON (ex.curr = a.curr
 		          AND ex.transdate = a.transdate)
 		LEFT JOIN department d ON (a.department_id = d.id)

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.