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 #======================================================================
43 $lxdebug->enter_sub();
45 RC->paymentaccounts(\%myconfig, \%$form);
48 map { $selection .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{PR} };
50 $form->{title} = $locale->text('Reconciliation');
57 <form method=post action=$form->{script}>
61 <th class=listtop>$form->{title}</th>
68 <th align=right nowrap>|.$locale->text('Account').qq|</th>
69 <td colspan=3><select name=accno>$selection</select>
73 <th align=right>|.$locale->text('From').qq|</th>
74 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
75 <th align=right>|.$locale->text('To').qq|</th>
76 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
82 <td><hr size=3 noshade></td>
87 <input type=hidden name=nextsub value=get_payments>
89 <input type=hidden name=path value=$form->{path}>
90 <input type=hidden name=login value=$form->{login}>
91 <input type=hidden name=password value=$form->{password}>
93 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
101 $lxdebug->leave_sub();
105 sub continue { &{ $form->{nextsub} } };
109 $lxdebug->enter_sub();
111 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
113 RC->payment_transactions(\%myconfig, \%$form);
117 $lxdebug->leave_sub();
122 $lxdebug->enter_sub();
124 @column_index = qw(cleared transdate source name credit debit balance);
126 $column_header{cleared} = "<th> </th>";
127 $column_header{source} = "<th class=listheading>".$locale->text('Source')."</a></th>";
128 $column_header{name} = "<th class=listheading>".$locale->text('Description')."</a></th>";
129 $column_header{transdate} = "<th class=listheading>".$locale->text('Date')."</a></th>";
131 if ($form->{category} eq 'A') {
132 $column_header{debit} = "<th class=listheading>".$locale->text('Deposit')."</a></th>";
133 $column_header{credit} = "<th class=listheading>".$locale->text('Payment')."</a></th>";
135 $column_header{debit} = "<th class=listheading>".$locale->text('Decrease')."</a></th>";
136 $column_header{credit} = "<th class=listheading>".$locale->text('Increase')."</a></th>";
139 $column_header{balance} = "<th class=listheading>".$locale->text('Balance')."</a></th>";
141 if ($form->{fromdate}) {
142 $option .= "\n<br>" if ($option);
143 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{fromdate}, 1);
145 if ($form->{todate}) {
146 $option .= "\n<br>" if ($option);
147 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{todate}, 1);
150 $form->{title} = "$form->{accno}--$form->{account}";
157 <form method=post action=$form->{script}>
161 <th class=listtop>$form->{title}</th>
170 <tr class=listheading>
173 map { print "\n$column_header{$_}" } @column_index;
179 $ml = ($form->{category} eq 'A') ? -1 : 1;
180 $form->{beginningbalance} *= $ml;
181 $clearedbalance = $balance = $form->{beginningbalance};
185 map { $column_data{$_} = "<td> </td>" } qw(cleared transdate source name debit credit);
186 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
192 map { print "\n$column_data{$_}" } @column_index;
199 foreach $ref (@{ $form->{PR} }) {
201 $balance += $ref->{amount} * $ml;
202 $cleared += $ref->{amount} * $ml if $ref->{cleared};
204 $column_data{name} = "<td>$ref->{name} </td>";
205 $column_data{source} = qq|<td>$ref->{source} </a>
207 $column_data{transdate} = "<td>$ref->{transdate} </td>";
209 $column_data{debit} = "<td> </td>";
210 $column_data{credit} = "<td> </td>";
212 if ($ref->{amount} < 0) {
213 $totaldebits += $ref->{amount} * -1;
214 $column_data{debit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")."</td>";
216 $totalcredits += $ref->{amount};
217 $column_data{credit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")."</td>";
220 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
222 if ($ref->{fx_transaction}) {
223 $i++ unless $id == $ref->{id};
225 $fx += $ref->{amount} * $ml;
226 $column_data{cleared} = qq|<td align=center>
227 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
230 $i++ unless ($fx_transaction && $id == $ref->{id});
232 $column_data{cleared} = qq|<td>
233 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
234 <input type=hidden name="oid_$i" value=$ref->{oid}>
244 map { print "\n$column_data{$_}" } @column_index;
253 map { $column_data{$_} = "<td> </td>" } @column_index;
255 $column_data{debit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totaldebits, 2, " ")."</th>";
256 $column_data{credit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalcredits, 2, " ")."</th>";
262 map { print "\n$column_data{$_}" } @column_index;
264 $form->{statementbalance} = $form->parse_amount(\%myconfig, $form->{statementbalance});
265 $difference = $form->format_amount(\%myconfig, $form->{statementbalance} - $clearedbalance - $cleared, 2, 0);
267 $form->{statementbalance} = $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
269 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
272 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
274 <th align=right nowrap>|.$locale->text('Exchangerate Difference').qq|</th>
276 <td align=right>$fx</td>
292 <th align=right nowrap>|.$locale->text('Cleared Balance').qq|</th>
294 <td align=right>$clearedbalance</td>
304 <th align=right nowrap>|.$locale->text('Statement Balance').qq|</th>
306 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
309 <th align=right nowrap>|.$locale->text('Difference').qq|</th>
311 <td align=right><input name=null size=11 value=$difference></td>
312 <input type=hidden name=difference value=$difference>
321 <td><hr size=3 noshade></td>
325 <input type=hidden name=rowcount value=$i>
326 <input type=hidden name=accno value=$form->{accno}>
327 <input type=hidden name=account value="$form->{account}">
329 <input type=hidden name=fromdate value=$form->{fromdate}>
330 <input type=hidden name=todate value=$form->{todate}>
332 <input type=hidden name=path value=$form->{path}>
333 <input type=hidden name=login value=$form->{login}>
334 <input type=hidden name=password value=$form->{password}>
337 <input type=submit class=submit name=action value="|.$locale->text('Update').qq|">
338 <input type=submit class=submit name=action value="|.$locale->text('Select all').qq|">
339 <input type=submit class=submit name=action value="|.$locale->text('Done').qq|">|;
341 if ($form->{menubar}) {
342 require "$form->{path}/menu.pl";
353 $lxdebug->leave_sub();
358 $lxdebug->enter_sub();
360 RC->payment_transactions(\%myconfig, \%$form);
362 foreach $ref (@{ $form->{PR} }) {
363 if (!$ref->{fx_transaction}) {
365 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
371 $lxdebug->leave_sub();
376 $lxdebug->enter_sub();
378 RC->payment_transactions(\%myconfig, \%$form);
380 map { $_->{cleared} = "checked" unless $_->{fx_transaction} } @{ $form->{PR} };
384 $lxdebug->leave_sub();
389 $lxdebug->enter_sub();
391 $form->{callback} = "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&password=$form->{password}";
393 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
395 RC->reconcile(\%myconfig, \%$form);
398 $lxdebug->leave_sub();