Kontoauszug rückgängig machen: Nur bei aktuellem Beleg arap.paid neu setzen
authorJan Büren <jan@kivitendo.de>
Tue, 23 Jul 2019 07:04:41 +0000 (09:04 +0200)
committerJan Büren <jan@kivitendo.de>
Tue, 23 Jul 2019 07:04:41 +0000 (09:04 +0200)
SL/Controller/BankTransaction.pm

index 86ff35e..98639ff 100644 (file)
@@ -791,9 +791,10 @@ sub action_unlink_bank_transaction {
         my $query = qq|UPDATE $type SET paid =
                         (SELECT COALESCE(abs(sum(amount)),0) FROM acc_trans
                          WHERE trans_id = ?
-                         AND chart_link ilike '%paid%')|;
+                         AND chart_link ilike '%paid%')
+                       WHERE id = ?|;
 
-        die if (do_query($::form, $bank_transaction->db->dbh, $query, $trans_id) == -1);
+        die if (do_query($::form, $bank_transaction->db->dbh, $query, $trans_id, $trans_id) == -1);
       }
       # 4. and delete all (if any) record links
       my $rl = SL::DB::Manager::RecordLink->delete_all(where => [ from_id => $bt_id, from_table => 'bank_transactions' ]);