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 #======================================================================
41 $lxdebug->enter_sub();
43 RC->paymentaccounts(\%myconfig, \%$form);
46 map { $selection .= "<option>$_->{accno}--$_->{description}\n" }
49 $form->{title} = $locale->text('Reconciliation');
56 <form method=post action=$form->{script}>
60 <th class=listtop>$form->{title}</th>
67 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
68 <td colspan=3><select name=accno>$selection</select>
72 <th align=right>| . $locale->text('From') . qq|</th>
73 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
74 <th align=right>| . $locale->text('To') . qq|</th>
75 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
81 <td><hr size=3 noshade></td>
86 <input type=hidden name=nextsub value=get_payments>
88 <input type=hidden name=path value=$form->{path}>
89 <input type=hidden name=login value=$form->{login}>
90 <input type=hidden name=password value=$form->{password}>
92 <input type=submit class=submit name=action value="|
93 . $locale->text('Continue') . qq|">
101 $lxdebug->leave_sub();
104 sub continue { &{ $form->{nextsub} } }
107 $lxdebug->enter_sub();
109 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
111 RC->payment_transactions(\%myconfig, \%$form);
115 $lxdebug->leave_sub();
119 $lxdebug->enter_sub();
121 @column_index = qw(cleared transdate source name credit debit balance);
123 $column_header{cleared} = "<th> </th>";
124 $column_header{source} =
125 "<th class=listheading>" . $locale->text('Source') . "</a></th>";
126 $column_header{name} =
127 "<th class=listheading>" . $locale->text('Description') . "</a></th>";
128 $column_header{transdate} =
129 "<th class=listheading>" . $locale->text('Date') . "</a></th>";
131 if ($form->{category} eq 'A') {
132 $column_header{debit} =
133 "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
134 $column_header{credit} =
135 "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
137 $column_header{debit} =
138 "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
139 $column_header{credit} =
140 "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
143 $column_header{balance} =
144 "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
146 if ($form->{fromdate}) {
147 $option .= "\n<br>" if ($option);
149 $locale->text('From') . " "
150 . $locale->date(\%myconfig, $form->{fromdate}, 1);
152 if ($form->{todate}) {
153 $option .= "\n<br>" if ($option);
155 $locale->text('To') . " "
156 . $locale->date(\%myconfig, $form->{todate}, 1);
159 $form->{title} = "$form->{accno}--$form->{account}";
166 <form method=post action=$form->{script}>
170 <th class=listtop>$form->{title}</th>
179 <tr class=listheading>
182 map { print "\n$column_header{$_}" } @column_index;
188 $ml = ($form->{category} eq 'A') ? -1 : 1;
189 $form->{beginningbalance} *= $ml;
190 $clearedbalance = $balance = $form->{beginningbalance};
194 map { $column_data{$_} = "<td> </td>" }
195 qw(cleared transdate source name debit credit);
196 $column_data{balance} =
198 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
204 map { print "\n$column_data{$_}" } @column_index;
210 foreach $ref (@{ $form->{PR} }) {
212 $balance += $ref->{amount} * $ml;
213 $cleared += $ref->{amount} * $ml if $ref->{cleared};
215 $column_data{name} = "<td>$ref->{name} </td>";
216 $column_data{source} = qq|<td>$ref->{source} </a>
218 $column_data{transdate} = "<td>$ref->{transdate} </td>";
220 $column_data{debit} = "<td> </td>";
221 $column_data{credit} = "<td> </td>";
223 if ($ref->{amount} < 0) {
224 $totaldebits += $ref->{amount} * -1;
225 $column_data{debit} =
227 . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
230 $totalcredits += $ref->{amount};
231 $column_data{credit} =
233 . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
237 $column_data{balance} =
239 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
241 if ($ref->{fx_transaction}) {
242 $i++ unless $id == $ref->{id};
244 $fx += $ref->{amount} * $ml;
245 $column_data{cleared} = qq|<td align=center>
246 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
249 $i++ unless ($fx_transaction && $id == $ref->{id});
251 $column_data{cleared} = qq|<td>
252 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
253 <input type=hidden name="oid_$i" value=$ref->{oid}>
264 map { print "\n$column_data{$_}" } @column_index;
273 map { $column_data{$_} = "<td> </td>" } @column_index;
275 $column_data{debit} =
276 "<th class=listtotal align=right>"
277 . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
278 $column_data{credit} =
279 "<th class=listtotal align=right>"
280 . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
286 map { print "\n$column_data{$_}" } @column_index;
288 $form->{statementbalance} =
289 $form->parse_amount(\%myconfig, $form->{statementbalance});
291 $form->format_amount(\%myconfig,
292 $form->{statementbalance} - $clearedbalance - $cleared,
295 $form->{statementbalance} =
296 $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
298 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
301 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
303 <th align=right nowrap>|
304 . $locale->text('Exchangerate Difference')
307 <td align=right>$fx</td>
323 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
325 <td align=right>$clearedbalance</td>
335 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
337 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
340 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
342 <td align=right><input name=null size=11 value=$difference></td>
343 <input type=hidden name=difference value=$difference>
352 <td><hr size=3 noshade></td>
356 <input type=hidden name=rowcount value=$i>
357 <input type=hidden name=accno value=$form->{accno}>
358 <input type=hidden name=account value="$form->{account}">
360 <input type=hidden name=fromdate value=$form->{fromdate}>
361 <input type=hidden name=todate value=$form->{todate}>
363 <input type=hidden name=path value=$form->{path}>
364 <input type=hidden name=login value=$form->{login}>
365 <input type=hidden name=password value=$form->{password}>
368 <input type=submit class=submit name=action value="|
369 . $locale->text('Update') . qq|">
370 <input type=submit class=submit name=action value="|
371 . $locale->text('Select all') . qq|">
372 <input type=submit class=submit name=action value="|
373 . $locale->text('Done') . qq|">|;
375 if ($form->{menubar}) {
376 require "$form->{path}/menu.pl";
387 $lxdebug->leave_sub();
391 $lxdebug->enter_sub();
393 RC->payment_transactions(\%myconfig, \%$form);
395 foreach $ref (@{ $form->{PR} }) {
396 if (!$ref->{fx_transaction}) {
398 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
404 $lxdebug->leave_sub();
408 $lxdebug->enter_sub();
410 RC->payment_transactions(\%myconfig, \%$form);
412 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
417 $lxdebug->leave_sub();
421 $lxdebug->enter_sub();
424 "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&password=$form->{password}";
426 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
428 RC->reconcile(\%myconfig, \%$form);
431 $lxdebug->leave_sub();