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

SF.net SVN: ledger-smb:[2660] trunk/sql/modules/test



Revision: 2660
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2660&view=rev
Author:   einhverfr
Date:     2009-06-12 17:57:49 +0000 (Fri, 12 Jun 2009)

Log Message:
-----------
Corrected test cases

Modified Paths:
--------------
    trunk/sql/modules/test/Account.sql
    trunk/sql/modules/test/Base.sql
    trunk/sql/modules/test/Reconciliation.sql
    trunk/sql/modules/test/Voucher.sql
    trunk/sql/modules/test/data/Reconciliation.sql

Modified: trunk/sql/modules/test/Account.sql
===================================================================
--- trunk/sql/modules/test/Account.sql	2009-06-12 17:06:04 UTC (rev 2659)
+++ trunk/sql/modules/test/Account.sql	2009-06-12 17:57:49 UTC (rev 2660)
@@ -16,7 +16,7 @@
 INSERT INTO ap (invnumber, netamount, amount, entity_credit_account, id) 
 VALUES ('TEST', '0', '0', -100, -100);
 INSERT INTO acc_trans (trans_id, chart_id, amount)
-VALUES (-100, currval('chart_id_seq')::int, '0');
+VALUES (-100, currval('account_id_seq')::int, '0');
 
 INSERT INTO chart (description, charttype, category, accno, link)
 VALUES ('TEST AP 1', 'A', 'L', '00003', 'AP');
@@ -79,7 +79,7 @@
 VALUES ('TEST AP Overpayment 4 INVALID', 'A', 'A', '00022', 'AR_overp');
 
 INSERT INTO test_result(test_name, success)
-VALUES ('Accounts created', currval('chart_id_seq') is not null);
+VALUES ('Accounts created', currval('account_id_seq') is not null);
 
 INSERT INTO test_result(test_name, success)
 VALUES ('Chart 1 is orphaned', account_has_transactions((select id from chart where description = 'TEST testing 1')) is false);
@@ -88,7 +88,7 @@
 VALUES ('Chart 2 is not orphaned', account_has_transactions((select id from chart where accno = '00002')) is true);
 
 INSERT INTO test_result(test_name, success)
-SELECT 'All Test Accounts Exist', count(*) = 22 FROM chart_list_all() 
+SELECT 'All Test Accounts Exist', count(*) = 23 FROM chart_list_all() 
 where accno like '0%' AND description LIKE 'TEST%';
 
 INSERT INTO test_result(test_name, success)

Modified: trunk/sql/modules/test/Base.sql
===================================================================
--- trunk/sql/modules/test/Base.sql	2009-06-12 17:06:04 UTC (rev 2659)
+++ trunk/sql/modules/test/Base.sql	2009-06-12 17:57:49 UTC (rev 2660)
@@ -2,3 +2,10 @@
 	test_name text,
 	success bool
 );
+
+select account_heading_save(NULL, '000000000000000000000', 'TEST', NULL);
+
+CREATE OR REPLACE FUNCTION test_get_account_id(in_accno text) returns int as
+$$ 
+SELECT id FROM chart WHERE accno = $1; 
+$$ language sql;

Modified: trunk/sql/modules/test/Reconciliation.sql
===================================================================
--- trunk/sql/modules/test/Reconciliation.sql	2009-06-12 17:06:04 UTC (rev 2659)
+++ trunk/sql/modules/test/Reconciliation.sql	2009-06-12 17:57:49 UTC (rev 2660)
@@ -15,10 +15,10 @@
 
 INSERT INTO test_result(test_name, success)
 SELECT 'Create Recon Report', 
-	reconciliation__new_report_id(-200, 100, now()::date) > 0;
+	reconciliation__new_report_id(test_get_account_id('-11111'), 100, now()::date) > 0;
 
 INSERT INTO test_result(test_name, success)
