summaryrefslogtreecommitdiff
path: root/bin/rc.pl
blob: 8f331a3bb35a8ac55a3f656b6b13f6e65cab0dda (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # http://www.ledgersmb.org/
  4. #
  5. # Copyright (C) 2006
  6. # This work contains copyrighted information from a number of sources all used
  7. # with permission.
  8. #
  9. # This file contains source code included with or based on SQL-Ledger which
  10. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  11. # under the GNU General Public License version 2 or, at your option, any later
  12. # version. For a full list including contact information of contributors,
  13. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  14. #
  15. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  16. # Copyright (c) 2003
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. #
  22. # This program is free software; you can redistribute it and/or modify
  23. # it under the terms of the GNU General Public License as published by
  24. # the Free Software Foundation; either version 2 of the License, or
  25. # (at your option) any later version.
  26. #
  27. # This program is distributed in the hope that it will be useful,
  28. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. # GNU General Public License for more details.
  31. # You should have received a copy of the GNU General Public License
  32. # along with this program; if not, write to the Free Software
  33. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  34. #======================================================================
  35. #
  36. # Account reconciliation module
  37. #
  38. #======================================================================
  39. use LedgerSMB::RC;
  40. 1;
  41. # end of main
  42. # this is for our long dates
  43. # $locale->text('January')
  44. # $locale->text('February')
  45. # $locale->text('March')
  46. # $locale->text('April')
  47. # $locale->text('May ')
  48. # $locale->text('June')
  49. # $locale->text('July')
  50. # $locale->text('August')
  51. # $locale->text('September')
  52. # $locale->text('October')
  53. # $locale->text('November')
  54. # $locale->text('December')
  55. # this is for our short month
  56. # $locale->text('Jan')
  57. # $locale->text('Feb')
  58. # $locale->text('Mar')
  59. # $locale->text('Apr')
  60. # $locale->text('May')
  61. # $locale->text('Jun')
  62. # $locale->text('Jul')
  63. # $locale->text('Aug')
  64. # $locale->text('Sep')
  65. # $locale->text('Oct')
  66. # $locale->text('Nov')
  67. # $locale->text('Dec')
  68. sub reconciliation {
  69. RC->paymentaccounts( \%myconfig, \%$form );
  70. $selection = "";
  71. for ( @{ $form->{PR} } ) {
  72. $selection .= "<option>$_->{accno}--$_->{description}\n";
  73. }
  74. $form->{title} = $locale->text('Reconciliation');
  75. if ( $form->{report} ) {
  76. $form->{title} = $locale->text('Reconciliation Report');
  77. $cleared = qq|
  78. <input type=hidden name=report value=1>
  79. <tr>
  80. <td align=right><input type=checkbox class=checkbox name=outstanding value=1 checked></td>
  81. <td>| . $locale->text('Outstanding') . qq|</td>
  82. <td align=right><input type=checkbox class=checkbox name=cleared value=1></td>
  83. <td>| . $locale->text('Cleared') . qq|</td>
  84. </tr>
  85. |;
  86. }
  87. if ( @{ $form->{all_years} } ) {
  88. # accounting years
  89. $form->{selectaccountingyear} = "<option>\n";
  90. for ( @{ $form->{all_years} } ) {
  91. $form->{selectaccountingyear} .= qq|<option>$_\n|;
  92. }
  93. $form->{selectaccountingmonth} = "<option>\n";
  94. for ( sort keys %{ $form->{all_month} } ) {
  95. $form->{selectaccountingmonth} .=
  96. qq|<option value=$_>|
  97. . $locale->text( $form->{all_month}{$_} ) . qq|\n|;
  98. }
  99. $selectfrom = qq|
  100. <tr>
  101. <th align=right>| . $locale->text('Period') . qq|</th>
  102. <td colspan=3>
  103. <select name=month>$form->{selectaccountingmonth}</select>
  104. <select name=year>$form->{selectaccountingyear}</select>
  105. <input name=interval class=radio type=radio value=0 checked>&nbsp;|
  106. . $locale->text('Current') . qq|
  107. <input name=interval class=radio type=radio value=1>&nbsp;|
  108. . $locale->text('Month') . qq|
  109. <input name=interval class=radio type=radio value=3>&nbsp;|
  110. . $locale->text('Quarter') . qq|
  111. <input name=interval class=radio type=radio value=12>&nbsp;|
  112. . $locale->text('Year') . qq|
  113. </td>
  114. </tr>
  115. |;
  116. }
  117. $form->header;
  118. print qq|
  119. <body>
  120. <form method=post action=$form->{script}>
  121. <table width=100%>
  122. <tr>
  123. <th class=listtop>$form->{title}</th>
  124. </tr>
  125. <tr height="5"></tr>
  126. <tr>
  127. <td>
  128. <table>
  129. <tr>
  130. <th align=right nowrap>| . $locale->text('Account') . qq|</th>
  131. <td colspan=3><select name=accno>$selection</select></td>
  132. </tr>
  133. <tr>
  134. <th align=right>| . $locale->text('From') . qq|</th>
  135. <td colspan=3><input class="date" name=fromdate size=11 title="$myconfig{dateformat}"> <b>|
  136. . $locale->text('To')
  137. . qq|</b> <input class="date" name=todate size=11 title="$myconfig{dateformat}"></td>
  138. </tr>
  139. $selectfrom
  140. $cleared
  141. <tr>
  142. <td></td>
  143. <td colspan=3><input type=radio style=radio name=summary value=1 checked> |
  144. . $locale->text('Summary') . qq|
  145. <input type=radio style=radio name=summary value=0> |
  146. . $locale->text('Detail')
  147. . qq|</td>
  148. </tr>
  149. <tr>
  150. <td></td>
  151. <td colspan=3><input type=checkbox class=checkbox name=fx_transaction value=1 checked> |
  152. . $locale->text('Include Exchange Rate Difference')
  153. . qq|</td>
  154. </tr>
  155. </table>
  156. </td>
  157. </tr>
  158. <tr>
  159. <td><hr size=3 noshade></td>
  160. </tr>
  161. </table>
  162. <br>
  163. <input type=hidden name=nextsub value=get_payments>
  164. |;
  165. $form->hide_form(qw(path login sessionid));
  166. print qq|
  167. <button type="submit" class="submit" name="action" value="continue">|
  168. . $locale->text('Continue')
  169. . qq|</button>
  170. </form>
  171. |;
  172. if ( $form->{lynx} ) {
  173. require "bin/menu.pl";
  174. &menubar;
  175. }
  176. print qq|
  177. </body>
  178. </html>
  179. |;
  180. }
  181. sub continue { &{ $form->{nextsub} } }
  182. sub till_closing {
  183. my %hiddens;
  184. $form->{callback} =
  185. "$form->{script}?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
  186. # $locale->text("Source");
  187. # $locale->text("Actual");
  188. # $locale->text("Expected");
  189. # $locale->text("Error");
  190. @colheadings = qw(Source Actual Expected Error);
  191. my $curren = $pos_config{'curren'};
  192. $form->{title} = $locale->text( "Closing Till For [_1]", $form->{login} );
  193. require "pos.conf.pl";
  194. RC->getposlines( \%myconfig, \%$form );
  195. $hiddens{path} = $form->{path};
  196. $hiddens{login} = $form->{login};
  197. $hiddens{sessionid} = $form->{sessionid};
  198. $hiddens{callback} = $form->{callback};
  199. $hiddens{sum} = "$form->{sum}" * -1;
  200. my $j;
  201. my $source;
  202. my @sources;
  203. foreach $source ( sort keys %pos_sources ) {
  204. $amount = 0;
  205. foreach $ref ( @{ $form->{TB} } ) {
  206. if ( $ref->{source} eq $source ) {
  207. $amount = $ref->{amount} * -1;
  208. last;
  209. }
  210. }
  211. ++$j;
  212. $j = $j % 2;
  213. push @sources, {i => $j,
  214. label => $pos_sources{$source},
  215. source => $source,
  216. currenamount => "${curren}${amount}",
  217. };
  218. $hiddens{"expected_$source"} = "$amount";
  219. }
  220. my @units;
  221. foreach my $unit ( @{ $pos_config{'breakdown'} } ) {
  222. # XXX Needs to take into account currencies that don't use 2 dp
  223. my $calcval = $form->parse_amount( \%pos_config, $unit );
  224. $calcval = sprintf( '%03d', $calcval * 100 ) if $calcval < 1;
  225. my $subval = 'sub_' . $calcval;
  226. my $unit_name = $calcval;
  227. $calcval = 'calc_' . $calcval;
  228. push @units, {
  229. unit => $unit,
  230. unit_name => "$unit_name",
  231. currenunit => "${curren}${unit}",
  232. quantity => {name => $calcval, value => $form->{$calcval}},
  233. value => {name => $subval, value => $form->{$subval}},
  234. };
  235. }
  236. my @buttons = ({
  237. name => 'calculate',
  238. value => 'Calculate',
  239. type => 'button',
  240. text => $locale->text('Calculate'),
  241. attributes => {onclick => 'custom_calc_total()'},
  242. }, {
  243. name => 'action',
  244. value => 'close_till',
  245. text => $locale->text('Close Till'),
  246. });
  247. my $template = LedgerSMB::Template->new_UI(
  248. user => \%myconfig,
  249. locale => $locale,
  250. template => 'rc-till-closing',
  251. );
  252. $template->render({
  253. form => $form,
  254. user => \%myconfig,
  255. 'pos' => \%pos_config,
  256. hiddens => \%hiddens,
  257. columns => \@colheadings,
  258. sources => \@sources,
  259. units => \@units,
  260. buttons => \@buttons,
  261. });
  262. }
  263. sub close_till {
  264. use LedgerSMB::GL;
  265. require 'pos.conf.pl';
  266. RC->clear_till( \%myconfig, \%$form );
  267. my $amount = 0;
  268. my $expected = 0;
  269. my $difference = 0;
  270. my $lines = '';
  271. $form->{rowcount} = 2;
  272. foreach $key ( keys %pos_sources ) {
  273. $amount = 0;
  274. $expected = 0;
  275. $amount = $form->parse_amount( \%myconfig, $form->{"amount_$key"} );
  276. $expected = $form->parse_amount( \%myconfig, $form->{"expected_$key"} );
  277. $gl_entry = "Closing Till $pos_config{till} source = $key";
  278. $accno1 = $pos_config{till_accno};
  279. if ( ${ $pos_config{'source_accno_override'}{$key} } ) {
  280. $accno2 = ${ $pos_config{'source_accno_override'}{$key} };
  281. }
  282. else {
  283. $accno2 = $pos_config{'close_cash_accno'};
  284. }
  285. $form->{reference} = $gl_entry;
  286. $form->{accno_1} = $accno1;
  287. $form->{credit_1} = $amount;
  288. $form->{accno_2} = $accno2;
  289. $form->{debit_2} = $amount;
  290. $form->{transdate} = $form->current_date( \%myconfig );
  291. GL->post_transaction( \%myconfig, \%$form );
  292. delete $form->{id};
  293. $error = $amount - $expected;
  294. $difference += $error;
  295. $lines .=
  296. "Source: $key, Amount: $amount\nExpected: $expected. Error= $error\n\n";
  297. }
  298. $gl_entry = "Closing Till: $pos_config{till} Over/Under";
  299. $amount = $difference * -1;
  300. $form->{reference} = $gl_entry;
  301. $form->{accno_1} = $accno1;
  302. $form->{credit_1} = $amount;
  303. $form->{accno_2} = $pos_config{coa_prefix};
  304. $form->{debit_2} = $amount;
  305. $form->{transdate} = $form->current_date( \%myconfig );
  306. GL->post_transaction( \%myconfig, \%$form );
  307. delete $form->{id};
  308. $lines .= "Cumulative Error: $amount";
  309. $form->{accno} = $form->{accno_1};
  310. RC->getbalance( \%myconfig, \%$form );
  311. $amount = $form->{balance} * -1;
  312. $gl_entry = "Resetting Till: $pos_config{till}";
  313. $form->{reference} = $gl_entry;
  314. $form->{accno_1} = $accno1;
  315. $form->{credit_1} = $amount;
  316. $form->{accno_2} = $pos_config{coa_prefix};
  317. $form->{debit_2} = $amount;
  318. $form->{transdate} = $form->current_date( \%myconfig );
  319. GL->post_transaction( \%myconfig, \%$form );
  320. delete $form->{id};
  321. $head =
  322. "Closing Till $pos_config{till} for $form->{login}\n"
  323. . "Date: $form->{transdate}\n\n\n";
  324. my @cashlines = [ $locale->text("Cash Breakdown:") ];
  325. foreach my $unit ( @{ $pos_config{'breakdown'} } ) {
  326. # XXX Needs to take into account currencies that don't use 2 dp
  327. my $parsed = $form->parse_amount( \%pos_config, $unit );
  328. my $calcval = $parsed;
  329. $calcval = sprintf( '%03d', $calcval * 100 ) if $calcval < 1;
  330. my $subval = 'sub_' . $calcval;
  331. $calcval = 'calc_' . $calcval;
  332. push @cashlines, "$form->{$calcval} x $parseval = $form->{$subval}";
  333. }
  334. push @cashlines,
  335. $locale->text( "Total Cash in Drawer: [_1]", $form->{sub_sub} );
  336. push @cashlines,
  337. $locale->text( "Less Cash in Till At Start: [_1]", $form->{till_cash} );
  338. push @cashlines, "\n";
  339. $cash = join( "\n", @cashlines );
  340. $foot = $locale->text( "Cumulative Error: [_1]", $difference ) . "\n";
  341. $foot .=
  342. $locale->text( 'Reset Till By [_1]', $amount ) . "\n\n\n\n\n\n\n\n\n\n";
  343. open( PRN, "|-", ${LedgerSMB::Sysconfig::printer}{Printer} );
  344. print PRN $head;
  345. print PRN $lines;
  346. print PRN $cash;
  347. print PRN $cash;
  348. print PRN $foot;
  349. close PRN;
  350. if ( $difference > 0 ) {
  351. $message = $locale->text( "You are over by [_1]", $difference );
  352. }
  353. elsif ( $difference < 0 ) {
  354. $message = $locale->text( "You are under by [_1]", $difference * -1 );
  355. }
  356. else {
  357. $message =
  358. $local->text("Congratulations! Your till is exactly balanced.");
  359. }
  360. $form->info($message);
  361. }
  362. sub get_payments {
  363. ( $form->{accno}, $form->{account} ) = split /--/, $form->{accno};
  364. if ( $form->{'pos'} ) {
  365. require "pos.conf.pl";
  366. $form->{fromdate} = $form->current_date( \%myconfig );
  367. unless ( $form->{source} ) {
  368. $form->{source} = ( sort keys(%pos_sources) )[0];
  369. }
  370. if ( $form->{source} eq 'cash' ) {
  371. $form->{summary} = "true";
  372. }
  373. else {
  374. $form->{summary} = "";
  375. }
  376. $form->{accno} = $pos_config{'coa_prefix'} . "." . $pos_config{'till'};
  377. $form->{account} = $form->{source};
  378. }
  379. RC->payment_transactions( \%myconfig, \%$form );
  380. $ml = ( $form->{category} eq 'A' ) ? -1 : 1;
  381. $form->{statementbalance} = $form->{endingbalance} * $ml;
  382. if ( !$form->{fx_transaction} ) {
  383. $form->{statementbalance} =
  384. ( $form->{endingbalance} - $form->{fx_endingbalance} ) * $ml;
  385. }
  386. $form->{statementbalance} =
  387. $form->format_amount( \%myconfig, $form->{statementbalance}, 2, 0 );
  388. &display_form;
  389. }
  390. sub display_form {
  391. if ( $form->{report} ) {
  392. @column_index = qw(transdate source name cleared debit credit);
  393. }
  394. else {
  395. @column_index = qw(transdate source name cleared debit credit balance);
  396. }
  397. $column_header{cleared} = qq|<th>| . $locale->text('R') . qq|</th>|;
  398. $column_header{source} =
  399. "<th class=listheading>" . $locale->text('Source') . "</a></th>";
  400. $column_header{name} =
  401. "<th class=listheading>" . $locale->text('Description') . "</a></th>";
  402. $column_header{transdate} =
  403. "<th class=listheading>" . $locale->text('Date') . "</a></th>";
  404. $column_header{debit} =
  405. "<th class=listheading>" . $locale->text('Debit') . "</a></th>";
  406. $column_header{credit} =
  407. "<th class=listheading>" . $locale->text('Credit') . "</a></th>";
  408. $column_header{balance} =
  409. "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
  410. if ( $form->{fromdate} ) {
  411. $option .= "\n<br>" if ($option);
  412. $option .=
  413. $locale->text('From') . "&nbsp;"
  414. . $locale->date( \%myconfig, $form->{fromdate}, 1 );
  415. }
  416. if ( $form->{todate} ) {
  417. $option .= "\n<br>" if ($option);
  418. $option .=
  419. $locale->text('To') . "&nbsp;"
  420. . $locale->date( \%myconfig, $form->{todate}, 1 );
  421. }
  422. $form->{title} = "$form->{accno}--$form->{account}";
  423. $form->header;
  424. print qq|
  425. <body>
  426. <form method=post action=$form->{script}>
  427. <input type=hidden name=source value="$form->{source}">
  428. <input type=hidden name=cumulative_error value="$form->{cumulative_error}">
  429. <table width=100%>
  430. <tr>
  431. <th class=listtop>$form->{title}</th>
  432. </tr>
  433. <tr height="5"></tr>
  434. <tr>
  435. <td>$option</td>
  436. </tr>
  437. <tr>
  438. <td>
  439. <table width=100%>
  440. <tr class=listheading>
  441. |;
  442. for (@column_index) { print "\n$column_header{$_}" }
  443. print qq|
  444. </tr>
  445. |;
  446. $ml = ( $form->{category} eq 'A' ) ? -1 : 1;
  447. $form->{beginningbalance} *= $ml;
  448. $form->{fx_balance} *= $ml;
  449. if ( !$form->{fx_transaction} ) {
  450. $form->{beginningbalance} -= $form->{fx_balance};
  451. }
  452. $balance = $form->{beginningbalance};
  453. $i = 0;
  454. $j = 0;
  455. for (qw(cleared transdate source debit credit)) {
  456. $column_data{$_} = "<td>&nbsp;</td>";
  457. }
  458. if ( !$form->{report} ) {
  459. $column_data{name} =
  460. qq|<td>| . $locale->text('Beginning Balance') . qq|</td>|;
  461. $column_data{balance} =
  462. "<td align=right>"
  463. . $form->format_amount( \%myconfig, $balance, 2, 0 ) . "</td>";
  464. print qq|
  465. <tr class=listrow$j>
  466. |;
  467. for (@column_index) { print "\n$column_data{$_}" }
  468. print qq|
  469. </tr>
  470. |;
  471. }
  472. foreach $ref ( @{ $form->{PR} } ) {
  473. $i++;
  474. if ( !$form->{fx_transaction} ) {
  475. next if $ref->{fx_transaction};
  476. }
  477. $checked = ( $ref->{cleared} ) ? "checked" : "";
  478. %temp = ();
  479. if ( !$ref->{fx_transaction} ) {
  480. for (qw(name source transdate)) { $temp{$_} = $ref->{$_} }
  481. }
  482. $column_data{name} = "<td>";
  483. for ( @{ $temp{name} } ) { $column_data{name} .= "$_<br>" }
  484. $column_data{name} .= "</td>";
  485. $column_data{source} = qq|<td>$temp{source}&nbsp;</td>
  486. <input type=hidden name="id_$i" value=$ref->{id}>|;
  487. $column_data{debit} = "<td>&nbsp;</td>";
  488. $column_data{credit} = "<td>&nbsp;</td>";
  489. $balance += $ref->{amount} * $ml;
  490. if ( $ref->{amount} < 0 ) {
  491. $totaldebits += $ref->{amount} * -1;
  492. $column_data{debit} = "<td align=right>"
  493. . $form->format_amount( \%myconfig, $ref->{amount} * -1,
  494. 2, "&nbsp;" )
  495. . "</td>";
  496. }
  497. else {
  498. $totalcredits += $ref->{amount};
  499. $column_data{credit} =
  500. "<td align=right>"
  501. . $form->format_amount( \%myconfig, $ref->{amount}, 2, "&nbsp;" )
  502. . "</td>";
  503. }
  504. $column_data{balance} =
  505. "<td align=right>"
  506. . $form->format_amount( \%myconfig, $balance, 2, 0 ) . "</td>";
  507. if ( $ref->{fx_transaction} ) {
  508. $column_data{cleared} =
  509. ($clearfx) ? qq|<td align=center>*</td>| : qq|<td>&nbsp;</td>|;
  510. $cleared += $ref->{amount} * $ml if $clearfx;
  511. }
  512. else {
  513. if ( $form->{report} ) {
  514. if ( $ref->{cleared} ) {
  515. $column_data{cleared} = qq|<td align=center>*</td>|;
  516. $clearfx = 1;
  517. }
  518. else {
  519. $column_data{cleared} = qq|<td>&nbsp;</td>|;
  520. $clearfx = 0;
  521. }
  522. }
  523. else {
  524. if ( $ref->{oldcleared} ) {
  525. $cleared += $ref->{amount} * $ml;
  526. $clearfx = 1;
  527. $column_data{cleared} = qq|<td align=center>*</td>
  528. <input type=hidden name="cleared_$i" value=$ref->{cleared}>
  529. <input type=hidden name="oldcleared_$i" value=$ref->{oldcleared}>
  530. <input type=hidden name="source_$i" value="$ref->{source}">
  531. <input type=hidden name="amount_$1" value="$ref->{amount}">|;
  532. }
  533. else {
  534. $cleared += $ref->{amount} * $ml if $checked;
  535. $clearfx = ($checked) ? 1 : 0;
  536. $column_data{cleared} =
  537. qq|<td align=center><input name="cleared_$i" type=checkbox class=checkbox value=1 $checked>
  538. <input type=hidden name="source_$i" value="$ref->{source}">
  539. <input type=hidden name="amount_$i" value="$ref->{amount}">
  540. </td>|;
  541. }
  542. }
  543. }
  544. $column_data{transdate} = qq|<td>$temp{transdate}&nbsp;</td>
  545. <input type=hidden name="transdate_$i" value=$ref->{transdate}>|;
  546. $j++;
  547. $j %= 2;
  548. print qq|
  549. <tr class=listrow$j>
  550. |;
  551. for (@column_index) { print "\n$column_data{$_}" }
  552. print qq|
  553. </tr>
  554. |;
  555. }
  556. $form->{rowcount} = $i;
  557. # print totals
  558. for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
  559. $column_data{debit} =
  560. "<th class=listtotal align=right>"
  561. . $form->format_amount( \%myconfig, $totaldebits, 2, "&nbsp;" ) . "</th>";
  562. $column_data{credit} =
  563. "<th class=listtotal align=right>"
  564. . $form->format_amount( \%myconfig, $totalcredits, 2, "&nbsp;" )
  565. . "</th>";
  566. print qq|
  567. <tr class=listtotal>
  568. |;
  569. for (@column_index) { print "\n$column_data{$_}" }
  570. $form->{statementbalance} =
  571. $form->parse_amount( \%myconfig, $form->{statementbalance} );
  572. $difference =
  573. $form->format_amount( \%myconfig,
  574. $form->{beginningbalance} + $cleared - $form->{statementbalance},
  575. 2, 0 );
  576. if ( $form->{source} ) {
  577. $difference = 0;
  578. }
  579. $form->{statementbalance} =
  580. $form->format_amount( \%myconfig, $form->{statementbalance}, 2, 0 );
  581. print qq|
  582. </tr>
  583. </table>
  584. </td>
  585. </tr>
  586. |;
  587. if ( $form->{'pos'} ) {
  588. $close_next = qq|<button type="submit" class="submit" name="action"
  589. value="close_next">| . $locale->text('Close Next') . qq|</button>|;
  590. $done = "";
  591. }
  592. else {
  593. $close_next = "";
  594. $done = qq|<button type="submit" class="submit" name="action"
  595. value="done">| . $locale->text('Done') . qq|</button>|;
  596. }
  597. if ( $form->{'pos'} ) {
  598. $difference = qq|
  599. <tr>
  600. <th align=right><select name=over_under>
  601. <option value=under>|
  602. . $locale->text('Under')
  603. . qq|</option>
  604. <option value=over>| . $locale->text('Over') . qq|</option>
  605. </select><input type=hidden name=pos value='true'>
  606. </th>
  607. <td width=10%></td>
  608. <td align=right><input name=null size=11
  609. value='| . $form->{null2} . qq|'></td>
  610. <input type=hidden name=difference
  611. value=$difference>
  612. |;
  613. if ( $form->{'over_under'} ) {
  614. $o_u = $form->{'over_under'};
  615. $difference =~ s/(value=$o_u)/SELECTED $1/g;
  616. }
  617. }
  618. else {
  619. $difference = qq|
  620. <tr>
  621. <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
  622. <td width=10%></td>
  623. <td align=right><input name=null size=11 value=$difference></td>
  624. <input type=hidden name=difference value=$difference>
  625. </tr>|;
  626. }
  627. if ( $form->{report} ) {
  628. print qq|
  629. </tr>
  630. </table>
  631. |;
  632. }
  633. else {
  634. print qq|
  635. <tr>
  636. <td>
  637. <table width=100%>
  638. <tr>
  639. <td align=right>
  640. <table>
  641. <tr>
  642. <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
  643. <td width=10%></td>
  644. <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
  645. </tr>
  646. $difference
  647. </table>
  648. </td>
  649. </tr>
  650. </table>
  651. </td>
  652. </tr>
  653. <tr>
  654. <td><hr size=3 noshade></td>
  655. </tr>
  656. </table>
  657. |;
  658. $form->hide_form(
  659. qw(fx_transaction summary rowcount accno account fromdate todate path login sessionid)
  660. );
  661. print qq|
  662. <br>
  663. <button type="submit" class="submit" name="action" value="update">|
  664. . $locale->text('Update')
  665. . qq|</button>
  666. <button type="submit" class="submit" name="action" value="select_all">|
  667. . $locale->text('Select all')
  668. . qq|</button>
  669. $done
  670. $close_next |;
  671. }
  672. if ( $form->{lynx} ) {
  673. require "bin/menu.pl";
  674. &menubar;
  675. }
  676. print qq|
  677. </form>
  678. </body>
  679. </html>
  680. |;
  681. }
  682. sub update {
  683. $form->{null2} = $form->{null};
  684. RC->payment_transactions( \%myconfig, \%$form );
  685. $i = 0;
  686. foreach $ref ( @{ $form->{PR} } ) {
  687. $i++;
  688. $ref->{cleared} = ( $form->{"cleared_$i"} ) ? 1 : 0;
  689. }
  690. &display_form;
  691. }
  692. sub select_all {
  693. RC->payment_transactions( \%myconfig, \%$form );
  694. for ( @{ $form->{PR} } ) { $_->{cleared} = 1 }
  695. &display_form;
  696. }
  697. sub done {
  698. $form->{callback} =
  699. "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&sessionid=$form->{sessionid}";
  700. $form->error( $locale->text('Out of balance!') )
  701. if ( $form->{difference} *= 1 );
  702. RC->reconcile( \%myconfig, \%$form );
  703. $form->redirect;
  704. }