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";
43 # this is for our long dates
44 # $locale->text('January')
45 # $locale->text('February')
46 # $locale->text('March')
47 # $locale->text('April')
48 # $locale->text('May ')
49 # $locale->text('June')
50 # $locale->text('July')
51 # $locale->text('August')
52 # $locale->text('September')
53 # $locale->text('October')
54 # $locale->text('November')
55 # $locale->text('December')
57 # this is for our short month
58 # $locale->text('Jan')
59 # $locale->text('Feb')
60 # $locale->text('Mar')
61 # $locale->text('Apr')
62 # $locale->text('May')
63 # $locale->text('Jun')
64 # $locale->text('Jul')
65 # $locale->text('Aug')
66 # $locale->text('Sep')
67 # $locale->text('Oct')
68 # $locale->text('Nov')
69 # $locale->text('Dec')
72 $lxdebug->enter_sub();
74 $form->{title} = "Add";
77 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
78 unless $form->{callback};
80 # we use this only to set a default date
81 GL->transaction(\%myconfig, \%$form);
85 "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>"
86 } @{ $form->{chart} };
89 qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |
90 . ($_->{rate} * 100) . qq| %|
93 $form->{chart} = $chart;
94 $form->{chartinit} = $chart;
95 $form->{rowcount} = 2;
97 $form->{debitchart} = $chart;
98 $form->{creditchart} = $chart;
99 $form->{taxchart} = $tax;
106 $form->all_departments(\%myconfig);
107 if (@{ $form->{all_departments} }) {
108 $form->{selectdepartment} = "<option>\n";
111 $form->{selectdepartment} .=
112 "<option>$_->{description}--$_->{id}\n"
113 } (@{ $form->{all_departments} });
117 $lxdebug->leave_sub();
122 $lxdebug->enter_sub();
124 GL->transaction(\%myconfig, \%$form);
127 "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>"
128 } @{ $form->{chart} };
132 qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |
133 . ($_->{rate} * 100) . qq| %|
136 $form->{chart} = $chart;
138 $form->{taxchart} = $tax;
140 $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2);
143 $form->all_departments(\%myconfig);
144 if (@{ $form->{all_departments} }) {
145 $form->{selectdepartment} = "<option>\n";
148 $form->{selectdepartment} .=
149 "<option>$_->{description}--$_->{id}\n"
150 } (@{ $form->{all_departments} });
156 foreach $ref (@{ $form->{GL} }) {
157 $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
160 if ($tax && ($ref->{accno} eq $taxaccno)) {
161 $form->{"tax_$j"} = abs($ref->{amount});
162 $form->{"taxchart_$j"} = $ref->{taxkey} . "--" . $ref->{taxrate};
164 $form->{"accno_$i"} = "$ref->{accno}--$ref->{accnotaxkey}";
165 for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
166 if ($ref->{amount} < 0) {
167 $form->{totaldebit} -= $ref->{amount};
168 $form->{"debit_$i"} = $ref->{amount} * -1;
170 $form->{totalcredit} += $ref->{amount};
171 $form->{"credit_$i"} = $ref->{amount};
175 if ($ref->{taxaccno} && !$tax) {
176 $taxaccno = $ref->{taxaccno};
185 $form->{rowcount} = $i;
187 ($form->datetonum($form->{transdate}, \%myconfig) <=
188 $form->datetonum($form->{closedto}, \%myconfig));
190 $form->{title} = "Edit";
195 $lxdebug->leave_sub();
200 $lxdebug->enter_sub();
202 $form->{title} = $locale->text('Buchungsjournal');
204 $form->all_departments(\%myconfig);
207 if (@{ $form->{all_departments} }) {
208 $form->{selectdepartment} = "<option>\n";
211 $form->{selectdepartment} .=
212 "<option>$_->{description}--$_->{id}\n"
213 } (@{ $form->{all_departments} });
218 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
219 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
221 | if $form->{selectdepartment};
223 # use JavaScript Calendar or not
224 $form->{jsscript} = $jscalendar;
226 if ($form->{jsscript}) {
228 # with JavaScript Calendar
230 <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
231 <input type=button name=datefrom id="trigger1" value=|
232 . $locale->text('button') . qq|></td>
235 <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
236 <input type=button name=dateto id="trigger2" value=|
237 . $locale->text('button') . qq|></td>
242 Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1",
243 "dateto", "BL", "trigger2");
246 # without JavaScript Calendar
248 qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
250 qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
258 <form method=post action=$form->{script}>
260 <input type=hidden name=sort value=transdate>
264 <th class=listtop>$form->{title}</th>
271 <th align=right>| . $locale->text('Reference') . qq|</th>
272 <td><input name=reference size=20></td>
273 <th align=right>| . $locale->text('Source') . qq|</th>
274 <td><input name=source size=20></td>
278 <th align=right>| . $locale->text('Description') . qq|</th>
279 <td colspan=3><input name=description size=40></td>
282 <th align=right>| . $locale->text('Notes') . qq|</th>
283 <td colspan=3><input name=notes size=40></td>
286 <th align=right>| . $locale->text('From') . qq|</th>
291 <th align=right>| . $locale->text('Include in Report') . qq|</th>
296 <input name="category" class=radio type=radio value=X checked> |
297 . $locale->text('All') . qq|
298 <input name="category" class=radio type=radio value=A> |
299 . $locale->text('Asset') . qq|
300 <input name="category" class=radio type=radio value=C> |
301 . $locale->text('Contra') . qq|
302 <input name="category" class=radio type=radio value=L> |
303 . $locale->text('Liability') . qq|
304 <input name="category" class=radio type=radio value=Q> |
305 . $locale->text('Equity') . qq|
306 <input name="category" class=radio type=radio value=I> |
307 . $locale->text('Revenue') . qq|
308 <input name="category" class=radio type=radio value=E> |
309 . $locale->text('Expense') . qq|
315 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
316 <td>| . $locale->text('ID') . qq|</td>
317 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
318 <td>| . $locale->text('Date') . qq|</td>
319 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
320 <td>| . $locale->text('Reference') . qq|</td>
321 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
322 <td>| . $locale->text('Description') . qq|</td>
323 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
324 <td>| . $locale->text('Notes') . qq|</td>
327 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
328 <td>| . $locale->text('Debit') . qq|</td>
329 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
330 <td>| . $locale->text('Credit') . qq|</td>
331 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
332 <td>| . $locale->text('Source') . qq|</td>
333 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
334 <td>| . $locale->text('Account') . qq|</td>
335 <td align=right><input name="l_gifi_accno" class=checkbox type=checkbox value=Y></td>
336 <td>| . $locale->text('GIFI') . qq|</td>
339 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
340 <td>| . $locale->text('Subtotal') . qq|</td>
350 <td><hr size=3 noshade></td>
356 <input type=hidden name=nextsub value=generate_report>
358 <input type=hidden name=path value=$form->{path}>
359 <input type=hidden name=login value=$form->{login}>
360 <input type=hidden name=password value=$form->{password}>
363 <input class=submit type=submit name=action value="|
364 . $locale->text('Continue') . qq|">
370 $lxdebug->leave_sub();
373 sub generate_report {
374 $lxdebug->enter_sub();
376 $form->{sort} = "transdate" unless $form->{sort};
378 GL->all_transactions(\%myconfig, \%$form);
381 "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
385 %acctype = ('A' => $locale->text('Asset'),
386 'C' => $locale->text('Contra'),
387 'L' => $locale->text('Liability'),
388 'Q' => $locale->text('Equity'),
389 'I' => $locale->text('Revenue'),
390 'E' => $locale->text('Expense'),);
392 $form->{title} = $locale->text('General Ledger');
394 $ml = ($form->{ml} =~ /(A|E)/) ? -1 : 1;
396 unless ($form->{category} eq 'X') {
397 $form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
399 if ($form->{accno}) {
400 $href .= "&accno=" . $form->escape($form->{accno});
401 $callback .= "&accno=" . $form->escape($form->{accno}, 1);
403 $locale->text('Account')
404 . " : $form->{accno} $form->{account_description}";
406 if ($form->{gifi_accno}) {
407 $href .= "&gifi_accno=" . $form->escape($form->{gifi_accno});
408 $callback .= "&gifi_accno=" . $form->escape($form->{gifi_accno}, 1);
409 $option .= "\n<br>" if $option;
411 $locale->text('GIFI')
412 . " : $form->{gifi_accno} $form->{gifi_account_description}";
414 if ($form->{source}) {
415 $href .= "&source=" . $form->escape($form->{source});
416 $callback .= "&source=" . $form->escape($form->{source}, 1);
417 $option .= "\n<br>" if $option;
418 $option .= $locale->text('Source') . " : $form->{source}";
420 if ($form->{reference}) {
421 $href .= "&reference=" . $form->escape($form->{reference});
422 $callback .= "&reference=" . $form->escape($form->{reference}, 1);
423 $option .= "\n<br>" if $option;
424 $option .= $locale->text('Reference') . " : $form->{reference}";
426 if ($form->{department}) {
427 $href .= "&department=" . $form->escape($form->{department});
428 $callback .= "&department=" . $form->escape($form->{department}, 1);
429 ($department) = split /--/, $form->{department};
430 $option .= "\n<br>" if $option;
431 $option .= $locale->text('Department') . " : $department";
434 if ($form->{description}) {
435 $href .= "&description=" . $form->escape($form->{description});
436 $callback .= "&description=" . $form->escape($form->{description}, 1);
437 $option .= "\n<br>" if $option;
438 $option .= $locale->text('Description') . " : $form->{description}";
440 if ($form->{notes}) {
441 $href .= "¬es=" . $form->escape($form->{notes});
442 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
443 $option .= "\n<br>" if $option;
444 $option .= $locale->text('Notes') . " : $form->{notes}";
447 if ($form->{datefrom}) {
448 $href .= "&datefrom=$form->{datefrom}";
449 $callback .= "&datefrom=$form->{datefrom}";
450 $option .= "\n<br>" if $option;
452 $locale->text('From') . " "
453 . $locale->date(\%myconfig, $form->{datefrom}, 1);
455 if ($form->{dateto}) {
456 $href .= "&dateto=$form->{dateto}";
457 $callback .= "&dateto=$form->{dateto}";
458 if ($form->{datefrom}) {
461 $option .= "\n<br>" if $option;
464 $locale->text('Bis') . " "
465 . $locale->date(\%myconfig, $form->{dateto}, 1);
468 @columns = $form->sort_columns(
469 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)
472 if ($form->{accno} || $form->{gifi_accno}) {
473 @columns = grep !/(accno|gifi_accno)/, @columns;
474 push @columns, "balance";
475 $form->{l_balance} = "Y";
479 $form->{l_credit_accno} = "Y";
480 $form->{l_debit_accno} = "Y";
481 $form->{l_credit_tax} = "Y";
482 $form->{l_debit_tax} = "Y";
483 $form->{l_credit_tax_accno} = "Y";
484 $form->{l_debit_tax_accno} = "Y";
485 $form->{l_accno} = "N";
486 foreach $item (@columns) {
487 if ($form->{"l_$item"} eq "Y") {
488 push @column_index, $item;
490 # add column to href and callback
491 $callback .= "&l_$item=Y";
492 $href .= "&l_$item=Y";
496 if ($form->{l_subtotal} eq 'Y') {
497 $callback .= "&l_subtotal=Y";
498 $href .= "&l_subtotal=Y";
501 $callback .= "&category=$form->{category}";
502 $href .= "&category=$form->{category}";
505 "<th><a class=listheading href=$href&sort=id>"
506 . $locale->text('ID')
508 $column_header{transdate} =
509 "<th><a class=listheading href=$href&sort=transdate>"
510 . $locale->text('Date')
512 $column_header{reference} =
513 "<th><a class=listheading href=$href&sort=reference>"
514 . $locale->text('Reference')
516 $column_header{source} =
517 "<th><a class=listheading href=$href&sort=source>"
518 . $locale->text('Source')
520 $column_header{description} =
521 "<th><a class=listheading href=$href&sort=description>"
522 . $locale->text('Description')
524 $column_header{notes} =
525 "<th class=listheading>" . $locale->text('Notes') . "</th>";
526 $column_header{debit} =
527 "<th class=listheading>" . $locale->text('Debit') . "</th>";
528 $column_header{debit_accno} =
529 "<th><a class=listheading href=$href&sort=accno>"
530 . $locale->text('Debit Account')
532 $column_header{credit} =
533 "<th class=listheading>" . $locale->text('Credit') . "</th>";
534 $column_header{credit_accno} =
535 "<th><a class=listheading href=$href&sort=accno>"
536 . $locale->text('Credit Account')
538 $column_header{debit_tax} =
539 "<th><a class=listheading href=$href&sort=accno>"
540 . $locale->text('Debit Tax')
542 $column_header{debit_tax_accno} =
543 "<th><a class=listheading href=$href&sort=accno>"
544 . $locale->text('Debit Tax Account')
546 $column_header{credit_tax} =
547 "<th><a class=listheading href=$href&sort=accno>"
548 . $locale->text('Credit Tax')
550 $column_header{credit_tax_accno} =
551 "<th><a class=listheading href=$href&sort=accno>"
552 . $locale->text('Credit Tax Account')
554 $column_header{gifi_accno} =
555 "<th><a class=listheading href=$href&sort=gifi_accno>"
556 . $locale->text('GIFI')
558 $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
560 $form->{landscape} = 1;
569 <th class=listtop>$form->{title}</th>
579 <tr class=listheading>
582 map { print "$column_header{$_}\n" } @column_index;
591 # add sort to callback
592 $form->{callback} = "$callback&sort=$form->{sort}";
593 $callback = $form->escape($form->{callback});
595 # initial item for subtotals
596 if (@{ $form->{GL} }) {
597 $sameitem = $form->{GL}->[0]->{ $form->{sort} };
600 if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
602 map { $column_data{$_} = "<td> </td>" } @column_index;
603 $column_data{balance} =
605 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
613 map { print "$column_data{$_}\n" } @column_index;
620 foreach $ref (@{ $form->{GL} }) {
622 # if item ne sort print subtotal
623 if ($form->{l_subtotal} eq 'Y') {
624 if ($sameitem ne $ref->{ $form->{sort} }) {
628 foreach $key (sort keys(%{ $ref->{amount} })) {
629 $form->{balance} += $ref->{amount}{$key};
633 foreach $key (sort keys(%{ $ref->{debit} })) {
634 $subtotaldebit += $ref->{debit}{$key};
635 $totaldebit += $ref->{debit}{$key};
637 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
640 "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
645 foreach $key (sort keys(%{ $ref->{credit} })) {
646 $subtotalcredit += $ref->{credit}{$key};
647 $totalcredit += $ref->{credit}{$key};
649 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
652 . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
657 foreach $key (sort keys(%{ $ref->{debit_tax} })) {
658 $subtotaldebittax += $ref->{debit_tax}{$key};
659 $totaldebittax += $ref->{debit_tax}{$key};
662 $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
665 . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
670 foreach $key (sort keys(%{ $ref->{credit_tax} })) {
671 $subtotalcredittax += $ref->{credit_tax}{$key};
672 $totalcredittax += $ref->{credit_tax}{$key};
675 $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
678 . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
685 foreach $key (sort keys(%{ $ref->{debit_accno} })) {
688 "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
691 "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
693 if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
694 $ref->{debit_tax_accno}{$key} = $taxaccno;
696 $taxaccno = $ref->{debit_tax_accno}{$key};
697 $debittaxkey = $ref->{debit_taxkey}{$key};
703 foreach $key (sort keys(%{ $ref->{credit_accno} })) {
706 "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
709 "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
711 if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
712 $ref->{credit_tax_accno}{$key} = $taxaccno;
714 $taxaccno = $ref->{credit_tax_accno}{$key};
715 $credittaxkey = $ref->{credit_taxkey}{$key};
719 foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
722 "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
725 "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
729 $credittaxaccno = "";
730 foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
733 "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
736 "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
740 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
741 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
743 $column_data{id} = "<td align=right> $ref->{id} </td>";
744 $column_data{transdate} =
745 "<td align=center> $ref->{transdate} </td>";
746 $column_data{reference} =
747 "<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>";
748 $column_data{description} =
749 "<td align=center>$ref->{description} </td>";
750 $column_data{source} = "<td align=center>$ref->{source} </td>";
751 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
752 $column_data{debit} = "<td align=right>$debit</td>";
753 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
754 $column_data{credit} = "<td align=right>$credit</td>";
755 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
756 $column_data{debit_tax} =
757 ($ref->{debit_tax_accno} ne "")
758 ? "<td align=right>$debittax</td>"
760 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
761 $column_data{gifi_accno} =
762 "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
763 $column_data{credit_tax} =
764 ($ref->{credit_tax_accno} ne "")
765 ? "<td align=right>$credittax</td>"
767 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
768 $column_data{gifi_accno} =
769 "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
770 $column_data{balance} =
772 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
778 <tr class=listrow$i>";
779 map { print "$column_data{$_}\n" } @column_index;
784 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
786 map { $column_data{$_} = "<td> </td>" } @column_index;
788 $column_data{debit} =
789 "<th align=right class=listtotal>"
790 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
791 $column_data{credit} =
792 "<th align=right class=listtotal>"
793 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
794 $column_data{debit_tax} =
795 "<th align=right class=listtotal>"
796 . $form->format_amount(\%myconfig, $totaldebittax, 2, " ") . "</th>";
797 $column_data{credit_tax} =
798 "<th align=right class=listtotal>"
799 . $form->format_amount(\%myconfig, $totalcredittax, 2, " ") . "</th>";
800 $column_data{balance} =
801 "<th align=right class=listtotal>"
802 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
808 map { print "$column_data{$_}\n" } @column_index;
817 <td><hr size=3 noshade></td>
823 <form method=post action=$form->{script}>
825 <input name=callback type=hidden value="$form->{callback}">
827 <input type=hidden name=path value=$form->{path}>
828 <input type=hidden name=login value=$form->{login}>
829 <input type=hidden name=password value=$form->{password}>
831 <input class=submit type=submit name=action value="|
832 . $locale->text('GL Transaction') . qq|">
833 <input class=submit type=submit name=action value="|
834 . $locale->text('AR Transaction') . qq|">
835 <input class=submit type=submit name=action value="|
836 . $locale->text('AP Transaction') . qq|">
837 <input class=submit type=submit name=action value="|
838 . $locale->text('Sales Invoice') . qq|">
839 <input class=submit type=submit name=action value="|
840 . $locale->text('Vendor Invoice') . qq|">|;
842 if ($form->{menubar}) {
843 require "$form->{path}/menu.pl";
854 $lxdebug->leave_sub();
859 $lxdebug->enter_sub();
862 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
864 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
866 map { $column_data{$_} = "<td> </td>" }
867 qw(transdate id reference source description accno);
868 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
869 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
871 print "<tr class=listsubtotal>";
872 map { print "$column_data{$_}\n" } @column_index;
878 $sameitem = $ref->{ $form->{sort} };
879 $lxdebug->leave_sub();
884 $lxdebug->enter_sub();
886 if ($form->{transdate} ne $form->{oldtransdate}) {
887 if ($form->{selectprojectnumber}) {
888 $form->all_projects(\%myconfig, undef, $form->{transdate});
889 if (@{ $form->{all_project} }) {
890 $form->{selectprojectnumber} = "<option>\n";
891 for (@{ $form->{all_project} }) {
892 $form->{selectprojectnumber} .=
893 qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n|;
895 $form->{selectprojectnumber} =
896 $form->escape($form->{selectprojectnumber}, 1);
899 $form->{oldtransdate} = $form->{transdate};
912 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
914 for my $i (1 .. $form->{rowcount}) {
916 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
917 for (qw(debit credit tax)) {
919 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
923 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
930 if (($debitcount >= 2) && ($creditcount == 2)) {
931 $form->{"credit_$i"} = 0;
932 $form->{"tax_$i"} = 0;
936 if (($creditcount >= 2) && ($debitcount == 2)) {
937 $form->{"debit_$i"} = 0;
938 $form->{"tax_$i"} = 0;
942 if (($creditcount == 1) && ($debitcount == 2)) {
945 if (($creditcount == 2) && ($debitcount == 1)) {
948 if ($debitcredit && $credittax) {
949 $form->{"taxchart_$i"} = "0--0.00";
951 if (!$debitcredit && $debittax) {
952 $form->{"taxchart_$i"} = "0--0.00";
955 ($form->{"debit_$i"} == 0)
956 ? $form->{"credit_$i"}
957 : $form->{"debit_$i"};
959 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
960 $form->{"taxchart_$i"} = "0--";
961 $form->{"tax_$i"} = 0;
963 if (!$form->{"korrektur_$i"}) {
964 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
971 if ($form->{taxincluded}) {
972 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
974 $form->{"tax_$i"} = $amount * $rate;
977 $form->{"tax_$i"} = 0;
981 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
986 for $i (1 .. $count) {
988 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
991 for $i ($count + 1 .. $form->{rowcount}) {
992 for (@flds) { delete $form->{"${_}_$i"} }
995 $form->{rowcount} = $count + 1;
998 $lxdebug->leave_sub();
1004 $lxdebug->enter_sub();
1006 &form_header($init);
1008 # for $i (1 .. $form->{rowcount}) {
1009 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1010 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1014 &display_rows($init);
1016 $lxdebug->leave_sub();
1022 $lxdebug->enter_sub();
1024 $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber})
1025 if $form->{selectprojectnumber};
1027 $form->{totaldebit} = 0;
1028 $form->{totalcredit} = 0;
1029 my $chart = $form->{chart};
1030 $chart = $form->unquote($chart);
1031 $form->{taxchart} = $form->unquote($form->{taxchart});
1032 $taxchart = $form->{taxchart};
1033 for $i (1 .. $form->{rowcount}) {
1036 <td><input name="source_$i" value="$form->{"source_$i"}" tabindex=|
1037 . ($i + 11 + (($i - 1) * 8)) . qq|></td>|;
1039 <td><input name="memo_$i" value="$form->{"memo_$i"}" tabindex=|
1040 . ($i + 12 + (($i - 1) * 8)) . qq|></td>|;
1044 <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|
1045 . ($i + 5 + (($i - 1) * 8)) . qq|>$form->{chartinit}</select></td>|;
1047 qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1048 . ($i + 10 + (($i - 1) * 8))
1049 . qq|>$form->{taxchart}</select></td>|;
1050 if ($form->{selectprojectnumber}) {
1052 <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
1055 qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1056 . ($i + 9 + (($i - 1) * 8))
1058 if ($form->{transfer}) {
1059 $fx_transaction = qq|
1060 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1065 if ($form->{"debit_$i"} != 0) {
1066 $form->{totaldebit} += $form->{"debit_$i"};
1067 $form->{totaldebit} += $form->{"tax_$i"};
1069 $form->{totalcredit} += $form->{"credit_$i"};
1070 $form->{totalcredit} += $form->{"tax_$i"};
1073 for (qw(debit credit tax)) {
1074 $form->{"${_}_$i"} =
1075 ($form->{"${_}_$i"})
1076 ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
1080 if ($i < $form->{rowcount}) {
1083 $chart_selected = $form->{"accno_$i"};
1085 s/value=\"$chart_selected\"/value=\"$chart_selected\" selected/;
1087 qq|<td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|
1088 . ($i + 5 + (($i - 1) * 8))
1089 . qq|>$accno</select></td>|;
1091 $tax_selected = $form->{"taxchart_$i"};
1092 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
1094 qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1095 . ($i + 10 + (($i - 1) * 8))
1096 . qq|>$tax</select></td>|;
1098 if ($form->{selectprojectnumber}) {
1099 $form->{"projectnumber_$i"} = ""
1100 if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/;
1102 $project = $form->{"projectnumber_$i"};
1103 $project =~ s/--.*//;
1104 $project = qq|<td>$project</td>|;
1107 if ($form->{transfer}) {
1108 $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
1109 $x = ($checked) ? "x" : "";
1110 $fx_transaction = qq|
1111 <td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
1114 $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
1116 qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked tabindex=|
1117 . ($i + 9 + (($i - 1) * 8))
1119 $form->hide_form("accno_$i", "projectnumber_$i");
1124 <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|
1125 . ($i + 5 + (($i - 1) * 8)) . qq|>$chart</select></td>|;
1127 <td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
1128 . ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart</select></td>|;
1129 if ($form->{selectprojectnumber}) {
1131 <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
1134 qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1135 . ($i + 9 + (($i - 1) * 8))
1137 if ($form->{transfer}) {
1138 $fx_transaction = qq|
1139 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1144 my $debitreadonly = "";
1145 my $creditreadonly = "";
1146 if ($i == $form->{rowcount}) {
1148 $debitreadonly = "readonly";
1149 } elsif ($creditlock) {
1150 $creditreadonly = "readonly";
1154 print qq|<tr valign=top>
1157 <td><input name="debit_$i" size=10 value="$form->{"debit_$i"}" accesskey=$i tabindex=|
1158 . ($i + 6 + (($i - 1) * 8)) . qq| $debitreadonly></td>
1159 <td><input name="credit_$i" size=10 value="$form->{"credit_$i"}" tabindex=|
1160 . ($i + 7 + (($i - 1) * 8)) . qq| $creditreadonly></td>
1161 <td><input name="tax_$i" size=8 value="$form->{"tax_$i"}" tabindex=|
1162 . ($i + 8 + (($i - 1) * 8)) . qq|></td>
1173 $form->hide_form(qw(rowcount selectaccno));
1175 <input type=hidden name=selectprojectnumber value="|
1176 . $form->escape($form->{selectprojectnumber}, 1) . qq|">|;
1177 $lxdebug->leave_sub();
1183 $lxdebug->enter_sub();
1184 $title = $form->{title};
1185 $form->{title} = $locale->text("$title General Ledger Transaction");
1186 $readonly = ($form->{id}) ? "readonly" : "";
1188 # $locale->text('Add General Ledger Transaction')
1189 # $locale->text('Edit General Ledger Transaction')
1191 map { $form->{$_} =~ s/\"/"/g }
1192 qw(reference description chart taxchart);
1193 $form->{javascript} = qq|<script type="text/javascript">
1195 function setTaxkey(accno, row) {
1196 var taxkey = accno.options[accno.selectedIndex].value;
1197 var reg = /--([0-9])*/;
1198 var found = reg.exec(taxkey);
1199 var index = found[1];
1200 index = parseInt(index);
1201 var tax = 'taxchart_' + row;
1202 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
1203 var reg2 = new RegExp("^"+ index, "");
1204 if (reg2.exec(document.getElementById(tax).options[i].value)) {
1205 document.getElementById(tax).options[i].selected = true;
1213 $form->{selectdepartment} =~ s/ selected//;
1214 $form->{selectdepartment} =~
1215 s/option>\Q$form->{department}\E/option selected>$form->{department}/;
1217 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
1219 qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
1222 qq|<input name=description size=50 value="$form->{description}" tabindex="3" $readonly>|;
1225 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
1228 $taxincluded = "checked";
1233 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1234 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1235 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
1237 | if $form->{selectdepartment};
1239 $form->{fokus} = "gl.reference";
1241 $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
1244 # use JavaScript Calendar or not
1245 $form->{jsscript} = $jscalendar;
1247 if ($form->{jsscript}) {
1249 # with JavaScript Calendar
1251 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate} tabindex="2" $readonly>
1252 <input type=button name=transdate id="trigger1" value=|
1253 . $locale->text('button') . qq|></td>
1258 Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1", "",
1262 # without JavaScript Calendar
1264 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate} tabindex="2" $readonly></td>|;
1270 <body onLoad="fokus()">
1272 <form method=post name="gl" action=$form->{script}>
1274 <input name=id type=hidden value=$form->{id}>
1276 <input type=hidden name=closedto value=$form->{closedto}>
1277 <input type=hidden name=locked value=$form->{locked}>
1278 <input type=hidden name=title value="$title">
1279 <input type=hidden name=taxchart value="$form->{taxchart}">
1280 <input type=hidden name=chart value="$form->{chart}">
1285 <th class=listtop>$form->{title}</th>
1287 <tr height="5"></tr>
1292 <th align=left>| . $locale->text('Reference') . qq|</th>
1293 <td><input name=reference size=20 value="$form->{reference}" tabindex="1" $readonly></td>
1297 <th align=right nowrap>| . $locale->text('Date') . qq|</th>
1306 <th align=right>| . $locale->text('Belegnummer') . qq|</th>
1307 <td><input name=id size=20 value="$form->{id}" $readonly></td>
1311 <th align=right width=50%>| . $locale->text('Buchungsdatum') . qq|</th>
1312 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly></td>
1323 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1324 <td width=1%>$description</td>
1328 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1329 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1336 <th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
1337 <td align=left><input name=employee size=11 value=$form->{employee} $readonly></td>
1345 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1346 <td width=1%>$description</td>
1350 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1351 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1361 <tr class=listheading>
1362 <th class=listheading style="width:15%">|
1363 . $locale->text('Account') . qq|</th>
1364 <th class=listheading style="width:10%">|
1365 . $locale->text('Debit') . qq|</th>
1366 <th class=listheading style="width:10%">|
1367 . $locale->text('Credit') . qq|</th>
1368 <th class=listheading style="width:10%">|
1369 . $locale->text('Tax') . qq|</th>
1370 <th class=listheading style="width:5%">|
1371 . $locale->text('Korrektur') . qq|</th>
1372 <th class=listheading style="width:10%">|
1373 . $locale->text('Taxkey') . qq|</th>
1374 <th class=listheading style="width:20%">|
1375 . $locale->text('Source') . qq|</th>
1376 <th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
1382 $lxdebug->leave_sub();
1387 $lxdebug->enter_sub();
1388 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1390 $decimalplaces = ($dec > 2) ? $dec : 2;
1391 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
1395 $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
1396 } qw(totaldebit totalcredit);
1399 <tr class=listtotal>
1401 <th align=right class=listtotal> $form->{totaldebit}</th>
1402 <th align=right class=listtotal> $form->{totalcredit}</th>
1410 <input type=hidden name=path value=$form->{path}>
1411 <input type=hidden name=login value=$form->{login}>
1412 <input type=hidden name=password value=$form->{password}>
1414 <input name=callback type=hidden value="$form->{callback}">
1419 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1420 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1424 print qq|<input class=submit type=submit name=action value="|
1425 . $locale->text('Storno') . qq|">|;
1427 # Löschen und ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1429 if (!$form->{locked} && $radieren) {
1431 <input class=submit type=submit name=action value="|
1432 . $locale->text('Post') . qq|" accesskey="b">
1433 <input class=submit type=submit name=action value="|
1434 . $locale->text('Delete') . qq|">|;
1437 # if ($transdate > $closedto) {
1439 # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
1442 if ($transdate > $closedto) {
1443 print qq|<input class=submit type=submit name=action value="|
1444 . $locale->text('Update') . qq|">
1445 <input class=submit type=submit name=action value="|
1446 . $locale->text('Post') . qq|">|;
1450 if ($form->{menubar}) {
1451 require "$form->{path}/menu.pl";
1461 $lxdebug->leave_sub();
1466 $lxdebug->enter_sub();
1473 <form method=post action=$form->{script}>
1476 map { $form->{$_} =~ s/\"/"/g } qw(reference description chart);
1478 delete $form->{header};
1480 foreach $key (keys %$form) {
1481 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1485 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1488 . $locale->text('Are you sure you want to delete Transaction')
1489 . qq| $form->{reference}</h4>
1491 <input name=action class=submit type=submit value="|
1492 . $locale->text('Yes') . qq|">
1495 $lxdebug->leave_sub();
1500 $lxdebug->enter_sub();
1502 $form->redirect($locale->text('Transaction deleted!'))
1503 if (GL->delete_transaction(\%myconfig, \%$form));
1504 $form->error($locale->text('Cannot delete transaction!'));
1505 $lxdebug->leave_sub();
1510 $lxdebug->enter_sub();
1512 # check if there is something in reference and date
1513 $form->isblank("reference", $locale->text('Reference missing!'));
1514 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1515 $form->isblank("description", $locale->text('Description missing!'));
1517 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1518 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1528 my $creditcount = 0;
1533 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1535 for my $i (1 .. $form->{rowcount}) {
1537 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1538 for (qw(debit credit tax)) {
1539 $form->{"${_}_$i"} =
1540 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1544 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1552 if (($debitcount >= 2) && ($creditcount == 2)) {
1553 $form->{"credit_$i"} = 0;
1554 $form->{"tax_$i"} = 0;
1558 if (($creditcount >= 2) && ($debitcount == 2)) {
1559 $form->{"debit_$i"} = 0;
1560 $form->{"tax_$i"} = 0;
1564 if (($creditcount == 1) && ($debitcount == 2)) {
1567 if (($creditcount == 2) && ($debitcount == 1)) {
1570 if ($debitcredit && $credittax) {
1571 $form->{"taxchart_$i"} = "0--0.00";
1573 if (!$debitcredit && $debittax) {
1574 $form->{"taxchart_$i"} = "0--0.00";
1577 ($form->{"debit_$i"} == 0)
1578 ? $form->{"credit_$i"}
1579 : $form->{"debit_$i"};
1581 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1582 $form->{"taxchart_$i"} = "0--";
1583 $form->{"tax_$i"} = 0;
1585 if (!$form->{"korrektur_$i"}) {
1586 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1593 if ($form->{taxincluded}) {
1594 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1596 $form->{"tax_$i"} = $amount * $rate;
1599 $form->{"tax_$i"} = 0;
1603 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1608 for $i (1 .. $count) {
1610 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1613 for $i ($count + 1 .. $form->{rowcount}) {
1614 for (@flds) { delete $form->{"${_}_$i"} }
1617 for $i (1 .. $form->{rowcount}) {
1618 $dr = $form->{"debit_$i"};
1619 $cr = $form->{"credit_$i"};
1620 $tax = $form->{"tax_$i"};
1624 'Cannot post transaction with a debit and credit entry for the same account!'
1627 if ($form->{taxincluded}) {
1633 $debit += $dr + $tax;
1636 $credit += $cr + $tax;
1641 $form->{taxincluded} = 0;
1644 # this is just for the wise guys
1645 $form->error($locale->text('Cannot post transaction for a closed period!'))
1646 if ($transdate <= $closedto);
1647 if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
1648 $form->error($locale->text('Out of balance transaction!'));
1650 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1652 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1653 $err[2] = $locale->text('Debit and credit out of balance!');
1654 $err[3] = $locale->text('Cannot post a transaction without a value!');
1656 $form->error($err[$errno]);
1658 undef($form->{callback});
1659 $form->redirect("Buchung gespeichert. Buchungsnummer = " . $form->{id});
1660 $lxdebug->leave_sub();
1665 $lxdebug->enter_sub();
1669 $lxdebug->leave_sub();
1674 $lxdebug->enter_sub();
1677 $form->{storno} = 1;
1679 $lxdebug->leave_sub();