Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision af131a46

Von Martin Helmling martin.helmling@octosoft.eu vor fast 8 Jahren hinzugefügt

  • ID af131a4635b49e0615dec59c9b7423f0c828e027
  • Vorgänger 568004ba
  • Nachfolger 63dc98ee

Banktransaction: Kontoauszug verbuchen: Sonderfall für "credit_notes"

"credit_notes" haben negativen Betrag,
diese werden nun gesondert behandelt.

Ersetzt commit fbcd5580

Unterschiede anzeigen:

SL/Controller/BankTransaction.pm
100 100
  );
101 101
  $main::lxdebug->message(LXDebug->DEBUG2(),"count bt=".scalar(@{$bank_transactions}." bank_account=".$bank_account->id." chart=".$bank_account->chart_id));
102 102

  
103
  my $all_open_ar_invoices = SL::DB::Manager::Invoice        ->get_all(where => [amount => { ne => \'paid' }], with_objects => ['customer','payment_terms']);
103
  # credit notes have a negative amount, treat differently
104
  my $all_open_ar_invoices = SL::DB::Manager::Invoice        ->get_all(where => [ or => [ amount => { gt => \'paid' },
105
                                                                                          and => [ type    => 'credit_note',
106
                                                                                                   amount  => { lt => \'paid' }
107
                                                                                                 ],
108
                                                                                        ],
109
                                                                                ],
110
                                                                       with_objects => ['customer','payment_terms']);
111

  
104 112
  my $all_open_ap_invoices = SL::DB::Manager::PurchaseInvoice->get_all(where => [amount => { ne => \'paid' }], with_objects => ['vendor'  ,'payment_terms']);
105 113
  my $all_open_sepa_export_items = SL::DB::Manager::SepaExportItem->get_all(where => [chart_id => $bank_account->chart_id ,
106 114
                                                                             'sepa_export.executed' => 0, 'sepa_export.closed' => 0 ], with_objects => ['sepa_export']);
......
658 666
                              amount       => $open_amount,
659 667
                              payment_type => $payment_type,
660 668
                              transdate    => $bank_transaction->transdate->to_kivitendo);
669
      } elsif ( $invoice->is_sales && $invoice->type eq 'credit_note' ) {
670
        # no check for overpayment/multiple payments
671
        $invoice->pay_invoice(chart_id     => $bank_transaction->local_bank_account->chart_id,
672
                              trans_id     => $invoice->id,
673
                              amount       => $invoice->open_amount,
674
                              payment_type => $payment_type,
675
                              transdate    => $bank_transaction->transdate->to_kivitendo);
661 676
      } else { # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary
662
        if ( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) {
663
          $amount_of_transaction *= -1;
664
        }
665 677
        my $overpaid_amount = $amount_of_transaction - $invoice->open_amount;
666 678
        $invoice->pay_invoice(chart_id     => $bank_transaction->local_bank_account->chart_id,
667 679
                              trans_id     => $invoice->id,

Auch abrufbar als: Unified diff