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

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



Revision: 4914
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4914&view=rev
Author:   einhverfr
Date:     2012-06-18 13:00:48 +0000 (Mon, 18 Jun 2012)
Log Message:
-----------
all db tests passing

Modified Paths:
--------------
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Account.sql
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Drafts.sql
    trunk/sql/modules/Voucher.sql
    trunk/sql/modules/test/Company.sql
    trunk/sql/modules/test/Draft.sql
    trunk/sql/modules/test/Reconciliation.sql
    trunk/sql/modules/test/Voucher.sql

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/Pg-database.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -1118,6 +1118,7 @@
     trans_type text, 
     post_date date,
     ledger_id int,
+    voucher_id int references voucher(id),
     overlook boolean not null default 'f',
     cleared boolean not null default 'f'
 );
@@ -1201,8 +1202,6 @@
     line_type text references account_link_description,
     primary key (id)
 );
-ALTER TABLE cr_report_line ADD FOREIGN KEY (ledger_id) 
-REFERENCES journal_line(id);
 
 COMMENT ON TABLE journal_line IS
 $$ Replaces acc_trans as the main account transaction line table.$$;
@@ -1366,7 +1365,7 @@
 -- Although I am moving the primary key to voucher.id for now, as of 1.4, I 
 -- would expect trans_id to be primary key
 CREATE TABLE voucher (
-  trans_id int REFERENCES journal_entry(id) NOT NULL,
+  trans_id int REFERENCES transactions(id) NOT NULL,
   batch_id int references batch(id) not null,
   id serial PRIMARY KEY,
   batch_class int references batch_class(id) not null
@@ -2077,7 +2076,7 @@
 management data.$$;
 --
 CREATE TABLE yearend (
-  trans_id int PRIMARY KEY REFERENCES journal_entry(id),
+  trans_id int PRIMARY KEY REFERENCES gl(id),
   reversed bool default false,
   transdate date
 );
@@ -2307,7 +2306,7 @@
 );
 
 CREATE TABLE ac_tax_form (
-        entry_id int references journal_line(id) primary key,
+        entry_id int references acc_trans(id) primary key,
         reportable bool
 );
 

Modified: trunk/sql/modules/Account.sql
===================================================================
--- trunk/sql/modules/Account.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/Account.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -147,10 +147,10 @@
 END;
 $$ language plpgsql;
 
-COMMENT ON FUNCTION account_save
-(in_id int, in_accno text, in_description text, in_category char(1),
+COMMENT ON FUNCTION account__save
+(in_id int, in_accno text, in_description text, in_category char(1), 
 in_gifi_accno text, in_heading int, in_contra bool, in_tax bool,
-in_link text[], is_obsolete bool) IS
+in_link text[], in_obsolete bool, in_is_temp bool) IS
 $$ This deletes existing account_link entries, where the 
 account_link.description is not designated as a custom one in the 
 account_link_description table.
@@ -216,12 +216,12 @@
 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,
+ account__save(new.id, new.accno, new.description, new.category,
   new.gifi_accno, NULL,
   -- should these be rewritten as coalesces? --CT
   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, ':'), false)
+  string_to_array(new.link, ':'), false, false)
 END;
 
 CREATE OR REPLACE FUNCTION cr_coa_to_account_save(in_accno text, in_description text)

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/Company.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -971,18 +971,6 @@
 COMMENT ON FUNCTION entity__list_contacts(in_entity_id int) IS
 $$ Lists all contact info for the entity.$$;
 
-CREATE OR REPLACE FUNCTION entity__delete_bank_account(in_id int)
-RETURNS BOOL AS
-$$
-BEGIN
-
-DELETE FROM entity_bank_account WHERE id = in_id;
-
-RETURN FOUND;
-
-END;
-
-$$ LANGUAGE PLPGSQL;
 CREATE OR REPLACE FUNCTION entity__list_bank_account(in_entity_id int)
 RETURNS SETOF entity_bank_account AS
 $$

Modified: trunk/sql/modules/Drafts.sql
===================================================================
--- trunk/sql/modules/Drafts.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/Drafts.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -28,7 +28,7 @@
 			    END) as amount
 		FROM (
 			SELECT id, transdate, reference, 
-				description, false as invoice
+				description, false as invoice,
                                 approved from gl
 			WHERE lower(in_type) = 'gl'
 			UNION
@@ -50,7 +50,8 @@
 				or trans.transdate <= in_to_date)
 			AND trans.approved IS FALSE
 			AND v.id IS NULL
-		GROUP BY trans.id, trans.transdate, trans.description, trans.reference
+		GROUP BY trans.id, trans.transdate, trans.description, 
+                         trans.reference, trans.invoice
 		HAVING (in_with_accno IS NULL or in_with_accno = 
 			ANY(as_array(chart.accno)))
 		ORDER BY trans.reference

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/Voucher.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -83,7 +83,7 @@
                         v.batch_id, v.trans_id, a.transdate, bc.class
 
 		UNION ALL
-		SELECT v.id, a.source, a.memo, 
+		SELECT v.id, false, a.source, a.memo, 
 			v.batch_id, v.trans_id, 
 			CASE WHEN bc.class LIKE 'receipt%' THEN sum(a.amount) * -1
 			     ELSE sum(a.amount)  END, a.transdate, 
@@ -105,7 +105,7 @@
 		GROUP BY v.id, a.source, cr.meta_number, co.legal_name ,
                         a.memo, v.batch_id, v.trans_id, a.transdate, bc.class
 		UNION ALL
