save_single_bank_transaction dem caller weniger erlauben
authorJan Büren <jan@kivitendo-premium.de>
Thu, 12 Jul 2018 13:25:51 +0000 (15:25 +0200)
committerJan Büren <jan@kivitendo-premium.de>
Mon, 16 Jul 2018 10:41:58 +0000 (12:41 +0200)
Als Konsequenz zum beschriebenem Verhalten im  POD

SL/Controller/BankTransaction.pm

index 591ee7c..6e5c5b4 100644 (file)
@@ -555,11 +555,20 @@ sub save_single_bank_transaction {
     };
   }
 
+  my $bank_transaction = $data{bank_transaction};
+
+  # see pod
+  if (@{ $bank_transaction->linked_invoices } || $bank_transaction->invoice_amount != 0) {
+        return {
+          %data,
+          result  => 'error',
+          message => $::locale->text("Bank transaction with id #1 has already been linked to one or more record and/or some amount is already assigned.", $bank_transaction->id),
+        };
+      }
   my (@warnings);
 
   my $worker = sub {
     my $bt_id                 = $data{bank_transaction_id};
-    my $bank_transaction      = $data{bank_transaction};
     my $sign                  = $bank_transaction->amount < 0 ? -1 : 1;
     my $amount_of_transaction = $sign * $bank_transaction->amount;
     my $payment_received      = $bank_transaction->amount > 0;