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

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

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

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

            //~ Update transaction
            $transactionMapper = new TransactionMapper(Database::get('money'));
            $transactionId     = $this->route->getParameterCollection()->getByName('id')->getValue();
            $transaction       = $transactionMapper->findById($transactionId);

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

            //~ Check for virtual account
            $accountVirtual         = $this->getAccountVirtual();
            $accountVirtualPrevious = $this->getPreviousAccount($transaction->getAccountIdVirtual());
            $this->updateAccountVirtual($accountVirtual, $accountVirtualPrevious, (float) $post->get('transactionAmount'), $transaction->getAmount());

            $date = trim($post->get('transactionDate'));
            $date = \DateTimeImmutable::createFromFormat('d/m/Y', $date);

            $oldAmount = $transaction->getAmount();

            //~ Add transaction
            $transaction->setAccountId($account->getId());
            $transaction->setName(trim($post->get('transactionName')));
            $transaction->setAmount((float) $post->get('transactionAmount'));
            $transaction->setType(trim($post->get('transactionType')));
            $transaction->setDate($date->format('Y-m-d'));
            $transaction->setComment(trim($post->get('transactionComment')));
            $transaction->setCategoryId((int) $post->get('categoryId'));
            $transaction->setAccountIdVirtual($accountVirtual->getId());

            $transactionMapper->update($transaction);

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

            $accountMapper = new AccountMapper(Database::get('money'));
            $accountMapper->update($account);
        } catch (\Exception $exception) {
            $response->setIsSuccess(false)
                ->setHttpCode(500)
                ->setErrorCode($exception->getCode())
                ->setErrorMessage($exception->getMessage())
                ->setContent(true);
        }

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

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

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

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

            //~ Update transaction
            $transactionMapper = new TransactionMapper(Database::get('money'));
            $transactionId     = $this->route->getParameterCollection()->getByName('id')->getValue();
            $transaction       = $transactionMapper->findById($transactionId);

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

            //~ Check for virtual account
            $accountVirtual         = $this->getAccountVirtual();
            $accountVirtualPrevious = $this->getPreviousAccount($transaction->getAccountIdVirtual());
            $this->updateAccountVirtual($accountVirtual, $accountVirtualPrevious, (float) $post->get('transactionAmount'), $transaction->getAmount());

            $date = trim($post->get('transactionDate'));
            $date = \DateTimeImmutable::createFromFormat('d/m/Y', $date);

            $oldAmount = $transaction->getAmount();

            //~ Add transaction
            $transaction->setAccountId($account->getId());
            $transaction->setName(trim($post->get('transactionName')));
            $transaction->setAmount((float) $post->get('transactionAmount'));
            $transaction->setType(trim($post->get('transactionType')));
            $transaction->setDate($date->format('Y-m-d'));
            $transaction->setComment(trim($post->get('transactionComment')));
            $transaction->setCategoryId((int) $post->get('categoryId'));
            $transaction->setAccountIdVirtual($accountVirtual->getId());

            $transactionMapper->update($transaction);

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

            $accountMapper = new AccountMapper(Database::get('money'));
            $accountMapper->update($account);
        } catch (\Exception $exception) {
            $response->setIsSuccess(false)
                ->setHttpCode(500)
                ->setErrorCode($exception->getCode())
                ->setErrorMessage($exception->getMessage())
                ->setContent(true);
        }

        return $response;
    }
Ajax edit category.

@return ResponseInterface