Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 45d6fc38

Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt

  • ID 45d6fc385606d960c57d9bf1ec79bbc256f9a5a2
  • Vorgänger b3089c09
  • Nachfolger 517ed14d

PTC: Rückgabehash taxes in taxes_by_chart_id umbenannt

Damit ist klarer, was zu erwarten ist

Unterschiede anzeigen:

SL/DB/Helper/PriceTaxCalculator.pm
29 29
               last_incex_chart_id => undef,
30 30
               units_by_name       => \%units_by_name,
31 31
               price_factors_by_id => \%price_factors_by_id,
32
               taxes               => { },
32
               taxes_by_chart_id   => { },
33 33
               taxes_by_tax_id     => { },
34 34
               amounts             => { },
35 35
               amounts_cogs        => { },
......
66 66

  
67 67
  return $self unless wantarray;
68 68

  
69
  return map { ($_ => $data{$_}) } qw(taxes taxes_by_tax_id amounts amounts_cogs allocated exchangerate assembly_items items rounding);
69
  return map { ($_ => $data{$_}) } qw(taxes_by_chart_id taxes_by_tax_id amounts amounts_cogs allocated exchangerate assembly_items items rounding);
70 70
}
71 71

  
72 72
sub _get_exchangerate {
......
123 123
  }
124 124

  
125 125
  if ($taxkey->tax->chart_id) {
126
    $data->{taxes}->{ $taxkey->tax->chart_id } ||= 0;
127
    $data->{taxes}->{ $taxkey->tax->chart_id }  += $tax_amount;
128
    $data->{taxes_by_tax_id}->{ $taxkey->tax_id } ||= 0;
129
    $data->{taxes_by_tax_id}->{ $taxkey->tax_id }  += $tax_amount;
126
    $data->{taxes_by_chart_id}->{ $taxkey->tax->chart_id } ||= 0;
127
    $data->{taxes_by_chart_id}->{ $taxkey->tax->chart_id }  += $tax_amount;
128
    $data->{taxes_by_tax_id}->{ $taxkey->tax_id }          ||= 0;
129
    $data->{taxes_by_tax_id}->{ $taxkey->tax_id }           += $tax_amount;
130 130
  } elsif ($tax_amount) {
131 131
    die "tax_amount != 0 but no chart_id for taxkey " . $taxkey->id . " tax " . $taxkey->tax->id;
132 132
  }
......
183 183
  my ($self, $data, %params) = @_;
184 184

  
185 185
  my $tax_diff = 0;
186
  foreach my $chart_id (keys %{ $data->{taxes} }) {
187
    my $rounded                  = _round($data->{taxes}->{$chart_id} * $data->{exchangerate}, 2);
188
    $tax_diff                   += $data->{taxes}->{$chart_id} * $data->{exchangerate} - $rounded if $self->taxincluded;
189
    $data->{taxes}->{$chart_id}  = $rounded;
186
  foreach my $chart_id (keys %{ $data->{taxes_by_chart_id} }) {
187
    my $rounded                              = _round($data->{taxes_by_chart_id}->{$chart_id} * $data->{exchangerate}, 2);
188
    $tax_diff                               += $data->{taxes_by_chart_id}->{$chart_id} * $data->{exchangerate} - $rounded if $self->taxincluded;
189
    $data->{taxes_by_chart_id}->{$chart_id}  = $rounded;
190 190
  }
191 191

  
192 192
  $self->netamount(sum map { $_->{amount} } values %{ $data->{amounts} });
......
202 202

  
203 203
  _dbg("Sna " . $self->netamount . " idiff " . $data->{invoicediff} . " tdiff ${tax_diff}");
204 204

  
205
  my $tax              = sum values %{ $data->{taxes} };
205
  my $tax              = sum values %{ $data->{taxes_by_chart_id} };
206 206
  $amount              = $netamount + $tax;
207 207
  my $grossamount      = _round($amount, 2, 1);
208 208
  $data->{rounding}    = _round($grossamount - $amount, 2);
......
338 338

  
339 339
=over 2
340 340

  
341
=item C<taxes>
341
=item C<taxes_by_chart_id>
342 342

  
343 343
A hash reference with the calculated taxes. The keys are chart IDs,
344
the values the calculated taxes.
344
the values the rounded calculated taxes.
345 345

  
346 346
=item C<taxes_by_tax_id>
347 347

  

Auch abrufbar als: Unified diff