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

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



Revision: 3317
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3317&view=rev
Author:   einhverfr
Date:     2011-06-23 23:26:49 +0000 (Thu, 23 Jun 2011)

Log Message:
-----------
Corrections to Erik's tax change scripts

Modified Paths:
--------------
    trunk/sql/modules/Account.sql
    trunk/sql/upgrade/3290-tax-account.sql

Modified: trunk/sql/modules/Account.sql
===================================================================
--- trunk/sql/modules/Account.sql	2011-06-22 20:15:16 UTC (rev 3316)
+++ trunk/sql/modules/Account.sql	2011-06-23 23:26:49 UTC (rev 3317)
@@ -146,17 +146,17 @@
 $$ LANGUAGE PLPGSQL;
 
 
-CREATE RULE chart_i AS ON INSERT TO chart
+CREATE OR REPLACE RULE chart_i AS ON INSERT TO chart
 DO INSTEAD
-SELECT CASE WHEN new.charttype='H' THEN account_heading_save(new.id, new.accno, 
-new.description, NULL)
-ELSE account_save(new.id, new.accno, new.description, new.category, 
-new.gifi_accno, NULL, 
-CASE WHEN new.contra IS NULL THEN FALSE ELSE new.contra END,
-CASE WHEN new.tax IS NULL THEN FALSE ELSE new.tax END, 
-string_to_array(new.link, ':'))
+SELECT CASE WHEN new.charttype='H' THEN 
+ account_heading_save(new.id, new.accno, new.description, NULL)
+ELSE
+ account_save(new.id, new.accno, new.description, new.category,
+  new.gifi_accno, NULL,
+  CASE WHEN new.contra IS NULL THEN FALSE ELSE new.contra END,
+  CASE WHEN new.tax IS NULL THEN FALSE ELSE new.tax END,
+  string_to_array(new.link, ':'))
 END;
---
 
 CREATE OR REPLACE FUNCTION cr_coa_to_account_save(in_accno text, in_description text)
 RETURNS void AS $BODY$

Modified: trunk/sql/upgrade/3290-tax-account.sql
===================================================================
--- trunk/sql/upgrade/3290-tax-account.sql	2011-06-22 20:15:16 UTC (rev 3316)
+++ trunk/sql/upgrade/3290-tax-account.sql	2011-06-23 23:26:49 UTC (rev 3317)
@@ -87,6 +87,11 @@
 
 DROP VIEW chart CASCADE;
 
+CREATE VIEW chart AS
+SELECT id, accno, description, 'H' as charttype, NULL as category, NULL as link, NULL as account_heading, null as gifi_accno, false as contra, false as tax from account_heading UNION
+select c.id, c.accno, c.description, 'A' as charttype, c.category, concat_colon(l.description) as link, heading, gifi_accno, contra, tax from account c left join account_link l ON (c.id = l.account_id) group by c.id, c.accno, c.description, c.category, c.heading, c.gifi_accno, c.contra, c.tax;
+
+
 CREATE OR REPLACE RULE chart_i AS ON INSERT TO chart
 DO INSTEAD
 SELECT CASE WHEN new.charttype='H' THEN 


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