Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6c0095f1

Von Jan Büren vor mehr als 5 Jahren hinzugefügt

  • ID 6c0095f1ec3bff00c172cc2c7649e757960da9fd
  • Vorgänger 69e03937
  • Nachfolger 0c227fb2

Kontoauszug verbuchen: Neuen Skonto-Typ

Eingabe eines freien Skonto-Betrags in der Maske aktiv.
Ferner Anzeigen des Skonto-Betrags bei with_skonto_pt, damit
der Anwender besser visuell unterstützt wird.

Unterschiede anzeigen:

SL/Controller/BankTransaction.pm
627 627
        };
628 628
      }
629 629

  
630
      my $payment_type;
630
      my ($payment_type, $free_skonto_amount);
631 631
      if ( defined $::form->{invoice_skontos}->{"$bt_id"} ) {
632 632
        $payment_type = shift(@{ $::form->{invoice_skontos}->{"$bt_id"} });
633 633
      } else {
634 634
        $payment_type = 'without_skonto';
635
      };
635
      }
636

  
637
      if ($payment_type eq 'free_skonto') {
638
        # parse user input > 0
639
        if ($::form->parse_amount(\%::myconfig, $::form->{"free_skonto_amount"}->{"$bt_id"}{$invoice->id}) > 0) {
640
          $free_skonto_amount = $::form->parse_amount(\%::myconfig, $::form->{"free_skonto_amount"}->{"$bt_id"}{$invoice->id});
641
        } else {
642
          return {
643
            %data,
644
            result  => 'error',
645
            message => $::locale->text("Free skonto amount has to be a positive number."),
646
          };
647
        }
648
      }
636 649
    # pay invoice
637 650
    # TODO rewrite this: really booked amount should be a return value of Payment.pm
638 651
    # also this controller shouldnt care about how to calc skonto. we simply delegate the
......
648 661

  
649 662
    # get the right direction for the payment bookings (all amounts < 0 are stornos, credit notes or negative ap)
650 663
    $amount_for_payment *= -1 if $invoice->amount < 0;
664
    $free_skonto_amount *= -1 if ($free_skonto_amount && $invoice->amount < 0);
651 665
    # get the right direction for the bank transaction
652 666
    $amount_for_booking *= $sign;
653 667

  
......
655 669

  
656 670
    # ... and then pay the invoice
657 671
    my @acc_ids = $invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id,
658
                          trans_id     => $invoice->id,
659
                          amount       => $amount_for_payment,
660
                          payment_type => $payment_type,
661
                          source       => $source,
662
                          memo         => $memo,
663
                          transdate    => $bank_transaction->valutadate->to_kivitendo);
672
                          trans_id      => $invoice->id,
673
                          amount        => $amount_for_payment,
674
                          payment_type  => $payment_type,
675
                          source        => $source,
676
                          memo          => $memo,
677
                          skonto_amount => $free_skonto_amount,
678
                          transdate     => $bank_transaction->valutadate->to_kivitendo);
664 679
    # ... and record the origin via BankTransactionAccTrans
665 680
    if (scalar(@acc_ids) < 2) {
666 681
      return {

Auch abrufbar als: Unified diff