GnuCash 7574033+
Loading...
Searching...
No Matches
PageStockAmount Class Reference

Stock Amount page. More...

Public Member Functions

 PageStockAmount (GtkBuilder *builder, Account *account)
void prepare (StockTransactionEntry *)
gnc_numeric get_stock_amount ()
void set_stock_amount (std::string new_amount_str)
void connect (StockTransactionEntry *entry)

Detailed Description

Stock Amount page.

Display and the amount entered depend on the type of the transaction. It always displays the balanance on the transaction date before the transaction. For buy and sell transactions it collects the number of units bought or sold (always as a positive number) and displays the new balance. For split and reverse-split transactions it collects the balance after the transaction and computes the change in the amount of shares and the split ratio, displaying the latter.

Definition at line 1888 of file assistant-stock-transaction.cpp.

Constructor & Destructor Documentation

◆ PageStockAmount()

PageStockAmount::PageStockAmount ( GtkBuilder * builder,
Account * account )

Definition at line 1906 of file assistant-stock-transaction.cpp.

1906 :
1907 m_page (get_widget (builder, "stock_amount_page")),
1908 m_title (get_widget (builder, "stock_amount_title")),
1909 m_prev_amount (get_widget (builder, "prev_balance_amount")),
1910 m_next_amount (get_widget (builder, "next_balance_amount")),
1911 m_next_amount_label (get_widget (builder, "next_balance_label")),
1912 m_amount (builder, xaccAccountGetCommodity(account)),
1913 m_amount_label (get_widget (builder, "stock_amount_label"))
1914{
1915 m_amount.attach (builder, "stock_amount_table", "stock_amount_label", 1);
1916}
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
Definition Account.cpp:3389

Member Function Documentation

◆ connect()

void PageStockAmount::connect ( StockTransactionEntry * entry)

Definition at line 1948 of file assistant-stock-transaction.cpp.

1949{
1950 m_amount.connect(G_CALLBACK (page_stock_amount_changed_cb), entry);
1951 m_amount.set_owner(static_cast<gpointer>(this));
1952}

◆ get_stock_amount()

gnc_numeric PageStockAmount::get_stock_amount ( )
inline

Definition at line 1901 of file assistant-stock-transaction.cpp.

1901{ return m_amount.get(); }

◆ prepare()

void PageStockAmount::prepare ( StockTransactionEntry * entry)

Definition at line 1919 of file assistant-stock-transaction.cpp.

1920{
1921 gtk_label_set_text_with_mnemonic
1922 (GTK_LABEL (m_amount_label),
1923 entry->input_new_balance() ? _("Ne_w Balance") : _("_Shares"));
1924 gtk_label_set_text
1925 (GTK_LABEL (m_next_amount_label),
1926 entry->input_new_balance() ? _("Ratio") : _("Next Balance"));
1927 gtk_label_set_text
1928 (GTK_LABEL (m_title),
1929 entry->input_new_balance() ?
1930 _("Enter the new balance of shares after the stock split.") :
1931 _("Enter the number of shares you gained or lost in the transaction."));
1932 gtk_label_set_text (GTK_LABEL (m_prev_amount), entry->print_amount(entry->get_balance()));
1933 if (!gnc_numeric_check(get_stock_amount()))
1934 entry->set_amount(get_stock_amount());
1935 set_stock_amount(entry->amount_str_for_display());
1936 g_signal_connect(m_page, "focus", G_CALLBACK(assistant_page_set_focus), m_amount.widget());
1937}
virtual const char * print_amount(gnc_numeric amt) const
virtual std::string amount_str_for_display() const
Generate a string representation of the value.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric in)
Check for error signal in value.

◆ set_stock_amount()

void PageStockAmount::set_stock_amount ( std::string new_amount_str)

Definition at line 1955 of file assistant-stock-transaction.cpp.

1956{
1957 gtk_label_set_text (GTK_LABEL(m_next_amount), new_amount_str.c_str());
1958}

The documentation for this class was generated from the following file: