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