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 #======================================================================
40 require "$form->{path}/arap.pl";
46 # this is for our long dates
47 # $locale->text('January')
48 # $locale->text('February')
49 # $locale->text('March')
50 # $locale->text('April')
51 # $locale->text('May ')
52 # $locale->text('June')
53 # $locale->text('July')
54 # $locale->text('August')
55 # $locale->text('September')
56 # $locale->text('October')
57 # $locale->text('November')
58 # $locale->text('December')
60 # this is for our short month
61 # $locale->text('Jan')
62 # $locale->text('Feb')
63 # $locale->text('Mar')
64 # $locale->text('Apr')
65 # $locale->text('May')
66 # $locale->text('Jun')
67 # $locale->text('Jul')
68 # $locale->text('Aug')
69 # $locale->text('Sep')
70 # $locale->text('Oct')
71 # $locale->text('Nov')
72 # $locale->text('Dec')
76 $lxdebug->enter_sub();
78 $form->{title} = "Add";
80 $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
82 # we use this only to set a default date
83 GL->transaction(\%myconfig, \%$form);
85 map { $chart .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>" } @{ $form->{chart} };
86 map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
88 $form->{chart} = $chart;
90 $form->{debitchart} = $chart;
91 $form->{creditchart} = $chart;
92 $form->{taxchart} = $tax;
98 $form->{creditrowcount} = 2;
99 $form->{debitrowcount} = 2;
103 $form->all_departments(\%myconfig);
104 if (@{ $form->{all_departments} }) {
105 $form->{selectdepartment} = "<option>\n";
107 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
112 $lxdebug->leave_sub();
117 $lxdebug->enter_sub();
119 GL->transaction(\%myconfig, \%$form);
121 map { if ($form->{debitaccno} eq $_->{accno}) {$form->{debitchart} .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} };
122 map { if ($form->{creditaccno} eq $_->{accno}) {$form->{creditchart} .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} };
123 map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
125 if ($form->{creditrowcount} > 2) {
126 for $i (2 .. $form->{creditrowcount}) {
127 map { if ($form->{"creditchartselected_$i"} eq $_->{accno}) {$form->{"creditchartselected_$i"} = "$_->{accno}--$_->{taxkey_id}" }} @{ $form->{chart} };
128 map { if ($form->{"taxchartselected_$i"} eq $_->{taxkey}) {$form->{"taxchartselected_$i"} = "$_->{taxkey}--$_->{rate}" }} @{ $form->{TAX} };
131 if ($form->{debitrowcount} > 2) {
132 for $i (2 .. $form->{debitrowcount}) {
133 map { if ($form->{"debitchartselected_$i"} eq $_->{accno}) {$form->{"debitchartselected_$i"} = "$_->{accno}--$_->{taxkey_id}" }} @{ $form->{chart} };
134 map { if ($form->{"taxchartselected_$i"} eq $_->{taxkey}) {$form->{"taxchartselected_$i"} = "$_->{taxkey}--$_->{rate}" }} @{ $form->{TAX} };
137 map { $chart .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>" } @{ $form->{chart} };
138 $form->{chart} = $chart;
139 map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
140 $form->{taxchart} = $tax;
142 if ($form->{tax} < 0) {
143 $form->{tax} = $form->{tax} * (-1);
146 $form->{amount}=$form->format_amount(\%myconfig, $form->{amount}, 2);
149 $form->all_departments(\%myconfig);
150 if (@{ $form->{all_departments} }) {
151 $form->{selectdepartment} = "<option>\n";
153 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
156 $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
158 $form->{title} = "Edit";
165 $lxdebug->leave_sub();
171 $lxdebug->enter_sub();
173 $form->{title} = $locale->text('Buchungsjournal');
175 $form->all_departments(\%myconfig);
177 if (@{ $form->{all_departments} }) {
178 $form->{selectdepartment} = "<option>\n";
180 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
185 <th align=right nowrap>|.$locale->text('Department').qq|</th>
186 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
188 | if $form->{selectdepartment};
190 # use JavaScript Calendar or not
191 $form->{jsscript} = $jscalendar;
193 if ($form->{jsscript})
195 # with JavaScript Calendar
197 <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
198 <input type=button name=datefrom id="trigger1" value=|.$locale->text('button').qq|></td>
201 <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
202 <input type=button name=dateto id="trigger2" value=|.$locale->text('button').qq|></td>
205 $jsscript = Form->write_trigger(\%myconfig,"2","datefrom","BR","trigger1","dateto","BL","trigger2");
209 # without JavaScript Calendar
210 $button1 = qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
211 $button2 = qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
219 <form method=post action=$form->{script}>
221 <input type=hidden name=sort value=transdate>
225 <th class=listtop>$form->{title}</th>
232 <th align=right>|.$locale->text('Reference').qq|</th>
233 <td><input name=reference size=20></td>
234 <th align=right>|.$locale->text('Source').qq|</th>
235 <td><input name=source size=20></td>
239 <th align=right>|.$locale->text('Description').qq|</th>
240 <td colspan=3><input name=description size=40></td>
243 <th align=right>|.$locale->text('Notes').qq|</th>
244 <td colspan=3><input name=notes size=40></td>
247 <th align=right>|.$locale->text('From').qq|</th>
252 <th align=right>|.$locale->text('Include in Report').qq|</th>
257 <input name="category" class=radio type=radio value=X checked> |.$locale->text('All').qq|
258 <input name="category" class=radio type=radio value=A> |.$locale->text('Asset').qq|
259 <input name="category" class=radio type=radio value=L> |.$locale->text('Liability').qq|
260 <input name="category" class=radio type=radio value=I> |.$locale->text('Revenue').qq|
261 <input name="category" class=radio type=radio value=E> |.$locale->text('Expense').qq|
267 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
268 <td>|.$locale->text('ID').qq|</td>
269 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
270 <td>|.$locale->text('Date').qq|</td>
271 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
272 <td>|.$locale->text('Reference').qq|</td>
273 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
274 <td>|.$locale->text('Description').qq|</td>
275 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
276 <td>|.$locale->text('Notes').qq|</td>
279 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
280 <td>|.$locale->text('Debit').qq|</td>
281 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
282 <td>|.$locale->text('Credit').qq|</td>
283 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
284 <td>|.$locale->text('Source').qq|</td>
285 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
286 <td>|.$locale->text('Account').qq|</td>
287 <td align=right><input name="l_gifi_accno" class=checkbox type=checkbox value=Y></td>
288 <td>|.$locale->text('GIFI').qq|</td>
291 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
292 <td>|.$locale->text('Subtotal').qq|</td>
302 <td><hr size=3 noshade></td>
308 <input type=hidden name=nextsub value=generate_report>
310 <input type=hidden name=path value=$form->{path}>
311 <input type=hidden name=login value=$form->{login}>
312 <input type=hidden name=password value=$form->{password}>
315 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
321 $lxdebug->leave_sub();
325 sub generate_report {
326 $lxdebug->enter_sub();
328 $form->{sort} = "transdate" unless $form->{sort};
330 GL->all_transactions(\%myconfig, \%$form);
332 $callback = "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
336 %acctype = ( 'A' => $locale->text('Asset'),
337 'C' => $locale->text('Contra'),
338 'L' => $locale->text('Liability'),
339 'Q' => $locale->text('Equity'),
340 'I' => $locale->text('Revenue'),
341 'E' => $locale->text('Expense'),
344 $form->{title} = $locale->text('General Ledger');
346 $ml = ($form->{ml} =~ /(A|E)/) ? -1 : 1;
348 unless ($form->{category} eq 'X') {
349 $form->{title} .= " : ".$locale->text($acctype{$form->{category}});
351 if ($form->{accno}) {
352 $href .= "&accno=".$form->escape($form->{accno});
353 $callback .= "&accno=".$form->escape($form->{accno},1);
354 $option = $locale->text('Account')." : $form->{accno} $form->{account_description}";
356 if ($form->{gifi_accno}) {
357 $href .= "&gifi_accno=".$form->escape($form->{gifi_accno});
358 $callback .= "&gifi_accno=".$form->escape($form->{gifi_accno},1);
359 $option .= "\n<br>" if $option;
360 $option .= $locale->text('GIFI')." : $form->{gifi_accno} $form->{gifi_account_description}";
362 if ($form->{source}) {
363 $href .= "&source=".$form->escape($form->{source});
364 $callback .= "&source=".$form->escape($form->{source},1);
365 $option .= "\n<br>" if $option;
366 $option .= $locale->text('Source')." : $form->{source}";
368 if ($form->{reference}) {
369 $href .= "&reference=".$form->escape($form->{reference});
370 $callback .= "&reference=".$form->escape($form->{reference},1);
371 $option .= "\n<br>" if $option;
372 $option .= $locale->text('Reference')." : $form->{reference}";
374 if ($form->{department}) {
375 $href .= "&department=".$form->escape($form->{department});
376 $callback .= "&department=".$form->escape($form->{department},1);
377 ($department) = split /--/, $form->{department};
378 $option .= "\n<br>" if $option;
379 $option .= $locale->text('Department')." : $department";
382 if ($form->{description}) {
383 $href .= "&description=".$form->escape($form->{description});
384 $callback .= "&description=".$form->escape($form->{description},1);
385 $option .= "\n<br>" if $option;
386 $option .= $locale->text('Description')." : $form->{description}";
388 if ($form->{notes}) {
389 $href .= "¬es=".$form->escape($form->{notes});
390 $callback .= "¬es=".$form->escape($form->{notes},1);
391 $option .= "\n<br>" if $option;
392 $option .= $locale->text('Notes')." : $form->{notes}";
395 if ($form->{datefrom}) {
396 $href .= "&datefrom=$form->{datefrom}";
397 $callback .= "&datefrom=$form->{datefrom}";
398 $option .= "\n<br>" if $option;
399 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{datefrom}, 1);
401 if ($form->{dateto}) {
402 $href .= "&dateto=$form->{dateto}";
403 $callback .= "&dateto=$form->{dateto}";
404 if ($form->{datefrom}) {
407 $option .= "\n<br>" if $option;
409 $option .= $locale->text('Bis')." ".$locale->date(\%myconfig, $form->{dateto}, 1);
413 @columns = $form->sort_columns(qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno));
415 if ($form->{accno} || $form->{gifi_accno}) {
416 @columns = grep !/(accno|gifi_accno)/, @columns;
417 push @columns, "balance";
418 $form->{l_balance} = "Y";
422 $form->{l_credit_accno} = "Y";
423 $form->{l_debit_accno} = "Y";
424 $form->{l_credit_tax} = "Y";
425 $form->{l_debit_tax} = "Y";
426 $form->{l_credit_tax_accno} = "Y";
427 $form->{l_debit_tax_accno} = "Y";
428 $form->{l_accno} = "N";
429 foreach $item (@columns) {
430 if ($form->{"l_$item"} eq "Y") {
431 push @column_index, $item;
433 # add column to href and callback
434 $callback .= "&l_$item=Y";
435 $href .= "&l_$item=Y";
439 if ($form->{l_subtotal} eq 'Y') {
440 $callback .= "&l_subtotal=Y";
441 $href .= "&l_subtotal=Y";
444 $callback .= "&category=$form->{category}";
445 $href .= "&category=$form->{category}";
447 $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
448 $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
449 $column_header{reference} = "<th><a class=listheading href=$href&sort=reference>".$locale->text('Reference')."</a></th>";
450 $column_header{source} = "<th><a class=listheading href=$href&sort=source>".$locale->text('Source')."</a></th>";
451 $column_header{description} = "<th><a class=listheading href=$href&sort=description>".$locale->text('Description')."</a></th>";
452 $column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
453 $column_header{debit} = "<th class=listheading>".$locale->text('Debit')."</th>";
454 $column_header{debit_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Account')."</a></th>";
455 $column_header{credit} = "<th class=listheading>".$locale->text('Credit')."</th>";
456 $column_header{credit_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Account')."</a></th>";
457 $column_header{debit_tax} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Tax')."</a></th>";
458 $column_header{debit_tax_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Tax Account')."</a></th>";
459 $column_header{credit_tax} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Tax')."</a></th>";
460 $column_header{credit_tax_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Tax Account')."</a></th>";
461 $column_header{gifi_accno} = "<th><a class=listheading href=$href&sort=gifi_accno>".$locale->text('GIFI')."</a></th>";
462 $column_header{balance} = "<th>".$locale->text('Balance')."</th>";
464 $form->{landscape} = 1;
473 <th class=listtop>$form->{title}</th>
483 <tr class=listheading>
486 map { print "$column_header{$_}\n" } @column_index;
495 # add sort to callback
496 $form->{callback} = "$callback&sort=$form->{sort}";
497 $callback = $form->escape($form->{callback});
499 # initial item for subtotals
500 if (@{ $form->{GL} }) {
501 $sameitem = $form->{GL}->[0]->{$form->{sort}};
504 if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
506 map { $column_data{$_} = "<td> </td>" } @column_index;
507 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
513 map { print "$column_data{$_}\n" } @column_index;
520 foreach $ref (@{ $form->{GL} }) {
522 # if item ne sort print subtotal
523 if ($form->{l_subtotal} eq 'Y') {
524 if ($sameitem ne $ref->{$form->{sort}}) {
528 foreach $key (sort keys (%{$ref->{amount}})) {
529 $form->{balance} += $ref->{amount}{$key};
533 foreach $key (sort keys (%{$ref->{debit}})) {
534 $subtotaldebit += $ref->{debit}{$key};
535 $totaldebit += $ref->{debit}{$key};
537 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
539 $debit .= "<br>".$form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
544 foreach $key (sort keys (%{$ref->{credit}})) {
545 $subtotalcredit += $ref->{credit}{$key};
546 $totalcredit += $ref->{credit}{$key};
548 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
550 $credit .= "<br>".$form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
555 foreach $key (sort keys (%{$ref->{debit_tax}})) {
556 $subtotaldebittax += $ref->{debit_tax}{$key};
557 $totaldebittax += $ref->{debit_tax}{$key};
559 $debittax = $form->format_amount(\%myconfig, $ref->{debit_tax}{$key} , 2, 0);
561 $debittax .= "<br>".$form->format_amount(\%myconfig, $ref->{debit_tax}{$key} , 2, 0);
566 foreach $key (sort keys (%{$ref->{credit_tax}})) {
567 $subtotalcredittax += $ref->{credit_tax}{$key};
568 $totalcredittax += $ref->{credit_tax}{$key};
570 $credittax = $form->format_amount(\%myconfig, $ref->{credit_tax}{$key} , 2, 0);
572 $credittax .= "<br>".$form->format_amount(\%myconfig, $ref->{credit_tax}{$key} , 2, 0);
579 foreach $key (sort keys (%{$ref->{debit_accno}})) {
581 $debitaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
583 $debitaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
585 if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
586 $ref->{debit_tax_accno}{$key} = $taxaccno;
588 $taxaccno = $ref->{debit_tax_accno}{$key};
589 $debittaxkey = $ref->{debit_taxkey}{$key};
595 foreach $key (sort keys (%{$ref->{credit_accno}})) {
597 $creditaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
599 $creditaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
601 if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
602 $ref->{credit_tax_accno}{$key} = $taxaccno;
604 $taxaccno = $ref->{credit_tax_accno}{$key};
605 $credittaxkey = $ref->{credit_taxkey}{$key};
609 foreach $key (sort keys (%{$ref->{debit_tax_accno}})) {
611 $debittaxaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
613 $debittaxaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
617 $credittaxaccno = "";
618 foreach $key (sort keys (%{$ref->{credit_tax_accno}})) {
620 $credittaxaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
622 $credittaxaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
625 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
626 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
628 $column_data{id} = "<td align=right> $ref->{id} </td>";
629 $column_data{transdate} = "<td align=center> $ref->{transdate} </td>";
630 $column_data{reference} = "<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>";
631 $column_data{description} = "<td align=center>$ref->{description} </td>";
632 $column_data{source} = "<td align=center>$ref->{source} </td>";
633 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
634 $column_data{debit} = "<td align=right>$debit</td>";
635 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
636 $column_data{credit} = "<td align=right>$credit</td>";
637 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
638 $column_data{debit_tax} = ($ref->{debit_tax_accno} ne "") ? "<td align=right>$debittax</td>" : "<td></td>";
639 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
640 $column_data{gifi_accno} = "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
641 $column_data{credit_tax} = ($ref->{credit_tax_accno} ne "") ? "<td align=right>$credittax</td>" : "<td></td>";
642 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
643 $column_data{gifi_accno} = "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
644 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
648 <tr class=listrow$i>";
649 map { print "$column_data{$_}\n" } @column_index;
655 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
658 map { $column_data{$_} = "<td> </td>" } @column_index;
660 $column_data{debit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebit, 2, " ")."</th>";
661 $column_data{credit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredit, 2, " ")."</th>";
662 $column_data{debit_tax} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebittax, 2, " ")."</th>";
663 $column_data{credit_tax} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredittax, 2, " ")."</th>";
664 $column_data{balance} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</th>";
670 map { print "$column_data{$_}\n" } @column_index;
679 <td><hr size=3 noshade></td>
685 <form method=post action=$form->{script}>
687 <input name=callback type=hidden value="$form->{callback}">
689 <input type=hidden name=path value=$form->{path}>
690 <input type=hidden name=login value=$form->{login}>
691 <input type=hidden name=password value=$form->{password}>
693 <input class=submit type=submit name=action value="|.$locale->text('GL Transaction').qq|">
694 <input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|">
695 <input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|">
696 <input class=submit type=submit name=action value="|.$locale->text('Sales Invoice').qq|">
697 <input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice').qq|">|;
700 if ($form->{menubar}) {
701 require "$form->{path}/menu.pl";
713 $lxdebug->leave_sub();
718 $lxdebug->enter_sub();
720 $subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
721 $subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
723 map { $column_data{$_} = "<td> </td>" } qw(transdate id reference source description accno);
724 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
725 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
728 print "<tr class=listsubtotal>";
729 map { print "$column_data{$_}\n" } @column_index;
735 $sameitem = $ref->{$form->{sort}};
737 $lxdebug->leave_sub();
744 $lxdebug->enter_sub();
748 @flds = (qw(accno debit credit projectnumber project_id oldprojectnumber));
749 $credit_save = $form->{credit};
750 $debit_save = $form->{debit};
752 if ($form->{chart} eq "") {
753 $form->{creditchart} = "<option>".$form->{creditchartselected}."</option>";
754 $form->{debitchart} = "<option>".$form->{debitchartselected}."</option>";
756 $form->{creditchart} = $form->{chart};
757 $form->{creditchart} =~ s/value=\"$form->{creditchartselected}\"/value=\"$form->{creditchartselected}\" selected/;
759 $form->{debitchart} = $form->{chart};
760 $form->{debitchart} =~ s/value=\"$form->{debitchartselected}\"/value=\"$form->{debitchartselected}\" selected/;
762 ($debitaccno, $debittaxkey) = split(/--/, $form->{debitchartselected});
763 ($creditaccno, $credittaxkey) = split(/--/, $form->{creditchartselected});
764 if ($debittaxkey >0) {
765 $form->{taxchart} = $form->unescape($form->{taxchart});
766 $form->{taxchart} =~ s/selected//ig;
767 $form->{taxchart} =~ s/\"$debittaxkey--([^\"]*)\"/\"$debittaxkey--$1\" selected/;
771 if ($form->{taxincluded}) {
772 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1);
773 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
774 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1) * $rate;
776 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
777 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * ($rate + 1);
778 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) * $rate;
781 $form->{taxchart} = $form->unescape($form->{taxchart});
782 $form->{taxchart} =~ s/selected//ig;
783 $form->{taxchart} =~ s/\"$credittaxkey--([^\"]*)\"/\"$credittaxkey--$1\" selected/;
786 if ($form->{taxincluded}) {
787 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
788 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1);
789 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1) * $rate;
791 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * ($rate + 1);
792 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
793 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) * $rate;
796 if ($form->{credit_splited}) {
797 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
798 $form->{credit} = $credit_save;
800 } elsif ($form->{debit_splited}) {
801 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
802 $form->{debit} = $debit_save;
809 $lxdebug->leave_sub();
814 $lxdebug->enter_sub();
818 # for $i (1 .. $form->{rowcount}) {
819 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
820 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
827 $lxdebug->leave_sub();
834 $lxdebug->enter_sub();
836 $title = $form->{title};
837 $form->{title} = $locale->text("$title General Ledger Transaction");
838 $readonly = ($form->{id}) ? "readonly" : "";
840 $form->{urldebit} = "$form->{script}?action=split_debit&path=$form->{path}&login=$form->{login}&password=$form->{password}";
841 $form->{urlcredit} = "$form->{script}?action=split_credit&path=$form->{path}&login=$form->{login}&password=$form->{password}";
842 # $locale->text('Add General Ledger Transaction')
843 # $locale->text('Edit General Ledger Transaction')
844 map { $form->{$_} =~ s/\"/"/g } qw(reference description chart);
846 $form->{selectdepartment} =~ s/ selected//;
847 $form->{taxchart} =~ s/ selected//;
848 $form->{selectdepartment} =~ s/option>\Q$form->{department}\E/option selected>$form->{department}/;
850 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
851 $description = qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
853 $description = qq|<input name=description size=50 value="$form->{description}" tabindex="3" $readonly>|;
856 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
859 $taxincluded = "checked";
862 $amount = qq|<input name=amount size=20 value="$form->{amount}" tabindex="4" $readonly>|;
867 <th align=right nowrap>|.$locale->text('Department').qq|</th>
868 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
869 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
871 | if $form->{selectdepartment};
873 $form->{fokus} = "gl.reference";
876 # use JavaScript Calendar or not
877 $form->{jsscript} = $jscalendar;
879 if ($form->{jsscript})
881 # with JavaScript Calendar
883 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate} tabindex="2" $readonly></td>
884 <td><input type=button name=transdate id="trigger1" value=|.$locale->text('button').qq|></td>
887 $jsscript = Form->write_trigger(\%myconfig,"1","transdate","BL","trigger1","","","");
891 # without JavaScript Calendar
892 $button1 = qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate} tabindex="2" $readonly></td>|;
899 <body onLoad="fokus()">
901 <form method=post name="gl" action=$form->{script}>
903 <input name=id type=hidden value=$form->{id}>
905 <input type=hidden name=closedto value=$form->{closedto}>
906 <input type=hidden name=locked value=$form->{locked}>
907 <input type=hidden name=title value="$title">
908 <input type=hidden name=taxchart value=|.$form->escape($form->{taxchart}).qq|>
909 <input type=hidden name=chart value="$form->{chart}">
910 <input type=hidden name=creditrowcount value="$form->{creditrowcount}">
911 <input type=hidden name=debitrowcount value="$form->{debitrowcount}">
916 <th class=listtop>$form->{title}</th>
923 <th align=right>|.$locale->text('Reference').qq|</th>
924 <td><input name=reference size=20 value="$form->{reference}" tabindex="1" $readonly></td>
928 <th align=right nowrap>|.$locale->text('Date').qq|</th>
937 <th align=right>|.$locale->text('Belegnummer').qq|</th>
938 <td><input name=id size=20 value="$form->{id}" $readonly></td>
942 <th align=right width=50%>|.$locale->text('Buchungsdatum').qq|</th>
943 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly></td>
954 <th align=right>|.$locale->text('Description').qq|</th>
955 <td>$description</td>
959 <th align=right width=50%>|.$locale->text('Mitarbeiter').qq|</th>
960 <td align=left><input name=employee size=11 value=$form->{employee} $readonly></td>
968 <th align=right>|.$locale->text('Description').qq|</th>
969 <td colspan=3>$description</td>
974 <th align=right>|.$locale->text('Betrag').qq|</th>
976 <td align=left colspan=2>
979 <th align=left>|.$locale->text('MwSt. inkl.').qq|</th>
980 <td><input type=checkbox name=taxincluded value=1 tabindex="8" $taxincluded></td>
985 if ($form->{debit_splited}) {
988 <th align=right>|.$locale->text('Debit').qq|</th>
989 <td>Betrag gesplittet</td>
990 <td><input name=debit size=10 value="|.$form->format_amount(\%myconfig, $form->{debit}, 2).qq|" readonly> EUR</td>
991 <td><input class=submit type=submit name=action value="|.$locale->text('Split Debit').qq|"></td>
992 <input name=debit_splited type=hidden size=10 value=$form->{debit_splited}>
995 <th align=right>|.$locale->text('Credit').qq|</th>
996 <td><select name=creditchartselected tabindex="6">$form->{creditchart}</select></td>
997 <td><input name=credit size=10 value="|.$form->format_amount(\%myconfig, $form->{credit},2).qq|" readonly > EUR</td>
998 <input name=credit_splited type=hidden size=10 value=$form->{credit_splited}>
1001 } elsif ($form->{credit_splited}) {
1004 <th align=right>|.$locale->text('Debit').qq|</th>
1005 <td><select name=debitchartselected tabindex="6">$form->{debitchart}</select></td>
1006 <td><input name=debit size=10 value="|.$form->format_amount(\%myconfig, $form->{debit}, 2).qq|" readonly> EUR</td>
1007 <input name=debit_splited type=hidden size=10 value=$form->{debit_splited}>
1010 <th align=right>|.$locale->text('Credit').qq|</th>
1011 <td>Betrag gesplittet</td>
1012 <td><input name=credit size=10 value="|.$form->format_amount(\%myconfig, $form->{credit},2).qq|" readonly > EUR</td>
1013 <td><input class=submit type=submit name=action value="|.$locale->text('Split Credit').qq|"></td>
1014 <input name=credit_splited type=hidden size=10 value=$form->{credit_splited}>
1019 <th align=right>|.$locale->text('Debit').qq|</th>
1020 <td><select name=debitchartselected tabindex="6">$form->{debitchart}</select></td>
1021 <td><input name=debit size=10 value="|.$form->format_amount(\%myconfig, $form->{debit}, 2).qq|" readonly> EUR</td>
1022 <td><input class=submit type=submit name=action value="|.$locale->text('Split Debit').qq|"></td>
1023 <input name=debit_splited type=hidden size=10 value=$form->{debit_splited}>
1026 <th align=right>|.$locale->text('Credit').qq|</th>
1027 <td><select name=creditchartselected tabindex="6">$form->{creditchart}</select></td>
1028 <td><input name=credit size=10 value="|.$form->format_amount(\%myconfig, $form->{credit},2).qq|" readonly > EUR</td>
1029 <td><input class=submit type=submit name=action value="|.$locale->text('Split Credit').qq|"></td>
1030 <input name=credit_splited type=hidden size=10 value=$form->{credit_splited}>
1033 <th align=right>|.$locale->text('Tax').qq|</th>
1034 <td><select name=taxchartselected tabindex="7">$form->{taxchart}</select></td>
1035 <td><input name=tax size=10 value="|.$form->format_amount(\%myconfig, $form->{tax},2).qq|" readonly > EUR</td>
1044 <td><hr size=3 noshade></td>
1049 $lxdebug->leave_sub();
1054 $lxdebug->enter_sub();
1055 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1057 $decimalplaces = ($dec > 2) ? $dec : 2;
1058 $taxrowcount = ($form->{creditrowcount} > $form->{debitrowcount}) ? $form->{creditrowcount} : $form->{debitrowcount};
1059 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate})? 1 : 0;
1061 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces, " ") } qw(totaldebit totalcredit);
1066 for $i (2 .. $form->{creditrowcount}) {
1068 <input type=hidden name=creditchartselected_$i value="$form->{"creditchartselected_$i"}">
1069 <input type=hidden name=credit_$i value="$form->{"credit_$i"}">
1072 for $i (2 .. $form->{debitrowcount}) {
1074 <input type=hidden name=debitchartselected_$i value="$form->{"debitchartselected_$i"}">
1075 <input type=hidden name=debit_$i value="$form->{"debit_$i"}">
1078 if ($taxrowcount > 1) {
1079 for $i (2 .. $taxrowcount) {
1081 <input type=hidden name=taxchartselected_$i value="$form->{"taxchartselected_$i"}">
1082 <input type=hidden name=tax_$i value="$form->{"tax_$i"}">
1087 <input type=hidden name=path value=$form->{path}>
1088 <input type=hidden name=login value=$form->{login}>
1089 <input type=hidden name=password value=$form->{password}>
1091 <input name=callback type=hidden value="$form->{callback}">
1095 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1096 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1100 print qq|<input class=submit type=submit name=action value="|.$locale->text('Storno').qq|">|;
1102 # Löschen und ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1106 if (!$form->{locked} && $radieren) {
1108 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|" accesskey="b">
1109 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">|;
1113 # if ($transdate > $closedto) {
1115 # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
1118 if ($transdate > $closedto) {
1119 print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
1120 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
1124 if ($form->{menubar}) {
1125 require "$form->{path}/menu.pl";
1136 $lxdebug->leave_sub();
1141 $lxdebug->enter_sub();
1148 <form method=post action=$form->{script}>
1151 map { $form->{$_} =~ s/\"/"/g } qw(reference description chart);
1153 delete $form->{header};
1155 foreach $key (keys %$form) {
1156 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1160 <h2 class=confirm>|.$locale->text('Confirm!').qq|</h2>
1162 <h4>|.$locale->text('Are you sure you want to delete Transaction').qq| $form->{reference}</h4>
1164 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
1168 $lxdebug->leave_sub();
1173 $lxdebug->enter_sub();
1175 $form->redirect($locale->text('Transaction deleted!')) if (GL->delete_transaction(\%myconfig, \%$form));
1176 $form->error($locale->text('Cannot delete transaction!'));
1178 $lxdebug->leave_sub();
1183 $lxdebug->enter_sub();
1184 # check if there is something in reference and date
1185 $form->isblank("reference", $locale->text('Reference missing!'));
1186 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1187 $form->isblank("description", $locale->text('Description missing!'));
1189 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1190 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1192 ($debitaccno, $debittaxkey) = split(/--/, $form->{debitchartselected});
1193 ($creditaccno, $credittaxkey) = split(/--/, $form->{creditchartselected});
1195 $credit_save = $form->{credit};
1196 $debit_save = $form->{debit};
1200 ($taxkey, $taxrate) = split(/--/, $form->{taxchartselected});
1202 if ($debittaxkey >0) {
1203 $form->{taxchart} = $form->unescape($form->{taxchart});
1204 $form->{taxchart} =~ s/\"$debittaxkey--([^\"]*)\"/\"$debittaxkey--$1\"/;
1206 $rate = ($form->{taxchart} =~ /selected/) ? $taxrate : $1;
1207 $form->{taxkey} = ($form->{taxchart} =~ /selected/) ? $taxkey : $debittaxkey;
1209 if ($form->{storno}) {
1210 $form->{debit} = $form->parse_amount(\%myconfig, $form->{debit});
1211 $form->{credit} = $form->parse_amount(\%myconfig, $form->{credit});
1212 $form->{tax} = $form->parse_amount(\%myconfig, $form->{tax});
1214 if ($form->{taxincluded}) {
1215 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1);
1216 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
1217 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1) * $rate;
1219 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
1220 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * ($rate + 1);
1221 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) * $rate;
1224 $form->{debittaxkey}=1;
1227 $form->{taxchart} = $form->unescape($form->{taxchart});
1228 $form->{taxchart} =~ s/\"$credittaxkey--([^\"]*)\"/\"$credittaxkey--$1\"/;
1231 $rate = ($form->{taxchart} =~ /selected/) ? $taxrate : $1;
1232 $form->{taxkey} = ($form->{taxchart} =~ /selected/) ? $taxkey : $credittaxkey;
1234 if ($form->{storno}) {
1235 $form->{debit} = $form->parse_amount(\%myconfig, $form->{debit});
1236 $form->{credit} = $form->parse_amount(\%myconfig, $form->{credit});
1237 $form->{tax} = $form->parse_amount(\%myconfig, $form->{tax});
1239 if ($form->{taxincluded}) {
1240 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
1241 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1);
1242 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) / ($rate + 1) * $rate;
1244 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * ($rate + 1);
1245 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
1246 $form->{tax} = $form->parse_amount(\%myconfig, $form->{amount}) * $rate;
1249 $form->{debittaxkey}=0;
1252 if ($form->{credit_splited}) {
1253 $form->{debit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
1254 $form->{credit} = $credit_save;
1256 } elsif ($form->{debit_splited}) {
1257 $form->{credit} = $form->parse_amount(\%myconfig, $form->{amount}) * 1;
1258 $form->{debit} = $debit_save;
1263 # this is just for the wise guys
1264 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
1265 $form->error($locale->text('Soll- und Habenkonto sind gleich!')) if ($debitaccno eq $creditaccno);
1266 $form->error($locale->text('Keine Steuerautomatik möglich!')) if ($debittaxkey && $credittaxkey && !($taxkey == 0));
1268 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1270 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1271 $err[2] = $locale->text('Debit and credit out of balance!');
1272 $err[3] = $locale->text('Cannot post a transaction without a value!');
1274 $form->error($err[$errno]);
1276 undef($form->{callback});
1277 $form->redirect("Buchung gespeichert. Buchungsnummer = ".$form->{id});
1279 $lxdebug->leave_sub();
1284 $lxdebug->enter_sub();
1289 $lxdebug->leave_sub();
1293 $lxdebug->enter_sub();
1299 $lxdebug->leave_sub();
1303 $lxdebug->enter_sub();
1305 $form->{old_callback} = $form->escape($form->{callback},1);
1306 $form->{callback} = $form->escape("$form->{script}?action=update",1);
1308 delete $form->{action};
1309 # save all other form variables in a previousform variable
1310 foreach $key (keys %$form) {
1312 $form->{$key} =~ s/&/%26/g;
1313 $previousform .= qq|$key=$form->{$key}&|;
1316 $previousform = $form->escape($previousform, 1);
1317 if (!$form->{debitpost}) {
1318 $form->{debitpost} = $form->{amount};
1320 $form->{previousform} = $previousform;
1321 &display_split_debit();
1324 $lxdebug->leave_sub();
1328 $lxdebug->enter_sub();
1330 $form->{old_callback} = $form->escape($form->{callback},1);
1331 $form->{callback} = $form->escape("$form->{script}?action=update",1);
1333 delete $form->{action};
1334 # save all other form variables in a previousform variable
1335 foreach $key (keys %$form) {
1337 $form->{$key} =~ s/&/%26/g;
1338 $previousform .= qq|$key=$form->{$key}&|;
1341 $previousform = $form->escape($previousform, 1);
1342 if (!$form->{creditpost}) {
1343 $form->{creditpost} = $form->{amount};
1345 $form->{previousform} = $previousform;
1346 &display_split_credit();
1347 $lxdebug->leave_sub();
1350 sub display_split_credit {
1351 $lxdebug->enter_sub();
1352 $form->{taxchart} = $form->unescape($form->{taxchart});
1358 <form method=post name=split_credit action=gl.pl>
1359 |.$locale->text('Credit').qq|: |.$form->format_amount(\%myconfig, $form->{amount},2).qq| EUR<br>
1360 |.$locale->text('Still to post').qq|:<input name=creditpost size=10 value="|.$form->format_amount(\%myconfig, $form->{creditpost},2).qq|"> EUR<br>
1361 <script type="text/javascript">
1362 function update_stilltopost (betrag){
1363 remaining = parseFloat(document.split_credit.creditpost.value) - parseFloat(betrag);
1364 document.split_credit.creditpost.value= remaining;
1369 for $i (2 .. $form->{creditrowcount}) {
1370 $form->{"creditchart_$i"} = $form->{chart};
1371 $form->{"creditchart_$i"} =~ s/value=\"$form->{"creditchartselected_$i"}\"/value=\"$form->{"creditchartselected_$i"}\" selected/;
1373 $form->{"taxchart_$i"} = $form->{taxchart};
1374 $form->{"taxchart_$i"} =~ s/value=\"$form->{"taxchartselected_$i"}\"/value=\"$form->{"taxchartselected_$i"}\" selected/;
1379 <th>Position $position</th>
1380 <td><select name=creditchartselected_$i>$form->{"creditchart_$i"}</select></td>
1381 <th align=right>|.$locale->text('Amount').qq| $1</th>
1382 <td><input name=credit_$i size=10 value="|.$form->format_amount(\%myconfig, $form->{"credit_$i"},2).qq|" onBlur="update_stilltopost(this.value)"> EUR</td>
1386 <td><select name=taxchartselected_$i>$form->{"taxchart_$i"}</select></td>
1387 <th align=right>|.$locale->text('Tax').qq|</th>
1388 <td><input name=tax_$i size=10 value="|.$form->format_amount(\%myconfig, $form->{"tax_$i"},2).qq|"> EUR</td>
1389 <td><input type=checkbox name=tax_manual_$i value=1> Steuerkorrektur</td>
1395 <td colspan=5><hr size=3 noshade></td>
1402 <input type=hidden name=previousform value="$form->{previousform}">
1404 <input type=hidden name=path value=$form->{path}>
1405 <input type=hidden name=login value=$form->{login}>
1406 <input type=hidden name=password value=$form->{password}>
1407 <input type=hidden name=callback value=$form->{callback}>
1408 <input type=hidden name=old_callback value=$form->{old_callback}>
1409 <input type=hidden name=amount value=$form->{amount}>
1410 <input type=hidden name=credit_splited value=1>
1411 <input type=hidden name=creditrowcount value="$form->{creditrowcount}">
1412 <input type=hidden name=chart value=|.$form->escape($form->{chart}).qq|>
1413 <input type=hidden name=taxchart value=|.$form->escape($form->{taxchart}).qq|>
1415 <input class=submit type=submit name=action value="|.$locale->text('New Account').qq|">
1416 <input class=submit type=submit name=action value="|.$locale->text('Close').qq|">
1423 $lxdebug->leave_sub();
1426 sub display_split_debit {
1427 $lxdebug->enter_sub();
1428 $form->{taxchart} = $form->unescape($form->{taxchart});
1434 <form method=post name=split_debit action=gl.pl>
1435 |.$locale->text('Debit').qq|: |.$form->format_amount(\%myconfig, $form->{amount},2).qq| EUR<br>
1436 |.$locale->text('Still to post').qq|:<input name=debitpost size=10 value="|.$form->format_amount(\%myconfig, $form->{debitpost},2).qq|"> EUR<br>
1437 <script type="text/javascript">
1438 function update_stilltopost (betrag){
1439 remaining = parseFloat(document.split_debit.debitpost.value) - parseFloat(betrag);
1440 document.split_debit.debitpost.value= remaining;
1445 for $i (2 .. $form->{debitrowcount}) {
1446 $form->{"debitchart_$i"} = $form->{chart};
1447 $form->{"debitchart_$i"} =~ s/value=\"$form->{"debitchartselected_$i"}\"/value=\"$form->{"debitchartselected_$i"}\" selected/;
1449 $form->{"taxchart_$i"} = $form->{taxchart};
1450 $form->{"taxchart_$i"} =~ s/value=\"$form->{"taxchartselected_$i"}\"/value=\"$form->{"taxchartselected_$i"}\" selected/;
1455 <th>Position $position</th>
1456 <td><select name=debitchartselected_$i>$form->{"debitchart_$i"}</select></td>
1457 <th align=right>|.$locale->text('Amount').qq| $1</th>
1458 <td><input name=debit_$i size=10 value="|.$form->format_amount(\%myconfig, $form->{"debit_$i"},2).qq|" onBlur="update_stilltopost(this.value)"> EUR</td>
1462 <td><select name=taxchartselected_$i>$form->{"taxchart_$i"}</select></td>
1463 <th align=right>|.$locale->text('Tax').qq|</th>
1464 <td><input name=tax_$i size=10 value="|.$form->format_amount(\%myconfig, $form->{"tax_$i"},2).qq|"> EUR</td>
1465 <td><input type=checkbox name=tax_manual_$i value=1> Steuerkorrektur</td>
1471 <td colspan=5><hr size=3 noshade></td>
1478 <input type=hidden name=previousform value="$form->{previousform}">
1480 <input type=hidden name=path value=$form->{path}>
1481 <input type=hidden name=login value=$form->{login}>
1482 <input type=hidden name=password value=$form->{password}>
1483 <input type=hidden name=callback value=$form->{callback}>
1484 <input type=hidden name=old_callback value=$form->{old_callback}>
1485 <input type=hidden name=amount value=$form->{amount}>
1486 <input type=hidden name=debit_splited value=1>
1487 <input type=hidden name=debitrowcount value="$form->{debitrowcount}">
1488 <input type=hidden name=chart value=|.$form->escape($form->{chart}).qq|>
1489 <input type=hidden name=taxchart value=|.$form->escape($form->{taxchart}).qq|>
1491 <input class=submit type=submit name=action value="|.$locale->text('New Account').qq|">
1492 <input class=submit type=submit name=action value="|.$locale->text('Close').qq|">
1499 $lxdebug->leave_sub();
1503 $lxdebug->enter_sub();
1505 $form->{chart} = $form->unescape($form->{chart});
1507 if ($form->{credit_splited}) {
1508 $form->{creditpost} = $form->{amount};
1510 for $i (2 .. $form->{creditrowcount}) {
1511 $form->{"credit_$i"} = $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1512 $form->{creditpost} -= $form->{"credit_$i"};
1513 ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
1514 if ($form->{"tax_manual_$i"}) {
1515 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
1517 $form->{"tax_$i"} = $form->{"credit_$i"} * $taxrate;
1519 $form->{creditpost} -= $form->{"tax_$i"};
1522 if ($form->{"credit_$form->{creditrowcount}"}) {
1523 $form->{creditrowcount}++;
1526 &display_split_credit;
1528 if ($form->{debit_splited}) {
1529 $form->{debitpost} = $form->{amount};
1531 for $i (2 .. $form->{debitrowcount}) {
1532 $form->{"debit_$i"} = $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1533 $form->{debitpost} -= $form->{"debit_$i"};
1534 ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
1535 if ($form->{"tax_manual_$i"}) {
1536 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
1538 $form->{"tax_$i"} = $form->{"debit_$i"} * $taxrate;
1540 $form->{debitpost} -= $form->{"tax_$i"};
1543 if ($form->{"debit_$form->{debitrowcount}"}) {
1544 $form->{debitrowcount}++;
1547 &display_split_debit;
1549 $lxdebug->leave_sub();
1553 $lxdebug->enter_sub();
1555 # save the new form variables before splitting previousform
1556 map { $newform{$_} = $form->{$_} } keys %$form;
1558 $previousform = $form->unescape($form->{previousform});
1560 # don't trample on previous variables
1561 map { delete $form->{$_} } keys %newform;
1563 # now take it apart and restore original values
1564 foreach $item (split /&/, $previousform) {
1565 ($key, $value) = split /=/, $item, 2;
1566 $value =~ s/%26/&/g;
1567 $form->{$key} = $value;
1569 if ($newform{credit_splited}) {
1570 $form->{credit} = 0;
1571 $form->{credit_splited} = $newform{credit_splited};
1572 $form->{creditrowcount} = $newform{creditrowcount};
1573 for $i (2 .. $form->{creditrowcount}) {
1574 $form->{"creditchartselected_$i"} =$newform{"creditchartselected_$i"};
1575 $form->{"credit_$i"} =$newform{"credit_$i"};
1576 $form->{"credit_$i"} = $form->parse_amount(\%myconfig, $form->{"credit_$i"});
1577 $form->{"taxchartselected_$i"} =$newform{"taxchartselected_$i"};
1578 ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
1579 if ($newform{"tax_manual_$i"}) {
1580 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $newform{"tax_$i"});
1582 $form->{"tax_$i"} = $form->{"credit_$i"} * $taxrate;
1584 $form->{credit} += $form->round_amount($form->{"credit_$i"},2);
1585 $form->{credit} += $form->round_amount($form->{"tax_$i"},2);;
1590 $form->{debit_splited} = $newform{debit_splited};
1591 $form->{debitrowcount} = $newform{debitrowcount};
1592 for $i (2 .. $form->{debitrowcount}) {
1593 $form->{"debitchartselected_$i"} =$newform{"debitchartselected_$i"};
1594 $form->{"debit_$i"} =$newform{"debit_$i"};
1595 $form->{"debit_$i"} = $form->parse_amount(\%myconfig, $form->{"debit_$i"});
1596 $form->{"taxchartselected_$i"} =$newform{"taxchartselected_$i"};
1597 ($taxkey, $taxrate) = split(/--/, $form->{"taxchartselected_$i"});
1598 if ($newform{"tax_manual_$i"}) {
1599 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $newform{"tax_$i"});
1601 $form->{"tax_$i"} = $form->{"debit_$i"} * $taxrate;
1603 $form->{debit} += $form->round_amount($form->{"debit_$i"},2);
1604 $form->{debit} += $form->round_amount($form->{"tax_$i"},2);;
1607 delete $form->{action};
1608 $callback = $form->unescape($form->{callback});
1609 $form->{callback} = $form->unescape($form->{old_callback});
1610 delete $form->{old_callback};
1612 # put callback together
1613 foreach $key (keys %$form) {
1614 # do single escape for Apache 2.0
1615 $value = $form->escape($form->{$key}, 1);
1616 $callback .= qq|&$key=$value|;
1618 $form->{callback} = $callback;
1623 $lxdebug->leave_sub();