From d679bb5b866e0336fb3df96a28cb58de349c9cb0 Mon Sep 17 00:00:00 2001 From: Rolf Fluehmann Date: Fri, 3 Jul 2015 14:27:48 +0200 Subject: [PATCH] Erfolgsrechnung 1st draft Conflicts: bin/mozilla/rp.pl --- SL/Menu.pm | 15 +- SL/RP.pm | 30 ++++ bin/mozilla/rp.pl | 237 ++++++++++++++++++++++++++---- menus/user/00-erp.yaml | 17 +++ templates/webpages/rp/report.html | 14 ++ 5 files changed, 278 insertions(+), 35 deletions(-) diff --git a/SL/Menu.pm b/SL/Menu.pm index f01b341be..ac8f7280b 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -220,6 +220,12 @@ sub parse_instance_conf_string { return $::instance_conf->data->{$setting}; } +sub parse_compare_string { + my ($self, $switch) = @_; + my ($setting, $mode) = split m/=/, $switch, 2; + return $::instance_conf->data->{$setting} eq $mode; +} + sub clear_access { my ($self) = @_; for my $node ($self->tree_walk("all")) { @@ -230,11 +236,14 @@ sub clear_access { sub set_access { my ($self) = @_; - # 1. evaluate access for all - # 2. if a menu has no visible children, its not visible either + # 1. evaluate appearence + # 2. evaluate access for all + # 3. if a menu has no visible children, its not visible either for my $node (reverse $self->tree_walk("all")) { - $node->{visible} = $node->{access} ? $self->parse_access_string($node) + $node->{visible} = $node->{inclusion} ? $self->parse_compare_string($node->{inclusion}) : 1 + && $node->{exclusion} ? !$self->parse_compare_string($node->{exclusion}) : 1 + && $node->{access} ? $self->parse_access_string($node) : !$node->{children} ? 1 : $node->{visible_children} ? 1 : 0; diff --git a/SL/RP.pm b/SL/RP.pm index b2fd5e069..e8e07e0ce 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -1871,4 +1871,34 @@ sub income_statement { } $main::lxdebug->leave_sub(); } + +sub income_statement_ch { + + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + + my $last_period = 0; + + + # connect to database + my $dbh = $form->dbconnect($myconfig); + + get_accounts_ch($dbh, $last_period, $form->{fromdate}, $form->{todate}, $form); + + $main::lxdebug->leave_sub(); +} + + + sub get_accounts_ch { + $main::lxdebug->enter_sub(); + + my $query = + qq|SELECT c.accno, c.description + FROM chart c + ORDER BY c.accno|; + + $main::lxdebug->leave_sub(); +} + 1; diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 02023f532..6672be75e 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -101,15 +101,16 @@ use strict; # $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', + 'projects' => 'report', + 'ar_aging' => 'general_ledger', + 'ap_aging' => 'general_ledger', + 'receipts' => 'cash', + 'payments' => 'cash', + 'trial_balance' => 'report', + 'income_statement' => 'report', + 'income_statement_ch'=> 'report', + 'bwa' => 'report', + 'balance_sheet' => 'report', }; sub check_rp_access { @@ -129,6 +130,7 @@ sub report { my %title = ( balance_sheet => $::locale->text('Balance Sheet'), income_statement => $::locale->text('Income Statement'), + income_statement_ch => ('Erfolgsrechnung'), trial_balance => $::locale->text('Trial Balance'), ar_aging => $::locale->text('Search AR Aging'), ap_aging => $::locale->text('Search AP Aging'), @@ -152,13 +154,14 @@ sub report { $::form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }); - my $is_projects = $::form->{report} eq "projects"; - my $is_income_statement = $::form->{report} eq "income_statement"; - 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_aging = $::form->{report} =~ /^a[rp]_aging$/; - my $is_payments = $::form->{report} =~ /(receipts|payments)$/; + my $is_projects = $::form->{report} eq "projects"; + my $is_income_statement = $::form->{report} eq "income_statement"; + my $is_income_statement_ch = $::form->{report} eq "income_statement_ch"; + 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_aging = $::form->{report} =~ /^a[rp]_aging$/; + my $is_payments = $::form->{report} =~ /(receipts|payments)$/; my ($label, $nextsub, $vc); if ($is_aging) { @@ -191,22 +194,23 @@ sub report { $::form->header; print $::form->parse_html_template('rp/report', { - paymentaccounts => $paymentaccounts, - selection => $selection, - is_aging => $is_aging, - vc => $vc, - label => $label, - year => DateTime->today->year, - today => DateTime->today, - nextsub => $nextsub, - accrual => $::instance_conf->get_accounting_method ne 'cash', - cash => $::instance_conf->get_accounting_method eq 'cash', - is_payments => $is_payments, - is_trial_balance => $is_trial_balance, - is_balance_sheet => $is_balance_sheet, - is_bwa => $is_bwa, - is_income_statement => $is_income_statement, - is_projects => $is_projects, + paymentaccounts => $paymentaccounts, + selection => $selection, + is_aging => $is_aging, + vc => $vc, + label => $label, + year => DateTime->today->year, + today => DateTime->today, + nextsub => $nextsub, + accrual => $::instance_conf->get_accounting_method ne 'cash', + cash => $::instance_conf->get_accounting_method eq 'cash', + is_payments => $is_payments, + is_trial_balance => $is_trial_balance, + is_balance_sheet => $is_balance_sheet, + is_bwa => $is_bwa, + is_income_statement => $is_income_statement, + is_income_statement_ch => $is_income_statement_ch, + is_projects => $is_projects, }); $::lxdebug->leave_sub; @@ -397,6 +401,175 @@ sub generate_income_statement { $main::lxdebug->leave_sub(); } +sub generate_income_statement_ch { + $main::lxdebug->enter_sub(); + + $main::auth->assert('report'); + + my $form = $main::form; + 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} = ""; + $form->{br} = "
"; + + if ($form->{reporttype} eq "custom") { + + #forgotten the year --> thisyear + if ($form->{year} !~ m/^\d\d\d\d$/) { + $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~ + /(\d\d\d\d)/; + $form->{year} = $1; + } + + #yearly report + if ($form->{duetyp} eq "13") { + $form->{fromdate} = "1.1.$form->{year}"; + $form->{todate} = "31.12.$form->{year}"; + } + #Quater reports + if ($form->{duetyp} eq "A") { + $form->{fromdate} = "1.1.$form->{year}"; + $form->{todate} = "31.3.$form->{year}"; + } + if ($form->{duetyp} eq "B") { + $form->{fromdate} = "1.4.$form->{year}"; + $form->{todate} = "30.6.$form->{year}"; + } + if ($form->{duetyp} eq "C") { + $form->{fromdate} = "1.7.$form->{year}"; + $form->{todate} = "30.9.$form->{year}"; + } + if ($form->{duetyp} eq "D") { + $form->{fromdate} = "1.10.$form->{year}"; + $form->{todate} = "31.12.$form->{year}"; + } + #Monthly reports + SWITCH: { + $form->{duetyp} eq "1" && do { + $form->{fromdate} = "1.1.$form->{year}"; + $form->{todate} = "31.1.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "2" && do { + $form->{fromdate} = "1.2.$form->{year}"; + + #this works from 1901 to 2099, 1900 and 2100 fail. + my $leap = ($form->{year} % 4 == 0) ? "29" : "28"; + $form->{todate} = "$leap.2.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "3" && do { + $form->{fromdate} = "1.3.$form->{year}"; + $form->{todate} = "31.3.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "4" && do { + $form->{fromdate} = "1.4.$form->{year}"; + $form->{todate} = "30.4.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "5" && do { + $form->{fromdate} = "1.5.$form->{year}"; + $form->{todate} = "31.5.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "6" && do { + $form->{fromdate} = "1.6.$form->{year}"; + $form->{todate} = "30.6.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "7" && do { + $form->{fromdate} = "1.7.$form->{year}"; + $form->{todate} = "31.7.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "8" && do { + $form->{fromdate} = "1.8.$form->{year}"; + $form->{todate} = "31.8.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "9" && do { + $form->{fromdate} = "1.9.$form->{year}"; + $form->{todate} = "30.9.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "10" && do { + $form->{fromdate} = "1.10.$form->{year}"; + $form->{todate} = "31.10.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "11" && do { + $form->{fromdate} = "1.11.$form->{year}"; + $form->{todate} = "30.11.$form->{year}"; + last SWITCH; + }; + $form->{duetyp} eq "12" && do { + $form->{fromdate} = "1.12.$form->{year}"; + $form->{todate} = "31.12.$form->{year}"; + last SWITCH; + }; + } + hotfix_reformat_date(); + } # Ende Bericht für vorgewählten Zeitraum (warum auch immer die Prüfung (custom eq true) ist ... + + RP->income_statement_ch(\%myconfig, \%$form); + + ($form->{department}) = split /--/, $form->{department}; + + $form->{period} = + $locale->date(\%myconfig, $form->current_date(\%myconfig), 1); + $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate}; + + # if there are any dates construct a where + if ($form->{fromdate} || $form->{todate}) { + + unless ($form->{todate}) { + $form->{todate} = $form->current_date(\%myconfig); + } + + my $longtodate = $locale->date(\%myconfig, $form->{todate}, 1); + my $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0); + + my $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1); + my $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0); + + $form->{this_period} = "$shortfromdate\n$shorttodate"; + $form->{period} = + $locale->text('for Period') + . qq|\n$longfromdate | + . $locale->text('Bis') + . qq| $longtodate|; + } + + if ($form->{comparefromdate} || $form->{comparetodate}) { + my $longcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 1); + my $shortcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 0); + + my $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1); + my $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0); + + $form->{last_period} = "$shortcomparefromdate\n$shortcomparetodate"; + $form->{period} .= + "\n$longcomparefromdate " + . $locale->text('Bis') + . qq| $longcomparetodate|; + } + + $form->{IN} = "erfolgsrechnung.html"; + + $form->parse_template; + + $main::lxdebug->leave_sub(); +} + + sub generate_balance_sheet { $::lxdebug->enter_sub; $::auth->assert('report'); diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml index 53d0586b4..1dddff202 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -574,6 +574,7 @@ id: general_ledger_datev_export_assistent name: DATEV - Export Assistent icon: datev + exclusion: country_mode=CH order: 400 access: datev_export module: datev.pl @@ -772,11 +773,23 @@ params: action: report report: trial_balance +- parent: reports + id: reports_erfolgsrechnung + name: Erfolgsrechnung + icon: income_statement + order: 300 + inclusion: country_mode=CH + access: report + module: rp.pl + params: + action: report + report: erfolgsrechnung - parent: reports id: reports_income_statement name: Income Statement icon: income_statement order: 300 + exclusion: country_mode=CH access: report module: rp.pl params: @@ -786,6 +799,7 @@ id: reports_bwa name: BWA order: 400 + exclusion: country_mode=CH access: report module: rp.pl params: @@ -796,6 +810,7 @@ name: Balance Sheet icon: balance_sheet order: 500 + exclusion: country_mode=CH access: report module: rp.pl params: @@ -806,6 +821,7 @@ name: UStVa icon: ustva order: 600 + exclusion: country_mode=CH access: advance_turnover_tax_return module: ustva.pl params: @@ -985,6 +1001,7 @@ id: system_ustva_einstellungen name: UStVa Einstellungen order: 200 + exclusion: country_mode=CH module: ustva.pl params: action: config_step1 diff --git a/templates/webpages/rp/report.html b/templates/webpages/rp/report.html index 93ef0a9ea..7744f31f5 100644 --- a/templates/webpages/rp/report.html +++ b/templates/webpages/rp/report.html @@ -125,6 +125,20 @@ [%- END %] + [%- IF is_income_statement_ch %] +[%- PROCESS projectnumber %] + + + +[%- PROCESS customized_report %] +[%- PROCESS cash_or_accrual %] + + + + +[%- END %] + + [%- IF is_bwa %] [%- PROCESS projectnumber %] -- 2.20.1
[% 'Include in Report' | $T8 %] [% 'CB Transactions' | $T8 %]