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

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



Revision: 5274
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5274&view=rev
Author:   einhverfr
Date:     2012-11-27 08:16:25 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
Adding db infrastructure for cash vs accrual tax forms

Modified Paths:
--------------
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Fixes.sql
    trunk/sql/modules/TaxForm.sql

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-11-27 08:04:38 UTC (rev 5273)
+++ trunk/sql/Pg-database.sql	2012-11-27 08:16:25 UTC (rev 5274)
@@ -497,6 +497,7 @@
    form_name text not null,
    id serial not null unique,
    default_reportable bool not null default false,
+   is_accrual bool not null default false;
    primary key(country_id, form_name)
 );
 

Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql	2012-11-27 08:04:38 UTC (rev 5273)
+++ trunk/sql/modules/Fixes.sql	2012-11-27 08:16:25 UTC (rev 5274)
@@ -1,10 +1,14 @@
 -- SQL Fixes for upgrades.  These must be safe to run repeatedly, or they must 
 -- fail transactionally.  Please:  one transaction per fix.  
 --
+-- These will be cleaned up going back no more than one beta.
+
 -- Chris Travers
 
 -- during 1.4m2
 
+-- BETA 1
+
 BEGIN;
 
 CREATE TABLE lsmb_group (
@@ -65,3 +69,9 @@
 ALTER TABLE file_transaction ADD FOREIGN KEY (ref_key) REFERENCES transactions(id);
 
 COMMIT;
+
+BEGIN;
+
+ALTER TABLE country_tax_form ADD is_accrual bool not null default false;
+
+COMMIT;

Modified: trunk/sql/modules/TaxForm.sql
===================================================================
--- trunk/sql/modules/TaxForm.sql	2012-11-27 08:04:38 UTC (rev 5273)
+++ trunk/sql/modules/TaxForm.sql	2012-11-27 08:16:25 UTC (rev 5274)
@@ -1,14 +1,18 @@
 BEGIN;
 
+DROP FUNCTION IF EXISTS tax_form__save(in_id int, in_country_id int,
+                          in_form_name text, in_default_reportable bool);
 CREATE OR REPLACE FUNCTION tax_form__save(in_id int, in_country_id int, 
-                          in_form_name text, in_default_reportable bool)
+                          in_form_name text, in_default_reportable bool, 
+                          in_is_accrual bool)
 RETURNS int AS
 $$
 BEGIN
         UPDATE country_tax_form 
            SET country_id = in_country_id,
                form_name =in_form_name,
-               default_reportable = coalesce(in_default_reportable,false)
+               default_reportable = coalesce(in_default_reportable,false),
+               is_accrual = coalesce(in_is_accrual, false)
          WHERE id = in_id;
 
         IF FOUND THEN
@@ -17,14 +21,16 @@
 
 	insert into country_tax_form(country_id,form_name, default_reportable) 
 	values (in_country_id, in_form_name, 
-                coalesce(in_default_reportable, false));
+                coalesce(in_default_reportable, false), 
+                coalesce(in_is_accrual, false));
 
 	RETURN currval('country_tax_form_id_seq');
 END;
 $$ LANGUAGE PLPGSQL;
 
 COMMENT ON FUNCTION tax_form__save(in_id int, in_country_id int,
-                          in_form_name text, in_default_reportable bool) IS
+                          in_form_name text, in_default_reportable bool,
+                          in_is_accrual bool) IS
 $$Saves tax form information to the database.$$;
 
 CREATE OR REPLACE FUNCTION tax_form__get(in_form_id int) 
@@ -51,13 +57,15 @@
    form_name text,
    country_id int,
    country_name text,
-   default_reportable bool
+   default_reportable bool,
+   is_accrual bool
 );
 
 CREATE OR REPLACE function tax_form__list_ext()
 RETURNS SETOF taxform_list AS
 $BODY$
-SELECT t.id, t.form_name, t.country_id, c.name, t.default_reportable
+SELECT t.id, t.form_name, t.country_id, c.name, t.default_reportable, 
+       t.is_accrual
   FROM country_tax_form t
   JOIN country c ON c.id = t.country_id
  ORDER BY c.name, t.form_name;

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