src/Money/Module/Transaction/Controller/Transaction.php
public function ajaxDelete()
    {
        if (!Server::getInstance()->isAjax()) {
            throw new \RuntimeException();
        }

        $response = new Api();
        $response->setHttpCode(200);
        $response->setIsSuccess(true);

        try {
            $post = Post::getInstance();

            //~ Verify account
            $accountId = (int) $post->get('accountId');
            $account   = $this->verifyAccount($accountId);

            //~ Load transaction
            $transactionId = (int) $this->route->getParameterCollection()->getByName('id')->getValue();

            $transactionMapper = new TransactionMapper(Database::get('money'));
            $transaction       = $transactionMapper->findById($transactionId);

            if ($accountId !== $transaction->getAccountId()) {
                throw new \Exception('Mismatch account ID!');
            }

            //~ Check for virtual account
            $accountMapper          = new AccountMapper(Database::get('money'));
            $accountVirtual         = $this->getPreviousAccount($transaction->getAccountIdVirtual());
            $accountVirtualPrevious = $accountMapper->newDataInstance();
            $this->updateAccountVirtual($accountVirtual, $accountVirtualPrevious, $transaction->getAmount(), 0.0);

            //~ Update account amount
            $account->addAmount(-$transaction->getAmount());
            $accountMapper->update($account);

            $transactionMapper->delete($transaction);
        } catch (\Exception $exception) {
            $response->setIsSuccess(false)
                ->setHttpCode(500)
                ->setErrorCode($exception->getCode())
                ->setErrorMessage($exception->getMessage())
                ->setContent(true);
        }

        return $response;
    }
public function ajaxDelete()
    {
        if (!Server::getInstance()->isAjax()) {
            throw new \RuntimeException();
        }

        $response = new Api();
        $response->setHttpCode(200);
        $response->setIsSuccess(true);

        try {
            $post = Post::getInstance();

            //~ Verify account
            $accountId = (int) $post->get('accountId');
            $account   = $this->verifyAccount($accountId);

            //~ Load transaction
            $transactionId = (int) $this->route->getParameterCollection()->getByName('id')->getValue();

            $transactionMapper = new TransactionMapper(Database::get('money'));
            $transaction       = $transactionMapper->findById($transactionId);

            if ($accountId !== $transaction->getAccountId()) {
                throw new \Exception('Mismatch account ID!');
            }

            //~ Check for virtual account
            $accountMapper          = new AccountMapper(Database::get('money'));
            $accountVirtual         = $this->getPreviousAccount($transaction->getAccountIdVirtual());
            $accountVirtualPrevious = $accountMapper->newDataInstance();
            $this->updateAccountVirtual($accountVirtual, $accountVirtualPrevious, $transaction->getAmount(), 0.0);

            //~ Update account amount
            $account->addAmount(-$transaction->getAmount());
            $accountMapper->update($account);

            $transactionMapper->delete($transaction);
        } catch (\Exception $exception) {
            $response->setIsSuccess(false)
                ->setHttpCode(500)
                ->setErrorCode($exception->getCode())
                ->setErrorMessage($exception->getMessage())
                ->setContent(true);
        }

        return $response;
    }
Ajax edit category.

@return ResponseInterface