=item C<expense_accno_id $taxzone>
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<SL::DB::TaxZone>).
+(either the DB id or an instance of L<SL::DB::TaxZone>).
=item C<expense_account>
Return the chart (an instance of L<SL::DB::Chart>) for the expense
-account for the given taxzone (either an integer between 0 and 3
-inclusively or an instance of L<SL::DB::TaxZone>).
+account for the given taxzone (either the DB id or an instance of
+L<SL::DB::TaxZone>).
=item C<income_accno_id>
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<SL::DB::TaxZone>).
L<SL::DB::TaxZone>).
=item C<income_account>
Return the chart (an instance of L<SL::DB::Chart>) for the income
-account for the given taxzone (either an integer between 0 and 3
-inclusively or an instance of L<SL::DB::TaxZone>).
+account for the given taxzone (either the DB id or an instance of
+L<SL::DB::TaxZone>).
=back
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<tax_zones> table
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item C<get_default>
+
+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
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.
the three key words C<income>, C<expense> and C<inventory>.
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.
use SL::IO;
use SL::MoreCommon;
use SL::DB::Default;
+use SL::DB::TaxZone;
use List::Util qw(min);
use strict;
# 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
}
$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 = ?,
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 =
}
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
use SL::TransNumber;
use SL::DB::Default;
use SL::DB::Tax;
+use SL::DB::TaxZone;
use SL::TransNumber;
use Data::Dumper;
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 =