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

SF.net SVN: ledger-smb: [1961] trunk/sql/modules/Payment.sql



Revision: 1961
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1961&view=rev
Author:   einhverfr
Date:     2007-12-07 12:56:43 -0800 (Fri, 07 Dec 2007)

Log Message:
-----------
Fixing some payment issues.

Modified Paths:
--------------
    trunk/sql/modules/Payment.sql

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2007-12-07 19:30:27 UTC (rev 1960)
+++ trunk/sql/modules/Payment.sql	2007-12-07 20:56:43 UTC (rev 1961)
@@ -117,7 +117,7 @@
 );
 
 CREATE OR REPLACE FUNCTION payment_get_all_contact_invoices
-(in_account_class int, in_business_type int, in_currency char(3),
+(in_account_class int, in_business_id int, in_currency char(3),
 	in_date_from date, in_date_to date, in_batch_id int, 
 	in_ar_ap_accno text)
 RETURNS SETOF payment_contact_invoice AS
@@ -159,13 +159,13 @@
 			ORDER BY transdate
 		         ) a USING (entity_id)
 		    JOIN transactions t ON (a.id = t.id)
-		   WHERE a.invoice_class = in_account_class
+		   WHERE a.id IN (select voucher.trans_id FROM voucher
+		                          WHERE batch_id = in_batch_id)
+		          OR (a.invoice_class = in_account_class
 			 AND c.business_id = 
-				coalesce(in_business_type, c.business_id)
+				coalesce(in_business_id, c.business_id)
 		         AND ((a.transdate >= COALESCE(in_date_from, a.transdate)
-		               AND a.transdate <= COALESCE(in_date_to, a.transdate))
-		             OR a.id IN (select voucher.trans_id FROM voucher
-		                          WHERE batch_id = in_batch_id))
+		               AND a.transdate <= COALESCE(in_date_to, a.transdate)))
 		         AND c.entity_class = in_account_class
 		         AND a.curr = in_currency
 		         AND a.entity_credit_account = c.id
@@ -180,7 +180,7 @@
 		                            chart_id = (SELECT id frOM chart
 		                                         WHERE accno
 		                                               = in_ar_ap_accno)
-		                    )
+		                    ))
 		GROUP BY c.id, e.name, c.meta_number, c.threshold
 		  HAVING sum(a.amount - a.paid) > c.threshold
 	LOOP
@@ -199,6 +199,7 @@
 business_type: integer of business.id.
 currency: char(3) of currency (for example 'USD')
 date_from, date_to:  These dates are inclusive.
+1;3B
 batch_id:  For payment batches, where fees are concerned.
 ar_ap_accno:  The AR/AP account number.
 


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