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}" onBlur=\"check_right_date_format(this)\">
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}" onBlur=\"check_right_date_format(this)\">
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}" onBlur=\"check_right_date_format(this)\"></td>|;
256 qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
258 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
260 $onload = qq|focus()|;
261 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
262 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
264 <body onLoad="$onload">
266 <form method=post action=$form->{script}>
268 <input type=hidden name=sort value=transdate>
272 <th class=listtop>$form->{title}</th>
279 <th align=right>| . $locale->text('Reference') . qq|</th>
280 <td><input name=reference size=20></td>
281 <th align=right>| . $locale->text('Source') . qq|</th>
282 <td><input name=source size=20></td>
286 <th align=right>| . $locale->text('Description') . qq|</th>
287 <td colspan=3><input name=description size=40></td>
290 <th align=right>| . $locale->text('Notes') . qq|</th>
291 <td colspan=3><input name=notes size=40></td>
294 <th align=right>| . $locale->text('Project Number') . qq|</th>
295 <td colspan=3>$projectnumber</td>
298 <th align=right>| . $locale->text('From') . qq|</th>
300 <th align=right>| . $locale->text('To (time)') . qq|</th>
304 <th align=right>| . $locale->text('Include in Report') . qq|</th>
309 <input name="category" class=radio type=radio value=X checked> |
310 . $locale->text('All') . qq|
311 <input name="category" class=radio type=radio value=A> |
312 . $locale->text('Asset') . qq|
313 <input name="category" class=radio type=radio value=L> |
314 . $locale->text('Liability') . qq|
315 <input name="category" class=radio type=radio value=I> |
316 . $locale->text('Revenue') . qq|
317 <input name="category" class=radio type=radio value=E> |
318 . $locale->text('Expense') . qq|
324 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
325 <td>| . $locale->text('ID') . qq|</td>
326 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
327 <td>| . $locale->text('Date') . qq|</td>
328 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
329 <td>| . $locale->text('Reference') . qq|</td>
330 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
331 <td>| . $locale->text('Description') . qq|</td>
332 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
333 <td>| . $locale->text('Notes') . qq|</td>
336 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
337 <td>| . $locale->text('Debit') . qq|</td>
338 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
339 <td>| . $locale->text('Credit') . qq|</td>
340 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
341 <td>| . $locale->text('Source') . qq|</td>
342 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
343 <td>| . $locale->text('Account') . 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->{source}) {
416 $href .= "&source=" . $form->escape($form->{source});
417 $callback .= "&source=" . $form->escape($form->{source}, 1);
418 $option .= "\n<br>" if $option;
419 $option .= $locale->text('Source') . " : $form->{source}";
421 if ($form->{reference}) {
422 $href .= "&reference=" . $form->escape($form->{reference});
423 $callback .= "&reference=" . $form->escape($form->{reference}, 1);
424 $option .= "\n<br>" if $option;
425 $option .= $locale->text('Reference') . " : $form->{reference}";
427 if ($form->{department}) {
428 $href .= "&department=" . $form->escape($form->{department});
429 $callback .= "&department=" . $form->escape($form->{department}, 1);
430 ($department) = split /--/, $form->{department};
431 $option .= "\n<br>" if $option;
432 $option .= $locale->text('Department') . " : $department";
435 if ($form->{description}) {
436 $href .= "&description=" . $form->escape($form->{description});
437 $callback .= "&description=" . $form->escape($form->{description}, 1);
438 $option .= "\n<br>" if $option;
439 $option .= $locale->text('Description') . " : $form->{description}";
441 if ($form->{notes}) {
442 $href .= "¬es=" . $form->escape($form->{notes});
443 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
444 $option .= "\n<br>" if $option;
445 $option .= $locale->text('Notes') . " : $form->{notes}";
447 if ($form->{project_id}) {
448 $href .= "&project_id=" . $form->escape($form->{project_id});
449 $callback .= "&project_id=" . $form->escape($form->{project_id});
452 if ($form->{datefrom}) {
453 $href .= "&datefrom=$form->{datefrom}";
454 $callback .= "&datefrom=$form->{datefrom}";
455 $option .= "\n<br>" if $option;
457 $locale->text('From') . " "
458 . $locale->date(\%myconfig, $form->{datefrom}, 1);
460 if ($form->{dateto}) {
461 $href .= "&dateto=$form->{dateto}";
462 $callback .= "&dateto=$form->{dateto}";
463 if ($form->{datefrom}) {
466 $option .= "\n<br>" if $option;
469 $locale->text('Bis') . " "
470 . $locale->date(\%myconfig, $form->{dateto}, 1);
473 @columns = $form->sort_columns( qw(
474 transdate id reference description
475 notes source debit debit_accno
476 credit credit_accno debit_tax debit_tax_accno
477 credit_tax credit_tax_accno accno
482 if ($form->{accno}) {
483 @columns = grep !/accno/, @columns;
484 push @columns, "balance";
485 $form->{l_balance} = "Y";
489 $form->{l_credit_accno} = "Y";
490 $form->{l_debit_accno} = "Y";
491 $form->{l_credit_tax} = "Y";
492 $form->{l_debit_tax} = "Y";
493 $form->{l_credit_tax_accno} = "Y";
494 $form->{l_debit_tax_accno} = "Y";
495 $form->{l_accno} = "N";
496 foreach $item (@columns) {
497 if ($form->{"l_$item"} eq "Y") {
498 push @column_index, $item;
500 # add column to href and callback
501 $callback .= "&l_$item=Y";
502 $href .= "&l_$item=Y";
506 if ($form->{l_subtotal} eq 'Y') {
507 $callback .= "&l_subtotal=Y";
508 $href .= "&l_subtotal=Y";
511 $callback .= "&category=$form->{category}";
512 $href .= "&category=$form->{category}";
515 "<th><a class=listheading href=$href&sort=id>"
516 . $locale->text('ID')
518 $column_header{transdate} =
519 "<th><a class=listheading href=$href&sort=transdate>"
520 . $locale->text('Date')
522 $column_header{reference} =
523 "<th><a class=listheading href=$href&sort=reference>"
524 . $locale->text('Reference')
526 $column_header{source} =
527 "<th><a class=listheading href=$href&sort=source>"
528 . $locale->text('Source')
530 $column_header{description} =
531 "<th><a class=listheading href=$href&sort=description>"
532 . $locale->text('Description')
534 $column_header{notes} =
535 "<th class=listheading>" . $locale->text('Notes') . "</th>";
536 $column_header{debit} =
537 "<th class=listheading>" . $locale->text('Debit') . "</th>";
538 $column_header{debit_accno} =
539 "<th><a class=listheading href=$href&sort=accno>"
540 . $locale->text('Debit Account')
542 $column_header{credit} =
543 "<th class=listheading>" . $locale->text('Credit') . "</th>";
544 $column_header{credit_accno} =
545 "<th><a class=listheading href=$href&sort=accno>"
546 . $locale->text('Credit Account')
548 $column_header{debit_tax} =
549 "<th><a class=listheading href=$href&sort=accno>"
550 . $locale->text('Debit Tax')
552 $column_header{debit_tax_accno} =
553 "<th><a class=listheading href=$href&sort=accno>"
554 . $locale->text('Debit Tax Account')
556 $column_header{credit_tax} =
557 "<th><a class=listheading href=$href&sort=accno>"
558 . $locale->text('Credit Tax')
560 $column_header{credit_tax_accno} =
561 "<th><a class=listheading href=$href&sort=accno>"
562 . $locale->text('Credit Tax Account')
564 $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
565 $column_header{projectnumbers} =
566 "<th class=listheading>" . $locale->text('Project Numbers') . "</th>";
568 $form->{landscape} = 1;
577 <th class=listtop>$form->{title}</th>
587 <tr class=listheading>
590 map { print "$column_header{$_}\n" } @column_index;
599 # add sort to callback
600 $form->{callback} = "$callback&sort=$form->{sort}";
601 $callback = $form->escape($form->{callback});
603 # initial item for subtotals
604 if (@{ $form->{GL} }) {
605 $sameitem = $form->{GL}->[0]->{ $form->{sort} };
608 if ($form->{accno} && $form->{balance}) {
610 map { $column_data{$_} = "<td> </td>" } @column_index;
611 $column_data{balance} =
613 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
621 map { print "$column_data{$_}\n" } @column_index;
627 $form->{balance} *= $ml;
628 foreach $ref (@{ $form->{GL} }) {
629 $form->{balance} *= $ml;
631 # if item ne sort print subtotal
632 if ($form->{l_subtotal} eq 'Y') {
633 if ($sameitem ne $ref->{ $form->{sort} }) {
638 #foreach $key (sort keys(%{ $ref->{amount} })) {
639 # $form->{balance} += $ref->{amount}{$key};
643 foreach $key (sort keys(%{ $ref->{debit} })) {
644 $subtotaldebit += $ref->{debit}{$key};
645 $totaldebit += $ref->{debit}{$key};
647 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
650 "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
652 $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key});
656 foreach $key (sort keys(%{ $ref->{credit} })) {
657 $subtotalcredit += $ref->{credit}{$key};
658 $totalcredit += $ref->{credit}{$key};
660 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
663 . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
665 $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key});
669 foreach $key (sort keys(%{ $ref->{debit_tax} })) {
670 $subtotaldebittax += $ref->{debit_tax}{$key};
671 $totaldebittax += $ref->{debit_tax}{$key};
674 $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
677 . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
679 $form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key});
683 foreach $key (sort keys(%{ $ref->{credit_tax} })) {
684 $subtotalcredittax += $ref->{credit_tax}{$key};
685 $totalcredittax += $ref->{credit_tax}{$key};
688 $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
691 . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
693 $form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key});
699 foreach $key (sort keys(%{ $ref->{debit_accno} })) {
702 "<a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
705 "<br><a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
708 # if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
709 # $ref->{debit_tax_accno}{$key} = $taxaccno;
711 $taxaccno = $ref->{debit_tax_accno}{$key};
712 $debittaxkey = $ref->{debit_taxkey}{$key};
718 foreach $key (sort keys(%{ $ref->{credit_accno} })) {
721 "<a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
724 "<br><a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
727 # if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
728 # $ref->{credit_tax_accno}{$key} = $taxaccno;
730 $taxaccno = $ref->{credit_tax_accno}{$key};
731 $credittaxkey = $ref->{credit_taxkey}{$key};
735 foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
738 "<a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
741 "<br><a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
745 $credittaxaccno = "";
746 foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
749 "<a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
752 "<br><a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
757 foreach $key (sort keys(%{ $ref->{ac_transdate} })) {
759 $transdate = "$ref->{ac_transdate}{$key}";
761 $transdate .= "<br>$ref->{ac_transdate}{$key}";
765 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
766 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
768 $column_data{id} = "<td align=right> $ref->{id} </td>";
769 $column_data{transdate} = "<td align=center>$transdate</td>";
770 $column_data{reference} =
771 "<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>";
772 $column_data{description} = "<td align=center>$ref->{description} </td>";
773 $column_data{source} = "<td align=center>$ref->{source} </td>";
774 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
775 $column_data{debit} = "<td align=right>$debit</td>";
776 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
777 $column_data{credit} = "<td align=right>$credit</td>";
778 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
779 $column_data{debit_tax} =
780 ($ref->{debit_tax_accno} ne "")
781 ? "<td align=right>$debittax</td>"
783 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
784 $column_data{credit_tax} =
785 ($ref->{credit_tax_accno} ne "")
786 ? "<td align=right>$credittax</td>"
788 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
789 $column_data{balance} =
791 . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . "</td>";
792 $column_data{projectnumbers} =
793 "<td>" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . "</td>";
798 <tr class=listrow$i>";
799 map { print "$column_data{$_}\n" } @column_index;
804 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
806 map { $column_data{$_} = "<td> </td>" } @column_index;
808 my $balanced_ledger = $totaldebit
812 # = 0 for balanced ledger
814 $column_data{debit} =
815 "<th align=right class=listtotal>"
816 . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
817 $column_data{credit} =
818 "<th align=right class=listtotal>"
819 . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
820 $column_data{debit_tax} =
821 "<th align=right class=listtotal>"
822 . $form->format_amount(\%myconfig, $totaldebittax, 2, " ") . "</th>";
823 $column_data{credit_tax} =
824 "<th align=right class=listtotal>"
825 . $form->format_amount(\%myconfig, $totalcredittax, 2, " ") . "</th>";
826 $column_data{balance} =
827 "<th align=right class=listtotal>"
828 . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
834 map { print "$column_data{$_}\n" } @column_index;
841 if ( abs($balanced_ledger) > 0.001 ) {
843 print qq|<td colspan="4" style="background-color:#FFA0A0" >|
844 . $locale->text('Unbalanced Ledger')
846 . $form->format_amount(\%myconfig, $balanced_ledger, 3, " ")
848 } elsif ( abs($balanced_ledger) <= 0.001 ) {
850 print qq|<td colspan="3">|
851 . $locale->text('Balanced Ledger')
864 <td><hr size=3 noshade></td>
870 <form method=post action=$form->{script}>
872 <input name=callback type=hidden value="$form->{callback}">
874 <input type=hidden name=path value=$form->{path}>
875 <input type=hidden name=login value=$form->{login}>
876 <input type=hidden name=password value=$form->{password}>
878 <input class=submit type=submit name=action value="|
879 . $locale->text('GL Transaction') . qq|">
880 <input class=submit type=submit name=action value="|
881 . $locale->text('AR Transaction') . qq|">
882 <input class=submit type=submit name=action value="|
883 . $locale->text('AP Transaction') . qq|">
884 <input class=submit type=submit name=action value="|
885 . $locale->text('Sales Invoice') . qq|">
886 <input class=submit type=submit name=action value="|
887 . $locale->text('Vendor Invoice') . qq|">
894 $lxdebug->leave_sub();
899 $lxdebug->enter_sub();
902 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
904 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
906 map { $column_data{$_} = "<td> </td>" }
907 qw(transdate id reference source description accno);
908 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
909 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
911 print "<tr class=listsubtotal>";
912 map { print "$column_data{$_}\n" } @column_index;
918 $sameitem = $ref->{ $form->{sort} };
919 $lxdebug->leave_sub();
924 $lxdebug->enter_sub();
926 $form->{oldtransdate} = $form->{transdate};
938 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
940 for my $i (1 .. $form->{rowcount}) {
942 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
943 for (qw(debit credit tax)) {
945 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
949 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
956 if (($debitcount >= 2) && ($creditcount == 2)) {
957 $form->{"credit_$i"} = 0;
958 $form->{"tax_$i"} = 0;
962 if (($creditcount >= 2) && ($debitcount == 2)) {
963 $form->{"debit_$i"} = 0;
964 $form->{"tax_$i"} = 0;
968 if (($creditcount == 1) && ($debitcount == 2)) {
971 if (($creditcount == 2) && ($debitcount == 1)) {
974 if ($debitcredit && $credittax) {
975 $form->{"taxchart_$i"} = "0--0.00";
977 if (!$debitcredit && $debittax) {
978 $form->{"taxchart_$i"} = "0--0.00";
981 ($form->{"debit_$i"} == 0)
982 ? $form->{"credit_$i"}
983 : $form->{"debit_$i"};
985 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
986 $form->{"taxchart_$i"} = "0--0.00";
987 $form->{"tax_$i"} = 0;
989 if (!$form->{"korrektur_$i"}) {
990 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
997 if ($form->{taxincluded}) {
998 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1000 $form->{"tax_$i"} = $amount * $rate;
1003 $form->{"tax_$i"} = 0;
1007 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1012 for $i (1 .. $count) {
1014 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1017 for $i ($count + 1 .. $form->{rowcount}) {
1018 for (@flds) { delete $form->{"${_}_$i"} }
1021 $form->{rowcount} = $count + 1;
1024 $lxdebug->leave_sub();
1030 $lxdebug->enter_sub();
1032 &form_header($init);
1034 # for $i (1 .. $form->{rowcount}) {
1035 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1036 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1040 &display_rows($init);
1042 $lxdebug->leave_sub();
1048 $lxdebug->enter_sub();
1050 $form->{totaldebit} = 0;
1051 $form->{totalcredit} = 0;
1053 my @old_project_ids = ();
1054 map({ push(@old_project_ids, $form->{"project_id_$_"})
1055 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
1057 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1059 "old_id" => \@old_project_ids },
1060 "charts" => { "key" => "ALL_CHARTS",
1061 "transdate" => $form->{transdate} },
1062 "taxcharts" => "ALL_TAXCHARTS");
1064 my %project_labels = ();
1065 my @project_values = ("");
1066 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1067 push(@project_values, $item->{"id"});
1068 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
1071 my %chart_labels = ();
1072 my @chart_values = ();
1075 foreach my $item (@{ $form->{ALL_CHARTS} }) {
1076 my $key = Q($item->{accno}) . "--" . Q($item->{tax_id});
1077 $taxchart_init = $item->{taxkey_id} unless (@chart_values);
1078 push(@chart_values, $key);
1079 $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description});
1080 $charts{$item->{accno}} = $item;
1083 my %taxchart_labels = ();
1084 my @taxchart_values = ();
1086 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
1087 my $key = Q($item->{id}) . "--" . Q($item->{rate});
1088 $taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
1089 push(@taxchart_values, $key);
1090 $taxchart_labels{$key} = H($item->{taxdescription}) . " " .
1091 H($item->{rate} * 100) . ' %';
1092 $taxcharts{$item->{id}} = $item;
1095 for $i (1 .. $form->{rowcount}) {
1098 <td><input name="source_$i" value="$form->{"source_$i"}" size="16"></td>|;
1100 <td><input name="memo_$i" value="$form->{"memo_$i"}" size="16"></td>|;
1102 my $selected_accno_full;
1103 my ($accno_row) = split(/--/, $form->{"accno_$i"});
1104 my $item = $charts{$accno_row};
1105 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
1107 my $selected_taxchart = $form->{"taxchart_$i"};
1108 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
1109 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_accno_$i"});
1111 if ($previous_accno &&
1112 ($previous_accno eq $selected_accno) &&
1113 ($previous_tax_id ne $selected_tax_id)) {
1114 my $item = $taxcharts{$selected_tax_id};
1115 $selected_taxchart = "$item->{id}--$item->{rate}";
1118 $selected_accno = '' if ($init);
1119 $selected_taxchart = $taxchart_init unless ($selected_taxchart ne "");
1122 NTI($cgi->popup_menu('-name' => "accno_$i",
1123 '-id' => "accno_$i",
1124 '-onChange' => "setTaxkey(this, $i)",
1125 '-style' => 'width:200px',
1126 '-values' => \@chart_values,
1127 '-labels' => \%chart_labels,
1128 '-default' => $selected_accno_full))
1129 . $cgi->hidden('-name' => "previous_accno_$i",
1130 '-default' => $selected_accno_full)
1133 NTI($cgi->popup_menu('-name' => "taxchart_$i",
1134 '-id' => "taxchart_$i",
1135 '-style' => 'width:200px',
1136 '-values' => \@taxchart_values,
1137 '-labels' => \%taxchart_labels,
1138 '-default' => $selected_taxchart))
1143 qq|<td><input type="checkbox" name="korrektur_$i" value="1"</td>|;
1144 if ($form->{transfer}) {
1145 $fx_transaction = qq|
1146 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1151 if ($form->{"debit_$i"} != 0) {
1152 $form->{totaldebit} += $form->{"debit_$i"};
1153 if (!$form->{taxincluded}) {
1154 $form->{totaldebit} += $form->{"tax_$i"};
1157 $form->{totalcredit} += $form->{"credit_$i"};
1158 if (!$form->{taxincluded}) {
1159 $form->{totalcredit} += $form->{"tax_$i"};
1163 for (qw(debit credit tax)) {
1164 $form->{"${_}_$i"} =
1165 ($form->{"${_}_$i"})
1166 ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
1170 if ($i < $form->{rowcount}) {
1171 if ($form->{transfer}) {
1172 $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
1173 $x = ($checked) ? "x" : "";
1174 $fx_transaction = qq|
1175 <td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
1178 $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
1180 qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked></td>|;
1181 $form->hide_form("accno_$i");
1185 qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
1186 if ($form->{transfer}) {
1187 $fx_transaction = qq|
1188 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
1193 my $debitreadonly = "";
1194 my $creditreadonly = "";
1195 if ($i == $form->{rowcount}) {
1197 $debitreadonly = "readonly";
1198 } elsif ($creditlock) {
1199 $creditreadonly = "readonly";
1204 NTI($cgi->popup_menu('-name' => "project_id_$i",
1205 '-values' => \@project_values,
1206 '-labels' => \%project_labels,
1207 '-default' => $form->{"project_id_$i"} ));
1209 print qq|<tr valign=top>
1212 <td><input name="debit_$i" size=8 value="$form->{"debit_$i"}" accesskey=$i $debitreadonly></td>
1213 <td><input name="credit_$i" size=8 value="$form->{"credit_$i"}" $creditreadonly></td>
1214 <td><input name="tax_$i" size=6 value="$form->{"tax_$i"}"></td>
1219 <td>$projectnumber</td>
1225 $form->hide_form(qw(rowcount selectaccno));
1227 $lxdebug->leave_sub();
1233 $lxdebug->enter_sub();
1234 $title = $form->{title};
1235 $form->{title} = $locale->text("$title General Ledger Transaction");
1236 $readonly = ($form->{id}) ? "readonly" : "";
1238 # $locale->text('Add General Ledger Transaction')
1239 # $locale->text('Edit General Ledger Transaction')
1241 map { $form->{$_} =~ s/\"/"/g }
1242 qw(reference description chart taxchart);
1243 $form->{javascript} = qq|<script type="text/javascript">
1245 function setTaxkey(accno, row) {
1246 var taxkey = accno.options[accno.selectedIndex].value;
1247 var reg = /--([0-9]*)/;
1248 var found = reg.exec(taxkey);
1249 var index = found[1];
1250 index = parseInt(index);
1251 var tax = 'taxchart_' + row;
1252 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
1253 var reg2 = new RegExp("^"+ index, "");
1254 if (reg2.exec(document.getElementById(tax).options[i].value)) {
1255 document.getElementById(tax).options[i].selected = true;
1263 $form->{selectdepartment} =~ s/ selected//;
1264 $form->{selectdepartment} =~
1265 s/option>\Q$form->{department}\E/option selected>$form->{department}/;
1267 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
1269 qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
1272 qq|<input name=description size=50 value="$form->{description}" $readonly>|;
1275 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
1278 $taxincluded = "checked";
1283 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1284 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1285 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
1287 | if $form->{selectdepartment};
1289 $form->{fokus} = "gl.reference";
1291 $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
1294 # use JavaScript Calendar or not
1295 $form->{jsscript} = $jscalendar;
1297 if ($form->{jsscript}) {
1299 # with JavaScript Calendar
1301 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\">
1302 <input type=button name=transdate id="trigger1" value=|
1303 . $locale->text('button') . qq|></td>
1308 Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1");
1311 # without JavaScript Calendar
1313 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\"></td>|;
1319 <body onLoad="fokus()">
1321 <form method=post name="gl" action=$form->{script}>
1323 <input name=id type=hidden value=$form->{id}>
1325 <input type=hidden name=closedto value=$form->{closedto}>
1326 <input type=hidden name=locked value=$form->{locked}>
1327 <input type=hidden name=title value="$title">
1332 <th class=listtop>$form->{title}</th>
1334 <tr height="5"></tr>
1339 <th align=right>| . $locale->text('Reference') . qq|</th>
1340 <td><input name=reference size=20 value="$form->{reference}" $readonly></td>
1344 <th align=right nowrap>| . $locale->text('Date') . qq|</th>
1353 <th align=right>| . $locale->text('Belegnummer') . qq|</th>
1354 <td><input name=id size=20 value="$form->{id}" $readonly></td>
1358 <th align=right width=50%>| . $locale->text('Buchungsdatum') . qq|</th>
1359 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly onBlur=\"check_right_date_format(this)\"></td>
1370 <th align=right width=1%>| . $locale->text('Description') . qq|</th>
1371 <td width=1%>$description</td>
1375 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1376 <td><input type=checkbox name=taxincluded value=1 $taxincluded></td>
1383 <th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
1384 <td align=left><input name=employee size=20 value="| . H($form->{employee}) . qq|" readonly></td>
1392 <th align=left width=1%>| . $locale->text('Description') . qq|</th>
1393 <td width=1%>$description</td>
1397 <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
1398 <td><input type=checkbox name=taxincluded value=1 $taxincluded></td>
1408 <tr class=listheading>
1409 <th class=listheading style="width:15%">|
1410 . $locale->text('Account') . qq|</th>
1411 <th class=listheading style="width:10%">|
1412 . $locale->text('Debit') . qq|</th>
1413 <th class=listheading style="width:10%">|
1414 . $locale->text('Credit') . qq|</th>
1415 <th class=listheading style="width:10%">|
1416 . $locale->text('Tax') . qq|</th>
1417 <th class=listheading style="width:5%">|
1418 . $locale->text('Korrektur') . qq|</th>
1419 <th class=listheading style="width:10%">|
1420 . $locale->text('Taxkey') . qq|</th>
1421 <th class=listheading style="width:20%">|
1422 . $locale->text('Source') . qq|</th>
1423 <th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
1424 <th class=listheading style="width:20%">|
1425 . $locale->text('Project Number') . qq|</th>
1430 $lxdebug->leave_sub();
1435 $lxdebug->enter_sub();
1436 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1438 $decimalplaces = ($dec > 2) ? $dec : 2;
1439 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
1443 $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
1444 } qw(totaldebit totalcredit);
1447 <tr class=listtotal>
1449 <th align=right class=listtotal> $form->{totaldebit}</th>
1450 <th align=right class=listtotal> $form->{totalcredit}</th>
1458 <input type=hidden name=path value=$form->{path}>
1459 <input type=hidden name=login value=$form->{login}>
1460 <input type=hidden name=password value=$form->{password}>
1462 <input name=callback type=hidden value="$form->{callback}">
1467 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1468 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1472 print qq|<input class=submit type=submit name=action value="|
1473 . $locale->text('Storno') . qq|">|;
1475 # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1477 if (!$form->{locked} && $radieren) {
1479 <input class=submit type=submit name=action value="|
1480 . $locale->text('Post') . qq|" accesskey="b">
1481 <input class=submit type=submit name=action value="|
1482 . $locale->text('Delete') . qq|">|;
1485 # if ($transdate > $closedto) {
1487 # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
1490 if ($transdate > $closedto) {
1491 print qq|<input class=submit type=submit name=action value="|
1492 . $locale->text('Update') . qq|">
1493 <input class=submit type=submit name=action value="|
1494 . $locale->text('Post') . qq|">|;
1504 $lxdebug->leave_sub();
1509 $lxdebug->enter_sub();
1516 <form method=post action=$form->{script}>
1519 map { $form->{$_} =~ s/\"/"/g } qw(reference description);
1521 delete $form->{header};
1523 foreach $key (keys %$form) {
1524 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1528 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1531 . $locale->text('Are you sure you want to delete Transaction')
1532 . qq| $form->{reference}</h4>
1534 <input name=action class=submit type=submit value="|
1535 . $locale->text('Yes') . qq|">
1538 $lxdebug->leave_sub();
1543 $lxdebug->enter_sub();
1544 if (GL->delete_transaction(\%myconfig, \%$form)){
1545 # saving the history
1546 if(!exists $form->{addition} && $form->{id} ne "") {
1547 $form->{snumber} = qq|ordnumber_| . $form->{ordnumber};
1548 $form->{addition} = "DELETED";
1549 $form->save_history($form->dbconnect(\%myconfig));
1551 # /saving the history
1552 $form->redirect($locale->text('Transaction deleted!'))
1554 $form->error($locale->text('Cannot delete transaction!'));
1555 $lxdebug->leave_sub();
1560 $lxdebug->enter_sub();
1562 # check if there is something in reference and date
1563 $form->isblank("reference", $locale->text('Reference missing!'));
1564 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1565 $form->isblank("description", $locale->text('Description missing!'));
1567 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1568 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1575 my $creditcount = 0;
1580 qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1581 if ($form->{storno}) {
1582 for my $i (1 .. $form->{rowcount}) {
1583 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1584 if ($form->{"debit_$i"} ne "") {
1585 $form->{"credit_$i"} = $form->{"debit_$i"};
1586 $form->{"debit_$i"} = "";
1587 } elsif ($form->{"credit_$i"} ne "") {
1588 $form->{"debit_$i"} = $form->{"credit_$i"};
1589 $form->{"credit_$i"} = "";
1595 for my $i (1 .. $form->{rowcount}) {
1597 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1598 for (qw(debit credit tax)) {
1599 $form->{"${_}_$i"} =
1600 $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
1604 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1612 if (($debitcount >= 2) && ($creditcount == 2)) {
1613 $form->{"credit_$i"} = 0;
1614 $form->{"tax_$i"} = 0;
1618 if (($creditcount >= 2) && ($debitcount == 2)) {
1619 $form->{"debit_$i"} = 0;
1620 $form->{"tax_$i"} = 0;
1624 if (($creditcount == 1) && ($debitcount == 2)) {
1627 if (($creditcount == 2) && ($debitcount == 1)) {
1630 if ($debitcredit && $credittax) {
1631 $form->{"taxchart_$i"} = "0--0.00";
1633 if (!$debitcredit && $debittax) {
1634 $form->{"taxchart_$i"} = "0--0.00";
1637 ($form->{"debit_$i"} == 0)
1638 ? $form->{"credit_$i"}
1639 : $form->{"debit_$i"};
1641 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1642 $form->{"taxchart_$i"} = "0--0.00";
1643 $form->{"tax_$i"} = 0;
1645 if (!$form->{"korrektur_$i"}) {
1646 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1653 if ($form->{taxincluded}) {
1654 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1656 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1658 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1661 $form->{"tax_$i"} = $amount * $rate;
1664 $form->{"tax_$i"} = 0;
1666 } elsif ($form->{taxincluded}) {
1668 $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
1670 $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
1674 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1679 for $i (1 .. $count) {
1681 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1684 for $i ($count + 1 .. $form->{rowcount}) {
1685 for (@flds) { delete $form->{"${_}_$i"} }
1688 for $i (1 .. $form->{rowcount}) {
1689 $dr = $form->{"debit_$i"};
1690 $cr = $form->{"credit_$i"};
1691 $tax = $form->{"tax_$i"};
1695 'Cannot post transaction with a debit and credit entry for the same account!'
1698 if ($form->{taxincluded}) {
1700 $debit += $dr + $tax;
1703 $credit += $cr + $tax;
1708 $debit += $dr + $tax;
1711 $credit += $cr + $tax;
1716 $form->{taxincluded} = 0;
1719 # this is just for the wise guys
1720 $form->error($locale->text('Cannot post transaction for a closed period!'))
1721 if ($transdate <= $closedto);
1722 if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
1723 $form->error($locale->text('Out of balance transaction!'));
1726 if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) {
1727 $form->error($locale->text('Empty transaction!'));
1730 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1732 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1733 $err[2] = $locale->text('Debit and credit out of balance!');
1734 $err[3] = $locale->text('Cannot post a transaction without a value!');
1736 $form->error($err[$errno]);
1738 undef($form->{callback});
1739 # saving the history
1740 if(!exists $form->{addition} && $form->{id} ne "") {
1741 $form->{snumber} = qq|ordnumber_| . $form->{ordnumber};
1742 $form->{addition} = "SAVED";
1743 $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
1744 $form->save_history($form->dbconnect(\%myconfig));
1746 # /saving the history
1747 $form->redirect("Buchung gespeichert. Buchungsnummer = " . $form->{id});
1748 $lxdebug->leave_sub();
1753 $lxdebug->enter_sub();
1757 $lxdebug->leave_sub();
1762 $lxdebug->enter_sub();
1765 $form->{storno} = 1;
1766 # saving the history
1767 if(!exists $form->{addition} && $form->{id} ne "") {
1768 $form->{snumber} = qq|ordnumber_| . $form->{ordnumber};
1769 $form->{addition} = "STORNO";
1770 $form->save_history($form->dbconnect(\%myconfig));
1772 # /saving the history
1774 $lxdebug->leave_sub();