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