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";
43 $lxdebug->enter_sub();
45 RC->paymentaccounts(\%myconfig, \%$form);
48 map { $selection .= "<option>$_->{accno}--$_->{description}\n" }
51 $form->{title} = $locale->text('Reconciliation');
52 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
53 $form->{"jsscript"} = 1;
55 $onload = qq|focus()|;
56 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
59 <body onLoad="$onload">
61 <form method=post action=$form->{script}>
65 <th class=listtop>$form->{title}</th>
72 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
73 <td colspan=3><select name=accno>$selection</select>
77 <th align=right>| . $locale->text('From') . qq|</th>
78 <td><input name=fromdate id=fromdate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
79 <input type="button" name="fromdate" id="trigger_fromdate" value="?"></td>
80 <th align=right>| . $locale->text('Until') . qq|</th>
81 <td><input name=todate id=todate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
82 <input type="button" name="todate" id="trigger_todate" value="?"></td>
88 <td><hr size=3 noshade></td>
92 | . $form->write_trigger(\%myconfig, 2,
93 "fromdate", "BL", "trigger_fromdate",
94 "todate", "BL", "trigger_todate") . qq|
97 <input type=hidden name=nextsub value=get_payments>
99 <input type=hidden name=path value=$form->{path}>
100 <input type=hidden name=login value=$form->{login}>
101 <input type=hidden name=password value=$form->{password}>
103 <input type=submit class=submit name=action value="|
104 . $locale->text('Continue') . qq|">
112 $lxdebug->leave_sub();
115 sub continue { call_sub($form->{"nextsub"}); }
118 $lxdebug->enter_sub();
120 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
122 RC->payment_transactions(\%myconfig, \%$form);
126 $lxdebug->leave_sub();
130 $lxdebug->enter_sub();
132 @column_index = qw(cleared transdate source name credit debit balance);
134 $column_header{cleared} = "<th> </th>";
135 $column_header{source} =
136 "<th class=listheading>" . $locale->text('Source') . "</a></th>";
137 $column_header{name} =
138 "<th class=listheading>" . $locale->text('Description') . "</a></th>";
139 $column_header{transdate} =
140 "<th class=listheading>" . $locale->text('Date') . "</a></th>";
142 if ($form->{category} eq 'A') {
143 $column_header{debit} =
144 "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
145 $column_header{credit} =
146 "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
148 $column_header{debit} =
149 "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
150 $column_header{credit} =
151 "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
154 $column_header{balance} =
155 "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
157 if ($form->{fromdate}) {
158 $option .= "\n<br>" if ($option);
160 $locale->text('From') . " "
161 . $locale->date(\%myconfig, $form->{fromdate}, 0);
163 if ($form->{todate}) {
164 $option .= "\n<br>" if ($option);
166 $locale->text('Until') . " "
167 . $locale->date(\%myconfig, $form->{todate}, 0);
170 $form->{title} = "$form->{accno}--$form->{account}";
177 <form method=post action=$form->{script}>
181 <th class=listtop>$form->{title}</th>
190 <tr class=listheading>
193 map { print "\n$column_header{$_}" } @column_index;
199 $ml = ($form->{category} eq 'A') ? -1 : 1;
200 $form->{beginningbalance} *= $ml;
201 $clearedbalance = $balance = $form->{beginningbalance};
205 map { $column_data{$_} = "<td> </td>" }
206 qw(cleared transdate source name debit credit);
207 $column_data{balance} =
209 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
215 map { print "\n$column_data{$_}" } @column_index;
221 foreach $ref (@{ $form->{PR} }) {
223 $balance += $ref->{amount} * $ml;
224 $cleared += $ref->{amount} * $ml if $ref->{cleared};
226 $column_data{name} = "<td>$ref->{name} </td>";
227 $column_data{source} = qq|<td>$ref->{source} </a>
229 $column_data{transdate} = "<td>$ref->{transdate} </td>";
231 $column_data{debit} = "<td> </td>";
232 $column_data{credit} = "<td> </td>";
234 if ($ref->{amount} < 0) {
235 $totaldebits += $ref->{amount} * -1;
236 $column_data{debit} =
238 . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
241 $totalcredits += $ref->{amount};
242 $column_data{credit} =
244 . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
248 $column_data{balance} =
250 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
252 if ($ref->{fx_transaction}) {
253 $i++ unless $id == $ref->{id};
255 $fx += $ref->{amount} * $ml;
256 $column_data{cleared} = qq|<td align=center>
257 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
260 $i++ unless ($fx_transaction && $id == $ref->{id});
262 $column_data{cleared} = qq|<td>
263 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
264 <input type=hidden name="oid_$i" value=$ref->{oid}>
275 map { print "\n$column_data{$_}" } @column_index;
284 map { $column_data{$_} = "<td> </td>" } @column_index;
286 $column_data{debit} =
287 "<th class=listtotal align=right>"
288 . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
289 $column_data{credit} =
290 "<th class=listtotal align=right>"
291 . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
297 map { print "\n$column_data{$_}" } @column_index;
299 $form->{statementbalance} =
300 $form->parse_amount(\%myconfig, $form->{statementbalance});
302 $form->format_amount(\%myconfig,
303 $form->{statementbalance} - $clearedbalance - $cleared,
306 $form->{statementbalance} =
307 $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
309 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
312 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
314 <th align=right nowrap>|
315 . $locale->text('Exchangerate Difference') . qq|</th>
317 <td align=right>$fx</td>
333 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
335 <td align=right>$clearedbalance</td>
345 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
347 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
350 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
352 <td align=right><input name=null size=11 value=$difference></td>
353 <input type=hidden name=difference value=$difference>
362 <td><hr size=3 noshade></td>
366 <input type=hidden name=rowcount value=$i>
367 <input type=hidden name=accno value=$form->{accno}>
368 <input type=hidden name=account value="$form->{account}">
370 <input type=hidden name=fromdate value=$form->{fromdate}>
371 <input type=hidden name=todate value=$form->{todate}>
373 <input type=hidden name=path value=$form->{path}>
374 <input type=hidden name=login value=$form->{login}>
375 <input type=hidden name=password value=$form->{password}>
378 <input type=submit class=submit name=action value="|
379 . $locale->text('Update') . qq|">
380 <input type=submit class=submit name=action value="|
381 . $locale->text('Select all') . qq|">
382 <input type=submit class=submit name=action value="|
383 . $locale->text('Done') . qq|">
391 $lxdebug->leave_sub();
395 $lxdebug->enter_sub();
397 RC->payment_transactions(\%myconfig, \%$form);
399 foreach $ref (@{ $form->{PR} }) {
400 if (!$ref->{fx_transaction}) {
402 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
408 $lxdebug->leave_sub();
412 $lxdebug->enter_sub();
414 RC->payment_transactions(\%myconfig, \%$form);
416 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
421 $lxdebug->leave_sub();
425 $lxdebug->enter_sub();
428 "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&password=$form->{password}";
430 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
432 RC->reconcile(\%myconfig, \%$form);
435 $lxdebug->leave_sub();