Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5adc35c8

Von Jan Büren vor etwa 2 Jahren hinzugefügt

  • ID 5adc35c8d0dd0ca16e5784eb888a6e83ffed177e
  • Vorgänger 9d9c8f14
  • Nachfolger 93cde6f5

Payment-Helper um Rückgabewert invoice_amount für bank_transaction ergänzt

Testfälle und Anmerkung zu exchangerate

Unterschiede anzeigen:

SL/DB/Helper/Payment.pm
91 91

  
92 92
  # currency is either passed or use the invoice currency if it differs from the default currency
93 93
  # TODO remove
94
  my ($exchangerate,$currency);
94
  my ($exchangerate, $currency, $return_bank_amount);
95
  $return_bank_amount = 0;
95 96
  if ($params{currency} || $params{currency_id}) {
96 97
    if ($params{currency} || $params{currency_id} ) { # currency was specified
97 98
      $currency = SL::DB::Manager::Currency->find_by(name => $params{currency}) || SL::DB::Manager::Currency->find_by(id => $params{currency_id});
......
171 172
                                                   taxkey     => 0,
172 173
                                                   tax_id     => SL::DB::Manager::Tax->find_by(taxkey => 0)->id);
173 174
      $new_acc_trans->save;
175
      $return_bank_amount += $amount;
174 176

  
175 177
      push @new_acc_ids, $new_acc_trans->acc_trans_id;
176 178
      # deal with fxtransaction
......
193 195
        if ($self->exchangerate and $self->exchangerate != 1 and $self->exchangerate != $exchangerate) {
194 196
          my $fxgain_chart = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxgain_accno_id) || die "Can't determine fxgain chart";
195 197
          my $fxloss_chart = SL::DB::Manager::Chart->find_by(id => $::instance_conf->get_fxloss_accno_id) || die "Can't determine fxloss chart";
198
          # would nearly work if $amount is in foreign currency. Old code in AP.pm
199
          # and old code says USD * ( rate invoice - rate payment )
196 200
          my $gain_loss_amount = _round($amount * ($exchangerate - $self->exchangerate ) * -1,2);
201
          #                               EUR / rate payment   * ( rate invoice - rate bank transaction)
197 202
          my $gain_loss_chart = $gain_loss_amount > 0 ? $fxgain_chart : $fxloss_chart;
198 203
          $fx_gain_loss_amount = $gain_loss_amount;
199 204

  
......
380 385
    1;
381 386

  
382 387
  }) || die t8('error while paying invoice #1 : ', $self->invnumber) . $db->error . "\n";
383
  return wantarray ? @new_acc_ids : 1;
388

  
389
  $return_bank_amount *= -1;   # negative booking is positive bank transaction
390
                               # positive booking is negative bank transaction
391
  return wantarray ? ( { return_bank_amount => $return_bank_amount }, @new_acc_ids) : 1;
384 392
}
385 393

  
386 394
sub skonto_date {

Auch abrufbar als: Unified diff