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();
 
 109   $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
 111   $report->set_columns(%column_defs);
 
 112   $report->set_column_order(@columns);
 
 114   $report->set_export_options('chart_of_accounts');
 
 116   $report->set_sort_indicator($form->{sort}, 1);
 
 118   my %totals = ('debit' => 0, 'credit' => 0);
 
 120   foreach my $ca (@{ $form->{CA} }) {
 
 121     next unless defined $ca->{amount};
 
 124     foreach (qw(debit credit)) {
 
 125       $totals{$_} += $ca->{$_} * 1;
 
 126       $ca->{$_}    = $form->format_amount(\%myconfig, $ca->{$_}, 2) if ($ca->{$_});
 
 129     map { $row->{$_} = { 'data' => $ca->{$_} } } @columns;
 
 131     map { $row->{$_}->{align} = 'right'       } qw(debit credit);
 
 132     map { $row->{$_}->{class} = 'listheading' } @columns if ($ca->{charttype} eq "H");
 
 134     $row->{accno}->{link} = build_std_url('action=list', 'accno=' . E($ca->{accno}), 'description=' . E($ca->{description}));
 
 136     $report->add_data($row);
 
 139   my $row = { map { $_ => { 'class' => 'listtotal', 'align' => 'right' } } @columns };
 
 140   map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals{$_}, 2) } qw(debit credit);
 
 142   $report->add_separator();
 
 143   $report->add_data($row);
 
 145   $report->generate_with_headers();
 
 147   $main::lxdebug->leave_sub();
 
 151   $main::lxdebug->enter_sub();
 
 153   my $form     = $main::form;
 
 154   my %myconfig = %main::myconfig;
 
 155   my $locale   = $main::locale;
 
 157   $main::auth->assert('report');
 
 159   $form->{title} = $locale->text('List Transactions');
 
 160   $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}";
 
 161   my $year = (localtime)[5] + 1900;
 
 164   $form->all_departments(\%myconfig);
 
 165   if (@{ $form->{all_departments} || [] }) {
 
 166     $form->{selectdepartment} = "<option>\n";
 
 169       $form->{selectdepartment} .=
 
 170         "<option>$_->{description}--$_->{id}\n"
 
 171     } (@{ $form->{all_departments} || [] });
 
 176           <th align=right nowrap>| . $locale->text('Department') . qq|</th>
 
 177           <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
 
 179 | if $form->{selectdepartment};
 
 180   my $accrual = ($main::eur) ? ""        : "checked";
 
 181   my $cash    = ($main::eur) ? "checked" : "";
 
 183   my $name_1    = "fromdate";
 
 184   my $id_1      = "fromdate";
 
 185   my $value_1   = "$form->{fromdate}";
 
 186   my $trigger_1 = "trigger1";
 
 187   my $name_2    = "todate";
 
 190   my $trigger_2 = "trigger2";
 
 192   my ($button1, $button1_2, $button2, $button2_2, $jsscript);
 
 194   # with JavaScript Calendar
 
 195   if ($form->{jsscript}) {
 
 199          <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 201         <input type=button name=$name_2 id="$trigger_2" value=|
 
 202         . $locale->text('button') . qq|>|;
 
 206         Form->write_trigger(\%myconfig, "1", "$name_2", "BR", "$trigger_2");
 
 209          <input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\" value="$value_1">|;
 
 211         <input type=button name=$name_1 id="$trigger_1" value=|
 
 212         . $locale->text('button') . qq|>|;
 
 214          <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 216          <input type=button name=$name_2 id="$trigger_2" value=|
 
 217         . $locale->text('button') . qq|>
 
 222         Form->write_trigger(\%myconfig, "2", "$name_1", "BR", "$trigger_1",
 
 223                             "$name_2", "BL", "$trigger_2");
 
 227     # without JavaScript Calendar
 
 230         qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 233         qq|<input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value="$value_1" onBlur=\"check_right_date_format(this)\">|;
 
 235         qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
 
 238   $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
 
 240   my $onload = qq|focus()|;
 
 241   $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
 
 242   $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
 
 247   $form->{description} =~ s/\"/"/g;
 
 250 <body onLoad="$onload">
 
 252 <form method=post action=$form->{script}>
 
 254 <input type=hidden name=accno value=$form->{accno}>
 
 255 <input type=hidden name=description value="$form->{description}">
 
 256 <input type=hidden name=sort value=transdate>
 
 257 <input type=hidden name=eur value=$main::eur>
 
 258 <input type=hidden name=accounttype value=$form->{accounttype}>
 
 260 <table border=0 width=100%>
 
 262     <th class=listtop>$form->{title}</th>
 
 268           <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
 
 269       . $locale->text('Customized Report') . qq|</th>
 
 272           <th colspan=1>| . $locale->text('Year') . qq|</th>
 
 273           <td><input name=year size=11 title="|
 
 274       . $locale->text('YYYY') . qq|" value="$year"></td>
 
 281 <b> | . $locale->text('Yearly') . qq|</b> </td>
 
 282                 <th align=left>| . $locale->text('Quarterly') . qq|</th>
 
 283                 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
 
 286                 <td align=right>  <input name=duetyp class=radio type=radio value="13"></td>
 
 287                 <td><input name=duetyp class=radio type=radio value="A"> 1. | . $locale->text('Quarter') . qq|</td>
 
 288                 <td><input name=duetyp class=radio type=radio value="1" "checked"> | . $locale->text('January') . qq|</td>
 
 289                 <td><input name=duetyp class=radio type=radio value="5" > | . $locale->text('May') . qq|</td>
 
 290                 <td><input name=duetyp class=radio type=radio value="9" > | . $locale->text('September') . qq|</td>
 
 294                 <td align= right> </td>
 
 295                 <td><input name=duetyp class=radio type=radio value="B"> 2. | . $locale->text('Quarter') . qq|</td>
 
 296                 <td><input name=duetyp class=radio type=radio value="2" > | . $locale->text('February') . qq|</td>
 
 297                 <td><input name=duetyp class=radio type=radio value="6" > | . $locale->text('June') . qq|</td>
 
 298                 <td><input name=duetyp class=radio type=radio value="10" > | . $locale->text('October') . qq|</td>
 
 302                 <td><input name=duetyp class=radio type=radio value="C"> 3. | . $locale->text('Quarter') . qq|</td>
 
 303                 <td><input name=duetyp class=radio type=radio value="3" > | . $locale->text('March') . qq|</td>
 
 304                 <td><input name=duetyp class=radio type=radio value="7" > | . $locale->text('July') . qq|</td>
 
 305                 <td><input name=duetyp class=radio type=radio value="11" > | . $locale->text('November') . qq|</td>
 
 310                 <td><input name=duetyp class=radio type=radio value="D"> 4. | . $locale->text('Quarter') . qq| </td>
 
 311                 <td><input name=duetyp class=radio type=radio value="4" > | . $locale->text('April') . qq|</td>
 
 312                 <td><input name=duetyp class=radio type=radio value="8" > | . $locale->text('August') . qq|</td>
 
 313                 <td><input name=duetyp class=radio type=radio value="12" > | . $locale->text('December') . qq|</td>
 
 317                    <td colspan=5><hr size=3 noshade></td>
 
 320           <th align=left><input name=reporttype class=radio type=radio value="free"> | . $locale->text('Free report period') . qq|</th>
 
 321           <td align=left colspan=4>| . $locale->text('From') . qq| 
 
 324               | . $locale->text('Bis') . qq| 
 
 330                    <td colspan=5><hr size=3 noshade></td>
 
 333           <th align=leftt>| . $locale->text('Method') . qq|</th>
 
 334           <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>| . $locale->text('Accrual') . qq|
 
 335            <input name=method class=radio type=radio value=cash $cash>| . $locale->text('EUR') . qq|</td>
 
 338          <th align=right colspan=4>| . $locale->text('Decimalplaces') . qq|</th>
 
 339              <td><input name=decimalplaces size=3 value="2"></td>
 
 342             <td><input name="subtotal" class=checkbox type=checkbox value=1> | . $locale->text('Subtotal') . qq|</td>
 
 346   <tr><td colspan=5 ><hr size=3 noshade></td></tr>
 
 349 <br><input class=submit type=submit name=action value="|
 
 350     . $locale->text('List Transactions') . qq|">
 
 357   $main::lxdebug->leave_sub();
 
 360 sub format_debit_credit {
 
 361   $main::lxdebug->enter_sub();
 
 365   my $form     = $main::form;
 
 366   my %myconfig = %main::myconfig;
 
 367   my $locale   = $main::locale;
 
 369   my $formatted_dc  = $form->format_amount(\%myconfig, abs($dc), 2) . ' ';
 
 370   $formatted_dc    .= ($dc > 0) ? $locale->text('Credit (one letter abbreviation)') : $locale->text('Debit (one letter abbreviation)');
 
 372   $main::lxdebug->leave_sub();
 
 374   return $formatted_dc;
 
 378 sub list_transactions {
 
 379   $main::lxdebug->enter_sub();
 
 381   my $form     = $main::form;
 
 382   my %myconfig = %main::myconfig;
 
 383   my $locale   = $main::locale;
 
 385   $main::auth->assert('report');
 
 387   $form->{title} = $locale->text('Account') . " $form->{accno} - $form->{description}";
 
 389   if ($form->{reporttype} eq "custom") {
 
 391     #forgotten the year --> thisyear
 
 392     if ($form->{year} !~ m/^\d\d\d\d$/) {
 
 393       $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
 
 399     if ($form->{duetyp} eq "13") {
 
 400       $form->{fromdate} = "1.1.$form->{year}";
 
 401       $form->{todate}   = "31.12.$form->{year}";
 
 405     if ($form->{duetyp} eq "A") {
 
 406       $form->{fromdate} = "1.1.$form->{year}";
 
 407       $form->{todate}   = "31.3.$form->{year}";
 
 409     if ($form->{duetyp} eq "B") {
 
 410       $form->{fromdate} = "1.4.$form->{year}";
 
 411       $form->{todate}   = "30.6.$form->{year}";
 
 413     if ($form->{duetyp} eq "C") {
 
 414       $form->{fromdate} = "1.7.$form->{year}";
 
 415       $form->{todate}   = "30.9.$form->{year}";
 
 417     if ($form->{duetyp} eq "D") {
 
 418       $form->{fromdate} = "1.10.$form->{year}";
 
 419       $form->{todate}   = "31.12.$form->{year}";
 
 424       $form->{duetyp} eq "1" && do {
 
 425         $form->{fromdate} = "1.1.$form->{year}";
 
 426         $form->{todate}   = "31.1.$form->{year}";
 
 429       $form->{duetyp} eq "2" && do {
 
 430         $form->{fromdate} = "1.2.$form->{year}";
 
 432         #this works from 1901 to 2099, 1900 and 2100 fail.
 
 433         my $leap = ($form->{year} % 4 == 0) ? "29" : "28";
 
 434         $form->{todate} = "$leap.2.$form->{year}";
 
 437       $form->{duetyp} eq "3" && do {
 
 438         $form->{fromdate} = "1.3.$form->{year}";
 
 439         $form->{todate}   = "31.3.$form->{year}";
 
 442       $form->{duetyp} eq "4" && do {
 
 443         $form->{fromdate} = "1.4.$form->{year}";
 
 444         $form->{todate}   = "30.4.$form->{year}";
 
 447       $form->{duetyp} eq "5" && do {
 
 448         $form->{fromdate} = "1.5.$form->{year}";
 
 449         $form->{todate}   = "31.5.$form->{year}";
 
 452       $form->{duetyp} eq "6" && do {
 
 453         $form->{fromdate} = "1.6.$form->{year}";
 
 454         $form->{todate}   = "30.6.$form->{year}";
 
 457       $form->{duetyp} eq "7" && do {
 
 458         $form->{fromdate} = "1.7.$form->{year}";
 
 459         $form->{todate}   = "31.7.$form->{year}";
 
 462       $form->{duetyp} eq "8" && do {
 
 463         $form->{fromdate} = "1.8.$form->{year}";
 
 464         $form->{todate}   = "31.8.$form->{year}";
 
 467       $form->{duetyp} eq "9" && do {
 
 468         $form->{fromdate} = "1.9.$form->{year}";
 
 469         $form->{todate}   = "30.9.$form->{year}";
 
 472       $form->{duetyp} eq "10" && do {
 
 473         $form->{fromdate} = "1.10.$form->{year}";
 
 474         $form->{todate}   = "31.10.$form->{year}";
 
 477       $form->{duetyp} eq "11" && do {
 
 478         $form->{fromdate} = "1.11.$form->{year}";
 
 479         $form->{todate}   = "30.11.$form->{year}";
 
 482       $form->{duetyp} eq "12" && do {
 
 483         $form->{fromdate} = "1.12.$form->{year}";
 
 484         $form->{todate}   = "31.12.$form->{year}";
 
 490   CA->all_transactions(\%myconfig, \%$form);
 
 492   $form->{saldo_old} += $form->{beginning_balance};
 
 493   $form->{saldo_new} += $form->{beginning_balance};
 
 494   my $saldo_old = format_debit_credit($form->{saldo_old});
 
 495   my $eb_string = format_debit_credit($form->{beginning_balance});
 
 496   $form->{balance} = $form->{saldo_old};
 
 499   if ($form->{department}) {
 
 500     my ($department) = split /--/, $form->{department};
 
 501     push @options, $locale->text('Department') . " : $department";
 
 503   if ($form->{projectnumber}) {
 
 504     push @options, $locale->text('Project Number') . " : $form->{projectnumber}<br>";
 
 508   if ($form->{fromdate} || $form->{todate}) {
 
 509     my ($fromdate, $todate);
 
 511     if ($form->{fromdate}) {
 
 512       $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
 
 514     if ($form->{todate}) {
 
 515       $todate = $locale->date(\%myconfig, $form->{todate}, 1);
 
 518     $period = "$fromdate - $todate";
 
 521     $period = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
 
 524   push @options, $period;
 
 526   $form->{print_date} = $locale->text('Create Date') . " " . $locale->date(\%myconfig, $form->current_date(\%myconfig), 0);
 
 527   push (@options, $form->{print_date});
 
 529   $form->{company} = $locale->text('Company') . " " . $myconfig{company};
 
 530   push (@options, $form->{company});
 
 532   my @columns     = qw(transdate reference description gegenkonto debit credit ustkonto ustrate balance);
 
 534     'transdate'   => { 'text' => $locale->text('Date'), },
 
 535     'reference'   => { 'text' => $locale->text('Reference'), },
 
 536     'description' => { 'text' => $locale->text('Description'), },
 
 537     'debit'       => { 'text' => $locale->text('Debit'), },
 
 538     'credit'      => { 'text' => $locale->text('Credit'), },
 
 539     'gegenkonto'  => { 'text' => $locale->text('Gegenkonto'), },
 
 540     'ustkonto'    => { 'text' => $locale->text('USt-Konto'), },
 
 541     'balance'     => { 'text' => $locale->text('Balance'), },
 
 542     'ustrate'     => { 'text' => $locale->text('Satz %'), },
 
 545   my @hidden_variables = qw(accno fromdate todate description accounttype l_heading subtotal department projectnumber project_id sort);
 
 547   my $link = build_std_url('action=list_transactions', grep { $form->{$_} } @hidden_variables);
 
 549   $form->{callback} = $link . '&sort=' . E($form->{sort});
 
 551   my %column_alignment = map { $_ => 'right' } qw(debit credit);
 
 553   my @custom_headers = ();
 
 555  push @custom_headers, [
 
 556    { 'text' => 'Letzte Buchung', },
 
 557    { 'text' => 'EB-Wert', },
 
 558    { 'text' => 'Saldo alt', 'colspan' => 2, },
 
 559    { 'text' => 'Jahresverkehrszahlen alt', 'colspan' => 2, },
 
 560    { 'text' => '', 'colspan' => 2, },
 
 562  push @custom_headers, [
 
 563    { 'text' => $form->{last_transaction}, },
 
 564    { 'text' => $eb_string, },
 
 565    { 'text' => $saldo_old, 'colspan' => 2, },
 
 566    { 'text' => $form->format_amount(\%myconfig, abs($form->{old_balance_debit}), 2) . " S", },
 
 567    { 'text' => $form->format_amount(\%myconfig, $form->{old_balance_credit}, 2) . " H", },
 
 568    { 'text' => '', 'colspan' => 2, },
 
 571  push @custom_headers, [
 
 572    { 'text' => $locale->text('Date'), 'link' => $link . "&sort=transdate", },
 
 573    { 'text' => $locale->text('Reference'), 'link' => $link . "&sort=reference",  },
 
 574    { 'text' => $locale->text('Description'), 'link' => $link . "&sort=description",  },
 
 575    { 'text' => $locale->text('Gegenkonto'), },
 
 576    { 'text' => $locale->text('Debit'), },
 
 577    { 'text' => $locale->text('Credit'), },
 
 578    { 'text' => $locale->text('USt-Konto'), },
 
 579    { 'text' => $locale->text('Satz %'), },
 
 580    { 'text' => $locale->text('Balance'), },
 
 587   my $report = SL::ReportGenerator->new(\%myconfig, $form);
 
 588   $report->set_custom_headers(@custom_headers);
 
 590   $report->set_options('top_info_text'         => join("\n", @options),
 
 591                        'output_format'         => 'HTML',
 
 592                        'title'                 => $form->{title},
 
 593                        'attachment_basename'   => $locale->text('list_of_transactions') . strftime('_%Y%m%d', localtime time),
 
 594                        'std_column_visibility' => 1,
 
 596   $report->set_options_from_form();
 
 597   $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
 599   $report->set_columns(%column_defs);
 
 600   $report->set_column_order(@columns);
 
 602   $report->set_export_options('list_transactions', @hidden_variables);
 
 604   $report->set_sort_indicator($form->{sort}, 1);
 
 606   $column_defs{balance}->{visible} = 1;
 
 608   my $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
 
 612   my %totals    = ( 'debit' => 0, 'credit' => 0 );
 
 613   my %subtotals = ( 'debit' => 0, 'credit' => 0 );
 
 614   my ($previous_index, $row_set);
 
 616   foreach my $ca (@{ $form->{CA} }) {
 
 618     foreach (qw(debit credit)) {
 
 619       $subtotals{$_} += $ca->{$_};
 
 620       $totals{$_}    += $ca->{$_};
 
 621       if ($_ =~ /debit.*/) {
 
 626       $form->{balance}= $form->{balance} + $ca->{$_} * $ml;
 
 627       $ca->{$_}       = $form->format_amount(\%myconfig, $ca->{$_}, 2) if ($ca->{$_} != 0);
 
 631     if (($form->{subtotal})
 
 632         && (($idx == scalar @{ $form->{CA} } - 1)
 
 633             || ($ca->{$form->{sort}} ne $form->{CA}->[$idx + 1]->{$form->{sort}}))) {
 
 639     $ca->{ustrate} = $form->format_amount(\%myconfig, $ca->{ustrate} * 100, 2) if ($ca->{ustrate} != 0);
 
 641     if ($ca->{memo} ne "") {
 
 642       $ca->{description} .= " \n " . $ca->{memo};
 
 647     foreach my $gegenkonto (@{ $ca->{GEGENKONTO} }) {
 
 648       if ($ca->{gegenkonto} eq "") {
 
 649         $ca->{gegenkonto} = $gegenkonto->{accno};
 
 651         $ca->{gegenkonto} .= ", " . $gegenkonto->{accno};
 
 658         'align' => $column_alignment{$_},
 
 662     $row->{balance}->{data}        = $form->format_amount(\%myconfig, $form->{balance}, 2, 'DRCR');
 
 664     if ($ca->{index} ne $previous_index) {
 
 665 #       $report->add_data($row_set) if ($row_set);
 
 668       $previous_index  = $ca->{index};
 
 670       $row->{reference}->{link} = build_std_url("script=$ca->{module}.pl", 'action=edit', 'id=' . E($ca->{id}), 'callback');
 
 672     } elsif ($ca->{index} eq $previous_index) {
 
 673       map { $row->{$_}->{data} = '' } qw(reference description);
 
 674       $row->{transdate}->{data} = '' if ($form->{sort} eq 'transdate');
 
 679     push @{ $row_set }, $row;
 
 681     push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, 'listsubtotal') if ($do_subtotal);
 
 685     $report->add_data($row_set);
 
 689   $report->add_data($row_set) if ($row_set);
 
 691   $report->add_separator();
 
 693   my $row = create_subtotal_row(\%totals, \@columns, \%column_alignment, 'listtotal');
 
 696   $row->{balance}->{data}        = $form->format_amount(\%myconfig, $form->{balance}, 2, 'DRCR');
 
 698   $report->add_data($row);
 
 701   $report->add_separator();
 
 705        'class' => 'listtotal',
 
 708        'data'    => $locale->text('EB-Wert'),
 
 709        'class' => 'listtotal',
 
 712        'data'    => $locale->text('Saldo neu'),
 
 714        'class' => 'listtotal',
 
 717        'data'    => $locale->text('Jahresverkehrszahlen neu'),
 
 720        'class' => 'listtotal',
 
 726        'class' => 'listtotal',
 
 730   $report->add_data($row);
 
 731   my $saldo_new = format_debit_credit($form->{saldo_new});
 
 735        'class' => 'listtotal',
 
 738        'data'    => $eb_string,
 
 739        'class' => 'listtotal',
 
 742        'data'    => $saldo_new,
 
 744        'class' => 'listtotal',
 
 747        'data'    => $form->format_amount(\%myconfig, abs($form->{current_balance_debit}) , 2) . " S",
 
 748        'class' => 'listtotal',
 
 751        'data'    => $form->format_amount(\%myconfig, $form->{current_balance_credit}, 2) . " H",
 
 752        'class' => 'listtotal',
 
 757        'class' => 'listtotal',
 
 761   $report->add_data($row);
 
 763   $report->generate_with_headers();
 
 765   $main::lxdebug->leave_sub();
 
 768 sub create_subtotal_row {
 
 769   $main::lxdebug->enter_sub();
 
 771   my $form     = $main::form;
 
 772   my %myconfig = %main::myconfig;
 
 774   my ($totals, $columns, $column_alignment, $class) = @_;
 
 776   my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
 
 778   map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } qw(credit debit);
 
 780   map { $totals->{$_} = 0 } qw(debit credit);
 
 782   $main::lxdebug->leave_sub();