public static function deleteTransaction($hash) {

        $transaction = Transaction::find()->withTransactionPartAndHash($hash)->one();

        if ($transaction === null) {
          throw new Exception("Transaction with hash " . $hash . " not found.");
        }

        $dbTransaction = \Yii::$app->db->beginTransaction();
        try {
            foreach ($transaction->transactionParts as $tp) {
                TransactionPersistance::setAccountBalance($tp->account_id, $tp->accountside_id, $tp->value, true);
            }
            $id = $transaction->transaction_id;
            TransactionPart::deleteAll(['transaction_id' => $transaction->transaction_id]);
            Transaction::deleteAll(['transaction_id' => $transaction->transaction_id]);
            
            $dbTransaction->commit();
            return $id;
        } catch (Exception $e) {
            $dbTransaction->rollBack();
            throw $e;
        }
    }
public static function deleteTransaction($hash) {

        $transaction = Transaction::find()->withTransactionPartAndHash($hash)->one();

        if ($transaction === null) {
          throw new Exception("Transaction with hash " . $hash . " not found.");
        }

        $dbTransaction = \Yii::$app->db->beginTransaction();
        try {
            foreach ($transaction->transactionParts as $tp) {
                TransactionPersistance::setAccountBalance($tp->account_id, $tp->accountside_id, $tp->value, true);
            }
            $id = $transaction->transaction_id;
            TransactionPart::deleteAll(['transaction_id' => $transaction->transaction_id]);
            Transaction::deleteAll(['transaction_id' => $transaction->transaction_id]);
            
            $dbTransaction->commit();
            return $id;
        } catch (Exception $e) {
            $dbTransaction->rollBack();
            throw $e;
        }
    }
public static function deleteTransaction ( $ hash ) { $ transaction = Transaction :: find ( ) -> withTransactionPartAndHash ( $ hash ) -> one ( ) ; if ( $ transaction === null ) { throw new Exception ( "Transaction with hash " . $ hash . " not found." ) ; } $ dbTransaction = \ Yii :: $ app -> db -> beginTransaction ( ) ; try { foreach ( $ transaction -> transactionParts as $ tp ) { TransactionPersistance :: setAccountBalance ( $ tp -> account_id , $ tp -> accountside_id , $ tp -> value , true ) ; } $ id = $ transaction -> transaction_id ; TransactionPart :: deleteAll ( [ 'transaction_id' => $ transaction -> transaction_id ] ) ; Transaction :: deleteAll ( [ 'transaction_id' => $ transaction -> transaction_id ] ) ; $ dbTransaction -> commit ( ) ; return $ id ; } catch ( Exception $ e ) { $ dbTransaction -> rollBack ( ) ; throw $ e ; } }
Delete a Transaction

@param string Transaction hash
@throws Exception
Delete a Transaction