From: Rolf Fluehmann Date: Mon, 4 Jan 2016 15:58:53 +0000 (+0100) Subject: Erfolgsrechnung X-Git-Tag: release-3.4.1~489 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e3f8237101c331c52098cf6f7db86e1db2a2b36a;p=kivitendo-erp.git Erfolgsrechnung --- diff --git a/SL/RP.pm b/SL/RP.pm index b2fd5e069..09c8d1c3f 100644 --- a/SL/RP.pm +++ b/SL/RP.pm @@ -1871,4 +1871,88 @@ sub income_statement { } $main::lxdebug->leave_sub(); } + +sub erfolgsrechnung { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $form) = @_; + $form->{company} = $::instance_conf->get_company; + $form->{address} = $::instance_conf->get_address; + + # wrong user inputs should be handled during users input + # e.g. spaces, tabs, wrong format or wrong dates + $form->{fromdate} = "01.01.2000" if !$form->{fromdate}; + $form->{todate} = $form->current_date(%{$myconfig}) if !$form->{todate}; + + my %categories = (I => "ERTRAG", E => "AUFWAND"); + my $fromdate = conv_dateq($form->{fromdate}); + my $todate = conv_dateq($form->{todate}); + + $form->{total} = 0; + foreach my $category (keys %categories) { + my %category = ( + name => $categories{$category}, + total => 0, + accounts => get_accounts_ch($category), + ); + foreach my $account (@{$category{accounts}}) { + $account->{total} += ($account->{category} eq $category ? 1 : -1) * get_total_ch($account->{id}, $fromdate, $todate); + $category{total} += $account->{total}; + $account->{total} = $form->format_amount($myconfig, $form->parse_amount($myconfig, $account->{total}), 2); + } + $form->{total} += $category{total}; + $category{total} = $form->format_amount($myconfig, $form->parse_amount($myconfig, $category{total}), 2); + push(@{$form->{categories}}, \%category); + } + $form->{total} = $form->format_amount($myconfig, $form->parse_amount($myconfig, $form->{total}), 2); + + $main::lxdebug->leave_sub(); + return {}; +} + +sub get_accounts_ch { + $main::lxdebug->enter_sub(); + + my ($category) = @_; + my ($inclusion); + + if ($category eq 'I') { + $inclusion = "AND pos_eur = NULL OR pos_eur > '0' AND pos_eur <= '5'"; + } elsif ($category eq 'E') { + $inclusion = "AND pos_eur = NULL OR pos_eur >= '6' AND pos_eur < '100'"; + } else { + $inclusion = ""; + } + + my $query = qq| + SELECT id, accno, description, category + FROM chart + WHERE category = ? $inclusion + ORDER BY accno + |; + my $accounts = selectall_hashref_query($::form, $::form->get_standard_dbh, $query, $category); + + $main::lxdebug->leave_sub(); + return $accounts; +} + +sub get_total_ch { + $main::lxdebug->enter_sub(); + + my ($chart_id, $fromdate, $todate) = @_; + my $total = 0; + my $query = qq| + SELECT SUM(amount) + FROM acc_trans + WHERE chart_id = ? + AND transdate >= ? + AND transdate <= ? + |; + my $data = selectfirst_hashref_query($::form, $::form->get_standard_dbh, $query, $chart_id, $fromdate, $todate); + $total += $data->{sum}; + + $main::lxdebug->leave_sub(); + return $total; +} + 1; diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index ae2669fe3..87f84b217 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', + 'erfolgsrechnung' => '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'), + erfolgsrechnung => $::locale->text('Erfolgsrechnung'), trial_balance => $::locale->text('Trial Balance'), ar_aging => $::locale->text('Search AR Aging'), ap_aging => $::locale->text('Search AP Aging'), @@ -142,6 +144,8 @@ sub report { $::form->{title} = $title{$::form->{report}}; $::request->{layout}->add_javascripts('autocomplete_customer.js'); + $::form->{fromdate} = DateTime->today->truncate(to => 'year')->to_kivitendo; + $::form->{todate} = DateTime->today->truncate(to => 'year')->add(years => 1)->add(days => -1)->to_kivitendo; # get departments $::form->all_departments(\%::myconfig); @@ -152,13 +156,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_erfolgsrechnung = $::form->{report} eq "erfolgsrechnung"; + 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,20 +196,21 @@ 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, - 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, + 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_erfolgsrechnung => $is_erfolgsrechnung, + is_projects => $is_projects, }); $::lxdebug->leave_sub; @@ -395,6 +401,25 @@ sub generate_income_statement { $main::lxdebug->leave_sub(); } +sub generate_erfolgsrechnung { + $::lxdebug->enter_sub; + $::auth->assert('report'); + + $::form->{decimalplaces} = $::form->{decimalplaces} * 1 || 2; + $::form->{padding} = " "; + $::form->{bold} = ""; + $::form->{endbold} = ""; + $::form->{br} = "
"; + + my $data = RP->erfolgsrechnung(\%::myconfig, $::form); + + $::form->header(); + print $::form->parse_html_template('rp/erfolgsrechnung', $data); + + $::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..f693a0f16 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -772,6 +772,16 @@ params: action: report report: trial_balance +- parent: reports + id: reports_erfolgsrechnung + name: Erfolgsrechnung + icon: income_statement + order: 300 + access: report + module: rp.pl + params: + action: report + report: erfolgsrechnung - parent: reports id: reports_income_statement name: Income Statement diff --git a/templates/webpages/rp/erfolgsrechnung.html b/templates/webpages/rp/erfolgsrechnung.html new file mode 100644 index 000000000..f3a73c76d --- /dev/null +++ b/templates/webpages/rp/erfolgsrechnung.html @@ -0,0 +1,40 @@ +[%- USE T8 %] +[%- USE HTML %] +[%- USE LxERP %] + +

