mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[assistant-stock-transaction] avoid resetting txn_types unnecessarily.
UX improvement. Previously the txn_types dropdown list would be regenerated whenever the GtkAssistant reaches the page PAGE_TRANSACTION_TYPE. This means selecting "Sell", pressing "Next", then "Previous" would reset the type to "Buy". This commit will store the date at which the txn_types was set; it will avoid resetting txn_types unless the date is changed.
This commit is contained in:
parent
19803ba9d0
commit
2b198dbce4
@ -430,6 +430,10 @@ typedef struct
|
|||||||
GtkWidget * assistant;
|
GtkWidget * assistant;
|
||||||
|
|
||||||
std::optional<TxnTypeVec> txn_types;
|
std::optional<TxnTypeVec> txn_types;
|
||||||
|
// the following stores date at which the txn_types were set. If
|
||||||
|
// the GNCDateEdit date is modified, it will trigger recreation of
|
||||||
|
// the txn_types above.
|
||||||
|
std::optional<time64> txn_types_date;
|
||||||
Account * acct;
|
Account * acct;
|
||||||
gnc_commodity * currency;
|
gnc_commodity * currency;
|
||||||
|
|
||||||
@ -830,6 +834,9 @@ stock_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
|
|||||||
gnc_numeric balance;
|
gnc_numeric balance;
|
||||||
time64 date;
|
time64 date;
|
||||||
date = gnc_date_edit_get_date_end (GNC_DATE_EDIT (info->date_edit));
|
date = gnc_date_edit_get_date_end (GNC_DATE_EDIT (info->date_edit));
|
||||||
|
if (info->txn_types_date && (info->txn_types_date == date))
|
||||||
|
break;
|
||||||
|
info->txn_types_date = date;
|
||||||
balance = xaccAccountGetBalanceAsOfDate (info->acct, date);
|
balance = xaccAccountGetBalanceAsOfDate (info->acct, date);
|
||||||
info->txn_types = gnc_numeric_zero_p (balance) ? starting_types
|
info->txn_types = gnc_numeric_zero_p (balance) ? starting_types
|
||||||
: gnc_numeric_positive_p (balance) ? long_types
|
: gnc_numeric_positive_p (balance) ? long_types
|
||||||
|
Loading…
Reference in New Issue
Block a user