1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
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 #======================================================================
32 #======================================================================
37 require "$form->{path}/arap.pl";
38 require "bin/mozilla/common.pl";
44 # this is for our long dates
45 # $locale->text('January')
46 # $locale->text('February')
47 # $locale->text('March')
48 # $locale->text('April')
49 # $locale->text('May ')
50 # $locale->text('June')
51 # $locale->text('July')
52 # $locale->text('August')
53 # $locale->text('September')
54 # $locale->text('October')
55 # $locale->text('November')
56 # $locale->text('December')
58 # this is for our short month
59 # $locale->text('Jan')
60 # $locale->text('Feb')
61 # $locale->text('Mar')
62 # $locale->text('Apr')
63 # $locale->text('May')
64 # $locale->text('Jun')
65 # $locale->text('Jul')
66 # $locale->text('Aug')
67 # $locale->text('Sep')
68 # $locale->text('Oct')
69 # $locale->text('Nov')
70 # $locale->text('Dec')
73 $lxdebug->enter_sub();
75 $form->{title} = "Add";
78 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
79 unless $form->{callback};
81 # we use this only to set a default date
82 GL->transaction(\%myconfig, \%$form);
86 "<option value=\"$_->{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}</option>"
87 } @{ $form->{chart} };
90 qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
91 . ($_->{rate} * 100) . qq| %|
94 $form->{chart} = $chart;
95 $form->{chartinit} = $chart;
96 $form->{rowcount} = 2;
98 $form->{debitchart} = $chart;
99 $form->{creditchart} = $chart;
100 $form->{taxchart} = $tax;
107 $form->all_departments(\%myconfig);
108 if (@{ $form->{all_departments} }) {
109 $form->{selectdepartment} = "<option>\n";
112 $form->{selectdepartment} .=
113 "<option>$_->{description}--$_->{id}\n"
114 } (@{ $form->{all_departments} });
118 $lxdebug->leave_sub();
123 $lxdebug->enter_sub();
125 GL->transaction(\%myconfig, \%$form);
128 "<option value=\"$_->{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}</option>"
129 } @{ $form->{chart} };
133 qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
134 . ($_->{rate} * 100) . qq| %|
137 $form->{chart} = $chart;
139 $form->{taxchart} = $tax;
141 $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2);
144 $form->all_departments(\%myconfig);
145 if (@{ $form->{all_departments} }) {
146 $form->{selectdepartment} = "<option>\n";
149 $form->{selectdepartment} .=
150 "<option>$_->{description}--$_->{id}\n"
151 } (@{ $form->{all_departments} });
157 foreach $ref (@{ $form->{GL} }) {
159 if ($tax && ($ref->{accno} eq $taxaccno)) {
160 $form->{"tax_$j"} = abs($ref->{amount});
161 $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate};
162 if ($form->{taxincluded}) {
163 if ($ref->{amount} < 0) {
164 $form->{"debit_$j"} += $form->{"tax_$j"};
166 $form->{"credit_$j"} += $form->{"tax_$j"};
170 $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}";
171 for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
172 if ($ref->{amount} < 0) {
173 $form->{totaldebit} -= $ref->{amount};
174 $form->{"debit_$i"} = $ref->{amount} * -1;
176 $form->{totalcredit} += $ref->{amount};
177 $form->{"credit_$i"} = $ref->{amount};
179 $form->{"taxchart_$i"} = "0--0.00";
182 if ($ref->{taxaccno} && !$tax) {
183 $taxaccno = $ref->{taxaccno};
192 $form->{rowcount} = $i;
194 ($form->datetonum($form->{transdate}, \%myconfig) <=
195 $form->datetonum($form->{closedto}, \%myconfig));
197 $form->{title} = "Edit";
202 $lxdebug->leave_sub();
207 $lxdebug->enter_sub();
209 $form->{title} = $locale->text('Buchungsjournal');
211 $form->all_departments(\%myconfig);
214 if (@{ $form->{all_departments} }) {
215 $form->{selectdepartment} = "<option>\n";
218 $form->{selectdepartment} .=
219 "<option>$_->{description}--$_->{id}\n"
220 } (@{ $form->{all_departments} });
225 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
226 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
228 | if $form->{selectdepartment};
230 # use JavaScript Calendar or not
231 $form->{jsscript} = $jscalendar;
233 if ($form->{jsscript}) {
235 # with JavaScript Calendar
237 <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
238 <input type=button name=datefrom id="trigger1" value=|
239 . $locale->text('button') . qq|></td>
242 <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
243 <input type=button name=dateto id="trigger2" value=|
244 . $locale->text('button') . qq|></td>
249 Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1",
250 "dateto", "BL", "trigger2");
253 # without JavaScript Calendar
255 qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
257 qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
265 <form method=post action=$form->{script}>
267 <input type=hidden name=sort value=transdate>
271 <th class=listtop>$form->{title}</th>
278 <th align=right>| . $locale->text('Reference') . qq|</th>
279 <td><input name=reference size=20></td>
280 <th align=right>| . $locale->text('Source') . qq|</th>
281 <td><input name=source size=20></td>
285 <th align=right>| . $locale->text('Description') . qq|</th>
286 <td colspan=3><input name=description size=40></td>
289 <th align=right>| . $locale->text('Notes') . qq|</th>
290 <td colspan=3><input name=notes size=40></td>
293 <th align=right>| . $locale->text('From') . qq|</th>
295 <th align=right>| . $locale->text('To (time)') . qq|</th>
299 <th align=right>| . $locale->text('Include in Report') . qq|</th>
304 <input name="category" class=radio type=radio value=X checked> |
305 . $locale->text('All') . qq|
306 <input name="category" class=radio type=radio value=A> |
307 . $locale->text('Asset') . qq|
308 <input name="category" class=radio type=radio value=L> |
309 . $locale->text('Liability') . qq|
310 <input name="category" class=radio type=radio value=I> |
311 . $locale->text('Revenue') . qq|
312 <input name="category" class=radio type=radio value=E> |
313 . $locale->text('Expense') . qq|
319 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
320 <td>| . $locale->text('ID') . qq|</td>
321 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
322 <td>| . $locale->text('Date') . qq|</td>
323 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
324 <td>| . $locale->text('Reference') . qq|</td>
325 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
326 <td>| . $locale->text('Description') . qq|</td>
327 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
328 <td>| . $locale->text('Notes') . qq|</td>
331 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
332 <td>| . $locale->text('Debit') . qq|</td>
333 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
334 <td>| . $locale->text('Credit') . qq|</td>
335 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
336 <td>| . $locale->text('Source') . qq|</td>
337 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
338 <td>| . $locale->text('Account') . qq|</td>
339 <td align=right><input name="l_gifi_accno" class=checkbox type=checkbox value=Y></td>
340 <td>| . $locale->text('GIFI') . qq|</td>
343 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
344 <td>| . $locale->text('Subtotal') . qq|</td>
354 <td><hr size=3 noshade></td>
360 <input type=hidden name=nextsub value=generate_report>
362 <input type=hidden name=path value=$form->{path}>
363 <input type=hidden name=login value=$form->{login}>
364 <input type=hidden name=password value=$form->{password}>
367 <input class=submit type=submit name=action value="|
368 . $locale->text('Continue') . qq|">
374 $lxdebug->leave_sub();
377 sub generate_report {
378 $lxdebug->enter_sub();
380 $form->{sort} = "transdate" unless $form->{sort};
382 GL->all_transactions(\%myconfig, \%$form);
385 "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
389 %acctype = ('A' => $locale->text('Asset'),
390 'C' => $locale->text('Contra'),
391 'L' => $locale->text('Liability'),
392 'Q' => $locale->text('Equity'),
393 'I' => $locale->text('Revenue'),
394 'E' => $locale->text('Expense'),);
396 $form->{title} = $locale->text('General Ledger');
398 $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
400 unless ($form->{category} eq 'X') {
401 $form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
403 if ($form->{accno}) {
404 $href .= "&accno=" . $form->escape($form->{accno});
405 $callback .= "&accno=" . $form->escape($form->{accno}, 1);
407 $locale->text('Account')
408 . " : $form->{accno} $form->{account_description}";
410 if ($form->{gifi_accno}) {
411 $href .= "&gifi_accno=" . $form->escape($form->{gifi_accno});
412 $callback .= "&gifi_accno=" . $form->escape($form->{gifi_accno}, 1);
413 $option .= "\n<br>" if $option;
415 $locale->text('GIFI')
416 . " : $form->{gifi_accno} $form->{gifi_account_description}";
418 if ($form->{source}) {
419 $href .= "&source=" . $form->escape($form->{source});
420 $callback .= "&source=" . $form->escape($form->{source}, 1);
421 $option .= "\n<br>" if $option;
422 $option .= $locale->text('Source') . " : $form->{source}";
424 if ($form->{reference}) {
425 $href .= "&reference=" . $form->escape($form->{reference});
426 $callback .= "&reference=" . $form->escape($form->{reference}, 1);
427 $option .= "\n<br>" if $option;
428 $option .= $locale->text('Reference') . " : $form->{reference}";
430 if ($form->{department}) {
431 $href .= "&department=" . $form->escape($form->{department});
432 $callback .= "&department=" . $form->escape($form->{department}, 1);
433 ($department) = split /--/, $form->{department};
434 $option .= "\n<br>" if $option;
435 $option .= $locale->text('Department') . " : $department";
438 if ($form->{description}) {
439 $href .= "&description=" . $form->escape($form->{description});
440 $callback .= "&description=" . $form->escape($form->{description}, 1);
441 $option .= "\n<br>" if $option;
442 $option .= $locale->text('Description') . " : $form->{description}";
444 if ($form->{notes}) {
445 $href .= "¬es=" . $form->escape($form->{notes});
446 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
447 $option .= "\n<br>" if $option;
448 $option .= $locale->text('Notes') . " : $form->{notes}";
451 if ($form->{datefrom}) {
452 $href .= "&datefrom=$form->{datefrom}";
453 $callback .= "&datefrom=$form->{datefrom}";
454 $option .= "\n<br>" if $option;
456 $locale->text('From') . " "
457 . $locale->date(\%myconfig, $form->{datefrom}, 1);
459 if ($form->{dateto}) {
460 $href .= "&dateto=$form->{dateto}";
461 $callback .= "&dateto=$form->{dateto}";
462 if ($form->{datefrom}) {
465 $option .= "\n<br>" if $option;
468 $locale->text('Bis') . " "
469 . $locale->date(\%myconfig, $form->{dateto}, 1);
472 @columns = $form->sort_columns(
473 qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno)
476 if ($form->{accno} || $form->{gifi_accno}) {
477 @columns = grep !/(accno|gifi_accno)/, @columns;
478 push @columns, "balance";
479 $form->{l_balance} = "Y";
483 $form->{l_credit_accno} = "Y";
484 $form->{l_debit_accno} = "Y";
485 $form->{l_credit_tax} = "Y";
486 $form->{l_debit_tax} = "Y";
487 $form->{l_credit_tax_accno} = "Y";
488 $form->{l_debit_tax_accno} = "Y";
489 $form->{l_accno} = "N";
490 foreach $item (@columns) {
491 if ($form->{"l_$item"} eq "Y") {
492 push @column_index, $item;
494 # add column to href and callback
495 $callback .= "&l_$item=Y";
496 $href .= "&l_$item=Y";
500 if ($form->{l_subtotal} eq 'Y') {
501 $callback .= "&l_subtotal=Y";
502 $href .= "&l_subtotal=Y";
505 $callback .= "&category=$form->{category}";
506 $href .= "&category=$form->{category}";
509 "<th><a class=listheading href=$href&sort=id>"
510 . $locale->text('ID')
512 $column_header{transdate} =
513 "<th><a class=listheading href=$href&sort=transdate>"
514 . $locale->text('Date')
516 $column_header{reference} =
517 "<th><a class=listheading href=$href&sort=reference>"
518 . $locale->text('Reference')
520 $column_header{source} =
521 "<th><a class=listheading href=$href&sort=source>"
522 . $locale->text('Source')
524 $column_header{description} =
525 "<th><a class=listheading href=$href&sort=description>"
526 . $locale->text('Description')
528 $column_header{notes} =
529 "<th class=listheading>" . $locale->text('Notes') . "</th>";
530 $column_header{debit} =
531 "<th class=listheading>" . $locale->text('Debit') . "</th>";
532 $column_header{debit_accno} =
533 "<th><a class=listheading href=$href&sort=accno>"
534 . $locale->text('Debit Account')
536 $column_header{credit} =
537 "<th class=listheading>" . $locale->text('Credit') . "</th>";
538 $column_header{credit_accno} =
539 "<th><a class=listheading href=$href&sort=accno>"
540 . $locale->text('Credit Account')
542 $column_header{debit_tax} =
543 "<th><a class=listheading href=$href&sort=accno>"
544 . $locale->text('Debit Tax')
546 $column_header{debit_tax_accno} =
547 "<th><a class=listheading href=$href&sort=accno>"
548 . $locale->text('Debit Tax Account')
550 $column_header{credit_tax} =
551 "<th><a class=listheading href=$href&sort=accno>"
552 . $locale->text('Credit Tax')
554 $column_header{credit_tax_accno} =
555 "<th><a class=listheading href=$href&sort=accno>"
556 . $locale->text('Credit Tax Account')
558 $column_header{gifi_accno} =
559 "<th><a class=listheading href=$href&sort=gifi_accno>"
560 . $locale->text('GIFI')
562 $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
564 $form->{landscape} = 1;
573 <th class=listtop>$form->{title}</th>
583 <tr class=listheading>
586 map { print "$column_header{$_}\n" } @column_index;
595 # add sort to callback
596 $form->{callback} = "$callback&sort=$form->{sort}";
597 $callback = $form->escape($form->{callback});
599 # initial item for subtotals
600 if (@{ $form->{GL} }) {
601 $sameitem = $form->{GL}->[0]->{ $form->{sort} };
604 if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
606 map { $column_data{$_} = "<td> </td>" } @column_index;
607 $column_data{balance} =
609 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
617 map { print "$column_data{$_}\n" } @column_index;
623 $form->{balance} *= $ml;
624 foreach $ref (@{ $form->{GL} }) {
625 $form->{balance} *= $ml;
627 # if item ne sort print subtotal
628 if ($form->{l_subtotal} eq 'Y') {
629 if ($sameitem ne $ref->{ $form->{sort} }) {
634 #foreach $key (sort keys(%{ $ref->{amount} })) {
635 # $form->{balance} += $ref->{amount}{$key};
639 foreach $key (sort keys(%{ $ref->{debit} })) {
640 $subtotaldebit += $ref->{debit}{$key};
641 $totaldebit += $ref->{debit}{$key};
643 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
646 "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
648 $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key});
652 foreach $key (sort keys(%{ $ref->{credit} })) {
653 $subtotalcredit += $ref->{credit}{$key};
654 $totalcredit += $ref->{credit}{$key};
656 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
659 . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
661 $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key});
665 foreach $key (sort keys(%{ $ref->{debit_tax} })) {
666 $subtotaldebittax += $ref->{debit_tax}{$key};
667 $totaldebittax += $ref->{debit_tax}{$key};
670 $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
673 . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
675 $form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key});
679 foreach $key (sort keys(%{ $ref->{credit_tax} })) {
680 $subtotalcredittax += $ref->{credit_tax}{$key};
681 $totalcredittax += $ref->{credit_tax}{$key};
684 $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
687 . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
689 $form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key});
695 foreach $key (sort keys(%{ $ref->{debit_accno} })) {
698 "<a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
701 "<br><a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
704 # if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
705 # $ref->{debit_tax_accno}{$key} = $taxaccno;
707 $taxaccno = $ref->{debit_tax_accno}{$key};
708 $debittaxkey = $ref->{debit_taxkey}{$key};
714 foreach $key (sort keys(%{ $ref->{credit_accno} })) {
717 "<a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
720 "<br><a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
723 # if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
724 # $ref->{credit_tax_accno}{$key} = $taxaccno;
726 $taxaccno = $ref->{credit_tax_accno}{$key};
727 $credittaxkey = $ref->{credit_taxkey}{$key};
731 foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
734 "<a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
737 "<br><a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
741 $credittaxaccno = "";
742 foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
745 "<a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
748 "<br><a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
753 foreach $key (sort keys(%{ $ref->{transdate} })) {
755 $transdate = "$ref->{transdate}{$key}";
757 $transdate .= "<br>$ref->{transdate}{$key}";
761 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
762 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
764 $column_data{id} = "<td align=right> $ref->{id} </td>";
765 $column_data{transdate} = "<td align=center>$transdate</td>";
766 $column_data{reference} =
767 "<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
768 $column_data{description} = "<td align=center>$ref->{description} </td>";
769 $column_data{source} = "<td align=center>$ref->{source} </td>";
770 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
771 $column_data{debit} = "<td align=right>$debit</td>";
772 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
773 $column_data{credit} = "<td align=right>$credit</td>";
774 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
775 $column_data{debit_tax} =
776 ($ref->{debit_tax_accno} ne "")
777 ? "<td align=right>$debittax</td>"
779 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
780 $column_data{gifi_accno} =
781 "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
782 $column_data{credit_tax} =
783 ($ref->{credit_tax_accno} ne "")
784 ? "<td align=right>$credittax</td>"
786 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
787 $column_data{gifi_accno} =
788 "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
789 $column_data{balance} =
791 . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . "</td>";
796 <tr class=listrow$i>";
797 map { print "$column_data{$_}\n" } @column_index;
802 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
804 map { $column_data{$_} = "<td> </td>" } @column_index;
806 $column_data{debit} =
807 "<th align=right class=listtotal>"
808 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
809 $column_data{credit} =
810 "<th align=right class=listtotal>"
811 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
812 $column_data{debit_tax} =
813 "<th align=right class=listtotal>"
814 . $form->format_amount(\%myconfig, $totaldebittax, 2, " ") . "</th>";
815 $column_data{credit_tax} =
816 "<th align=right class=listtotal>"
817 . $form->format_amount(\%myconfig, $totalcredittax, 2, " ") . "</th>";
818 $column_data{balance} =
819 "<th align=right class=listtotal>"
820 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
826 map { print "$column_data{$_}\n" } @column_index;
835 <td><hr size=3 noshade></td>
841 <form method=post action=$form->{script}>
843 <input name=callback type=hidden value="$form->{callback}">
845 <input type=hidden name=path value=$form->{path}>
846 <input type=hidden name=login value=$form->{login}>
847 <input type=hidden name=password value=$form->{password}>
849 <input class=submit type=submit name=action value="|
850 . $locale->text('GL Transaction') . qq|">
851 <input class=submit type=submit name=action value="|
852 . $locale->text('AR Transaction') . qq|">
853 <input class=submit type=submit name=action value="|
854 . $locale->text('AP Transaction') . qq|">
855 <input class=submit type=submit name=action value="|
856 . $locale->text('Sales Invoice') . qq|">
857 <input class=submit type=submit name=action value="|
858 . $locale->text('Vendor Invoice') . qq|">
865 $lxdebug->leave_sub();
870 $lxdebug->enter_sub();
873 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
875 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
877 map { $column_data{$_} = "<td> </td>" }
878 qw(transdate id reference source description accno);
879 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
880 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
882 print "<tr class=listsubtotal>";
883 map { print "$column_data{$_}\n" } @column_index;
889 $sameitem = $ref->{ $form->{sort} };
890 $lxdebug->leave_sub();
895 $lxdebug->enter_sub();
897 $form->{oldtransdate} = $form->{transdate};
909 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
911 for my $i (1 .. $form->{rowcount}) {
913 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
914 for (qw(debit credit tax)) {
916 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
920 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
927 if (($debitcount >= 2) && ($creditcount == 2)) {
928 $form->{"credit_$i"} = 0;
929 $form->{"tax_$i"} = 0;
933 if (($creditcount >= 2) && ($debitcount == 2)) {
934 $form->{"debit_$i"} = 0;
935 $form->{"tax_$i"} = 0;
939 if (($creditcount == 1) && ($debitcount == 2)) {
942 if (($creditcount == 2) && ($debitcount == 1)) {
945 if ($debitcredit && $credittax) {
946 $form->{"taxchart_$i"} = "0--0.00";
948 if (!$debitcredit && $debittax) {
949 $form->{"taxchart_$i"} = "0--0.00";
952 ($form->{"debit_$i"} == 0)
953 ? $form->{"credit_$i"}
954 : $form->{"debit_$i"};
956 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
957 $form->{"taxchart_$i"} = "0--0.00";
958 $form->{"tax_$i"} = 0;
960 if (!$form->{"korrektur_$i"}) {
961 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
968 if ($form->{taxincluded}) {
969 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
971 $form->{"tax_$i"} = $amount * $rate;
974 $form->{"tax_$i"} = 0;
978 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
983 for $i (1 .. $count) {
985 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
988 for $i ($count + 1 .. $form->{rowcount}) {
989 for (@flds) { delete $form->{"${_}_$i"} }
992 $form->{rowcount} = $count + 1;
995 $lxdebug->leave_sub();
1001 $lxdebug->enter_sub();
1003 &form_header($init);
1005 # for $i (1 .. $form->{rowcount}) {
1006 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1007 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1011 &display_rows($init);
1013 $lxdebug->leave_sub();
1019 $lxdebug->enter_sub();
1021 $form->{totaldebit} = 0;
1022 $form->{totalcredit} = 0;
1023 my $chart = $form->{chart};
1024 $chart = $form->unquote($chart);
1025 $form->{taxchart} = $form->unquote($form->{taxchart});
1026 $taxchart = $form->{taxchart};
1028 my @old_project_ids = ();
1029 map({ push(@old_project_ids, $form->{"project_id_$_"})
1030 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
1032 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1034 "old_id" => \@old_project_ids });
1036 my %project_labels = ();
1037 my @project_values = ("");
1038 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1039 push(@project_values, $item->{"id"});
1040 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
1043 for $i (1 .. $form->{rowcount}) {
1046 <td><input name="source_$i" value="$form->{"source_$i"}" size="16" tabindex=|
1047 . ($i + 11 + (($i - 1) * 8)) . qq|></td>|;
1049 <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16" tabindex=|
1050 . ($i + 12 + (($i - 1) * 8)) . qq|></td>|;
1054 <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:200px" tabindex=|
1055 . ($i + 5 + (($i - 1) * 8)) . qq|>$form->{chartinit}</select></td>|;
1057 qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px" tabindex=|
1058 . ($i + 10 + (($i - 1) * 8))
1059 . qq|>$form->{taxchart}</select></td>|;
1062 qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1063 . ($i + 9 + (($i - 1) * 8))
1065 if ($form->{transfer}) {
1066 $fx_transaction = qq|
1067 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1072 if ($form->{"debit_$i"} != 0) {
1073 $form->{totaldebit} += $form->{"debit_$i"};
1074 if (!$form->{taxincluded}) {
1075 $form->{totaldebit} += $form->{"tax_$i"};
1078 $form->{totalcredit} += $form->{"credit_$i"};
1079 if (!$form->{taxincluded}) {
1080 $form->{totalcredit} += $form->{"tax_$i"};
1084 for (qw(debit credit tax)) {
1085 $form->{"${_}_$i"} =
1086 ($form->{"${_}_$i"})
1087 ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
1091 if ($i < $form->{rowcount}) {
1094 $chart_selected = $form->{"accno_$i"};
1096 s/value=\"$chart_selected\"/value=\"$chart_selected\" selected/;
1098 qq|<td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:200px" tabindex=|
1099 . ($i + 5 + (($i - 1) * 8))
1100 . qq|>$accno</select></td>|;
1102 $tax_selected = $form->{"taxchart_$i"};
1103 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
1105 qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1106 . ($i + 10 + (($i - 1) * 8))
1107 . qq|>$tax</select></td>|;
1109 if ($form->{transfer}) {
1110 $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
1111 $x = ($checked) ? "x" : "";
1112 $fx_transaction = qq|
1113 <td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
1116 $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
1118 qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked tabindex=|
1119 . ($i + 9 + (($i - 1) * 8))
1121 $form->hide_form("accno_$i");
1126 <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|
1127 . ($i + 5 + (($i - 1) * 8)) . qq|>$chart</select></td>|;
1129 <td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1130 . ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart</select></td>|;
1133 qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1134 . ($i + 9 + (($i - 1) * 8))
1136 if ($form->{transfer}) {
1137 $fx_transaction = qq|
1138 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1143 my $debitreadonly = "";
1144 my $creditreadonly = "";
1145 if ($i == $form->{rowcount}) {
1147 $debitreadonly = "readonly";
1148 } elsif ($creditlock) {
1149 $creditreadonly = "readonly";
1154 NTI($cgi->popup_menu('-name' => "project_id_$i",
1155 '-values' => \@project_values,
1156 '-labels' => \%project_labels,
1157 '-default' => $form->{"project_id_$i"} ));
1159 print qq|<tr valign=top>
1162 <td><input name="debit_$i" size=8 value="$form->{"debit_$i"}" accesskey=$i tabindex=|
1163 . ($i + 6 + (($i - 1) * 8)) . qq| $debitreadonly></td>
1164 <td><input name="credit_$i" size=8 value="$form->{"credit_$i"}" tabindex=|
1165 . ($i + 7 + (($i - 1) * 8)) . qq| $creditreadonly></td>
1166 <td><input name="tax_$i" size=6 value="$form->{"tax_$i"}" tabindex=|
1167 . ($i + 8 + (($i - 1) * 8)) . qq|></td>
1172 <td>$projectnumber</td>
1178 $form->hide_form(qw(rowcount selectaccno));
1180 $lxdebug->leave_sub();
1186 $lxdebug->enter_sub();
1187 $title = $form->{title};
1188 $form->{title} = $locale->text("$title General Ledger Transaction");
1189 $readonly = ($form->{id}) ? "readonly" : "";
1191 # $locale->text('Add General Ledger Transaction')
1192 # $locale->text('Edit General Ledger Transaction')
1194 map { $form->{$_} =~ s/\"/"/g }
1195 qw(reference description chart taxchart);
1196 $form->{javascript} = qq|<script type="text/javascript">
1198 function setTaxkey(accno, row) {
1199 var taxkey = accno.options[accno.selectedIndex].value;
1200 var reg = /--([0-9]*)/;
1201 var found = reg.exec(taxkey);
1202 var index = found[1];
1203 index = parseInt(index);
1204 var tax = 'taxchart_' + row;
1205 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
1206 var reg2 = new RegExp("^"+ index, "");
1207 if (reg2.exec(document.getElementById(tax).options[i].value)) {
1208 document.getElementById(tax).options[i].selected = true;
1216 $form->{selectdepartment} =~ s/ selected//;
1217 $form->{selectdepartment} =~
1218 s/option>\Q$form->{department}\E/option selected>$form->{department}/;
1220 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
1222 qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
1225 qq|<input name=description size=50 value="$form->{description}" tabindex="3" $readonly>|;
1228 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
1231 $taxincluded = "checked";
1236 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1237 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1238 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
1240 | if $form->{selectdepartment};
1242 $form->{fokus} = "gl.reference";
1244 $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
1247 # use JavaScript Calendar or not
1248 $form->{jsscript} = $jscalendar;
1250 if ($form->{jsscript}) {
1252 # with JavaScript Calendar
1254 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" tabindex="2" $readonly>
1255 <input type=button name=transdate id="trigger1" value=|
1256 . $locale->text('button') . qq|></td>
1261 Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1");
1264 # without JavaScript Calendar
1266 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" tabindex="2" $readonly></td>|;
1272 <body onLoad="fokus()">
1274 <form method=post name="gl" action=$form->{script}>
1276 <input name=id type=hidden value=$form->{id}>
1278 <input type=hidden name=closedto value=$form->{closedto}>
1279 <input type=hidden name=locked value=$form->{locked}>
1280 <input type=hidden name=title value="$title">
1281 <input type=hidden name=taxchart value="$form->{taxchart}">
1282 <input type=hidden name=chart value="$form->{chart}">
1287 <th class=listtop>$form->{title}</th>
1289 <tr height="5"></tr>
1294 <th align=left>| . $locale->text('Reference') . qq|</th>
1295 <td><input name=reference size=20 value="$form->{reference}" tabindex="1" $readonly></td>
1299 <th align=right nowrap>| . $locale->text('Date') . qq|</th>
1308 <th align=right>| . $locale->text('Belegnummer') . qq|</th>
1309 <td><input name=id size=20 value="$form->{id}" $readonly></td>
1313 <th align=right width=50%>| . $locale->text('Buchungsdatum') . qq|</th>
1314 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly></td>
1325 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1326 <td width=1%>$description</td>
1330 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1331 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1338 <th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
1339 <td align=left><input name=employee size=11 value=$form->{employee} $readonly></td>
1347 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1348 <td width=1%>$description</td>
1352 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1353 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1363 <tr class=listheading>
1364 <th class=listheading style="width:15%">|
1365 . $locale->text('Account') . qq|</th>
1366 <th class=listheading style="width:10%">|
1367 . $locale->text('Debit') . qq|</th>
1368 <th class=listheading style="width:10%">|
1369 . $locale->text('Credit') . qq|</th>
1370 <th class=listheading style="width:10%">|
1371 . $locale->text('Tax') . qq|</th>
1372 <th class=listheading style="width:5%">|
1373 . $locale->text('Korrektur') . qq|</th>
1374 <th class=listheading style="width:10%">|
1375 . $locale->text('Taxkey') . qq|</th>
1376 <th class=listheading style="width:20%">|
1377 . $locale->text('Source') . qq|</th>
1378 <th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
1379 <th class=listheading style="width:20%">|
1380 . $locale->text('Project Number') . qq|</th>
1385 $lxdebug->leave_sub();
1390 $lxdebug->enter_sub();
1391 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1393 $decimalplaces = ($dec > 2) ? $dec : 2;
1394 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
1398 $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
1399 } qw(totaldebit totalcredit);
1402 <tr class=listtotal>
1404 <th align=right class=listtotal> $form->{totaldebit}</th>
1405 <th align=right class=listtotal> $form->{totalcredit}</th>
1413 <input type=hidden name=path value=$form->{path}>
1414 <input type=hidden name=login value=$form->{login}>
1415 <input type=hidden name=password value=$form->{password}>
1417 <input name=callback type=hidden value="$form->{callback}">
1422 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1423 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1427 print qq|<input class=submit type=submit name=action value="|
1428 . $locale->text('Storno') . qq|">|;
1430 # Löschen und ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1432 if (!$form->{locked} && $radieren) {
1434 <input class=submit type=submit name=action value="|
1435 . $locale->text('Post') . qq|" accesskey="b">
1436 <input class=submit type=submit name=action value="|
1437 . $locale->text('Delete') . qq|">|;
1440 # if ($transdate > $closedto) {
1442 # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
1445 if ($transdate > $closedto) {
1446 print qq|<input class=submit type=submit name=action value="|
1447 . $locale->text('Update') . qq|">
1448 <input class=submit type=submit name=action value="|
1449 . $locale->text('Post') . qq|">|;
1459 $lxdebug->leave_sub();
1464 $lxdebug->enter_sub();
1471 <form method=post action=$form->{script}>
1474 map { $form->{$_} =~ s/\"/"/g } qw(reference description chart taxchart);
1476 delete $form->{header};
1478 foreach $key (keys %$form) {
1479 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1483 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1486 . $locale->text('Are you sure you want to delete Transaction')
1487 . qq| $form->{reference}</h4>
1489 <input name=action class=submit type=submit value="|
1490 . $locale->text('Yes') . qq|">
1493 $lxdebug->leave_sub();
1498 $lxdebug->enter_sub();
1500 $form->redirect($locale->text('Transaction deleted!'))
1501 if (GL->delete_transaction(\%myconfig, \%$form));
1502 $form->error($locale->text('Cannot delete transaction!'));
1503 $lxdebug->leave_sub();
1508 $lxdebug->enter_sub();
1510 # check if there is something in reference and date
1511 $form->isblank("reference", $locale->text('Reference missing!'));
1512 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1513 $form->isblank("description", $locale->text('Description missing!'));
1515 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1516 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1523 my $creditcount = 0;
1528 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1529 if ($form->{storno}) {
1530 for my $i (1 .. $form->{rowcount}) {
1531 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1532 if ($form->{"debit_$i"} ne "") {
1533 $form->{"credit_$i"} = $form->{"debit_$i"};
1534 $form->{"debit_$i"} = "";
1535 } elsif ($form->{"credit_$i"} ne "") {
1536 $form->{"debit_$i"} = $form->{"credit_$i"};
1537 $form->{"credit_$i"} = "";
1543 for my $i (1 .. $form->{rowcount}) {
1545 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1546 for (qw(debit credit tax)) {
1547 $form->{"${_}_$i"} =
1548 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1552 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1560 if (($debitcount >= 2) && ($creditcount == 2)) {
1561 $form->{"credit_$i"} = 0;
1562 $form->{"tax_$i"} = 0;
1566 if (($creditcount >= 2) && ($debitcount == 2)) {
1567 $form->{"debit_$i"} = 0;
1568 $form->{"tax_$i"} = 0;
1572 if (($creditcount == 1) && ($debitcount == 2)) {
1575 if (($creditcount == 2) && ($debitcount == 1)) {
1578 if ($debitcredit && $credittax) {
1579 $form->{"taxchart_$i"} = "0--0.00";
1581 if (!$debitcredit && $debittax) {
1582 $form->{"taxchart_$i"} = "0--0.00";
1585 ($form->{"debit_$i"} == 0)
1586 ? $form->{"credit_$i"}
1587 : $form->{"debit_$i"};
1589 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1590 $form->{"taxchart_$i"} = "0--0.00";
1591 $form->{"tax_$i"} = 0;
1593 if (!$form->{"korrektur_$i"}) {
1594 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1601 if ($form->{taxincluded}) {
1602 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1604 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1606 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1609 $form->{"tax_$i"} = $amount * $rate;
1612 $form->{"tax_$i"} = 0;
1614 } elsif ($form->{taxincluded}) {
1616 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1618 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1622 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1627 for $i (1 .. $count) {
1629 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1632 for $i ($count + 1 .. $form->{rowcount}) {
1633 for (@flds) { delete $form->{"${_}_$i"} }
1636 for $i (1 .. $form->{rowcount}) {
1637 $dr = $form->{"debit_$i"};
1638 $cr = $form->{"credit_$i"};
1639 $tax = $form->{"tax_$i"};
1643 'Cannot post transaction with a debit and credit entry for the same account!'
1646 if ($form->{taxincluded}) {
1648 $debit += $dr + $tax;
1651 $credit += $cr + $tax;
1656 $debit += $dr + $tax;
1659 $credit += $cr + $tax;
1664 $form->{taxincluded} = 0;
1667 # this is just for the wise guys
1668 $form->error($locale->text('Cannot post transaction for a closed period!'))
1669 if ($transdate <= $closedto);
1670 if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
1671 $form->error($locale->text('Out of balance transaction!'));
1674 if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) {
1675 $form->error($locale->text('Empty transaction!'));
1678 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1680 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1681 $err[2] = $locale->text('Debit and credit out of balance!');
1682 $err[3] = $locale->text('Cannot post a transaction without a value!');
1684 $form->error($err[$errno]);
1686 undef($form->{callback});
1687 $form->redirect("Buchung gespeichert. Buchungsnummer = " . $form->{id});
1688 $lxdebug->leave_sub();
1693 $lxdebug->enter_sub();
1697 $lxdebug->leave_sub();
1702 $lxdebug->enter_sub();
1705 $form->{storno} = 1;
1707 $lxdebug->leave_sub();