+
[% company %] +
[% address %] +

[% 'ERFOLGSRECHNUNG' %] +
[% fromdate %] bis [% todate %] +

+ + + + + [%- FOREACH category = categories %] + + + + [%- FOREACH row = category.accounts %] + + + + + + [%- END %] + + + + + + + + + + [%- END %] + + + + +

[% category.name %]
[% row.accno %][% row.description %][% row.total %]


TOTAL[% category.total %]
GEWINN/VERLUST[% total %]

diff --git a/templates/webpages/rp/report.html b/templates/webpages/rp/report.html index 2e9775a96..1eb5e48d1 100644 --- a/templates/webpages/rp/report.html +++ b/templates/webpages/rp/report.html @@ -9,7 +9,9 @@ [% 'Year' | $T8 %] - + + + [% 'Yearly' | $T8 %] @@ -17,32 +19,66 @@ [% 'Monthly' | $T8 %] -   -  1. [% 'Quarter' | $T8 %] -  [% 'January' | $T8 %] -  [% 'May' | $T8 %] -  [% 'September' | $T8 %] +   + + + +  1. [% 'Quarter' | $T8 %] + + +  [% 'January' | $T8 %] + + +  [% 'May' | $T8 %] + + +  [% 'September' | $T8 %] +   -  2. [% 'Quarter' | $T8 %] -  [% 'February' | $T8 %] -  [% 'June' | $T8 %] -  [% 'October' | $T8 %] + +  2. [% 'Quarter' | $T8 %] + + +  [% 'February' | $T8 %] + + +  [% 'June' | $T8 %] + + +  [% 'October' | $T8 %] +   -  3. [% 'Quarter' | $T8 %] -  [% 'March' | $T8 %] -  [% 'July' | $T8 %] -  [% 'November' | $T8 %] + +  3. [% 'Quarter' | $T8 %] + + +  [% 'March' | $T8 %] + + +  [% 'July' | $T8 %] + + +  [% 'November' | $T8 %] +   -  4. [% 'Quarter' | $T8 %] -  [% 'April' | $T8 %] -  [% 'August' | $T8 %] -  [% 'December' | $T8 %] + +  4. [% 'Quarter' | $T8 %] + + +  [% 'April' | $T8 %] + + +  [% 'August' | $T8 %] + + +  [% 'December' | $T8 %] +
@@ -51,7 +87,7 @@ [% 'Free report period' | $T8 %] [% 'From' | $T8 %] [% L.date_tag('fromdate', fromdate) %] - [% 'Bis' | $T8 %] [% L.date_tag('todate') %] + [% 'Bis' | $T8 %] [% L.date_tag('todate', todate) %] @@ -125,6 +161,7 @@ [%- END %] + [%- IF is_bwa %] [%- PROCESS projectnumber %] @@ -138,6 +175,15 @@ [%- END %] + +[%- IF is_erfolgsrechnung %] + + + +[%- PROCESS customized_report %] +[%- END %] + + [%- IF is_balance_sheet %] @@ -323,3 +369,92 @@ + + +