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 $auth->assert('cash');
47 RC->paymentaccounts(\%myconfig, \%$form);
50 map { $selection .= "<option>$_->{accno}--$_->{description}\n" }
53 $form->{title} = $locale->text('Reconciliation');
54 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
55 $form->{"jsscript"} = 1;
57 $onload = qq|focus()|;
58 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
61 <body onLoad="$onload">
63 <form method=post action=$form->{script}>
67 <th class=listtop>$form->{title}</th>
74 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
75 <td colspan=3><select name=accno>$selection</select>
79 <th align=right>| . $locale->text('From') . qq|</th>
80 <td><input name=fromdate id=fromdate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
81 <input type="button" name="fromdate" id="trigger_fromdate" value="?"></td>
82 <th align=right>| . $locale->text('Until') . qq|</th>
83 <td><input name=todate id=todate size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
84 <input type="button" name="todate" id="trigger_todate" value="?"></td>
90 <td><hr size=3 noshade></td>
94 | . $form->write_trigger(\%myconfig, 2,
95 "fromdate", "BL", "trigger_fromdate",
96 "todate", "BL", "trigger_todate") . qq|
99 <input type=hidden name=nextsub value=get_payments>
101 <input type=submit class=submit name=action value="|
102 . $locale->text('Continue') . qq|">
110 $lxdebug->leave_sub();
113 sub continue { call_sub($form->{"nextsub"}); }
116 $lxdebug->enter_sub();
118 $auth->assert('cash');
120 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
122 RC->payment_transactions(\%myconfig, \%$form);
126 $lxdebug->leave_sub();
130 $lxdebug->enter_sub();
132 $auth->assert('cash');
134 @column_index = qw(cleared transdate source name credit debit balance);
136 $column_header{cleared} = "<th> </th>";
137 $column_header{source} =
138 "<th class=listheading>" . $locale->text('Source') . "</a></th>";
139 $column_header{name} =
140 "<th class=listheading>" . $locale->text('Description') . "</a></th>";
141 $column_header{transdate} =
142 "<th class=listheading>" . $locale->text('Date') . "</a></th>";
144 if ($form->{category} eq 'A') {
145 $column_header{debit} =
146 "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
147 $column_header{credit} =
148 "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
150 $column_header{debit} =
151 "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
152 $column_header{credit} =
153 "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
156 $column_header{balance} =
157 "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
159 if ($form->{fromdate}) {
160 $option .= "\n<br>" if ($option);
162 $locale->text('From') . " "
163 . $locale->date(\%myconfig, $form->{fromdate}, 0);
165 if ($form->{todate}) {
166 $option .= "\n<br>" if ($option);
168 $locale->text('Until') . " "
169 . $locale->date(\%myconfig, $form->{todate}, 0);
172 $form->{title} = "$form->{accno}--$form->{account}";
179 <form method=post action=$form->{script}>
183 <th class=listtop>$form->{title}</th>
192 <tr class=listheading>
195 map { print "\n$column_header{$_}" } @column_index;
201 $ml = ($form->{category} eq 'A') ? -1 : 1;
202 $form->{beginningbalance} *= $ml;
203 $clearedbalance = $balance = $form->{beginningbalance};
207 map { $column_data{$_} = "<td> </td>" }
208 qw(cleared transdate source name debit credit);
209 $column_data{balance} =
211 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
217 map { print "\n$column_data{$_}" } @column_index;
223 foreach $ref (@{ $form->{PR} }) {
225 $balance += $ref->{amount} * $ml;
226 $cleared += $ref->{amount} * $ml if $ref->{cleared};
228 $column_data{name} = "<td>$ref->{name} </td>";
229 $column_data{source} = qq|<td>$ref->{source} </a>
231 $column_data{transdate} = "<td>$ref->{transdate} </td>";
233 $column_data{debit} = "<td> </td>";
234 $column_data{credit} = "<td> </td>";
236 if ($ref->{amount} < 0) {
237 $totaldebits += $ref->{amount} * -1;
238 $column_data{debit} =
240 . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
243 $totalcredits += $ref->{amount};
244 $column_data{credit} =
246 . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
250 $column_data{balance} =
252 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
254 if ($ref->{fx_transaction}) {
255 $i++ unless $id == $ref->{id};
257 $fx += $ref->{amount} * $ml;
258 $column_data{cleared} = qq|<td align=center>
259 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
262 $i++ unless ($fx_transaction && $id == $ref->{id});
264 $column_data{cleared} = qq|<td>
265 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
266 <input type=hidden name="oid_$i" value=$ref->{oid}>
277 map { print "\n$column_data{$_}" } @column_index;
286 map { $column_data{$_} = "<td> </td>" } @column_index;
288 $column_data{debit} =
289 "<th class=listtotal align=right>"
290 . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
291 $column_data{credit} =
292 "<th class=listtotal align=right>"
293 . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
299 map { print "\n$column_data{$_}" } @column_index;
301 $form->{statementbalance} =
302 $form->parse_amount(\%myconfig, $form->{statementbalance});
304 $form->format_amount(\%myconfig,
305 $form->{statementbalance} - $clearedbalance - $cleared,
308 $form->{statementbalance} =
309 $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
311 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
314 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
316 <th align=right nowrap>|
317 . $locale->text('Exchangerate Difference') . qq|</th>
319 <td align=right>$fx</td>
335 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
337 <td align=right>$clearedbalance</td>
347 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
349 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
352 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
354 <td align=right><input name=null size=11 value=$difference></td>
355 <input type=hidden name=difference value=$difference>
364 <td><hr size=3 noshade></td>
368 <input type=hidden name=rowcount value=$i>
369 <input type=hidden name=accno value=$form->{accno}>
370 <input type=hidden name=account value="$form->{account}">
372 <input type=hidden name=fromdate value=$form->{fromdate}>
373 <input type=hidden name=todate value=$form->{todate}>
376 <input type=submit class=submit name=action value="|
377 . $locale->text('Update') . qq|">
378 <input type=submit class=submit name=action value="|
379 . $locale->text('Select all') . qq|">
380 <input type=submit class=submit name=action value="|
381 . $locale->text('Done') . qq|">
389 $lxdebug->leave_sub();
393 $lxdebug->enter_sub();
395 $auth->assert('cash');
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 $auth->assert('cash');
416 RC->payment_transactions(\%myconfig, \%$form);
418 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
423 $lxdebug->leave_sub();
427 $lxdebug->enter_sub();
429 $auth->assert('cash');
431 $form->{callback} = "$form->{script}?action=reconciliation";
433 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
435 RC->reconcile(\%myconfig, \%$form);
438 $lxdebug->leave_sub();