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

SF.net SVN: ledger-smb:[2459] trunk



Revision: 2459
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2459&view=rev
Author:   einhverfr
Date:     2009-02-24 00:56:53 +0000 (Tue, 24 Feb 2009)

Log Message:
-----------
New Reconciliation Test Suite in place.  Also corrects bug in reconciliation approval

Modified Paths:
--------------
    trunk/sql/modules/Reconciliaton.sql
    trunk/sql/modules/test/Reconciliation.sql
    trunk/t/43-dbtest.t

Added Paths:
-----------
    trunk/sql/modules/test/data/
    trunk/sql/modules/test/data/Reconciliation.sql

Modified: trunk/sql/modules/Reconciliaton.sql
===================================================================
--- trunk/sql/modules/Reconciliaton.sql	2009-02-22 21:48:16 UTC (rev 2458)
+++ trunk/sql/modules/Reconciliaton.sql	2009-02-24 00:56:53 UTC (rev 2459)
@@ -90,7 +90,8 @@
 	where id = in_report_id;
 
 	FOR current_row IN 
-		select as_array(ac.entry_id) as entries
+		SELECT compound_array(entries) AS entries FROM (
+			select as_array(ac.entry_id) as entries
 		FROM acc_trans ac
 		JOIN transactions t on (ac.trans_id = t.id)
 		JOIN (select id, entity_credit_account::text as ref, 'ar' as table FROM ar
@@ -100,14 +101,14 @@
 		      select id, reference, 'gl' as table FROM gl) gl
 			ON (gl.table = t.table_name AND gl.id = t.id)
 		LEFT JOIN cr_report_line rl ON (rl.report_id = in_report_id
-			AND ((rl.ledger_id = ac.trans_id 
+			AND ((rl.ledger_id = ac.entry_id 
 				AND ac.voucher_id IS NULL) 
 				OR (rl.voucher_id = ac.voucher_id)))
 		WHERE ac.cleared IS FALSE
 			AND ac.chart_id = (select chart_id from cr_report where id = in_report_id)
 		GROUP BY gl.ref, ac.source, ac.transdate,
 			ac.memo, ac.voucher_id, gl.table
-		HAVING count(rl.report_id) > 0
+		HAVING count(rl.report_id) > 0) a
 	LOOP
 		ac_entries := ac_entries || current_row.entries;
 	END LOOP;

Modified: trunk/sql/modules/test/Reconciliation.sql
===================================================================
--- trunk/sql/modules/test/Reconciliation.sql	2009-02-22 21:48:16 UTC (rev 2458)
+++ trunk/sql/modules/test/Reconciliation.sql	2009-02-24 00:56:53 UTC (rev 2459)
@@ -1,13 +1,39 @@
 BEGIN;
 \i Base.sql
+\i data/Reconciliation.sql
 
-INSERT INTO chart (id, accno, description, charttype, category)
-values (-100, -100, 'Test acct', 'A', 'A');
+INSERT INTO entity (id, control_code, name, entity_class) values (-50, 'Test User', 'Test User', 3);
+INSERT INTO person (id, entity_id, first_name, last_name) values (-50, -50, 'Test', 'Usr');
 
+INSERT INTO users (id, entity_id, username) values (-50, -50, SESSION_USER);
+
 INSERT INTO test_result(test_name, success)
 SELECT 'Create Recon Report', 
-	reconciliation__new_report_id(-100, 100, now()::date) > 0;
+	reconciliation__new_report_id(-200, 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) > 0;
+
+INSERT INTO test_result(test_name, success)
+SELECT 'Correct number of GL groups', count(*) = 4 from cr_report_line where scn like '% gl %' and report_id = currval('cr_report_id_seq')::int;
+
+INSERT INTO test_result(test_name, success)
+SELECT 'Correct number of report lines', count(*) = 10 from cr_report_line where report_id = currval('cr_report_id_seq')::int;
+
+
+INSERT INTO test_result(test_name, success)
+SELECT 'Report Submitted', reconciliation__submit_set(currval('cr_report_id_seq')::int, (select as_array(id::int) from cr_report_line where report_id = currval('cr_report_id_seq')::int));
+
+INSERT INTO test_result(test_name, success)
+SELECT 'Report Submitted', reconciliation__submit_set(currval('cr_report_id_seq')::int, (select as_array(id::int) from cr_report_line where report_id = currval('cr_report_id_seq')::int));
+
+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(*) = 0 FROM acc_trans where chart_id = -200 and cleared is false;
+
+
 SELECT * FROM test_result;
 
 SELECT (select count(*) from test_result where success is true) 

Added: trunk/sql/modules/test/data/Reconciliation.sql
===================================================================
--- trunk/sql/modules/test/data/Reconciliation.sql	                        (rev 0)
+++ trunk/sql/modules/test/data/Reconciliation.sql	2009-02-24 00:56:53 UTC (rev 2459)
@@ -0,0 +1,50 @@
+-- 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 entity (id, control_code, name, entity_class) values (-200, '-11111', 'Test 1', 1);
+
+INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class) values (-200, -200, 'T-11111', 1);
+INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class) values (-200, -201, 'T-11112', 1);
+
+
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-200, '-2000', '10', '10', '0', -200, '1000-01-01');
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-201, '-2001', '10', '10', '0', -200, '1000-01-03');
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-204, '-2002', '10', '10', '0', -200, '1000-01-01');
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-205, '-2003', '10', '10', '0', -200, '1000-01-03');
+
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-206, '-2004', '10', '10', '0', -201, '1000-01-01');
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-207, '-2005', '10', '10', '0', -201, '1000-01-03');
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-208, '-2006', '10', '10', '0', -201, '1000-01-01');
+INSERT INTO ar (id, invnumber, amount, netamount, paid, entity_credit_account, transdate) values (-209, '-2007', '10', '10', '0', -201, '1000-01-03');
+
+INSERT INTO gl (id, reference, transdate) values (-202, 'Recon gl test 1', '1000-01-01');
+INSERT INTO gl (id, reference, transdate) values (-203, 'Recon gl test 2', '1000-01-01');
+INSERT INTO gl (id, reference, transdate) values (-210, 'Recon gl test 3', '1000-01-03');
+INSERT INTO gl (id, reference, transdate) values (-211, 'Recon gl test 4', '1000-01-03');
+
+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) 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');

Modified: trunk/t/43-dbtest.t
===================================================================
--- trunk/t/43-dbtest.t	2009-02-22 21:48:16 UTC (rev 2458)
+++ trunk/t/43-dbtest.t	2009-02-24 00:56:53 UTC (rev 2459)
@@ -5,7 +5,7 @@
 	plan skip_all => 'Skipping all.  Told not to test db.';
 }
 else {
-	plan tests => 57;
+	plan tests => 64;
 	if (defined $ENV{LSMB_NEW_DB}){
 		$ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
 	}


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