1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
  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 #======================================================================
 
  30 # module for Chart of Accounts, Income Statement and Balance Sheet
 
  31 # search and edit transactions posted by the GL, AR and AP
 
  33 #======================================================================
 
  35 use POSIX qw(strftime);
 
  38 use SL::ReportGenerator;
 
  40 require "bin/mozilla/reportgenerator.pl";
 
  48 # this is for our long dates
 
  49 # $locale->text('January')
 
  50 # $locale->text('February')
 
  51 # $locale->text('March')
 
  52 # $locale->text('April')
 
  53 # $locale->text('May ')
 
  54 # $locale->text('June')
 
  55 # $locale->text('July')
 
  56 # $locale->text('August')
 
  57 # $locale->text('September')
 
  58 # $locale->text('October')
 
  59 # $locale->text('November')
 
  60 # $locale->text('December')
 
  62 # this is for our short month
 
  63 # $locale->text('Jan')
 
  64 # $locale->text('Feb')
 
  65 # $locale->text('Mar')
 
  66 # $locale->text('Apr')
 
  67 # $locale->text('May')
 
  68 # $locale->text('Jun')
 
  69 # $locale->text('Jul')
 
  70 # $locale->text('Aug')
 
  71 # $locale->text('Sep')
 
  72 # $locale->text('Oct')
 
  73 # $locale->text('Nov')
 
  74 # $locale->text('Dec')
 
  76 sub chart_of_accounts {
 
  77   $main::lxdebug->enter_sub();
 
  79   my $form     = $main::form;
 
  80   my %myconfig = %main::myconfig;
 
  81   my $locale   = $main::locale;
 
  83   $main::auth->assert('report');
 
  85   $form->{title} = $locale->text('Chart of Accounts');
 
  88     $form->{method} = "cash";
 
  91   CA->all_accounts(\%myconfig, \%$form);
 
  93   my @columns     = qw(accno description debit credit);
 
  95     'accno'       => { 'text' => $locale->text('Account'), },
 
  96     'description' => { 'text' => $locale->text('Description'), },
 
  97     'debit'       => { 'text' => $locale->text('Debit'), },
 
  98     'credit'      => { 'text' => $locale->text('Credit'), },
 
 101   my $report = SL::ReportGenerator->new(\%myconfig, $form);
 
 103   $report->set_options('output_format'         => 'HTML',
 
 104                        'title'                 => $form->{title},
 
 105                        'attachment_basename'   => $locale->text('chart_of_accounts') . strftime('_%Y%m%d', localtime time),
 
 106                        'std_column_visibility' => 1,
 
 108   $report->set_options_from_form();
 
 110   $report->set_columns(%column_defs);
 
 111   $report->set_column_order(@columns);
 
 113   $report->set_export_options('chart_of_accounts');
 
 115   $report->set_sort_indicator($form->{sort}, 1);
 
 117   my %totals = ('debit' => 0, 'credit' => 0);
 
 119   foreach my $ca (@{ $form->{CA} }) {
 
 120     next unless defined $ca->{amount};
 
 123     foreach (qw(debit credit)) {
 
 124       $totals{$_} += $ca->{$_} * 1;
 
 125       $ca->{$_}    = $form->format_amount(\%myconfig, $ca->{$_}, 2) if ($ca->{$_});
 
 128     map { $row->{$_} = { 'data' => $ca->{$_} } } @columns;
 
 130     map { $row->{$_}->{align} = 'right'       } qw(debit credit);
 
 131     map { $row->{$_}->{class} = 'listheading' } @columns if ($ca->{charttype} eq "H");
 
 133     $row->{accno}->{link} = build_std_url('action=list', 'accno=' . E($ca->{accno}), 'description=' . E($ca->{description}));
 
 135     $report->add_data($row);
 
 138   my $row = { map { $_ => { 'class' => 'listtotal', 'align' => 'right' } } @columns };
 
 139   map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals{$_}, 2) } qw(debit credit);
 
 141   $report->add_separator();
 
 142   $report->add_data($row);
 
 144   $report->generate_with_headers();
 
 146   $main::lxdebug->leave_sub();
 
 150   $main::lxdebug->enter_sub();
 
 152   my $form     = $main::form;
 
 153   my %myconfig = %main::myconfig;
 
 154   my $locale   = $main::locale;
 
 156   $main::auth->assert('report');
 
 158   $form->{title} = $locale->text('List Transactions');
 
 159   $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}";
 
 160   my $year = (localtime)[5] + 1900;
 
 163   $form->all_departments(\%myconfig);
 
 164   if (@{ $form->{all_departments} || [] }) {
 
 165     $form->{selectdepartment} = "<option>\n";
 
 168       $form->{selectdepartment} .=
 
 169         "<option>$_->{description}--$_->{id}\n"
 
 170     } (@{ $form->{all_departments} || [] });
 
 175           <th align=right nowrap>| . $locale->text('Department') . qq|</th>
 
 176           <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
 
 178 | if $form->{selectdepartment};
 
 179   my $accrual = ($main::eur) ? ""        : "checked";
 
 180   my $cash    = ($main::eur) ? "checked" : "";
 
 182   my $name_1    = "fromdate";
 
 183   my $id_1      = "fromdate";
 
 184   my $value_1   = "$form->{fromdate}";
 
 185   my $trigger_1 = "trigger1";
 
 186   my $name_2    = "todate";
 
 189   my $trigger_2 = "trigger2";
 
 191   my ($button1, $button1_2, $button2, $button2_2, $jsscript);
 
 193   # with JavaScript Calendar
 
 194   if ($form->{jsscript}) {
 
 198          <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 200         <input type=button name=$name_2 id="$trigger_2" value=|
 
 201         . $locale->text('button') . qq|>|;
 
 205         Form->write_trigger(\%myconfig, "1", "$name_2", "BR", "$trigger_2");
 
 208          <input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\" value="$value_1">|;
 
 210         <input type=button name=$name_1 id="$trigger_1" value=|
 
 211         . $locale->text('button') . qq|>|;
 
 213          <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 215          <input type=button name=$name_2 id="$trigger_2" value=|
 
 216         . $locale->text('button') . qq|>
 
 221         Form->write_trigger(\%myconfig, "2", "$name_1", "BR", "$trigger_1",
 
 222                             "$name_2", "BL", "$trigger_2");
 
 226     # without JavaScript Calendar
 
 229         qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 232         qq|<input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value="$value_1" onBlur=\"check_right_date_format(this)\">|;
 
 234         qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 237   $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
 
 239   my $onload = qq|focus()|;
 
 240   $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
 
 241   $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
 
 246   $form->{description} =~ s/\"/"/g;
 
 249 <body onLoad="$onload">
 
 251 <form method=post action=$form->{script}>
 
 253 <input type=hidden name=accno value=$form->{accno}>
 
 254 <input type=hidden name=description value="$form->{description}">
 
 255 <input type=hidden name=sort value=transdate>
 
 256 <input type=hidden name=eur value=$main::eur>
 
 257 <input type=hidden name=accounttype value=$form->{accounttype}>
 
 259 <table border=0 width=100%>
 
 261     <th class=listtop>$form->{title}</th>
 
 267           <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
 
 268       . $locale->text('Customized Report') . qq|</th>
 
 271           <th colspan=1>| . $locale->text('Year') . qq|</th>
 
 272           <td><input name=year size=11 title="|
 
 273       . $locale->text('YYYY') . qq|" value="$year"></td>
 
 280 <b> | . $locale->text('Yearly') . qq|</b> </td>
 
 281                 <th align=left>| . $locale->text('Quarterly') . qq|</th>
 
 282                 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
 
 285                 <td align=right>  <input name=duetyp class=radio type=radio value="13"></td>
 
 286                 <td><input name=duetyp class=radio type=radio value="A"> 1. | . $locale->text('Quarter') . qq|</td>
 
 287                 <td><input name=duetyp class=radio type=radio value="1" "checked"> | . $locale->text('January') . qq|</td>
 
 288                 <td><input name=duetyp class=radio type=radio value="5" > | . $locale->text('May') . qq|</td>
 
 289                 <td><input name=duetyp class=radio type=radio value="9" > | . $locale->text('September') . qq|</td>
 
 293                 <td align= right> </td>
 
 294                 <td><input name=duetyp class=radio type=radio value="B"> 2. | . $locale->text('Quarter') . qq|</td>
 
 295                 <td><input name=duetyp class=radio type=radio value="2" > | . $locale->text('February') . qq|</td>
 
 296                 <td><input name=duetyp class=radio type=radio value="6" > | . $locale->text('June') . qq|</td>
 
 297                 <td><input name=duetyp class=radio type=radio value="10" > | . $locale->text('October') . qq|</td>
 
 301                 <td><input name=duetyp class=radio type=radio value="C"> 3. | . $locale->text('Quarter') . qq|</td>
 
 302                 <td><input name=duetyp class=radio type=radio value="3" > | . $locale->text('March') . qq|</td>
 
 303                 <td><input name=duetyp class=radio type=radio value="7" > | . $locale->text('July') . qq|</td>
 
 304                 <td><input name=duetyp class=radio type=radio value="11" > | . $locale->text('November') . qq|</td>
 
 309                 <td><input name=duetyp class=radio type=radio value="D"> 4. | . $locale->text('Quarter') . qq| </td>
 
 310                 <td><input name=duetyp class=radio type=radio value="4" > | . $locale->text('April') . qq|</td>
 
 311                 <td><input name=duetyp class=radio type=radio value="8" > | . $locale->text('August') . qq|</td>
 
 312                 <td><input name=duetyp class=radio type=radio value="12" > | . $locale->text('December') . qq|</td>
 
 316                    <td colspan=5><hr size=3 noshade></td>
 
 319           <th align=left><input name=reporttype class=radio type=radio value="free"> | . $locale->text('Free report period') . qq|</th>
 
 320           <td align=left colspan=4>| . $locale->text('From') . qq| 
 
 323               | . $locale->text('Bis') . qq| 
 
 329                    <td colspan=5><hr size=3 noshade></td>
 
 332           <th align=leftt>| . $locale->text('Method') . qq|</th>
 
 333           <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>| . $locale->text('Accrual') . qq|
 
 334            <input name=method class=radio type=radio value=cash $cash>| . $locale->text('EUR') . qq|</td>
 
 337          <th align=right colspan=4>| . $locale->text('Decimalplaces') . qq|</th>
 
 338              <td><input name=decimalplaces size=3 value="2"></td>
 
 341             <td><input name="subtotal" class=checkbox type=checkbox value=1> | . $locale->text('Subtotal') . qq|</td>
 
 345   <tr><td colspan=5 ><hr size=3 noshade></td></tr>
 
 348 <br><input class=submit type=submit name=action value="|
 
 349     . $locale->text('List Transactions') . qq|">
 
 356   $main::lxdebug->leave_sub();
 
 359 sub format_debit_credit {
 
 360   $main::lxdebug->enter_sub();
 
 364   my $form     = $main::form;
 
 365   my %myconfig = %main::myconfig;
 
 366   my $locale   = $main::locale;
 
 368   my $formatted_dc  = $form->format_amount(\%myconfig, abs($dc), 2) . ' ';
 
 369   $formatted_dc    .= ($dc > 0) ? $locale->text('Credit (one letter abbreviation)') : $locale->text('Debit (one letter abbreviation)');
 
 371   $main::lxdebug->leave_sub();
 
 373   return $formatted_dc;
 
 377 sub list_transactions {
 
 378   $main::lxdebug->enter_sub();
 
 380   my $form     = $main::form;
 
 381   my %myconfig = %main::myconfig;
 
 382   my $locale   = $main::locale;
 
 384   $main::auth->assert('report');
 
 386   $form->{title} = $locale->text('Account') . " $form->{accno} - $form->{description}";
 
 388   if ($form->{reporttype} eq "custom") {
 
 390     #forgotten the year --> thisyear
 
 391     if ($form->{year} !~ m/^\d\d\d\d$/) {
 
 392       $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
 
 398     if ($form->{duetyp} eq "13") {
 
 399       $form->{fromdate} = "1.1.$form->{year}";
 
 400       $form->{todate}   = "31.12.$form->{year}";
 
 404     if ($form->{duetyp} eq "A") {
 
 405       $form->{fromdate} = "1.1.$form->{year}";
 
 406       $form->{todate}   = "31.3.$form->{year}";
 
 408     if ($form->{duetyp} eq "B") {
 
 409       $form->{fromdate} = "1.4.$form->{year}";
 
 410       $form->{todate}   = "30.6.$form->{year}";
 
 412     if ($form->{duetyp} eq "C") {
 
 413       $form->{fromdate} = "1.7.$form->{year}";
 
 414       $form->{todate}   = "30.9.$form->{year}";
 
 416     if ($form->{duetyp} eq "D") {
 
 417       $form->{fromdate} = "1.10.$form->{year}";
 
 418       $form->{todate}   = "31.12.$form->{year}";
 
 423       $form->{duetyp} eq "1" && do {
 
 424         $form->{fromdate} = "1.1.$form->{year}";
 
 425         $form->{todate}   = "31.1.$form->{year}";
 
 428       $form->{duetyp} eq "2" && do {
 
 429         $form->{fromdate} = "1.2.$form->{year}";
 
 431         #this works from 1901 to 2099, 1900 and 2100 fail.
 
 432         my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
 
 433         $form->{todate} = "$leap.2.$form->{year}";
 
 436       $form->{duetyp} eq "3" && do {
 
 437         $form->{fromdate} = "1.3.$form->{year}";
 
 438         $form->{todate}   = "31.3.$form->{year}";
 
 441       $form->{duetyp} eq "4" && do {
 
 442         $form->{fromdate} = "1.4.$form->{year}";
 
 443         $form->{todate}   = "30.4.$form->{year}";
 
 446       $form->{duetyp} eq "5" && do {
 
 447         $form->{fromdate} = "1.5.$form->{year}";
 
 448         $form->{todate}   = "31.5.$form->{year}";
 
 451       $form->{duetyp} eq "6" && do {
 
 452         $form->{fromdate} = "1.6.$form->{year}";
 
 453         $form->{todate}   = "30.6.$form->{year}";
 
 456       $form->{duetyp} eq "7" && do {
 
 457         $form->{fromdate} = "1.7.$form->{year}";
 
 458         $form->{todate}   = "31.7.$form->{year}";
 
 461       $form->{duetyp} eq "8" && do {
 
 462         $form->{fromdate} = "1.8.$form->{year}";
 
 463         $form->{todate}   = "31.8.$form->{year}";
 
 466       $form->{duetyp} eq "9" && do {
 
 467         $form->{fromdate} = "1.9.$form->{year}";
 
 468         $form->{todate}   = "30.9.$form->{year}";
 
 471       $form->{duetyp} eq "10" && do {
 
 472         $form->{fromdate} = "1.10.$form->{year}";
 
 473         $form->{todate}   = "31.10.$form->{year}";
 
 476       $form->{duetyp} eq "11" && do {
 
 477         $form->{fromdate} = "1.11.$form->{year}";
 
 478         $form->{todate}   = "30.11.$form->{year}";
 
 481       $form->{duetyp} eq "12" && do {
 
 482         $form->{fromdate} = "1.12.$form->{year}";
 
 483         $form->{todate}   = "31.12.$form->{year}";
 
 489   CA->all_transactions(\%myconfig, \%$form);
 
 491   $form->{saldo_old} += $form->{beginning_balance};
 
 492   $form->{saldo_new} += $form->{beginning_balance};
 
 493   my $saldo_old = format_debit_credit($form->{saldo_old});
 
 494   my $eb_string = format_debit_credit($form->{beginning_balance});
 
 495   $form->{balance} = $form->{saldo_old};
 
 498   if ($form->{department}) {
 
 499     my ($department) = split /--/, $form->{department};
 
 500     push @options, $locale->text('Department') . " : $department";
 
 502   if ($form->{projectnumber}) {
 
 503     push @options, $locale->text('Project Number') . " : $form->{projectnumber}<br>";
 
 507   if ($form->{fromdate} || $form->{todate}) {
 
 508     my ($fromdate, $todate);
 
 510     if ($form->{fromdate}) {
 
 511       $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
 
 513     if ($form->{todate}) {
 
 514       $todate = $locale->date(\%myconfig, $form->{todate}, 1);
 
 517     $period = "$fromdate - $todate";
 
 520     $period = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
 
 523   push @options, $period;
 
 525   $form->{print_date} = $locale->text('Create Date') . " " . $locale->date(\%myconfig, $form->current_date(\%myconfig), 0);
 
 526   push (@options, $form->{print_date});
 
 528   $form->{company} = $locale->text('Company') . " " . $myconfig{company};
 
 529   push (@options, $form->{company});
 
 531   my @columns     = qw(transdate reference description gegenkonto debit credit ustkonto ustrate balance);
 
 533     'transdate'   => { 'text' => $locale->text('Date'), },
 
 534     'reference'   => { 'text' => $locale->text('Reference'), },
 
 535     'description' => { 'text' => $locale->text('Description'), },
 
 536     'debit'       => { 'text' => $locale->text('Debit'), },
 
 537     'credit'      => { 'text' => $locale->text('Credit'), },
 
 538     'gegenkonto'  => { 'text' => $locale->text('Gegenkonto'), },
 
 539     'ustkonto'    => { 'text' => $locale->text('USt-Konto'), },
 
 540     'balance'     => { 'text' => $locale->text('Balance'), },
 
 541     'ustrate'     => { 'text' => $locale->text('Satz %'), },
 
 544   my @hidden_variables = qw(accno fromdate todate description accounttype l_heading subtotal department projectnumber project_id sort);
 
 546   my $link = build_std_url('action=list_transactions', grep { $form->{$_} } @hidden_variables);
 
 548   $form->{callback} = $link . '&sort=' . E($form->{sort});
 
 550   my %column_alignment = map { $_ => 'right' } qw(debit credit);
 
 552   my @custom_headers = ();
 
 554  push @custom_headers, [
 
 555    { 'text' => 'Letzte Buchung', },
 
 556    { 'text' => 'EB-Wert', },
 
 557    { 'text' => 'Saldo alt', 'colspan' => 2, },
 
 558    { 'text' => 'Jahresverkehrszahlen alt', 'colspan' => 2, },
 
 559    { 'text' => '', 'colspan' => 2, },
 
 561  push @custom_headers, [
 
 562    { 'text' => $form->{last_transaction}, },
 
 563    { 'text' => $eb_string, },
 
 564    { 'text' => $saldo_old, 'colspan' => 2, },
 
 565    { 'text' => $form->format_amount(\%myconfig, abs($form->{old_balance_debit}), 2) . " S", },
 
 566    { 'text' => $form->format_amount(\%myconfig, $form->{old_balance_credit}, 2) . " H", },
 
 567    { 'text' => '', 'colspan' => 2, },
 
 570  push @custom_headers, [
 
 571    { 'text' => $locale->text('Date'), 'link' => $link . "&sort=transdate", },
 
 572    { 'text' => $locale->text('Reference'), 'link' => $link . "&sort=reference",  },
 
 573    { 'text' => $locale->text('Description'), 'link' => $link . "&sort=description",  },
 
 574    { 'text' => $locale->text('Gegenkonto'), },
 
 575    { 'text' => $locale->text('Debit'), },
 
 576    { 'text' => $locale->text('Credit'), },
 
 577    { 'text' => $locale->text('USt-Konto'), },
 
 578    { 'text' => $locale->text('Satz %'), },
 
 579    { 'text' => $locale->text('Balance'), },
 
 586   my $report = SL::ReportGenerator->new(\%myconfig, $form);
 
 587   $report->set_custom_headers(@custom_headers);
 
 589   $report->set_options('top_info_text'         => join("\n", @options),
 
 590                        'output_format'         => 'HTML',
 
 591                        'title'                 => $form->{title},
 
 592                        'attachment_basename'   => $locale->text('list_of_transactions') . strftime('_%Y%m%d', localtime time),
 
 593                        'std_column_visibility' => 1,
 
 595   $report->set_options_from_form();
 
 597   $report->set_columns(%column_defs);
 
 598   $report->set_column_order(@columns);
 
 600   $report->set_export_options('list_transactions', @hidden_variables);
 
 602   $report->set_sort_indicator($form->{sort}, 1);
 
 604   $column_defs{balance}->{visible} = 1;
 
 606   my $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
 
 610   my %totals    = ( 'debit' => 0, 'credit' => 0 );
 
 611   my %subtotals = ( 'debit' => 0, 'credit' => 0 );
 
 612   my ($previous_index, $row_set);
 
 614   foreach my $ca (@{ $form->{CA} }) {
 
 616     foreach (qw(debit credit)) {
 
 617       $subtotals{$_} += $ca->{$_};
 
 618       $totals{$_}    += $ca->{$_};
 
 619       if ($_ =~ /debit.*/) {
 
 624       $form->{balance}= $form->{balance} + $ca->{$_} * $ml;
 
 625       $ca->{$_}       = $form->format_amount(\%myconfig, $ca->{$_}, 2) if ($ca->{$_} != 0);
 
 629     if (($form->{subtotal})
 
 630         && (($idx == scalar @{ $form->{CA} } - 1)
 
 631             || ($ca->{$form->{sort}} ne $form->{CA}->[$idx + 1]->{$form->{sort}}))) {
 
 637     $ca->{ustrate} = $form->format_amount(\%myconfig, $ca->{ustrate} * 100, 2) if ($ca->{ustrate} != 0);
 
 639     if ($ca->{memo} ne "") {
 
 640       $ca->{description} .= " \n " . $ca->{memo};
 
 645     foreach my $gegenkonto (@{ $ca->{GEGENKONTO} }) {
 
 646       if ($ca->{gegenkonto} eq "") {
 
 647         $ca->{gegenkonto} = $gegenkonto->{accno};
 
 649         $ca->{gegenkonto} .= ", " . $gegenkonto->{accno};
 
 656         'align' => $column_alignment{$_},
 
 660     $row->{balance}->{data}        = $form->format_amount(\%myconfig, $form->{balance}, 2, 'DRCR');
 
 662     if ($ca->{index} ne $previous_index) {
 
 663 #       $report->add_data($row_set) if ($row_set);
 
 666       $previous_index  = $ca->{index};
 
 668       $row->{reference}->{link} = build_std_url("script=$ca->{module}.pl", 'action=edit', 'id=' . E($ca->{id}), 'callback');
 
 670     } elsif ($ca->{index} eq $previous_index) {
 
 671       map { $row->{$_}->{data} = '' } qw(reference description);
 
 672       $row->{transdate}->{data} = '' if ($form->{sort} eq 'transdate');
 
 677     push @{ $row_set }, $row;
 
 679     push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, 'listsubtotal') if ($do_subtotal);
 
 683     $report->add_data($row_set);
 
 687   $report->add_data($row_set) if ($row_set);
 
 689   $report->add_separator();
 
 691   my $row = create_subtotal_row(\%totals, \@columns, \%column_alignment, 'listtotal');
 
 694   $row->{balance}->{data}        = $form->format_amount(\%myconfig, $form->{balance}, 2, 'DRCR');
 
 696   $report->add_data($row);
 
 699   $report->add_separator();
 
 703        'class' => 'listtotal',
 
 706        'data'    => $locale->text('EB-Wert'),
 
 707        'class' => 'listtotal',
 
 710        'data'    => $locale->text('Saldo neu'),
 
 712        'class' => 'listtotal',
 
 715        'data'    => $locale->text('Jahresverkehrszahlen neu'),
 
 718        'class' => 'listtotal',
 
 724        'class' => 'listtotal',
 
 728   $report->add_data($row);
 
 729   my $saldo_new = format_debit_credit($form->{saldo_new});
 
 733        'class' => 'listtotal',
 
 736        'data'    => $eb_string,
 
 737        'class' => 'listtotal',
 
 740        'data'    => $saldo_new,
 
 742        'class' => 'listtotal',
 
 745        'data'    => $form->format_amount(\%myconfig, abs($form->{current_balance_debit}) , 2) . " S",
 
 746        'class' => 'listtotal',
 
 749        'data'    => $form->format_amount(\%myconfig, $form->{current_balance_credit}, 2) . " H",
 
 750        'class' => 'listtotal',
 
 755        'class' => 'listtotal',
 
 759   $report->add_data($row);
 
 761   $report->generate_with_headers();
 
 763   $main::lxdebug->leave_sub();
 
 766 sub create_subtotal_row {
 
 767   $main::lxdebug->enter_sub();
 
 769   my $form     = $main::form;
 
 770   my %myconfig = %main::myconfig;
 
 772   my ($totals, $columns, $column_alignment, $class) = @_;
 
 774   my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
 
 776   map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } qw(credit debit);
 
 778   map { $totals->{$_} = 0 } qw(debit credit);
 
 780   $main::lxdebug->leave_sub();