X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/73be6af449d872825d1fbdffe536b9061ca649c8..a3ae31c:/bin/mozilla/rp.pl diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index a339cd41a..8062dad90 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -37,11 +37,14 @@ use POSIX qw(strftime); +use SL::DB::Default; +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 +95,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 +133,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'), @@ -151,8 +150,6 @@ sub report { $::form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }); - my $onload = qq|focus()|; - my $is_projects = $::form->{report} eq "projects"; my $is_income_statement = $::form->{report} eq "income_statement"; my $is_bwa = $::form->{report} eq "bwa"; @@ -198,7 +195,7 @@ sub report { vc => $vc, label => $label, year => DateTime->today->year, - onload => $onload, + today => DateTime->today, nextsub => $nextsub, accrual => $::instance_conf->get_accounting_method ne 'cash', cash => $::instance_conf->get_accounting_method eq 'cash', @@ -215,35 +212,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(); @@ -253,6 +221,10 @@ sub generate_income_statement { my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + $form->{padding} = "  "; $form->{bold} = ""; $form->{endbold} = ""; @@ -403,12 +375,6 @@ sub generate_income_statement { . qq| $longcomparetodate|; } - # setup variables for the form - my @a = qw(company address businessnumber); - map { $form->{$_} = $myconfig{$_} } @a; - - $form->{templates} = $myconfig{templates}; - $form->{IN} = "income_statement.html"; $form->parse_template; @@ -420,6 +386,9 @@ sub generate_balance_sheet { $::lxdebug->enter_sub; $::auth->assert('report'); + my $defaults = SL::DB::Default->get; + $::form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $::form->{templates} = $defaults->templates; $::form->{decimalplaces} = $::form->{decimalplaces} * 1 || 2; $::form->{padding} = "  "; $::form->{bold} = ""; @@ -442,11 +411,6 @@ sub generate_balance_sheet { # $::form->{IN} = "balance_sheet.html"; - # setup company variables for the form - map { $::form->{$_} = $::myconfig{$_} } qw(company address businessnumber nativecurr); - - $::form->{templates} = $::myconfig{templates}; - $::form->header; print $::form->parse_html_template('rp/balance_sheet', $data); @@ -462,8 +426,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'); @@ -488,6 +452,7 @@ sub generate_trial_balance { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; if ($form->{reporttype} eq "custom") { @@ -649,7 +614,7 @@ sub generate_trial_balance { $form->{print_date} = $locale->text('Create Date') . " " . $locale->date(\%myconfig, $form->current_date(\%myconfig), 0); push (@options, $form->{print_date}); - $form->{company} = $locale->text('Company') . " " . $myconfig{company}; + $form->{company} = $locale->text('Company') . " " . $defaults->company; push (@options, $form->{company}); @@ -1002,7 +967,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; @@ -1228,9 +1193,11 @@ sub print_form { my %myconfig = %main::myconfig; my $locale = $main::locale; - $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1); + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; - $form->{templates} = "$myconfig{templates}"; + $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1); my $suffix = "html"; my $attachment_suffix = "html"; @@ -1664,6 +1631,10 @@ sub generate_bwa { my %myconfig = %main::myconfig; my $locale = $main::locale; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; + $form->{padding} = "  "; $form->{bold} = ""; $form->{endbold} = ""; @@ -1851,11 +1822,6 @@ sub generate_bwa { . qq| $longtodate|; } - # setup variables for the form - my @a = qw(company address businessnumber); - map { $form->{$_} = $myconfig{$_} } @a; - $form->{templates} = $myconfig{templates}; - $form->{IN} = "bwa.html"; $form->parse_template;