From: Sven Schöling Date: Mon, 19 Apr 2010 13:37:18 +0000 (+0200) Subject: Check in Acctrancorrections zu fehlenden Steuerschluesseln. X-Git-Tag: release-2.6.2beta1~342^2~13 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1a3707af8c238632e58ee10f4c2a7719fcd60e01;p=kivitendo-erp.git Check in Acctrancorrections zu fehlenden Steuerschluesseln. --- diff --git a/SL/AccTransCorrections.pm b/SL/AccTransCorrections.pm index 44f3afd6b..ec440f1bb 100644 --- a/SL/AccTransCorrections.pm +++ b/SL/AccTransCorrections.pm @@ -288,6 +288,49 @@ sub _check_trans_invoices_inventory_with_taxkeys { return 0; } +# Problemfall: Verkaufsrechnungen, bei denen Steuern verbucht wurden, obwohl +# kein Steuerschlüssel eingetragen ist. +sub _check_missing_taxkeys_in_invoices { + $::lxdebug->enter_sub; + + my $self = shift; + my %params = @_; + my $transaction = $params{transaction}; + my $found_broken = 0; + + $::lxdebug->leave_sub and return 0 + if !$transaction->[0]->{invoice}; + + my @sub_transactions = $self->_group_sub_transactions($transaction); + + for my $sub_transaction (@sub_transactions) { + $::lxdebug->leave_sub and return 0 + if _is_split_transaction($sub_transaction) + || _is_simple_transaction($sub_transaction); + + my $split_side_entries = _get_splitted_side($sub_transaction); + my $num_tax_rows; + my $num_taxed_rows; + for my $entry (@{ $split_side_entries }) { + my $is_tax = grep { m/(?:AP_tax|AR_tax)/ } keys %{ $entry->{chartlinks} }; + + $num_tax_rows++ if $is_tax; + $num_taxed_rows++ if !$is_tax && $entry->{tax_key} != 0; + } + + # now if this has tax rows but NO taxed rows, something is wrong. + if ($num_tax_rows > 0 && $num_taxed_rows == 0) { + $params{problem}->{type} = 'missing_taxkeys_in_invoices'; + push @{ $self->{missing_taxkeys_in_invoices} ||= [] }, $params{problem}; + $found_broken = 1; + } + } + + $::lxdebug->leave_sub; + + return $found_broken; +} + # Problemfall: Kreditorenbuchungen, bei denen mit Umsatzsteuerschlüsseln # gebucht wurde und Debitorenbuchungen, bei denen mit Vorsteuerschlüsseln # gebucht wurde. @@ -623,8 +666,18 @@ sub analyze { unshift @problems, $problem; } + if (0 != scalar @{ $self->{missing_taxkeys_in_invoices} }) { + my $problem = { + 'type' => 'missing_taxkeys_in_invoices', + 'ap_problems' => [ grep { $_->{data}->{module} eq 'ap' } @{ $self->{missing_taxkeys_in_invoices} } ], + 'ar_problems' => [ grep { $_->{data}->{module} eq 'ar' } @{ $self->{missing_taxkeys_in_invoices} } ], + }; + unshift @problems, $problem; + } + $main::lxdebug->leave_sub(); +# $::lxdebug->dump(0, 'problems:', \@problems); return @problems; } diff --git a/locale/de/all b/locale/de/all index 3a8060af1..bbfe0e515 100644 --- a/locale/de/all +++ b/locale/de/all @@ -996,6 +996,7 @@ $self->{texts} = { 'Missing amount' => 'Fehlbetrag', 'Missing parameter #1 in call to sub #2.' => 'Fehlernder Parameter \'#1\' in Funktionsaufruf \'#2\'.', 'Missing parameter (at least one of #1) in call to sub #2.' => 'Fehlernder Parameter (mindestens einer aus \'#1\') in Funktionsaufruf \'#2\'.', + 'Missing taxkeys in invoices with taxes.' => 'Fehlende Steuerschlüssel in Rechnungen mit Steuern', 'Mitarbeiter' => 'Mitarbeiter', 'Mobile1' => 'Mobile 1', 'Mobile2' => 'Mobile 2', diff --git a/templates/webpages/acctranscorrections/analyze_overview_de.html b/templates/webpages/acctranscorrections/analyze_overview_de.html index 8a6876c4c..99eb3db5e 100644 --- a/templates/webpages/acctranscorrections/analyze_overview_de.html +++ b/templates/webpages/acctranscorrections/analyze_overview_de.html @@ -67,6 +67,24 @@ [%- END %] [%- END %] + [%- ELSIF problem.type == 'missing_taxkeys_in_invoices' %] + [%- IF problem.ar_problems.size %] + Verkaufsrechnungen + [%- FOREACH subproblem = problem.ar_problems %] + [%- UNLESS loop.first %], [%- END %] + [% HTML.escape(subproblem.data.reference) %] + [%- END %] + [%- END %] + + [%- IF problem.ap_problems.size %] + [%- IF problem.ar_problems.size %]; [%- END %] + Einkaufsrechnungen + [%- FOREACH subproblem = problem.ap_problems %] + [%- UNLESS loop.first %], [%- END %] + [% HTML.escape(subproblem.data.reference) %] + [%- END %] + [%- END %] + [%- ELSE %] @@ -101,6 +119,9 @@ [%- ELSIF problem.type == 'invoice_inventory_with_taxkeys' %] Einkaufs- und Verkaufsrechnungen mit Warenbestandsbuchungen mit Steuerschlüsseln + [%- ELSIF problem.type == 'missing_taxkeys_in_invoices' %] + Fehlende Steuerschlüssel in Rechnungen mit Steuern + [%- END %] diff --git a/templates/webpages/acctranscorrections/analyze_overview_master.html b/templates/webpages/acctranscorrections/analyze_overview_master.html index bb574ca64..408bc04fe 100644 --- a/templates/webpages/acctranscorrections/analyze_overview_master.html +++ b/templates/webpages/acctranscorrections/analyze_overview_master.html @@ -67,6 +67,24 @@ [%- END %] [%- END %] + [%- ELSIF problem.type == 'missing_taxkeys_in_invoices' %] + [%- IF problem.ar_problems.size %] + Sales invoices + [%- FOREACH subproblem = problem.ar_problems %] + [%- UNLESS loop.first %], [%- END %] + [% HTML.escape(subproblem.data.reference) %] + [%- END %] + [%- END %] + + [%- IF problem.ap_problems.size %] + [%- IF problem.ar_problems.size %]; [%- END %] + Purchase invoices + [%- FOREACH subproblem = problem.ap_problems %] + [%- UNLESS loop.first %], [%- END %] + [% HTML.escape(subproblem.data.reference) %] + [%- END %] + [%- END %] + [%- ELSE %] @@ -101,6 +119,9 @@ [%- ELSIF problem.type == 'invoice_inventory_with_taxkeys' %] Sales and purchase invoices with inventory transactions with taxkeys + [%- ELSIF problem.type == 'missing_taxkeys_in_invoices' %] + Missing taxkeys in invoices with taxes. + [%- END %]