Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fa1bc76f

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

  • ID fa1bc76fea2531a563f1c16ce0bc08e32ebb44fc
  • Vorgänger 5d6e7d01
  • Nachfolger 251171c1

Wechselkurs-Optimierung: Kosmetik weiter aufräumen

Unterschiede anzeigen:

SL/Controller/BankTransaction.pm
717 717
    # sign is simply the sign of amount in bank_transactions: positive for increase and negative for decrease
718 718
    $amount_for_booking *= $sign;
719 719

  
720
    $main::lxdebug->message(0, 'amount for payment:' . $amount_for_payment);
721
    # check exchangerate and if fx_loss calculate new booking_amount for this invoice
722
    #if ($fx_rate > 0)  {
723
    #  die "Exchangerate without currency"                     unless $currency_id;
724
    #  die "Invoice currency differs from user input currency" unless $currency_id == $invoice->currency->id;
725

  
726

  
727
      # open_amount is open_amount for default currency
728
      # TODO
729
      # use helper to calc everything (even)
730
      # 2 if fx_loss, we probably need a higher amount to pay the original amount of the ap invoice
731
      # no, just calc new open_amount and check if user wants a fee booking
732
    #  my $open_amount_fx = $invoice->open_amount_fx($fx_rate);
733
    #  $amount_for_payment = $fx_book ? $not_assigned_amount : $invoice->open_amount_fx($fx_rate);
734

  
735
    #  die $open_amount_fx;
736
    #  if ($invoice->get_exchangerate < $fx_rate) {
737
        # set whole bank_transaction amount -> pay_invoice will try to calculate losses and bank fees
738
    #    my $not_assigned_amount = abs($bank_transaction->not_assigned_amount);
739
    #    $amount_for_payment = $not_assigned_amount;
740
    #    $amount_for_payment *= -1 if $invoice->amount < 0;
741
    #  } elsif ($invoice->get_exchangerate >= $fx_rate) {
742
        # if fx_gain do nothing, because gain
743
        # bla bla
744
        # TODO copy paste
745
    #    my $not_assigned_amount = abs($bank_transaction->not_assigned_amount);
746
    #    $amount_for_payment = $not_assigned_amount;
747
    #    $amount_for_payment *= -1 if $invoice->amount < 0;
748
    #  } else {
749
    #    die "Invalid exchange rate state for record:" . $invoice->get_exchangerate . " " . $fx_rate;
750
    #  }
751
    #}
752
    #$main::lxdebug->message(0, 'amount for payment2:' . $amount_for_payment);
753 720
    # ... and then pay the invoice
754 721
    my @acc_ids = $invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id,
755 722
                          trans_id      => $invoice->id,
......
766 733
                          transdate     => $bank_transaction->valutadate->to_kivitendo);
767 734
    # First element is the booked amount for accno bank
768 735
    my $bank_amount = shift @acc_ids;
769
    $main::lxdebug->message(0, 'a' . $bank_amount->{return_bank_amount});
770
    $main::lxdebug->message(0, 'b' . $amount_for_booking);
736

  
771 737
    if (!$invoice->forex) {
772 738
      # die "Invalid state, calculated invoice_amount differs from expected invoice amount" unless (abs($bank_amount->{return_bank_amount}) - abs($amount_for_booking) < 0.001);
773 739
      $bank_transaction->invoice_amount($bank_transaction->invoice_amount + $amount_for_booking);
SL/DB/Helper/Payment.pm
163 163
      $paid_amount += $pay_amount;
164 164

  
165 165
      my $amount = (-1 * $pay_amount) * $mult;
166
      $main::lxdebug->message(0, 'bank pay amount:' . $pay_amount);
167
      $main::lxdebug->message(0, 'paidamount:' . $paid_amount);
168 166

  
169 167
      # total amount against bank, do we already know this by now?
170 168
      # Yes, method requires this

Auch abrufbar als: Unified diff