summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-08 20:47:38 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-08 20:47:38 +0000
commit68399771603d9a2d084a9eaca480f17016801fe6 (patch)
tree02859ae3e2743f8b141a9837f703c21d77651759 /sql
parent7376ef357ac4dce6bf30548c773774dddd2ea033 (diff)
First round of tax code replacement, adds cumulative tax support
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@195 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rwxr-xr-xsql/Canada-French_General-chart.sql2
-rwxr-xr-xsql/Pg-tables.sql12
-rw-r--r--sql/Pg-upgrade-2.6.18-2.6.19.sql20
3 files changed, 31 insertions, 3 deletions
diff --git a/sql/Canada-French_General-chart.sql b/sql/Canada-French_General-chart.sql
index 647dd121..add09a73 100755
--- a/sql/Canada-French_General-chart.sql
+++ b/sql/Canada-French_General-chart.sql
@@ -73,6 +73,6 @@ INSERT INTO chart (accno,description,charttype,category,link,gifi_accno) VALUES
INSERT INTO chart (accno,description,charttype,category,link,gifi_accno) VALUES ('5800', 'Taxes d''affaires, droits d''adhésion et permis', 'A', 'E', 'AP_amount', '8760');
--
insert into tax (chart_id,rate) values ((select id from chart where accno = '2310'),0.06);
-insert into tax (chart_id,rate) values ((select id from chart where accno = '2320'),0.08025);
+insert into tax (chart_id,rate,pass) values ((select id from chart where accno = '2320'),0.08,1);
--
update defaults set inventory_accno_id = (select id from chart where accno = '1520'), income_accno_id = (select id from chart where accno = '4020'), expense_accno_id = (select id from chart where accno = '5010'), fxgain_accno_id = (select id from chart where accno = '4450'), fxloss_accno_id = (select id from chart where accno = '4450'), curr = 'CAD:USD:EUR', weightunit = 'kg';
diff --git a/sql/Pg-tables.sql b/sql/Pg-tables.sql
index 42471a15..40a81af8 100755
--- a/sql/Pg-tables.sql
+++ b/sql/Pg-tables.sql
@@ -12,7 +12,7 @@ CREATE SEQUENCE jcitemsid;
SELECT nextval ('jcitemsid');
--
-create table transactions (
+CREATE TABLE transactions (
id int PRIMARY KEY,
table_name text
);
@@ -243,12 +243,20 @@ CREATE TABLE partstax (
PRIMARY KEY (parts_id, chart_id)
);
--
+CREATE TABLE taxmodule (
+ taxmodule_id serial PRIMARY KEY,
+ taxmodulename text NOT NULL
+};
+--
CREATE TABLE tax (
chart_id int PRIMARY KEY,
rate numeric,
taxnumber text,
validto date,
- FOREIGN KEY (chart_id) REFERENCES chart (id)
+ pass integer DEFAULT 0 NOT NULL,
+ taxmodule_id int,
+ FOREIGN KEY (chart_id) REFERENCES chart (id),
+ FOREIGN KEY (taxmodule_id) REFERENCES taxmodule (taxmodule_id)
);
--
CREATE TABLE customertax (
diff --git a/sql/Pg-upgrade-2.6.18-2.6.19.sql b/sql/Pg-upgrade-2.6.18-2.6.19.sql
index 07541bde..d8e304f3 100644
--- a/sql/Pg-upgrade-2.6.18-2.6.19.sql
+++ b/sql/Pg-upgrade-2.6.18-2.6.19.sql
@@ -120,3 +120,23 @@ SET DEFAULT nextval('shipto_entry_id_seq');
UPDATE shipto SET entry_id = nextval('shipto_entry_id_seq');
ALTER TABLE shipto ADD PRIMARY KEY (entry_id);
+
+CREATE TABLE taxmodule (
+ taxmodule_id serial PRIMARY KEY,
+ taxmodulename text NOT NULL
+);
+
+INSERT INTO taxmodule (
+ taxmodule_id, taxmodulename
+ ) VALUES (
+ 1, 'Simple'
+);
+
+LOCK tax IN EXCLUSIVE MODE;
+ALTER TABLE tax ADD COLUMN pass int DEFAULT 0;
+UPDATE tax SET pass = 0;
+ALTER TABLE tax ALTER COLUMN pass SET NOT NULL;
+
+ALTER TABLE tax ADD COLUMN taxmodule_id int REFERENCES taxmodule DEFAULT 1;
+UPDATE tax SET taxmodule_id = 1;
+ALTER TABLE tax ALTER COLUMN taxmodule_id SET NOT NULL;