Revision e765ebf8
Von G. Richardson vor mehr als 4 Jahren hinzugefügt
SL/GL.pm | ||
---|---|---|
773 | 773 |
} |
774 | 774 |
|
775 | 775 |
sub get_active_taxes_for_chart { |
776 |
my ($self, $chart_id, $transdate) = @_; |
|
776 |
my ($self, $chart_id, $transdate, $tax_id) = @_;
|
|
777 | 777 |
|
778 | 778 |
my $chart = SL::DB::Chart->new(id => $chart_id)->load; |
779 | 779 |
my $active_taxkey = $chart->get_active_taxkey($transdate); |
780 |
|
|
781 |
my $where = [ chart_categories => { like => '%' . $chart->category . '%' } ]; |
|
782 |
|
|
783 |
if ( defined $tax_id && $tax_id >= 0 ) { |
|
784 |
$where = [ or => [ chart_categories => { like => '%' . $chart->category . '%' }, |
|
785 |
id => $tax_id |
|
786 |
] |
|
787 |
]; |
|
788 |
} |
|
789 |
|
|
780 | 790 |
my $taxes = SL::DB::Manager::Tax->get_all( |
781 |
where => [ chart_categories => { like => '%' . $chart->category . '%' }],
|
|
791 |
where => $where,
|
|
782 | 792 |
sort_by => 'taxkey, rate', |
783 | 793 |
); |
784 | 794 |
|
... | ... | |
789 | 799 |
} |
790 | 800 |
|
791 | 801 |
1; |
802 |
|
|
803 |
__END__ |
|
804 |
|
|
805 |
=pod |
|
806 |
|
|
807 |
=encoding utf8 |
|
808 |
|
|
809 |
=head1 NAME |
|
810 |
|
|
811 |
SL::GL - some useful GL functions |
|
812 |
|
|
813 |
=head1 FUNCTIONS |
|
814 |
|
|
815 |
=over 4 |
|
816 |
|
|
817 |
=item C<get_active_taxes_for_chart> |
|
818 |
|
|
819 |
Returns a list of taxes for a certain chart and date to be used for dropdowns, |
|
820 |
for e.g. ar/ap/gl records. |
|
821 |
|
|
822 |
The possible entries are filtered by the charttype of the tax, i.e. only taxes |
|
823 |
whose chart_categories match the category of the chart will be shown. |
|
824 |
|
|
825 |
In the case of existing records, e.g. when opening an old ar record, due to |
|
826 |
changes in the configurations the desired tax might not be available in the |
|
827 |
dropdown anymore. If we are loading an old record and know its tax_id (from |
|
828 |
acc_trans), we can pass $tax_id as the third parameter and be sure that the |
|
829 |
original tax always appears in the dropdown. |
|
830 |
|
|
831 |
=back |
|
832 |
|
|
833 |
=head1 TODO |
|
834 |
|
|
835 |
=head1 BUGS |
|
836 |
|
|
837 |
Nothing here yet. |
|
838 |
|
|
839 |
=head1 AUTHOR |
|
840 |
|
|
841 |
G. Richardson E<lt>grichardson@kivitec.de<gt> |
|
842 |
|
|
843 |
=cut |
Auch abrufbar als: Unified diff
GL get_active_taxes_for_chart - tax_id param
Damit kann man bei bereits gebuchten acc_trans-Einträgen den aktuellen
tax_id Wert übergeben, so daß der Eintrag bei Dropdowns immer erscheint,
also auch dann, wenn er durch Umkonfiguration ansonsten aus dem Dropdown
herausgefiltert werden würde (z.B. wenn sich chart_categories in tax
ändert).