-SELECT 'Pending Transactions Ran', reconciliation__pending_transactions(now()::date, -200, currval('cr_report_id_seq')::int, 110) > 0;
+SELECT 'Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11111'), currval('cr_report_id_seq')::int, 110) > 0;
 
 INSERT INTO test_result(test_name, success)
 select 'Correct number of transactions 1', count(*) = 10 
@@ -47,21 +47,21 @@
 SELECT '1 Report Approved', reconciliation__report_approve(currval('cr_report_id_seq')::int) > 0;
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Transactions closed', count(*) = 2 FROM acc_trans where chart_id = -200 and cleared is false;
+SELECT '1 Transactions closed', count(*) = 2 FROM acc_trans where chart_id = test_get_account_id('-11111') and cleared is false;
 
 INSERT INTO test_result(test_name, success)
 SELECT '1 Create Recon Report', 
-	reconciliation__new_report_id(-201, 100, now()::date) > 0;
+	reconciliation__new_report_id(test_get_account_id('-11112'), 100, now()::date) > 0;
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, -201, currval('cr_report_id_seq')::int, 110) > 0;
+SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11112'), currval('cr_report_id_seq')::int, 110) > 0;
 
 INSERT INTO test_result(test_name, success)
 select 'Correct number of transactions 2', count(*) = 10 
 from cr_report_line where report_id = currval('cr_report_id_seq')::int;
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, -201, currval('cr_report_id_seq')::int, 110) > 0;
+SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11112'), currval('cr_report_id_seq')::int, 110) > 0;
 
 INSERT INTO test_result(test_name, success)
 select 'Correct number of transactions 3', count(*) = 10 
@@ -79,24 +79,23 @@
 
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Cleared balance pre-approval is 10', reconciliation__get_cleared_balance(-201) = 10;
+SELECT '1 Cleared balance pre-approval is 10', reconciliation__get_cleared_balance(test_get_account_id('-11112')) = -10;
 
 INSERT INTO test_result(test_name, success)
 SELECT '1 Report Approved', reconciliation__report_approve(currval('cr_report_id_seq')::int) > 0;
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Transactions open', count(*) = 14 FROM acc_trans where chart_id = -201 and cleared is false;
+SELECT '1 Transactions open', count(*) = 14 FROM acc_trans where chart_id = test_get_account_id('-11112') and cleared is false;
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Cleared balance post-approval is 10', reconciliation__get_cleared_balance(-201) = 10;
+SELECT '1 Cleared balance post-approval is 10', reconciliation__get_cleared_balance(test_get_account_id('-11112')) = -10;
 
-
 INSERT INTO test_result(test_name, success)
 SELECT '1 Create Recon Report', 
-	reconciliation__new_report_id(-201, 100, now()::date) > 0;
+	reconciliation__new_report_id(test_get_account_id('-11112'), 100, now()::date) > 0;
 
 INSERT INTO test_result(test_name, success)
-SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, -201, currval('cr_report_id_seq')::int, 110) > 0;
+SELECT '1 Pending Transactions Ran', reconciliation__pending_transactions(now()::date, test_get_account_id('-11112'), currval('cr_report_id_seq')::int, 110) > 0;
 
 INSERT INTO test_result(test_name, success)
 select 'Correct number of transactions 4', count(*) = 10 
@@ -111,18 +110,18 @@
 FROM reconciliation__report_summary(currval('cr_report_id_seq')::int);
 
 INSERT INTO test_result(test_name, success)
-SELECT 'Cleared balance pre-approval is 10', reconciliation__get_cleared_balance(-201) = 10;
+SELECT 'Cleared balance pre-approval is 10', reconciliation__get_cleared_balance(test_get_account_id('-11112')) = -10;
 
+
 INSERT INTO test_result(test_name, success)
 SELECT 'Report Approved', reconciliation__report_approve(currval('cr_report_id_seq')::int) > 0;
 
 INSERT INTO test_result(test_name, success)
