1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
30 # Account reconciliation module
32 #======================================================================
36 require "bin/mozilla/common.pl";
45 $main::lxdebug->enter_sub();
47 my $form = $main::form;
48 my %myconfig = %main::myconfig;
49 my $locale = $main::locale;
51 $main::auth->assert('cash');
53 RC->paymentaccounts(\%myconfig, \%$form);
56 map { $selection .= "<option>$_->{accno}--$_->{description}\n" }
59 $form->{title} = $locale->text('Reconciliation');
60 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
61 $form->{"jsscript"} = 1;
63 my $onload = qq|focus()|;
64 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
67 <body onLoad="$onload">
69 <form method=post action=$form->{script}>
73 <th class=listtop>$form->{title}</th>
80 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
81 <td colspan=3><select name=accno>$selection</select>
85 <th align=right>| . $locale->text('From') . qq|</th>
86 <td><input name=fromdate id=fromdate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
87 <input type="button" name="fromdate" id="trigger_fromdate" value="?"></td>
88 <th align=right>| . $locale->text('Until') . qq|</th>
89 <td><input name=todate id=todate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
90 <input type="button" name="todate" id="trigger_todate" value="?"></td>
96 <td><hr size=3 noshade></td>
100 | . $form->write_trigger(\%myconfig, 2,
101 "fromdate", "BL", "trigger_fromdate",
102 "todate", "BL", "trigger_todate") . qq|
105 <input type=hidden name=nextsub value=get_payments>
107 <input type=submit class=submit name=action value="|
108 . $locale->text('Continue') . qq|">
116 $main::lxdebug->leave_sub();
119 sub continue { call_sub($main::form->{"nextsub"}); }
122 $main::lxdebug->enter_sub();
124 my $form = $main::form;
125 my %myconfig = %main::myconfig;
127 $main::auth->assert('cash');
129 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
131 RC->payment_transactions(\%myconfig, \%$form);
135 $main::lxdebug->leave_sub();
139 $main::lxdebug->enter_sub();
141 my $form = $main::form;
142 my %myconfig = %main::myconfig;
143 my $locale = $main::locale;
145 $main::auth->assert('cash');
147 my @column_index = qw(cleared transdate source name credit debit balance);
149 $column_header{cleared} = "<th> </th>";
150 $column_header{source} =
151 "<th class=listheading>" . $locale->text('Source') . "</a></th>";
152 $column_header{name} =
153 "<th class=listheading>" . $locale->text('Description') . "</a></th>";
154 $column_header{transdate} =
155 "<th class=listheading>" . $locale->text('Date') . "</a></th>";
157 if ($form->{category} eq 'A') {
158 $column_header{debit} =
159 "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
160 $column_header{credit} =
161 "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
163 $column_header{debit} =
164 "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
165 $column_header{credit} =
166 "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
169 $column_header{balance} =
170 "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
173 if ($form->{fromdate}) {
174 $option .= "\n<br>" if ($option);
176 $locale->text('From') . " "
177 . $locale->date(\%myconfig, $form->{fromdate}, 0);
179 if ($form->{todate}) {
180 $option .= "\n<br>" if ($option);
182 $locale->text('Until') . " "
183 . $locale->date(\%myconfig, $form->{todate}, 0);
186 $form->{title} = "$form->{accno}--$form->{account}";
193 <form method=post action=$form->{script}>
197 <th class=listtop>$form->{title}</th>
206 <tr class=listheading>
209 map { print "\n$column_header{$_}" } @column_index;
215 my $ml = ($form->{category} eq 'A') ? -1 : 1;
216 $form->{beginningbalance} *= $ml;
217 my $balance = $form->{beginningbalance};
218 my $clearedbalance = $balance;
223 map { $column_data{$_} = "<td> </td>" }
224 qw(cleared transdate source name debit credit);
225 $column_data{balance} =
227 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
233 map { print "\n$column_data{$_}" } @column_index;
244 foreach my $ref (@{ $form->{PR} }) {
246 $balance += $ref->{amount} * $ml;
247 $cleared += $ref->{amount} * $ml if $ref->{cleared};
249 $column_data{name} = "<td>$ref->{name} </td>";
250 $column_data{source} = qq|<td>$ref->{source} </a>
252 $column_data{transdate} = "<td>$ref->{transdate} </td>";
254 $column_data{debit} = "<td> </td>";
255 $column_data{credit} = "<td> </td>";
257 if ($ref->{amount} < 0) {
258 $totaldebits += $ref->{amount} * -1;
259 $column_data{debit} =
261 . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
264 $totalcredits += $ref->{amount};
265 $column_data{credit} =
267 . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
271 $column_data{balance} =
273 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
275 if ($ref->{fx_transaction}) {
276 $i++ unless $id == $ref->{id};
278 $fx += $ref->{amount} * $ml;
279 $column_data{cleared} = qq|<td align=center>
280 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
283 $i++ unless ($fx_transaction && $id == $ref->{id});
285 $column_data{cleared} = qq|<td>
286 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
287 <input type=hidden name="oid_$i" value=$ref->{oid}>
298 map { print "\n$column_data{$_}" } @column_index;
307 map { $column_data{$_} = "<td> </td>" } @column_index;
309 $column_data{debit} =
310 "<th class=listtotal align=right>"
311 . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
312 $column_data{credit} =
313 "<th class=listtotal align=right>"
314 . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
320 map { print "\n$column_data{$_}" } @column_index;
322 $form->{statementbalance} =
323 $form->parse_amount(\%myconfig, $form->{statementbalance});
325 $form->format_amount(\%myconfig,
326 $form->{statementbalance} - $clearedbalance - $cleared,
329 $form->{statementbalance} =
330 $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
332 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
336 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
338 <th align=right nowrap>|
339 . $locale->text('Exchangerate Difference') . qq|</th>
341 <td align=right>$fx</td>
357 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
359 <td align=right>$clearedbalance</td>
369 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
371 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
374 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
376 <td align=right><input name=null size=11 value=$difference></td>
377 <input type=hidden name=difference value=$difference>
386 <td><hr size=3 noshade></td>
390 <input type=hidden name=rowcount value=$i>
391 <input type=hidden name=accno value=$form->{accno}>
392 <input type=hidden name=account value="$form->{account}">
394 <input type=hidden name=fromdate value=$form->{fromdate}>
395 <input type=hidden name=todate value=$form->{todate}>
398 <input type=submit class=submit name=action value="|
399 . $locale->text('Update') . qq|">
400 <input type=submit class=submit name=action value="|
401 . $locale->text('Select all') . qq|">
402 <input type=submit class=submit name=action value="|
403 . $locale->text('Done') . qq|">
411 $main::lxdebug->leave_sub();
415 $main::lxdebug->enter_sub();
417 my $form = $main::form;
418 my %myconfig = %main::myconfig;
420 $main::auth->assert('cash');
422 RC->payment_transactions(\%myconfig, \%$form);
425 foreach my $ref (@{ $form->{PR} }) {
426 if (!$ref->{fx_transaction}) {
428 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
434 $main::lxdebug->leave_sub();
438 $main::lxdebug->enter_sub();
440 my $form = $main::form;
441 my %myconfig = %main::myconfig;
443 $main::auth->assert('cash');
445 RC->payment_transactions(\%myconfig, \%$form);
447 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
452 $main::lxdebug->leave_sub();
456 $main::lxdebug->enter_sub();
458 my $form = $main::form;
459 my %myconfig = %main::myconfig;
460 my $locale = $main::locale;
462 $main::auth->assert('cash');
464 $form->{callback} = "$form->{script}?action=reconciliation";
466 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
468 RC->reconcile(\%myconfig, \%$form);
471 $main::lxdebug->leave_sub();