summaryrefslogtreecommitdiff
path: root/sql/modules/test/Voucher.sql
blob: 467d3d38a7765cf2e7cd953a29bce06d912886ac (plain)
  1. BEGIN;
  2. \i Base.sql
  3. INSERT INTO test_result (test_name, success)
  4. SELECT 'Batch Created',
  5. batch_create('_TEST', '_TEST', 'payment', '2008-01-01') IS NOT NULL;
  6. INSERT INTO entity (id, name, entity_class, control_code)
  7. values (-3, 'Test', 1, 'test');
  8. INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class)
  9. values (-3, -1, 'Test', 1);
  10. INSERT INTO chart (id, accno, description, link)
  11. VALUES ('-5', '-21111', 'Testing AP', 'AP');
  12. INSERT INTO ap (id, invnumber, amount, curr, approved, entity_credit_account)
  13. VALUES (-5, 'test1', '1000', 'USD', false, -1);
  14. INSERT INTO acc_trans(trans_id, chart_id, amount, approved)
  15. values (-5, -5, 1000, true);
  16. INSERT INTO voucher (trans_id, batch_id, batch_class)
  17. values (-5, currval('batch_id_seq'), 1);
  18. INSERT INTO voucher (trans_id, batch_id, batch_class)
  19. values (-5, currval('batch_id_seq'), 3);
  20. INSERT INTO voucher (trans_id, batch_id, batch_class)
  21. values (-5, currval('batch_id_seq'), 3);
  22. INSERT INTO test_result(test_name, success)
  23. select 'Voucher Seach finds Payable Vouchers', count(*)=1
  24. from voucher_list( currval('batch_id_seq')::int);
  25. INSERT INTO test_result (test_name, success)
  26. SELECT 'partial payment support', count(*) > 1
  27. FROM voucher where trans_id = -5 and batch_class = 3;
  28. SELECT * FROM test_result;
  29. SELECT (select count(*) from test_result where success is true)
  30. || ' tests passed and '
  31. || (select count(*) from test_result where success is not true)
  32. || ' failed' as message;
  33. ROLLBACK;