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

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



Revision: 2343
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2343&view=rev
Author:   einhverfr
Date:     2008-09-26 01:38:47 +0000 (Fri, 26 Sep 2008)

Log Message:
-----------
Removing some hidden inputs from the payment details screen.

Modified Paths:
--------------
    trunk/UI/payments/payments_detail.html
    trunk/sql/modules/Payment.sql
    trunk/sql/modules/Session.sql
    trunk/sql/modules/test/Session.sql

Modified: trunk/UI/payments/payments_detail.html
===================================================================
--- trunk/UI/payments/payments_detail.html	2008-09-25 23:08:34 UTC (rev 2342)
+++ trunk/UI/payments/payments_detail.html	2008-09-26 01:38:47 UTC (rev 2343)
@@ -243,17 +243,7 @@
 		<?lsmb icount = icount + 1 ?>
 		<tr>
 			<td class="invoice_date_list">&nbsp;<?lsmb i.2 ?></td>
-			<input
-				name = "<?lsmb "invdate_$i.0" ?>"
-				type = "hidden"
-				value = "<?lsmb i.2 ?>"
-			/>
 			<td class="invoice_list">&nbsp;<?lsmb i.1 ?></td>
-			<input
-				name = "<?lsmb "invnumber_$i.0" ?>"
-				type = "hidden"
-				value = "<?lsmb i.1 ?>"
-			} ?>
 		        <td class="total_due_list">&nbsp;
 				<?lsmb i.3 ?></td>
 			<td class="paid_list">&nbsp;

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2008-09-25 23:08:34 UTC (rev 2342)
+++ trunk/sql/modules/Payment.sql	2008-09-26 01:38:47 UTC (rev 2343)
@@ -460,6 +460,7 @@
 		set paid = paid +in_transactions[out_count][2]
 		where id =in_transactions[out_count][1];
 	END LOOP;
+	perform unlock_all();
 	return out_count;
 END;
 $$ language plpgsql;

Modified: trunk/sql/modules/Session.sql
===================================================================
--- trunk/sql/modules/Session.sql	2008-09-25 23:08:34 UTC (rev 2342)
+++ trunk/sql/modules/Session.sql	2008-09-26 01:38:47 UTC (rev 2343)
@@ -72,3 +72,24 @@
 
 COMMENT ON FUNCTION session_check(int, text) IS 
 $$ Return code is 0 for failure, 1 for success. $$;
+
+CREATE OR REPLACE FUNCTION unlock_all() RETURNS BOOL AS
+$$
+BEGIN
+    UPDATE transactions SET locked_by = NULL 
+    where locked_by IN 
+          (select session_id from session WHERE users_id = 
+                  (SELECT id FROM users WHERE username = SESSION_USER));
+
+    RETURN FOUND;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION unlock(in_id int) RETURNS BOOL AS $$
+BEGIN
+    UPDATE transactions SET locked_by = NULL WHERE id = in_id 
+           AND locked_by IN (SELECT session_id FROM session WHERE users_id =
+		(SELECT id FROM users WHERE username = SESSION_USER));
+    RETURN FOUND;
+END;
+$$ LANGUAGE PLPGSQL;

Modified: trunk/sql/modules/test/Session.sql
===================================================================
--- trunk/sql/modules/test/Session.sql	2008-09-25 23:08:34 UTC (rev 2342)
+++ trunk/sql/modules/test/Session.sql	2008-09-26 01:38:47 UTC (rev 2343)
@@ -29,8 +29,30 @@
 INSERT INTO session (users_id, last_used, token, transaction_id)
 SELECT currval('users_id_seq'), now(), md5('test1'), 1;
 
+INSERT INTO test_result (test_name, success)
+SELECT 'records exist in transactions table', count(*) > 0 FROM transactions;
 
 INSERT INTO test_result (test_name, success)
+SELECT 'unlock record fails when record is not locked', unlock(max(id)) IS FALSE
+FROM transactions;
+
+INSERT INTO test_result (test_name, success)
+SELECT 'lock record', lock_record(max(id), currval('session_session_id_seq')::int)
+
+FROM transactions WHERE locked_by IS NULL;
+
+INSERT INTO test_result (test_name, success)
+SELECT 'unlock record', unlock(max(id))
+FROM transactions WHERE locked_by = currval('session_session_id_seq')::int;
+
+INSERT INTO test_result (test_name, success)
+SELECT 'lock all record', bool_and(lock_record(id, currval('session_session_id_seq')::int))
+FROM transactions WHERE locked_by IS NULL;
+
+INSERT INTO test_result (test_name, success)
+SELECT 'unlock all records', unlock_all();
+
+INSERT INTO test_result (test_name, success)
 values ('session1 retrieved', 
 (select t.token = md5('test1') 
 FROM session_check(
@@ -43,9 +65,6 @@
 VALUES ('session 2 removed', 
 (select count(*) from session where token = md5('test2') AND users_id = currval('users_id_seq')) = 0);
 
-DELETE FROM session WHERE users_id = currval('users_id_seq');
-DELETE FROM entity WHERE control_code = '_TESTING.....';
-
 SELECT * FROM test_result;
 
 SELECT (select count(*) from test_result where success is true) 
@@ -53,5 +72,4 @@
 || (select count(*) from test_result where success is not true) 
 || ' failed' as message;
 
-DROP TABLE test_result;
 ROLLBACK;


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