Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision abd56be1

Von Rolf Fluehmann vor fast 8 Jahren hinzugefügt

  • ID abd56be11a58421b1d9401e812a83d28832b939a
  • Vorgänger 04caff2d
  • Nachfolger 4e0bef2d

added roundings for periodic invoices

Unterschiede anzeigen:

SL/DB/Helper/PriceTaxCalculator.pm
57 57

  
58 58
  return $self unless wantarray;
59 59

  
60
  return map { ($_ => $data{$_}) } qw(taxes amounts amounts_cogs allocated exchangerate assembly_items items);
60
  return map { ($_ => $data{$_}) } qw(taxes amounts amounts_cogs allocated exchangerate assembly_items items rounding);
61 61
}
62 62

  
63 63
sub _get_exchangerate {
......
185 185
  _dbg("Sna " . $self->netamount . " idiff " . $data->{invoicediff} . " tdiff ${tax_diff}");
186 186

  
187 187
  my $tax              = sum values %{ $data->{taxes} };
188
  $data->{arap_amount} = $netamount + $tax;
188
  $amount              = $netamount + $tax;
189
  my $grossamount      = _round($amount, 2, 1);
190
  $data->{rounding}    = _round($grossamount - $amount, 2);
191
  $data->{arap_amount} = $grossamount;
189 192

  
190 193
  $self->netamount(    $netamount);
191
  $self->amount(       $netamount + $tax);
194
  $self->amount(       $grossamount);
192 195
  $self->marge_percent($self->netamount ? ($self->netamount - $data->{lastcost_total}) * 100 / $self->netamount : 0);
193 196
}
194 197

  
SL/DB/Invoice.pm
260 260
    $self->_post_add_acctrans({ $params{ar_id} => $self->amount * -1 });
261 261

  
262 262
    $self->_post_update_allocated($data{allocated});
263

  
264
    $self->_post_book_rounding($data{rounding});
263 265
  };
264 266

  
265 267
  if ($self->db->in_transaction) {
......
296 298
  }
297 299
}
298 300

  
301
sub _post_book_rounding {
302
  my ($self, $rounding) = @_;
303

  
304
  my $tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id;
305
  my $rnd_accno = $rounding == 0 ? 0
306
                : $rounding > 0  ? SL::DB::Default->get->rndgain_accno_id
307
                :                  SL::DB::Default->get->rndloss_accno_id
308
  ;
309
  if ($rnd_accno != 0) {
310
    SL::DB::AccTransaction->new(trans_id   => $self->id,
311
                                chart_id   => $rnd_accno,
312
                                amount     => $rounding,
313
                                tax_id     => $tax_id,
314
                                taxkey     => 0,
315
                                project_id => $self->globalproject_id,
316
                                transdate  => $self->transdate,
317
                                chart_link => $rnd_accno)->save;
318
  }
319
}
320

  
299 321
sub add_ar_amount_row {
300 322
  my ($self, %params ) = @_;
301 323

  

Auch abrufbar als: Unified diff