1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
38 require "$form->{path}/arap.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')
75 $form->{title} = "Add";
77 $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
79 # we use this only to set a default date
80 GL->transaction(\%myconfig, \%$form);
82 map { $chart .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>" } @{ $form->{chart} };
83 map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
85 $form->{chart} = $chart;
86 $form->{chartinit} = $chart;
87 $form->{rowcount} = 2;
89 $form->{debitchart} = $chart;
90 $form->{creditchart} = $chart;
91 $form->{taxchart} = $tax;
99 $form->all_departments(\%myconfig);
100 if (@{ $form->{all_departments} }) {
101 $form->{selectdepartment} = "<option>\n";
103 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
113 GL->transaction(\%myconfig, \%$form);
115 map { if ($form->{debitaccno} eq $_->{accno}) {$form->{debitchart} .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} };
116 map { if ($form->{creditaccno} eq $_->{accno}) {$form->{creditchart} .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} };
117 map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
119 $form->{chart} = $chart;
121 $form->{taxchart} = $tax;
123 if ($form->{tax} < 0) {
124 $form->{tax} = $form->{tax} * (-1);
127 $form->{amount}=$form->format_amount(\%myconfig, $form->{amount}, 2);
130 $form->all_departments(\%myconfig);
131 if (@{ $form->{all_departments} }) {
132 $form->{selectdepartment} = "<option>\n";
134 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
138 foreach $ref (@{ $form->{GL} }) {
139 $form->{"accno_$i"} = "$ref->{accno}--$ref->{description}";
141 $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
142 for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
144 if ($ref->{amount} < 0) {
145 $form->{totaldebit} -= $ref->{amount};
146 $form->{"debit_$i"} = $ref->{amount} * -1;
148 $form->{totalcredit} += $ref->{amount};
149 $form->{"credit_$i"} = $ref->{amount};
155 $form->{rowcount} = $i;
156 $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
158 $form->{title} = "Edit";
170 $form->{title} = $locale->text('Buchungsjournal');
172 $form->all_departments(\%myconfig);
174 if (@{ $form->{all_departments} }) {
175 $form->{selectdepartment} = "<option>\n";
177 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
182 <th align=right nowrap>|.$locale->text('Department').qq|</th>
183 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
185 | if $form->{selectdepartment};
187 # use JavaScript Calendar or not
188 $form->{jsscript} = $jscalendar;
190 if ($form->{jsscript})
192 # with JavaScript Calendar
194 <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
195 <input type=button name=datefrom id="trigger1" value=|.$locale->text('button').qq|></td>
198 <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
199 <input type=button name=dateto id="trigger2" value=|.$locale->text('button').qq|></td>
202 $jsscript = Form->write_trigger(\%myconfig,"2","datefrom","BR","trigger1","dateto","BL","trigger2");
206 # without JavaScript Calendar
207 $button1 = qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
208 $button2 = qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
216 <form method=post action=$form->{script}>
218 <input type=hidden name=sort value=transdate>
222 <th class=listtop>$form->{title}</th>
229 <th align=right>|.$locale->text('Reference').qq|</th>
230 <td><input name=reference size=20></td>
231 <th align=right>|.$locale->text('Source').qq|</th>
232 <td><input name=source size=20></td>
236 <th align=right>|.$locale->text('Description').qq|</th>
237 <td colspan=3><input name=description size=40></td>
240 <th align=right>|.$locale->text('Notes').qq|</th>
241 <td colspan=3><input name=notes size=40></td>
244 <th align=right>|.$locale->text('From').qq|</th>
249 <th align=right>|.$locale->text('Include in Report').qq|</th>
254 <input name="category" class=radio type=radio value=X checked> |.$locale->text('All').qq|
255 <input name="category" class=radio type=radio value=A> |.$locale->text('Asset').qq|
256 <input name="category" class=radio type=radio value=C> |.$locale->text('Contra').qq|
257 <input name="category" class=radio type=radio value=L> |.$locale->text('Liability').qq|
258 <input name="category" class=radio type=radio value=Q> |.$locale->text('Equity').qq|
259 <input name="category" class=radio type=radio value=I> |.$locale->text('Revenue').qq|
260 <input name="category" class=radio type=radio value=E> |.$locale->text('Expense').qq|
266 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
267 <td>|.$locale->text('ID').qq|</td>
268 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
269 <td>|.$locale->text('Date').qq|</td>
270 <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
271 <td>|.$locale->text('Reference').qq|</td>
272 <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
273 <td>|.$locale->text('Description').qq|</td>
274 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
275 <td>|.$locale->text('Notes').qq|</td>
278 <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
279 <td>|.$locale->text('Debit').qq|</td>
280 <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
281 <td>|.$locale->text('Credit').qq|</td>
282 <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
283 <td>|.$locale->text('Source').qq|</td>
284 <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
285 <td>|.$locale->text('Account').qq|</td>
286 <td align=right><input name="l_gifi_accno" class=checkbox type=checkbox value=Y></td>
287 <td>|.$locale->text('GIFI').qq|</td>
290 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
291 <td>|.$locale->text('Subtotal').qq|</td>
301 <td><hr size=3 noshade></td>
307 <input type=hidden name=nextsub value=generate_report>
309 <input type=hidden name=path value=$form->{path}>
310 <input type=hidden name=login value=$form->{login}>
311 <input type=hidden name=password value=$form->{password}>
314 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
323 sub generate_report {
325 $form->{sort} = "transdate" unless $form->{sort};
327 GL->all_transactions(\%myconfig, \%$form);
329 $callback = "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
333 %acctype = ( 'A' => $locale->text('Asset'),
334 'C' => $locale->text('Contra'),
335 'L' => $locale->text('Liability'),
336 'Q' => $locale->text('Equity'),
337 'I' => $locale->text('Revenue'),
338 'E' => $locale->text('Expense'),
341 $form->{title} = $locale->text('General Ledger');
343 $ml = ($form->{ml} =~ /(A|E)/) ? -1 : 1;
345 unless ($form->{category} eq 'X') {
346 $form->{title} .= " : ".$locale->text($acctype{$form->{category}});
348 if ($form->{accno}) {
349 $href .= "&accno=".$form->escape($form->{accno});
350 $callback .= "&accno=".$form->escape($form->{accno},1);
351 $option = $locale->text('Account')." : $form->{accno} $form->{account_description}";
353 if ($form->{gifi_accno}) {
354 $href .= "&gifi_accno=".$form->escape($form->{gifi_accno});
355 $callback .= "&gifi_accno=".$form->escape($form->{gifi_accno},1);
356 $option .= "\n<br>" if $option;
357 $option .= $locale->text('GIFI')." : $form->{gifi_accno} $form->{gifi_account_description}";
359 if ($form->{source}) {
360 $href .= "&source=".$form->escape($form->{source});
361 $callback .= "&source=".$form->escape($form->{source},1);
362 $option .= "\n<br>" if $option;
363 $option .= $locale->text('Source')." : $form->{source}";
365 if ($form->{reference}) {
366 $href .= "&reference=".$form->escape($form->{reference});
367 $callback .= "&reference=".$form->escape($form->{reference},1);
368 $option .= "\n<br>" if $option;
369 $option .= $locale->text('Reference')." : $form->{reference}";
371 if ($form->{department}) {
372 $href .= "&department=".$form->escape($form->{department});
373 $callback .= "&department=".$form->escape($form->{department},1);
374 ($department) = split /--/, $form->{department};
375 $option .= "\n<br>" if $option;
376 $option .= $locale->text('Department')." : $department";
379 if ($form->{description}) {
380 $href .= "&description=".$form->escape($form->{description});
381 $callback .= "&description=".$form->escape($form->{description},1);
382 $option .= "\n<br>" if $option;
383 $option .= $locale->text('Description')." : $form->{description}";
385 if ($form->{notes}) {
386 $href .= "¬es=".$form->escape($form->{notes});
387 $callback .= "¬es=".$form->escape($form->{notes},1);
388 $option .= "\n<br>" if $option;
389 $option .= $locale->text('Notes')." : $form->{notes}";
392 if ($form->{datefrom}) {
393 $href .= "&datefrom=$form->{datefrom}";
394 $callback .= "&datefrom=$form->{datefrom}";
395 $option .= "\n<br>" if $option;
396 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{datefrom}, 1);
398 if ($form->{dateto}) {
399 $href .= "&dateto=$form->{dateto}";
400 $callback .= "&dateto=$form->{dateto}";
401 if ($form->{datefrom}) {
404 $option .= "\n<br>" if $option;
406 $option .= $locale->text('Bis')." ".$locale->date(\%myconfig, $form->{dateto}, 1);
410 @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));
412 if ($form->{accno} || $form->{gifi_accno}) {
413 @columns = grep !/(accno|gifi_accno)/, @columns;
414 push @columns, "balance";
415 $form->{l_balance} = "Y";
419 $form->{l_credit_accno} = "Y";
420 $form->{l_debit_accno} = "Y";
421 $form->{l_credit_tax} = "Y";
422 $form->{l_debit_tax} = "Y";
423 $form->{l_credit_tax_accno} = "Y";
424 $form->{l_debit_tax_accno} = "Y";
425 $form->{l_accno} = "N";
426 foreach $item (@columns) {
427 if ($form->{"l_$item"} eq "Y") {
428 push @column_index, $item;
430 # add column to href and callback
431 $callback .= "&l_$item=Y";
432 $href .= "&l_$item=Y";
436 if ($form->{l_subtotal} eq 'Y') {
437 $callback .= "&l_subtotal=Y";
438 $href .= "&l_subtotal=Y";
441 $callback .= "&category=$form->{category}";
442 $href .= "&category=$form->{category}";
444 $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
445 $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
446 $column_header{reference} = "<th><a class=listheading href=$href&sort=reference>".$locale->text('Reference')."</a></th>";
447 $column_header{source} = "<th><a class=listheading href=$href&sort=source>".$locale->text('Source')."</a></th>";
448 $column_header{description} = "<th><a class=listheading href=$href&sort=description>".$locale->text('Description')."</a></th>";
449 $column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
450 $column_header{debit} = "<th class=listheading>".$locale->text('Debit')."</th>";
451 $column_header{debit_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Account')."</a></th>";
452 $column_header{credit} = "<th class=listheading>".$locale->text('Credit')."</th>";
453 $column_header{credit_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Account')."</a></th>";
454 $column_header{debit_tax} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Tax')."</a></th>";
455 $column_header{debit_tax_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Tax Account')."</a></th>";
456 $column_header{credit_tax} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Tax')."</a></th>";
457 $column_header{credit_tax_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Tax Account')."</a></th>";
458 $column_header{gifi_accno} = "<th><a class=listheading href=$href&sort=gifi_accno>".$locale->text('GIFI')."</a></th>";
459 $column_header{balance} = "<th>".$locale->text('Balance')."</th>";
461 $form->{landscape} = 1;
470 <th class=listtop>$form->{title}</th>
480 <tr class=listheading>
483 map { print "$column_header{$_}\n" } @column_index;
492 # add sort to callback
493 $form->{callback} = "$callback&sort=$form->{sort}";
494 $callback = $form->escape($form->{callback});
496 # initial item for subtotals
497 if (@{ $form->{GL} }) {
498 $sameitem = $form->{GL}->[0]->{$form->{sort}};
501 if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
503 map { $column_data{$_} = "<td> </td>" } @column_index;
504 $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
510 map { print "$column_data{$_}\n" } @column_index;
517 foreach $ref (@{ $form->{GL} }) {
519 # if item ne sort print subtotal
520 if ($form->{l_subtotal} eq 'Y') {
521 if ($sameitem ne $ref->{$form->{sort}}) {
525 foreach $key (sort keys (%{$ref->{amount}})) {
526 $form->{balance} += $ref->{amount}{$key};
530 foreach $key (sort keys (%{$ref->{debit}})) {
531 $subtotaldebit += $ref->{debit}{$key};
532 $totaldebit += $ref->{debit}{$key};
534 $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
536 $debit .= "<br>".$form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
541 foreach $key (sort keys (%{$ref->{credit}})) {
542 $subtotalcredit += $ref->{credit}{$key};
543 $totalcredit += $ref->{credit}{$key};
545 $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
547 $credit .= "<br>".$form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
552 foreach $key (sort keys (%{$ref->{debit_tax}})) {
553 $subtotaldebittax += $ref->{debit_tax}{$key};
554 $totaldebittax += $ref->{debit_tax}{$key};
556 $debittax = $form->format_amount(\%myconfig, $ref->{debit_tax}{$key} , 2, 0);
558 $debittax .= "<br>".$form->format_amount(\%myconfig, $ref->{debit_tax}{$key} , 2, 0);
563 foreach $key (sort keys (%{$ref->{credit_tax}})) {
564 $subtotalcredittax += $ref->{credit_tax}{$key};
565 $totalcredittax += $ref->{credit_tax}{$key};
567 $credittax = $form->format_amount(\%myconfig, $ref->{credit_tax}{$key} , 2, 0);
569 $credittax .= "<br>".$form->format_amount(\%myconfig, $ref->{credit_tax}{$key} , 2, 0);
576 foreach $key (sort keys (%{$ref->{debit_accno}})) {
578 $debitaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
580 $debitaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
582 if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
583 $ref->{debit_tax_accno}{$key} = $taxaccno;
585 $taxaccno = $ref->{debit_tax_accno}{$key};
586 $debittaxkey = $ref->{debit_taxkey}{$key};
592 foreach $key (sort keys (%{$ref->{credit_accno}})) {
594 $creditaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
596 $creditaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
598 if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
599 $ref->{credit_tax_accno}{$key} = $taxaccno;
601 $taxaccno = $ref->{credit_tax_accno}{$key};
602 $credittaxkey = $ref->{credit_taxkey}{$key};
606 foreach $key (sort keys (%{$ref->{debit_tax_accno}})) {
608 $debittaxaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
610 $debittaxaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
614 $credittaxaccno = "";
615 foreach $key (sort keys (%{$ref->{credit_tax_accno}})) {
617 $credittaxaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
619 $credittaxaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
622 # $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
623 # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
625 $column_data{id} = "<td align=right> $ref->{id} </td>";
626 $column_data{transdate} = "<td align=center> $ref->{transdate} </td>";
627 $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>";
628 $column_data{description} = "<td align=center>$ref->{description} </td>";
629 $column_data{source} = "<td align=center>$ref->{source} </td>";
630 $column_data{notes} = "<td align=center>$ref->{notes} </td>";
631 $column_data{debit} = "<td align=right>$debit</td>";
632 $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
633 $column_data{credit} = "<td align=right>$credit</td>";
634 $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
635 $column_data{debit_tax} = ($ref->{debit_tax_accno} ne "") ? "<td align=right>$debittax</td>" : "<td></td>";
636 $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
637 $column_data{gifi_accno} = "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a> </td>";
638 $column_data{credit_tax} = ($ref->{credit_tax_accno} ne "") ? "<td align=right>$credittax</td>" : "<td></td>";
639 $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</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{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
645 <tr class=listrow$i>";
646 map { print "$column_data{$_}\n" } @column_index;
652 &gl_subtotal if ($form->{l_subtotal} eq 'Y');
655 map { $column_data{$_} = "<td> </td>" } @column_index;
657 $column_data{debit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebit, 2, " ")."</th>";
658 $column_data{credit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredit, 2, " ")."</th>";
659 $column_data{debit_tax} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebittax, 2, " ")."</th>";
660 $column_data{credit_tax} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredittax, 2, " ")."</th>";
661 $column_data{balance} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</th>";
667 map { print "$column_data{$_}\n" } @column_index;
676 <td><hr size=3 noshade></td>
682 <form method=post action=$form->{script}>
684 <input name=callback type=hidden value="$form->{callback}">
686 <input type=hidden name=path value=$form->{path}>
687 <input type=hidden name=login value=$form->{login}>
688 <input type=hidden name=password value=$form->{password}>
690 <input class=submit type=submit name=action value="|.$locale->text('GL Transaction').qq|">
691 <input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|">
692 <input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|">
693 <input class=submit type=submit name=action value="|.$locale->text('Sales Invoice').qq|">
694 <input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice').qq|">|;
697 if ($form->{menubar}) {
698 require "$form->{path}/menu.pl";
715 $subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
716 $subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
718 map { $column_data{$_} = "<td> </td>" } qw(transdate id reference source description accno);
719 $column_data{debit} = "<th align=right>$subtotaldebit</td>";
720 $column_data{credit} = "<th align=right>$subtotalcredit</td>";
723 print "<tr class=listsubtotal>";
724 map { print "$column_data{$_}\n" } @column_index;
730 $sameitem = $ref->{$form->{sort}};
737 if ($form->{transdate} ne $form->{oldtransdate}) {
738 if ($form->{selectprojectnumber}) {
739 $form->all_projects(\%myconfig, undef, $form->{transdate});
740 if (@{ $form->{all_project} }) {
741 $form->{selectprojectnumber} = "<option>\n";
742 for (@{ $form->{all_project} }) { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| }
743 $form->{selectprojectnumber} = $form->escape($form->{selectprojectnumber},1);
746 $form->{oldtransdate} = $form->{transdate};
753 my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
755 for my $i (1 .. $form->{rowcount}) {
757 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
758 for (qw(debit credit tax)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
761 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
762 $amount = ($form->{"debit_$i"} == 0) ? $form->{"credit_$i"} : $form->{"debit_$i"};
764 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
765 $form->{"taxchart_$i"} = "0--";
766 $form->{"tax_$i"} = 0;
768 if (!$form->{"korrektur_$i"}) {
769 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
776 if ($form->{taxincluded}) {
777 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
779 $form->{"tax_$i"} = $amount * $rate;
782 $form->{"tax_$i"} = 0;
786 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
792 for $i (1 .. $count) {
794 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
797 for $i ($count + 1 .. $form->{rowcount}) {
798 for (@flds) { delete $form->{"${_}_$i"} }
801 $form->{rowcount} = $count + 1;
812 # for $i (1 .. $form->{rowcount}) {
813 # $form->{totaldebit} += $form->parse_amount(\%myconfig, $form->{"debit_$i"});
814 # $form->{totalcredit} += $form->parse_amount(\%myconfig, $form->{"credit_$i"});
818 &display_rows($init);
827 $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber}) if $form->{selectprojectnumber};
829 $form->{totaldebit} = 0;
830 $form->{totalcredit} = 0;
831 my $chart= $form->{chart};
832 $chart = $form->unquote($chart);
833 $form->{taxchart} = $form->unquote($form->{taxchart});
834 $taxchart = $form->{taxchart};
835 for $i (1 .. $form->{rowcount}) {
838 <td><input name="source_$i" value="$form->{"source_$i"}" tabindex=|.($i+11+(($i-1)*8)).qq|></td>|;
840 <td><input name="memo_$i" value="$form->{"memo_$i"}" tabindex=|.($i+12+(($i-1)*8)).qq|></td>|;
844 <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|.($i+5+(($i-1)*8)).qq|>$form->{chartinit}</select></td>|;
845 $tax = qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|.($i+10+(($i-1)*8)).qq|>$form->{taxchart}</select></td>|;
846 if ($form->{selectprojectnumber}) {
848 <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
850 $korrektur = qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|.($i+9+(($i-1)*8)).qq|></td>|;
851 if ($form->{transfer}) {
852 $fx_transaction = qq|
853 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
859 $form->{totaldebit} += $form->{"debit_$i"};
860 $form->{totalcredit} += $form->{"credit_$i"};
862 for (qw(debit credit tax)) { $form->{"${_}_$i"} = ($form->{"${_}_$i"}) ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) : "" }
864 if ($i < $form->{rowcount}) {
867 $chart_selected = $form->{"accno_$i"};
868 $accno =~ s/value=\"$chart_selected\"/value=\"$chart_selected\" selected/;
869 $accno = qq|<td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|.($i+5+(($i-1)*8)).qq|>$accno</select></td>|;
871 $tax_selected = $form->{"taxchart_$i"};
872 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
873 $tax = qq|<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|.($i+10+(($i-1)*8)).qq|>$tax</select></td>|;
874 if ($form->{selectprojectnumber}) {
875 $form->{"projectnumber_$i"} = "" if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/;
877 $project = $form->{"projectnumber_$i"};
878 $project =~ s/--.*//;
879 $project = qq|<td>$project</td>|;
882 if ($form->{transfer}) {
883 $checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
884 $x = ($checked) ? "x" : "";
885 $fx_transaction = qq|
886 <td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
889 $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
890 $korrektur = qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked tabindex=|.($i+9+(($i-1)*8)).qq|></td>|;
891 $form->hide_form("accno_$i", "projectnumber_$i");
896 <td><select name="accno_$i" onChange="setTaxkey(this, $i)" style="width:300px" tabindex=|.($i+5+(($i-1)*8)).qq|>$chart</select></td>|;
898 <td><select id="taxchart_$i" name="taxchart_$i" tabindex=|.($i+10+(($i-1)*8)).qq|>$taxchart</select></td>|;
899 if ($form->{selectprojectnumber}) {
901 <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
903 $korrektur = qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|.($i+9+(($i-1)*8)).qq|></td>|;
904 if ($form->{transfer}) {
905 $fx_transaction = qq|
906 <td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
912 print qq|<tr valign=top>
915 <td><input name="debit_$i" size=10 value="$form->{"debit_$i"}" accesskey=$i tabindex=|.($i+6+(($i-1)*8)).qq|></td>
916 <td><input name="credit_$i" size=10 value="$form->{"credit_$i"}" tabindex=|.($i+7+(($i-1)*8)).qq|></td>
917 <td><input name="tax_$i" size=8 value="$form->{"tax_$i"}" tabindex=|.($i+8+(($i-1)*8)).qq|></td>
928 $form->hide_form(qw(rowcount selectaccno));
930 <input type=hidden name=selectprojectnumber value="|.$form->escape($form->{selectprojectnumber},1).qq|">|;
936 $title = $form->{title};
937 $form->{title} = $locale->text("$title General Ledger Transaction");
938 $readonly = ($form->{id}) ? "readonly" : "";
941 # $locale->text('Add General Ledger Transaction')
942 # $locale->text('Edit General Ledger Transaction')
944 map { $form->{$_} =~ s/\"/"/g } qw(reference description chart taxchart);
945 $form->{javascript} = qq|<script type="text/javascript">
947 function setTaxkey(accno, row) {
948 var taxkey = accno.options[accno.selectedIndex].value;
949 var reg = /--([0-9])*/;
950 var found = reg.exec(taxkey);
951 var index = found[1];
952 index = parseInt(index);
953 var tax = 'taxchart_' + row;
954 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
955 var reg2 = new RegExp("^"+ index, "");
956 if (reg2.exec(document.getElementById(tax).options[i].value)) {
957 document.getElementById(tax).options[i].selected = true;
965 $form->{selectdepartment} =~ s/ selected//;
966 $form->{selectdepartment} =~ s/option>\Q$form->{department}\E/option selected>$form->{department}/;
968 if (($rows = $form->numtextrows($form->{description}, 50)) > 1) {
969 $description = qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
971 $description = qq|<input name=description size=50 value="$form->{description}" tabindex="3" $readonly>|;
974 $taxincluded = ($form->{taxincluded}) ? "checked" : "";
977 $taxincluded = "checked";
980 $amount = qq|<input name=amount size=20 value="$form->{amount}" tabindex="4" $readonly>|;
985 <th align=right nowrap>|.$locale->text('Department').qq|</th>
986 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
987 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
989 | if $form->{selectdepartment};
991 $form->{fokus} = "gl.reference";
993 $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
996 # use JavaScript Calendar or not
997 $form->{jsscript} = $jscalendar;
999 if ($form->{jsscript})
1001 # with JavaScript Calendar
1003 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate} tabindex="2" $readonly>
1004 <input type=button name=transdate id="trigger1" value=|.$locale->text('button').qq|></td>
1007 $jsscript = Form->write_trigger(\%myconfig,"1","transdate","BL","trigger1","","","");
1011 # without JavaScript Calendar
1012 $button1 = qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate} tabindex="2" $readonly></td>|;
1019 <body onLoad="fokus()">
1021 <form method=post name="gl" action=$form->{script}>
1023 <input name=id type=hidden value=$form->{id}>
1025 <input type=hidden name=closedto value=$form->{closedto}>
1026 <input type=hidden name=locked value=$form->{locked}>
1027 <input type=hidden name=title value="$title">
1028 <input type=hidden name=taxchart value="$form->{taxchart}">
1029 <input type=hidden name=chart value="$form->{chart}">
1034 <th class=listtop>$form->{title}</th>
1036 <tr height="5"></tr>
1041 <th align=right>|.$locale->text('Reference').qq|</th>
1042 <td><input name=reference size=20 value="$form->{reference}" tabindex="1" $readonly></td>
1046 <th align=right nowrap>|.$locale->text('Date').qq|</th>
1055 <th align=right>|.$locale->text('Belegnummer').qq|</th>
1056 <td><input name=id size=20 value="$form->{id}" $readonly></td>
1060 <th align=right width=50%>|.$locale->text('Buchungsdatum').qq|</th>
1061 <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly></td>
1072 <th align=right>|.$locale->text('Description').qq|</th>
1073 <td>$description</td>
1077 <th align=right width=50%>|.$locale->text('Mitarbeiter').qq|</th>
1078 <td align=left><input name=employee size=11 value=$form->{employee} $readonly></td>
1086 <th align=right>|.$locale->text('Description').qq|</th>
1087 <td colspan=2>$description</td>
1092 <th align=right>|.$locale->text('Betrag').qq|</th>
1097 <th align=left>|.$locale->text('MwSt. inkl.').qq|</th>
1098 <td><input type=checkbox name=taxincluded value=1 tabindex="5" $taxincluded></td>
1105 <tr class=listheading>
1106 <th class=listheading style="width:15%">|.$locale->text('Account').qq|</th>
1107 <th class=listheading style="width:10%">|.$locale->text('Debit').qq|</th>
1108 <th class=listheading style="width:10%">|.$locale->text('Credit').qq|</th>
1109 <th class=listheading style="width:10%">|.$locale->text('Tax').qq|</th>
1110 <th class=listheading style="width:5%">|.$locale->text('Korrektur').qq|</th>
1111 <th class=listheading style="width:10%">|.$locale->text('Taxkey').qq|</th>
1112 <th class=listheading style="width:20%">|.$locale->text('Source').qq|</th>
1113 <th class=listheading style="width:20%">|.$locale->text('Memo').qq|</th>
1124 ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
1126 $decimalplaces = ($dec > 2) ? $dec : 2;
1127 $radieren = ($form->current_date(\%myconfig) eq $form->{gldate})? 1 : 0;
1129 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces, " ") } qw(totaldebit totalcredit);
1135 <input type=hidden name=path value=$form->{path}>
1136 <input type=hidden name=login value=$form->{login}>
1137 <input type=hidden name=password value=$form->{password}>
1139 <input name=callback type=hidden value="$form->{callback}">
1144 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1145 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1149 print qq|<input class=submit type=submit name=action value="|.$locale->text('Storno').qq|">|;
1151 # Löschen und ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
1155 if (!$form->{locked} && $radieren) {
1157 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|" accesskey="b">
1158 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">|;
1162 # if ($transdate > $closedto) {
1164 # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
1167 if ($transdate > $closedto) {
1168 print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
1169 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">|;
1173 if ($form->{menubar}) {
1174 require "$form->{path}/menu.pl";
1195 <form method=post action=$form->{script}>
1198 map { $form->{$_} =~ s/\"/"/g } qw(reference description chart);
1200 delete $form->{header};
1202 foreach $key (keys %$form) {
1203 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1207 <h2 class=confirm>|.$locale->text('Confirm!').qq|</h2>
1209 <h4>|.$locale->text('Are you sure you want to delete Transaction').qq| $form->{reference}</h4>
1211 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
1220 $form->redirect($locale->text('Transaction deleted!')) if (GL->delete_transaction(\%myconfig, \%$form));
1221 $form->error($locale->text('Cannot delete transaction!'));
1227 # check if there is something in reference and date
1228 $form->isblank("reference", $locale->text('Reference missing!'));
1229 $form->isblank("transdate", $locale->text('Transaction Date missing!'));
1230 $form->isblank("description", $locale->text('Description missing!'));
1232 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1233 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1243 my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
1245 for my $i (1 .. $form->{rowcount}) {
1247 unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
1248 for (qw(debit credit tax)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
1251 $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
1252 $amount = ($form->{"debit_$i"} == 0) ? $form->{"credit_$i"} : $form->{"debit_$i"};
1254 if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
1255 $form->{"taxchart_$i"} = "0--";
1256 $form->{"tax_$i"} = 0;
1258 if (!$form->{"korrektur_$i"}) {
1259 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
1266 if ($form->{taxincluded}) {
1267 $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
1269 $form->{"tax_$i"} = $amount * $rate;
1272 $form->{"tax_$i"} = 0;
1276 for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
1282 for $i (1 .. $count) {
1284 for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }
1287 for $i ($count + 1 .. $form->{rowcount}) {
1288 for (@flds) { delete $form->{"${_}_$i"} }
1291 for $i (1 .. $form->{rowcount}) {
1292 $dr = $form->{"debit_$i"};
1293 $cr = $form->{"credit_$i"};
1294 $tax = $form->{"tax_$i"};
1296 $form->error($locale->text('Cannot post transaction with a debit and credit entry for the same account!'));
1298 if ($form->{taxincluded}) {
1304 $debit += $dr + $tax;
1307 $credit += $cr + $tax;
1312 $form->{taxincluded} = 0;
1315 # this is just for the wise guys
1316 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
1317 if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
1318 $form->error($locale->text('Out of balance transaction!'));
1320 if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
1322 $err[1] = $locale->text('Cannot have a value in both Debit and Credit!');
1323 $err[2] = $locale->text('Debit and credit out of balance!');
1324 $err[3] = $locale->text('Cannot post a transaction without a value!');
1326 $form->error($err[$errno]);
1328 undef($form->{callback});
1329 $form->redirect("Buchung gespeichert. Buchungsnummer = ".$form->{id});