-SELECT 'Transactions closed', count(*) = 2 FROM acc_trans where chart_id = -200 and cleared is false;
+SELECT 'Transactions closed', count(*) = 2 FROM acc_trans where chart_id = test_get_account_id('-11111') and cleared is false;
 
 INSERT INTO test_result(test_name, success)
-SELECT 'Cleared balance post-approval is 130', reconciliation__get_cleared_balance(-201) = 130;
+SELECT 'Cleared balance post-approval is 130', reconciliation__get_cleared_balance(test_get_account_id('-11112')) = -130;
 
-select * from cr_report_line where report_id = currval('cr_report_id_seq')::int;
 
 SELECT * FROM test_result;
 
@@ -131,5 +130,4 @@
 || (select count(*) from test_result where success is not true) 
 || ' failed' as message;
 
-
 ROLLBACK;

Modified: trunk/sql/modules/test/Voucher.sql
===================================================================
--- trunk/sql/modules/test/Voucher.sql	2009-06-12 17:06:04 UTC (rev 2659)
+++ trunk/sql/modules/test/Voucher.sql	2009-06-12 17:57:49 UTC (rev 2660)
@@ -12,20 +12,20 @@
 
 INSERT INTO entity_employee(entity_id) values (-3);
 
-INSERT INTO chart (id, accno, description, link)
-VALUES ('-5', '-21111', 'Testing AP', 'AP');
+INSERT INTO chart (id, accno, description, link, charttype, category)
+VALUES ('-5', '-21111', 'Testing AP', 'AP', 'A', 'A');
 
 INSERT INTO ap (id, invnumber, amount, curr, approved, entity_credit_account)
 VALUES (-5, 'test1', '1000', 'USD', false, -1);
 
 INSERT INTO acc_trans(trans_id, chart_id, amount, approved)
-values (-5, -5, 1000, true);
+values (-5, test_get_account_id('-21111'), 1000, true);
 
 INSERT INTO ap (id, invnumber, amount, curr, approved, entity_credit_account)
 VALUES (-6, 'test1', '1000', 'USD', false, -1);
 
 INSERT INTO acc_trans(trans_id, chart_id, amount, approved)
-values (-6, -5, 1000, true);
+values (-6, test_get_account_id('-21111'), 1000, true);
 INSERT INTO voucher (trans_id, batch_id, batch_class)
 values (-5, currval('batch_id_seq'), 1);
 INSERT INTO voucher (trans_id, batch_id, batch_class)

Modified: trunk/sql/modules/test/data/Reconciliation.sql
===================================================================
--- trunk/sql/modules/test/data/Reconciliation.sql	2009-06-12 17:06:04 UTC (rev 2659)
+++ trunk/sql/modules/test/data/Reconciliation.sql	2009-06-12 17:57:49 UTC (rev 2660)
@@ -1,7 +1,7 @@
 -- To run from other transaction test scripts!
 
-INSERT INTO chart (id, accno, description) values (-200, '-11111', 'Test Acct 1');
-INSERT INTO chart (id, accno, description) values (-201, '-11112', 'Test Acct 2');
+INSERT INTO chart (id, accno, description, category, charttype) values (-200, '-11111', 'Test Acct 1', 'A', 'A');
+INSERT INTO chart (id, accno, description, category, charttype) values (-201, '-11112', 'Test Acct 2', 'A', 'A');
 
 INSERT INTO entity (id, control_code, name, entity_class) values (-200, '-11111', 'Test 1', 1);
 
