summaryrefslogtreecommitdiff
path: root/bin/mozilla/aa.pl
blob: abbbd7daf9b9dcd572dd0d190fe05897878d3434 (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # http://sourceforge.net/projects/ledger-smb/
  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://sourceforge.net/projects/ledger-smb/
  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->redirect($locale->text('Transaction posted!'));
  756. } else {
  757. $form->error($locale->text('Cannot post transaction!'));
  758. }
  759. }
  760. sub delete {
  761. $form->{title} = $locale->text('Confirm!');
  762. $form->header;
  763. print qq|
  764. <body>
  765. <form method=post action=$form->{script}>
  766. |;
  767. $form->{action} = "yes";
  768. $form->hide_form;
  769. print qq|
  770. <h2 class=confirm>$form->{title}</h2>
  771. <h4>|.$locale->text('Are you sure you want to delete Transaction').qq| $form->{invnumber}</h4>
  772. <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
  773. </form>
  774. </body>
  775. </html>
  776. |;
  777. }
  778. sub yes {
  779. if (AA->delete_transaction(\%myconfig, \%$form, $spool)) {
  780. $form->redirect($locale->text('Transaction deleted!'));
  781. } else {
  782. $form->error($locale->text('Cannot delete transaction!'));
  783. }
  784. }
  785. sub search {
  786. $form->create_links($form->{ARAP}, \%myconfig, $form->{vc});
  787. $form->{"select$form->{ARAP}"} = "<option>\n";
  788. for (@{ $form->{"$form->{ARAP}_links"}{$form->{ARAP}} }) { $form->{"select$form->{ARAP}"} .= "<option>$_->{accno}--$_->{description}\n" }
  789. if (@{ $form->{"all_$form->{vc}"} }) {
  790. $selectname = "";
  791. for (@{ $form->{"all_$form->{vc}"} }) { $selectname .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  792. $selectname = qq|<select name="$form->{vc}"><option>\n$selectname</select>|;
  793. } else {
  794. $selectname = qq|<input name=$form->{vc} size=35>|;
  795. }
  796. # departments
  797. if (@{ $form->{all_department} }) {
  798. $form->{selectdepartment} = "<option>\n";
  799. for (@{ $form->{all_department} }) { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  800. $l_department = qq|<input name="l_department" class=checkbox type=checkbox value=Y> |.$locale->text('Department');
  801. $department = qq|
  802. <tr>
  803. <th align=right nowrap>|.$locale->text('Department').qq|</th>
  804. <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
  805. </tr>
  806. |;
  807. }
  808. if (@{ $form->{all_employee} }) {
  809. $form->{selectemployee} = "<option>\n";
  810. for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  811. $employeelabel = ($form->{ARAP} eq 'AR') ? $locale->text('Salesperson') : $locale->text('Employee');
  812. $employee = qq|
  813. <tr>
  814. <th align=right nowrap>$employeelabel</th>
  815. <td colspan=3><select name=employee>$form->{selectemployee}</select></td>
  816. </tr>
  817. |;
  818. $l_employee = qq|<input name="l_employee" class=checkbox type=checkbox value=Y> $employeelabel|;
  819. $l_manager = qq|<input name="l_manager" class=checkbox type=checkbox value=Y> |.$locale->text('Manager');
  820. }
  821. $form->{title} = ($form->{ARAP} eq 'AR') ? $locale->text('AR Transactions') : $locale->text('AP Transactions');
  822. $invnumber = qq|
  823. <tr>
  824. <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
  825. <td colspan=3><input name=invnumber size=20></td>
  826. </tr>
  827. <tr>
  828. <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
  829. <td colspan=3><input name=ordnumber size=20></td>
  830. </tr>
  831. <tr>
  832. <th align=right nowrap>|.$locale->text('PO Number').qq|</th>
  833. <td colspan=3><input name=ponumber size=20></td>
  834. </tr>
  835. <tr>
  836. <th align=right nowrap>|.$locale->text('Source').qq|</th>
  837. <td colspan=3><input name=source size=40></td>
  838. </tr>
  839. <tr>
  840. <th align=right nowrap>|.$locale->text('Description').qq|</th>
  841. <td colspan=3><input name=description size=40></td>
  842. </tr>
  843. <tr>
  844. <th align=right nowrap>|.$locale->text('Notes').qq|</th>
  845. <td colspan=3><input name=notes size=40></td>
  846. </tr>
  847. |;
  848. $openclosed = qq|
  849. <tr>
  850. <td nowrap><input name=open class=checkbox type=checkbox value=Y checked> |.$locale->text('Open').qq|</td>
  851. <td nowrap><input name=closed class=checkbox type=checkbox value=Y> |.$locale->text('Closed').qq|</td>
  852. </tr>
  853. |;
  854. $summary = qq|
  855. <tr>
  856. <td><input name=summary type=radio class=radio value=1 checked> |.$locale->text('Summary').qq|</td>
  857. <td><input name=summary type=radio class=radio value=0> |.$locale->text('Detail').qq|
  858. </td>
  859. </tr>
  860. |;
  861. if ($form->{outstanding}) {
  862. $form->{title} = ($form->{ARAP} eq 'AR') ? $locale->text('AR Outstanding') : $locale->text('AP Outstanding');
  863. $invnumber = "";
  864. $openclosed = "";
  865. $summary = "";
  866. }
  867. if (@{ $form->{all_years} }) {
  868. # accounting years
  869. $form->{selectaccountingyear} = "<option>\n";
  870. for (@{ $form->{all_years} }) { $form->{selectaccountingyear} .= qq|<option>$_\n| }
  871. $form->{selectaccountingmonth} = "<option>\n";
  872. for (sort keys %{ $form->{all_month} }) { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| }
  873. $selectfrom = qq|
  874. <tr>
  875. <th align=right>|.$locale->text('Period').qq|</th>
  876. <td colspan=3>
  877. <select name=month>$form->{selectaccountingmonth}</select>
  878. <select name=year>$form->{selectaccountingyear}</select>
  879. <input name=interval class=radio type=radio value=0 checked>&nbsp;|.$locale->text('Current').qq|
  880. <input name=interval class=radio type=radio value=1>&nbsp;|.$locale->text('Month').qq|
  881. <input name=interval class=radio type=radio value=3>&nbsp;|.$locale->text('Quarter').qq|
  882. <input name=interval class=radio type=radio value=12>&nbsp;|.$locale->text('Year').qq|
  883. </td>
  884. </tr>
  885. |;
  886. }
  887. $name = $locale->text('Customer');
  888. $l_name = qq|<input name="l_name" class=checkbox type=checkbox value=Y checked> $name|;
  889. $l_till = qq|<input name="l_till" class=checkbox type=checkbox value=Y> |.$locale->text('Till');
  890. if ($form->{vc} eq 'vendor') {
  891. $name = $locale->text('Vendor');
  892. $l_till = "";
  893. $l_name = qq|<input name="l_name" class=checkbox type=checkbox value=Y checked> $name|;
  894. }
  895. @a = ();
  896. push @a, qq|<input name="l_runningnumber" class=checkbox type=checkbox value=Y> |.$locale->text('No.');
  897. push @a, qq|<input name="l_id" class=checkbox type=checkbox value=Y> |.$locale->text('ID');
  898. push @a, qq|<input name="l_invnumber" class=checkbox type=checkbox value=Y checked> |.$locale->text('Invoice Number');
  899. push @a, qq|<input name="l_ordnumber" class=checkbox type=checkbox value=Y> |.$locale->text('Order Number');
  900. push @a, qq|<input name="l_ponumber" class=checkbox type=checkbox value=Y> |.$locale->text('PO Number');
  901. push @a, qq|<input name="l_transdate" class=checkbox type=checkbox value=Y checked> |.$locale->text('Invoice Date');
  902. push @a, $l_name;
  903. push @a, $l_employee if $l_employee;
  904. push @a, $l_manager if $l_employee;
  905. push @a, $l_department if $l_department;
  906. push @a, qq|<input name="l_netamount" class=checkbox type=checkbox value=Y> |.$locale->text('Amount');
  907. push @a, qq|<input name="l_tax" class=checkbox type=checkbox value=Y> |.$locale->text('Tax');
  908. push @a, qq|<input name="l_amount" class=checkbox type=checkbox value=Y checked> |.$locale->text('Total');
  909. push @a, qq|<input name="l_curr" class=checkbox type=checkbox value=Y> |.$locale->text('Currency');
  910. push @a, qq|<input name="l_datepaid" class=checkbox type=checkbox value=Y> |.$locale->text('Date Paid');
  911. push @a, qq|<input name="l_paid" class=checkbox type=checkbox value=Y checked> |.$locale->text('Paid');
  912. push @a, qq|<input name="l_duedate" class=checkbox type=checkbox value=Y> |.$locale->text('Due Date');
  913. push @a, qq|<input name="l_due" class=checkbox type=checkbox value=Y> |.$locale->text('Amount Due');
  914. push @a, qq|<input name="l_notes" class=checkbox type=checkbox value=Y> |.$locale->text('Notes');
  915. push @a, $l_till if $l_till;
  916. push @a, qq|<input name="l_shippingpoint" class=checkbox type=checkbox value=Y> |.$locale->text('Shipping Point');
  917. push @a, qq|<input name="l_shipvia" class=checkbox type=checkbox value=Y> |.$locale->text('Ship via');
  918. $form->header;
  919. print qq|
  920. <body>
  921. <form method=post action=$form->{script}>
  922. <table width=100%>
  923. <tr><th class=listtop>$form->{title}</th></tr>
  924. <tr height="5"></tr>
  925. <tr>
  926. <td>
  927. <table>
  928. <tr>
  929. <th align=right>|.$locale->text('Account').qq|</th>
  930. <td colspan=3><select name=$form->{ARAP}>$form->{"select$form->{ARAP}"}</select></td>
  931. </tr>
  932. <tr>
  933. <th align=right>$name</th>
  934. <td colspan=3>$selectname</td>
  935. </tr>
  936. $employee
  937. $department
  938. $invnumber
  939. <tr>
  940. <th align=right>|.$locale->text('Ship via').qq|</th>
  941. <td colspan=3><input name=shipvia size=40></td>
  942. </tr>
  943. <tr>
  944. <th align=right nowrap>|.$locale->text('From').qq|</th>
  945. <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  946. <th align=right>|.$locale->text('To').qq|</th>
  947. <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  948. </tr>
  949. $selectfrom
  950. </table>
  951. </td>
  952. </tr>
  953. <tr>
  954. <td>
  955. <table>
  956. <tr>
  957. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  958. <td>
  959. <table width=100%>
  960. $openclosed
  961. $summary
  962. |;
  963. $form->{sort} = "transdate";
  964. $form->hide_form(qw(title outstanding sort));
  965. while (@a) {
  966. for (1 .. 5) {
  967. print qq|<td nowrap>|. shift @a;
  968. print qq|</td>\n|;
  969. }
  970. print qq|</tr>\n|;
  971. }
  972. print qq|
  973. <tr>
  974. <td nowrap><input name="l_subtotal" class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|</td>
  975. </tr>
  976. </table>
  977. </td>
  978. </tr>
  979. </table>
  980. </td>
  981. </tr>
  982. <tr>
  983. <td><hr size=3 noshade></td>
  984. </tr>
  985. </table>
  986. <br>
  987. <input type=hidden name=action value=continue>
  988. <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">|;
  989. $form->hide_form(qw(nextsub path login sessionid));
  990. print qq|
  991. </form>
  992. |;
  993. if ($form->{menubar}) {
  994. require "$form->{path}/menu.pl";
  995. &menubar;
  996. }
  997. print qq|
  998. </body>
  999. </html>
  1000. |;
  1001. }
  1002. sub transactions {
  1003. if ($form->{$form->{vc}}) {
  1004. $form->{$form->{vc}} = $form->unescape($form->{$form->{vc}});
  1005. ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
  1006. }
  1007. AA->transactions(\%myconfig, \%$form);
  1008. $href = "$form->{script}?action=transactions";
  1009. for (qw(direction oldsort till outstanding path login sessionid summary)) { $href .= qq|&$_=$form->{$_}| }
  1010. $href .= "&title=".$form->escape($form->{title});
  1011. $form->sort_order();
  1012. $callback = "$form->{script}?action=transactions";
  1013. for (qw(direction oldsort till outstanding path login sessionid summary)) { $callback .= qq|&$_=$form->{$_}| }
  1014. $callback .= "&title=".$form->escape($form->{title},1);
  1015. if ($form->{$form->{ARAP}}) {
  1016. $callback .= "&$form->{ARAP}=".$form->escape($form->{$form->{ARAP}},1);
  1017. $href .= "&$form->{ARAP}=".$form->escape($form->{$form->{ARAP}});
  1018. $form->{$form->{ARAP}} =~ s/--/ /;
  1019. $option = $locale->text('Account')." : $form->{$form->{ARAP}}";
  1020. }
  1021. if ($form->{$form->{vc}}) {
  1022. $callback .= "&$form->{vc}=".$form->escape($form->{$form->{vc}},1).qq|--$form->{"$form->{vc}_id"}|;
  1023. $href .= "&$form->{vc}=".$form->escape($form->{$form->{vc}}).qq|--$form->{"$form->{vc}_id"}|;
  1024. $option .= "\n<br>" if ($option);
  1025. $name = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
  1026. $option .= "$name : $form->{$form->{vc}}";
  1027. }
  1028. if ($form->{department}) {
  1029. $callback .= "&department=".$form->escape($form->{department},1);
  1030. $href .= "&department=".$form->escape($form->{department});
  1031. ($department) = split /--/, $form->{department};
  1032. $option .= "\n<br>" if ($option);
  1033. $option .= $locale->text('Department')." : $department";
  1034. }
  1035. if ($form->{employee}) {
  1036. $callback .= "&employee=".$form->escape($form->{employee},1);
  1037. $href .= "&employee=".$form->escape($form->{employee});
  1038. ($employee) = split /--/, $form->{employee};
  1039. $option .= "\n<br>" if ($option);
  1040. if ($form->{ARAP} eq 'AR') {
  1041. $option .= $locale->text('Salesperson');
  1042. } else {
  1043. $option .= $locale->text('Employee');
  1044. }
  1045. $option .= " : $employee";
  1046. }
  1047. if ($form->{invnumber}) {
  1048. $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
  1049. $href .= "&invnumber=".$form->escape($form->{invnumber});
  1050. $option .= "\n<br>" if ($option);
  1051. $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
  1052. }
  1053. if ($form->{ordnumber}) {
  1054. $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
  1055. $href .= "&ordnumber=".$form->escape($form->{ordnumber});
  1056. $option .= "\n<br>" if ($option);
  1057. $option .= $locale->text('Order Number')." : $form->{ordnumber}";
  1058. }
  1059. if ($form->{ponumber}) {
  1060. $callback .= "&ponumber=".$form->escape($form->{ponumber},1);
  1061. $href .= "&ponumber=".$form->escape($form->{ponumber});
  1062. $option .= "\n<br>" if ($option);
  1063. $option .= $locale->text('PO Number')." : $form->{ponumber}";
  1064. }
  1065. if ($form->{source}) {
  1066. $callback .= "&source=".$form->escape($form->{source},1);
  1067. $href .= "&source=".$form->escape($form->{source});
  1068. $option .= "\n<br>" if $option;
  1069. $option .= $locale->text('Source')." : $form->{source}";
  1070. }
  1071. if ($form->{description}) {
  1072. $callback .= "&description=".$form->escape($form->{description},1);
  1073. $href .= "&description=".$form->escape($form->{description});
  1074. $option .= "\n<br>" if $option;
  1075. $option .= $locale->text('Description')." : $form->{description}";
  1076. }
  1077. if ($form->{notes}) {
  1078. $callback .= "&notes=".$form->escape($form->{notes},1);
  1079. $href .= "&notes=".$form->escape($form->{notes});
  1080. $option .= "\n<br>" if $option;
  1081. $option .= $locale->text('Notes')." : $form->{notes}";
  1082. }
  1083. if ($form->{shipvia}) {
  1084. $callback .= "&shipvia=".$form->escape($form->{shipvia},1);
  1085. $href .= "&shipvia=".$form->escape($form->{shipvia});
  1086. $option .= "\n<br>" if $option;
  1087. $option .= $locale->text('Ship via')." : $form->{shipvia}";
  1088. }
  1089. if ($form->{transdatefrom}) {
  1090. $callback .= "&transdatefrom=$form->{transdatefrom}";
  1091. $href .= "&transdatefrom=$form->{transdatefrom}";
  1092. $option .= "\n<br>" if ($option);
  1093. $option .= $locale->text('From')."&nbsp;".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
  1094. }
  1095. if ($form->{transdateto}) {
  1096. $callback .= "&transdateto=$form->{transdateto}";
  1097. $href .= "&transdateto=$form->{transdateto}";
  1098. $option .= "\n<br>" if ($option);
  1099. $option .= $locale->text('To')."&nbsp;".$locale->date(\%myconfig, $form->{transdateto}, 1);
  1100. }
  1101. if ($form->{open}) {
  1102. $callback .= "&open=$form->{open}";
  1103. $href .= "&open=$form->{open}";
  1104. $option .= "\n<br>" if ($option);
  1105. $option .= $locale->text('Open');
  1106. }
  1107. if ($form->{closed}) {
  1108. $callback .= "&closed=$form->{closed}";
  1109. $href .= "&closed=$form->{closed}";
  1110. $option .= "\n<br>" if ($option);
  1111. $option .= $locale->text('Closed');
  1112. }
  1113. @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));
  1114. pop @columns if $form->{department};
  1115. unshift @columns, "runningnumber";
  1116. foreach $item (@columns) {
  1117. if ($form->{"l_$item"} eq "Y") {
  1118. push @column_index, $item;
  1119. if ($form->{l_curr} && $item =~ /(amount|tax|paid|due)/) {
  1120. push @column_index, "fx_$item";
  1121. }
  1122. # add column to href and callback
  1123. $callback .= "&l_$item=Y";
  1124. $href .= "&l_$item=Y";
  1125. }
  1126. }
  1127. if (!$form->{summary}) {
  1128. foreach $item (qw(source debit credit accno description projectnumber)) {
  1129. push @column_index, $item;
  1130. }
  1131. }
  1132. if ($form->{l_subtotal} eq 'Y') {
  1133. $callback .= "&l_subtotal=Y";
  1134. $href .= "&l_subtotal=Y";
  1135. }
  1136. $employee = ($form->{ARAP} eq 'AR') ? $locale->text('Salesperson') : $locale->text('Employee');
  1137. $name = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
  1138. $column_header{runningnumber} = qq|<th class=listheading>&nbsp;</th>|;
  1139. $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
  1140. $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
  1141. $column_header{duedate} = "<th><a class=listheading href=$href&sort=duedate>".$locale->text('Due Date')."</a></th>";
  1142. $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
  1143. $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
  1144. $column_header{ponumber} = "<th><a class=listheading href=$href&sort=ponumber>".$locale->text('PO Number')."</a></th>";
  1145. $column_header{name} = "<th><a class=listheading href=$href&sort=name>$name</a></th>";
  1146. $column_header{netamount} = "<th class=listheading>" . $locale->text('Amount') . "</th>";
  1147. $column_header{tax} = "<th class=listheading>" . $locale->text('Tax') . "</th>";
  1148. $column_header{amount} = "<th class=listheading>" . $locale->text('Total') . "</th>";
  1149. $column_header{paid} = "<th class=listheading>" . $locale->text('Paid') . "</th>";
  1150. $column_header{datepaid} = "<th><a class=listheading href=$href&sort=datepaid>" . $locale->text('Date Paid') . "</a></th>";
  1151. $column_header{due} = "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
  1152. $column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
  1153. $column_header{employee} = "<th><a class=listheading href=$href&sort=employee>$employee</th>";
  1154. $column_header{manager} = "<th><a class=listheading href=$href&sort=manager>".$locale->text('Manager')."</th>";
  1155. $column_header{till} = "<th class=listheading><a class=listheading href=$href&sort=till>".$locale->text('Till')."</th>";
  1156. $column_header{shippingpoint} = "<th><a class=listheading href=$href&sort=shippingpoint>" . $locale->text('Shipping Point') . "</a></th>";
  1157. $column_header{shipvia} = "<th><a class=listheading href=$href&sort=shipvia>" . $locale->text('Ship via') . "</a></th>";
  1158. $column_header{curr} = "<th><a class=listheading href=$href&sort=curr>" . $locale->text('Curr') . "</a></th>";
  1159. for (qw(amount tax netamount paid due)) { $column_header{"fx_$_"} = "<th>&nbsp;</th>" }
  1160. $column_header{department} = "<th><a class=listheading href=$href&sort=department>" . $locale->text('Department') . "</a></th>";
  1161. $column_header{accno} = "<th><a class=listheading href=$href&sort=accno>" . $locale->text('Account') . "</a></th>";
  1162. $column_header{source} = "<th><a class=listheading href=$href&sort=source>" . $locale->text('Source') . "</a></th>";
  1163. $column_header{debit} = "<th class=listheading>" . $locale->text('Debit') . "</th>";
  1164. $column_header{credit} = "<th class=listheading>" . $locale->text('Credit') . "</th>";
  1165. $column_header{projectnumber} = "<th><a class=listheading href=$href&sort=projectnumber>" . $locale->text('Project') . "</a></th>";
  1166. $column_header{description} = "<th><a class=listheading href=$href&sort=linedescription>" . $locale->text('Description') . "</a></th>";
  1167. $form->{title} = ($form->{title}) ? $form->{title} : $locale->text('AR Transactions');
  1168. $form->header;
  1169. print qq|
  1170. <body>
  1171. <table width=100%>
  1172. <tr>
  1173. <th class=listtop>$form->{title}</th>
  1174. </tr>
  1175. <tr height="5"></tr>
  1176. <tr>
  1177. <td>$option</td>
  1178. </tr>
  1179. <tr>
  1180. <td>
  1181. <table width=100%>
  1182. <tr class=listheading>
  1183. |;
  1184. for (@column_index) { print "\n$column_header{$_}" }
  1185. print qq|
  1186. </tr>
  1187. |;
  1188. # add sort and escape callback, this one we use for the add sub
  1189. $form->{callback} = $callback .= "&sort=$form->{sort}";
  1190. # escape callback for href
  1191. $callback = $form->escape($callback);
  1192. # flip direction
  1193. $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
  1194. $href =~ s/&direction=(\w+)&/&direction=$direction&/;
  1195. if (@{ $form->{transactions} }) {
  1196. $sameitem = $form->{transactions}->[0]->{$form->{sort}};
  1197. }
  1198. # sums and tax on reports by Antonio Gallardo
  1199. #
  1200. $i = 0;
  1201. foreach $ref (@{ $form->{transactions} }) {
  1202. $i++;
  1203. if ($form->{l_subtotal} eq 'Y') {
  1204. if ($sameitem ne $ref->{$form->{sort}}) {
  1205. &subtotal;
  1206. $sameitem = $ref->{$form->{sort}};
  1207. }
  1208. }
  1209. if ($form->{l_curr}) {
  1210. for (qw(netamount amount paid)) { $ref->{"fx_$_"} = $ref->{$_}/$ref->{exchangerate} }
  1211. for (qw(netamount amount paid)) { $column_data{"fx_$_"} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{"fx_$_"}, 2, "&nbsp;")."</td>" }
  1212. $column_data{fx_tax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{fx_amount} - $ref->{fx_netamount}, 2, "&nbsp;")."</td>";
  1213. $column_data{fx_due} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{fx_amount} - $ref->{fx_paid}, 2, "&nbsp;")."</td>";
  1214. $subtotalfxnetamount += $ref->{fx_netamount};
  1215. $subtotalfxamount += $ref->{fx_amount};
  1216. $subtotalfxpaid += $ref->{fx_paid};
  1217. $totalfxnetamount += $ref->{fx_netamount};
  1218. $totalfxamount += $ref->{fx_amount};
  1219. $totalfxpaid += $ref->{fx_paid};
  1220. }
  1221. $column_data{runningnumber} = "<td align=right>$i</td>";
  1222. for (qw(netamount amount paid debit credit)) { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{$_}, 2, "&nbsp;")."</td>" }
  1223. $column_data{tax} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{netamount}, 2, "&nbsp;")."</td>";
  1224. $column_data{due} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} - $ref->{paid}, 2, "&nbsp;")."</td>";
  1225. $subtotalnetamount += $ref->{netamount};
  1226. $subtotalamount += $ref->{amount};
  1227. $subtotalpaid += $ref->{paid};
  1228. $subtotaldebit += $ref->{debit};
  1229. $subtotalcredit += $ref->{credit};
  1230. $totalnetamount += $ref->{netamount};
  1231. $totalamount += $ref->{amount};
  1232. $totalpaid += $ref->{paid};
  1233. $totaldebit += $ref->{debit};
  1234. $totalcredit += $ref->{credit};
  1235. $module = ($ref->{invoice}) ? ($form->{ARAP} eq 'AR') ? "is.pl" : "ir.pl" : $form->{script};
  1236. $module = ($ref->{till}) ? "ps.pl" : $module;
  1237. $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>";
  1238. for (qw(notes description)) { $ref->{$_} =~ s/\r?\n/<br>/g }
  1239. for (qw(transdate datepaid duedate department ordnumber ponumber notes shippingpoint shipvia employee manager till source description projectnumber)) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  1240. for (qw(id curr)) { $column_data{$_} = "<td>$ref->{$_}</td>" }
  1241. $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>|;
  1242. $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>|;
  1243. if ($ref->{id} != $sameid) {
  1244. $j++; $j %= 2;
  1245. }
  1246. print "
  1247. <tr class=listrow$j>
  1248. ";
  1249. for (@column_index) { print "\n$column_data{$_}" }
  1250. print qq|
  1251. </tr>
  1252. |;
  1253. $sameid = $ref->{id};
  1254. }
  1255. if ($form->{l_subtotal} eq 'Y') {
  1256. &subtotal;
  1257. $sameitem = $ref->{$form->{sort}};
  1258. }
  1259. # print totals
  1260. print qq|
  1261. <tr class=listtotal>
  1262. |;
  1263. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1264. $column_data{netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalnetamount, 2, "&nbsp;")."</th>";
  1265. $column_data{tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalnetamount, 2, "&nbsp;")."</th>";
  1266. $column_data{amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount, 2, "&nbsp;")."</th>";
  1267. $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalpaid, 2, "&nbsp;")."</th>";
  1268. $column_data{due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalpaid, 2, "&nbsp;")."</th>";
  1269. $column_data{debit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totaldebit, 2, "&nbsp;")."</th>";
  1270. $column_data{credit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalcredit, 2, "&nbsp;")."</th>";
  1271. if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
  1272. $column_data{fx_netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxnetamount, 2, "&nbsp;")."</th>";
  1273. $column_data{fx_tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxnetamount, 2, "&nbsp;")."</th>";
  1274. $column_data{fx_amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount, 2, "&nbsp;")."</th>";
  1275. $column_data{fx_paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxpaid, 2, "&nbsp;")."</th>";
  1276. $column_data{fx_due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxpaid, 2, "&nbsp;")."</th>";
  1277. }
  1278. for (@column_index) { print "\n$column_data{$_}" }
  1279. if ($myconfig{acs} !~ /$form->{ARAP}--$form->{ARAP}/) {
  1280. $i = 1;
  1281. if ($form->{ARAP} eq 'AR') {
  1282. $button{'AR--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|"> |;
  1283. $button{'AR--Add Transaction'}{order} = $i++;
  1284. $button{'AR--Sales Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice.').qq|"> |;
  1285. $button{'AR--Sales Invoice'}{order} = $i++;
  1286. } else {
  1287. $button{'AP--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|"> |;
  1288. $button{'AP--Add Transaction'}{order} = $i++;
  1289. $button{'AP--Vendor Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice.').qq|"> |;
  1290. $button{'AP--Vendor Invoice'}{order} = $i++;
  1291. }
  1292. foreach $item (split /;/, $myconfig{acs}) {
  1293. delete $button{$item};
  1294. }
  1295. }
  1296. print qq|
  1297. </tr>
  1298. </table>
  1299. </td>
  1300. </tr>
  1301. <tr>
  1302. <td><hr size=3 noshade></td>
  1303. </tr>
  1304. </table>
  1305. <br>
  1306. <form method=post action=$form->{script}>
  1307. |;
  1308. $form->hide_form("callback", "path", "login", "sessionid", "$form->{vc}", "$form->{vc}_id");
  1309. if (! $form->{till}) {
  1310. foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
  1311. print $item->{code};
  1312. }
  1313. }
  1314. if ($form->{menubar}) {
  1315. require "$form->{path}/menu.pl";
  1316. &menubar;
  1317. }
  1318. print qq|
  1319. </form>
  1320. </body>
  1321. </html>
  1322. |;
  1323. }
  1324. sub subtotal {
  1325. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  1326. $column_data{tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount, 2, "&nbsp;")."</th>";
  1327. $column_data{amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount, 2, "&nbsp;")."</th>";
  1328. $column_data{paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalpaid, 2, "&nbsp;")."</th>";
  1329. $column_data{due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalpaid, 2, "&nbsp;")."</th>";
  1330. $column_data{debit} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotaldebit, 2, "&nbsp;")."</th>";
  1331. $column_data{credit} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalcredit, 2, "&nbsp;")."</th>";
  1332. if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
  1333. $column_data{fx_tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount - $subtotalfxnetamount, 2, "&nbsp;")."</th>";
  1334. $column_data{fx_amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount, 2, "&nbsp;")."</th>";
  1335. $column_data{fx_paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxpaid, 2, "&nbsp;")."</th>";
  1336. $column_data{fx_due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxmount - $subtotalfxpaid, 2, "&nbsp;")."</th>";
  1337. }
  1338. $subtotalnetamount = 0;
  1339. $subtotalamount = 0;
  1340. $subtotalpaid = 0;
  1341. $subtotaldebit = 0;
  1342. $subtotalcredit = 0;
  1343. $subtotalfxnetamount = 0;
  1344. $subtotalfxamount = 0;
  1345. $subtotalfxpaid = 0;
  1346. print "<tr class=listsubtotal>";
  1347. for (@column_index) { print "\n$column_data{$_}" }
  1348. print "
  1349. </tr>
  1350. ";
  1351. }