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";
43 $lxdebug->enter_sub();
45 RC->paymentaccounts(\%myconfig, \%$form);
48 map { $selection .= "<option>$_->{accno}--$_->{description}\n" }
51 $form->{title} = $locale->text('Reconciliation');
53 $form->{"jsscript"} = 1;
59 <form method=post action=$form->{script}>
63 <th class=listtop>$form->{title}</th>
70 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
71 <td colspan=3><select name=accno>$selection</select>
75 <th align=right>| . $locale->text('From') . qq|</th>
76 <td><input name=fromdate id=fromdate size=11 title="$myconfig{dateformat}">
77 <input type="button" name="fromdate" id="trigger_fromdate" value="?"></td>
78 <th align=right>| . $locale->text('Until') . qq|</th>
79 <td><input name=todate id=todate size=11 title="$myconfig{dateformat}">
80 <input type="button" name="todate" id="trigger_todate" value="?"></td>
86 <td><hr size=3 noshade></td>
90 | . $form->write_trigger(\%myconfig, 2,
91 "fromdate", "BL", "trigger_fromdate",
92 "todate", "BL", "trigger_todate") . qq|
95 <input type=hidden name=nextsub value=get_payments>
97 <input type=hidden name=path value=$form->{path}>
98 <input type=hidden name=login value=$form->{login}>
99 <input type=hidden name=password value=$form->{password}>
101 <input type=submit class=submit name=action value="|
102 . $locale->text('Continue') . qq|">
110 $lxdebug->leave_sub();
113 sub continue { call_sub($form->{"nextsub"}); }
116 $lxdebug->enter_sub();
118 ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
120 RC->payment_transactions(\%myconfig, \%$form);
124 $lxdebug->leave_sub();
128 $lxdebug->enter_sub();
130 @column_index = qw(cleared transdate source name credit debit balance);
132 $column_header{cleared} = "<th> </th>";
133 $column_header{source} =
134 "<th class=listheading>" . $locale->text('Source') . "</a></th>";
135 $column_header{name} =
136 "<th class=listheading>" . $locale->text('Description') . "</a></th>";
137 $column_header{transdate} =
138 "<th class=listheading>" . $locale->text('Date') . "</a></th>";
140 if ($form->{category} eq 'A') {
141 $column_header{debit} =
142 "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
143 $column_header{credit} =
144 "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
146 $column_header{debit} =
147 "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
148 $column_header{credit} =
149 "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
152 $column_header{balance} =
153 "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
155 if ($form->{fromdate}) {
156 $option .= "\n<br>" if ($option);
158 $locale->text('From') . " "
159 . $locale->date(\%myconfig, $form->{fromdate}, 0);
161 if ($form->{todate}) {
162 $option .= "\n<br>" if ($option);
164 $locale->text('Until') . " "
165 . $locale->date(\%myconfig, $form->{todate}, 0);
168 $form->{title} = "$form->{accno}--$form->{account}";
175 <form method=post action=$form->{script}>
179 <th class=listtop>$form->{title}</th>
188 <tr class=listheading>
191 map { print "\n$column_header{$_}" } @column_index;
197 $ml = ($form->{category} eq 'A') ? -1 : 1;
198 $form->{beginningbalance} *= $ml;
199 $clearedbalance = $balance = $form->{beginningbalance};
203 map { $column_data{$_} = "<td> </td>" }
204 qw(cleared transdate source name debit credit);
205 $column_data{balance} =
207 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
213 map { print "\n$column_data{$_}" } @column_index;
219 foreach $ref (@{ $form->{PR} }) {
221 $balance += $ref->{amount} * $ml;
222 $cleared += $ref->{amount} * $ml if $ref->{cleared};
224 $column_data{name} = "<td>$ref->{name} </td>";
225 $column_data{source} = qq|<td>$ref->{source} </a>
227 $column_data{transdate} = "<td>$ref->{transdate} </td>";
229 $column_data{debit} = "<td> </td>";
230 $column_data{credit} = "<td> </td>";
232 if ($ref->{amount} < 0) {
233 $totaldebits += $ref->{amount} * -1;
234 $column_data{debit} =
236 . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
239 $totalcredits += $ref->{amount};
240 $column_data{credit} =
242 . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
246 $column_data{balance} =
248 . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
250 if ($ref->{fx_transaction}) {
251 $i++ unless $id == $ref->{id};
253 $fx += $ref->{amount} * $ml;
254 $column_data{cleared} = qq|<td align=center>
255 <input type=hidden name="fxoid_$i" value=$ref->{oid}>
258 $i++ unless ($fx_transaction && $id == $ref->{id});
260 $column_data{cleared} = qq|<td>
261 <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
262 <input type=hidden name="oid_$i" value=$ref->{oid}>
273 map { print "\n$column_data{$_}" } @column_index;
282 map { $column_data{$_} = "<td> </td>" } @column_index;
284 $column_data{debit} =
285 "<th class=listtotal align=right>"
286 . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
287 $column_data{credit} =
288 "<th class=listtotal align=right>"
289 . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
295 map { print "\n$column_data{$_}" } @column_index;
297 $form->{statementbalance} =
298 $form->parse_amount(\%myconfig, $form->{statementbalance});
300 $form->format_amount(\%myconfig,
301 $form->{statementbalance} - $clearedbalance - $cleared,
304 $form->{statementbalance} =
305 $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
307 $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
310 $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
312 <th align=right nowrap>|
313 . $locale->text('Exchangerate Difference') . qq|</th>
315 <td align=right>$fx</td>
331 <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
333 <td align=right>$clearedbalance</td>
343 <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
345 <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
348 <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
350 <td align=right><input name=null size=11 value=$difference></td>
351 <input type=hidden name=difference value=$difference>
360 <td><hr size=3 noshade></td>
364 <input type=hidden name=rowcount value=$i>
365 <input type=hidden name=accno value=$form->{accno}>
366 <input type=hidden name=account value="$form->{account}">
368 <input type=hidden name=fromdate value=$form->{fromdate}>
369 <input type=hidden name=todate value=$form->{todate}>
371 <input type=hidden name=path value=$form->{path}>
372 <input type=hidden name=login value=$form->{login}>
373 <input type=hidden name=password value=$form->{password}>
376 <input type=submit class=submit name=action value="|
377 . $locale->text('Update') . qq|">
378 <input type=submit class=submit name=action value="|
379 . $locale->text('Select all') . qq|">
380 <input type=submit class=submit name=action value="|
381 . $locale->text('Done') . qq|">
389 $lxdebug->leave_sub();
393 $lxdebug->enter_sub();
395 RC->payment_transactions(\%myconfig, \%$form);
397 foreach $ref (@{ $form->{PR} }) {
398 if (!$ref->{fx_transaction}) {
400 $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
406 $lxdebug->leave_sub();
410 $lxdebug->enter_sub();
412 RC->payment_transactions(\%myconfig, \%$form);
414 map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
419 $lxdebug->leave_sub();
423 $lxdebug->enter_sub();
426 "$form->{script}?path=$form->{path}&action=reconciliation&login=$form->{login}&password=$form->{password}";
428 $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
430 RC->reconcile(\%myconfig, \%$form);
433 $lxdebug->leave_sub();