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 qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
87 . ($_->{rate} * 100) . qq| %|
90 $form->{rowcount} = 2;
97 $form->all_departments(\%myconfig);
98 if (@{ $form->{all_departments} }) {
99 $form->{selectdepartment} = "<option>\n";
102 $form->{selectdepartment} .=
103 "<option>$_->{description}--$_->{id}\n"
104 } (@{ $form->{all_departments} });
108 $lxdebug->leave_sub();
113 $lxdebug->enter_sub();
115 GL->transaction(\%myconfig, \%$form);
119 qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
120 . ($_->{rate} * 100) . qq| %|
123 $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2);
126 $form->all_departments(\%myconfig);
127 if (@{ $form->{all_departments} }) {
128 $form->{selectdepartment} = "<option>\n";
131 $form->{selectdepartment} .=
132 "<option>$_->{description}--$_->{id}\n"
133 } (@{ $form->{all_departments} });
139 foreach $ref (@{ $form->{GL} }) {
141 if ($tax && ($ref->{accno} eq $taxaccno)) {
142 $form->{"tax_$j"} = abs($ref->{amount});
143 $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate};
144 if ($form->{taxincluded}) {
145 if ($ref->{amount} < 0) {
146 $form->{"debit_$j"} += $form->{"tax_$j"};
148 $form->{"credit_$j"} += $form->{"tax_$j"};
151 $form->{"project_id_$j"} = $ref->{project_id};
154 $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}";
155 for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
156 if ($ref->{amount} < 0) {
157 $form->{totaldebit} -= $ref->{amount};
158 $form->{"debit_$i"} = $ref->{amount} * -1;
160 $form->{totalcredit} += $ref->{amount};
161 $form->{"credit_$i"} = $ref->{amount};
163 $form->{"taxchart_$i"} = "0--0.00";
164 $form->{"project_id_$i"} = $ref->{project_id};
167 if ($ref->{taxaccno} && !$tax) {
168 $taxaccno = $ref->{taxaccno};
176 $form->{rowcount} = $i;
178 ($form->datetonum($form->{transdate}, \%myconfig) <=
179 $form->datetonum($form->{closedto}, \%myconfig));
181 $form->{title} = "Edit";
186 $lxdebug->leave_sub();
191 $lxdebug->enter_sub();
193 $form->{title} = $locale->text('Buchungsjournal');
195 $form->all_departments(\%myconfig);
198 if (@{ $form->{all_departments} }) {
199 $form->{selectdepartment} = "<option>\n";
202 $form->{selectdepartment} .=
203 "<option>$_->{description}--$_->{id}\n"
204 } (@{ $form->{all_departments} });
209 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
210 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
212 | if $form->{selectdepartment};
214 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
217 my %project_labels = ();
218 my @project_values = ("");
219 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
220 push(@project_values, $item->{"id"});
221 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
225 NTI($cgi->popup_menu('-name' => "project_id",
226 '-values' => \@project_values,
227 '-labels' => \%project_labels));
229 # use JavaScript Calendar or not
230 $form->{jsscript} = $jscalendar;
232 if ($form->{jsscript}) {
234 # with JavaScript Calendar
236 <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
237 <input type=button name=datefrom id="trigger1" value=|
238 . $locale->text('button') . qq|></td>
241 <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
242 <input type=button name=dateto id="trigger2" value=|
243 . $locale->text('button') . qq|></td>
248 Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1",
249 "dateto", "BL", "trigger2");
252 # without JavaScript Calendar
254 qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
256 qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
264 <form method=post action=$form->{script}>
266 <input type=hidden name=sort value=transdate>
270 <th class=listtop>$form->{title}</th>
277 <th align=right>| . $locale->text('Reference') . qq|</th>
278 <td><input name=reference size=20></td>
279 <th align=right>| . $locale->text('Source') . qq|</th>
280 <td><input name=source size=20></td>
284 <th align=right>| . $locale->text('Description') . qq|</th>
285 <td colspan=3><input name=description size=40></td>
288 <th align=right>| . $locale->text('Notes') . qq|</th>
289 <td colspan=3><input name=notes size=40></td>
292 <th align=right>| . $locale->text('Project Number') . qq|</th>
293 <td colspan=3>$projectnumber</td>
296 <th align=right>| . $locale->text('From') . qq|</th>
298 <th align=right>| . $locale->text('To (time)') . qq|</th>
302 <th align=right>| . $locale->text('Include in Report') . qq|</th>
307 <input name="category" class=radio type=radio value=X checked> |
308 . $locale->text('All') . qq|
309 <input name="category" class=radio type=radio value=A> |
310 . $locale->text('Asset') . qq|
311 <input name="category" class=radio type=radio value=L> |
312 . $locale->text('Liability') . qq|
313 <input name="category" class=radio type=radio value=I> |
314 . $locale->text('Revenue') . qq|
315 <input name="category" class=radio type=radio value=E> |
316 . $locale->text('Expense') . qq|
322 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
323 <td>| . $locale->text('ID') . qq|</td>
324 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
325 <td>| . $locale->text('Date') . qq|</td>
326 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
327 <td>| . $locale->text('Reference') . qq|</td>
328 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
329 <td>| . $locale->text('Description') . qq|</td>
330 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
331 <td>| . $locale->text('Notes') . qq|</td>
334 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
335 <td>| . $locale->text('Debit') . qq|</td>
336 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
337 <td>| . $locale->text('Credit') . qq|</td>
338 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
339 <td>| . $locale->text('Source') . qq|</td>
340 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
341 <td>| . $locale->text('Account') . qq|</td>
342 <td align=right><input name="l_gifi_accno" class=checkbox type=checkbox value=Y></td>
343 <td>| . $locale->text('GIFI') . qq|</td>
346 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
347 <td>| . $locale->text('Subtotal') . qq|</td>
348 <td align=right><input name="l_projectnumbers" class=checkbox type=checkbox value=Y></td>
349 <td>| . $locale->text('Project Number') . qq|</td>
359 <td><hr size=3 noshade></td>
365 <input type=hidden name=nextsub value=generate_report>
367 <input type=hidden name=path value=$form->{path}>
368 <input type=hidden name=login value=$form->{login}>
369 <input type=hidden name=password value=$form->{password}>
372 <input class=submit type=submit name=action value="|
373 . $locale->text('Continue') . qq|">
379 $lxdebug->leave_sub();
382 sub generate_report {
383 $lxdebug->enter_sub();
385 $form->{sort} = "transdate" unless $form->{sort};
387 GL->all_transactions(\%myconfig, \%$form);
390 "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
394 %acctype = ('A' => $locale->text('Asset'),
395 'C' => $locale->text('Contra'),
396 'L' => $locale->text('Liability'),
397 'Q' => $locale->text('Equity'),
398 'I' => $locale->text('Revenue'),
399 'E' => $locale->text('Expense'),);
401 $form->{title} = $locale->text('General Ledger');
403 $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
405 unless ($form->{category} eq 'X') {
406 $form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
408 if ($form->{accno}) {
409 $href .= "&accno=" . $form->escape($form->{accno});
410 $callback .= "&accno=" . $form->escape($form->{accno}, 1);
412 $locale->text('Account')
413 . " : $form->{accno} $form->{account_description}";
415 if ($form->{gifi_accno}) {
416 $href .= "&gifi_accno=" . $form->escape($form->{gifi_accno});
417 $callback .= "&gifi_accno=" . $form->escape($form->{gifi_accno}, 1);
418 $option .= "\n<br>" if $option;
420 $locale->text('GIFI')
421 . " : $form->{gifi_accno} $form->{gifi_account_description}";
423 if ($form->{source}) {
424 $href .= "&source=" . $form->escape($form->{source});
425 $callback .= "&source=" . $form->escape($form->{source}, 1);
426 $option .= "\n<br>" if $option;
427 $option .= $locale->text('Source') . " : $form->{source}";
429 if ($form->{reference}) {
430 $href .= "&reference=" . $form->escape($form->{reference});
431 $callback .= "&reference=" . $form->escape($form->{reference}, 1);
432 $option .= "\n<br>" if $option;
433 $option .= $locale->text('Reference') . " : $form->{reference}";
435 if ($form->{department}) {
436 $href .= "&department=" . $form->escape($form->{department});
437 $callback .= "&department=" . $form->escape($form->{department}, 1);
438 ($department) = split /--/, $form->{department};
439 $option .= "\n<br>" if $option;
440 $option .= $locale->text('Department') . " : $department";
443 if ($form->{description}) {
444 $href .= "&description=" . $form->escape($form->{description});
445 $callback .= "&description=" . $form->escape($form->{description}, 1);
446 $option .= "\n<br>" if $option;
447 $option .= $locale->text('Description') . " : $form->{description}";
449 if ($form->{notes}) {
450 $href .= "¬es=" . $form->escape($form->{notes});
451 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
452 $option .= "\n<br>" if $option;
453 $option .= $locale->text('Notes') . " : $form->{notes}";
455 if ($form->{project_id}) {
456 $href .= "&project_id=" . $form->escape($form->{project_id});
457 $callback .= "&project_id=" . $form->escape($form->{project_id});
460 if ($form->{datefrom}) {
461 $href .= "&datefrom=$form->{datefrom}";
462 $callback .= "&datefrom=$form->{datefrom}";
463 $option .= "\n<br>" if $option;
465 $locale->text('From') . " "
466 . $locale->date(\%myconfig, $form->{datefrom}, 1);
468 if ($form->{dateto}) {
469 $href .= "&dateto=$form->{dateto}";
470 $callback .= "&dateto=$form->{dateto}";
471 if ($form->{datefrom}) {
474 $option .= "\n<br>" if $option;
477 $locale->text('Bis') . " "
478 . $locale->date(\%myconfig, $form->{dateto}, 1);
481 @columns = $form->sort_columns( qw(
482 transdate id reference description
483 notes source debit debit_accno
484 credit credit_accno debit_tax debit_tax_accno
485 credit_tax credit_tax_accno accno gifi_accno
490 if ($form->{accno} || $form->{gifi_accno}) {
491 @columns = grep !/(accno|gifi_accno)/, @columns;
492 push @columns, "balance";
493 $form->{l_balance} = "Y";
497 $form->{l_credit_accno} = "Y";
498 $form->{l_debit_accno} = "Y";
499 $form->{l_credit_tax} = "Y";
500 $form->{l_debit_tax} = "Y";
501 $form->{l_credit_tax_accno} = "Y";
502 $form->{l_debit_tax_accno} = "Y";
503 $form->{l_accno} = "N";
504 foreach $item (@columns) {
505 if ($form->{"l_$item"} eq "Y") {
506 push @column_index, $item;
508 # add column to href and callback
509 $callback .= "&l_$item=Y";
510 $href .= "&l_$item=Y";
514 if ($form->{l_subtotal} eq 'Y') {
515 $callback .= "&l_subtotal=Y";
516 $href .= "&l_subtotal=Y";
519 $callback .= "&category=$form->{category}";
520 $href .= "&category=$form->{category}";
523 "<th><a class=listheading href=$href&sort=id>"
524 . $locale->text('ID')
526 $column_header{transdate} =
527 "<th><a class=listheading href=$href&sort=transdate>"
528 . $locale->text('Date')
530 $column_header{reference} =
531 "<th><a class=listheading href=$href&sort=reference>"
532 . $locale->text('Reference')
534 $column_header{source} =
535 "<th><a class=listheading href=$href&sort=source>"
536 . $locale->text('Source')
538 $column_header{description} =
539 "<th><a class=listheading href=$href&sort=description>"
540 . $locale->text('Description')
542 $column_header{notes} =
543 "<th class=listheading>" . $locale->text('Notes') . "</th>";
544 $column_header{debit} =
545 "<th class=listheading>" . $locale->text('Debit') . "</th>";
546 $column_header{debit_accno} =
547 "<th><a class=listheading href=$href&sort=accno>"
548 . $locale->text('Debit Account')
550 $column_header{credit} =
551 "<th class=listheading>" . $locale->text('Credit') . "</th>";
552 $column_header{credit_accno} =
553 "<th><a class=listheading href=$href&sort=accno>"
554 . $locale->text('Credit Account')
556 $column_header{debit_tax} =
557 "<th><a class=listheading href=$href&sort=accno>"
558 . $locale->text('Debit Tax')
560 $column_header{debit_tax_accno} =
561 "<th><a class=listheading href=$href&sort=accno>"
562 . $locale->text('Debit Tax Account')
564 $column_header{credit_tax} =
565 "<th><a class=listheading href=$href&sort=accno>"
566 . $locale->text('Credit Tax')
568 $column_header{credit_tax_accno} =
569 "<th><a class=listheading href=$href&sort=accno>"
570 . $locale->text('Credit Tax Account')
572 $column_header{gifi_accno} =
573 "<th><a class=listheading href=$href&sort=gifi_accno>"
574 . $locale->text('GIFI')
576 $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
577 $column_header{projectnumbers} =
578 "<th class=listheading>" . $locale->text('Project Numbers') . "</th>";
580 $form->{landscape} = 1;
589 <th class=listtop>$form->{title}</th>
599 <tr class=listheading>
602 map { print "$column_header{$_}\n" } @column_index;
611 # add sort to callback
612 $form->{callback} = "$callback&sort=$form->{sort}";
613 $callback = $form->escape($form->{callback});
615 # initial item for subtotals
616 if (@{ $form->{GL} }) {
617 $sameitem = $form->{GL}->[0]->{ $form->{sort} };
620 if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
622 map { $column_data{$_} = "<td> </td>" } @column_index;
623 $column_data{balance} =
625 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
633 map { print "$column_data{$_}\n" } @column_index;
639 $form->{balance} *= $ml;
640 foreach $ref (@{ $form->{GL} }) {
641 $form->{balance} *= $ml;
643 # if item ne sort print subtotal
644 if ($form->{l_subtotal} eq 'Y') {
645 if ($sameitem ne $ref->{ $form->{sort} }) {
650 #foreach $key (sort keys(%{ $ref->{amount} })) {
651 # $form->{balance} += $ref->{amount}{$key};
655 foreach $key (sort keys(%{ $ref->{debit} })) {
656 $subtotaldebit += $ref->{debit}{$key};
657 $totaldebit += $ref->{debit}{$key};
659 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
662 "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
664 $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key});
668 foreach $key (sort keys(%{ $ref->{credit} })) {
669 $subtotalcredit += $ref->{credit}{$key};
670 $totalcredit += $ref->{credit}{$key};
672 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
675 . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
677 $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key});
681 foreach $key (sort keys(%{ $ref->{debit_tax} })) {
682 $subtotaldebittax += $ref->{debit_tax}{$key};
683 $totaldebittax += $ref->{debit_tax}{$key};
686 $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
689 . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
691 $form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key});
695 foreach $key (sort keys(%{ $ref->{credit_tax} })) {
696 $subtotalcredittax += $ref->{credit_tax}{$key};
697 $totalcredittax += $ref->{credit_tax}{$key};
700 $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
703 . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
705 $form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key});
711 foreach $key (sort keys(%{ $ref->{debit_accno} })) {
714 "<a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
717 "<br><a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
720 # if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
721 # $ref->{debit_tax_accno}{$key} = $taxaccno;
723 $taxaccno = $ref->{debit_tax_accno}{$key};
724 $debittaxkey = $ref->{debit_taxkey}{$key};
730 foreach $key (sort keys(%{ $ref->{credit_accno} })) {
733 "<a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
736 "<br><a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
739 # if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
740 # $ref->{credit_tax_accno}{$key} = $taxaccno;
742 $taxaccno = $ref->{credit_tax_accno}{$key};
743 $credittaxkey = $ref->{credit_taxkey}{$key};
747 foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
750 "<a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
753 "<br><a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
757 $credittaxaccno = "";
758 foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
761 "<a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
764 "<br><a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
769 foreach $key (sort keys(%{ $ref->{transdate} })) {
771 $transdate = "$ref->{transdate}{$key}";
773 $transdate .= "<br>$ref->{transdate}{$key}";
777 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
778 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
780 $column_data{id} = "<td align=right> $ref->{id} </td>";
781 $column_data{transdate} = "<td align=center>$transdate</td>";
782 $column_data{reference} =
783 "<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>";
784 $column_data{description} = "<td align=center>$ref->{description} </td>";
785 $column_data{source} = "<td align=center>$ref->{source} </td>";
786 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
787 $column_data{debit} = "<td align=right>$debit</td>";
788 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
789 $column_data{credit} = "<td align=right>$credit</td>";
790 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
791 $column_data{debit_tax} =
792 ($ref->{debit_tax_accno} ne "")
793 ? "<td align=right>$debittax</td>"
795 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
796 $column_data{gifi_accno} =
797 "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
798 $column_data{credit_tax} =
799 ($ref->{credit_tax_accno} ne "")
800 ? "<td align=right>$credittax</td>"
802 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
803 $column_data{gifi_accno} =
804 "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
805 $column_data{balance} =
807 . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . "</td>";
808 $column_data{projectnumbers} =
809 "<td>" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . "</td>";
814 <tr class=listrow$i>";
815 map { print "$column_data{$_}\n" } @column_index;
820 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
822 map { $column_data{$_} = "<td> </td>" } @column_index;
824 my $balanced_ledger = $totaldebit
828 # = 0 for balanced ledger
830 $column_data{debit} =
831 "<th align=right class=listtotal>"
832 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
833 $column_data{credit} =
834 "<th align=right class=listtotal>"
835 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
836 $column_data{debit_tax} =
837 "<th align=right class=listtotal>"
838 . $form->format_amount(\%myconfig, $totaldebittax, 2, " ") . "</th>";
839 $column_data{credit_tax} =
840 "<th align=right class=listtotal>"
841 . $form->format_amount(\%myconfig, $totalcredittax, 2, " ") . "</th>";
842 $column_data{balance} =
843 "<th align=right class=listtotal>"
844 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
850 map { print "$column_data{$_}\n" } @column_index;
857 if ( abs($balanced_ledger) > 0.001 ) {
859 print qq|<td colspan="4" style="background-color:#FFA0A0" >|
860 . $locale->text('Unbalanced Ledger')
862 . $form->format_amount(\%myconfig, $balanced_ledger, 3, " ")
864 } elsif ( abs($balanced_ledger) <= 0.001 ) {
866 print qq|<td colspan="3">|
867 . $locale->text('Balanced Ledger')
880 <td><hr size=3 noshade></td>
886 <form method=post action=$form->{script}>
888 <input name=callback type=hidden value="$form->{callback}">
890 <input type=hidden name=path value=$form->{path}>
891 <input type=hidden name=login value=$form->{login}>
892 <input type=hidden name=password value=$form->{password}>
894 <input class=submit type=submit name=action value="|
895 . $locale->text('GL Transaction') . qq|">
896 <input class=submit type=submit name=action value="|
897 . $locale->text('AR Transaction') . qq|">
898 <input class=submit type=submit name=action value="|
899 . $locale->text('AP Transaction') . qq|">
900 <input class=submit type=submit name=action value="|
901 . $locale->text('Sales Invoice') . qq|">
902 <input class=submit type=submit name=action value="|
903 . $locale->text('Vendor Invoice') . qq|">
910 $lxdebug->leave_sub();
915 $lxdebug->enter_sub();
918 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
920 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
922 map { $column_data{$_} = "<td> </td>" }
923 qw(transdate id reference source description accno);
924 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
925 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
927 print "<tr class=listsubtotal>";
928 map { print "$column_data{$_}\n" } @column_index;
934 $sameitem = $ref->{ $form->{sort} };
935 $lxdebug->leave_sub();
940 $lxdebug->enter_sub();
942 $form->{oldtransdate} = $form->{transdate};
954 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
956 for my $i (1 .. $form->{rowcount}) {
958 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
959 for (qw(debit credit tax)) {
961 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
965 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
972 if (($debitcount >= 2) && ($creditcount == 2)) {
973 $form->{"credit_$i"} = 0;
974 $form->{"tax_$i"} = 0;
978 if (($creditcount >= 2) && ($debitcount == 2)) {
979 $form->{"debit_$i"} = 0;
980 $form->{"tax_$i"} = 0;
984 if (($creditcount == 1) && ($debitcount == 2)) {
987 if (($creditcount == 2) && ($debitcount == 1)) {
990 if ($debitcredit && $credittax) {
991 $form->{"taxchart_$i"} = "0--0.00";
993 if (!$debitcredit && $debittax) {
994 $form->{"taxchart_$i"} = "0--0.00";
997 ($form->{"debit_$i"} == 0)
998 ? $form->{"credit_$i"}
999 : $form->{"debit_$i"};
1001 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1002 $form->{"taxchart_$i"} = "0--0.00";
1003 $form->{"tax_$i"} = 0;
1005 if (!$form->{"korrektur_$i"}) {
1006 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1013 if ($form->{taxincluded}) {
1014 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1016 $form->{"tax_$i"} = $amount * $rate;
1019 $form->{"tax_$i"} = 0;
1023 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1028 for $i (1 .. $count) {
1030 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1033 for $i ($count + 1 .. $form->{rowcount}) {
1034 for (@flds) { delete $form->{"${_}_$i"} }
1037 $form->{rowcount} = $count + 1;
1040 $lxdebug->leave_sub();
1046 $lxdebug->enter_sub();
1048 &form_header($init);
1050 # for $i (1 .. $form->{rowcount}) {
1051 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1052 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1056 &display_rows($init);
1058 $lxdebug->leave_sub();
1064 $lxdebug->enter_sub();
1066 $form->{totaldebit} = 0;
1067 $form->{totalcredit} = 0;
1069 my @old_project_ids = ();
1070 map({ push(@old_project_ids, $form->{"project_id_$_"})
1071 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
1073 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1075 "old_id" => \@old_project_ids },
1076 "charts" => { "key" => "ALL_CHARTS",
1077 "transdate" => $form->{transdate} },
1078 "taxcharts" => "ALL_TAXCHARTS");
1080 my %project_labels = ();
1081 my @project_values = ("");
1082 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1083 push(@project_values, $item->{"id"});
1084 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
1087 my %chart_labels = ();
1088 my @chart_values = ();
1091 foreach my $item (@{ $form->{ALL_CHARTS} }) {
1092 my $key = Q($item->{accno}) . "--" . Q($item->{tax_id});
1093 $taxchart_init = $item->{taxkey_id} unless (@chart_values);
1094 push(@chart_values, $key);
1095 $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description});
1096 $charts{$item->{accno}} = $item;
1099 my %taxchart_labels = ();
1100 my @taxchart_values = ();
1102 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
1103 my $key = Q($item->{id}) . "--" . Q($item->{rate});
1104 $taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
1105 push(@taxchart_values, $key);
1106 $taxchart_labels{$key} = H($item->{taxdescription}) . " " .
1107 H($item->{rate} * 100) . ' %';
1108 $taxcharts{$item->{id}} = $item;
1111 for $i (1 .. $form->{rowcount}) {
1114 <td><input name="source_$i" value="$form->{"source_$i"}" size="16" tabindex=|
1115 . ($i + 11 + (($i - 1) * 8)) . qq|></td>|;
1117 <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16" tabindex=|
1118 . ($i + 12 + (($i - 1) * 8)) . qq|></td>|;
1120 my $selected_accno_full;
1121 my ($accno_row) = split(/--/, $form->{"accno_$i"});
1122 my $item = $charts{$accno_row};
1123 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
1125 my $selected_taxchart = $form->{"taxchart_$i"};
1126 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
1127 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_accno_$i"});
1129 if ($previous_accno &&
1130 ($previous_accno eq $selected_accno) &&
1131 ($previous_tax_id ne $selected_tax_id)) {
1132 $lxdebug->message(0, "yeah");
1133 my $item = $taxcharts{$selected_tax_id};
1134 $selected_taxchart = "$item->{id}--$item->{rate}";
1138 $selected_accno = '';
1139 $selected_taxchart = $taxchart_init;
1143 $cgi->popup_menu('-name' => "accno_$i",
1144 '-id' => "accno_$i",
1145 '-onChange' => "setTaxkey(this, $i)",
1146 '-style' => 'width:200px',
1147 '-tabindex' => ($i + 5 + (($i - 1) * 8)),
1148 '-values' => \@chart_values,
1149 '-labels' => \%chart_labels,
1150 '-default' => $selected_accno_full)
1151 . $cgi->hidden('-name' => "previous_accno_$i",
1152 '-default' => $selected_accno_full)
1155 $cgi->popup_menu('-name' => "taxchart_$i",
1156 '-id' => "taxchart_$i",
1157 '-style' => 'width:200px',
1158 '-tabindex' => ($i + 10 + (($i - 1) * 8)),
1159 '-values' => \@taxchart_values,
1160 '-labels' => \%taxchart_labels,
1161 '-default' => $selected_taxchart)
1166 qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1167 . ($i + 9 + (($i - 1) * 8))
1169 if ($form->{transfer}) {
1170 $fx_transaction = qq|
1171 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1176 if ($form->{"debit_$i"} != 0) {
1177 $form->{totaldebit} += $form->{"debit_$i"};
1178 if (!$form->{taxincluded}) {
1179 $form->{totaldebit} += $form->{"tax_$i"};
1182 $form->{totalcredit} += $form->{"credit_$i"};
1183 if (!$form->{taxincluded}) {
1184 $form->{totalcredit} += $form->{"tax_$i"};
1188 for (qw(debit credit tax)) {
1189 $form->{"${_}_$i"} =
1190 ($form->{"${_}_$i"})
1191 ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
1195 if ($i < $form->{rowcount}) {
1196 if ($form->{transfer}) {
1197 $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
1198 $x = ($checked) ? "x" : "";
1199 $fx_transaction = qq|
1200 <td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
1203 $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
1205 qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked tabindex=|
1206 . ($i + 9 + (($i - 1) * 8))
1208 $form->hide_form("accno_$i");
1212 qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
1213 . ($i + 9 + (($i - 1) * 8))
1215 if ($form->{transfer}) {
1216 $fx_transaction = qq|
1217 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1222 my $debitreadonly = "";
1223 my $creditreadonly = "";
1224 if ($i == $form->{rowcount}) {
1226 $debitreadonly = "readonly";
1227 } elsif ($creditlock) {
1228 $creditreadonly = "readonly";
1233 NTI($cgi->popup_menu('-name' => "project_id_$i",
1234 '-values' => \@project_values,
1235 '-labels' => \%project_labels,
1236 '-default' => $form->{"project_id_$i"} ));
1238 print qq|<tr valign=top>
1241 <td><input name="debit_$i" size=8 value="$form->{"debit_$i"}" accesskey=$i tabindex=|
1242 . ($i + 6 + (($i - 1) * 8)) . qq| $debitreadonly></td>
1243 <td><input name="credit_$i" size=8 value="$form->{"credit_$i"}" tabindex=|
1244 . ($i + 7 + (($i - 1) * 8)) . qq| $creditreadonly></td>
1245 <td><input name="tax_$i" size=6 value="$form->{"tax_$i"}" tabindex=|
1246 . ($i + 8 + (($i - 1) * 8)) . qq|></td>
1251 <td>$projectnumber</td>
1257 $form->hide_form(qw(rowcount selectaccno));
1259 $lxdebug->leave_sub();
1265 $lxdebug->enter_sub();
1266 $title = $form->{title};
1267 $form->{title} = $locale->text("$title General Ledger Transaction");
1268 $readonly = ($form->{id}) ? "readonly" : "";
1270 # $locale->text('Add General Ledger Transaction')
1271 # $locale->text('Edit General Ledger Transaction')
1273 map { $form->{$_} =~ s/\"/"/g }
1274 qw(reference description chart taxchart);
1275 $form->{javascript} = qq|<script type="text/javascript">
1277 function setTaxkey(accno, row) {
1278 var taxkey = accno.options[accno.selectedIndex].value;
1279 var reg = /--([0-9]*)/;
1280 var found = reg.exec(taxkey);
1281 var index = found[1];
1282 index = parseInt(index);
1283 var tax = 'taxchart_' + row;
1284 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
1285 var reg2 = new RegExp("^"+ index, "");
1286 if (reg2.exec(document.getElementById(tax).options[i].value)) {
1287 document.getElementById(tax).options[i].selected = true;
1295 $form->{selectdepartment} =~ s/ selected//;
1296 $form->{selectdepartment} =~
1297 s/option>\Q$form->{department}\E/option selected>$form->{department}/;
1299 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
1301 qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
1304 qq|<input name=description size=50 value="$form->{description}" tabindex="3" $readonly>|;
1307 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
1310 $taxincluded = "checked";
1315 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1316 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1317 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
1319 | if $form->{selectdepartment};
1321 $form->{fokus} = "gl.reference";
1323 $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
1326 # use JavaScript Calendar or not
1327 $form->{jsscript} = $jscalendar;
1329 if ($form->{jsscript}) {
1331 # with JavaScript Calendar
1333 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" tabindex="2" $readonly>
1334 <input type=button name=transdate id="trigger1" value=|
1335 . $locale->text('button') . qq|></td>
1340 Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1");
1343 # without JavaScript Calendar
1345 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" tabindex="2" $readonly></td>|;
1351 <body onLoad="fokus()">
1353 <form method=post name="gl" action=$form->{script}>
1355 <input name=id type=hidden value=$form->{id}>
1357 <input type=hidden name=closedto value=$form->{closedto}>
1358 <input type=hidden name=locked value=$form->{locked}>
1359 <input type=hidden name=title value="$title">
1364 <th class=listtop>$form->{title}</th>
1366 <tr height="5"></tr>
1371 <th align=left>| . $locale->text('Reference') . qq|</th>
1372 <td><input name=reference size=20 value="$form->{reference}" tabindex="1" $readonly></td>
1376 <th align=right nowrap>| . $locale->text('Date') . qq|</th>
1385 <th align=right>| . $locale->text('Belegnummer') . qq|</th>
1386 <td><input name=id size=20 value="$form->{id}" $readonly></td>
1390 <th align=right width=50%>| . $locale->text('Buchungsdatum') . qq|</th>
1391 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly></td>
1402 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1403 <td width=1%>$description</td>
1407 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1408 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1415 <th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
1416 <td align=left><input name=employee size=11 value=$form->{employee} $readonly></td>
1424 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1425 <td width=1%>$description</td>
1429 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1430 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1440 <tr class=listheading>
1441 <th class=listheading style="width:15%">|
1442 . $locale->text('Account') . qq|</th>
1443 <th class=listheading style="width:10%">|
1444 . $locale->text('Debit') . qq|</th>
1445 <th class=listheading style="width:10%">|
1446 . $locale->text('Credit') . qq|</th>
1447 <th class=listheading style="width:10%">|
1448 . $locale->text('Tax') . qq|</th>
1449 <th class=listheading style="width:5%">|
1450 . $locale->text('Korrektur') . qq|</th>
1451 <th class=listheading style="width:10%">|
1452 . $locale->text('Taxkey') . qq|</th>
1453 <th class=listheading style="width:20%">|
1454 . $locale->text('Source') . qq|</th>
1455 <th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
1456 <th class=listheading style="width:20%">|
1457 . $locale->text('Project Number') . qq|</th>
1462 $lxdebug->leave_sub();
1467 $lxdebug->enter_sub();
1468 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1470 $decimalplaces = ($dec > 2) ? $dec : 2;
1471 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
1475 $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
1476 } qw(totaldebit totalcredit);
1479 <tr class=listtotal>
1481 <th align=right class=listtotal> $form->{totaldebit}</th>
1482 <th align=right class=listtotal> $form->{totalcredit}</th>
1490 <input type=hidden name=path value=$form->{path}>
1491 <input type=hidden name=login value=$form->{login}>
1492 <input type=hidden name=password value=$form->{password}>
1494 <input name=callback type=hidden value="$form->{callback}">
1499 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1500 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1504 print qq|<input class=submit type=submit name=action value="|
1505 . $locale->text('Storno') . qq|">|;
1507 # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1509 if (!$form->{locked} && $radieren) {
1511 <input class=submit type=submit name=action value="|
1512 . $locale->text('Post') . qq|" accesskey="b">
1513 <input class=submit type=submit name=action value="|
1514 . $locale->text('Delete') . qq|">|;
1517 # if ($transdate > $closedto) {
1519 # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
1522 if ($transdate > $closedto) {
1523 print qq|<input class=submit type=submit name=action value="|
1524 . $locale->text('Update') . qq|">
1525 <input class=submit type=submit name=action value="|
1526 . $locale->text('Post') . qq|">|;
1536 $lxdebug->leave_sub();
1541 $lxdebug->enter_sub();
1548 <form method=post action=$form->{script}>
1551 map { $form->{$_} =~ s/\"/"/g } qw(reference description);
1553 delete $form->{header};
1555 foreach $key (keys %$form) {
1556 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1560 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1563 . $locale->text('Are you sure you want to delete Transaction')
1564 . qq| $form->{reference}</h4>
1566 <input name=action class=submit type=submit value="|
1567 . $locale->text('Yes') . qq|">
1570 $lxdebug->leave_sub();
1575 $lxdebug->enter_sub();
1576 if (GL->delete_transaction(\%myconfig, \%$form)){
1577 # saving the history
1578 if(!exists $form->{addition} && $form->{id} ne "") {
1579 $form->{addition} = "DELETED";
1580 $form->save_history($form->dbconnect(\%myconfig));
1582 # /saving the history
1583 $form->redirect($locale->text('Transaction deleted!'))
1585 $form->error($locale->text('Cannot delete transaction!'));
1586 $lxdebug->leave_sub();
1591 $lxdebug->enter_sub();
1593 # check if there is something in reference and date
1594 $form->isblank("reference", $locale->text('Reference missing!'));
1595 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1596 $form->isblank("description", $locale->text('Description missing!'));
1598 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1599 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1606 my $creditcount = 0;
1611 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1612 if ($form->{storno}) {
1613 for my $i (1 .. $form->{rowcount}) {
1614 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1615 if ($form->{"debit_$i"} ne "") {
1616 $form->{"credit_$i"} = $form->{"debit_$i"};
1617 $form->{"debit_$i"} = "";
1618 } elsif ($form->{"credit_$i"} ne "") {
1619 $form->{"debit_$i"} = $form->{"credit_$i"};
1620 $form->{"credit_$i"} = "";
1626 for my $i (1 .. $form->{rowcount}) {
1628 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1629 for (qw(debit credit tax)) {
1630 $form->{"${_}_$i"} =
1631 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1635 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1643 if (($debitcount >= 2) && ($creditcount == 2)) {
1644 $form->{"credit_$i"} = 0;
1645 $form->{"tax_$i"} = 0;
1649 if (($creditcount >= 2) && ($debitcount == 2)) {
1650 $form->{"debit_$i"} = 0;
1651 $form->{"tax_$i"} = 0;
1655 if (($creditcount == 1) && ($debitcount == 2)) {
1658 if (($creditcount == 2) && ($debitcount == 1)) {
1661 if ($debitcredit && $credittax) {
1662 $form->{"taxchart_$i"} = "0--0.00";
1664 if (!$debitcredit && $debittax) {
1665 $form->{"taxchart_$i"} = "0--0.00";
1668 ($form->{"debit_$i"} == 0)
1669 ? $form->{"credit_$i"}
1670 : $form->{"debit_$i"};
1672 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1673 $form->{"taxchart_$i"} = "0--0.00";
1674 $form->{"tax_$i"} = 0;
1676 if (!$form->{"korrektur_$i"}) {
1677 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1684 if ($form->{taxincluded}) {
1685 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1687 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1689 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1692 $form->{"tax_$i"} = $amount * $rate;
1695 $form->{"tax_$i"} = 0;
1697 } elsif ($form->{taxincluded}) {
1699 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1701 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1705 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1710 for $i (1 .. $count) {
1712 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1715 for $i ($count + 1 .. $form->{rowcount}) {
1716 for (@flds) { delete $form->{"${_}_$i"} }
1719 for $i (1 .. $form->{rowcount}) {
1720 $dr = $form->{"debit_$i"};
1721 $cr = $form->{"credit_$i"};
1722 $tax = $form->{"tax_$i"};
1726 'Cannot post transaction with a debit and credit entry for the same account!'
1729 if ($form->{taxincluded}) {
1731 $debit += $dr + $tax;
1734 $credit += $cr + $tax;
1739 $debit += $dr + $tax;
1742 $credit += $cr + $tax;
1747 $form->{taxincluded} = 0;
1750 # this is just for the wise guys
1751 $form->error($locale->text('Cannot post transaction for a closed period!'))
1752 if ($transdate <= $closedto);
1753 if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
1754 $form->error($locale->text('Out of balance transaction!'));
1757 if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) {
1758 $form->error($locale->text('Empty transaction!'));
1761 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1763 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1764 $err[2] = $locale->text('Debit and credit out of balance!');
1765 $err[3] = $locale->text('Cannot post a transaction without a value!');
1767 $form->error($err[$errno]);
1769 undef($form->{callback});
1770 # saving the history
1771 if(!exists $form->{addition} && $form->{id} ne "") {
1772 $form->{addition} = "SAVED";
1773 $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
1774 $form->save_history($form->dbconnect(\%myconfig));
1776 # /saving the history
1777 $form->redirect("Buchung gespeichert. Buchungsnummer = " . $form->{id});
1778 $lxdebug->leave_sub();
1783 $lxdebug->enter_sub();
1787 $lxdebug->leave_sub();
1792 $lxdebug->enter_sub();
1795 $form->{storno} = 1;
1796 # saving the history
1797 if(!exists $form->{addition} && $form->{id} ne "") {
1798 $form->{addition} = "STORNO";
1799 $form->save_history($form->dbconnect(\%myconfig));
1801 # /saving the history
1803 $lxdebug->leave_sub();