X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Frp.pl;h=7f5aa0d6969a382be88fd68d4c587c354ec9ff04;hb=c66624d02068502ae8e7bc55f7ec2edbcd8a4702;hp=2a6321422b824873f0ae946d312f9b171ea0047b;hpb=796b3881fae7c5f5feacfc5914a2d47cb85e18e6;p=kivitendo-erp.git
diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl
index 2a6321422..7f5aa0d69 100644
--- a/bin/mozilla/rp.pl
+++ b/bin/mozilla/rp.pl
@@ -39,13 +39,12 @@ use POSIX qw(strftime);
use SL::PE;
use SL::RP;
-use SL::USTVA;
use SL::Iconv;
use SL::ReportGenerator;
require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
-require "bin/mozilla/report_generator.pl";
+require "bin/mozilla/reportgenerator.pl";
1;
@@ -92,9 +91,32 @@ require "bin/mozilla/report_generator.pl";
# $locale->text('Non-taxable Sales')
# $locale->text('Non-taxable Purchases')
+# $form->parse_html_template('rp/html_report_susa')
+
+my $rp_access_map = {
+ 'projects' => 'report',
+ 'ar_aging' => 'general_ledger',
+ 'ap_aging' => 'general_ledger',
+ 'receipts' => 'cash',
+ 'payments' => 'cash',
+ 'trial_balance' => 'report',
+ 'income_statement' => 'report',
+ 'bwa' => 'report',
+ 'balance_sheet' => 'report',
+};
+
+sub check_rp_access {
+ my $right = $rp_access_map->{$form->{report}};
+ $right ||= 'DOES_NOT_EXIST';
+
+ $auth->assert($right);
+}
+
sub report {
$lxdebug->enter_sub();
+ check_rp_access();
+
%title = ('balance_sheet' => 'Balance Sheet',
'income_statement' => 'Income Statement',
'trial_balance' => 'Trial Balance',
@@ -107,8 +129,7 @@ sub report {
'receipts' => 'Receipts',
'payments' => 'Payments',
'projects' => 'Project Transactions',
- 'bwa' => 'Betriebswirtschaftliche Auswertung',
- 'ustva' => 'Umsatzsteuervoranmeldung',);
+ 'bwa' => 'Betriebswirtschaftliche Auswertung',);
$form->{title} = $locale->text($title{ $form->{report} });
@@ -121,11 +142,7 @@ sub report {
$form->all_departments(\%myconfig);
if (@{ $form->{all_departments} }) {
$form->{selectdepartment} = "
+ my @hidden_variables = qw(fromdate todate department l_heading l_subtotal all_accounts sort accounttype eur projectnumber project_id title nextsub);
-
-
- $form->{title} |
-
-
-
- $options |
-
-
-
-
- |;
+ $form->{callback} = build_std_url("action=$action", grep { $form->{$_} } @hidden_variables);
+
+ my $report = SL::ReportGenerator->new(\%myconfig, $form);
+
+ $report->set_options('top_info_text' => join("\n", @options),
+ 'output_format' => 'HTML',
+ 'title' => $form->{title},
+ 'attachment_basename' => $locale->text('list_of_transactions') . strftime('_%Y%m%d', localtime time),
+ 'std_column_visibility' => 1,
+ );
+ $report->set_options_from_form();
- map { print "$column_header{$_}\n" } @column_index;
+ $report->set_columns(%column_defs);
+ $report->set_column_order(@columns);
- print qq|
-
-|;
+ $report->set_export_options($action, @hidden_variables);
- # sort the whole thing by account numbers and display
- foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} }) {
-
- $description = $form->escape($ref->{description});
-
- $href =
- qq|ca.pl?action=list_transactions&accounttype=$form->{accounttype}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&sort=transdate&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&eur=$form->{eur}&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}&accno=$ref->{accno}&description=$description|;
-
- $ml = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
-
- $debit = ($ref->{debit} != 0) ? $form->format_amount(\%myconfig, $ref->{debit}, 2, " ") : " ";
- $credit = ($ref->{credit} != 0) ? $form->format_amount(\%myconfig, $ref->{credit}, 2, " ") : " ";
- $begbalance =
- $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2, " ");
- $endbalance =
- $form->format_amount(\%myconfig,
- ($ref->{balance} + $ref->{amount}) * $ml,
- 2, " ");
-
- # next if ($ref->{debit} == 0 && $ref->{credit} == 0);
-
- if ($ref->{charttype} eq "H" && $subtotal && $form->{l_subtotal}) {
- map { $column_data{$_} = " | " }
- qw(accno begbalance endbalance);
-
- $subtotalbegbalance =
- $form->format_amount(\%myconfig, $subtotalbegbalance, 2, " ");
- $subtotalendbalance =
- $form->format_amount(\%myconfig, $subtotalendbalance, 2, " ");
- $subtotaldebit =
- $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
- $subtotalcredit =
- $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
-
- $column_data{description} = "$subtotaldescription | ";
- $column_data{begbalance} = "$subtotalbegbalance | ";
- $column_data{endbalance} = "$subtotalendbalance | ";
- $column_data{debit} = "$subtotaldebit | ";
- $column_data{credit} = "$subtotalcredit | ";
-
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
+ $report->set_sort_indicator('accno', 1);
- print qq|
-
-|;
- }
+ my @totals_columns = qw(credit debit begbalance endbalance);
+ my %subtotals = map { $_ => 0 } @totals_columns;
+ my %totals = map { $_ => 0 } @totals_columns;
+ my $found_heading = 0;
+ my @tb = sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} };
- if ($ref->{charttype} eq "H") {
- $subtotal = 1;
- $subtotaldescription = $ref->{description};
- $subtotaldebit = $ref->{debit};
- $subtotalcredit = $ref->{credit};
- $subtotalbegbalance = 0;
- $subtotalendbalance = 0;
+ # sort the whole thing by account numbers and display
+ foreach my $idx (0 .. scalar(@tb) - 1) {
+ my $ref = $tb[$idx];
+ my $href = build_std_url('script=ca.pl', 'action=list_transactions', 'accno=' . E($ref->{accno}), 'description=' . E($ref->{description}), @hidden_variables);
- next unless $form->{l_heading};
+ my $ml = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
- map { $column_data{$_} = " | " }
- qw(accno debit credit begbalance endbalance);
- $column_data{description} =
- "$ref->{description} | ";
- }
+ my $row = { map { $_ => { 'align' => $column_alignment{$_} } } @columns };
- if ($ref->{charttype} eq "A") {
- $column_data{accno} = "$ref->{accno} | ";
- $column_data{description} = "$ref->{description} | ";
- $column_data{debit} = "$debit | ";
- $column_data{credit} = "$credit | ";
- $column_data{begbalance} = "$begbalance | ";
- $column_data{endbalance} = "$endbalance | ";
+ if ($ref->{charttype} eq 'H') {
+ next unless ($form->{l_heading});
- $totaldebit += $ref->{debit};
- $totalcredit += $ref->{credit};
+ %subtotals = map { $_ => 0 } @totals_columns;
+ $found_heading = 1;
+ $row->{description}->{class} = 'listheading';
+ $row->{description}->{data} = $ref->{description};
- $subtotalbegbalance += $ref->{balance} * $ml;
- $subtotalendbalance += ($ref->{balance} + $ref->{amount}) * $ml;
+ $report->add_data($row);
+ next;
}
- if ($ref->{charttype} eq "H") {
- print qq|
-
-|;
- }
- if ($ref->{charttype} eq "A") {
- $i++;
- $i %= 2;
- print qq|
-
-|;
+ foreach (qw(debit credit)) {
+ $subtotals{$_} += $ref->{$_};
+ $totals{$_} += $ref->{$_};
}
- map { print "$column_data{$_}\n" } @column_index;
+ $subtotals{begbalance} += $ref->{balance} * $ml;
+ $subtotals{endbalance} += ($ref->{balance} + $ref->{amount}) * $ml;
- print qq|
-
-|;
- }
+ map { $row->{$_}->{data} = $ref->{$_} } qw(accno description);
+ map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}, 2) if ($ref->{$_} != 0) } qw(credit debit);
- # print last subtotal
- if ($subtotal && $form->{l_subtotal}) {
- map { $column_data{$_} = " | " }
- qw(accno begbalance endbalance);
- $subtotalbegbalance =
- $form->format_amount(\%myconfig, $subtotalbegbalance, 2, " ");
- $subtotalendbalance =
- $form->format_amount(\%myconfig, $subtotalendbalance, 2, " ");
- $subtotaldebit =
- $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
- $subtotalcredit =
- $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
- $column_data{description} = "$subdescription | ";
- $column_data{begbalance} = "$subtotalbegbalance | ";
- $column_data{endbalance} = "$subtotalendbalance | ";
- $column_data{debit} = "$subtotaldebit | ";
- $column_data{credit} = "$subtotalcredit | ";
+ $row->{begbalance}->{data} = $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2);
+ $row->{endbalance}->{data} = $form->format_amount(\%myconfig, ($ref->{balance} + $ref->{amount}) * $ml, 2);
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
+ $report->add_data($row);
- print qq|
-
-|;
+ if ($form->{l_heading} && $found_heading &&
+ (($idx == scalar(@tb) - 1) || ('H' eq $tb[$idx + 1]->{charttype}))) {
+ $report->add_data(create_list_accounts_subtotal_row(\%subtotals, \@columns, \@totals_columns, 'listsubtotal'));
+ }
}
- $totaldebit = $form->format_amount(\%myconfig, $totaldebit, 2, " ");
- $totalcredit = $form->format_amount(\%myconfig, $totalcredit, 2, " ");
-
- map { $column_data{$_} = " | " }
- qw(accno description begbalance endbalance);
-
- $column_data{debit} = qq|$totaldebit | |;
- $column_data{credit} = qq|$totalcredit | |;
-
- print qq|
-
-|;
-
- map { print "$column_data{$_}\n" } @column_index;
+ $report->add_separator();
- print qq|
-
-
- |
-
-
-
|
-
-
+ $report->add_data(create_list_accounts_subtotal_row(\%totals, \@columns, [ qw(debit credit) ], 'listtotal'));
-