summaryrefslogtreecommitdiff
path: root/bin/lynx/aa.pl
blob: 5fbb9c933f8f8d4572354f2f1206c29f8455912e (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # Copyright (c) 2005
  4. #
  5. # Author: DWS Systems Inc.
  6. # Web: http://sourceforge.net/projects/ledger-smb/
  7. #
  8. # Contributors:
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. #======================================================================
  23. #
  24. # AR / AP
  25. #
  26. #======================================================================
  27. # any custom scripts for this one
  28. if (-f "$form->{path}/custom_aa.pl") {
  29. eval { require "$form->{path}/custom_aa.pl"; };
  30. }
  31. if (-f "$form->{path}/$form->{login}_aa.pl") {
  32. eval { require "$form->{path}/$form->{login}_aa.pl"; };
  33. }
  34. 1;
  35. # end of main
  36. # this is for our long dates
  37. # $locale->text('January')
  38. # $locale->text('February')
  39. # $locale->text('March')
  40. # $locale->text('April')
  41. # $locale->text('May ')
  42. # $locale->text('June')
  43. # $locale->text('July')
  44. # $locale->text('August')
  45. # $locale->text('September')
  46. # $locale->text('October')
  47. # $locale->text('November')
  48. # $locale->text('December')
  49. # this is for our short month
  50. # $locale->text('Jan')
  51. # $locale->text('Feb')
  52. # $locale->text('Mar')
  53. # $locale->text('Apr')
  54. # $locale->text('May')
  55. # $locale->text('Jun')
  56. # $locale->text('Jul')
  57. # $locale->text('Aug')
  58. # $locale->text('Sep')
  59. # $locale->text('Oct')
  60. # $locale->text('Nov')
  61. # $locale->text('Dec')
  62. sub add {
  63. $form->{title} = "Add";
  64. $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
  65. &create_links;
  66. $form->{focus} = "amount_1";
  67. &display_form;
  68. }
  69. sub edit {
  70. $form->{title} = "Edit";
  71. &create_links;
  72. &display_form;
  73. }
  74. sub display_form {
  75. &form_header;
  76. &form_footer;
  77. }
  78. sub create_links {
  79. $form->create_links($form->{ARAP}, \%myconfig, $form->{vc});
  80. $duedate = $form->{duedate};
  81. $taxincluded = $form->{taxincluded};
  82. $form->{formname} = "transaction";
  83. $form->{format} = "postscript" if $myconfig{printer};
  84. $form->{media} = $myconfig{printer};
  85. $form->{selectformname} = qq|<option value="transaction">|.$locale->text('Transaction');
  86. if ($latex) {
  87. if ($form->{ARAP} eq 'AR') {
  88. $form->{selectformname} .= qq|
  89. <option value="receipt">|.$locale->text('Receipt');
  90. } else {
  91. $form->{selectformname} .= qq|
  92. <option value="check">|.$locale->text('Check');
  93. }
  94. }
  95. # currencies
  96. @curr = split /:/, $form->{currencies};
  97. $form->{defaultcurrency} = $curr[0];
  98. chomp $form->{defaultcurrency};
  99. for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  100. AA->get_name(\%myconfig, \%$form);
  101. $form->{currency} =~ s/ //g;
  102. $form->{duedate} = $duedate if $duedate;
  103. $form->{taxincluded} = $taxincluded if $form->{id};
  104. $form->{notes} = $form->{intnotes} if !$form->{id};
  105. $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
  106. $form->{oldtransdate} = $form->{transdate};
  107. # customers/vendors
  108. $form->{"select$form->{vc}"} = "";
  109. if (@{ $form->{"all_$form->{vc}"} }) {
  110. $form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
  111. for (@{ $form->{"all_$form->{vc}"} }) { $form->{"select$form->{vc}"} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  112. }
  113. # departments
  114. if (@{ $form->{all_department} }) {
  115. $form->{selectdepartment} = "<option>\n";
  116. $form->{department} = "$form->{department}--$form->{department_id}" if $form->{department_id};
  117. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  118. }
  119. $form->{employee} = "$form->{employee}--$form->{employee_id}";
  120. # sales staff
  121. if (@{ $form->{all_employee} }) {
  122. $form->{selectemployee} = "";
  123. for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  124. }
  125. # projects
  126. if (@{ $form->{all_project} }) {
  127. $form->{selectprojectnumber} = "<option>\n";
  128. for (@{ $form->{all_project} }) { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| }
  129. }
  130. if (@{ $form->{all_language} }) {
  131. $form->{selectlanguage} = "<option>\n";
  132. for (@{ $form->{all_language} }) { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| }
  133. }
  134. # forex
  135. $form->{forex} = $form->{exchangerate};
  136. $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
  137. $netamount = 0;
  138. $tax = 0;
  139. $taxrate = 0;
  140. $ml = ($form->{ARAP} eq 'AR') ? 1 : -1;
  141. foreach $key (keys %{ $form->{"$form->{ARAP}_links"} }) {
  142. $form->{"select$key"} = "";
  143. foreach $ref (@{ $form->{"$form->{ARAP}_links"}{$key} }) {
  144. if ($key eq "$form->{ARAP}_tax") {
  145. $form->{"select$form->{ARAP}_tax_$ref->{accno}"} = "<option>$ref->{accno}--$ref->{description}\n";
  146. next;
  147. }
  148. $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
  149. }
  150. # if there is a value we have an old entry
  151. for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
  152. if ($key eq "$form->{ARAP}_paid") {
  153. $form->{"$form->{ARAP}_paid_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
  154. $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i-1]->{amount} * -1 * $ml;
  155. $form->{"datepaid_$i"} = $form->{acc_trans}{$key}->[$i-1]->{transdate};
  156. $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i-1]->{source};
  157. $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i-1]->{memo};
  158. $form->{"forex_$i"} = $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i-1]->{exchangerate};
  159. $form->{paidaccounts}++;
  160. } else {
  161. $akey = $key;
  162. $akey =~ s/$form->{ARAP}_//;
  163. if ($key eq "$form->{ARAP}_tax") {
  164. $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
  165. $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = $form->{acc_trans}{$key}->[$i-1]->{amount} * $ml;
  166. $tax += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
  167. $taxrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
  168. } else {
  169. $form->{"${akey}_$i"} = $form->{acc_trans}{$key}->[$i-1]->{amount} * $ml;
  170. if ($akey eq 'amount') {
  171. $form->{"description_$i"} = $form->{acc_trans}{$key}->[$i-1]->{memo};
  172. $form->{rowcount}++;
  173. $netamount += $form->{"${akey}_$i"};
  174. $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}--$form->{acc_trans}{$key}->[$i-1]->{project_id}" if $form->{acc_trans}{$key}->[$i-1]->{project_id};
  175. } else {
  176. $form->{invtotal} = $form->{acc_trans}{$key}->[$i-1]->{amount} * -1 * $ml;
  177. }
  178. $form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
  179. }
  180. }
  181. }
  182. }
  183. $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
  184. if ($form->{taxincluded}) {
  185. $diff = 0;
  186. # add tax to individual amounts
  187. for $i (1 .. $form->{rowcount}) {
  188. if ($netamount) {
  189. $amount = $form->{"amount_$i"} * (1 + $tax / $netamount);
  190. $form->{"amount_$i"} = $form->round_amount($amount, 2);
  191. }
  192. }
  193. }
  194. $form->{invtotal} = $netamount + $tax;
  195. # check if calculated is equal to stored
  196. # taxincluded is terrible to calculate
  197. # this works only if all taxes are checked
  198. @taxaccounts = split / /, $form->{taxaccounts};
  199. if ($form->{id}) {
  200. if ($form->{taxincluded}) {
  201. $ml = 1;
  202. for (0 .. 1) {
  203. $taxrate = 0;
  204. $diff = 0;
  205. for (@taxaccounts) { $taxrate += $form->{"${_}_rate"} if ($form->{"${_}_rate"} * $ml) > 0 }
  206. $taxrate *= $ml;
  207. foreach $item (@taxaccounts) {
  208. if (($form->{"${item}_rate"} * $ml) > 0) {
  209. if ($taxrate) {
  210. $amount = $form->{invtotal} * $form->{"${item}_rate"} / (1 + $taxrate);
  211. $tax = $form->round_amount($amount, 2);
  212. $tax{$item} = $form->round_amount($amount - $diff, 2);
  213. $diff = $tax{$item} - ($amount - $diff);
  214. if ($tax) {
  215. if ($form->{"tax_$item"} == $tax{$item}) {
  216. $form->{"calctax_$item"} = 1;
  217. }
  218. }
  219. }
  220. }
  221. }
  222. $ml *= -1;
  223. }
  224. } else {
  225. for (@taxaccounts) {
  226. $tax = $form->round_amount($netamount * $form->{"${_}_rate"}, 2);
  227. if ($tax) {
  228. if ($form->{"tax_$_"} == $tax) {
  229. $form->{"calctax_$_"} = 1;
  230. }
  231. }
  232. }
  233. }
  234. } else {
  235. for (@taxaccounts) { $form->{"calctax_$_"} = 1 }
  236. }
  237. $form->{rowcount}++ if ($form->{id} || !$form->{rowcount});
  238. $form->{$form->{ARAP}} = $form->{"$form->{ARAP}_1"};
  239. $form->{rowcount} = 1 unless $form->{"$form->{ARAP}_amount_1"};
  240. $form->{locked} = ($form->{revtrans}) ? '1' : ($form->datetonum(\%myconfig, $form->{transdate}) <= $form->datetonum(\%myconfig, $form->{closedto}));
  241. # readonly
  242. if (! $form->{readonly}) {
  243. $form->{readonly} = 1 if $myconfig{acs} =~ /$form->{ARAP}--Add Transaction/;
  244. }
  245. }
  246. sub form_header {
  247. $title = $form->{title};
  248. $form->{title} = $locale->text("$title $form->{ARAP} Transaction");
  249. $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
  250. # $locale->text('Add AR Transaction')
  251. # $locale->text('Edit AR Transaction')
  252. # $locale->text('Add AP Transaction')
  253. # $locale->text('Edit AP Transaction')
  254. # set option selected
  255. for ("$form->{ARAP}", "currency") {
  256. $form->{"select$_"} =~ s/ selected//;
  257. $form->{"select$_"} =~ s/<option>\Q$form->{$_}\E/<option selected>$form->{$_}/;
  258. }
  259. for ("$form->{vc}", "department", "employee", "formname") {
  260. $form->{"select$_"} = $form->unescape($form->{"select$_"});
  261. $form->{"select$_"} =~ s/ selected//;
  262. $form->{"select$_"} =~ s/(<option value="\Q$form->{$_}\E")/$1 selected/;
  263. }
  264. $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber});
  265. # format amounts
  266. $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
  267. $exchangerate = qq|<tr>|;
  268. $exchangerate .= qq|
  269. <th align=right nowrap>|.$locale->text('Currency').qq|</th>
  270. <td><select name=currency>$form->{selectcurrency}</select></td> | if $form->{defaultcurrency};
  271. $exchangerate .= qq|
  272. <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
  273. <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
  274. |;
  275. if ($form->{defaultcurrency} && $form->{currency} ne $form->{defaultcurrency}) {
  276. if ($form->{forex}) {
  277. $exchangerate .= qq|
  278. <th align=right>|.$locale->text('Exchange Rate').qq|</th>
  279. <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
  280. |;
  281. } else {
  282. $exchangerate .= qq|
  283. <th align=right>|.$locale->text('Exchange Rate').qq|</th>
  284. <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
  285. |;
  286. }
  287. }
  288. $exchangerate .= qq|
  289. <input type=hidden name=forex value=$form->{forex}>
  290. </tr>
  291. |;
  292. $taxincluded = "";
  293. if ($form->{taxaccounts}) {
  294. $taxincluded = qq|
  295. <tr>
  296. <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
  297. <th align=left nowrap>|.$locale->text('Tax Included').qq|</th>
  298. </tr>
  299. |;
  300. }
  301. if (($rows = $form->numtextrows($form->{notes}, 50) - 1) < 2) {
  302. $rows = 2;
  303. }
  304. $notes = qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
  305. $department = qq|
  306. <tr>
  307. <th align="right" nowrap>|.$locale->text('Department').qq|</th>
  308. <td colspan=3><select name=department>$form->{selectdepartment}</select>
  309. <input type=hidden name=selectdepartment value="|.$form->escape($form->{selectdepartment},1).qq|">
  310. </td>
  311. </tr>
  312. | if $form->{selectdepartment};
  313. $n = ($form->{creditremaining} < 0) ? "0" : "1";
  314. $name = ($form->{"select$form->{vc}"}) ? qq|<select name="$form->{vc}">$form->{"select$form->{vc}"}</select>| : qq|<input name="$form->{vc}" value="$form->{$form->{vc}}" size=35>|;
  315. $employee = qq|
  316. <input type=hidden name=employee value="$form->{employee}">
  317. |;
  318. if ($form->{selectemployee}) {
  319. $label = ($form->{ARAP} eq 'AR') ? $locale->text('Salesperson') : $locale->text('Employee');
  320. $employee = qq|
  321. <tr>
  322. <th align=right nowrap>$label</th>
  323. <td><select name=employee>$form->{selectemployee}</select></td>
  324. <input type=hidden name=selectemployee value="|.$form->escape($form->{selectemployee},1).qq|">
  325. </tr>
  326. |;
  327. }
  328. $focus = ($form->{focus}) ? $form->{focus} : "amount_$form->{rowcount}";
  329. $form->header;
  330. print qq|
  331. <body onload="document.forms[0].${focus}.focus()" />
  332. <form method=post action=$form->{script}>
  333. <input type=hidden name=type value="$form->{formname}">
  334. <input type=hidden name=title value="$title">
  335. |;
  336. $form->hide_form(qw(id printed emailed sort closedto locked oldtransdate audittrail recurring checktax));
  337. if ($form->{vc} eq 'customer') {
  338. $label = $locale->text('Customer');
  339. } else {
  340. $label = $locale->text('Vendor');
  341. }
  342. $form->hide_form("old$form->{vc}", "$form->{vc}_id", "terms", "creditlimit", "creditremaining", "selectcurrency", "defaultcurrency", "select$form->{ARAP}_amount", "rowcount");
  343. print qq|
  344. <table width=100%>
  345. <tr class=listtop>
  346. <th class=listtop>$form->{title}</th>
  347. </tr>
  348. <tr height="5"></tr>
  349. <tr valign=top>
  350. <td>
  351. <table width=100%>
  352. <tr valign=top>
  353. <td>
  354. <table>
  355. <tr>
  356. <th align="right" nowrap>$label</th>
  357. <td colspan=3>$name</td>
  358. <input type=hidden name="select$form->{vc}" value="|.$form->escape($form->{"select$form->{vc}"},1).qq|">
  359. </tr>
  360. <tr>
  361. <td></td>
  362. <td colspan=3>
  363. <table width=100%>
  364. <tr>
  365. <th align=left nowrap>|.$locale->text('Credit Limit').qq|</th>
  366. <td>$form->{creditlimit}</td>
  367. <th align=left nowrap>|.$locale->text('Remaining').qq|</th>
  368. <td class="plus$n">|.$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0").qq|</td>
  369. </tr>
  370. </table>
  371. </td>
  372. </tr>
  373. $exchangerate
  374. $department
  375. $taxincluded
  376. </table>
  377. </td>
  378. <td align=right>
  379. <table>
  380. $employee
  381. <tr>
  382. <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
  383. <td><input name=invnumber size=20 value="$form->{invnumber}"></td>
  384. </tr>
  385. <tr>
  386. <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
  387. <td><input name=ordnumber size=20 value="$form->{ordnumber}"></td>
  388. </tr>
  389. <tr>
  390. <th align=right nowrap>|.$locale->text('Invoice Date').qq|</th>
  391. <td><input name=transdate size=11 title="($myconfig{'dateformat'})" value=$form->{transdate}></td>
  392. </tr>
  393. <tr>
  394. <th align=right nowrap>|.$locale->text('Due Date').qq|</th>
  395. <td><input name=duedate size=11 title="$myconfig{'dateformat'}" value=$form->{duedate}></td>
  396. </tr>
  397. <tr>
  398. <th align=right nowrap>|.$locale->text('PO Number').qq|</th>
  399. <td><input name=ponumber size=20 value="$form->{ponumber}"></td>
  400. </tr>
  401. </table>
  402. </td>
  403. </tr>
  404. </table>
  405. </td>
  406. </tr>
  407. <input type=hidden name=selectprojectnumber value="|.$form->escape($form->{selectprojectnumber},1).qq|">
  408. <tr>
  409. <td>
  410. <table>
  411. |;
  412. $project = qq|
  413. <th>|.$locale->text('Project').qq|</th>
  414. | if $form->{selectprojectnumber};
  415. print qq|
  416. <tr>
  417. <th>|.$locale->text('Amount').qq|</th>
  418. <th></th>
  419. <th>|.$locale->text('Account').qq|</th>
  420. <th>|.$locale->text('Description').qq|</th>
  421. $project
  422. </tr>
  423. |;
  424. for $i (1 .. $form->{rowcount}) {
  425. $selectamount = $form->{"select$form->{ARAP}_amount"};
  426. $selectamount =~ s/option>\Q$form->{"$form->{ARAP}_amount_$i"}\E/option selected>$form->{"$form->{ARAP}_amount_$i"}/;
  427. $selectprojectnumber = $form->{selectprojectnumber};
  428. $selectprojectnumber =~ s/(<option value="\Q$form->{"projectnumber_$i"}\E")/$1 selected/;
  429. # format amounts
  430. $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
  431. $project = qq|
  432. <td align=right><select name="projectnumber_$i">$selectprojectnumber</select></td>
  433. | if $form->{selectprojectnumber};
  434. if (($rows = $form->numtextrows($form->{"description_$i"}, 40)) > 1) {
  435. $description = qq|<td><textarea name="description_$i" rows=$rows cols=40>$form->{"description_$i"}</textarea></td>|;
  436. } else {
  437. $description = qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
  438. }
  439. print qq|
  440. <tr valign=top>
  441. <td><input name="amount_$i" size=10 value="$form->{"amount_$i"}" accesskey="$i"></td>
  442. <td></td>
  443. <td><select name="$form->{ARAP}_amount_$i">$selectamount</select></td>
  444. $description
  445. $project
  446. </tr>
  447. |;
  448. }
  449. foreach $item (split / /, $form->{taxaccounts}) {
  450. $form->{"calctax_$item"} = ($form->{"calctax_$item"}) ? "checked" : "";
  451. $form->{"tax_$item"} = $form->format_amount(\%myconfig, $form->{"tax_$item"}, 2);
  452. print qq|
  453. <tr>
  454. <td><input name="tax_$item" size=10 value=$form->{"tax_$item"}></td>
  455. <td align=right><input name="calctax_$item" class=checkbox type=checkbox value=1 $form->{"calctax_$item"}></td>
  456. <td><select name="$form->{ARAP}_tax_$item">$form->{"select$form->{ARAP}_tax_$item"}</select></td>
  457. </tr>
  458. |;
  459. $form->hide_form("${item}_rate", "${item}_description", "${item}_taxnumber", "select$form->{ARAP}_tax_$item");
  460. }
  461. $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
  462. $form->hide_form("oldinvtotal", "oldtotalpaid", "taxaccounts", "select$form->{ARAP}");
  463. print qq|
  464. <tr>
  465. <th align=left>$form->{invtotal}</th>
  466. <td></td>
  467. <td><select name=$form->{ARAP}>$form->{"select$form->{ARAP}"}</select></td>
  468. </tr>
  469. <tr>
  470. <th align=right>|.$locale->text('Notes').qq|</th>
  471. <td></td>
  472. <td colspan=3>$notes</td>
  473. </tr>
  474. </table>
  475. </td>
  476. </tr>
  477. <tr class=listheading>
  478. <th class=listheading>|.$locale->text('Payments').qq|</th>
  479. </tr>
  480. <tr>
  481. <td>
  482. <table width=100%>
  483. |;
  484. if ($form->{currency} eq $form->{defaultcurrency}) {
  485. @column_index = qw(datepaid source memo paid ARAP_paid);
  486. } else {
  487. @column_index = qw(datepaid source memo paid exchangerate ARAP_paid);
  488. }
  489. $column_data{datepaid} = "<th>".$locale->text('Date')."</th>";
  490. $column_data{paid} = "<th>".$locale->text('Amount')."</th>";
  491. $column_data{exchangerate} = "<th>".$locale->text('Exch')."</th>";
  492. $column_data{ARAP_paid} = "<th>".$locale->text('Account')."</th>";
  493. $column_data{source} = "<th>".$locale->text('Source')."</th>";
  494. $column_data{memo} = "<th>".$locale->text('Memo')."</th>";
  495. print "
  496. <tr>
  497. ";
  498. for (@column_index) { print "$column_data{$_}\n" }
  499. print "
  500. </tr>
  501. ";
  502. $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
  503. for $i (1 .. $form->{paidaccounts}) {
  504. $form->hide_form("cleared_$i");
  505. print "
  506. <tr>
  507. ";
  508. $form->{"select$form->{ARAP}_paid_$i"} = $form->{"select$form->{ARAP}_paid"};
  509. $form->{"select$form->{ARAP}_paid_$i"} =~ s/option>\Q$form->{"$form->{ARAP}_paid_$i"}\E/option selected>$form->{"$form->{ARAP}_paid_$i"}/;
  510. # format amounts
  511. $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
  512. $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
  513. $exchangerate = qq|&nbsp;|;
  514. if ($form->{currency} ne $form->{defaultcurrency}) {
  515. if ($form->{"forex_$i"}) {
  516. $form->hide_form("exchangerate_$i");
  517. $exchangerate = qq|$form->{"exchangerate_$i"}|;
  518. } else {
  519. $exchangerate = qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
  520. }
  521. }
  522. $form->hide_form("forex_$i");
  523. $column_data{paid} = qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
  524. $column_data{ARAP_paid} = qq|<td align=center><select name="$form->{ARAP}_paid_$i">$form->{"select$form->{ARAP}_paid_$i"}</select></td>|;
  525. $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
  526. $column_data{datepaid} = qq|<td align=center><input name="datepaid_$i" size=11 value=$form->{"datepaid_$i"}></td>|;
  527. $column_data{source} = qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
  528. $column_data{memo} = qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
  529. for (@column_index) { print qq|$column_data{$_}\n| }
  530. print "
  531. </tr>
  532. ";
  533. }
  534. $form->hide_form("paidaccounts", "select$form->{ARAP}_paid");
  535. print qq|
  536. </table>
  537. </td>
  538. </tr>
  539. <tr>
  540. <td><hr size=3 noshade></td>
  541. </tr>
  542. </table>
  543. |;
  544. }
  545. sub form_footer {
  546. $form->hide_form(qw(callback path login sessionid));
  547. $transdate = $form->datetonum(\%myconfig, $form->{transdate});
  548. $closedto = $form->datetonum(\%myconfig, $form->{closedto});
  549. # type=submit $locale->text('Update')
  550. # type=submit $locale->text('Print')
  551. # type=submit $locale->text('Post')
  552. # type=submit $locale->text('Print and Post')
  553. # type=submit $locale->text('Schedule')
  554. # type=submit $locale->text('Ship to')
  555. # type=submit $locale->text('Post as new')
  556. # type=submit $locale->text('Print and Post as new')
  557. # type=submit $locale->text('Delete')
  558. if (! $form->{readonly}) {
  559. &print_options;
  560. print "<br>";
  561. %button = ('Update' => { ndx => 1, key => 'U', value => $locale->text('Update') },
  562. 'Print' => { ndx => 2, key => 'P', value => $locale->text('Print') },
  563. 'Post' => { ndx => 3, key => 'O', value => $locale->text('Post') },
  564. 'Print and Post' => { ndx => 4, key => 'R', value => $locale->text('Print and Post') },
  565. 'Post as new' => { ndx => 5, key => 'N', value => $locale->text('Post as new') },
  566. 'Print and Post as new' => { ndx => 6, key => 'W', value => $locale->text('Print and Post as new') },
  567. 'Schedule' => { ndx => 7, key => 'H', value => $locale->text('Schedule') },
  568. 'Delete' => { ndx => 8, key => 'D', value => $locale->text('Delete') },
  569. );
  570. if ($form->{id}) {
  571. if ($form->{locked} || $transdate <= $closedto) {
  572. for ("Post", "Print and Post", "Delete") { delete $button{$_} }
  573. }
  574. if (!$latex) {
  575. for ("Print and Post", "Print and Post as new") { delete $button{$_} }
  576. }
  577. } else {
  578. for ("Post as new", "Print and Post as new", "Delete") { delete $button{$_} }
  579. delete $button{"Print and Post"} if ! $latex;
  580. if ($transdate <= $closedto) {
  581. for ("Post", "Print and Post") { delete $button{$_} }
  582. }
  583. }
  584. for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
  585. }
  586. if ($form->{menubar}) {
  587. require "$form->{path}/menu.pl";
  588. &menubar;
  589. }
  590. print qq|
  591. </form>
  592. </body>
  593. </html>
  594. |;
  595. }
  596. sub update {
  597. my $display = shift;
  598. if (!$display) {
  599. $form->{invtotal} = 0;
  600. $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
  601. @flds = ("amount", "$form->{ARAP}_amount", "projectnumber", "description");
  602. $count = 0;
  603. @a = ();
  604. for $i (1 .. $form->{rowcount}) {
  605. $form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"});
  606. if ($form->{"amount_$i"}) {
  607. push @a, {};
  608. $j = $#a;
  609. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  610. $count++;
  611. }
  612. }
  613. $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
  614. $form->{rowcount} = $count + 1;
  615. for (1 .. $form->{rowcount}) { $form->{invtotal} += $form->{"amount_$_"} }
  616. $form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, ($form->{ARAP} eq 'AR') ? 'buy' : 'sell')));
  617. if ($newname = &check_name($form->{vc})) {
  618. $form->{notes} = $form->{intnotes} unless $form->{id};
  619. &rebuild_vc($form->{vc}, $form->{ARAP}, $form->{transdate});
  620. }
  621. if ($form->{transdate} ne $form->{oldtransdate}) {
  622. $form->{duedate} = $form->current_date(\%myconfig, $form->{transdate}, $form->{terms} * 1);
  623. $form->{oldtransdate} = $form->{transdate};
  624. $newproj = &rebuild_vc($form->{vc}, $form->{ARAP}, $form->{transdate}) if ! $newname;
  625. $form->all_projects(\%myconfig, undef, $form->{transdate}) if ! $newproj;
  626. $form->{selectemployee} = "";
  627. if (@{ $form->{all_employee} }) {
  628. for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  629. }
  630. }
  631. }
  632. # recalculate taxes
  633. @taxaccounts = split / /, $form->{taxaccounts};
  634. for (@taxaccounts) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
  635. if ($form->{taxincluded}) {
  636. $ml = 1;
  637. for (0 .. 1) {
  638. $taxrate = 0;
  639. $diff = 0;
  640. for (@taxaccounts) {
  641. if (($form->{"${_}_rate"} * $ml) > 0) {
  642. if ($form->{"calctax_$_"}) {
  643. $taxrate += $form->{"${_}_rate"};
  644. } else {
  645. if ($form->{checktax}) {
  646. if ($form->{"tax_$_"}) {
  647. $taxrate += $form->{"${_}_rate"};
  648. }
  649. }
  650. }
  651. }
  652. }
  653. $taxrate *= $ml;
  654. foreach $item (@taxaccounts) {
  655. if (($form->{"${item}_rate"} * $ml) > 0) {
  656. if ($taxrate) {
  657. $a = $form->{invtotal} * $form->{"${item}_rate"} / (1 + $taxrate);
  658. $b = $form->round_amount($a, 2);
  659. $tax = $form->round_amount($a - $diff, 2);
  660. $diff = $b - ($a - $diff);
  661. }
  662. $form->{"tax_$item"} = $tax if $form->{"calctax_$item"};
  663. $form->{"select$form->{ARAP}_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
  664. $totaltax += $form->{"tax_$item"};
  665. }
  666. }
  667. $ml *= -1;
  668. }
  669. $totaltax += $form->round_amount($diff, 2);
  670. $form->{checktax} = 1;
  671. } else {
  672. foreach $item (@taxaccounts) {
  673. $form->{"calctax_$item"} = 1 if $form->{calctax};
  674. if ($form->{"calctax_$item"}) {
  675. $form->{"tax_$item"} = $form->round_amount($form->{invtotal} * $form->{"${item}_rate"}, 2);
  676. }
  677. $form->{"select$form->{ARAP}_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
  678. $totaltax += $form->{"tax_$item"};
  679. }
  680. }
  681. $form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
  682. $j = 1;
  683. for $i (1 .. $form->{paidaccounts}) {
  684. if ($form->{"paid_$i"}) {
  685. for (qw(datepaid source memo cleared)) { $form->{"${_}_$j"} = $form->{"${_}_$i"} }
  686. for (qw(paid exchangerate)) { $form->{"${_}_$j"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  687. $totalpaid += $form->{"paid_$j"};
  688. $form->{"exchangerate_$j"} = $exchangerate if ($form->{"forex_$j"} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$j"}, ($form->{ARAP} eq 'AR') ? 'buy' : 'sell')));
  689. if ($j++ != $i) {
  690. for (qw(datepaid source memo paid exchangerate forex cleared)) { delete $form->{"${_}_$i"} }
  691. }
  692. } else {
  693. for (qw(datepaid source memo paid exchangerate forex cleared)) { delete $form->{"${_}_$i"} }
  694. }
  695. }
  696. $form->{paidaccounts} = $j;
  697. $form->{creditremaining} -= ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} - $form->{oldinvtotal});
  698. $form->{oldinvtotal} = $form->{invtotal};
  699. $form->{oldtotalpaid} = $totalpaid;
  700. &display_form;
  701. }
  702. sub post {
  703. $label = ($form->{vc} eq 'customer') ? $locale->text('Customer missing!') : $locale->text('Vendor missing!');
  704. # check if there is an invoice number, invoice and due date
  705. $form->isblank("transdate", $locale->text('Invoice Date missing!'));
  706. $form->isblank("duedate", $locale->text('Due Date missing!'));
  707. $form->isblank($form->{vc}, $label);
  708. $closedto = $form->datetonum(\%myconfig, $form->{closedto});
  709. $transdate = $form->datetonum(\%myconfig, $form->{transdate});
  710. $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
  711. $form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
  712. for $i (1 .. $form->{paidaccounts}) {
  713. if ($form->{"paid_$i"}) {
  714. $datepaid = $form->datetonum(\%myconfig, $form->{"datepaid_$i"});
  715. $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
  716. $form->error($locale->text('Cannot post payment for a closed period!')) if ($datepaid <= $closedto);
  717. if ($form->{currency} ne $form->{defaultcurrency}) {
  718. $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
  719. $form->isblank("exchangerate_$i", $locale->text('Exchange rate for payment missing!'));
  720. }
  721. }
  722. }
  723. # if oldname ne name redo form
  724. ($name) = split /--/, $form->{$form->{vc}};
  725. if ($form->{"old$form->{vc}"} ne qq|$name--$form->{"$form->{vc}_id"}|) {
  726. &update;
  727. exit;
  728. }
  729. if (! $form->{repost}) {
  730. if ($form->{id}) {
  731. &repost;
  732. exit;
  733. }
  734. }
  735. if (AA->post_transaction(\%myconfig, \%$form)) {
  736. $form->redirect($locale->text('Transaction posted!'));
  737. } else {
  738. $form->error($locale->text('Cannot post transaction!'));
  739. }
  740. }
  741. sub delete {
  742. $form->{title} = $locale->text('Confirm!');
  743. $form->header;
  744. print qq|
  745. <body>
  746. <form method=post action=$form->{script}>
  747. |;
  748. $form->{action} = "yes";
  749. $form->hide_form;
  750. print qq|
  751. <h2 class=confirm>$form->{title}</h2>
  752. <h4>|.$locale->text('Are you sure you want to delete Transaction').qq| $form->{invnumber}</h4>
  753. <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
  754. </form>
  755. </body>
  756. </html>
  757. |;
  758. }
  759. sub yes {
  760. if (AA->delete_transaction(\%myconfig, \%$form, $spool)) {
  761. $form->redirect($locale->text('Transaction deleted!'));
  762. } else {
  763. $form->error($locale->text('Cannot delete transaction!'));
  764. }
  765. }
  766. sub search {
  767. $form->create_links($form->{ARAP}, \%myconfig, $form->{vc});
  768. $form->{"select$form->{ARAP}"} = "<option>\n";
  769. for (@{ $form->{"$form->{ARAP}_links"}{$form->{ARAP}} }) { $form->{"select$form->{ARAP}"} .= "<option>$_->{accno}--$_->{description}\n" }
  770. if (@{ $form->{"all_$form->{vc}"} }) {
  771. $selectname = "";
  772. for (@{ $form->{"all_$form->{vc}"} }) { $selectname .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  773. $selectname = qq|<select name="$form->{vc}"><option>\n$selectname</select>|;
  774. } else {
  775. $selectname = qq|<input name=$form->{vc} size=35>|;
  776. }
  777. # departments
  778. if (@{ $form->{all_department} }) {
  779. $form->{selectdepartment} = "<option>\n";
  780. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  781. $l_department = qq|<input name="l_department" class=checkbox type=checkbox value=Y> |.$locale->text('Department');
  782. $department = qq|
  783. <tr>
  784. <th align=right nowrap>|.$locale->text('Department').qq|</th>
  785. <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
  786. </tr>
  787. |;
  788. }
  789. if (@{ $form->{all_employee} }) {
  790. $form->{selectemployee} = "<option>\n";
  791. for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  792. $employeelabel = ($form->{ARAP} eq 'AR') ? $locale->text('Salesperson') : $locale->text('Employee');
  793. $employee = qq|
  794. <tr>
  795. <th align=right nowrap>$employeelabel</th>
  796. <td colspan=3><select name=employee>$form->{selectemployee}</select></td>
  797. </tr>
  798. |;
  799. $l_employee = qq|<input name="l_employee" class=checkbox type=checkbox value=Y> $employeelabel|;
  800. $l_manager = qq|<input name="l_manager" class=checkbox type=checkbox value=Y> |.$locale->text('Manager');
  801. }
  802. $form->{title} = ($form->{ARAP} eq 'AR') ? $locale->text('AR Transactions') : $locale->text('AP Transactions');
  803. $invnumber = qq|
  804. <tr>
  805. <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
  806. <td colspan=3><input name=invnumber size=20></td>
  807. </tr>
  808. <tr>
  809. <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
  810. <td colspan=3><input name=ordnumber size=20></td>
  811. </tr>
  812. <tr>
  813. <th align=right nowrap>|.$locale->text('PO Number').qq|</th>
  814. <td colspan=3><input name=ponumber size=20></td>
  815. </tr>
  816. <tr>
  817. <th align=right nowrap>|.$locale->text('Source').qq|</th>
  818. <td colspan=3><input name=source size=40></td>
  819. </tr>
  820. <tr>
  821. <th align=right nowrap>|.$locale->text('Description').qq|</th>
  822. <td colspan=3><input name=description size=40></td>
  823. </tr>
  824. <tr>
  825. <th align=right nowrap>|.$locale->text('Notes').qq|</th>
  826. <td colspan=3><input name=notes size=40></td>
  827. </tr>
  828. |;
  829. $openclosed = qq|
  830. <tr>
  831. <td nowrap><input name=open class=checkbox type=checkbox value=Y checked> |.$locale->text('Open').qq|</td>
  832. <td nowrap><input name=closed class=checkbox type=checkbox value=Y> |.$locale->text('Closed').qq|</td>
  833. </tr>
  834. |;
  835. $summary = qq|
  836. <tr>
  837. <td><input name=summary type=radio class=radio value=1 checked> |.$locale->text('Summary').qq|</td>
  838. <td><input name=summary type=radio class=radio value=0> |.$locale->text('Detail').qq|
  839. </td>
  840. </tr>
  841. |;
  842. if ($form->{outstanding}) {
  843. $form->{title} = ($form->{ARAP} eq 'AR') ? $locale->text('AR Outstanding') : $locale->text('AP Outstanding');
  844. $invnumber = "";
  845. $openclosed = "";
  846. $summary = "";
  847. }
  848. if (@{ $form->{all_years} }) {
  849. # accounting years
  850. $form->{selectaccountingyear} = "<option>\n";
  851. for (@{ $form->{all_years} }) { $form->{selectaccountingyear} .= qq|<option>$_\n| }
  852. $form->{selectaccountingmonth} = "<option>\n";
  853. for (sort keys %{ $form->{all_month} }) { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| }
  854. $selectfrom = qq|
  855. <tr>
  856. <th align=right>|.$locale->text('Period').qq|</th>
  857. <td colspan=3>
  858. <select name=month>$form->{selectaccountingmonth}</select>
  859. <select name=year>$form->{selectaccountingyear}</select>
  860. <input name=interval class=radio type=radio value=0 checked>&nbsp;|.$locale->text('Current').qq|
  861. <input name=interval class=radio type=radio value=1>&nbsp;|.$locale->text('Month').qq|
  862. <input name=interval class=radio type=radio value=3>&nbsp;|.$locale->text('Quarter').qq|
  863. <input name=interval class=radio type=radio value=12>&nbsp;|.$locale->text('Year').qq|
  864. </td>
  865. </tr>
  866. |;
  867. }
  868. $name = $locale->text('Customer');
  869. $l_name = qq|<input name="l_name" class=checkbox type=checkbox value=Y checked> $name|;
  870. $l_till = qq|<input name="l_till" class=checkbox type=checkbox value=Y> |.$locale->text('Till');
  871. if ($form->{vc} eq 'vendor') {
  872. $name = $locale->text('Vendor');
  873. $l_till = "";
  874. $l_name = qq|<input name="l_name" class=checkbox type=checkbox value=Y checked> $name|;
  875. }
  876. @a = ();
  877. push @a, qq|<input name="l_runningnumber" class=checkbox type=checkbox value=Y> |.$locale->text('No.');
  878. push @a, qq|<input name="l_id" class=checkbox type=checkbox value=Y> |.$locale->text('ID');
  879. push @a, qq|<input name="l_invnumber" class=checkbox type=checkbox value=Y checked> |.$locale->text('Invoice Number');
  880. push @a, qq|<input name="l_ordnumber" class=checkbox type=checkbox value=Y> |.$locale->text('Order Number');
  881. push @a, qq|<input name="l_ponumber" class=checkbox type=checkbox value=Y> |.$locale->text('PO Number');
  882. push @a, qq|<input name="l_transdate" class=checkbox type=checkbox value=Y checked> |.$locale->text('Invoice Date');
  883. push @a, $l_name;
  884. push @a, $l_employee if $l_employee;
  885. push @a, $l_manager if $l_employee;
  886. push @a, $l_department if $l_department;
  887. push @a, qq|<input name="l_netamount" class=checkbox type=checkbox value=Y> |.$locale->text('Amount');
  888. push @a, qq|<input name="l_tax" class=checkbox type=checkbox value=Y> |.$locale->text('Tax');
  889. push @a, qq|<input name="l_amount" class=checkbox type=checkbox value=Y checked> |.$locale->text('Total');
  890. push @a, qq|<input name="l_curr" class=checkbox type=checkbox value=Y> |.$locale->text('Currency');
  891. push @a, qq|<input name="l_datepaid" class=checkbox type=checkbox value=Y> |.$locale->text('Date Paid');
  892. push @a, qq|<input name="l_paid" class=checkbox type=checkbox value=Y checked> |.$locale->text('Paid');
  893. push @a, qq|<input name="l_duedate" class=checkbox type=checkbox value=Y> |.$locale->text('Due Date');
  894. push @a, qq|<input name="l_due" class=checkbox type=checkbox value=Y> |.$locale->text('Amount Due');
  895. push @a, qq|<input name="l_notes" class=checkbox type=checkbox value=Y> |.$locale->text('Notes');
  896. push @a, $l_till if $l_till;
  897. push @a, qq|<input name="l_shippingpoint" class=checkbox type=checkbox value=Y> |.$locale->text('Shipping Point');
  898. push @a, qq|<input name="l_shipvia" class=checkbox type=checkbox value=Y> |.$locale->text('Ship via');
  899. $form->header;
  900. print qq|
  901. <body>
  902. <form method=post action=$form->{script}>
  903. <table width=100%>
  904. <tr><th class=listtop>$form->{title}</th></tr>
  905. <tr height="5"></tr>
  906. <tr>
  907. <td>
  908. <table>
  909. <tr>
  910. <th align=right>|.$locale->text('Account').qq|</th>
  911. <td colspan=3><select name=$form->{ARAP}>$form->{"select$form->{ARAP}"}</select></td>
  912. </tr>
  913. <tr>
  914. <th align=right>$name</th>
  915. <td colspan=3>$selectname</td>
  916. </tr>
  917. $employee
  918. $department
  919. $invnumber
  920. <tr>
  921. <th align=right>|.$locale->text('Ship via').qq|</th>
  922. <td colspan=3><input name=shipvia size=40></td>
  923. </tr>
  924. <tr>
  925. <th align=right nowrap>|.$locale->text('From').qq|</th>
  926. <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  927. <th align=right>|.$locale->text('To').qq|</th>
  928. <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  929. </tr>
  930. $selectfrom
  931. </table>
  932. </td>
  933. </tr>
  934. <tr>
  935. <td>
  936. <table>
  937. <tr>
  938. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  939. <td>
  940. <table width=100%>
  941. $openclosed
  942. $summary
  943. |;
  944. $form->{sort} = "transdate";
  945. $form->hide_form(qw(title outstanding sort));
  946. while (@a) {
  947. for (1 .. 5) {
  948. print qq|<td nowrap>|. shift @a;
  949. print qq|</td>\n|;
  950. }
  951. print qq|</tr>\n|;
  952. }
  953. print qq|
  954. <tr>
  955. <td nowrap><input name="l_subtotal" class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|</td>
  956. </tr>
  957. </table>
  958. </td>
  959. </tr>
  960. </table>
  961. </td>
  962. </tr>
  963. <tr>
  964. <td><hr size=3 noshade></td>
  965. </tr>
  966. </table>
  967. <br>
  968. <input type=hidden name=action value=continue>
  969. <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|;
  970. $form->hide_form(qw(nextsub path login sessionid));
  971. print qq|
  972. </form>
  973. |;
  974. if ($form->{menubar}) {
  975. require "$form->{path}/menu.pl";
  976. &menubar;
  977. }
  978. print qq|
  979. </body>
  980. </html>
  981. |;
  982. }
  983. sub transactions {
  984. if ($form->{$form->{vc}}) {
  985. $form->{$form->{vc}} = $form->unescape($form->{$form->{vc}});
  986. ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
  987. }
  988. AA->transactions(\%myconfig, \%$form);
  989. $href = "$form->{script}?action=transactions";
  990. for (qw(direction oldsort till outstanding path login sessionid summary)) { $href .= qq|&$_=$form->{$_}| }
  991. $href .= "&title=".$form->escape($form->{title});
  992. $form->sort_order();
  993. $callback = "$form->{script}?action=transactions";
  994. for (qw(direction oldsort till outstanding path login sessionid summary)) { $callback .= qq|&$_=$form->{$_}| }
  995. $callback .= "&title=".$form->escape($form->{title},1);
  996. if ($form->{$form->{ARAP}}) {
  997. $callback .= "&$form->{ARAP}=".$form->escape($form->{$form->{ARAP}},1);
  998. $href .= "&$form->{ARAP}=".$form->escape($form->{$form->{ARAP}});
  999. $form->{$form->{ARAP}} =~ s/--/ /;
  1000. $option = $locale->text('Account')." : $form->{$form->{ARAP}}";
  1001. }
  1002. if ($form->{$form->{vc}}) {
  1003. $callback .= "&$form->{vc}=".$form->escape($form->{$form->{vc}},1).qq|--$form->{"$form->{vc}_id"}|;
  1004. $href .= "&$form->{vc}=".$form->escape($form->{$form->{vc}}).qq|--$form->{"$form->{vc}_id"}|;
  1005. $option .= "\n<br>" if ($option);
  1006. $name = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
  1007. $option .= "$name : $form->{$form->{vc}}";
  1008. }
  1009. if ($form->{department}) {
  1010. $callback .= "&department=".$form->escape($form->{department},1);
  1011. $href .= "&department=".$form->escape($form->{department});
  1012. ($department) = split /--/, $form->{department};
  1013. $option .= "\n<br>" if ($option);
  1014. $option .= $locale->text('Department')." : $department";
  1015. }
  1016. if ($form->{employee}) {
  1017. $callback .= "&employee=".$form->escape($form->{employee},1);
  1018. $href .= "&employee=".$form->escape($form->{employee});
  1019. ($employee) = split /--/, $form->{employee};
  1020. $option .= "\n<br>" if ($option);
  1021. if ($form->{ARAP} eq 'AR') {
  1022. $option .= $locale->text('Salesperson');
  1023. } else {
  1024. $option .= $locale->text('Employee');
  1025. }
  1026. $option .= " : $employee";
  1027. }
  1028. if ($form->{invnumber}) {
  1029. $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
  1030. $href .= "&invnumber=".$form->escape($form->{invnumber});
  1031. $option .= "\n<br>" if ($option);
  1032. $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
  1033. }
  1034. if ($form->{ordnumber}) {
  1035. $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
  1036. $href .= "&ordnumber=".$form->escape($form->{ordnumber});
  1037. $option .= "\n<br>" if ($option);
  1038. $option .= $locale->text('Order Number')." : $form->{ordnumber}";
  1039. }
  1040. if ($form->{ponumber}) {
  1041. $callback .= "&ponumber=".$form->escape($form->{ponumber},1);
  1042. $href .= "&ponumber=".$form->escape($form->{ponumber});
  1043. $option .= "\n<br>" if ($option);
  1044. $option .= $locale->text('PO Number')." : $form->{ponumber}";
  1045. }
  1046. if ($form->{source}) {
  1047. $callback .= "&source=".$form->escape($form->{source},1);
  1048. $href .= "&source=".$form->escape($form->{source});
  1049. $option .= "\n<br>" if $option;
  1050. $option .= $locale->text('Source')." : $form->{source}";
  1051. }
  1052. if ($form->{description}) {
  1053. $callback .= "&description=".$form->escape($form->{description},1);
  1054. $href .= "&description=".$form->escape($form->{description});
  1055. $option .= "\n<br>" if $option;
  1056. $option .= $locale->text('Description')." : $form->{description}";
  1057. }
  1058. if ($form->{notes}) {
  1059. $callback .= "&notes=".$form->escape($form->{notes},1);
  1060. $href .= "&notes=".$form->escape($form->{notes});
  1061. $option .= "\n<br>" if $option;
  1062. $option .= $locale->text('Notes')." : $form->{notes}";
  1063. }
  1064. if ($form->{shipvia}) {
  1065. $callback .= "&shipvia=".$form->escape($form->{shipvia},1);
  1066. $href .= "&shipvia=".$form->escape($form->{shipvia});
  1067. $option .= "\n<br>" if $option;
  1068. $option .= $locale->text('Ship via')." : $form->{shipvia}";
  1069. }
  1070. if ($form->{transdatefrom}) {
  1071. $callback .= "&transdatefrom=$form->{transdatefrom}";
  1072. $href .= "&transdatefrom=$form->{transdatefrom}";
  1073. $option .= "\n<br>" if ($option);
  1074. $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
  1075. }
  1076. if ($form->{transdateto}) {
  1077. $callback .= "&transdateto=$form->{transdateto}";
  1078. $href .= "&transdateto=$form->{transdateto}";
  1079. $option .= "\n<br>" if ($option);
  1080. $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{transdateto}, 1);
  1081. }
  1082. if ($form->{open}) {
  1083. $callback .= "&open=$form->{open}";
  1084. $href .= "&open=$form->{open}";
  1085. $option .= "\n<br>" if ($option);
  1086. $option .= $locale->text('Open');
  1087. }
  1088. if ($form->{closed}) {
  1089. $callback .= "&closed=$form->{closed}";
  1090. $href .= "&closed=$form->{closed}";
  1091. $option .= "\n<br>" if ($option);
  1092. $option .= $locale->text('Closed');
  1093. }
  1094. @columns = $form->sort_columns(qw(transdate id invnumber ordnumber ponumber name netamount tax amount paid due curr datepaid duedate notes till employee manager shippingpoint shipvia department));
  1095. pop @columns if $form->{department};
  1096. unshift @columns, "runningnumber";
  1097. foreach $item (@columns) {
  1098. if ($form->{"l_$item"} eq "Y") {
  1099. push @column_index, $item;
  1100. if ($form->{l_curr} && $item =~ /(amount|tax|paid|due)/) {
  1101. push @column_index, "fx_$item";
  1102. }
  1103. # add column to href and callback
  1104. $callback .= "&l_$item=Y";
  1105. $href .= "&l_$item=Y";
  1106. }
  1107. }
  1108. if (!$form->{summary}) {
  1109. foreach $item (qw(source debit credit accno description projectnumber)) {
  1110. push @column_index, $item;
  1111. }
  1112. }
  1113. if ($form->{l_subtotal} eq 'Y') {
  1114. $callback .= "&l_subtotal=Y";
  1115. $href .= "&l_subtotal=Y";
  1116. }
  1117. $employee = ($form->{ARAP} eq 'AR') ? $locale->text('Salesperson') : $locale->text('Employee');
  1118. $name = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
  1119. $column_header{runningnumber} = qq|<th class=listheading>&nbsp;</th>|;
  1120. $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
  1121. $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
  1122. $column_header{duedate} = "<th><a class=listheading href=$href&sort=duedate>".$locale->text('Due Date')."</a></th>";
  1123. $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
  1124. $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
  1125. $column_header{ponumber} = "<th><a class=listheading href=$href&sort=ponumber>".$locale->text('PO Number')."</a></th>";
  1126. $column_header{name} = "<th><a class=listheading href=$href&sort=name>$name</a></th>";
  1127. $column_header{netamount} = "<th class=listheading>" . $locale->text('Amount') . "</th>";
  1128. $column_header{tax} = "<th class=listheading>" . $locale->text('Tax') . "</th>";
  1129. $column_header{amount} = "<th class=listheading>" . $locale->text('Total') . "</th>";
  1130. $column_header{paid} = "<th class=listheading>" . $locale->text('Paid') . "</th>";
  1131. $column_header{datepaid} = "<th><a class=listheading href=$href&sort=datepaid>" . $locale->text('Date Paid') . "</a></th>";
  1132. $column_header{due} = "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
  1133. $column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
  1134. $column_header{employee} = "<th><a class=listheading href=$href&sort=employee>$employee</th>";
  1135. $column_header{manager} = "<th><a class=listheading href=$href&sort=manager>".$locale->text('Manager')."</th>";
  1136. $column_header{till} = "<th class=listheading><a class=listheading href=$href&sort=till>".$locale->text('Till')."</th>";
  1137. $column_header{shippingpoint} = "<th><a class=listheading href=$href&sort=shippingpoint>" . $locale->text('Shipping Point') . "</a></th>";
  1138. $column_header{shipvia} = "<th><a class=listheading href=$href&sort=shipvia>" . $locale->text('Ship via') . "</a></th>";
  1139. $column_header{curr} = "<th><a class=listheading href=$href&sort=curr>" . $locale->text('Curr') . "</a></th>";
  1140. for (qw(amount tax netamount paid due)) { $column_header{"fx_$_"} = "<th>&nbsp;</th>" }
  1141. $column_header{department} = "<th><a class=listheading href=$href&sort=department>" . $locale->text('Department') . "</a></th>";
  1142. $column_header{accno} = "<th><a class=listheading href=$href&sort=accno>" . $locale->text('Account') . "</a></th>";
  1143. $column_header{source} = "<th><a class=listheading href=$href&sort=source>" . $locale->text('Source') . "</a></th>";
  1144. $column_header{debit} = "<th class=listheading>" . $locale->text('Debit') . "</th>";
  1145. $column_header{credit} = "<th class=listheading>" . $locale->text('Credit') . "</th>";
  1146. $column_header{projectnumber} = "<th><a class=listheading href=$href&sort=projectnumber>" . $locale->text('Project') . "</a></th>";
  1147. $column_header{description} = "<th><a class=listheading href=$href&sort=linedescription>" . $locale->text('Description') . "</a></th>";
  1148. $form->{title} = ($form->{title}) ? $form->{title} : $locale->text('AR Transactions');
  1149. $form->header;
  1150. print qq|
  1151. <body>
  1152. <table width=100%>
  1153. <tr>
  1154. <th class=listtop>$form->{title}</th>
  1155. </tr>
  1156. <tr height="5"></tr>
  1157. <tr>
  1158. <td>$option</td>
  1159. </tr>
  1160. <tr>
  1161. <td>
  1162. <table width=100%>
  1163. <tr class=listheading>
  1164. |;
  1165. for (@column_index) { print "\n$column_header{$_}" }
  1166. print qq|
  1167. </tr>
  1168. |;
  1169. # add sort and escape callback, this one we use for the add sub
  1170. $form->{callback} = $callback .= "&sort=$form->{sort}";
  1171. # escape callback for href
  1172. $callback = $form->escape($callback);
  1173. # flip direction
  1174. $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
  1175. $href =~ s/&direction=(\w+)&/&direction=$direction&/;
  1176. if (@{ $form->{transactions} }) {
  1177. $sameitem = $form->{transactions}->[0]->{$form->{sort}};
  1178. }
  1179. # sums and tax on reports by Antonio Gallardo
  1180. #
  1181. $i = 0;
  1182. foreach $ref (@{ $form->{transactions} }) {
  1183. $i++;
  1184. if ($form->{l_subtotal} eq 'Y') {
  1185. if ($sameitem ne $ref->{$form->{sort}}) {
  1186. &subtotal;
  1187. $sameitem = $ref->{$form->{sort}};
  1188. }
  1189. }
  1190. if ($form->{l_curr}) {
  1191. for (qw(netamount amount paid)) { $ref->{"fx_$_"} = $ref->{$_}/$ref->{exchangerate} }
  1192. for (qw(netamount amount paid)) { $column_data{"fx_$_"} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{"fx_$_"}, 2, "&nbsp;")."</td>" }
  1193. $column_data{fx_tax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{fx_amount} - $ref->{fx_netamount}, 2, "&nbsp;")."</td>";
  1194. $column_data{fx_due} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{fx_amount} - $ref->{fx_paid}, 2, "&nbsp;")."</td>";
  1195. $subtotalfxnetamount += $ref->{fx_netamount};
  1196. $subtotalfxamount += $ref->{fx_amount};
  1197. $subtotalfxpaid += $ref->{fx_paid};
  1198. $totalfxnetamount += $ref->{fx_netamount};
  1199. $totalfxamount += $ref->{fx_amount};
  1200. $totalfxpaid += $ref->{fx_paid};
  1201. }
  1202. $column_data{runningnumber} = "<td align=right>$i</td>";
  1203. for (qw(netamount amount paid debit credit)) { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{$_}, 2, "&nbsp;")."</td>" }
  1204. $column_data{tax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, "&nbsp;")."</td>";
  1205. $column_data{due} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{paid}, 2, "&nbsp;")."</td>";
  1206. $subtotalnetamount += $ref->{netamount};
  1207. $subtotalamount += $ref->{amount};
  1208. $subtotalpaid += $ref->{paid};
  1209. $subtotaldebit += $ref->{debit};
  1210. $subtotalcredit += $ref->{credit};
  1211. $totalnetamount += $ref->{netamount};
  1212. $totalamount += $ref->{amount};
  1213. $totalpaid += $ref->{paid};
  1214. $totaldebit += $ref->{debit};
  1215. $totalcredit += $ref->{credit};
  1216. $module = ($ref->{invoice}) ? ($form->{ARAP} eq 'AR') ? "is.pl" : "ir.pl" : $form->{script};
  1217. $module = ($ref->{till}) ? "ps.pl" : $module;
  1218. $column_data{invnumber} = "<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{invnumber}&nbsp;</a></td>";
  1219. for (qw(notes description)) { $ref->{$_} =~ s/\r?\n/<br>/g }
  1220. for (qw(transdate datepaid duedate department ordnumber ponumber notes shippingpoint shipvia employee manager till source description projectnumber)) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  1221. for (qw(id curr)) { $column_data{$_} = "<td>$ref->{$_}</td>" }
  1222. $column_data{accno} = qq|<td><a href=ca.pl?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&action=list_transactions&accounttype=standard&accno=$ref->{accno}&fromdate=$form->{transdatefrom}&todate=$form->{transdateto}&sort=transdate&l_subtotal=$form->{l_subtotal}&prevreport=$callback>$ref->{accno}</a></td>|;
  1223. $column_data{name} = qq|<td><a href=ct.pl?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&action=edit&id=$ref->{"$form->{vc}_id"}&db=$form->{vc}&callback=$callback>$ref->{name}</a></td>|;
  1224. if ($ref->{id} != $sameid) {
  1225. $j++; $j %= 2;
  1226. }
  1227. print "
  1228. <tr class=listrow$j>
  1229. ";
  1230. for (@column_index) { print "\n$column_data{$_}" }
  1231. print qq|
  1232. </tr>
  1233. |;
  1234. $sameid = $ref->{id};
  1235. }
  1236. if ($form->{l_subtotal} eq 'Y') {
  1237. &subtotal;
  1238. $sameitem = $ref->{$form->{sort}};
  1239. }
  1240. # print totals
  1241. print qq|
  1242. <tr class=listtotal>
  1243. |;
  1244. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1245. $column_data{netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalnetamount, 2, "&nbsp;")."</th>";
  1246. $column_data{tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalnetamount, 2, "&nbsp;")."</th>";
  1247. $column_data{amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount, 2, "&nbsp;")."</th>";
  1248. $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalpaid, 2, "&nbsp;")."</th>";
  1249. $column_data{due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalpaid, 2, "&nbsp;")."</th>";
  1250. $column_data{debit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totaldebit, 2, "&nbsp;")."</th>";
  1251. $column_data{credit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalcredit, 2, "&nbsp;")."</th>";
  1252. if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
  1253. $column_data{fx_netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxnetamount, 2, "&nbsp;")."</th>";
  1254. $column_data{fx_tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxnetamount, 2, "&nbsp;")."</th>";
  1255. $column_data{fx_amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount, 2, "&nbsp;")."</th>";
  1256. $column_data{fx_paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxpaid, 2, "&nbsp;")."</th>";
  1257. $column_data{fx_due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxpaid, 2, "&nbsp;")."</th>";
  1258. }
  1259. for (@column_index) { print "\n$column_data{$_}" }
  1260. if ($myconfig{acs} !~ /$form->{ARAP}--$form->{ARAP}/) {
  1261. $i = 1;
  1262. if ($form->{ARAP} eq 'AR') {
  1263. $button{'AR--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|"> |;
  1264. $button{'AR--Add Transaction'}{order} = $i++;
  1265. $button{'AR--Sales Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice.').qq|"> |;
  1266. $button{'AR--Sales Invoice'}{order} = $i++;
  1267. } else {
  1268. $button{'AP--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|"> |;
  1269. $button{'AP--Add Transaction'}{order} = $i++;
  1270. $button{'AP--Vendor Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice.').qq|"> |;
  1271. $button{'AP--Vendor Invoice'}{order} = $i++;
  1272. }
  1273. foreach $item (split /;/, $myconfig{acs}) {
  1274. delete $button{$item};
  1275. }
  1276. }
  1277. print qq|
  1278. </tr>
  1279. </table>
  1280. </td>
  1281. </tr>
  1282. <tr>
  1283. <td><hr size=3 noshade></td>
  1284. </tr>
  1285. </table>
  1286. <br>
  1287. <form method=post action=$form->{script}>
  1288. |;
  1289. $form->hide_form("callback", "path", "login", "sessionid", "$form->{vc}", "$form->{vc}_id");
  1290. if (! $form->{till}) {
  1291. foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
  1292. print $item->{code};
  1293. }
  1294. }
  1295. if ($form->{menubar}) {
  1296. require "$form->{path}/menu.pl";
  1297. &menubar;
  1298. }
  1299. print qq|
  1300. </form>
  1301. </body>
  1302. </html>
  1303. |;
  1304. }
  1305. sub subtotal {
  1306. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1307. $column_data{tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount, 2, "&nbsp;")."</th>";
  1308. $column_data{amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount, 2, "&nbsp;")."</th>";
  1309. $column_data{paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalpaid, 2, "&nbsp;")."</th>";
  1310. $column_data{due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalpaid, 2, "&nbsp;")."</th>";
  1311. $column_data{debit} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotaldebit, 2, "&nbsp;")."</th>";
  1312. $column_data{credit} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalcredit, 2, "&nbsp;")."</th>";
  1313. if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
  1314. $column_data{fx_tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount - $subtotalfxnetamount, 2, "&nbsp;")."</th>";
  1315. $column_data{fx_amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount, 2, "&nbsp;")."</th>";
  1316. $column_data{fx_paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxpaid, 2, "&nbsp;")."</th>";
  1317. $column_data{fx_due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxmount - $subtotalfxpaid, 2, "&nbsp;")."</th>";
  1318. }
  1319. $subtotalnetamount = 0;
  1320. $subtotalamount = 0;
  1321. $subtotalpaid = 0;
  1322. $subtotaldebit = 0;
  1323. $subtotalcredit = 0;
  1324. $subtotalfxnetamount = 0;
  1325. $subtotalfxamount = 0;
  1326. $subtotalfxpaid = 0;
  1327. print "<tr class=listsubtotal>";
  1328. for (@column_index) { print "\n$column_data{$_}" }
  1329. print "
  1330. </tr>
  1331. ";
  1332. }