From c313c3dedf02bd9ce800755c6a169fec07b2bb57 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Fri, 30 Jun 2023 19:18:03 +0800 Subject: [PATCH] [stock-txn-asst] create_transaction() returns This reverts commit 67515497f7d37bf67bf917ba37099851ddc78fb2. Because the Transaction* is used in the tests. Also it's a possible enhancement that the register will jump to the newly created transaction when the assistant completes. --- gnucash/gnome/assistant-stock-transaction.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gnucash/gnome/assistant-stock-transaction.cpp b/gnucash/gnome/assistant-stock-transaction.cpp index eafab37f06..6b2d428581 100644 --- a/gnucash/gnome/assistant-stock-transaction.cpp +++ b/gnucash/gnome/assistant-stock-transaction.cpp @@ -736,7 +736,7 @@ struct StockAssistantModel std::string get_new_amount_str (); std::tuple calculate_price (); std::tuple generate_list_of_splits (); - bool create_transaction (); + std::tuple create_transaction (); private: std::optional m_txn_types_date; @@ -1044,13 +1044,13 @@ StockAssistantModel::generate_list_of_splits() { return { m_ready_to_create, summary_message(), m_list_of_splits }; } -bool +std::tuple StockAssistantModel::create_transaction () { if (!m_ready_to_create) { PERR ("errors exist. cannot create transaction."); - return false; + return {false, nullptr}; } auto book = qof_instance_get_book (m_acct); auto trans = xaccMallocTransaction (book); @@ -1065,7 +1065,7 @@ StockAssistantModel::create_transaction () xaccTransCommitEdit (trans); std::for_each (accounts.begin(), accounts.end(), xaccAccountCommitEdit); m_ready_to_create = false; - return true; + return {true, trans}; } void @@ -2020,11 +2020,10 @@ stock_assistant_finish_cb (GtkAssistant *assistant, gpointer user_data) g_return_if_fail (info->model->m_txn_type); gnc_suspend_gui_refresh (); - auto success = info->model->create_transaction(); + [[maybe_unused]] auto [success, trans] = info->model->create_transaction(); gnc_resume_gui_refresh (); - if (success) - gnc_close_gui_component_by_data (ASSISTANT_STOCK_TRANSACTION_CM_CLASS, info); + gnc_close_gui_component_by_data (ASSISTANT_STOCK_TRANSACTION_CM_CLASS, info); }