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

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



Revision: 2377
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2377&view=rev
Author:   einhverfr
Date:     2008-10-22 20:29:16 +0000 (Wed, 22 Oct 2008)

Log Message:
-----------
Corrected missing commit on draft deletion
Corrected inadequate cleanup on draft deletion

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Draft.pm
    trunk/sql/modules/Drafts.sql
    trunk/sql/modules/test/Draft.sql

Modified: trunk/LedgerSMB/DBObject/Draft.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Draft.pm	2008-10-20 19:22:39 UTC (rev 2376)
+++ trunk/LedgerSMB/DBObject/Draft.pm	2008-10-22 20:29:16 UTC (rev 2377)
@@ -24,6 +24,7 @@
        $self->error($self->{_locale}->text('No ID Set'));
    }
    ($self->{deleted}) = $self->exec_method(funcname => 'draft_delete');
+   $self->{dbh}->commit;
    return $self->{deleted};
 }
 

Modified: trunk/sql/modules/Drafts.sql
===================================================================
--- trunk/sql/modules/Drafts.sql	2008-10-20 19:22:39 UTC (rev 2376)
+++ trunk/sql/modules/Drafts.sql	2008-10-22 20:29:16 UTC (rev 2377)
@@ -91,7 +91,9 @@
 declare 
 	t_table text;
 begin
-	SELECT table_name into t_table FROM transactions where id = in_id;
+        DELETE FROM acc_trans WHERE trans_id = in_id;
+	SELECT lower(table_name) into t_table FROM transactions where id = in_id;
+
         IF t_table = 'ar' THEN
 		DELETE FROM ar WHERE id = in_id AND approved IS FALSE;
 	ELSIF t_table = 'ap' THEN
@@ -101,7 +103,10 @@
 	ELSE
 		raise exception 'Invalid table % in draft_delete for transaction %', t_table, in_id;
 	END IF;
-	RETURN FOUND;
+	IF NOT FOUND THEN
+		RAISE EXCEPTION 'Invalid transaction id %', in_id;
+	END IF;
+	RETURN TRUE;
 END;
 $$ LANGUAGE PLPGSQL SECURITY DEFINER;
 

Modified: trunk/sql/modules/test/Draft.sql
===================================================================
--- trunk/sql/modules/test/Draft.sql	2008-10-20 19:22:39 UTC (rev 2376)
+++ trunk/sql/modules/test/Draft.sql	2008-10-22 20:29:16 UTC (rev 2377)
@@ -63,8 +63,6 @@
 FROM draft__search('AR',  NULL, NULL, NULL, NULL, NULL)
 WHERE reference = '_TEST AR';
 
-SELECT *
-FROM draft__search('gl',  NULL, NULL, NULL, NULL, NULL);
 INSERT INTO test_result(test_name, success)
 SELECT '"gl" search successful', count(*) = 1
 FROM draft__search('gl',  NULL, NULL, NULL, NULL, NULL)
@@ -75,6 +73,15 @@
 FROM draft__search('GL',  NULL, NULL, NULL, NULL, NULL)
 WHERE reference = '_TEST GL';
 
+INSERT INTO test_result(test_name, success)
+SELECT 'gl draft deletion', draft_delete(currval('id')::int);
+
+INSERT INTO test_result(test_name, success)
+SELECT 'gl table cleanup', count(*) = 0 from gl where id = currval('id');
+
+INSERT INTO test_result(test_name, success)
+SELECT 'acc_trans table cleanup', count(*) = 0 from acc_trans where trans_id = currval('id');
+
 SELECT * FROM test_result;
 
 SELECT (select count(*) from test_result where success is true) 


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