[gnc-plugin-page-register.cpp] rewrite function to avoid goto

reorder logic to avoid using goto
This commit is contained in:
Christopher Lam 2024-02-24 23:17:11 +08:00
parent 8090f1c5b0
commit 46aa584ab9

View File

@ -3898,29 +3898,31 @@ gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
{ {
const char *rev = _("A reversing entry has already been created for this transaction."); const char *rev = _("A reversing entry has already been created for this transaction.");
const char *jump = _("Jump to the transaction?"); const char *jump = _("Jump to the transaction?");
if (gnc_verify_dialog (GTK_WINDOW (window), TRUE, "%s\n\n%s", rev, jump)) if (!gnc_verify_dialog (GTK_WINDOW (window), TRUE, "%s\n\n%s", rev, jump))
goto jump_to_trans; {
else LEAVE ("reverse cancelled");
return; return;
}
} }
else
if (!gnc_dup_time64_dialog (window, _("Reverse Transaction"),
_("New Transaction Information"), &date))
{ {
LEAVE ("reverse cancelled"); if (!gnc_dup_time64_dialog (window, _("Reverse Transaction"),
return; _("New Transaction Information"), &date))
{
LEAVE ("reverse cancelled");
return;
}
gnc_suspend_gui_refresh ();
new_trans = xaccTransReverse (trans);
/* Clear transaction level info */
xaccTransSetDatePostedSecsNormalized (new_trans, date);
xaccTransSetDateEnteredSecs (new_trans, gnc_time (NULL));
gnc_resume_gui_refresh();
} }
gnc_suspend_gui_refresh();
new_trans = xaccTransReverse (trans);
/* Clear transaction level info */
xaccTransSetDatePostedSecsNormalized (new_trans, date);
xaccTransSetDateEnteredSecs (new_trans, gnc_time (NULL));
gnc_resume_gui_refresh();
jump_to_trans:
/* Now jump to new trans */ /* Now jump to new trans */
gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE (page)); gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE (page));
split = xaccTransFindSplitByAccount(new_trans, account); split = xaccTransFindSplitByAccount(new_trans, account);