1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
24 # Account reconciliation module
26 #======================================================================
38 RC->paymentaccounts(\%myconfig, \%$form);
41 map { $selection .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{PR} };
43 $form->{title} = $locale->text('Reconciliation');
50 <form method=post action=$form->{script}>
54 <th class=listtop>$form->{title}</th>
61 <th align=right nowrap>|.$locale->text('Account').qq|</th>
62 <td colspan=3><select name=accno>$selection</select>
66 <th align=right>|.$locale->text('From').qq|</th>
67 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
68 <th align=right>|.$locale->text('to').qq|</th>
69 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
75 <td><hr size=3 noshade></td>
80 <input type=hidden name=nextsub value=get_payments>
82 <input type=hidden name=path value=$form->{path}>
83 <input type=hidden name=login value=$form->{login}>
84 <input type=hidden name=password value=$form->{password}>
86 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
97 sub continue { &{ $form->{nextsub} } };
102 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
104 RC->payment_transactions(\%myconfig, \%$form);
113 @column_index = qw(cleared transdate source name credit debit balance);
115 $column_header{cleared} = "<th class=listheading> </th>";
116 $column_header{source} = "<th class=listheading>".$locale->text('Source')."</a></th>";
117 $column_header{name} = "<th class=listheading>".$locale->text('Description')."</a></th>";
118 $column_header{transdate} = "<th class=listheading>".$locale->text('Date')."</a></th>";
120 $column_header{debit} = "<th class=listheading>".$locale->text('Deposit')."</a></th>";
121 $column_header{credit} = "<th class=listheading>".$locale->text('Payment')."</a></th>";
123 $column_header{balance} = "<th class=listheading>".$locale->text('Balance')."</a></th>";
125 if ($form->{fromdate}) {
126 $option .= "\n<br>" if ($option);
127 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{fromdate}, 1);
129 if ($form->{todate}) {
130 $option .= "\n<br>" if ($option);
131 $option .= $locale->text('to')." ".$locale->date(\%myconfig, $form->{todate}, 1);
134 $form->{title} = "$form->{accno}--$form->{account}";
141 <form method=post action=$form->{script}>
145 <th class=listtop>$form->{title}</th>
157 map { print "\n$column_header{$_}" } @column_index;
163 $form->{beginningbalance} *= -1;
164 $clearedbalance = $balance = $form->{beginningbalance};
168 map { $column_data{$_} = "<td> </td>" } qw(cleared transdate source name debit credit);
169 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
175 map { print "\n$column_data{$_}" } @column_index;
182 foreach $ref (@{ $form->{PR} }) {
184 $balance += $ref->{amount} * -1;
185 $cleared += $ref->{amount} * -1 if $ref->{cleared};
187 $column_data{name} = "<td>$ref->{name} </td>";
188 $column_data{source} = qq|<td>$ref->{source} </a>
190 $column_data{transdate} = "<td>$ref->{transdate} </td>";
192 $column_data{debit} = "<td> </td>";
193 $column_data{credit} = "<td> </td>";
195 if ($ref->{amount} < 0) {
196 $totaldebits += $ref->{amount} * -1;
197 $column_data{debit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")."</td>";
199 $totalcredits += $ref->{amount};
200 $column_data{credit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")."</td>";
203 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
205 if ($ref->{fx_transaction}) {
206 $i++ unless $id == $ref->{id};
208 $fx += $ref->{amount} * -1;
209 $column_data{cleared} = qq|<td align=center>
210 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
213 $i++ unless ($fx_transaction && $id == $ref->{id});
215 $column_data{cleared} = qq|<td>
216 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
217 <input type=hidden name="oid_$i" value=$ref->{oid}>
227 map { print "\n$column_data{$_}" } @column_index;
236 map { $column_data{$_} = "<td> </td>" } @column_index;
238 $column_data{debit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totaldebits, 2, " ")."</th>";
239 $column_data{credit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalcredits, 2, " ")."</th>";
245 map { print "\n$column_data{$_}" } @column_index;
247 $form->{statementbalance} = $form->parse_amount(\%myconfig, $form->{statementbalance});
248 $difference = $form->format_amount(\%myconfig, $form->{statementbalance} - $clearedbalance - $cleared, 2, 0);
250 $form->{statementbalance} = $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
252 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
255 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
257 <th align=right nowrap>|.$locale->text('Exchangerate Difference').qq|</th>
259 <td align=right>$fx</td>
275 <th align=right nowrap>|.$locale->text('Cleared Balance').qq|</th>
277 <td align=right>$clearedbalance</td>
287 <th align=right nowrap>|.$locale->text('Statement Balance').qq|</th>
289 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
292 <th align=right nowrap>|.$locale->text('Difference').qq|</th>
294 <td align=right><input name=none size=11 value=$difference></td>
295 <input type=hidden name=difference value=$difference>
304 <td><hr size=3 noshade></td>
308 <input type=hidden name=rowcount value=$i>
309 <input type=hidden name=accno value=$form->{accno}>
310 <input type=hidden name=account value="$form->{account}">
312 <input type=hidden name=fromdate value=$form->{fromdate}>
313 <input type=hidden name=todate value=$form->{todate}>
315 <input type=hidden name=path value=$form->{path}>
316 <input type=hidden name=login value=$form->{login}>
317 <input type=hidden name=password value=$form->{password}>
320 <input type=submit class=submit name=action value="|.$locale->text('Update').qq|">
321 <input type=submit class=submit name=action value="|.$locale->text('Select all').qq|">
322 <input type=submit class=submit name=action value="|.$locale->text('Done').qq|">
335 RC->payment_transactions(\%myconfig, \%$form);
337 foreach $ref (@{ $form->{PR} }) {
338 if (!$ref->{fx_transaction}) {
340 $ref->{cleared} = "checked" if $form->{"cleared_$i"};
351 RC->payment_transactions(\%myconfig, \%$form);
353 map { $_->{cleared} = "checked" unless $_->{fx_transaction} } @{ $form->{PR} };
362 $form->{callback} = "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&password=$form->{password}";
364 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
366 RC->reconcile(\%myconfig, \%$form);