summaryrefslogtreecommitdiff
path: root/sql/modules/test/Account.sql
blob: 23597c8e811323572b09a235b1f9313b73e94734 (plain)
  1. BEGIN;
  2. \i Base.sql
  3. INSERT INTO chart (description, charttype, category, accno)
  4. VALUES ('TEST testing 1', 'A', 'A', '00001');
  5. INSERT INTO chart (description, charttype, category, accno)
  6. VALUES ('TEST testing 2', 'A', 'A', '00002');
  7. INSERT INTO ap (invnumber, netamount, amount) VALUES ('TEST', '0', '0');
  8. INSERT INTO acc_trans (trans_id, chart_id, amount)
  9. VALUES (currval('id')::int, currval('chart_id_seq')::int, '0');
  10. INSERT INTO chart (description, charttype, category, accno, link)
  11. VALUES ('TEST AP 1', 'A', 'L', '00003', 'AP');
  12. INSERT INTO chart (description, charttype, category, accno, link)
  13. VALUES ('TEST AP 2', 'A', 'L', '00004', 'AP');
  14. INSERT INTO chart (description, charttype, category, accno, link)
  15. VALUES ('TEST AR 1', 'A', 'A', '00005', 'AR');
  16. INSERT INTO chart (description, charttype, category, accno, link)
  17. VALUES ('TEST AR 2', 'A', 'A', '00006', 'AR');
  18. INSERT INTO chart (description, charttype, category, accno, link)
  19. VALUES ('TEST AR PAID 1', 'A', 'A', '00007', 'AR_paid');
  20. INSERT INTO chart (description, charttype, category, accno, link)
  21. VALUES ('TEST AR PAID 2', 'A', 'A', '00008', 'AR_paid1');
  22. INSERT INTO chart (description, charttype, category, accno, link)
  23. VALUES ('TEST AR PAID 3', 'A', 'A', '00009', 'IC_tax:AR_paid');
  24. INSERT INTO chart (description, charttype, category, accno, link)
  25. VALUES ('TEST AR PAID 4 INVALID', 'A', 'A', '00010', 'AR_p');
  26. INSERT INTO chart (description, charttype, category, accno, link)
  27. VALUES ('TEST AP PAID 1', 'A', 'A', '00011', 'AP_paid');
  28. INSERT INTO chart (description, charttype, category, accno, link)
  29. VALUES ('TEST AP PAID 2', 'A', 'A', '00012', 'AP_paid1');
  30. INSERT INTO chart (description, charttype, category, accno, link)
  31. VALUES ('TEST AP PAID 3', 'A', 'A', '00013', 'IC_tax:AP_paid');
  32. INSERT INTO chart (description, charttype, category, accno, link)
  33. VALUES ('TEST AP PAID 4 INVALID', 'A', 'A', '00014', 'AP_p');
  34. INSERT INTO chart (description, charttype, category, accno, link)
  35. VALUES ('TEST AP Overpayment 1', 'A', 'A', '00015', 'AP_overpayment');
  36. INSERT INTO chart (description, charttype, category, accno, link)
  37. VALUES ('TEST AP Overpayment 2', 'A', 'A', '00016', 'AP_overpayment1');
  38. INSERT INTO chart (description, charttype, category, accno, link)
  39. VALUES ('TEST AP Overpayment 3', 'A', 'A', '00017', 'IC_tax:AP_overpayment');
  40. INSERT INTO chart (description, charttype, category, accno, link)
  41. VALUES ('TEST AP Overpayment 4 INVALID', 'A', 'A', '00018', 'AP_overp');
  42. INSERT INTO chart (description, charttype, category, accno, link)
  43. VALUES ('TEST AP Overpayment 1', 'A', 'A', '00019', 'AR_overpayment');
  44. INSERT INTO chart (description, charttype, category, accno, link)
  45. VALUES ('TEST AP Overpayment 2', 'A', 'A', '00020', 'AR_overpayment1');
  46. INSERT INTO chart (description, charttype, category, accno, link)
  47. VALUES ('TEST AP Overpayment 3', 'A', 'A', '00021', 'IC_tax:AR_overpayment');
  48. INSERT INTO chart (description, charttype, category, accno, link)
  49. VALUES ('TEST AP Overpayment 4 INVALID', 'A', 'A', '00022', 'AR_overp');
  50. INSERT INTO test_result(test_name, success)
  51. VALUES ('Accounts created', currval('chart_id_seq') is not null);
  52. INSERT INTO test_result(test_name, success)
  53. VALUES ('Chart 1 is orphaned', account_has_transactions((select id from chart where description = 'TEST testing 1')) is false);
  54. INSERT INTO test_result(test_name, success)
  55. VALUES ('Chart 2 is not orphaned', account_has_transactions((select id from chart where accno = '00002')) is true);
  56. INSERT INTO test_result(test_name, success)
  57. SELECT 'All Test Accounts Exist', count(*) = 22 FROM chart_list_all()
  58. where accno like '0%' AND description LIKE 'TEST%';
  59. INSERT INTO test_result(test_name, success)
  60. SELECT 'List AR Cash Test Accounts', count(*) = 3 FROM chart_list_cash(2)
  61. where accno like '0%' AND description LIKE 'TEST%';
  62. INSERT INTO test_result(test_name, success)
  63. SELECT 'List AP Cash Test Accounts', count(*) = 3 FROM chart_list_cash(1)
  64. where accno like '0%' AND description LIKE 'TEST%';
  65. INSERT INTO test_result(test_name, success)
  66. SELECT 'List AP Overpayment Accts', count(*) = 3 FROM chart_list_overpayment(1)
  67. where accno like '0%' AND description LIKE 'TEST%';
  68. INSERT INTO test_result(test_name, success)
  69. SELECT 'List AR Overpayment Accts', count(*) = 3 FROM chart_list_overpayment(2)
  70. where accno like '0%' AND description LIKE 'TEST%';
  71. INSERT INTO test_result(test_name, success)
  72. SELECT 'Test AP Accounts Are Found', count(*) = 2 FROM chart_get_ar_ap(1)
  73. where accno like '0%' AND description LIKE 'TEST%';
  74. INSERT INTO test_result(test_name, success)
  75. SELECT 'Test AR Accounts Are Found', count(*) = 2 FROM chart_get_ar_ap(2)
  76. where accno like '0%' AND description LIKE 'TEST%';
  77. SELECT * FROM test_result;
  78. SELECT (select count(*) from test_result where success is true)
  79. || ' tests passed and '
  80. || (select count(*) from test_result where success is not true)
  81. || ' failed' as message;
  82. ROLLBACK;