]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/BankTransaction.pm
DB/BankTransaction: Kosmetik Fall SEPA-Check
[mfinanz.git] / SL / Controller / BankTransaction.pm
index f93bfd79e3500ed42e0ee2172304a68211877547..03826739139908c22bfc962ff30fe996ebba45e3 100644 (file)
@@ -222,11 +222,11 @@ sub action_list {
     # the arrays $bt->{proposals} and $bt->{rule_matches}, and the agreement
     # score is stored in $bt->{agreement}
 
     # the arrays $bt->{proposals} and $bt->{rule_matches}, and the agreement
     # score is stored in $bt->{agreement}
 
-    foreach my $open_invoice (@all_non_sepa_invoices){
+    foreach my $open_invoice (@all_non_sepa_invoices, @all_sepa_invoices) {
       ($open_invoice->{agreement}, $open_invoice->{rule_matches}) = $bt->get_agreement_with_invoice($open_invoice);
       ($open_invoice->{agreement}, $open_invoice->{rule_matches}) = $bt->get_agreement_with_invoice($open_invoice);
-      $open_invoice->{realamount} = $::form->format_amount(\%::myconfig,$open_invoice->amount*($open_invoice->{is_ar}?1:-1),2);
-      $main::lxdebug->message(LXDebug->DEBUG2(),"nons invoice_id=".$open_invoice->id." amount=".$open_invoice->amount." agreement=".$open_invoice->{agreement}." rules matches=".$open_invoice->{rule_matches}) if $open_invoice->{agreement} > 2;
-    };
+      $open_invoice->{realamount} = $::form->format_amount(\%::myconfig,
+                                      $open_invoice->amount * ($open_invoice->{is_ar} ? 1 : -1), 2);
+    }
 
     my $agreement = 15;
     my $min_agreement = 3; # suggestions must have at least this score
 
     my $agreement = 15;
     my $min_agreement = 3; # suggestions must have at least this score
@@ -669,7 +669,8 @@ sub save_single_bank_transaction {
       } else {
         # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary
 
       } else {
         # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary
 
-        if ( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) {
+        # this catches credit_notes and negative sales invoices
+        if ( $invoice->is_sales && $invoice->amount < 0 ) {
           # $invoice->open_amount     is negative for credit_notes
           # $bank_transaction->amount is negative for outgoing transactions
           # so $amount_of_transaction is negative but needs positive
           # $invoice->open_amount     is negative for credit_notes
           # $bank_transaction->amount is negative for outgoing transactions
           # so $amount_of_transaction is negative but needs positive
@@ -889,17 +890,16 @@ sub load_ap_record_template_url {
   my ($self, $template) = @_;
 
   return $self->url_for(
   my ($self, $template) = @_;
 
   return $self->url_for(
-    controller                 => 'ap.pl',
-    action                     => 'load_record_template',
-    id                         => $template->id,
-    'form_defaults.amount_1'   => $::form->format_amount(\%::myconfig, -1 * $self->transaction->amount, 2),
-    'form_defaults.transdate'  => $self->transaction->transdate_as_date,
-    'form_defaults.duedate'    => $self->transaction->transdate_as_date,
-    'form_defaults.datepaid_1' => $self->transaction->transdate_as_date,
-    'form_defaults.paid_1'     => $::form->format_amount(\%::myconfig, -1 * $self->transaction->amount, 2),
-    'form_defaults.currency'   => $self->transaction->currency->name,
-    'form_defaults.AP_paid_1'  => $self->transaction->local_bank_account->chart->accno,
-    'form_defaults.callback'   => $self->callback,
+    controller                           => 'ap.pl',
+    action                               => 'load_record_template',
+    id                                   => $template->id,
+    'form_defaults.amount_1'             => $::form->format_amount(\%::myconfig, -1 * $self->transaction->amount, 2),
+    'form_defaults.transdate'            => $self->transaction->transdate_as_date,
+    'form_defaults.duedate'              => $self->transaction->transdate_as_date,
+    'form_defaults.no_payment_bookings'  => 1,
+    'form_defaults.paid_1_suggestion'    => $::form->format_amount(\%::myconfig, -1 * $self->transaction->amount, 2),
+    'form_defaults.AP_paid_1_suggestion' => $self->transaction->local_bank_account->chart->accno,
+    'form_defaults.callback'             => $self->callback,
   );
 }
 
   );
 }