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

SF.net SVN: ledger-smb:[3501] trunk/sql/Pg-database.sql



Revision: 3501
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3501&view=rev
Author:   einhverfr
Date:     2011-07-13 19:14:08 +0000 (Wed, 13 Jul 2011)

Log Message:
-----------
Rearranging tables so fkey works from invoice table

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

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2011-07-13 19:08:37 UTC (rev 3500)
+++ trunk/sql/Pg-database.sql	2011-07-13 19:14:08 UTC (rev 3501)
@@ -1056,58 +1056,6 @@
 
 CREATE INDEX acc_trans_voucher_id_idx ON acc_trans(voucher_id);
 --
-CREATE TABLE invoice (
-  id serial PRIMARY KEY,
-  trans_id int REFERENCES transactions(id),
-  parts_id int REFERENCES parts(id),
-  description text,
-  qty NUMERIC,
-  allocated integer,
-  sellprice NUMERIC,
-  precision int,
-  fxsellprice NUMERIC,
-  discount numeric,
-  assemblyitem bool DEFAULT 'f',
-  unit varchar(5),
-  project_id int,
-  deliverydate date,
-  serialnumber text,
-  notes text
-);
-
-COMMENT ON TABLE invoice IS
-$$Line items of invoices with goods/services attached.$$;
-
-COMMENT ON COLUMN invoice.allocated IS
-$$Number of allocated items, negative relative to qty.
-When qty + allocated = 0, then the item is fully used for purposes of COGS 
-calculations.$$;
-
-COMMENT ON COLUMN invoice.qty IS
-$$Positive is normal for sales invoices, negative for vendor invoices.$$;
-
--- Added for Entity but can't be added due to order
-ALTER TABLE invoice_note ADD FOREIGN KEY (ref_key) REFERENCES invoice(id);
-
---
-
---
-
--- THe following credit accounts are used for inventory adjustments.
-INSERT INTO entity (id, name, entity_class, control_code,country_id) 
-values (0, 'Inventory Entity', 1, 'AUTO-01','232');
-
-INSERT INTO company (legal_name, entity_id) 
-values ('Inventory Entity', 0);
-
-INSERT INTO entity_credit_account (entity_id, meta_number, entity_class)
-VALUES 
-(0, '00000', 1);
-INSERT INTO entity_credit_account (entity_id, meta_number, entity_class)
-VALUES 
-(0, '00000', 2);
-
-
 CREATE TABLE parts (
   id serial PRIMARY KEY,
   partnumber text,
@@ -1162,7 +1110,59 @@
 	
 CREATE UNIQUE INDEX parts_partnumber_index_u ON parts (partnumber) 
 WHERE obsolete is false;
+CREATE TABLE invoice (
+  id serial PRIMARY KEY,
+  trans_id int REFERENCES transactions(id),
+  parts_id int REFERENCES parts(id),
+  description text,
+  qty NUMERIC,
+  allocated integer,
+  sellprice NUMERIC,
+  precision int,
+  fxsellprice NUMERIC,
+  discount numeric,
+  assemblyitem bool DEFAULT 'f',
+  unit varchar(5),
+  project_id int,
+  deliverydate date,
+  serialnumber text,
+  notes text
+);
+
+COMMENT ON TABLE invoice IS
+$$Line items of invoices with goods/services attached.$$;
+
+COMMENT ON COLUMN invoice.allocated IS
+$$Number of allocated items, negative relative to qty.
+When qty + allocated = 0, then the item is fully used for purposes of COGS 
+calculations.$$;
+
+COMMENT ON COLUMN invoice.qty IS
+$$Positive is normal for sales invoices, negative for vendor invoices.$$;
+
+-- Added for Entity but can't be added due to order
+ALTER TABLE invoice_note ADD FOREIGN KEY (ref_key) REFERENCES invoice(id);
+
 --
+
+--
+
+-- THe following credit accounts are used for inventory adjustments.
+INSERT INTO entity (id, name, entity_class, control_code,country_id) 
+values (0, 'Inventory Entity', 1, 'AUTO-01','232');
+
+INSERT INTO company (legal_name, entity_id) 
+values ('Inventory Entity', 0);
+
+INSERT INTO entity_credit_account (entity_id, meta_number, entity_class)
+VALUES 
+(0, '00000', 1);
+INSERT INTO entity_credit_account (entity_id, meta_number, entity_class)
+VALUES 
+(0, '00000', 2);
+
+
+--
 CREATE TABLE assembly (
   id int REFERENCES parts(id),
   parts_id int REFERENCES parts(id),


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