use POSIX qw(strftime);
+use SL::DB::Default;
+use SL::DB::Project;
+use SL::DB::Customer;
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";
# $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')
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'),
);
$::form->{title} = $title{$::form->{report}};
+ $::request->{layout}->add_javascripts('autocomplete_customer.js');
# get departments
$::form->all_departments(\%::myconfig);
$::form->all_vc(\%::myconfig, $::form->{vc}, $is_sales ? "AR" : "AP");
$vc .= "<option>$_->{name}--$_->{id}\n" for @{ $::form->{"all_$::form->{vc}"} };
$vc = ($vc)
- ? qq|<select name=$::form->{vc}><option>\n$vc</select>|
- : qq|<input name=$::form->{vc} size=35>|;
+ ? qq|<select name=$::form->{vc} class="initial_focus"><option>\n$vc</select>|
+ : qq|<input name=$::form->{vc} size=35 class="initial_focus">|;
}
my ($selection, $paymentaccounts);
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();
. qq| $longcomparetodate|;
}
- # setup variables for the form
- my @a = qw(company address businessnumber);
- map { $form->{$_} = $myconfig{$_} } @a;
+ if ( $::instance_conf->get_profit_determination eq 'balance' ) {
+ $form->{title} = $locale->text('Income Statement');
+ } elsif ( $::instance_conf->get_profit_determination eq 'income' ) {
+ $form->{title} = $locale->text('Net Income Statement');
+ } else {
+ $form->{title} = "";
+ };
- $form->{templates} = $myconfig{templates};
+ if ( $form->{method} eq 'cash' ) {
+ $form->{accounting_method} = $locale->text('Cash accounting');
+ } elsif ( $form->{method} eq 'accrual' ) {
+ $form->{accounting_method} = $locale->text('Accrual accounting');
+ } else {
+ $form->{accounting_method} = "";
+ };
- $form->{IN} = "income_statement.html";
+ $form->{report_date} = $locale->text('Report date') . ": " . $form->current_date;
- $form->parse_template;
+ $form->header;
+ print $form->parse_html_template('rp/income_statement');
$main::lxdebug->leave_sub();
}
my $data = RP->balance_sheet(\%::myconfig, $::form);
- $::form->{asofdate} ||= $::form->current_date;
- $::form->{period} = $::locale->date(\%::myconfig, $::form->current_date, 1);
+ $::form->{asofdate} ||= $::form->current_date;
+ $::form->{report_title} = $::locale->text('Balance Sheet');
+ $::form->{report_date} ||= $::form->current_date;
($::form->{department}) = split /--/, $::form->{department};
$::form->{this_period} = $::locale->date(\%::myconfig, $::form->{asofdate}, 0);
$::form->{last_period} = $::locale->date(\%::myconfig, $::form->{compareasofdate}, 0);
+# balance sheet isn't read from print templates anymore,
+# instead use template in rp
# $::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);
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');
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
+ my $defaults = SL::DB::Default->get;
if ($form->{reporttype} eq "custom") {
my $attachment_basename = $locale->text('trial_balance');
my $report = SL::ReportGenerator->new(\%myconfig, $form);
- my @hidden_variables = qw(fromdate todate year cash);
+ my @hidden_variables = qw(fromdate todate year method);
my $href = build_std_url('action=generate_trial_balance', grep { $form->{$_} } @hidden_variables);
$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});
+ if ($::form->{customer_id}) {
+ my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id});
+ push @options, $::locale->text('Customer') . ' ' . $customer->displayable_name;
+ }
+
$form->{template_to} = $locale->date(\%myconfig, $form->{todate}, 0);
$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;
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";
# if (defined ($form->{fromdate|todate}=='..'))
# immer wahr
if ($form->{fromdate}){
- my ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{fromdate});
- my $datetime = $locale->parse_date_to_object(\%myconfig, $form->{fromdate});
+ my $datetime = $locale->parse_date_to_object($form->{fromdate});
$datetime->set( month => 1,
day => 1);
$form->{comparefromdate} = $locale->format_date(\%::myconfig, $datetime);
. qq| $longtodate|;
}
- # setup variables for the form
- my @a = qw(company address businessnumber);
- map { $form->{$_} = $myconfig{$_} } @a;
- $form->{templates} = $myconfig{templates};
+ $form->{report_date} = $locale->text('Report date') . ": " . $form->current_date;
+
+ if ( $form->{method} eq 'cash' ) {
+ $form->{accounting_method} = $locale->text('Cash accounting');
+ } elsif ( $form->{method} eq 'accrual' ) {
+ $form->{accounting_method} = $locale->text('Accrual accounting');
+ } else {
+ $form->{accounting_method} = "";
+ };
- $form->{IN} = "bwa.html";
+ $form->{title} = $locale->text('BWA');
- $form->parse_template;
+ $::request->layout->add_stylesheets('bwa.css');
+ $form->header;
+ print $form->parse_html_template('rp/bwa');
$main::lxdebug->leave_sub();
}