diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-11-19 20:28:51 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-11-19 20:28:51 +0000 |
commit | 1da73e2fcbc5863ee770fe157e32c1070dabc1eb (patch) | |
tree | 8ea216c248f7141c2d2ee4b634cbdfe6c01a1fe5 /sql/modules | |
parent | 5a00285539a34d8ff8d7656e3e0bd4ff8e1f9e1a (diff) |
Test case for threshold now passes
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2406 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql/modules')
-rw-r--r-- | sql/modules/test/Payment.sql | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/sql/modules/test/Payment.sql b/sql/modules/test/Payment.sql index 9bed4948..1cc83e23 100644 --- a/sql/modules/test/Payment.sql +++ b/sql/modules/test/Payment.sql @@ -18,7 +18,7 @@ VALUES (-100, -100); INSERT INTO chart (accno, description, charttype, category, link) VALUES ('00001', 'testing', 'A', 'L', 'AP'); INSERT INTO chart (accno, description, charttype, category, link) -VALUES ('00002', 'testing2', 'A', 'E', 'AP'); +VALUES ('00002', 'testing2', 'A', 'E', 'AP_expense'); INSERT INTO session (users_id, last_used, token, transaction_id) values (currval('users_id_seq'), now(), md5('test2'), 2); @@ -32,20 +32,22 @@ VALUES (-101, 1, 'TEST VENDOR', 'TEST 2'); INSERT INTO company (id, legal_name, entity_id) VALUES (-101, 'TEST', -101); -INSERT INTO entity_credit_account (id, meta_number, threshold, entity_id, entity_class) -values (-101, 'TEST1', 100000, -101, 1); +INSERT INTO business (id, description) +values (-101, 'test'); + +INSERT INTO entity_credit_account (id, meta_number, threshold, entity_id, entity_class, business_id) +values (-101, 'TEST1', 100000, -101, 1, -101); INSERT INTO ap (invnumber, entity_credit_account, approved, amount, netamount, curr) -values ('test_hide', -101, false, '100000', '100000', 'USD'); +values ('test_hide', -101, false, '1', '1', 'USD'); INSERT INTO voucher (trans_id, batch_class, batch_id) VALUES (currval('id'), 1, currval('batch_id_seq')); INSERT INTO test_result(test_name, success) SELECT 'Payment Batch created', (SELECT batch_create('test', 'test', 'ap', now()::date)) IS NOT NULL; - -INSERT INTO ap (invnumber, entity_credit_account, approved, amount, netamount, curr, transdate) -values ('test_show', -101, false, '100000', '100000', 'USD', now()::date); +INSERT INTO ap (invnumber, entity_credit_account, approved, amount, netamount, curr, transdate, paid) +VALUES ('test_show2', -101, true, 100000, 100000, 'USD', now()::date, 0); INSERT INTO acc_trans (approved, transdate, amount, trans_id, chart_id) VALUES (true, now()::date, '100000', currval('id'), (select id from chart where accno = '00001')); @@ -53,6 +55,15 @@ VALUES (true, now()::date, '100000', currval('id'), (select id from chart where INSERT INTO acc_trans (approved, transdate, amount, trans_id, chart_id) VALUES (true, now()::date, '-100000', currval('id'), (select id from chart where accno = '00002')); +INSERT INTO ap (invnumber, entity_credit_account, approved, amount, netamount, curr, transdate, paid) +values ('test_show', -101, false, '1', '1', 'USD', now()::date, 0); + +INSERT INTO acc_trans (approved, transdate, amount, trans_id, chart_id) +VALUES (true, now()::date, '1', currval('id'), (select id from chart where accno = '00001')); + +INSERT INTO acc_trans (approved, transdate, amount, trans_id, chart_id) +VALUES (true, now()::date, '-1', currval('id'), (select id from chart where accno = '00002')); + INSERT INTO voucher (trans_id, batch_class, batch_id) VALUES (currval('id'), 1, currval('batch_id_seq')); @@ -66,16 +77,23 @@ VALUES ('Batch Voucher In Payment Selection', (SELECT test_convert_array(invoices) LIKE '%::test_show::%' FROM ( -SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', (select meta_number from entity_credit_account order by id asc limit 1)) +SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', 'TEST1') )p)); -SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', (select meta_number from entity_credit_account order by id asc limit 1)); +INSERT INTO test_result(test_name, success) +VALUES ('Threshold met', + (SELECT test_convert_array(invoices) LIKE '%::test_show2::%' + FROM + ( +SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', 'TEST1') +)p)); +SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', 'TEST1'); INSERT INTO test_result(test_name, success) VALUES ('Non-Batch Voucher Not In Payment Selection', (SELECT test_convert_array(invoices) NOT LIKE '%::test_hide::%' FROM - (SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', (select meta_number from entity_credit_account order by id asc limit 1)))p )); + (SELECT invoices FROM payment_get_all_contact_invoices(1, NULL, 'USD', NULL, NULL, currval('batch_id_seq')::int, '00001', 'TEST1'))p )); SELECT * FROM TEST_RESULT; @@ -84,4 +102,4 @@ SELECT (select count(*) from test_result where success is true) || (select count(*) from test_result where success is not true) || ' failed' as message; -ROLLBACK; +-- ROLLBACK; |