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')
70 sub chart_of_accounts {
71 $lxdebug->enter_sub();
74 CA->all_accounts(\%myconfig, \%$form);
76 @column_index = qw(accno gifi_accno description debit credit);
78 $column_header{accno} = qq|<th class=listheading>|.$locale->text('Account').qq|</th>\n|;
79 $column_header{gifi_accno} = qq|<th class=listheading>|.$locale->text('GIFI').qq|</th>\n|;
80 $column_header{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>\n|;
81 $column_header{debit} = qq|<th class=listheading>|.$locale->text('Debit').qq|</th>\n|;
82 $column_header{credit} = 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;
106 foreach $ca (@{ $form->{CA} }) {
108 $description = $form->escape($ca->{description});
109 $gifi_description = $form->escape($ca->{gifi_description});
111 $href = 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|;
113 if ($ca->{charttype} eq "H") {
114 print qq|<tr class=listheading>|;
115 map { $column_data{$_} = "<th>$ca->{$_}</th>"; } qw(accno description);
116 $column_data{gifi_accno} = "<th>$ca->{gifi_accno} </th>";
119 print qq|<tr class=listrow$i>|;
120 $column_data{accno} = "<td><a href=$href>$ca->{accno}</a></td>";
121 $column_data{gifi_accno} = "<td><a href=$href&accounttype=gifi>$ca->{gifi_accno}</a> </td>";
122 $column_data{description} = "<td>$ca->{description}</td>";
125 $column_data{debit} = "<td align=right>".$form->format_amount(\%myconfig, $ca->{debit}, 2, " ")."</td>\n";
126 $column_data{credit} = "<td align=right>".$form->format_amount(\%myconfig, $ca->{credit}, 2, " ")."</td>\n";
128 $totaldebit += $ca->{debit};
129 $totalcredit += $ca->{credit};
131 map { print $column_data{$_} } @column_index;
138 map { $column_data{$_} = "<td> </td>"; } qw(accno gifi_accno description);
140 $column_data{debit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebit, 2, 0)."</th>";
141 $column_data{credit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredit, 2, 0)."</th>";
143 print "<tr class=listtotal>";
145 map { print $column_data{$_} } @column_index;
150 <td colspan=$colspan><hr size=3 noshade></td>
158 $lxdebug->leave_sub();
163 $lxdebug->enter_sub();
166 $form->{title} = $locale->text('List Transactions');
167 if ($form->{accounttype} eq 'gifi') {
168 $form->{title} .= " - ".$locale->text('GIFI')." $form->{gifi_accno}";
170 $form->{title} .= " - ".$locale->text('Account')." $form->{accno}";
174 $form->all_departments(\%myconfig);
175 if (@{ $form->{all_departments} }) {
176 $form->{selectdepartment} = "<option>\n";
178 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
183 <th align=right nowrap>|.$locale->text('Department').qq|</th>
184 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
186 | if $form->{selectdepartment};
191 map { $form->{$_} =~ s/\"/"/g; } qw(description gifi_description);
196 <form method=post action=$form->{script}>
198 <input type=hidden name=accno value=$form->{accno}>
199 <input type=hidden name=description value="$form->{description}">
200 <input type=hidden name=sort value=transdate>
201 <input type=hidden name=eur value=$eur>
202 <input type=hidden name=accounttype value=$form->{accounttype}>
203 <input type=hidden name=gifi_accno value=$form->{gifi_accno}>
204 <input type=hidden name=gifi_description value="$form->{gifi_description}">
206 <table border=0 width=100%>
207 <tr><th class=listtop>$form->{title}</th></tr>
214 <th align=right>|.$locale->text('From').qq|</th>
215 <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
216 <th align=right>|.$locale->text('To').qq|</th>
217 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
220 <th align=right>|.$locale->text('Include in Report').qq|</th>
222 <input name=l_subtotal class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|</td>
227 <tr><td><hr size=3 noshade></td></tr>
230 <input type=hidden name=login value=$form->{login}>
231 <input type=hidden name=path value=$form->{path}>
232 <input type=hidden name=password value=$form->{password}>
234 <br><input class=submit type=submit name=action value="|.$locale->text('List Transactions').qq|">
241 $lxdebug->leave_sub();
245 sub list_transactions {
246 $lxdebug->enter_sub();
249 CA->all_transactions(\%myconfig, \%$form);
251 $description = $form->escape($form->{description});
252 $gifi_description = $form->escape($form->{gifi_description});
253 $department = $form->escape($form->{department});
254 $projectnumber = $form->escape($form->{projectnumber});
255 $title = $form->escape($form->{title});
258 $href = "$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";
261 $description = $form->escape($form->{description},1);
262 $gifi_description = $form->escape($form->{gifi_description},1);
263 $department = $form->escape($form->{department},1);
264 $projectnumber = $form->escape($form->{projectnumber},1);
265 $title = $form->escape($form->{title},1);
268 $callback = "$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";
270 # figure out which column comes first
271 $column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</a></th>|;
272 $column_header{reference} = qq|<th><a class=listheading href=$href&sort=reference>|.$locale->text('Reference').qq|</a></th>|;
273 $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
274 $column_header{debit} = qq|<th>|.$locale->text('Debit').qq|</th>|;
275 $column_header{credit} = qq|<th>|.$locale->text('Credit').qq|</th>|;
276 $column_header{balance} = qq|<th>|.$locale->text('Balance').qq|</th>|;
278 @column_index = $form->sort_columns(qw(transdate reference description debit credit));
280 if ($form->{accounttype} eq 'gifi') {
281 map { $form->{$_} = $form->{"gifi_$_"} } qw(accno description);
283 if ($form->{accno}) {
284 push @column_index, "balance";
287 $form->{title} = ($form->{accounttype} eq 'gifi') ? $locale->text('GIFI') : $locale->text('Account');
289 $form->{title} .= " $form->{accno} - $form->{description}";
291 if ($form->{department}) {
292 ($department) = split /--/, $form->{department};
293 $options = $locale->text('Department')." : $department<br>";
295 if ($form->{projectnumber}) {
296 $options .= $locale->text('Project Number');
297 $options .= " : $form->{projectnumber}<br>";
300 if ($form->{fromdate} || $form->{todate}) {
301 if ($form->{fromdate}) {
302 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
304 if ($form->{todate}) {
305 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
308 $form->{period} = "$fromdate - $todate";
310 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig),1);
313 $options .= $form->{period};
322 <th class=listtop>$form->{title}</th>
331 <tr class=listheading>
334 map { print "$column_header{$_}\n" } @column_index;
340 # add sort to callback
341 $callback = $form->escape($callback . "&sort=$form->{sort}");
343 if (@{ $form->{CA} }) {
344 $sameitem = $form->{CA}->[0]->{$form->{sort}};
347 $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
348 if ($form->{accno} && $form->{balance}) {
350 map { $column_data{$_} = "<td> </td>" } @column_index;
352 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
358 map { print $column_data{$_} } @column_index;
364 foreach $ca (@{ $form->{CA} }) {
366 if ($form->{l_subtotal} eq 'Y') {
367 if ($sameitem ne $ca->{$form->{sort}}) {
372 # construct link to source
373 $href = "<a href=$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{reference}</a>";
376 $column_data{debit} = "<td align=right>".$form->format_amount(\%myconfig, $ca->{debit}, 2, " ")."</td>";
377 $column_data{credit} = "<td align=right>".$form->format_amount(\%myconfig, $ca->{credit}, 2, " ")."</td>";
379 $form->{balance} += $ca->{amount};
380 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
382 $subtotaldebit += $ca->{debit};
383 $subtotalcredit += $ca->{credit};
385 $totaldebit += $ca->{debit};
386 $totalcredit += $ca->{credit};
388 $column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
389 $column_data{reference} = qq|<td>$href</td>|;
390 $column_data{description} = qq|<td>$ca->{description}</td>|;
397 map { print $column_data{$_} } @column_index;
406 if ($form->{l_subtotal} eq 'Y') {
411 map { $column_data{$_} = "<td> </td>" } @column_index;
413 $column_data{debit} = "<th align=right>".$form->format_amount(\%myconfig, $totaldebit, 2, " ")."</th>";
414 $column_data{credit} = "<th align=right>".$form->format_amount(\%myconfig, $totalcredit, 2, " ")."</th>";
415 $column_data{balance} = "<th align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</th>";
421 map { print $column_data{$_} } @column_index;
429 <td><hr size=3 noshade></td>
437 $lxdebug->leave_sub();
442 $lxdebug->enter_sub();
445 map { $column_data{$_} = "<td> </td>" } @column_index;
447 $column_data{debit} = "<th align=right>".$form->format_amount(\%myconfig, $subtotaldebit, 2, " ") . "</th>";
448 $column_data{credit} = "<th align=right>".$form->format_amount(\%myconfig, $subtotalcredit, 2, " ") . "</th>";
453 $sameitem = $ca->{$form->{sort}};
456 <tr class=listsubtotal>
459 map { print "$column_data{$_}\n" } @column_index;
465 $lxdebug->leave_sub();