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

SF.net SVN: ledger-smb:[5604] branches/1.3



Revision: 5604
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5604&view=rev
Author:   einhverfr
Date:     2013-01-17 19:06:30 +0000 (Thu, 17 Jan 2013)
Log Message:
-----------
Excluding unapproved payments from credit limit calculations

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

Property Changed:
----------------
    branches/1.3/


Property changes on: branches/1.3
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:3711-3712,5424,5446-5448,5451,5457,5459,5461,5466,5473,5475,5482-5483,5485,5487,5489,5495-5496,5515,5519,5524,5526,5528-5529,5533,5544-5546,5548-5549,5554-5555,5563,5565,5569,5576,5579,5589-5590,5597
   + /trunk:3711-3712,5424,5446-5448,5451,5457,5459,5461,5466,5473,5475,5482-5483,5485,5487,5489,5495-5496,5515,5519,5524,5526,5528-5529,5533,5544-5546,5548-5549,5554-5555,5563,5565,5569,5576,5579,5589-5590,5597,5602-5603

Modified: branches/1.3/LedgerSMB/AA.pm
===================================================================
--- branches/1.3/LedgerSMB/AA.pm	2013-01-17 19:04:14 UTC (rev 5603)
+++ branches/1.3/LedgerSMB/AA.pm	2013-01-17 19:06:30 UTC (rev 5604)
@@ -1350,12 +1350,15 @@
     my $ARAP = uc $arap;
 
     $form->{creditremaining} = $form->{creditlimit};
+    # acc_trans.approved is only false in the case of batch payments which 
+    # have not yet been approved.  Unapproved transactions set approved on the
+    # ar or ap record level.  --CT
     $query = qq|
                 SELECT sum(used) FROM (
 		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 acc_trans ac ON a.id = ac.trans_id and approved
                   JOIN account_link al ON al.account_id = ac.chart_id
                                        AND al.description IN ('AR', 'AP')
 		 WHERE entity_credit_account = ?

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