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

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



Revision: 3018
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3018&view=rev
Author:   einhverfr
Date:     2010-06-28 20:24:30 +0000 (Mon, 28 Jun 2010)

Log Message:
-----------
More voucher deletion fixes and tests

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

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2010-06-28 18:18:14 UTC (rev 3017)
+++ trunk/sql/modules/Voucher.sql	2010-06-28 20:24:30 UTC (rev 3018)
@@ -434,7 +434,7 @@
 	SELECT as_array(trans_id) INTO t_transaction_ids
 	FROM voucher WHERE batch_id = in_batch_id AND batch_class IN (1, 2, 5);
 
-        DELETE FROM ac_tax_from WHERE entry_id in
+        DELETE FROM ac_tax_form WHERE entry_id in
                (select entry_id from acc_trans 
                  where trans_id = any(t_transaction_ids));
 
@@ -461,7 +461,7 @@
 BEGIN
 	SELECT * INTO voucher_row FROM voucher WHERE id = in_voucher_id;
 	IF voucher_row.batch_class IN (1, 2, 5) THEN
-                DELETE FROM ac_tax_form WHERE trans_id IN (
+                DELETE FROM ac_tax_form WHERE entry_id IN (
                        SELECT entry_id
                         from acc_trans
                        WHERE trans_id = voucher_row.trans_id);

Modified: trunk/sql/modules/test/Voucher.sql
===================================================================
--- trunk/sql/modules/test/Voucher.sql	2010-06-28 18:18:14 UTC (rev 3017)
+++ trunk/sql/modules/test/Voucher.sql	2010-06-28 20:24:30 UTC (rev 3018)
@@ -31,20 +31,30 @@
 INSERT INTO acc_trans(trans_id, chart_id, amount, approved, entry_id)
 values (-6, test_get_account_id('-21111'), 1000, true, -1);
 
+INSERT INTO voucher(id, trans_id, batch_id, batch_class)
+values (-6, -6, currval('batch_id_seq'), 1);
 
-
 INSERT INTO ac_tax_form (entry_id, reportable)
 values (-1, false);
 
-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)
-values (-5, currval('batch_id_seq'), 3);
-INSERT INTO voucher (trans_id, batch_id, batch_class)
-values (-5, currval('batch_id_seq'), 3);
+INSERT INTO ap (id, invnumber, amount, curr, approved, entity_credit_account)
+VALUES (-7, 'test1', '1000', 'USD', false, -1);
 
+INSERT INTO acc_trans(trans_id, chart_id, amount, approved, entry_id)
+values (-7, test_get_account_id('-21111'), 1000, true, -2);
+
+INSERT INTO ac_tax_form (entry_id, reportable)
+values (-2, false);
+
+INSERT INTO voucher (id, trans_id, batch_id, batch_class)
+values (-1, -5, currval('batch_id_seq'), 1);
+INSERT INTO voucher (id, trans_id, batch_id, batch_class)
+values (-2, -5, currval('batch_id_seq'), 3);
+INSERT INTO voucher (id, trans_id, batch_id, batch_class)
+values (-3, -5, currval('batch_id_seq'), 3);
+
 INSERT INTO test_result(test_name, success)
-select 'Voucher Seach finds Payable Vouchers',  count(*)=1 
+select 'Voucher Seach finds Payable Vouchers',  count(*)=2 
 from voucher_list( currval('batch_id_seq')::int);
 
 INSERT INTO test_result (test_name, success)
@@ -68,6 +78,21 @@
 INSERT INTO test_result(test_name, success)
 SELECT 'Delete voucher with tax_form', voucher__delete(-6) = 1;
 
+INSERT INTO test_result(test_name, success)
+SELECT 'not all tax form lines deleted', count(*) > 0
+FROM ac_tax_form;
+
+INSERT INTO test_result(test_name, success)
+select 'DELETED voucher does not exist', count(*) = 0
+FROM ap WHERE id = -6;
+
+INSERT INTO test_result(test_name, success)
+SELECT 'Delete batch', batch_delete(currval('batch_id_seq')::int) = 1;
+
+INSERT INTO test_result(test_name, success)
+SELECT 'Batch is deleted', count(*) = 0
+FROM batch where id = currval('batch_id_seq');
+
 SELECT * FROM test_result;
 
 SELECT (select count(*) from test_result where success is true) 

Modified: trunk/t/43-dbtest.t
===================================================================
--- trunk/t/43-dbtest.t	2010-06-28 18:18:14 UTC (rev 3017)
+++ trunk/t/43-dbtest.t	2010-06-28 20:24:30 UTC (rev 3018)
@@ -5,7 +5,7 @@
 	plan skip_all => 'Skipping all.  Told not to test db.';
 }
 else {
-	plan tests => 111;
+	plan tests => 115;
 	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.