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') . qq|</td>
243 <tr><td><hr size=3 noshade></td></tr>
246 <input type=hidden name=login value=$form->{login}>
247 <input type=hidden name=path value=$form->{path}>
248 <input type=hidden name=password value=$form->{password}>
250 <br><input class=submit type=submit name=action value="|
251 . $locale->text('List Transactions') . qq|">
258 $lxdebug->leave_sub();
261 sub list_transactions {
262 $lxdebug->enter_sub();
264 CA->all_transactions(\%myconfig, \%$form);
266 $description = $form->escape($form->{description});
267 $gifi_description = $form->escape($form->{gifi_description});
268 $department = $form->escape($form->{department});
269 $projectnumber = $form->escape($form->{projectnumber});
270 $title = $form->escape($form->{title});
274 "$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";
276 $description = $form->escape($form->{description}, 1);
277 $gifi_description = $form->escape($form->{gifi_description}, 1);
278 $department = $form->escape($form->{department}, 1);
279 $projectnumber = $form->escape($form->{projectnumber}, 1);
280 $title = $form->escape($form->{title}, 1);
284 "$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";
286 # figure out which column comes first
287 $column_header{transdate} =
288 qq|<th><a class=listheading href=$href&sort=transdate>|
289 . $locale->text('Date')
291 $column_header{reference} =
292 qq|<th><a class=listheading href=$href&sort=reference>|
293 . $locale->text('Reference')
295 $column_header{description} =
296 qq|<th><a class=listheading href=$href&sort=description>|
297 . $locale->text('Description')
299 $column_header{debit} = qq|<th>| . $locale->text('Debit') . qq|</th>|;
300 $column_header{credit} = qq|<th>| . $locale->text('Credit') . qq|</th>|;
301 $column_header{balance} = qq|<th>| . $locale->text('Balance') . qq|</th>|;
304 $form->sort_columns(qw(transdate reference description debit credit));
306 if ($form->{accounttype} eq 'gifi') {
307 map { $form->{$_} = $form->{"gifi_$_"} } qw(accno description);
309 if ($form->{accno}) {
310 push @column_index, "balance";
314 ($form->{accounttype} eq 'gifi')
315 ? $locale->text('GIFI')
316 : $locale->text('Account');
318 $form->{title} .= " $form->{accno} - $form->{description}";
320 if ($form->{department}) {
321 ($department) = split /--/, $form->{department};
322 $options = $locale->text('Department') . " : $department<br>";
324 if ($form->{projectnumber}) {
325 $options .= $locale->text('Project Number');
326 $options .= " : $form->{projectnumber}<br>";
329 if ($form->{fromdate} || $form->{todate}) {
330 if ($form->{fromdate}) {
331 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
333 if ($form->{todate}) {
334 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
337 $form->{period} = "$fromdate - $todate";
340 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
343 $options .= $form->{period};
352 <th class=listtop>$form->{title}</th>
361 <tr class=listheading>
364 map { print "$column_header{$_}\n" } @column_index;
370 # add sort to callback
371 $callback = $form->escape($callback . "&sort=$form->{sort}");
373 if (@{ $form->{CA} }) {
374 $sameitem = $form->{CA}->[0]->{ $form->{sort} };
377 $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
378 if ($form->{accno} && $form->{balance}) {
380 map { $column_data{$_} = "<td> </td>" } @column_index;
382 $column_data{balance} =
384 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
392 map { print $column_data{$_} } @column_index;
398 foreach $ca (@{ $form->{CA} }) {
400 if ($form->{l_subtotal} eq 'Y') {
401 if ($sameitem ne $ca->{ $form->{sort} }) {
406 # construct link to source
408 "<a href=$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{reference}</a>";
410 $column_data{debit} =
412 . $form->format_amount(\%myconfig, $ca->{debit}, 2, " ") . "</td>";
413 $column_data{credit} =
415 . $form->format_amount(\%myconfig, $ca->{credit}, 2, " ") . "</td>";
417 $form->{balance} += $ca->{amount};
418 $column_data{balance} =
420 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
423 $subtotaldebit += $ca->{debit};
424 $subtotalcredit += $ca->{credit};
426 $totaldebit += $ca->{debit};
427 $totalcredit += $ca->{credit};
429 $column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
430 $column_data{reference} = qq|<td>$href</td>|;
431 $column_data{description} = qq|<td>$ca->{description}</td>|;
439 map { print $column_data{$_} } @column_index;
447 if ($form->{l_subtotal} eq 'Y') {
451 map { $column_data{$_} = "<td> </td>" } @column_index;
453 $column_data{debit} =
455 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
456 $column_data{credit} =
458 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
459 $column_data{balance} =
461 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
467 map { print $column_data{$_} } @column_index;
475 <td><hr size=3 noshade></td>
483 $lxdebug->leave_sub();
487 $lxdebug->enter_sub();
489 map { $column_data{$_} = "<td> </td>" } @column_index;
491 $column_data{debit} =
493 . $form->format_amount(\%myconfig, $subtotaldebit, 2, " ") . "</th>";
494 $column_data{credit} =
496 . $form->format_amount(\%myconfig, $subtotalcredit, 2, " ") . "</th>";
501 $sameitem = $ca->{ $form->{sort} };
504 <tr class=listsubtotal>
507 map { print "$column_data{$_}\n" } @column_index;
513 $lxdebug->leave_sub();