X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;fp=SL%2FGL.pm;h=3b99238f702aad39987bd53c542157a6dddf33d5;hb=e765ebf812bd760e24aa7a78e135403505fff28a;hp=a1d3a9d2221215cac4af804ee9a89d996883db28;hpb=09a2093df3c809a942af7676f0e9bec30808410c;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index a1d3a9d22..3b99238f7 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -773,12 +773,22 @@ sub get_chart_balances { } sub get_active_taxes_for_chart { - my ($self, $chart_id, $transdate) = @_; + my ($self, $chart_id, $transdate, $tax_id) = @_; my $chart = SL::DB::Chart->new(id => $chart_id)->load; my $active_taxkey = $chart->get_active_taxkey($transdate); + + my $where = [ chart_categories => { like => '%' . $chart->category . '%' } ]; + + if ( defined $tax_id && $tax_id >= 0 ) { + $where = [ or => [ chart_categories => { like => '%' . $chart->category . '%' }, + id => $tax_id + ] + ]; + } + my $taxes = SL::DB::Manager::Tax->get_all( - where => [ chart_categories => { like => '%' . $chart->category . '%' }], + where => $where, sort_by => 'taxkey, rate', ); @@ -789,3 +799,45 @@ sub get_active_taxes_for_chart { } 1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::GL - some useful GL functions + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a list of taxes for a certain chart and date to be used for dropdowns, +for e.g. ar/ap/gl records. + +The possible entries are filtered by the charttype of the tax, i.e. only taxes +whose chart_categories match the category of the chart will be shown. + +In the case of existing records, e.g. when opening an old ar record, due to +changes in the configurations the desired tax might not be available in the +dropdown anymore. If we are loading an old record and know its tax_id (from +acc_trans), we can pass $tax_id as the third parameter and be sure that the +original tax always appears in the dropdown. + +=back + +=head1 TODO + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +G. Richardson Egrichardson@kivitec.de + +=cut