summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-26 01:38:47 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-26 01:38:47 +0000
commitbe0fdf68acb96cd021608564fa3c7c40803fdee2 (patch)
tree73c4d574e0236d30964b964c57debfbfe6929195
parenta316a97097bf8bcf9a4f809faf30dd756e60563d (diff)
Removing some hidden inputs from the payment details screen.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2343 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--UI/payments/payments_detail.html10
-rw-r--r--sql/modules/Payment.sql1
-rw-r--r--sql/modules/Session.sql21
-rw-r--r--sql/modules/test/Session.sql26
4 files changed, 44 insertions, 14 deletions
diff --git a/UI/payments/payments_detail.html b/UI/payments/payments_detail.html
index 2c486e58..2fc92804 100644
--- a/UI/payments/payments_detail.html
+++ b/UI/payments/payments_detail.html
@@ -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;
diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql
index 24d1d730..ad2951a3 100644
--- a/sql/modules/Payment.sql
+++ b/sql/modules/Payment.sql
@@ -460,6 +460,7 @@ BEGIN
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;
diff --git a/sql/modules/Session.sql b/sql/modules/Session.sql
index 158c8c2e..9dcf378f 100644
--- a/sql/modules/Session.sql
+++ b/sql/modules/Session.sql
@@ -72,3 +72,24 @@ $$ LANGUAGE PLPGSQL;
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;
diff --git a/sql/modules/test/Session.sql b/sql/modules/test/Session.sql
index 97520bd1..bfcd37eb 100644
--- a/sql/modules/test/Session.sql
+++ b/sql/modules/test/Session.sql
@@ -29,6 +29,28 @@ select * from session_check(currval('session_session_id_seq')::int, md5('test1')
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',
@@ -43,9 +65,6 @@ INSERT INTO test_result (test_name, success)
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 (select count(*) from test_result where success is true)
|| (select count(*) from test_result where success is not true)
|| ' failed' as message;
-DROP TABLE test_result;
ROLLBACK;