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 $::lxdebug->enter_sub;
46 $::auth->assert('cash');
48 RC->paymentaccounts(\%::myconfig, $::form);
51 print $::form->parse_html_template('rc/step1', {
52 selection_sub => sub { ("$_[0]{accno}--$_[0]{description}")x2 },
55 $::lxdebug->leave_sub;
58 sub continue { call_sub($main::form->{"nextsub"}); }
61 $main::lxdebug->enter_sub();
63 my $form = $main::form;
64 my %myconfig = %main::myconfig;
66 $main::auth->assert('cash');
68 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
70 RC->payment_transactions(\%myconfig, \%$form);
74 $main::lxdebug->leave_sub();
78 $main::lxdebug->enter_sub();
80 my $form = $main::form;
81 my %myconfig = %main::myconfig;
82 my $locale = $main::locale;
84 $main::auth->assert('cash');
86 my @column_index = qw(cleared transdate source name credit debit balance);
88 $column_header{cleared} = "<th> </th>";
89 $column_header{source} =
90 "<th class=listheading>" . $locale->text('Source') . "</a></th>";
91 $column_header{name} =
92 "<th class=listheading>" . $locale->text('Description') . "</a></th>";
93 $column_header{transdate} =
94 "<th class=listheading>" . $locale->text('Date') . "</a></th>";
96 if ($form->{category} eq 'A') {
97 $column_header{debit} =
98 "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
99 $column_header{credit} =
100 "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
102 $column_header{debit} =
103 "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
104 $column_header{credit} =
105 "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
108 $column_header{balance} =
109 "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
112 if ($form->{fromdate}) {
113 $option .= "\n<br>" if ($option);
115 $locale->text('From') . " "
116 . $locale->date(\%myconfig, $form->{fromdate}, 0);
118 if ($form->{todate}) {
119 $option .= "\n<br>" if ($option);
121 $locale->text('Until') . " "
122 . $locale->date(\%myconfig, $form->{todate}, 0);
125 $form->{title} = "$form->{accno}--$form->{account}";
132 <form method=post action=$form->{script}>
136 <th class=listtop>$form->{title}</th>
145 <tr class=listheading>
148 map { print "\n$column_header{$_}" } @column_index;
154 my $ml = ($form->{category} eq 'A') ? -1 : 1;
155 $form->{beginningbalance} *= $ml;
156 my $balance = $form->{beginningbalance};
157 my $clearedbalance = $balance;
162 map { $column_data{$_} = "<td> </td>" }
163 qw(cleared transdate source name debit credit);
164 $column_data{balance} =
166 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
172 map { print "\n$column_data{$_}" } @column_index;
183 foreach my $ref (@{ $form->{PR} }) {
185 $balance += $ref->{amount} * $ml;
186 $cleared += $ref->{amount} * $ml if $ref->{cleared};
188 $column_data{name} = "<td>$ref->{name} </td>";
189 $column_data{source} = qq|<td>$ref->{source} </a>
191 $column_data{transdate} = "<td>$ref->{transdate} </td>";
193 $column_data{debit} = "<td> </td>";
194 $column_data{credit} = "<td> </td>";
196 if ($ref->{amount} < 0) {
197 $totaldebits += $ref->{amount} * -1;
198 $column_data{debit} =
200 . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
203 $totalcredits += $ref->{amount};
204 $column_data{credit} =
206 . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
210 $column_data{balance} =
212 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
214 if ($ref->{fx_transaction}) {
215 $i++ unless $id == $ref->{id};
217 $fx += $ref->{amount} * $ml;
218 $column_data{cleared} = qq|<td align=center>
219 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
222 $i++ unless ($fx_transaction && $id == $ref->{id});
224 $column_data{cleared} = qq|<td>
225 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
226 <input type=hidden name="oid_$i" value=$ref->{oid}>
237 map { print "\n$column_data{$_}" } @column_index;
246 map { $column_data{$_} = "<td> </td>" } @column_index;
248 $column_data{debit} =
249 "<th class=listtotal align=right>"
250 . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
251 $column_data{credit} =
252 "<th class=listtotal align=right>"
253 . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
259 map { print "\n$column_data{$_}" } @column_index;
261 $form->{statementbalance} =
262 $form->parse_amount(\%myconfig, $form->{statementbalance});
264 $form->format_amount(\%myconfig,
265 $form->{statementbalance} - $clearedbalance - $cleared,
268 $form->{statementbalance} =
269 $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
271 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
275 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
277 <th align=right nowrap>| . $locale->text('Exchangerate Difference') . qq|</th>
279 <td align=right>$fx</td>
295 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
297 <td align=right>$clearedbalance</td>
307 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
309 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
312 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
314 <td align=right><input name=null size=11 value=$difference></td>
315 <input type=hidden name=difference value=$difference>
324 <td><hr size=3 noshade></td>
328 <input type=hidden name=rowcount value=$i>
329 <input type=hidden name=accno value=$form->{accno}>
330 <input type=hidden name=account value="$form->{account}">
332 <input type=hidden name=fromdate value=$form->{fromdate}>
333 <input type=hidden name=todate value=$form->{todate}>
336 <input type=submit class=submit name=action value="|
337 . $locale->text('Update') . qq|">
338 <input type=submit class=submit name=action value="|
339 . $locale->text('Select all') . qq|">
340 <input type=submit class=submit name=action value="|
341 . $locale->text('Done') . qq|">
349 $main::lxdebug->leave_sub();
353 $main::lxdebug->enter_sub();
355 my $form = $main::form;
356 my %myconfig = %main::myconfig;
358 $main::auth->assert('cash');
360 RC->payment_transactions(\%myconfig, \%$form);
363 foreach my $ref (@{ $form->{PR} }) {
364 if (!$ref->{fx_transaction}) {
366 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
372 $main::lxdebug->leave_sub();
376 $main::lxdebug->enter_sub();
378 my $form = $main::form;
379 my %myconfig = %main::myconfig;
381 $main::auth->assert('cash');
383 RC->payment_transactions(\%myconfig, \%$form);
385 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
390 $main::lxdebug->leave_sub();
394 $main::lxdebug->enter_sub();
396 my $form = $main::form;
397 my %myconfig = %main::myconfig;
398 my $locale = $main::locale;
400 $main::auth->assert('cash');
402 $form->{callback} = "$form->{script}?action=reconciliation";
404 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
406 RC->reconcile(\%myconfig, \%$form);
409 $main::lxdebug->leave_sub();