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

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



Revision: 3448
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3448&view=rev
Author:   einhverfr
Date:     2011-07-05 15:10:18 +0000 (Tue, 05 Jul 2011)

Log Message:
-----------
Docstrings and cleanup to Location.sql

Modified Paths:
--------------
    trunk/LedgerSMB/Location.pm
    trunk/sql/modules/Location.sql

Added Paths:
-----------
    trunk/sql/modules/3448-drop-location-search.sql

Modified: trunk/LedgerSMB/Location.pm
===================================================================
--- trunk/LedgerSMB/Location.pm	2011-07-05 14:17:22 UTC (rev 3447)
+++ trunk/LedgerSMB/Location.pm	2011-07-05 15:10:18 UTC (rev 3448)
@@ -66,7 +66,7 @@
 
 sub get {
     my $self = shift;
-    my $ref = shift @{ $self->exec_method( procname => 'location_get' ) };
+    my $ref = shift @{ $self->exec_method( procname => 'location__get' ) };
     $self->merge( $ref, keys %{$ref} );
 }
 

Added: trunk/sql/modules/3448-drop-location-search.sql
===================================================================
--- trunk/sql/modules/3448-drop-location-search.sql	                        (rev 0)
+++ trunk/sql/modules/3448-drop-location-search.sql	2011-07-05 15:10:18 UTC (rev 3448)
@@ -0,0 +1,7 @@
+DROP FUNCTION location_search
+(in_companyname varchar, in_address1 varchar, in_address2 varchar,
+        in_city varchar, in_state varchar, in_zipcode varchar,
+        in_country varchar);
+
+DROP TYPE location_result CASCADE;
+

Modified: trunk/sql/modules/Location.sql
===================================================================
--- trunk/sql/modules/Location.sql	2011-07-05 14:17:22 UTC (rev 3447)
+++ trunk/sql/modules/Location.sql	2011-07-05 15:10:18 UTC (rev 3448)
@@ -13,6 +13,9 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON location_list_class() IS
+$$ Lists location classes, by default in order entered.$$;
+
 CREATE OR REPLACE FUNCTION location_list_country()
 RETURNS SETOF country AS
 $$
@@ -26,6 +29,9 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION location_list_country() IS
+$$ Lists countries, by default in alphabetical order.$$;
+
 CREATE OR REPLACE FUNCTION location_save
 (in_location_id int, in_address1 text, in_address2 text, in_address3 text,
 	in_city text, in_state text, in_zipcode text, in_country int) 
@@ -103,7 +109,7 @@
 used for mapping to other things.  This is necessary because locations are 
 only loosly coupled with entities, etc.$$;
 
-CREATE OR REPLACE FUNCTION location_get (in_id integer) returns location AS
+CREATE OR REPLACE FUNCTION location__get (in_id integer) returns location AS
 $$
 DECLARE
 	out_location location%ROWTYPE;
@@ -113,8 +119,11 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON location__get (in_id integer) IS
+$$ Returns the location specified by in_id.$$;
+
 CREATE OR REPLACE FUNCTION location_search 
-(in_companyname varchar, in_address1 varchar, in_address2 varchar, 
+(in_address1 varchar, in_address2 varchar, 
 	in_city varchar, in_state varchar, in_zipcode varchar, 
 	in_country varchar)
 RETURNS SETOF location
@@ -125,8 +134,7 @@
 BEGIN
 	FOR out_location IN
 		SELECT * FROM location 
-		WHERE companyname ilike '%' || in_companyname || '%'
-			AND address1 ilike '%' || in_address1 || '%'
+		WHERE address1 ilike '%' || in_address1 || '%'
 			AND address2 ilike '%' || in_address2 || '%'
 			AND in_city ilike '%' || in_city || '%'
 			AND in_state ilike '%' || in_state || '%'
@@ -138,6 +146,13 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION location_search
+(in_companyname varchar, in_address1 varchar, in_address2 varchar,
+        in_city varchar, in_state varchar, in_zipcode varchar,
+        in_country varchar) IS
+$$ Returns matching locations.  All matches may be partial.$$;
+
+
 CREATE OR REPLACE FUNCTION location_list_all () RETURNS SETOF location AS
 $$
 DECLARE 
@@ -145,13 +160,16 @@
 BEGIN
 	FOR out_location IN
 		SELECT * FROM location 
-		ORDER BY company_name, city, state, country
+		ORDER BY city, state, country
 	LOOP
 		RETURN NEXT out_location;
 	END LOOP;
 END;
 $$ LANGUAGE plpgsql;
 
+COMMENT ON FUNCTION location_list_all () is
+$$ Returns all locations, ordered by city, state, and country. $$;
+
 CREATE OR REPLACE FUNCTION location_delete (in_id integer) RETURNS VOID AS
 $$
 BEGIN
@@ -159,43 +177,6 @@
 END;
 $$ language plpgsql;
 
-CREATE TYPE location_result AS (
-	id int,
-	line_one text,
-	line_two text,
-	line_three text,
-	city text,
-	state text,
-        mail_code text,
-        country_id int,
-	country text,
-        class_id int,
-	class text
-);
+COMMENT ON FUNCTION location_delete (in_id integer)
+IS $$ DELETES the location specified by in_id.  Does not return a value.$$;
 
-CREATE OR REPLACE FUNCTION location__get(in_id int) returns location_result AS $$
-declare
-    l_row location_result;
-begin
-    FOR l_row IN 
-        SELECT 
-            l.id,                   
-            l.line_one,             
-            l.line_two,             
-            l.line_three,           
-            l.city,                 
-            l.state,                
-            l.mail_code,
-            c.id,
-            c.name as country,
-            NULL,
-            NULL
-        FROM location l
-        JOIN country c on l.country_id = c.id
-        WHERE l.id = in_id
-    LOOP
-    
-        return l_row;
-    END LOOP;
-END;
-$$ language plpgsql ;


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