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 description debit credit);
76 $column_header{accno} =
77 qq|<th class=listheading>| . $locale->text('Account') . qq|</th>\n|;
78 $column_header{description} =
79 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>\n|;
80 $column_header{debit} =
81 qq|<th class=listheading>| . $locale->text('Debit') . qq|</th>\n|;
82 $column_header{credit} =
83 qq|<th class=listheading>| . $locale->text('Credit') . qq|</th>\n|;
85 $form->{title} = $locale->text('Chart of Accounts');
87 $colspan = $#column_index + 1;
94 <table border=0 width=100%>
95 <tr><th class=listtop colspan=$colspan>$form->{title}</th></tr>
97 <tr class=listheading>|;
99 map { print $column_header{$_} } @column_index;
105 foreach $ca (@{ $form->{CA} }) {
107 $description = $form->escape($ca->{description});
110 qq|$form->{script}?path=$form->{path}&action=list&accno=$ca->{accno}&login=$form->{login}&password=$form->{password}&description=$description|;
112 if ($ca->{charttype} eq "H") {
113 print qq|<tr class=listheading>|;
114 map { $column_data{$_} = "<th>$ca->{$_}</th>"; } qw(accno description);
118 print qq|<tr class=listrow$i>|;
119 $column_data{accno} = "<td><a href=$href>$ca->{accno}</a></td>";
120 $column_data{description} = "<td>$ca->{description}</td>";
125 $debit = $form->format_amount(\%myconfig, $ca->{debit}, 2, " ");
128 $credit = $form->format_amount(\%myconfig, $ca->{credit}, 2, " ");
130 $column_data{debit} =
134 $column_data{credit} =
139 $totaldebit += $ca->{debit};
140 $totalcredit += $ca->{credit};
142 map { print $column_data{$_} } @column_index;
149 map { $column_data{$_} = "<td> </td>"; }
150 qw(accno description);
152 $column_data{debit} =
153 "<th align=right class=listtotal>"
154 . $form->format_amount(\%myconfig, $totaldebit, 2, 0) . "</th>";
155 $column_data{credit} =
156 "<th align=right class=listtotal>"
157 . $form->format_amount(\%myconfig, $totalcredit, 2, 0) . "</th>";
159 print "<tr class=listtotal>";
161 map { print $column_data{$_} } @column_index;
166 <td colspan=$colspan><hr size=3 noshade></td>
174 $lxdebug->leave_sub();
178 $lxdebug->enter_sub();
180 $form->{title} = $locale->text('List Transactions');
181 $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}";
184 $form->all_departments(\%myconfig);
185 if (@{ $form->{all_departments} }) {
186 $form->{selectdepartment} = "<option>\n";
189 $form->{selectdepartment} .=
190 "<option>$_->{description}--$_->{id}\n"
191 } (@{ $form->{all_departments} });
196 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
197 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
199 | if $form->{selectdepartment};
203 $form->{description} =~ s/\"/"/g;
208 <form method=post action=$form->{script}>
210 <input type=hidden name=accno value=$form->{accno}>
211 <input type=hidden name=description value="$form->{description}">
212 <input type=hidden name=sort value=transdate>
213 <input type=hidden name=eur value=$eur>
214 <input type=hidden name=accounttype value=$form->{accounttype}>
216 <table border=0 width=100%>
217 <tr><th class=listtop>$form->{title}</th></tr>
224 <th align=right>| . $locale->text('From') . qq|</th>
225 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
226 <th align=right>| . $locale->text('To') . qq|</th>
227 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
230 <th align=right>| . $locale->text('Include in Report') . qq|</th>
232 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
233 . $locale->text('Subtotal') . qq|</td>
238 <tr><td><hr size=3 noshade></td></tr>
241 <input type=hidden name=login value=$form->{login}>
242 <input type=hidden name=path value=$form->{path}>
243 <input type=hidden name=password value=$form->{password}>
245 <br><input class=submit type=submit name=action value="|
246 . $locale->text('List Transactions') . qq|">
253 $lxdebug->leave_sub();
256 sub list_transactions {
257 $lxdebug->enter_sub();
259 CA->all_transactions(\%myconfig, \%$form);
261 $description = $form->escape($form->{description});
262 $department = $form->escape($form->{department});
263 $projectnumber = $form->escape($form->{projectnumber});
264 $title = $form->escape($form->{title});
268 "$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}&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title";
270 $description = $form->escape($form->{description}, 1);
271 $department = $form->escape($form->{department}, 1);
272 $projectnumber = $form->escape($form->{projectnumber}, 1);
273 $title = $form->escape($form->{title}, 1);
277 "$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}&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title";
279 # figure out which column comes first
280 $column_header{transdate} =
281 qq|<th><a class=listheading href=$href&sort=transdate>|
282 . $locale->text('Date')
284 $column_header{reference} =
285 qq|<th><a class=listheading href=$href&sort=reference>|
286 . $locale->text('Reference')
288 $column_header{description} =
289 qq|<th><a class=listheading href=$href&sort=description>|
290 . $locale->text('Description')
292 $column_header{debit} = qq|<th>| . $locale->text('Debit') . qq|</th>|;
293 $column_header{credit} = qq|<th>| . $locale->text('Credit') . qq|</th>|;
294 $column_header{balance} = qq|<th>| . $locale->text('Balance') . qq|</th>|;
297 $form->sort_columns(qw(transdate reference description debit credit));
299 if ($form->{accno}) {
300 push @column_index, "balance";
303 $form->{title} = $locale->text('Account') .
304 " $form->{accno} - $form->{description}";
306 if ($form->{department}) {
307 ($department) = split /--/, $form->{department};
308 $options = $locale->text('Department') . " : $department<br>";
310 if ($form->{projectnumber}) {
311 $options .= $locale->text('Project Number');
312 $options .= " : $form->{projectnumber}<br>";
315 if ($form->{fromdate} || $form->{todate}) {
316 if ($form->{fromdate}) {
317 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
319 if ($form->{todate}) {
320 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
323 $form->{period} = "$fromdate - $todate";
326 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
329 $options .= $form->{period};
338 <th class=listtop>$form->{title}</th>
347 <tr class=listheading>
350 map { print "$column_header{$_}\n" } @column_index;
356 # add sort to callback
357 $callback = $form->escape($callback . "&sort=$form->{sort}");
359 if (@{ $form->{CA} }) {
360 $sameitem = $form->{CA}->[0]->{ $form->{sort} };
363 $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
364 if ($form->{accno} && $form->{balance}) {
366 map { $column_data{$_} = "<td> </td>" } @column_index;
368 $column_data{balance} =
370 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
378 map { print $column_data{$_} } @column_index;
384 foreach $ca (@{ $form->{CA} }) {
386 if ($form->{l_subtotal} eq 'Y') {
387 if ($sameitem ne $ca->{ $form->{sort} }) {
392 # construct link to source
394 "<a href=$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{reference}</a>";
395 my $debit = ($ca->{debit} != 0) ? $form->format_amount(\%myconfig, $ca->{debit}, 2, " ") : " ";
396 $column_data{debit} =
397 "<td align=right>$debit</td>";
398 my $credit = ($ca->{credit} != 0) ? $form->format_amount(\%myconfig, $ca->{credit}, 2, " ") : " ";
399 $column_data{credit} =
400 "<td align=right>$credit</td>";
402 $form->{balance} += $ca->{amount};
403 $column_data{balance} =
405 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
408 $subtotaldebit += $ca->{debit};
409 $subtotalcredit += $ca->{credit};
411 $totaldebit += $ca->{debit};
412 $totalcredit += $ca->{credit};
414 $column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
415 $column_data{reference} = qq|<td>$href</td>|;
416 $column_data{description} = qq|<td>$ca->{description}</td>|;
424 map { print $column_data{$_} } @column_index;
432 if ($form->{l_subtotal} eq 'Y') {
436 map { $column_data{$_} = "<td> </td>" } @column_index;
438 $column_data{debit} =
440 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
441 $column_data{credit} =
443 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
444 $column_data{balance} =
446 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
452 map { print $column_data{$_} } @column_index;
460 <td><hr size=3 noshade></td>
468 $lxdebug->leave_sub();
472 $lxdebug->enter_sub();
474 map { $column_data{$_} = "<td> </td>" } @column_index;
476 $column_data{debit} =
478 . $form->format_amount(\%myconfig, $subtotaldebit, 2, " ") . "</th>";
479 $column_data{credit} =
481 . $form->format_amount(\%myconfig, $subtotalcredit, 2, " ") . "</th>";
486 $sameitem = $ca->{ $form->{sort} };
489 <tr class=listsubtotal>
492 map { print "$column_data{$_}\n" } @column_index;
498 $lxdebug->leave_sub();