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 # module for Chart of Accounts, Income Statement and Balance Sheet
31 # search and edit transactions posted by the GL, AR and AP
33 #======================================================================
41 # this is for our long dates
42 # $locale->text('January')
43 # $locale->text('February')
44 # $locale->text('March')
45 # $locale->text('April')
46 # $locale->text('May ')
47 # $locale->text('June')
48 # $locale->text('July')
49 # $locale->text('August')
50 # $locale->text('September')
51 # $locale->text('October')
52 # $locale->text('November')
53 # $locale->text('December')
55 # this is for our short month
56 # $locale->text('Jan')
57 # $locale->text('Feb')
58 # $locale->text('Mar')
59 # $locale->text('Apr')
60 # $locale->text('May')
61 # $locale->text('Jun')
62 # $locale->text('Jul')
63 # $locale->text('Aug')
64 # $locale->text('Sep')
65 # $locale->text('Oct')
66 # $locale->text('Nov')
67 # $locale->text('Dec')
69 sub chart_of_accounts {
70 $lxdebug->enter_sub();
72 CA->all_accounts(\%myconfig, \%$form);
74 @column_index = qw(accno gifi_accno description debit credit);
76 $column_header{accno} =
77 qq|<th class=listheading>| . $locale->text('Account') . qq|</th>\n|;
78 $column_header{gifi_accno} =
79 qq|<th class=listheading>| . $locale->text('GIFI') . qq|</th>\n|;
80 $column_header{description} =
81 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>\n|;
82 $column_header{debit} =
83 qq|<th class=listheading>| . $locale->text('Debit') . qq|</th>\n|;
84 $column_header{credit} =
85 qq|<th class=listheading>| . $locale->text('Credit') . qq|</th>\n|;
87 $form->{title} = $locale->text('Chart of Accounts');
89 $colspan = $#column_index + 1;
96 <table border=0 width=100%>
97 <tr><th class=listtop colspan=$colspan>$form->{title}</th></tr>
99 <tr class=listheading>|;
101 map { print $column_header{$_} } @column_index;
107 foreach $ca (@{ $form->{CA} }) {
109 $description = $form->escape($ca->{description});
110 $gifi_description = $form->escape($ca->{gifi_description});
113 qq|$form->{script}?path=$form->{path}&action=list&accno=$ca->{accno}&login=$form->{login}&password=$form->{password}&description=$description&gifi_accno=$ca->{gifi_accno}&gifi_description=$gifi_description|;
115 if ($ca->{charttype} eq "H") {
116 print qq|<tr class=listheading>|;
117 map { $column_data{$_} = "<th>$ca->{$_}</th>"; } qw(accno description);
118 $column_data{gifi_accno} = "<th>$ca->{gifi_accno} </th>";
122 print qq|<tr class=listrow$i>|;
123 $column_data{accno} = "<td><a href=$href>$ca->{accno}</a></td>";
124 $column_data{gifi_accno} =
125 "<td><a href=$href&accounttype=gifi>$ca->{gifi_accno}</a> </td>";
126 $column_data{description} = "<td>$ca->{description}</td>";
131 $debit = $form->format_amount(\%myconfig, $ca->{debit}, 2, " ");
134 $credit = $form->format_amount(\%myconfig, $ca->{credit}, 2, " ");
136 $column_data{debit} =
140 $column_data{credit} =
145 $totaldebit += $ca->{debit};
146 $totalcredit += $ca->{credit};
148 map { print $column_data{$_} } @column_index;
155 map { $column_data{$_} = "<td> </td>"; }
156 qw(accno gifi_accno description);
158 $column_data{debit} =
159 "<th align=right class=listtotal>"
160 . $form->format_amount(\%myconfig, $totaldebit, 2, 0) . "</th>";
161 $column_data{credit} =
162 "<th align=right class=listtotal>"
163 . $form->format_amount(\%myconfig, $totalcredit, 2, 0) . "</th>";
165 print "<tr class=listtotal>";
167 map { print $column_data{$_} } @column_index;
172 <td colspan=$colspan><hr size=3 noshade></td>
180 $lxdebug->leave_sub();
184 $lxdebug->enter_sub();
186 $form->{title} = $locale->text('List Transactions');
187 if ($form->{accounttype} eq 'gifi') {
188 $form->{title} .= " - " . $locale->text('GIFI') . " $form->{gifi_accno}";
190 $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}";
194 $form->all_departments(\%myconfig);
195 if (@{ $form->{all_departments} }) {
196 $form->{selectdepartment} = "<option>\n";
199 $form->{selectdepartment} .=
200 "<option>$_->{description}--$_->{id}\n"
201 } (@{ $form->{all_departments} });
206 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
207 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
209 | if $form->{selectdepartment};
213 map { $form->{$_} =~ s/\"/"/g; } qw(description gifi_description);
218 <form method=post action=$form->{script}>
220 <input type=hidden name=accno value=$form->{accno}>
221 <input type=hidden name=description value="$form->{description}">
222 <input type=hidden name=sort value=transdate>
223 <input type=hidden name=eur value=$eur>
224 <input type=hidden name=accounttype value=$form->{accounttype}>
225 <input type=hidden name=gifi_accno value=$form->{gifi_accno}>
226 <input type=hidden name=gifi_description value="$form->{gifi_description}">
228 <table border=0 width=100%>
229 <tr><th class=listtop>$form->{title}</th></tr>
236 <th align=right>| . $locale->text('From') . qq|</th>
237 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
238 <th align=right>| . $locale->text('To') . qq|</th>
239 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
242 <th align=right>| . $locale->text('Include in Report') . qq|</th>
244 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
245 . $locale->text('Subtotal') . qq|</td>
250 <tr><td><hr size=3 noshade></td></tr>
253 <input type=hidden name=login value=$form->{login}>
254 <input type=hidden name=path value=$form->{path}>
255 <input type=hidden name=password value=$form->{password}>
257 <br><input class=submit type=submit name=action value="|
258 . $locale->text('List Transactions') . qq|">
265 $lxdebug->leave_sub();
268 sub list_transactions {
269 $lxdebug->enter_sub();
271 CA->all_transactions(\%myconfig, \%$form);
273 $description = $form->escape($form->{description});
274 $gifi_description = $form->escape($form->{gifi_description});
275 $department = $form->escape($form->{department});
276 $projectnumber = $form->escape($form->{projectnumber});
277 $title = $form->escape($form->{title});
281 "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title";
283 $description = $form->escape($form->{description}, 1);
284 $gifi_description = $form->escape($form->{gifi_description}, 1);
285 $department = $form->escape($form->{department}, 1);
286 $projectnumber = $form->escape($form->{projectnumber}, 1);
287 $title = $form->escape($form->{title}, 1);
291 "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title";
293 # figure out which column comes first
294 $column_header{transdate} =
295 qq|<th><a class=listheading href=$href&sort=transdate>|
296 . $locale->text('Date')
298 $column_header{reference} =
299 qq|<th><a class=listheading href=$href&sort=reference>|
300 . $locale->text('Reference')
302 $column_header{description} =
303 qq|<th><a class=listheading href=$href&sort=description>|
304 . $locale->text('Description')
306 $column_header{debit} = qq|<th>| . $locale->text('Debit') . qq|</th>|;
307 $column_header{credit} = qq|<th>| . $locale->text('Credit') . qq|</th>|;
308 $column_header{balance} = qq|<th>| . $locale->text('Balance') . qq|</th>|;
311 $form->sort_columns(qw(transdate reference description debit credit));
313 if ($form->{accounttype} eq 'gifi') {
314 map { $form->{$_} = $form->{"gifi_$_"} } qw(accno description);
316 if ($form->{accno}) {
317 push @column_index, "balance";
321 ($form->{accounttype} eq 'gifi')
322 ? $locale->text('GIFI')
323 : $locale->text('Account');
325 $form->{title} .= " $form->{accno} - $form->{description}";
327 if ($form->{department}) {
328 ($department) = split /--/, $form->{department};
329 $options = $locale->text('Department') . " : $department<br>";
331 if ($form->{projectnumber}) {
332 $options .= $locale->text('Project Number');
333 $options .= " : $form->{projectnumber}<br>";
336 if ($form->{fromdate} || $form->{todate}) {
337 if ($form->{fromdate}) {
338 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
340 if ($form->{todate}) {
341 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
344 $form->{period} = "$fromdate - $todate";
347 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
350 $options .= $form->{period};
359 <th class=listtop>$form->{title}</th>
368 <tr class=listheading>
371 map { print "$column_header{$_}\n" } @column_index;
377 # add sort to callback
378 $callback = $form->escape($callback . "&sort=$form->{sort}");
380 if (@{ $form->{CA} }) {
381 $sameitem = $form->{CA}->[0]->{ $form->{sort} };
384 $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
385 if ($form->{accno} && $form->{balance}) {
387 map { $column_data{$_} = "<td> </td>" } @column_index;
389 $column_data{balance} =
391 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
399 map { print $column_data{$_} } @column_index;
405 foreach $ca (@{ $form->{CA} }) {
407 if ($form->{l_subtotal} eq 'Y') {
408 if ($sameitem ne $ca->{ $form->{sort} }) {
413 # construct link to source
415 "<a href=$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{reference}</a>";
416 my $debit = ($ca->{debit} != 0) ? $form->format_amount(\%myconfig, $ca->{debit}, 2, " ") : " ";
417 $column_data{debit} =
418 "<td align=right>$debit</td>";
419 my $credit = ($ca->{credit} != 0) ? $form->format_amount(\%myconfig, $ca->{credit}, 2, " ") : " ";
420 $column_data{credit} =
421 "<td align=right>$credit</td>";
423 $form->{balance} += $ca->{amount};
424 $column_data{balance} =
426 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
429 $subtotaldebit += $ca->{debit};
430 $subtotalcredit += $ca->{credit};
432 $totaldebit += $ca->{debit};
433 $totalcredit += $ca->{credit};
435 $column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
436 $column_data{reference} = qq|<td>$href</td>|;
437 $column_data{description} = qq|<td>$ca->{description}</td>|;
445 map { print $column_data{$_} } @column_index;
453 if ($form->{l_subtotal} eq 'Y') {
457 map { $column_data{$_} = "<td> </td>" } @column_index;
459 $column_data{debit} =
461 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
462 $column_data{credit} =
464 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
465 $column_data{balance} =
467 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
473 map { print $column_data{$_} } @column_index;
481 <td><hr size=3 noshade></td>
489 $lxdebug->leave_sub();
493 $lxdebug->enter_sub();
495 map { $column_data{$_} = "<td> </td>" } @column_index;
497 $column_data{debit} =
499 . $form->format_amount(\%myconfig, $subtotaldebit, 2, " ") . "</th>";
500 $column_data{credit} =
502 . $form->format_amount(\%myconfig, $subtotalcredit, 2, " ") . "</th>";
507 $sameitem = $ca->{ $form->{sort} };
510 <tr class=listsubtotal>
513 map { print "$column_data{$_}\n" } @column_index;
519 $lxdebug->leave_sub();