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 #======================================================================
38 require "bin/mozilla/arap.pl";
39 require "bin/mozilla/common.pl";
45 # this is for our long dates
46 # $locale->text('January')
47 # $locale->text('February')
48 # $locale->text('March')
49 # $locale->text('April')
50 # $locale->text('May ')
51 # $locale->text('June')
52 # $locale->text('July')
53 # $locale->text('August')
54 # $locale->text('September')
55 # $locale->text('October')
56 # $locale->text('November')
57 # $locale->text('December')
59 # this is for our short month
60 # $locale->text('Jan')
61 # $locale->text('Feb')
62 # $locale->text('Mar')
63 # $locale->text('Apr')
64 # $locale->text('May')
65 # $locale->text('Jun')
66 # $locale->text('Jul')
67 # $locale->text('Aug')
68 # $locale->text('Sep')
69 # $locale->text('Oct')
70 # $locale->text('Nov')
71 # $locale->text('Dec')
74 $lxdebug->enter_sub();
76 $form->{title} = "Add";
79 "$form->{script}?action=add&login=$form->{login}&password=$form->{password}"
80 unless $form->{callback};
82 # we use this only to set a default date
83 GL->transaction(\%myconfig, \%$form);
87 qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
88 . ($_->{rate} * 100) . qq| %|
91 $form->{rowcount} = 2;
98 $form->all_departments(\%myconfig);
99 if (@{ $form->{all_departments} }) {
100 $form->{selectdepartment} = "<option>\n";
103 $form->{selectdepartment} .=
104 "<option>$_->{description}--$_->{id}\n"
105 } (@{ $form->{all_departments} });
108 $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
111 $lxdebug->leave_sub();
115 sub prepare_transaction {
116 $lxdebug->enter_sub();
118 GL->transaction(\%myconfig, \%$form);
122 qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
123 . ($_->{rate} * 100) . qq| %|
126 $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2);
129 $form->all_departments(\%myconfig);
130 if (@{ $form->{all_departments} }) {
131 $form->{selectdepartment} = "<option>\n";
134 $form->{selectdepartment} .=
135 "<option>$_->{description}--$_->{id}\n"
136 } (@{ $form->{all_departments} });
142 foreach $ref (@{ $form->{GL} }) {
144 if ($tax && ($ref->{accno} eq $taxaccno)) {
145 $form->{"tax_$j"} = abs($ref->{amount});
146 $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate};
147 if ($form->{taxincluded}) {
148 if ($ref->{amount} < 0) {
149 $form->{"debit_$j"} += $form->{"tax_$j"};
151 $form->{"credit_$j"} += $form->{"tax_$j"};
154 $form->{"project_id_$j"} = $ref->{project_id};
157 $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}";
158 for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
159 if ($ref->{amount} < 0) {
160 $form->{totaldebit} -= $ref->{amount};
161 $form->{"debit_$i"} = $ref->{amount} * -1;
163 $form->{totalcredit} += $ref->{amount};
164 $form->{"credit_$i"} = $ref->{amount};
166 $form->{"taxchart_$i"} = "0--0.00";
167 $form->{"project_id_$i"} = $ref->{project_id};
170 if ($ref->{taxaccno} && !$tax) {
171 $taxaccno = $ref->{taxaccno};
179 $form->{rowcount} = $i;
181 ($form->datetonum($form->{transdate}, \%myconfig) <=
182 $form->datetonum($form->{closedto}, \%myconfig));
184 $lxdebug->leave_sub();
188 $lxdebug->enter_sub();
190 prepare_transaction();
192 $form->{title} = "Edit";
194 $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
200 $lxdebug->leave_sub();
205 $lxdebug->enter_sub();
207 $form->{title} = $locale->text('Buchungsjournal');
209 $form->all_departments(\%myconfig);
212 if (@{ $form->{all_departments} }) {
213 $form->{selectdepartment} = "<option>\n";
216 $form->{selectdepartment} .=
217 "<option>$_->{description}--$_->{id}\n"
218 } (@{ $form->{all_departments} });
223 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
224 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
226 | if $form->{selectdepartment};
228 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
231 my %project_labels = ();
232 my @project_values = ("");
233 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
234 push(@project_values, $item->{"id"});
235 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
239 NTI($cgi->popup_menu('-name' => "project_id",
240 '-values' => \@project_values,
241 '-labels' => \%project_labels));
243 # use JavaScript Calendar or not
244 $form->{jsscript} = 1;
246 if ($form->{jsscript}) {
248 # with JavaScript Calendar
250 <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
251 <input type=button name=datefrom id="trigger1" value=|
252 . $locale->text('button') . qq|></td>
255 <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
256 <input type=button name=dateto id="trigger2" value=|
257 . $locale->text('button') . qq|></td>
262 Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1",
263 "dateto", "BL", "trigger2");
266 # without JavaScript Calendar
268 qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
270 qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
272 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
274 $onload = qq|focus()|;
275 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
276 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
278 <body onLoad="$onload">
280 <form method=post action=$form->{script}>
282 <input type=hidden name=sort value=transdate>
286 <th class=listtop>$form->{title}</th>
293 <th align=right>| . $locale->text('Reference') . qq|</th>
294 <td><input name=reference size=20></td>
295 <th align=right>| . $locale->text('Source') . qq|</th>
296 <td><input name=source size=20></td>
300 <th align=right>| . $locale->text('Description') . qq|</th>
301 <td colspan=3><input name=description size=40></td>
304 <th align=right>| . $locale->text('Notes') . qq|</th>
305 <td colspan=3><input name=notes size=40></td>
308 <th align=right>| . $locale->text('Project Number') . qq|</th>
309 <td colspan=3>$projectnumber</td>
312 <th align=right>| . $locale->text('From') . qq|</th>
314 <th align=right>| . $locale->text('To (time)') . qq|</th>
318 <th align=right>| . $locale->text('Include in Report') . qq|</th>
323 <input name="category" class=radio type=radio value=X checked> |
324 . $locale->text('All') . qq|
325 <input name="category" class=radio type=radio value=A> |
326 . $locale->text('Asset') . qq|
327 <input name="category" class=radio type=radio value=L> |
328 . $locale->text('Liability') . qq|
329 <input name="category" class=radio type=radio value=I> |
330 . $locale->text('Revenue') . qq|
331 <input name="category" class=radio type=radio value=E> |
332 . $locale->text('Expense') . qq|
338 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
339 <td>| . $locale->text('ID') . qq|</td>
340 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
341 <td>| . $locale->text('Date') . qq|</td>
342 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
343 <td>| . $locale->text('Reference') . qq|</td>
344 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
345 <td>| . $locale->text('Description') . qq|</td>
346 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
347 <td>| . $locale->text('Notes') . qq|</td>
350 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
351 <td>| . $locale->text('Debit') . qq|</td>
352 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
353 <td>| . $locale->text('Credit') . qq|</td>
354 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
355 <td>| . $locale->text('Source') . qq|</td>
356 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
357 <td>| . $locale->text('Account') . qq|</td>
360 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
361 <td>| . $locale->text('Subtotal') . qq|</td>
362 <td align=right><input name="l_projectnumbers" class=checkbox type=checkbox value=Y></td>
363 <td>| . $locale->text('Project Number') . qq|</td>
373 <td><hr size=3 noshade></td>
379 <input type=hidden name=nextsub value=generate_report>
381 <input type=hidden name=login value=$form->{login}>
382 <input type=hidden name=password value=$form->{password}>
385 <input class=submit type=submit name=action value="|
386 . $locale->text('Continue') . qq|">
392 $lxdebug->leave_sub();
395 sub generate_report {
396 $lxdebug->enter_sub();
398 $form->{sort} = "transdate" unless $form->{sort};
400 GL->all_transactions(\%myconfig, \%$form);
403 "$form->{script}?action=generate_report&login=$form->{login}&password=$form->{password}";
407 %acctype = ('A' => $locale->text('Asset'),
408 'C' => $locale->text('Contra'),
409 'L' => $locale->text('Liability'),
410 'Q' => $locale->text('Equity'),
411 'I' => $locale->text('Revenue'),
412 'E' => $locale->text('Expense'),);
414 $form->{title} = $locale->text('General Ledger');
416 $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
418 unless ($form->{category} eq 'X') {
419 $form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
421 if ($form->{accno}) {
422 $href .= "&accno=" . $form->escape($form->{accno});
423 $callback .= "&accno=" . $form->escape($form->{accno}, 1);
425 $locale->text('Account')
426 . " : $form->{accno} $form->{account_description}";
428 if ($form->{source}) {
429 $href .= "&source=" . $form->escape($form->{source});
430 $callback .= "&source=" . $form->escape($form->{source}, 1);
431 $option .= "\n<br>" if $option;
432 $option .= $locale->text('Source') . " : $form->{source}";
434 if ($form->{reference}) {
435 $href .= "&reference=" . $form->escape($form->{reference});
436 $callback .= "&reference=" . $form->escape($form->{reference}, 1);
437 $option .= "\n<br>" if $option;
438 $option .= $locale->text('Reference') . " : $form->{reference}";
440 if ($form->{department}) {
441 $href .= "&department=" . $form->escape($form->{department});
442 $callback .= "&department=" . $form->escape($form->{department}, 1);
443 ($department) = split /--/, $form->{department};
444 $option .= "\n<br>" if $option;
445 $option .= $locale->text('Department') . " : $department";
448 if ($form->{description}) {
449 $href .= "&description=" . $form->escape($form->{description});
450 $callback .= "&description=" . $form->escape($form->{description}, 1);
451 $option .= "\n<br>" if $option;
452 $option .= $locale->text('Description') . " : $form->{description}";
454 if ($form->{notes}) {
455 $href .= "¬es=" . $form->escape($form->{notes});
456 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
457 $option .= "\n<br>" if $option;
458 $option .= $locale->text('Notes') . " : $form->{notes}";
460 if ($form->{project_id}) {
461 $href .= "&project_id=" . $form->escape($form->{project_id});
462 $callback .= "&project_id=" . $form->escape($form->{project_id});
465 if ($form->{datefrom}) {
466 $href .= "&datefrom=$form->{datefrom}";
467 $callback .= "&datefrom=$form->{datefrom}";
468 $option .= "\n<br>" if $option;
470 $locale->text('From') . " "
471 . $locale->date(\%myconfig, $form->{datefrom}, 1);
473 if ($form->{dateto}) {
474 $href .= "&dateto=$form->{dateto}";
475 $callback .= "&dateto=$form->{dateto}";
476 if ($form->{datefrom}) {
479 $option .= "\n<br>" if $option;
482 $locale->text('Bis') . " "
483 . $locale->date(\%myconfig, $form->{dateto}, 1);
486 @columns = $form->sort_columns( qw(
487 transdate id reference description
488 notes source debit debit_accno
489 credit credit_accno debit_tax debit_tax_accno
490 credit_tax credit_tax_accno accno
495 if ($form->{accno}) {
496 @columns = grep !/accno/, @columns;
497 push @columns, "balance";
498 $form->{l_balance} = "Y";
502 $form->{l_credit_accno} = "Y";
503 $form->{l_debit_accno} = "Y";
504 $form->{l_credit_tax} = "Y";
505 $form->{l_debit_tax} = "Y";
506 $form->{l_credit_tax_accno} = "Y";
507 $form->{l_debit_tax_accno} = "Y";
508 $form->{l_accno} = "N";
509 foreach $item (@columns) {
510 if ($form->{"l_$item"} eq "Y") {
511 push @column_index, $item;
513 # add column to href and callback
514 $callback .= "&l_$item=Y";
515 $href .= "&l_$item=Y";
519 if ($form->{l_subtotal} eq 'Y') {
520 $callback .= "&l_subtotal=Y";
521 $href .= "&l_subtotal=Y";
524 $callback .= "&category=$form->{category}";
525 $href .= "&category=$form->{category}";
528 "<th><a class=listheading href=$href&sort=id>"
529 . $locale->text('ID')
531 $column_header{transdate} =
532 "<th><a class=listheading href=$href&sort=transdate>"
533 . $locale->text('Date')
535 $column_header{reference} =
536 "<th><a class=listheading href=$href&sort=reference>"
537 . $locale->text('Reference')
539 $column_header{source} =
540 "<th><a class=listheading href=$href&sort=source>"
541 . $locale->text('Source')
543 $column_header{description} =
544 "<th><a class=listheading href=$href&sort=description>"
545 . $locale->text('Description')
547 $column_header{notes} =
548 "<th class=listheading>" . $locale->text('Notes') . "</th>";
549 $column_header{debit} =
550 "<th class=listheading>" . $locale->text('Debit') . "</th>";
551 $column_header{debit_accno} =
552 "<th><a class=listheading href=$href&sort=accno>"
553 . $locale->text('Debit Account')
555 $column_header{credit} =
556 "<th class=listheading>" . $locale->text('Credit') . "</th>";
557 $column_header{credit_accno} =
558 "<th><a class=listheading href=$href&sort=accno>"
559 . $locale->text('Credit Account')
561 $column_header{debit_tax} =
562 "<th><a class=listheading href=$href&sort=accno>"
563 . $locale->text('Debit Tax')
565 $column_header{debit_tax_accno} =
566 "<th><a class=listheading href=$href&sort=accno>"
567 . $locale->text('Debit Tax Account')
569 $column_header{credit_tax} =
570 "<th><a class=listheading href=$href&sort=accno>"
571 . $locale->text('Credit Tax')
573 $column_header{credit_tax_accno} =
574 "<th><a class=listheading href=$href&sort=accno>"
575 . $locale->text('Credit Tax Account')
577 $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
578 $column_header{projectnumbers} =
579 "<th class=listheading>" . $locale->text('Project Numbers') . "</th>";
581 $form->{landscape} = 1;
590 <th class=listtop>$form->{title}</th>
600 <tr class=listheading>
603 map { print "$column_header{$_}\n" } @column_index;
612 # add sort to callback
613 $form->{callback} = "$callback&sort=$form->{sort}";
614 $callback = $form->escape($form->{callback});
616 # initial item for subtotals
617 if (@{ $form->{GL} }) {
618 $sameitem = $form->{GL}->[0]->{ $form->{sort} };
621 if ($form->{accno} && $form->{balance}) {
623 map { $column_data{$_} = "<td> </td>" } @column_index;
624 $column_data{balance} =
626 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
634 map { print "$column_data{$_}\n" } @column_index;
640 $form->{balance} *= $ml;
641 foreach $ref (@{ $form->{GL} }) {
642 $form->{balance} *= $ml;
644 # if item ne sort print subtotal
645 if ($form->{l_subtotal} eq 'Y') {
646 if ($sameitem ne $ref->{ $form->{sort} }) {
651 #foreach $key (sort keys(%{ $ref->{amount} })) {
652 # $form->{balance} += $ref->{amount}{$key};
656 foreach $key (sort keys(%{ $ref->{debit} })) {
657 $subtotaldebit += $ref->{debit}{$key};
658 $totaldebit += $ref->{debit}{$key};
660 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
663 "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
665 $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key});
669 foreach $key (sort keys(%{ $ref->{credit} })) {
670 $subtotalcredit += $ref->{credit}{$key};
671 $totalcredit += $ref->{credit}{$key};
673 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
676 . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
678 $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key});
682 foreach $key (sort keys(%{ $ref->{debit_tax} })) {
683 $subtotaldebittax += $ref->{debit_tax}{$key};
684 $totaldebittax += $ref->{debit_tax}{$key};
687 $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
690 . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
692 $form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key});
696 foreach $key (sort keys(%{ $ref->{credit_tax} })) {
697 $subtotalcredittax += $ref->{credit_tax}{$key};
698 $totalcredittax += $ref->{credit_tax}{$key};
701 $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
704 . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
706 $form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key});
712 foreach $key (sort keys(%{ $ref->{debit_accno} })) {
715 "<a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
718 "<br><a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
721 # if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
722 # $ref->{debit_tax_accno}{$key} = $taxaccno;
724 $taxaccno = $ref->{debit_tax_accno}{$key};
725 $debittaxkey = $ref->{debit_taxkey}{$key};
731 foreach $key (sort keys(%{ $ref->{credit_accno} })) {
734 "<a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
737 "<br><a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
740 # if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
741 # $ref->{credit_tax_accno}{$key} = $taxaccno;
743 $taxaccno = $ref->{credit_tax_accno}{$key};
744 $credittaxkey = $ref->{credit_taxkey}{$key};
748 foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
751 "<a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
754 "<br><a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
758 $credittaxaccno = "";
759 foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
762 "<a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
765 "<br><a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
770 foreach $key (sort keys(%{ $ref->{ac_transdate} })) {
772 $transdate = "$ref->{ac_transdate}{$key}";
774 $transdate .= "<br>$ref->{ac_transdate}{$key}";
778 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
779 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
781 $column_data{id} = "<td align=right> $ref->{id} </td>";
782 $column_data{transdate} = "<td align=center>$transdate</td>";
783 $column_data{reference} =
784 "<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
785 $column_data{description} = "<td align=center>$ref->{description} </td>";
786 $column_data{source} = "<td align=center>$ref->{source} </td>";
787 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
788 $column_data{debit} = "<td align=right>$debit</td>";
789 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
790 $column_data{credit} = "<td align=right>$credit</td>";
791 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
792 $column_data{debit_tax} =
793 ($ref->{debit_tax_accno} ne "")
794 ? "<td align=right>$debittax</td>"
796 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
797 $column_data{credit_tax} =
798 ($ref->{credit_tax_accno} ne "")
799 ? "<td align=right>$credittax</td>"
801 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
802 $column_data{balance} =
804 . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . "</td>";
805 $column_data{projectnumbers} =
806 "<td>" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . "</td>";
811 <tr class=listrow$i>";
812 map { print "$column_data{$_}\n" } @column_index;
817 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
819 map { $column_data{$_} = "<td> </td>" } @column_index;
821 my $balanced_ledger = $totaldebit
825 # = 0 for balanced ledger
827 $column_data{debit} =
828 "<th align=right class=listtotal>"
829 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
830 $column_data{credit} =
831 "<th align=right class=listtotal>"
832 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
833 $column_data{debit_tax} =
834 "<th align=right class=listtotal>"
835 . $form->format_amount(\%myconfig, $totaldebittax, 2, " ") . "</th>";
836 $column_data{credit_tax} =
837 "<th align=right class=listtotal>"
838 . $form->format_amount(\%myconfig, $totalcredittax, 2, " ") . "</th>";
839 $column_data{balance} =
840 "<th align=right class=listtotal>"
841 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
847 map { print "$column_data{$_}\n" } @column_index;
854 if ( abs($balanced_ledger) > 0.001 ) {
856 print qq|<td colspan="4" style="background-color:#FFA0A0" >|
857 . $locale->text('Unbalanced Ledger')
859 . $form->format_amount(\%myconfig, $balanced_ledger, 3, " ")
861 } elsif ( abs($balanced_ledger) <= 0.001 ) {
863 print qq|<td colspan="3">|
864 . $locale->text('Balanced Ledger')
877 <td><hr size=3 noshade></td>
883 <form method=post action=$form->{script}>
885 <input name=callback type=hidden value="$form->{callback}">
887 <input type=hidden name=login value=$form->{login}>
888 <input type=hidden name=password value=$form->{password}>
890 <input class=submit type=submit name=action value="|
891 . $locale->text('GL Transaction') . qq|">
892 <input class=submit type=submit name=action value="|
893 . $locale->text('AR Transaction') . qq|">
894 <input class=submit type=submit name=action value="|
895 . $locale->text('AP Transaction') . qq|">
896 <input class=submit type=submit name=action value="|
897 . $locale->text('Sales Invoice') . qq|">
898 <input class=submit type=submit name=action value="|
899 . $locale->text('Vendor Invoice') . qq|">
906 $lxdebug->leave_sub();
911 $lxdebug->enter_sub();
914 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
916 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
918 map { $column_data{$_} = "<td> </td>" }
919 qw(transdate id reference source description accno);
920 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
921 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
923 print "<tr class=listsubtotal>";
924 map { print "$column_data{$_}\n" } @column_index;
930 $sameitem = $ref->{ $form->{sort} };
931 $lxdebug->leave_sub();
936 $lxdebug->enter_sub();
938 $form->{oldtransdate} = $form->{transdate};
950 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
952 for my $i (1 .. $form->{rowcount}) {
954 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
955 for (qw(debit credit tax)) {
957 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
961 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
968 if (($debitcount >= 2) && ($creditcount == 2)) {
969 $form->{"credit_$i"} = 0;
970 $form->{"tax_$i"} = 0;
974 if (($creditcount >= 2) && ($debitcount == 2)) {
975 $form->{"debit_$i"} = 0;
976 $form->{"tax_$i"} = 0;
980 if (($creditcount == 1) && ($debitcount == 2)) {
983 if (($creditcount == 2) && ($debitcount == 1)) {
986 if ($debitcredit && $credittax) {
987 $form->{"taxchart_$i"} = "0--0.00";
989 if (!$debitcredit && $debittax) {
990 $form->{"taxchart_$i"} = "0--0.00";
993 ($form->{"debit_$i"} == 0)
994 ? $form->{"credit_$i"}
995 : $form->{"debit_$i"};
997 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
998 $form->{"taxchart_$i"} = "0--0.00";
999 $form->{"tax_$i"} = 0;
1001 if (!$form->{"korrektur_$i"}) {
1002 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1009 if ($form->{taxincluded}) {
1010 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1012 $form->{"tax_$i"} = $amount * $rate;
1015 $form->{"tax_$i"} = 0;
1019 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1024 for $i (1 .. $count) {
1026 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1029 for $i ($count + 1 .. $form->{rowcount}) {
1030 for (@flds) { delete $form->{"${_}_$i"} }
1033 $form->{rowcount} = $count + 1;
1036 $lxdebug->leave_sub();
1042 $lxdebug->enter_sub();
1044 &form_header($init);
1046 # for $i (1 .. $form->{rowcount}) {
1047 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1048 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1052 &display_rows($init);
1054 $lxdebug->leave_sub();
1060 $lxdebug->enter_sub();
1062 $form->{debit_1} = 0 if !$form->{"debit_1"};
1063 $form->{totaldebit} = 0;
1064 $form->{totalcredit} = 0;
1066 my @old_project_ids = ();
1067 map({ push(@old_project_ids, $form->{"project_id_$_"})
1068 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
1070 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1072 "old_id" => \@old_project_ids },
1073 "charts" => { "key" => "ALL_CHARTS",
1074 "transdate" => $form->{transdate} },
1075 "taxcharts" => "ALL_TAXCHARTS");
1077 my %project_labels = ();
1078 my @project_values = ("");
1079 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1080 push(@project_values, $item->{"id"});
1081 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
1084 my %chart_labels = ();
1085 my @chart_values = ();
1088 foreach my $item (@{ $form->{ALL_CHARTS} }) {
1089 my $key = Q($item->{accno}) . "--" . Q($item->{tax_id});
1090 $taxchart_init = $item->{taxkey_id} unless (@chart_values);
1091 push(@chart_values, $key);
1092 $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description});
1093 $charts{$item->{accno}} = $item;
1096 my %taxchart_labels = ();
1097 my @taxchart_values = ();
1099 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
1100 my $key = Q($item->{id}) . "--" . Q($item->{rate});
1101 $taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
1102 push(@taxchart_values, $key);
1103 $taxchart_labels{$key} = H($item->{taxdescription}) . " " .
1104 H($item->{rate} * 100) . ' %';
1105 $taxcharts{$item->{id}} = $item;
1108 for $i (1 .. $form->{rowcount}) {
1111 <td><input name="source_$i" value="$form->{"source_$i"}" size="16"></td>|;
1113 <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16"></td>|;
1115 my $selected_accno_full;
1116 my ($accno_row) = split(/--/, $form->{"accno_$i"});
1117 my $item = $charts{$accno_row};
1118 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
1120 my $selected_taxchart = $form->{"taxchart_$i"};
1121 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
1122 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_accno_$i"});
1124 if ($previous_accno &&
1125 ($previous_accno eq $selected_accno) &&
1126 ($previous_tax_id ne $selected_tax_id)) {
1127 my $item = $taxcharts{$selected_tax_id};
1128 $selected_taxchart = "$item->{id}--$item->{rate}";
1131 $selected_accno = '' if ($init);
1132 $selected_taxchart = $taxchart_init unless ($selected_taxchart ne "");
1135 NTI($cgi->popup_menu('-name' => "accno_$i",
1136 '-id' => "accno_$i",
1137 '-onChange' => "setTaxkey(this, $i)",
1138 '-style' => 'width:200px',
1139 '-values' => \@chart_values,
1140 '-labels' => \%chart_labels,
1141 '-default' => $selected_accno_full))
1142 . $cgi->hidden('-name' => "previous_accno_$i",
1143 '-default' => $selected_accno_full)
1146 NTI($cgi->popup_menu('-name' => "taxchart_$i",
1147 '-id' => "taxchart_$i",
1148 '-style' => 'width:200px',
1149 '-values' => \@taxchart_values,
1150 '-labels' => \%taxchart_labels,
1151 '-default' => $selected_taxchart))
1156 qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
1157 if ($form->{transfer}) {
1158 $fx_transaction = qq|
1159 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1164 if ($form->{"debit_$i"} != 0) {
1165 $form->{totaldebit} += $form->{"debit_$i"};
1166 if (!$form->{taxincluded}) {
1167 $form->{totaldebit} += $form->{"tax_$i"};
1170 $form->{totalcredit} += $form->{"credit_$i"};
1171 if (!$form->{taxincluded}) {
1172 $form->{totalcredit} += $form->{"tax_$i"};
1176 for (qw(debit credit tax)) {
1177 $form->{"${_}_$i"} =
1178 ($form->{"${_}_$i"})
1179 ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
1183 if ($i < $form->{rowcount}) {
1184 if ($form->{transfer}) {
1185 $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
1186 $x = ($checked) ? "x" : "";
1187 $fx_transaction = qq|
1188 <td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
1191 $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
1193 qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked></td>|;
1194 $form->hide_form("accno_$i");
1198 qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
1199 if ($form->{transfer}) {
1200 $fx_transaction = qq|
1201 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1206 my $debitreadonly = "";
1207 my $creditreadonly = "";
1208 if ($i == $form->{rowcount}) {
1210 $debitreadonly = "readonly";
1211 } elsif ($creditlock) {
1212 $creditreadonly = "readonly";
1217 NTI($cgi->popup_menu('-name' => "project_id_$i",
1218 '-values' => \@project_values,
1219 '-labels' => \%project_labels,
1220 '-default' => $form->{"project_id_$i"} ));
1222 my $copy2credit = 'onkeyup="copy_debit_to_credit()"' if $i == 1;
1224 print qq|<tr valign=top>
1227 <td><input name="debit_$i" size="8" value="$form->{"debit_$i"}" accesskey=$i $copy2credit $debitreadonly></td>
1228 <td><input name="credit_$i" size=8 value="$form->{"credit_$i"}" $creditreadonly></td>
1229 <td><input name="tax_$i" size=6 value="$form->{"tax_$i"}"></td>
1233 if ($form->{show_details}) {
1237 <td>$projectnumber</td>
1245 $form->hide_form(qw(rowcount selectaccno));
1247 $lxdebug->leave_sub();
1253 $lxdebug->enter_sub();
1254 $title = $form->{title};
1255 $form->{title} = $locale->text("$title General Ledger Transaction");
1256 $readonly = ($form->{id}) ? "readonly" : "";
1258 $show_details_checked = "checked" if $form->{show_details};
1260 # $locale->text('Add General Ledger Transaction')
1261 # $locale->text('Edit General Ledger Transaction')
1263 map { $form->{$_} =~ s/\"/"/g }
1264 qw(reference description chart taxchart);
1266 $form->{javascript} = qq|<script type="text/javascript">
1268 function setTaxkey(accno, row) {
1269 var taxkey = accno.options[accno.selectedIndex].value;
1270 var reg = /--([0-9]*)/;
1271 var found = reg.exec(taxkey);
1272 var index = found[1];
1273 index = parseInt(index);
1274 var tax = 'taxchart_' + row;
1275 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
1276 var reg2 = new RegExp("^"+ index, "");
1277 if (reg2.exec(document.getElementById(tax).options[i].value)) {
1278 document.getElementById(tax).options[i].selected = true;
1284 function copy_debit_to_credit() {
1285 var txt = document.getElementsByName('debit_1')[0].value;
1286 document.getElementsByName('credit_2')[0].value = txt;
1291 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
1293 $form->{selectdepartment} =~ s/ selected//;
1294 $form->{selectdepartment} =~
1295 s/option>\Q$form->{department}\E/option selected>$form->{department}/;
1297 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
1299 qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
1302 qq|<input name=description size=50 value="$form->{description}" $readonly>|;
1305 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
1308 $taxincluded = "checked";
1313 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1314 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1315 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
1317 | if $form->{selectdepartment};
1319 $form->{fokus} = "gl.reference";
1321 $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
1324 # use JavaScript Calendar or not
1325 $form->{jsscript} = 1;
1327 if ($form->{jsscript}) {
1329 # with JavaScript Calendar
1331 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\">
1332 <input type=button name=transdate id="trigger1" value=|
1333 . $locale->text('button') . qq|></td>
1338 Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1");
1341 # without JavaScript Calendar
1343 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\"></td>|;
1346 $form->{previous_id} ||= "--";
1347 $form->{previous_gldate} ||= "--";
1352 <body onLoad="fokus()">
1354 <form method=post name="gl" action=$form->{script}>
1357 $form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate));
1360 <input type=hidden name=title value="$title">
1365 <th class=listtop>$form->{title}</th>
1367 <tr height="5"></tr>
1372 <td colspan="6" align="left">|
1373 . $locale->text("Previous transnumber text")
1374 . " $form->{previous_id} "
1375 . $locale->text("Previous transdate text")
1376 . " $form->{previous_gldate}"
1380 <th align=right>| . $locale->text('Reference') . qq|</th>
1381 <td><input name=reference size=20 value="$form->{reference}" $readonly></td>
1385 <th align=right nowrap>| . $locale->text('Date') . qq|</th>
1394 <th align=right>| . $locale->text('Belegnummer') . qq|</th>
1395 <td><input name=id size=20 value="$form->{id}" $readonly></td>
1399 <th align=right width=50%>| . $locale->text('Buchungsdatum') . qq|</th>
1400 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly onBlur=\"check_right_date_format(this)\"></td>
1411 <th align=right width=1%>| . $locale->text('Description') . qq|</th>
1412 <td width=1%>$description</td>
1416 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1417 <td><input type=checkbox name=taxincluded value=1 $taxincluded></td>
1424 <th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
1425 <td align=left><input name=employee size=20 value="| . H($form->{employee}) . qq|" readonly></td>
1433 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1434 <td width=1%>$description</td>
1438 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1439 <td><input type=checkbox name=taxincluded value=1 $taxincluded></td>
1447 <td width="1%" align="right" nowrap>| . $locale->text('Show details') . qq|</td>
1448 <td width="1%"><input type="checkbox" onclick="show_form_details();" name="show_details" value="1" $show_details_checked></td>
1455 <tr class=listheading>
1456 <th class=listheading style="width:15%">|
1457 . $locale->text('Account') . qq|</th>
1458 <th class=listheading style="width:10%">|
1459 . $locale->text('Debit') . qq|</th>
1460 <th class=listheading style="width:10%">|
1461 . $locale->text('Credit') . qq|</th>
1462 <th class=listheading style="width:10%">|
1463 . $locale->text('Tax') . qq|</th>
1464 <th class=listheading style="width:5%">|
1465 . $locale->text('Korrektur') . qq|</th>
1466 <th class=listheading style="width:10%">|
1467 . $locale->text('Taxkey') . qq|</th>|;
1469 if ($form->{show_details}) {
1471 <th class=listheading style="width:20%">| . $locale->text('Source') . qq|</th>
1472 <th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
1473 <th class=listheading style="width:20%">| . $locale->text('Project Number') . qq|</th>
1482 $lxdebug->leave_sub();
1487 $lxdebug->enter_sub();
1488 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1490 $decimalplaces = ($dec > 2) ? $dec : 2;
1491 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
1494 $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
1495 } qw(totaldebit totalcredit);
1498 <tr class=listtotal>
1500 <th align=right class=listtotal> $form->{totaldebit}</th>
1501 <th align=right class=listtotal> $form->{totalcredit}</th>
1509 <input type=hidden name=login value=$form->{login}>
1510 <input type=hidden name=password value=$form->{password}>
1512 <input name=callback type=hidden value="$form->{callback}">
1517 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1518 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1522 if (!$form->{storno}) {
1523 print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|">|;
1526 # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1527 if (!$form->{locked} && $radieren) {
1529 <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|" accesskey="b">
1530 <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|;
1534 if ($transdate > $closedto) {
1536 <input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
1537 <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">|;
1547 $lxdebug->leave_sub();
1552 $lxdebug->enter_sub();
1559 <form method=post action=$form->{script}>
1562 map { $form->{$_} =~ s/\"/"/g } qw(reference description);
1564 delete $form->{header};
1566 foreach $key (keys %$form) {
1567 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1571 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1574 . $locale->text('Are you sure you want to delete Transaction')
1575 . qq| $form->{reference}</h4>
1577 <input name=action class=submit type=submit value="|
1578 . $locale->text('Yes') . qq|">
1581 $lxdebug->leave_sub();
1586 $lxdebug->enter_sub();
1587 if (GL->delete_transaction(\%myconfig, \%$form)){
1588 # saving the history
1589 if(!exists $form->{addition} && $form->{id} ne "") {
1590 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1591 $form->{addition} = "DELETED";
1592 $form->save_history($form->dbconnect(\%myconfig));
1594 # /saving the history
1595 $form->redirect($locale->text('Transaction deleted!'))
1597 $form->error($locale->text('Cannot delete transaction!'));
1598 $lxdebug->leave_sub();
1603 $lxdebug->enter_sub();
1605 $form->{title} = $locale->text("$form->{title} General Ledger Transaction");
1607 # check if there is something in reference and date
1608 $form->isblank("reference", $locale->text('Reference missing!'));
1609 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1610 $form->isblank("description", $locale->text('Description missing!'));
1612 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1613 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1620 my $creditcount = 0;
1625 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1627 for my $i (1 .. $form->{rowcount}) {
1629 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1630 for (qw(debit credit tax)) {
1631 $form->{"${_}_$i"} =
1632 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1636 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1644 if (($debitcount >= 2) && ($creditcount == 2)) {
1645 $form->{"credit_$i"} = 0;
1646 $form->{"tax_$i"} = 0;
1650 if (($creditcount >= 2) && ($debitcount == 2)) {
1651 $form->{"debit_$i"} = 0;
1652 $form->{"tax_$i"} = 0;
1656 if (($creditcount == 1) && ($debitcount == 2)) {
1659 if (($creditcount == 2) && ($debitcount == 1)) {
1662 if ($debitcredit && $credittax) {
1663 $form->{"taxchart_$i"} = "0--0.00";
1665 if (!$debitcredit && $debittax) {
1666 $form->{"taxchart_$i"} = "0--0.00";
1669 ($form->{"debit_$i"} == 0)
1670 ? $form->{"credit_$i"}
1671 : $form->{"debit_$i"};
1673 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1674 $form->{"taxchart_$i"} = "0--0.00";
1675 $form->{"tax_$i"} = 0;
1677 if (!$form->{"korrektur_$i"}) {
1678 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1685 if ($form->{taxincluded}) {
1686 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1688 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1690 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1693 $form->{"tax_$i"} = $amount * $rate;
1696 $form->{"tax_$i"} = 0;
1698 } elsif ($form->{taxincluded}) {
1700 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1702 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1706 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1711 for $i (1 .. $count) {
1713 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1716 for $i ($count + 1 .. $form->{rowcount}) {
1717 for (@flds) { delete $form->{"${_}_$i"} }
1720 for $i (1 .. $form->{rowcount}) {
1721 $dr = $form->{"debit_$i"};
1722 $cr = $form->{"credit_$i"};
1723 $tax = $form->{"tax_$i"};
1727 'Cannot post transaction with a debit and credit entry for the same account!'
1730 if ($form->{taxincluded}) {
1732 $debit += $dr + $tax;
1735 $credit += $cr + $tax;
1740 $debit += $dr + $tax;
1743 $credit += $cr + $tax;
1748 $form->{taxincluded} = 0;
1751 # this is just for the wise guys
1752 $form->error($locale->text('Cannot post transaction for a closed period!'))
1753 if ($transdate <= $closedto);
1754 if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
1755 $form->error($locale->text('Out of balance transaction!'));
1758 if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) {
1759 $form->error($locale->text('Empty transaction!'));
1762 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1764 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1765 $err[2] = $locale->text('Debit and credit out of balance!');
1766 $err[3] = $locale->text('Cannot post a transaction without a value!');
1768 $form->error($err[$errno]);
1770 undef($form->{callback});
1771 # saving the history
1772 if(!exists $form->{addition} && $form->{id} ne "") {
1773 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1774 $form->{addition} = "SAVED";
1775 $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
1776 $form->save_history($form->dbconnect(\%myconfig));
1778 # /saving the history
1780 $form->{callback} = build_std_url("action=add", "show_details");
1781 $form->redirect($form->{callback});
1783 $lxdebug->leave_sub();
1788 $lxdebug->enter_sub();
1792 $lxdebug->leave_sub();
1797 $lxdebug->enter_sub();
1799 if (IS->has_storno(\%myconfig, $form, 'gl')) {
1800 $form->{title} = $locale->text("Cancel General Ledger Transaction");
1801 $form->error($locale->text("Transaction has already been cancelled!"));
1804 my %keep_keys = map { $_, 1 } qw(login password id stylesheet);
1805 map { delete $form->{$_} unless $keep_keys{$_} } keys %{ $form };
1807 prepare_transaction();
1809 for my $i (1 .. $form->{rowcount}) {
1810 for (qw(debit credit tax)) {
1811 $form->{"${_}_$i"} =
1812 ($form->{"${_}_$i"})
1813 ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
1818 $form->{storno} = 1;
1819 $form->{storno_id} = $form->{id};
1822 $form->{reference} = "Storno-" . $form->{reference};
1823 $form->{description} = "Storno-" . $form->{description};
1825 for my $i (1 .. $form->{rowcount}) {
1826 next if (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq ""));
1828 if ($form->{"debit_$i"} ne "") {
1829 $form->{"credit_$i"} = $form->{"debit_$i"};
1830 $form->{"debit_$i"} = "";
1833 $form->{"debit_$i"} = $form->{"credit_$i"};
1834 $form->{"credit_$i"} = "";
1840 # saving the history
1841 if(!exists $form->{addition} && $form->{id} ne "") {
1842 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1843 $form->{addition} = "STORNO";
1844 $form->save_history($form->dbconnect(\%myconfig));
1846 # /saving the history
1848 $lxdebug->leave_sub();