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

SF.net SVN: ledger-smb: [1911] trunk/sql



Revision: 1911
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1911&view=rev
Author:   einhverfr
Date:     2007-11-27 12:09:23 -0800 (Tue, 27 Nov 2007)

Log Message:
-----------
Fixing wrong index on location table

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

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2007-11-27 08:08:19 UTC (rev 1910)
+++ trunk/sql/Pg-database.sql	2007-11-27 20:09:23 UTC (rev 1911)
@@ -141,7 +141,6 @@
   inactive_date timestamp default null,
   active boolean not null default TRUE
 );
-CREATE INDEX location_unique_class_idx ON location (id,location_class);
   
 CREATE TABLE company (
   id serial UNIQUE,

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2007-11-27 08:08:19 UTC (rev 1910)
+++ trunk/sql/modules/Payment.sql	2007-11-27 20:09:23 UTC (rev 1911)
@@ -66,13 +66,13 @@
 		SELECT a.id AS invoice_id, a.invnumber, 
 		       a.transdate AS invoice_date, a.amount, 
 		       CASE WHEN discount_terms 
-		                 > extract('days' FROM age(a.transdate))
+		                 < extract('days' FROM age(a.transdate))
 		            THEN 0
 		            ELSE (a.amount - a.paid) * c.discount / 100  
 		       END AS discount,
 		       a.amount - a.paid - 
 		       CASE WHEN discount_terms 
-		                 > extract('days' FROM age(a.transdate))
+		                 < extract('days' FROM age(a.transdate))
 		            THEN 0
 		            ELSE (a.amount - a.paid) * c.discount / 100  
 		       END AS due
@@ -88,6 +88,7 @@
 		 WHERE a.invoice_class = in_account_class
 		       AND c.entity_class = in_account_class
 		       AND a.curr = in_curr
+		       AND a.entity_id = coalesce(in_entity_id, a.entity_id)
 	LOOP
 		RETURN NEXT payment_inv;
 	END LOOP;
@@ -346,4 +347,4 @@
     END;
 $$ language plpgsql;                                                                  
 COMMENT ON FUNCTION payment_get_vc_info(in_entity_id int) IS
-$$ This function return vendor or customer info, its under construction $$;
\ No newline at end of file
+$$ This function return vendor or customer info, its under construction $$;


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