[assistant-stock-transaction] test splitinfo before check_page call

... This will be useful for adding Units column
This commit is contained in:
Christopher Lam 2022-09-07 23:46:58 +08:00
parent d3140af6a0
commit 79af372194

View File

@ -638,8 +638,6 @@ check_page (GtkListStore *list, gnc_numeric& debit, gnc_numeric& credit,
FieldMask splitfield, Account *acct, GtkWidget *memo, GtkWidget *gae, FieldMask splitfield, Account *acct, GtkWidget *memo, GtkWidget *gae,
gnc_commodity *comm, const char* page, StringVec& errors) gnc_commodity *comm, const char* page, StringVec& errors)
{ {
if (splitfield == FieldMask::DISABLED)
return;
const char* missing_str = N_("(missing)"); const char* missing_str = N_("(missing)");
const gchar* amtstr; const gchar* amtstr;
gnc_numeric amount; gnc_numeric amount;
@ -766,26 +764,32 @@ to ensure proper recording."), new_date_str, last_split_date_str);
add_error_str (errors, N_("Cannot cover buy more units than owed")); add_error_str (errors, N_("Cannot cover buy more units than owed"));
} }
check_page (list, debit, credit, info->txn_type->stock_value, info->acct, if (info->txn_type->stock_value != FieldMask::DISABLED)
info->stock_memo_edit, info->stock_value_edit, info->currency, check_page (list, debit, credit, info->txn_type->stock_value, info->acct,
NC_ ("Stock Assistant: Page name", "stock value"), errors); info->stock_memo_edit, info->stock_value_edit, info->currency,
NC_ ("Stock Assistant: Page name", "stock value"), errors);
check_page (list, debit, credit, info->txn_type->cash_value, if (info->txn_type->cash_value != FieldMask::DISABLED)
gas_account (info->cash_account), info->cash_memo_edit, check_page (list, debit, credit, info->txn_type->cash_value,
info->cash_value, info->currency, gas_account (info->cash_account), info->cash_memo_edit,
NC_ ("Stock Assistant: Page name", "cash"), errors); info->cash_value, info->currency,
NC_ ("Stock Assistant: Page name", "cash"), errors);
auto capitalize_fees = gtk_toggle_button_get_active if (info->txn_type->fees_value != FieldMask::DISABLED)
(GTK_TOGGLE_BUTTON (info->capitalize_fees_checkbox)); {
check_page (list, debit, credit, info->txn_type->fees_value, auto capitalize_fees = gtk_toggle_button_get_active
capitalize_fees ? info->acct : gas_account (info->fees_account), (GTK_TOGGLE_BUTTON (info->capitalize_fees_checkbox));
info->fees_memo_edit, info->fees_value, info->currency, check_page (list, debit, credit, info->txn_type->fees_value,
NC_ ("Stock Assistant: Page name", "fees"), errors); capitalize_fees ? info->acct : gas_account (info->fees_account),
info->fees_memo_edit, info->fees_value, info->currency,
NC_ ("Stock Assistant: Page name", "fees"), errors);
}
check_page (list, debit, credit, info->txn_type->dividend_value, if (info->txn_type->dividend_value != FieldMask::DISABLED)
gas_account (info->dividend_account), check_page (list, debit, credit, info->txn_type->dividend_value,
info->dividend_memo_edit, info->dividend_value, info->currency, gas_account (info->dividend_account),
NC_ ("Stock Assistant: Page name", "dividend"), errors); info->dividend_memo_edit, info->dividend_value, info->currency,
NC_ ("Stock Assistant: Page name", "dividend"), errors);
// the next two checks will involve the two capgains splits: // the next two checks will involve the two capgains splits:
// income side and stock side. The capgains_value ^ // income side and stock side. The capgains_value ^