Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[kivitendo-erp.git] / bin / mozilla / rp.pl
index bc2eab6..d455d5a 100644 (file)
 
 use POSIX qw(strftime);
 
+use SL::DB::Project;
 use SL::PE;
 use SL::RP;
 use SL::Iconv;
 use SL::ReportGenerator;
 use Data::Dumper;
+use List::MoreUtils qw(any);
 
 require "bin/mozilla/arap.pl";
 require "bin/mozilla/common.pl";
@@ -92,8 +94,6 @@ use strict;
 # $locale->text('Receipts')
 # $locale->text('Payments')
 # $locale->text('Project Transactions')
-# $locale->text('Non-taxable Sales')
-# $locale->text('Non-taxable Purchases')
 # $locale->text('Business evaluation')
 
 # $form->parse_html_template('rp/html_report_susa')
@@ -132,8 +132,6 @@ sub report {
     ap_aging             => $::locale->text('Search AP Aging'),
     tax_collected        => $::locale->text('Tax collected'),
     tax_paid             => $::locale->text('Tax paid'),
-    nontaxable_sales     => $::locale->text('Non-taxable Sales'),
-    nontaxable_purchases => $::locale->text('Non-taxable Purchases'),
     receipts             => $::locale->text('Receipts'),
     payments             => $::locale->text('Payments'),
     projects             => $::locale->text('Project Transactions'),
@@ -213,35 +211,6 @@ sub report {
 
 sub continue { call_sub($main::form->{"nextsub"}); }
 
-sub get_project {
-  $main::lxdebug->enter_sub();
-
-  $main::auth->assert('report');
-
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-  my $locale   = $main::locale;
-
-  my $nextsub = shift;
-
-  $form->{project_id} = $form->{project_id_1};
-  if ($form->{projectnumber} && !$form->{project_id}) {
-    $form->{rowcount} = 1;
-
-    # call this instead of update
-    $form->{update}          = $nextsub;
-    $form->{projectnumber_1} = $form->{projectnumber};
-
-    delete $form->{sort};
-    check_project('generate_projects');
-
-    # if there is one only, assign id
-    $form->{project_id} = $form->{project_id_1};
-  }
-
-  $main::lxdebug->leave_sub();
-}
-
 sub generate_income_statement {
   $main::lxdebug->enter_sub();
 
@@ -460,8 +429,8 @@ sub generate_projects {
   my %myconfig = %main::myconfig;
   my $locale   = $main::locale;
 
-  &get_project("generate_projects");
-  $form->{projectnumber} = $form->{projectnumber_1};
+  my $project            = $form->{project_id} ? SL::DB::Project->new(id => $form->{project_id})->load : undef;
+  $form->{projectnumber} = $project ? $project->projectnumber : '';
 
   $form->{nextsub} = "generate_projects";
   $form->{title}   = $locale->text('Project Transactions');
@@ -1000,7 +969,7 @@ sub aging {
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
 
-  my @hidden_variables = qw(todate customer vendor arap title ct);
+  my @hidden_variables = qw(todate customer vendor arap title ct fordate reporttype);
   $report->set_export_options('generate_' . ($form->{arap} eq 'ar' ? 'ar' : 'ap') . '_aging', @hidden_variables);
 
   my @options;