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

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



Revision: 2735
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2735&view=rev
Author:   einhverfr
Date:     2009-07-17 05:06:31 +0000 (Fri, 17 Jul 2009)

Log Message:
-----------
Sql schema fixes

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

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2009-07-16 05:34:18 UTC (rev 2734)
+++ trunk/sql/Pg-database.sql	2009-07-17 05:06:31 UTC (rev 2735)
@@ -90,6 +90,7 @@
   entity_class integer references entity_class(id) not null ,
   created date not null default current_date,
   control_code text,
+  country_id int references country(id) not null,
   PRIMARY KEY(control_code, entity_class));
   
 COMMENT ON TABLE entity IS $$ The primary entity table to map to all contacts $$;

Modified: trunk/sql/modules/chart.sql
===================================================================
--- trunk/sql/modules/chart.sql	2009-07-16 05:34:18 UTC (rev 2734)
+++ trunk/sql/modules/chart.sql	2009-07-17 05:06:31 UTC (rev 2735)
@@ -163,3 +163,28 @@
 $$ language plpgsql;
 COMMENT ON FUNCTION chart_list_cash(in_account_class int) IS
 $$ This function returns the overpayment accounts acording with in_account_class which must be 1 or 2 $$;
+
+CREATE OR REPLACE FUNCTION chart_list_discount(in_account_class int)
+RETURNS SETOF chart AS
+$$
+DECLARE resultrow record;
+        link_string text;
+BEGIN
+        IF in_account_class = 1 THEN
+           link_string := '%AP_discount%';
+        ELSE
+           link_string := '%AR_discount%';
+        END IF;
+
+        FOR resultrow IN
+          SELECT *  FROM chart
+          WHERE link LIKE link_string
+          ORDER BY accno
+          LOOP
+          return next resultrow;
+        END LOOP;
+END;
+$$ language plpgsql;
+
+COMMENT ON FUNCTION chart_list_discount(in_account_class int) IS
+$$ This function returns the discount accounts acording with in_account_class which must be 1 or 2 $$;


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