X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Frp.pl;h=aaf47ff5fec8d9fb12f2f758d5486602bff21086;hb=72be9c763f3b7f7df1fae4fe10011e45f9e2ad1d;hp=01ae84fdb8cba2ce44fb7bf344636855a5ab073d;hpb=0c2be9979d3c323a8f88ca372c0e1314774d7293;p=kivitendo-erp.git
diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl
index 01ae84fdb..aaf47ff5f 100644
--- a/bin/mozilla/rp.pl
+++ b/bin/mozilla/rp.pl
@@ -158,20 +158,9 @@ sub report {
my $is_bwa = $::form->{report} eq "bwa";
my $is_balance_sheet = $::form->{report} eq "balance_sheet";
my $is_trial_balance = $::form->{report} eq "trial_balance";
- my $is_taxreport = $::form->{report} =~ /^tax_/;
- my $is_nontaxable = $::form->{report} =~ /^nontaxable_/;
my $is_aging = $::form->{report} =~ /^a[rp]_aging$/;
my $is_payments = $::form->{report} =~ /(receipts|payments)$/;
-# if (is_taxreport) {
-# $::form->{db} = ($::form->{report} =~ /_collected/) ? "ar" : "ap";
-# RP->get_taxaccounts(\%::myconfig, $::form);
-# }
-#
-# if ($is_nontaxable) {
-# $::form->{db} = ($::form->{report} =~ /_sales/) ? "ar" : "ap";
-# }
-
my ($label, $nextsub, $vc);
if ($is_aging) {
my $is_sales = $::form->{report} eq 'ar_aging';
@@ -1349,259 +1338,138 @@ sub statement_details {
}
sub generate_tax_report {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('report');
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
+ $::lxdebug->enter_sub;
+ $::auth->assert('report');
- RP->tax_report(\%myconfig, \%$form);
+ RP->tax_report(\%::myconfig, $::form);
- my $descvar = "$form->{accno}_description";
- my $description = $form->escape($form->{$descvar});
- my $ratevar = "$form->{accno}_rate";
+ my $descvar = "$::form->{accno}_description";
my ($subtotalnetamount, $subtotaltax, $subtotal) = (0, 0, 0);
- my $department = $form->escape($form->{department});
-
# construct href
- my $href =
- "$form->{script}?&action=generate_tax_report&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&report=$form->{report}";
-
- # construct callback
- $description = $form->escape($form->{$descvar}, 1);
- $department = $form->escape($form->{department}, 1);
- my $callback =
- "$form->{script}?&action=generate_tax_report&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&report=$form->{report}";
-
- my $title = $form->escape($form->{title});
- $href .= "&title=$title";
- $title = $form->escape($form->{title}, 1);
- $callback .= "&title=$title";
-
- $form->{title} = qq|$form->{title} $form->{"$form->{accno}_description"} |;
+ my $href =
+ my $callback = build_std_url('action=generate_tax_report', $descvar,
+ qw(fromdate todate db method accno department report title));
- my @columns =
- $form->sort_columns(qw(id transdate invnumber name netamount tax amount));
+ my @columns = $::form->sort_columns(qw(id transdate invnumber name netamount tax amount));
my @column_index;
- foreach my $item (@columns) {
- if ($form->{"l_$item"} eq "Y") {
- push @column_index, $item;
-
- # add column to href and callback
+ for my $item (@columns, 'subtotal') {
+ if ($::form->{"l_$item"} eq "Y") {
$callback .= "&l_$item=Y";
$href .= "&l_$item=Y";
}
}
- if ($form->{l_subtotal} eq 'Y') {
- $callback .= "&l_subtotal=Y";
- $href .= "&l_subtotal=Y";
+ for my $item (@columns) {
+ if ($::form->{"l_$item"} eq "Y") {
+ push @column_index, $item;
+ }
}
- my $option;
- if ($form->{department}) {
- ($department) = split /--/, $form->{department};
- $option = $locale->text('Department') . " : $department";
+ my @options;
+ if ($::form->{department}) {
+ my ($department) = split /--/, $::form->{department};
+ push @options, $::locale->text('Department') . " : $department";
}
- my ($fromdate, $todate);
# if there are any dates
- if ($form->{fromdate} || $form->{todate}) {
- if ($form->{fromdate}) {
- $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
- }
- if ($form->{todate}) {
- $todate = $locale->date(\%myconfig, $form->{todate}, 1);
- }
-
- $form->{period} = "$fromdate - $todate";
+ if ($::form->{fromdate} || $::form->{todate}) {
+ my $fromdate = $::form->{fromdate} ? $::locale->date(\%::myconfig, $::form->{fromdate}, 1) : '';
+ my $todate = $::form->{todate} ? $::locale->date(\%::myconfig, $::form->{todate}, 1) : '';
+ push @options, "$fromdate - $todate";
} else {
- $form->{period} =
- $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
+ push @options, $::locale->date(\%::myconfig, $::form->current_date, 1);
}
my ($name, $invoice, $arap);
- if ($form->{db} eq 'ar') {
- $name = $locale->text('Customer');
+ if ($::form->{db} eq 'ar') {
+ $name = $::locale->text('Customer');
$invoice = 'is.pl';
$arap = 'ar.pl';
}
- if ($form->{db} eq 'ap') {
- $name = $locale->text('Vendor');
+ if ($::form->{db} eq 'ap') {
+ $name = $::locale->text('Vendor');
$invoice = 'ir.pl';
$arap = 'ap.pl';
}
- $option .= "
" if $option;
- $option .= "$form->{period}";
-
- my %column_header;
- $column_header{id} = qq|
| . $locale->text('ID') . qq| | |;
- $column_header{invnumber} = qq|| . $locale->text('Invoice') . qq| | |;
- $column_header{transdate} = qq|| . $locale->text('Date') . qq| | |;
- $column_header{netamount} = qq|| . $locale->text('Amount') . qq| | |;
- $column_header{tax} = qq|| . $locale->text('Tax') . qq| | |;
- $column_header{amount} = qq|| . $locale->text('Total') . qq| | |;
-
- $column_header{name} = qq|$name | |;
-
- $form->header;
-
- print qq|
-
-
-
-
- $form->{title} |
-
-
-
- $option |
-
-
-
-
-
-|;
-
- map { print "$column_header{$_}\n" } @column_index;
+ my %column_header = (
+ id => $::locale->text('ID'),
+ invnumber => $::locale->text('Invoice'),
+ transdate => $::locale->text('Date'),
+ netamount => $::locale->text('Amount'),
+ tax => $::locale->text('Tax'),
+ amount => $::locale->text('Total'),
+ name => $name,
+ );
- print qq|
-
-|;
+ my %column_sorted = map { $_ => 1 } qw(id invnumber transdate);
- # add sort and escape callback
- $callback = $form->escape($callback . "&sort=$form->{sort}");
+ $callback .= "&sort=$::form->{sort}";
my $sameitem;
- if (@{ $form->{TR} }) {
- $sameitem = $form->{TR}->[0]->{ $form->{sort} };
+ if (@{ $::form->{TR} }) {
+ $sameitem = $::form->{TR}->[0]->{ $::form->{sort} };
}
- my ($totalnetamount, $totaltax);
- my ($i);
- foreach my $ref (@{ $form->{TR} }) {
+ my ($totalnetamount, $totaltax, @data);
+ for my $ref (@{ $::form->{TR} }) {
my $module = ($ref->{invoice}) ? $invoice : $arap;
- if ($form->{l_subtotal} eq 'Y') {
- if ($sameitem ne $ref->{ $form->{sort} }) {
- tax_subtotal(\@column_index, \$subtotalnetamount, \$subtotaltax, \$subtotal);
- $sameitem = $ref->{ $form->{sort} };
+ if ($::form->{l_subtotal} eq 'Y') {
+ if ($sameitem ne $ref->{ $::form->{sort} }) {
+ push @data, {
+ subtotal => 1,
+ netamount => $subtotalnetamount,
+ tax => $subtotaltax,
+ amount => $subtotal,
+ };
+ $subtotalnetamount = 0;
+ $subtotaltax = 0;
+ $sameitem = $ref->{ $::form->{sort} };
}
}
- $totalnetamount += $ref->{netamount};
- $totaltax += $ref->{tax};
- $ref->{amount} = $ref->{netamount} + $ref->{tax};
-
$subtotalnetamount += $ref->{netamount};
$subtotaltax += $ref->{tax};
+ $totalnetamount += $ref->{netamount};
+ $totaltax += $ref->{tax};
+ $ref->{amount} = $ref->{netamount} + $ref->{tax};
- map {
- $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, " ");
- } qw(netamount tax amount);
-
- my %column_data;
- $column_data{id} = qq|$ref->{id} | |;
- $column_data{invnumber} =
- qq|{id}&callback=$callback>$ref->{invnumber} | |;
- $column_data{transdate} = qq|$ref->{transdate} | |;
- $column_data{name} = qq|$ref->{name} | |;
-
- map { $column_data{$_} = qq|$ref->{$_} | | }
- qw(netamount tax amount);
-
- $i++;
- $i %= 2;
- print qq|
-
-|;
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
-
-|;
-
+ push @data, { map { $_ => { data => $ref->{$_} } } keys %$ref };
+ $data[-1]{invnumber}{link} = "$module?action=edit&id=$ref->{id}&callback=$callback";
+ $data[-1]{$_}{numeric} = 1 for qw(netamount tax amount);
}
- if ($form->{l_subtotal} eq 'Y') {
- tax_subtotal(\@column_index, \$subtotalnetamount, \$subtotaltax, \$subtotal);
+ if ($::form->{l_subtotal} eq 'Y') {
+ push @data, {
+ subtotal => 1,
+ netamount => $subtotalnetamount,
+ tax => $subtotaltax,
+ amount => $subtotal,
+ };
}
- my %column_data;
- map { $column_data{$_} = qq| | | } @column_index;
-
- print qq|
-
-
-|;
-
- my $total = $form->format_amount(\%myconfig, $totalnetamount + $totaltax, 2, " ");
- $totalnetamount = $form->format_amount(\%myconfig, $totalnetamount, 2, " ");
- $totaltax = $form->format_amount(\%myconfig, $totaltax, 2, " ");
-
- $column_data{netamount} = qq|$totalnetamount | |;
- $column_data{tax} = qq|$totaltax | |;
- $column_data{amount} = qq|$total | |;
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
-
-
- |
-
-
-
|
-
-
-
-
-