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>";
129 $column_data{debit} =
131 . $form->format_amount(\%myconfig, $ca->{debit}, 2, " ")
133 $column_data{credit} =
135 . $form->format_amount(\%myconfig, $ca->{credit}, 2, " ")
138 $totaldebit += $ca->{debit};
139 $totalcredit += $ca->{credit};
141 map { print $column_data{$_} } @column_index;
148 map { $column_data{$_} = "<td> </td>"; }
149 qw(accno gifi_accno description);
151 $column_data{debit} =
152 "<th align=right class=listtotal>"
153 . $form->format_amount(\%myconfig, $totaldebit, 2, 0) . "</th>";
154 $column_data{credit} =
155 "<th align=right class=listtotal>"
156 . $form->format_amount(\%myconfig, $totalcredit, 2, 0) . "</th>";
158 print "<tr class=listtotal>";
160 map { print $column_data{$_} } @column_index;
165 <td colspan=$colspan><hr size=3 noshade></td>
173 $lxdebug->leave_sub();
177 $lxdebug->enter_sub();
179 $form->{title} = $locale->text('List Transactions');
180 if ($form->{accounttype} eq 'gifi') {
181 $form->{title} .= " - " . $locale->text('GIFI') . " $form->{gifi_accno}";
183 $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}";
187 $form->all_departments(\%myconfig);
188 if (@{ $form->{all_departments} }) {
189 $form->{selectdepartment} = "<option>\n";
192 $form->{selectdepartment} .=
193 "<option>$_->{description}--$_->{id}\n"
194 } (@{ $form->{all_departments} });
199 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
200 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
202 | if $form->{selectdepartment};
206 map { $form->{$_} =~ s/\"/"/g; } qw(description gifi_description);
211 <form method=post action=$form->{script}>
213 <input type=hidden name=accno value=$form->{accno}>
214 <input type=hidden name=description value="$form->{description}">
215 <input type=hidden name=sort value=transdate>
216 <input type=hidden name=eur value=$eur>
217 <input type=hidden name=accounttype value=$form->{accounttype}>
218 <input type=hidden name=gifi_accno value=$form->{gifi_accno}>
219 <input type=hidden name=gifi_description value="$form->{gifi_description}">
221 <table border=0 width=100%>
222 <tr><th class=listtop>$form->{title}</th></tr>
229 <th align=right>| . $locale->text('From') . qq|</th>
230 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
231 <th align=right>| . $locale->text('To') . qq|</th>
232 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
235 <th align=right>| . $locale->text('Include in Report') . qq|</th>
237 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
238 . $locale->text('Subtotal')
244 <tr><td><hr size=3 noshade></td></tr>
247 <input type=hidden name=login value=$form->{login}>
248 <input type=hidden name=path value=$form->{path}>
249 <input type=hidden name=password value=$form->{password}>
251 <br><input class=submit type=submit name=action value="|
252 . $locale->text('List Transactions') . qq|">
259 $lxdebug->leave_sub();
262 sub list_transactions {
263 $lxdebug->enter_sub();
265 CA->all_transactions(\%myconfig, \%$form);
267 $description = $form->escape($form->{description});
268 $gifi_description = $form->escape($form->{gifi_description});
269 $department = $form->escape($form->{department});
270 $projectnumber = $form->escape($form->{projectnumber});
271 $title = $form->escape($form->{title});
275 "$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";
277 $description = $form->escape($form->{description}, 1);
278 $gifi_description = $form->escape($form->{gifi_description}, 1);
279 $department = $form->escape($form->{department}, 1);
280 $projectnumber = $form->escape($form->{projectnumber}, 1);
281 $title = $form->escape($form->{title}, 1);
285 "$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";
287 # figure out which column comes first
288 $column_header{transdate} =
289 qq|<th><a class=listheading href=$href&sort=transdate>|
290 . $locale->text('Date')
292 $column_header{reference} =
293 qq|<th><a class=listheading href=$href&sort=reference>|
294 . $locale->text('Reference')
296 $column_header{description} =
297 qq|<th><a class=listheading href=$href&sort=description>|
298 . $locale->text('Description')
300 $column_header{debit} = qq|<th>| . $locale->text('Debit') . qq|</th>|;
301 $column_header{credit} = qq|<th>| . $locale->text('Credit') . qq|</th>|;
302 $column_header{balance} = qq|<th>| . $locale->text('Balance') . qq|</th>|;
305 $form->sort_columns(qw(transdate reference description debit credit));
307 if ($form->{accounttype} eq 'gifi') {
308 map { $form->{$_} = $form->{"gifi_$_"} } qw(accno description);
310 if ($form->{accno}) {
311 push @column_index, "balance";
315 ($form->{accounttype} eq 'gifi')
316 ? $locale->text('GIFI')
317 : $locale->text('Account');
319 $form->{title} .= " $form->{accno} - $form->{description}";
321 if ($form->{department}) {
322 ($department) = split /--/, $form->{department};
323 $options = $locale->text('Department') . " : $department<br>";
325 if ($form->{projectnumber}) {
326 $options .= $locale->text('Project Number');
327 $options .= " : $form->{projectnumber}<br>";
330 if ($form->{fromdate} || $form->{todate}) {
331 if ($form->{fromdate}) {
332 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
334 if ($form->{todate}) {
335 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
338 $form->{period} = "$fromdate - $todate";
341 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
344 $options .= $form->{period};
353 <th class=listtop>$form->{title}</th>
362 <tr class=listheading>
365 map { print "$column_header{$_}\n" } @column_index;
371 # add sort to callback
372 $callback = $form->escape($callback . "&sort=$form->{sort}");
374 if (@{ $form->{CA} }) {
375 $sameitem = $form->{CA}->[0]->{ $form->{sort} };
378 $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
379 if ($form->{accno} && $form->{balance}) {
381 map { $column_data{$_} = "<td> </td>" } @column_index;
383 $column_data{balance} =
385 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
393 map { print $column_data{$_} } @column_index;
399 foreach $ca (@{ $form->{CA} }) {
401 if ($form->{l_subtotal} eq 'Y') {
402 if ($sameitem ne $ca->{ $form->{sort} }) {
407 # construct link to source
409 "<a href=$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{reference}</a>";
411 $column_data{debit} =
413 . $form->format_amount(\%myconfig, $ca->{debit}, 2, " ") . "</td>";
414 $column_data{credit} =
416 . $form->format_amount(\%myconfig, $ca->{credit}, 2, " ") . "</td>";
418 $form->{balance} += $ca->{amount};
419 $column_data{balance} =
421 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
424 $subtotaldebit += $ca->{debit};
425 $subtotalcredit += $ca->{credit};
427 $totaldebit += $ca->{debit};
428 $totalcredit += $ca->{credit};
430 $column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
431 $column_data{reference} = qq|<td>$href</td>|;
432 $column_data{description} = qq|<td>$ca->{description}</td>|;
440 map { print $column_data{$_} } @column_index;
448 if ($form->{l_subtotal} eq 'Y') {
452 map { $column_data{$_} = "<td> </td>" } @column_index;
454 $column_data{debit} =
456 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
457 $column_data{credit} =
459 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
460 $column_data{balance} =
462 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
468 map { print $column_data{$_} } @column_index;
476 <td><hr size=3 noshade></td>
484 $lxdebug->leave_sub();
488 $lxdebug->enter_sub();
490 map { $column_data{$_} = "<td> </td>" } @column_index;
492 $column_data{debit} =
494 . $form->format_amount(\%myconfig, $subtotaldebit, 2, " ") . "</th>";
495 $column_data{credit} =
497 . $form->format_amount(\%myconfig, $subtotalcredit, 2, " ") . "</th>";
502 $sameitem = $ca->{ $form->{sort} };
505 <tr class=listsubtotal>
508 map { print "$column_data{$_}\n" } @column_index;
514 $lxdebug->leave_sub();