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