-		SELECT v.id, g.reference, g.description, 
+		SELECT v.id, false, g.reference, g.description, 
 			v.batch_id, v.trans_id,
 			sum(a.amount), g.transdate, 'GL'
 		FROM voucher v
@@ -468,8 +468,6 @@
 	DELETE FROM ap WHERE id = ANY(t_transaction_ids);
 	DELETE FROM gl WHERE id = ANY(t_transaction_ids);
 	DELETE FROM voucher WHERE batch_id = in_batch_id;
-	DELETE FROM payments_queue WHERE batch_id = in_batch_id;
-	DELETE FROM pending_job WHERE batch_id = in_batch_id;
 	DELETE FROM batch WHERE id = in_batch_id;
 	DELETE FROM transactions WHERE id = ANY(t_transaction_ids);
 

Modified: trunk/sql/modules/test/Company.sql
===================================================================
--- trunk/sql/modules/test/Company.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/test/Company.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -3,13 +3,13 @@
 
 INSERT INTO test_result (test_name, success)
 SELECT 'Saving Company', 
-	company_save (NULL, 'TESTING...', 1,'TESTING', 'TESTING', NULL, '1234', 232) 
+	company__save (NULL, 'TESTING...', 1,'TESTING', 'TESTING', NULL, '1234', 232, 'st-123', 'ubi-123-456-789') 
 		IS NOT NULL;
 
 
 INSERT INTO test_result (test_name, success)
 SELECT 'Saving Credit Acct', 
-	entity_credit_save(  NULL , 1, currval('entity_id_seq')::int, 'TEST', 0, false,
+	eca__save(  NULL , 1, currval('entity_id_seq')::int, 'TEST', 0, false,
 		0, 0, 0, 'test-123', NULL, NULL, NULL, 'USD', now()::date, now()::date,
 		0, -1000, NULL, NULL, NULL, NULL)
 	IS NOT NULL;

Modified: trunk/sql/modules/test/Draft.sql
===================================================================
--- trunk/sql/modules/test/Draft.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/test/Draft.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -7,10 +7,12 @@
 VALUES (-1000, '_testv', 1, -1000, -1000); 
 INSERT INTO entity_credit_account (id, meta_number, entity_class, entity_id, ar_ap_account_id)
 VALUES (-1001, '_testc', 2, -1000, -1000); 
-SELECT account_save
-       (NULL, '00001', 'test only', 'A', NULL, NULL, FALSE, FALSE,'{}');
-SELECT account_save
-       (NULL, '00002', 'test only', 'A', NULL, NULL, FALSE, FALSE,'{}');
+SELECT account__save
+       (NULL, '00001', 'test only', 'A', NULL, NULL, FALSE, FALSE,'{}', false, 
+       false);
+SELECT account__save
+       (NULL, '00002', 'test only', 'A', NULL, NULL, FALSE, FALSE,'{}', false, 
+       false);
 INSERT INTO ap (invnumber, entity_credit_account, amount, netamount, paid, 
 	approved, curr)
 select '_TEST AP', -1000, '100', '100', '0', FALSE, 'USD';

Modified: trunk/sql/modules/test/Reconciliation.sql
===================================================================
--- trunk/sql/modules/test/Reconciliation.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/test/Reconciliation.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -11,7 +11,7 @@
 
 INSERT INTO test_result(test_name, success)
 SELECT 'Create Recon Report', 
-	reconciliation__new_report_id(test_get_account_id('-11111'), 100, now()::date) > 0;
+	reconciliation__new_report_id(test_get_account_id('-11111'), 100, now()::date, false) > 0;
 
 INSERT INTO test_result(test_name, success)
 SELECT 'Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11111'), currval('cr_report_id_seq')::int, 110) > 0;
@@ -43,7 +43,7 @@
 
 INSERT INTO test_result(test_name, success)
 SELECT '1 Create Recon Report', 
-	reconciliation__new_report_id(test_get_account_id('-11112'), 100, now()::date) > 0;
+	reconciliation__new_report_id(test_get_account_id('-11112'), 100, now()::date, false) > 0;
 
 INSERT INTO test_result(test_name, success)
 SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11112'), currval('cr_report_id_seq')::int, 110) > 0;
@@ -87,7 +87,7 @@
 
 INSERT INTO test_result(test_name, success)
 SELECT '1 Create Recon Report', 
-	reconciliation__new_report_id(test_get_account_id('-11112'), 100, now()::date) > 0;
+	reconciliation__new_report_id(test_get_account_id('-11112'), 100, now()::date, false) > 0;
 
 INSERT INTO test_result(test_name, success)
 SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11112'), currval('cr_report_id_seq')::int, 110) > 0;

Modified: trunk/sql/modules/test/Voucher.sql
===================================================================
--- trunk/sql/modules/test/Voucher.sql	2012-06-18 12:25:28 UTC (rev 4913)
+++ trunk/sql/modules/test/Voucher.sql	2012-06-18 13:00:48 UTC (rev 4914)
@@ -55,7 +55,7 @@
 
 INSERT INTO test_result(test_name, success)
 select 'Voucher Seach finds Payable Vouchers',  count(*)=2 
-from voucher_list( currval('batch_id_seq')::int);
+from voucher__list( currval('batch_id_seq')::int);
 
 INSERT INTO test_result (test_name, success)
 SELECT 'partial payment support', count(*) > 1 

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