Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7d26ae8a

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 7d26ae8a9121401789d9cc97f522a8ad542319a6
  • Vorgänger 6fd01c3d
  • Nachfolger 4ac74078

Ermitteln des gültigen Steuerschlüssels zu einem Artikel an einem bestimmten Datum

Unterschiede anzeigen:

SL/DB/Part.pm
6 6
use SL::DBUtils;
7 7
use SL::DB::MetaSetup::Part;
8 8
use SL::DB::Manager::Part;
9
use SL::DB::Chart;
9 10

  
10 11
__PACKAGE__->meta->add_relationships(
11 12
  unit_obj                     => {
......
118 119
  shift->buchungsgruppen(@_);
119 120
}
120 121

  
122
sub get_taxkey {
123
  my ($self, %params) = @_;
124

  
125
  my $date     = $params{date} || DateTime->today_local;
126
  my $is_sales = !!$params{is_sales};
127
  my $taxzone  = $params{ defined($params{taxzone}) ? 'taxzone' : 'taxzone_id' } * 1;
128

  
129
  $self->{__partpriv_taxkey_information} ||= { };
130
  my $tk_info = $self->{__partpriv_taxkey_information};
131

  
132
  $tk_info->{$taxzone}              ||= { };
133
  $tk_info->{$taxzone}->{$is_sales} ||= { };
134

  
135
  return $tk_info->{$taxzone}->{$is_sales}->{$date} if exists $tk_info->{$taxzone}->{$is_sales}->{$date};
136

  
137
  my $bugru  = $self->buchungsgruppe;
138
  my %charts = ( inventory => { id => $self->inventory_accno_id ? $bugru->inventory_accno_id : undef },
139
                 income    => { id => $bugru->call_sub("income_accno_id_${taxzone}")                 },
140
                 expense   => { id => $bugru->call_sub("expense_accno_id_${taxzone}")                },
141
               );
142

  
143
  foreach my $type(qw(inventory income expense)) {
144
    $charts{$type}->{chart} ||= $charts{$type}->{id} ? SL::DB::Manager::Chart->find_by(id => $charts{$type}->{id}) : undef if $charts{$type}->{id};
145
  }
146

  
147
  my $chart = $charts{ $is_sales ? 'income' : 'expense' }->{chart};
148

  
149
  return $tk_info->{$taxzone}->{$is_sales}->{$date} = $chart->get_active_taxkey($date);
150
}
151

  
121 152
1;
122 153

  
123 154
__END__
......
216 247
Retrieves the quantity that has been ordered from a vendor but that
217 248
has not been delivered yet. Only open purchase orders are considered.
218 249

  
250
=item C<get_taxkey %params>
251

  
252
Retrieves and returns a taxkey object valid for the given date
253
C<$params{date}> and tax zone C<$params{taxzone}>
254
(C<$params{taxzone_id}> is also recognized). The date defaults to the
255
current date if undefined.
256

  
257
This function looks up the income (for trueish values of
258
C<$params{is_sales}>) or expense (for falsish values of
259
C<$params{is_sales}>) account for the current part. It uses the part's
260
associated buchungsgruppe and uses the fields belonging to the tax
261
zone given by C<$params{taxzone}> (range 0..3).
262

  
263
The information retrieved by the function is cached.
264

  
219 265
=item C<orphaned>
220 266

  
221 267
Checks if this articke is used in orders, invoices, delivery orders or

Auch abrufbar als: Unified diff