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

SF.net SVN: ledger-smb:[5597] trunk



Revision: 5597
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5597&view=rev
Author:   einhverfr
Date:     2013-01-17 09:28:37 +0000 (Thu, 17 Jan 2013)
Log Message:
-----------
Fixing credit limit not accounting for payments entered on single payment screen

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/AA.pm

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2013-01-16 09:45:01 UTC (rev 5596)
+++ trunk/Changelog	2013-01-17 09:28:37 UTC (rev 5597)
@@ -101,6 +101,7 @@
 * Fixed contact info addition workflow.  Now entering multiple contact records 
 is not a total pain(Chris T)
 * Fixed lines 2 and 3 not showing on address div for contacts (Chris T)
+* Fixed credit limit not accounting for some payments (Chris T, 3600679)
 
 Changelog for 1.3.28
 * Added db list to setup.pl when no db is entered and credentials allow login

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2013-01-16 09:45:01 UTC (rev 5596)
+++ trunk/LedgerSMB/AA.pm	2013-01-17 09:28:37 UTC (rev 5597)
@@ -892,8 +892,12 @@
     $form->{creditremaining} = $form->{creditlimit};
     $query = qq|
                 SELECT sum(used) FROM (
-		SELECT SUM(amount - paid) as used
-		  FROM $arap
+		SELECT SUM(ac.amount) 
+                       * CASE WHEN '$arap' = 'ar' THEN -1 ELSE 1 END as used
+		  FROM $arap a
+                  JOIN acc_trans ac ON a.id = ac.trans_id
+                  JOIN account_link al ON al.account_id = ac.chart_id
+                                       AND al.description IN ('AR', 'AP')
 		 WHERE entity_credit_account = ?
                  UNION 
                 SELECT sum(o.amount * coalesce(e.$buysell, 1)) as used

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