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 #======================================================================
33 # this is for our long dates
34 # $locale->text('January')
35 # $locale->text('February')
36 # $locale->text('March')
37 # $locale->text('April')
38 # $locale->text('May ')
39 # $locale->text('June')
40 # $locale->text('July')
41 # $locale->text('August')
42 # $locale->text('September')
43 # $locale->text('October')
44 # $locale->text('November')
45 # $locale->text('December')
47 # this is for our short month
48 # $locale->text('Jan')
49 # $locale->text('Feb')
50 # $locale->text('Mar')
51 # $locale->text('Apr')
52 # $locale->text('May')
53 # $locale->text('Jun')
54 # $locale->text('Jul')
55 # $locale->text('Aug')
56 # $locale->text('Sep')
57 # $locale->text('Oct')
58 # $locale->text('Nov')
59 # $locale->text('Dec')
64 RC->paymentaccounts(\%myconfig, \%$form);
67 map { $selection .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{PR} };
69 $form->{title} = $locale->text('Reconciliation');
71 if ($form->{report}) {
72 $form->{title} = $locale->text('Reconciliation Report');
74 <input type=hidden name=report value=1>
76 <td align=right><input type=checkbox style=checkbox name=outstanding value=1 checked></td>
77 <td>|.$locale->text('Outstanding').qq|</td>
78 <td align=right><input type=checkbox style=checkbox name=cleared value=1></td>
79 <td>|.$locale->text('Cleared').qq|</td>
87 $form->{selectaccountingyear} = "<option>\n";
88 map { $form->{selectaccountingyear} .= qq|<option>$_\n| } @{ $form->{all_years} };
89 $form->{selectaccountingmonth} = "<option>\n";
90 map { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| } sort keys %{ $form->{all_month} };
94 <th align=right>|.$locale->text('Period').qq|</th>
96 <select name=month>$form->{selectaccountingmonth}</select>
97 <select name=year>$form->{selectaccountingyear}</select>
98 <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
99 <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
100 <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
101 <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
112 <form method=post action=$form->{script}>
116 <th class=listtop>$form->{title}</th>
123 <th align=right nowrap>|.$locale->text('Account').qq|</th>
124 <td colspan=3><select name=accno>$selection</select>
128 <th align=right>|.$locale->text('From').qq|</th>
129 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
130 <th align=right>|.$locale->text('To').qq|</th>
131 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
136 <td align=right><input type=radio style=radio name=summary value=1 checked></td>
137 <td>|.$locale->text('Summary').qq|</td>
138 <td align=right><input type=radio style=radio name=summary value=0></td>
139 <td>|.$locale->text('Detail').qq|</td>
142 <td align=right><input type=checkbox style=checkbox name=fx_transaction value=1 checked></td>
143 <td colspan=3>|.$locale->text('Include Exchange Rate Difference').qq|</td>
149 <td><hr size=3 noshade></td>
154 <input type=hidden name=nextsub value=get_payments>
156 <input type=hidden name=path value=$form->{path}>
157 <input type=hidden name=login value=$form->{login}>
158 <input type=hidden name=sessionid value=$form->{sessionid}>
160 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
171 sub continue { &{ $form->{nextsub} } };
176 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
178 RC->payment_transactions(\%myconfig, \%$form);
180 $ml = ($form->{category} eq 'A') ? -1 : 1;
181 $form->{statementbalance} = $form->{endingbalance} * $ml;
182 if (! $form->{fx_transaction}) {
183 $form->{statementbalance} = ($form->{endingbalance} - $form->{fx_endingbalance}) * $ml;
186 $form->{statementbalance} = $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
195 if ($form->{report}) {
196 @column_index = qw(transdate source name cleared credit debit);
198 @column_index = qw(transdate source name cleared credit debit balance);
201 $column_header{cleared} = qq|<th>|.$locale->text('R').qq|</th>|;
202 $column_header{source} = "<th class=listheading>".$locale->text('Source')."</a></th>";
203 $column_header{name} = "<th class=listheading>".$locale->text('Description')."</a></th>";
204 $column_header{transdate} = "<th class=listheading>".$locale->text('Date')."</a></th>";
206 if ($form->{category} eq 'A') {
207 $column_header{debit} = "<th class=listheading>".$locale->text('Deposit')."</a></th>";
208 $column_header{credit} = "<th class=listheading>".$locale->text('Payment')."</a></th>";
210 $column_header{debit} = "<th class=listheading>".$locale->text('Decrease')."</a></th>";
211 $column_header{credit} = "<th class=listheading>".$locale->text('Increase')."</a></th>";
214 $column_header{balance} = "<th class=listheading>".$locale->text('Balance')."</a></th>";
216 if ($form->{fromdate}) {
217 $option .= "\n<br>" if ($option);
218 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{fromdate}, 1);
220 if ($form->{todate}) {
221 $option .= "\n<br>" if ($option);
222 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{todate}, 1);
225 $form->{title} = "$form->{accno}--$form->{account}";
232 <form method=post action=$form->{script}>
236 <th class=listtop>$form->{title}</th>
245 <tr class=listheading>
248 map { print "\n$column_header{$_}" } @column_index;
254 $ml = ($form->{category} eq 'A') ? -1 : 1;
255 $form->{beginningbalance} *= $ml;
256 $form->{fx_balance} *= $ml;
258 if (! $form->{fx_transaction}) {
259 $form->{beginningbalance} -= $form->{fx_balance};
261 $balance = $form->{beginningbalance};
266 map { $column_data{$_} = "<td> </td>" } qw(cleared transdate source debit credit);
268 if (! $form->{report}) {
269 $column_data{name} = qq|<td>|.$locale->text('Beginning Balance').qq|</td>|;
270 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
275 map { print "\n$column_data{$_}" } @column_index;
283 foreach $ref (@{ $form->{PR} }) {
287 if (! $form->{fx_transaction}) {
288 next if $ref->{fx_transaction};
291 $checked = ($ref->{cleared}) ? "checked" : "";
293 $column_data{name} = "<td>";
294 map { $column_data{name} .= "$_<br>" } @{ $ref->{name} };
295 $column_data{name} .= "</td>";
296 $column_data{source} = qq|<td>$ref->{source} </td>
297 <input type=hidden name="id_$i" value=$ref->{id}>|;
299 $column_data{debit} = "<td> </td>";
300 $column_data{credit} = "<td> </td>";
302 $balance += $ref->{amount} * $ml;
304 if ($ref->{amount} < 0) {
306 $totaldebits += $ref->{amount} * -1;
308 $column_data{debit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")."</td>";
312 $totalcredits += $ref->{amount};
314 $column_data{credit} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{amount}, 2, " ")."</td>";
318 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $balance, 2, 0)."</td>";
320 if ($ref->{fx_transaction}) {
322 $column_data{cleared} = ($clearfx) ? qq|<td align=center>*</td>| : qq|<td> </td>|;
323 $cleared += $ref->{amount} * $ml if $clearfx;
327 if ($form->{report}) {
329 if ($ref->{cleared}) {
330 $column_data{cleared} = qq|<td align=center>*</td>|;
333 $column_data{cleared} = qq|<td> </td>|;
339 if ($ref->{oldcleared}) {
340 $cleared += $ref->{amount} * $ml;
342 $column_data{cleared} = qq|<td align=center>*</td>
343 <input type=hidden name="cleared_$i" value=$ref->{cleared}>
344 <input type=hidden name="oldcleared_$i" value=$ref->{oldcleared}>
345 <input type=hidden name="source_$i" value="$ref->{source}">|;
347 $cleared += $ref->{amount} * $ml if $checked;
348 $clearfx = ($checked) ? 1 : 0;
349 $column_data{cleared} = qq|<td align=center><input name="cleared_$i" type=checkbox class=checkbox value=1 $checked>
350 <input type=hidden name="source_$i" value="$ref->{source}"></td>|;
356 $column_data{transdate} = qq|<td>$ref->{transdate} </td>
357 <input type=hidden name="transdate_$i" value=$ref->{transdate}>|;
364 map { print "\n$column_data{$_}" } @column_index;
372 $form->{rowcount} = $i;
375 map { $column_data{$_} = "<td> </td>" } @column_index;
377 $column_data{debit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totaldebits, 2, " ")."</th>";
378 $column_data{credit} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalcredits, 2, " ")."</th>";
384 map { print "\n$column_data{$_}" } @column_index;
386 $form->{statementbalance} = $form->parse_amount(\%myconfig, $form->{statementbalance});
387 $difference = $form->format_amount(\%myconfig, $form->{beginningbalance} + $cleared - $form->{statementbalance}, 2, 0);
388 $form->{statementbalance} = $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
398 if ($form->{report}) {
416 <th align=right nowrap>|.$locale->text('Statement Balance').qq|</th>
418 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
421 <th align=right nowrap>|.$locale->text('Difference').qq|</th>
423 <td align=right><input name=null size=11 value=$difference></td>
424 <input type=hidden name=difference value=$difference>
433 <td><hr size=3 noshade></td>
437 <input type=hidden name=fx_transaction value=$form->{fx_transaction}>
438 <input type=hidden name=summary value=$form->{summary}>
440 <input type=hidden name=rowcount value=$form->{rowcount}>
441 <input type=hidden name=accno value="$form->{accno}">
442 <input type=hidden name=account value="$form->{account}">
444 <input type=hidden name=fromdate value=$form->{fromdate}>
445 <input type=hidden name=todate value=$form->{todate}>
447 <input type=hidden name=path value=$form->{path}>
448 <input type=hidden name=login value=$form->{login}>
449 <input type=hidden name=sessionid value=$form->{sessionid}>
452 <input type=submit class=submit name=action value="|.$locale->text('Update').qq|">
453 <input type=submit class=submit name=action value="|.$locale->text('Select all').qq|">
454 <input type=submit class=submit name=action value="|.$locale->text('Done').qq|">|;
457 if ($form->{menubar}) {
458 require "$form->{path}/menu.pl";
474 RC->payment_transactions(\%myconfig, \%$form);
477 foreach $ref (@{ $form->{PR} }) {
479 $ref->{cleared} = ($form->{"cleared_$i"}) ? 1 : 0;
489 RC->payment_transactions(\%myconfig, \%$form);
491 map { $_->{cleared} = 1 } @{ $form->{PR} };
500 $form->{callback} = "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&sessionid=$form->{sessionid}";
502 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
504 RC->reconcile(\%myconfig, \%$form);