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>| . $locale->text('Exchangerate Difference') . qq|</th>
340 <td align=right>$fx</td>
356 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
358 <td align=right>$clearedbalance</td>
368 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
370 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
373 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
375 <td align=right><input name=null size=11 value=$difference></td>
376 <input type=hidden name=difference value=$difference>
385 <td><hr size=3 noshade></td>
389 <input type=hidden name=rowcount value=$i>
390 <input type=hidden name=accno value=$form->{accno}>
391 <input type=hidden name=account value="$form->{account}">
393 <input type=hidden name=fromdate value=$form->{fromdate}>
394 <input type=hidden name=todate value=$form->{todate}>
397 <input type=submit class=submit name=action value="|
398 . $locale->text('Update') . qq|">
399 <input type=submit class=submit name=action value="|
400 . $locale->text('Select all') . qq|">
401 <input type=submit class=submit name=action value="|
402 . $locale->text('Done') . qq|">
410 $main::lxdebug->leave_sub();
414 $main::lxdebug->enter_sub();
416 my $form = $main::form;
417 my %myconfig = %main::myconfig;
419 $main::auth->assert('cash');
421 RC->payment_transactions(\%myconfig, \%$form);
424 foreach my $ref (@{ $form->{PR} }) {
425 if (!$ref->{fx_transaction}) {
427 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
433 $main::lxdebug->leave_sub();
437 $main::lxdebug->enter_sub();
439 my $form = $main::form;
440 my %myconfig = %main::myconfig;
442 $main::auth->assert('cash');
444 RC->payment_transactions(\%myconfig, \%$form);
446 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
451 $main::lxdebug->leave_sub();
455 $main::lxdebug->enter_sub();
457 my $form = $main::form;
458 my %myconfig = %main::myconfig;
459 my $locale = $main::locale;
461 $main::auth->assert('cash');
463 $form->{callback} = "$form->{script}?action=reconciliation";
465 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
467 RC->reconcile(\%myconfig, \%$form);
470 $main::lxdebug->leave_sub();