From 1c62d23ef8305ca67a7cf19f69d4fb2939f972a0 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 31 Jul 2014 10:21:02 +0200 Subject: [PATCH] =?utf8?q?Steuerzone=20-=20Default=20eingef=C3=BChrt=20(st?= =?utf8?q?att=20id=200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Als Defaultsteuerzone gilt nun die Steuerzone mit dem höchsten Sortcode, der nicht obsolet ist (in der Regel also id 1). Bernd hatte noch ein paar Stellen gefunden, wo als Default 0 gesetzt wird. Außerdem Doku angepasst, taxzone_id ist nun nicht mehr im Bereich 0-3. --- SL/DB/Buchungsgruppe.pm | 13 ++++++------- SL/DB/Manager/TaxZone.pm | 32 ++++++++++++++++++++++++++++++++ SL/DB/Part.pm | 5 ++--- SL/IR.pm | 10 +++++----- SL/IS.pm | 3 ++- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/SL/DB/Buchungsgruppe.pm b/SL/DB/Buchungsgruppe.pm index e71d0f270..1b5bdad59 100644 --- a/SL/DB/Buchungsgruppe.pm +++ b/SL/DB/Buchungsgruppe.pm @@ -103,26 +103,25 @@ SL::DB::Buchungsgruppe - RDBO wrapper for the C table =item C Return the chart ID for the expense account for the given taxzone -(either an integer between 0 and 3 inclusively or an instance of -L). +(either the DB id or an instance of L). =item C Return the chart (an instance of L) for the expense -account for the given taxzone (either an integer between 0 and 3 -inclusively or an instance of L). +account for the given taxzone (either the DB id or an instance of +L). =item C Return the chart ID for the income account for the given taxzone -(either an integer between 0 and 3 inclusively or an instance of +(either the DB id or an instance of L). L). =item C Return the chart (an instance of L) for the income -account for the given taxzone (either an integer between 0 and 3 -inclusively or an instance of L). +account for the given taxzone (either the DB id or an instance of +L). =back diff --git a/SL/DB/Manager/TaxZone.pm b/SL/DB/Manager/TaxZone.pm index 6d61fad94..25ec44252 100644 --- a/SL/DB/Manager/TaxZone.pm +++ b/SL/DB/Manager/TaxZone.pm @@ -17,4 +17,36 @@ sub _sort_spec { columns => { SIMPLE => 'ALL' } ); } +sub get_default { + return $_[0]->get_first(where => [ obsolete => 0 ], sort_by => 'sortkey'); +} + 1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::Manager::TaxZone - RDBO manager for the C table + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns an RDBO instance corresponding to the default taxzone. The default +taxzone is defined as the taxzone with the highest sort order (usually 1) that +is not set to obsolete. + +Example: + + my $default_taxzone_id = SL::DB::Manager::TaxZone->get_default->id; + + +=back + +=cut diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index adb650e06..a25b64a74 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -318,7 +318,7 @@ This function looks up the income (for trueish values of C<$params{is_sales}>) or expense (for falsish values of C<$params{is_sales}>) account for the current part. It uses the part's associated buchungsgruppe and uses the fields belonging to the tax -zone given by C<$params{taxzone}> (range 0..3). +zone given by C<$params{taxzone}>. The information retrieved by the function is cached. @@ -330,8 +330,7 @@ C<$params{type}> and tax zone C<$params{taxzone}> the three key words C, C and C. This function uses the part's associated buchungsgruppe and uses the -fields belonging to the tax zone given by C<$params{taxzone}> (range -0..3). +fields belonging to the tax zone given by C<$params{taxzone}>. The information retrieved by the function is cached. diff --git a/SL/IR.pm b/SL/IR.pm index c13d84b1c..f880f862e 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -46,6 +46,7 @@ use SL::HTML::Restrict; use SL::IO; use SL::MoreCommon; use SL::DB::Default; +use SL::DB::TaxZone; use List::Util qw(min); use strict; @@ -672,6 +673,7 @@ sub post_invoice { # set values which could be empty my $taxzone_id = $form->{taxzone_id} * 1; + $taxzone_id = SL::DB::Manager::TaxZone->get_default->id unless SL::DB::Manager::TaxZone->find_by(id => $taxzone_id); # Seit neuestem wird die department_id schon übergeben UND $form->department nicht mehr # korrekt zusammengebaut. Sehr wahrscheinlich beim Umstieg auf T8 kaputt gegangen @@ -682,8 +684,6 @@ sub post_invoice { } $form->{invnumber} = $form->{id} unless $form->{invnumber}; - $taxzone_id = 0 if (3 < $taxzone_id) || (0 > $taxzone_id); - # save AP record $query = qq|UPDATE ap SET invnumber = ?, ordnumber = ?, quonumber = ?, transdate = ?, @@ -963,9 +963,9 @@ sub retrieve_invoice { map { $form->{$_} = $ref->{$_} } keys %$ref; my $transdate = $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date"; - my $taxzone_id = $form->{taxzone_id} * 1; - $taxzone_id = 0 if ((3 < $taxzone_id) || (0 > $taxzone_id)); + my $taxzone_id = $form->{taxzone_id} * 1; + $taxzone_id = SL::DB::Manager::TaxZone->get_default->id unless SL::DB::Manager::TaxZone->find_by(id => $taxzone_id); # retrieve individual items $query = @@ -1219,7 +1219,7 @@ sub retrieve_item { } my $taxzone_id = $form->{taxzone_id} * 1; - $taxzone_id = 0 if ((3 < $taxzone_id) || (0 > $taxzone_id)); + $taxzone_id = SL::DB::Manager::TaxZone->get_default->id unless SL::DB::Manager::TaxZone->find_by(id => $taxzone_id); my $query = qq|SELECT diff --git a/SL/IS.pm b/SL/IS.pm index a1fbeaf6e..51f3c1bec 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -51,6 +51,7 @@ use SL::IO; use SL::TransNumber; use SL::DB::Default; use SL::DB::Tax; +use SL::DB::TaxZone; use SL::TransNumber; use Data::Dumper; @@ -1638,7 +1639,7 @@ sub retrieve_invoice { my $taxzone_id = $form->{taxzone_id} *= 1; - $taxzone_id = 0 if (0 > $taxzone_id) || (3 < $taxzone_id); + $taxzone_id = SL::DB::Manager::TaxZone->get_default->id unless SL::DB::Manager::TaxZone->find_by(id => $taxzone_id); # retrieve individual items $query = -- 2.20.1