@@ -27,35 +27,37 @@
 INSERT INTO gl (id, reference, transdate, approved) values (-213, 'Unapproved gl trans', '1000-01-03', false);
 INSERT INTO gl (id, reference, transdate, approved) values (-214, 'gl trans, unapproved lines', '1000-01-03', false);
 
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-200, -200, '1000-01-01', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared, approved) values (-200, -200, '1000-01-01', -10, '1', true, false);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared, approved) values (-200, -201, '1000-01-01', 10, '1', true, false);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-200, -201, '1000-01-01', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-201, -200, '1000-01-03', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-201, -201, '1000-01-03', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-202, -200, '1000-01-01', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-202, -201, '1000-01-01', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-203, -200, '1000-01-01', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-203, -201, '1000-01-01', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-204, -200, '1000-01-01', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-204, -201, '1000-01-01', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-205, -200, '1000-01-03', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-205, -201, '1000-01-03', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-206, -200, '1000-01-01', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-206, -201, '1000-01-01', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-207, -200, '1000-01-03', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-207, -201, '1000-01-03', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-208, -200, '1000-01-01', -10, '2');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-208, -201, '1000-01-01', 10, '2');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-209, -200, '1000-01-03', -10, '2');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-209, -201, '1000-01-03', 10, '2');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-210, -200, '1000-01-03', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-210, -201, '1000-01-03', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-211, -200, '1000-01-03', -10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-211, -201, '1000-01-03', 10, '1');
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-212, -200, '1000-01-03', -10, '1', true);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-212, -201, '1000-01-03', 10, '1', true);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-213, -200, '1000-01-03', -10, '1', false);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-213, -201, '1000-01-03', 10, '1', false);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, approved) values (-214, -200, '1000-01-03', -10, '1', false);
-INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, approved) values (-214, -201, '1000-01-03', 10, '1', false);
+CREATE OR REPLACE FUNCTION test_get_account_id(in_accno text) returns int as $$ SELECT id FROM chart WHERE accno = $1; $$ language sql;
+
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-200, test_get_account_id('-11111'), '1000-01-01', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared, approved) values (-200, test_get_account_id('-11111'), '1000-01-01', -10, '1', true, false);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared, approved) values (-200, test_get_account_id('-11112'), '1000-01-01', 10, '1', true, false);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-200, test_get_account_id('-11112'), '1000-01-01', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-201, test_get_account_id('-11111'), '1000-01-03', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-201, test_get_account_id('-11112'), '1000-01-03', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-202, test_get_account_id('-11111'), '1000-01-01', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-202, test_get_account_id('-11112'), '1000-01-01', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-203, test_get_account_id('-11111'), '1000-01-01', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-203, test_get_account_id('-11112'), '1000-01-01', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-204, test_get_account_id('-11111'), '1000-01-01', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-204, test_get_account_id('-11112'), '1000-01-01', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-205, test_get_account_id('-11111'), '1000-01-03', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-205, test_get_account_id('-11112'), '1000-01-03', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-206, test_get_account_id('-11111'), '1000-01-01', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-206, test_get_account_id('-11112'), '1000-01-01', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-207, test_get_account_id('-11111'), '1000-01-03', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-207, test_get_account_id('-11112'), '1000-01-03', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-208, test_get_account_id('-11111'), '1000-01-01', -10, '2');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-208, test_get_account_id('-11112'), '1000-01-01', 10, '2');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-209, test_get_account_id('-11111'), '1000-01-03', -10, '2');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-209, test_get_account_id('-11112'), '1000-01-03', 10, '2');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-210, test_get_account_id('-11111'), '1000-01-03', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-210, test_get_account_id('-11112'), '1000-01-03', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-211, test_get_account_id('-11111'), '1000-01-03', -10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-211, test_get_account_id('-11112'), '1000-01-03', 10, '1');
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-212, test_get_account_id('-11111'), '1000-01-03', -10, '1', true);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-212, test_get_account_id('-11112'), '1000-01-03', 10, '1', true);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-213, test_get_account_id('-11111'), '1000-01-03', -10, '1', false);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-213, test_get_account_id('-11112'), '1000-01-03', 10, '1', false);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, approved) values (-214, test_get_account_id('-11111'), '1000-01-03', -10, '1', false);
+INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, approved) values (-214, test_get_account_id('-11112'), '1000-01-03', 10, '1', false);


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