summaryrefslogtreecommitdiff
path: root/t/data/62-request-data
blob: 58a52297d7ec5925f18c0f1226d1770c0ec10da3 (plain)
  1. use Test::More;
  2. our $test_request_data = [
  3. # AR/AP Transaction Screen Tests
  4. {
  5. '_test_id' => 'AR Transaction Screen',
  6. '_codebase' => 'old',
  7. 'module' => 'ar.pl',
  8. 'action' => 'add'
  9. },
  10. {
  11. '_test_id' => 'AP Transaction Screen',
  12. '_codebase' => 'old',
  13. 'module' => 'ap.pl',
  14. 'action' => 'add'
  15. },
  16. # Create Batch Screens
  17. {
  18. '_test_id' => 'AR Transaction Voucher Screen',
  19. '_codebase' => 'new',
  20. 'action' => 'create_batch',
  21. 'batch_type' => 'recievable',
  22. 'module' => 'vouchers.pl',
  23. },
  24. {
  25. '_test_id' => 'AP Transaction Voucher Screen',
  26. '_codebase' => 'new',
  27. 'action' => 'create_batch',
  28. 'batch_type' => 'payable',
  29. 'module' => 'vouchers.pl',
  30. },
  31. {
  32. '_test_id' => 'Payment Transaction Voucher Screen',
  33. '_codebase' => 'new',
  34. 'action' => 'create_batch',
  35. 'batch_type' => 'payment',
  36. 'module' => 'vouchers.pl',
  37. },
  38. {
  39. '_test_id' => 'Payment Reversal Transaction Voucher Screen',
  40. '_codebase' => 'new',
  41. 'action' => 'create_batch',
  42. 'batch_type' => 'payment_reversal',
  43. 'module' => 'vouchers.pl',
  44. },
  45. {
  46. '_test_id' => 'GL Transaction Voucher Screen',
  47. '_codebase' => 'new',
  48. 'action' => 'create_batch',
  49. 'batch_type' => 'gl',
  50. 'module' => 'vouchers.pl',
  51. },
  52. {
  53. '_test_id' => 'Payment source start error',
  54. '_codebase' => 'new',
  55. '_error_test' => 1,
  56. 'account_class' => 1,
  57. 'module' => 'payment.pl',
  58. 'action' => 'display_payments',
  59. 'approved' => 0,
  60. 'currency' => 'USD',
  61. 'datepaid' => '2008-07-22',
  62. },
  63. {
  64. '_test_id' => 'Payment source numbering',
  65. '_codebase' => 'new',
  66. '_error_test' => 1,
  67. 'account_class' => 1,
  68. 'start_source' => 1,
  69. 'module' => 'payment.pl',
  70. 'action' => 'update_payments',
  71. 'approved' => 0,
  72. 'currency' => 'USD',
  73. 'datepaid' => '2008-07-22',
  74. 'id_1' => 1,
  75. 'id_3' => 3,
  76. '_exec_override' => {
  77. 'payment_get_all_contact_invoices' => sub {
  78. my $self = shift;
  79. $retval = [ { contact_id => 1,
  80. total_due => Math::BigFloat->new(1000),
  81. econtrol_code => 'TEST1',
  82. eca_description => 'test',
  83. contact_name => 'test',
  84. account_number => 'test',
  85. invoices => '{{"100","101","2009-01-01",1000,1000}}',
  86. has_vouchers => 0,
  87. } ,
  88. {
  89. contact_id => 2,
  90. total_due => Math::BigFloat->new(1000),
  91. econtrol_code => 'TEST1',
  92. eca_description => 'test',
  93. contact_name => 'test',
  94. account_number => 'test',
  95. invoices => '{{101,101,2009-01-01,1000,1000}}',
  96. has_vouchers => 0,
  97. } ,
  98. {
  99. contact_id => 3,
  100. total_due => Math::BigFloat->new(1000),
  101. econtrol_code => 'TEST1',
  102. eca_description => 'test',
  103. contact_name => 'test',
  104. account_number => 'test',
  105. invoices => '{{102,101,2009-01-01,1000,1000}}',
  106. has_vouchers => 0,
  107. } ];
  108. $self->{contact_invoices} = $retval;
  109. $self->debug({'file' => '/tmp/test2'});
  110. return @$retval;
  111. }
  112. }
  113. },
  114. {
  115. '_test_id' => 'Payment print total',
  116. '_codebase' => 'new',
  117. 'action' => 'print',
  118. 'approved' => 0,
  119. 'currency' => 'USD',
  120. 'datepaid' => '2008-07-22',
  121. 'contact_1' => '25',
  122. 'id_25' => '25',
  123. 'paid_25' => 'all',
  124. 'payment_209' => '1000.00',
  125. 'invoice_25_1' => 209,
  126. 'net_209' => '1000.00',
  127. 'payment_210' => '-100.00',
  128. 'invoice_25_2' => '210',
  129. 'net_210' => '-100.00',
  130. 'payment_344' => '100000.00',
  131. 'invoice_25_3' => '344',
  132. 'net_344' => '100000.00',
  133. 'payment_352' => '1000.00',
  134. 'invoice_25_4' => '352',
  135. 'net_352' => '1000.00',
  136. 'payment_353' => '1000.00',
  137. 'invoice_25_5' => '353',
  138. 'net_353' => '1000.00',
  139. 'payment_354' => '1000.00',
  140. 'invoice_25_6' => '354',
  141. 'net_354' => '1000.00',
  142. 'payment_355' => '1000.00',
  143. 'invoice_25_7' => '355',
  144. 'net_355' => '1000.00',
  145. 'payment_356' => '1000.00',
  146. 'invoice_25_8' => '356',
  147. 'net_356' => '1000.00',
  148. 'invoice_count_25' => 8,
  149. 'contact_count' => 1,
  150. 'media' => 'screen',
  151. 'format' => 'PDF',
  152. 'module' => 'payment.pl',
  153. 'account_class' => 1,
  154. 'currency' => 'USD',
  155. 'multiple' => 1,
  156. },
  157. ];
  158. our $pre_test_subs = {
  159. 'Payment print total' => sub {
  160. $LedgerSMB::Sysconfig::check_max_invoices = 1;
  161. },
  162. };
  163. our $api_test_cases = {
  164. 'AR Transaction Voucher Screen' => sub {
  165. my $request = shift;
  166. ok($request->{batch_number}, 'Batch Number is Defined');
  167. },
  168. 'AP Transaction Voucher Screen' => sub {
  169. my $request = shift;
  170. ok($request->{batch_number}, 'Batch Number is Defined');
  171. },
  172. 'Payment Transaction Voucher Screen' => sub {
  173. my $request = shift;
  174. ok($request->{batch_number}, 'Batch Number is Defined');
  175. },
  176. 'Payment Reversal Transaction Voucher Screen' => sub {
  177. my $request = shift;
  178. ok($request->{batch_number}, 'Batch Number is Defined');
  179. },
  180. 'GL Transaction Voucher Screen' => sub {
  181. my $request = shift;
  182. ok($request->{batch_number}, 'Batch Number is Defined');
  183. },
  184. 'Payment print total' => sub {
  185. use strict;
  186. my $request = shift;
  187. $request->debug({file => '/tmp/check' });
  188. cmp_ok($request->{invoice_count_25}, '>', $LedgerSMB::Sysconfig::check_max_invoices, 'Test is valid under current config');
  189. cmp_ok(scalar @{$request->{checks}}, '==',
  190. $request->{contact_count},
  191. 'Correct number of checks printed');
  192. my $check = shift @{$request->{checks}};
  193. cmp_ok(
  194. $request->format_amount({
  195. amount => $check->{amount},
  196. format => '1000.00',
  197. precision => 2
  198. }), 'eq', '105900.00',
  199. 'Printed amount is correct'
  200. );
  201. },
  202. 'Payment source start error' => sub {
  203. my $self = shift;
  204. cmp_ok($self->{_error}, 'eq', 'No source start defined!',
  205. "Payment source start error: error correct");
  206. },
  207. 'Payment source numbering' => sub {
  208. my $self = shift;
  209. $self->debug({file => '/tmp/test'});
  210. ok(defined $self->{source_1},
  211. "$self->{_test_id} source 1 defined");
  212. cmp_ok($self->{source_2}, 'eq', '',
  213. "$self->{_test_id} source 2 not found");
  214. ok(defined $self->{source_3},
  215. "$self->{_test_id} source 3 defined");
  216. }
  217. };
  218. opendir (D62, 't/data/62.d');
  219. for my $testfile (readdir(D62)){
  220. do "t/data/62.d/$testfile";
  221. };
  222. # Overridden methods in classes for tests.
  223. package LedgerSMB::DBObject::Payment;
  224. sub exec_method {
  225. my $self = shift;
  226. my %args = @_;
  227. my $funcname = $args{funcname};
  228. if (ref $self->{_exec_override} eq 'HASH'){
  229. if ($self->{_exec_override}->{"$funcname"}){
  230. return $self->{_exec_override}->{"$args{funcname}"}($self);
  231. }
  232. }
  233. LedgerSMB::DBObject::exec_method($self, @_);
  234. }