GnuCash c935c2f+
Loading...
Searching...
No Matches
Modules | Files | Data Structures | Macros | Enumerations | Functions | Variables | Friends
GnuCash Engine: Core, Non-GUI Accounting Functions

The GnuCash Engine provides a set of objects and classes that encapsulate typical financial accounting concepts. More...

Modules

 Environment
 The API in this file is used to read the environment configuration file and set up a number of environment variables based on the values found in it.
 
 Generic Preference Utilities
 The only function in this file is meant to initialize the preferences system early in the load process.
 
 
 Cap Gains
 This file implements the various routines to automatically compute and handle Cap Gains/Losses resulting from trading activities.
 
 Commodities
 A commodity is something of value that is easily tradeable or sellable; for example, currencies, stocks, bonds, grain, copper, and oil are all commodities.
 
 Lots: Core Function for AR/AP, Inventory, Stock Lots, Cap Gains
 One often needs to know that the item 'bought' in one transaction is the same one as the item 'sold' in a different transaction.
 
 Options
 GnuCash Options System for Book, Report, and Stylesheet Options.
 
 Price Database
 The PriceDB is intended to be a database of price quotes, or more specifically, a database of GNCPrices.
 
 Prices
 Each price in the database represents an "instantaneous" quote for a given commodity with respect to another commodity.
 
 Business
 This module implements a number of basic small-business accounting functions.
 
 Accounting Policy (FIFO/LIFO)
 This file implements Accounting Policy.
 
 Scheduled/Periodic/Recurring Transactions
 Scheduled Transactions provide a framework for remembering information about a transactions that are set to occur in the future, either once or periodically.
 
 Data Validation
 Data scrubbing, repairing and forward migration routines.
 
 Transaction, Split
 A good overview of transactions, splits and accounts can be found in the texinfo documentation, together with an overview of how to use this API.
 
 Transaction Logging
 The transaction logging mechanism provides a very simple, low-level logging of user input to a file.
 

Files

file  gnc-engine.h
 All type declarations for the whole Gnucash engine.
 
file  Transaction.h
 API for Transactions and Splits (journal entries)
 

Data Structures

struct  GncImapInfo
 

Macros

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"
 This is the type-override when you want to match all accounts.
 
#define GNC_TYPE_TRANSACTION   (gnc_transaction_get_type ())
 
#define GNC_TRANSACTION(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, Transaction))
 
#define GNC_TRANSACTION_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, TransactionClass))
 
#define GNC_IS_TRANSACTION(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TRANSACTION))
 
#define GNC_IS_TRANSACTION_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TRANSACTION))
 
#define GNC_TRANSACTION_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TRANSACTION, TransactionClass))
 
#define GNC_IS_TRANS(obj)   GNC_IS_TRANSACTION(obj)
 
#define GNC_TRANS(obj)   GNC_TRANSACTION(obj)
 
#define RECONCILED_MATCH_TYPE   "reconciled-match"
 
#define xaccTransGetBook(X)   qof_instance_get_book (QOF_INSTANCE(X))
 
#define xaccTransGetGUID(X)   qof_entity_get_guid(QOF_INSTANCE(X))
 

Enumerations

enum  GNCPlaceholderType { PLACEHOLDER_NONE , PLACEHOLDER_THIS , PLACEHOLDER_CHILD }
 DOCUMENT ME! More...
 

Functions

 GncOptionValue< ValueType >::GncOptionValue (const char *section, const char *name, const char *key, const char *doc_string, ValueType value, GncOptionUIType ui_type=GncOptionUIType::INTERNAL)
 
 GncOptionValue< ValueType >::GncOptionValue (const GncOptionValue &)=default
 
 GncOptionValue< ValueType >::GncOptionValue (GncOptionValue &&)=default
 
GncOptionValueGncOptionValue< ValueType >::operator= (const GncOptionValue &)=default
 
GncOptionValueGncOptionValue< ValueType >::operator= (GncOptionValue &&)=default
 
ValueType GncOptionValue< ValueType >::get_value () const
 
ValueType GncOptionValue< ValueType >::get_default_value () const
 
void GncOptionValue< ValueType >::set_value (ValueType new_value)
 
void GncOptionValue< ValueType >::set_default_value (ValueType new_value)
 
void GncOptionValue< ValueType >::reset_default_value ()
 
void GncOptionValue< ValueType >::mark_saved () noexcept
 
bool GncOptionValue< ValueType >::is_dirty () const noexcept
 
bool GncOptionValue< ValueType >::is_changed () const noexcept
 
GncOptionUIType GncOptionValue< ValueType >::get_ui_type () const noexcept
 
void GncOptionValue< ValueType >::make_internal ()
 
bool GncOptionValue< ValueType >::is_internal ()
 
std::string GncOptionValue< ValueType >::serialize () const noexcept
 
bool GncOptionValue< ValueType >::deserialize (const std::string &str) noexcept
 
void GncOwnerDeleter::operator() (GncOwner *o)
 
 GncOptionGncOwnerValue::GncOptionGncOwnerValue (const char *section, const char *name, const char *key, const char *doc_string, const GncOwner *value, GncOptionUIType ui_type=GncOptionUIType::INTERNAL)
 
 GncOptionGncOwnerValue::GncOptionGncOwnerValue (const GncOptionGncOwnerValue &from)
 
 GncOptionGncOwnerValue::GncOptionGncOwnerValue (GncOptionGncOwnerValue &&)=default
 
const GncOwnerGncOptionGncOwnerValue::get_value () const
 
const GncOwnerGncOptionGncOwnerValue::get_default_value () const
 
void GncOptionGncOwnerValue::set_value (const GncOwner *new_value)
 
void GncOptionGncOwnerValue::set_default_value (const GncOwner *new_value)
 
void GncOptionGncOwnerValue::reset_default_value ()
 
void GncOptionGncOwnerValue::mark_saved () noexcept
 
bool GncOptionGncOwnerValue::is_dirty () const noexcept
 
bool GncOptionGncOwnerValue::is_changed () const noexcept
 
GncOptionUIType GncOptionGncOwnerValue::get_ui_type () const noexcept
 
void GncOptionGncOwnerValue::make_internal ()
 
bool GncOptionGncOwnerValue::is_internal ()
 
std::string GncOptionGncOwnerValue::serialize () const noexcept
 
bool GncOptionGncOwnerValue::deserialize (const std::string &str) noexcept
 
 GncOptionQofInstanceValue::GncOptionQofInstanceValue (const char *section, const char *name, const char *key, const char *doc_string, const QofInstance *value, GncOptionUIType ui_type=GncOptionUIType::INTERNAL)
 
 GncOptionQofInstanceValue::GncOptionQofInstanceValue (const GncOptionQofInstanceValue &from)
 
 GncOptionQofInstanceValue::GncOptionQofInstanceValue (GncOptionQofInstanceValue &&)=default
 
GncOptionQofInstanceValueGncOptionQofInstanceValue::operator= (GncOptionQofInstanceValue &&)=default
 
const QofInstanceGncOptionQofInstanceValue::get_value () const
 
const QofInstanceGncOptionQofInstanceValue::get_default_value () const
 
GncItem GncOptionQofInstanceValue::get_item () const
 
GncItem GncOptionQofInstanceValue::get_default_item () const
 
void GncOptionQofInstanceValue::set_value (const QofInstance *new_value)
 
void GncOptionQofInstanceValue::set_default_value (const QofInstance *new_value)
 
void GncOptionQofInstanceValue::reset_default_value ()
 
void GncOptionQofInstanceValue::mark_saved () noexcept
 
bool GncOptionQofInstanceValue::is_dirty () const noexcept
 
bool GncOptionQofInstanceValue::is_changed () const noexcept
 
GncOptionUIType GncOptionQofInstanceValue::get_ui_type () const noexcept
 
void GncOptionQofInstanceValue::make_internal ()
 
bool GncOptionQofInstanceValue::is_internal ()
 
std::string GncOptionQofInstanceValue::serialize () const noexcept
 
bool GncOptionQofInstanceValue::deserialize (const std::string &str) noexcept
 
 GncOptionCommodityValue::GncOptionCommodityValue (const char *section, const char *name, const char *key, const char *doc_string, gnc_commodity *value, GncOptionUIType ui_type=GncOptionUIType::COMMODITY)
 
 GncOptionCommodityValue::GncOptionCommodityValue (const GncOptionCommodityValue &)=default
 
 GncOptionCommodityValue::GncOptionCommodityValue (GncOptionCommodityValue &&)=default
 
GncOptionCommodityValueGncOptionCommodityValue::operator= (const GncOptionCommodityValue &)=default
 
GncOptionCommodityValueGncOptionCommodityValue::operator= (GncOptionCommodityValue &&)=default
 
gnc_commodity * GncOptionCommodityValue::get_value () const
 
gnc_commodity * GncOptionCommodityValue::get_default_value () const
 
bool GncOptionCommodityValue::validate (gnc_commodity *) const noexcept
 
void GncOptionCommodityValue::set_value (gnc_commodity *value)
 
void GncOptionCommodityValue::set_default_value (gnc_commodity *value)
 
void GncOptionCommodityValue::reset_default_value ()
 
void GncOptionCommodityValue::mark_saved () noexcept
 
bool GncOptionCommodityValue::is_dirty () const noexcept
 
bool GncOptionCommodityValue::is_changed () const noexcept
 
GncOptionUIType GncOptionCommodityValue::get_ui_type () const noexcept
 
void GncOptionCommodityValue::make_internal ()
 
bool GncOptionCommodityValue::is_internal ()
 
std::string GncOptionCommodityValue::serialize () const noexcept
 
bool GncOptionCommodityValue::deserialize (const std::string &str) noexcept
 
 GncOptionRangeValue< ValueType >::GncOptionRangeValue (const char *section, const char *name, const char *key, const char *doc_string, ValueType value, ValueType min, ValueType max, ValueType step)
 
 GncOptionRangeValue< ValueType >::GncOptionRangeValue (const char *section, const char *name, const char *key, const char *doc_string, ValueType value, ValueType min, ValueType max, ValueType step, GncOptionUIType ui)
 
 GncOptionRangeValue< ValueType >::GncOptionRangeValue (const GncOptionRangeValue< ValueType > &)=default
 
 GncOptionRangeValue< ValueType >::GncOptionRangeValue (GncOptionRangeValue< ValueType > &&)=default
 
GncOptionRangeValue< ValueType > & GncOptionRangeValue< ValueType >::operator= (const GncOptionRangeValue< ValueType > &)=default
 
GncOptionRangeValue< ValueType > & GncOptionRangeValue< ValueType >::operator= (GncOptionRangeValue< ValueType > &&)=default
 
ValueType GncOptionRangeValue< ValueType >::get_value () const
 
ValueType GncOptionRangeValue< ValueType >::get_default_value () const
 
bool GncOptionRangeValue< ValueType >::validate (ValueType value)
 
void GncOptionRangeValue< ValueType >::set_value (ValueType value)
 
void GncOptionRangeValue< ValueType >::set_default_value (ValueType value)
 
void GncOptionRangeValue< ValueType >::get_limits (ValueType &upper, ValueType &lower, ValueType &step) const noexcept
 
void GncOptionRangeValue< ValueType >::reset_default_value ()
 
void GncOptionRangeValue< ValueType >::mark_saved () noexcept
 
bool GncOptionRangeValue< ValueType >::is_dirty () const noexcept
 
bool GncOptionRangeValue< ValueType >::is_changed () const noexcept
 
GncOptionUIType GncOptionRangeValue< ValueType >::get_ui_type () const noexcept
 
void GncOptionRangeValue< ValueType >::make_internal ()
 
bool GncOptionRangeValue< ValueType >::is_internal ()
 
bool GncOptionRangeValue< ValueType >::is_alternate () const noexcept
 
void GncOptionRangeValue< ValueType >::set_alternate (bool value) noexcept
 
std::string GncOptionRangeValue< ValueType >::serialize () const noexcept
 
bool GncOptionRangeValue< ValueType >::deserialize (const std::string &str) noexcept
 
 GncOptionMultichoiceValue::GncOptionMultichoiceValue (const char *section, const char *name, const char *key, const char *doc_string, const char *value, GncMultichoiceOptionChoices &&choices, GncOptionUIType ui_type=GncOptionUIType::MULTICHOICE)
 
 GncOptionMultichoiceValue::GncOptionMultichoiceValue (const char *section, const char *name, const char *key, const char *doc_string, uint16_t index, GncMultichoiceOptionChoices &&choices, GncOptionUIType ui_type=GncOptionUIType::MULTICHOICE)
 
 GncOptionMultichoiceValue::GncOptionMultichoiceValue (const char *section, const char *name, const char *key, const char *doc_string, GncMultichoiceOptionIndexVec &&indices, GncMultichoiceOptionChoices &&choices, GncOptionUIType ui_type=GncOptionUIType::LIST)
 
 GncOptionMultichoiceValue::GncOptionMultichoiceValue (const GncOptionMultichoiceValue &)=default
 
 GncOptionMultichoiceValue::GncOptionMultichoiceValue (GncOptionMultichoiceValue &&)=default
 
GncOptionMultichoiceValueGncOptionMultichoiceValue::operator= (const GncOptionMultichoiceValue &)=default
 
GncOptionMultichoiceValueGncOptionMultichoiceValue::operator= (GncOptionMultichoiceValue &&)=default
 
const std::string & GncOptionMultichoiceValue::get_value () const
 
const std::string & GncOptionMultichoiceValue::get_default_value () const
 
uint16_t GncOptionMultichoiceValue::get_index () const
 
const GncMultichoiceOptionIndexVec & GncOptionMultichoiceValue::get_multiple () const noexcept
 
const GncMultichoiceOptionIndexVec & GncOptionMultichoiceValue::get_default_multiple () const noexcept
 
bool GncOptionMultichoiceValue::validate (const std::string &value) const noexcept
 
bool GncOptionMultichoiceValue::validate (const GncMultichoiceOptionIndexVec &indexes) const noexcept
 
void GncOptionMultichoiceValue::set_value (const std::string &value)
 
void GncOptionMultichoiceValue::set_value (uint16_t index)
 
void GncOptionMultichoiceValue::set_default_value (const std::string &value)
 
void GncOptionMultichoiceValue::set_default_value (uint16_t index)
 
void GncOptionMultichoiceValue::set_multiple (const GncMultichoiceOptionIndexVec &indexes)
 
void GncOptionMultichoiceValue::set_default_multiple (const GncMultichoiceOptionIndexVec &indexes)
 
uint16_t GncOptionMultichoiceValue::num_permissible_values () const noexcept
 
uint16_t GncOptionMultichoiceValue::permissible_value_index (const char *key) const noexcept
 
const char * GncOptionMultichoiceValue::permissible_value (uint16_t index) const
 
const char * GncOptionMultichoiceValue::permissible_value_name (uint16_t index) const
 
void GncOptionMultichoiceValue::reset_default_value ()
 
void GncOptionMultichoiceValue::mark_saved () noexcept
 
bool GncOptionMultichoiceValue::is_dirty () const noexcept
 
bool GncOptionMultichoiceValue::is_changed () const noexcept
 
GncOptionUIType GncOptionMultichoiceValue::get_ui_type () const noexcept
 
void GncOptionMultichoiceValue::make_internal ()
 
bool GncOptionMultichoiceValue::is_internal ()
 
GncOptionMultichoiceKeyType GncOptionMultichoiceValue::get_keytype (unsigned i) const
 
std::string GncOptionMultichoiceValue::serialize () const noexcept
 
bool GncOptionMultichoiceValue::deserialize (const std::string &str) noexcept
 
 GncOptionAccountListValue::GncOptionAccountListValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, bool multi=true)
 
 GncOptionAccountListValue::GncOptionAccountListValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, const GncOptionAccountList &value, bool multi=true)
 
 GncOptionAccountListValue::GncOptionAccountListValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, GncOptionAccountTypeList &&allowed, bool multi=true)
 
 GncOptionAccountListValue::GncOptionAccountListValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, const GncOptionAccountList &value, GncOptionAccountTypeList &&allowed, bool multi=true)
 
GncOptionAccountList GncOptionAccountListValue::get_value () const
 
GncOptionAccountList GncOptionAccountListValue::get_default_value () const
 
bool GncOptionAccountListValue::validate (const GncOptionAccountList &values) const
 
void GncOptionAccountListValue::set_value (GncOptionAccountList values)
 
void GncOptionAccountListValue::set_default_value (GncOptionAccountList values)
 
GList * GncOptionAccountListValue::account_type_list () const noexcept
 Create a GList of account types to pass to gnc_account_sel_set_acct_filters.
 
void GncOptionAccountListValue::reset_default_value ()
 
void GncOptionAccountListValue::mark_saved () noexcept
 
bool GncOptionAccountListValue::is_dirty () const noexcept
 
bool GncOptionAccountListValue::is_changed () const noexcept
 
GncOptionUIType GncOptionAccountListValue::get_ui_type () const noexcept
 
void GncOptionAccountListValue::make_internal ()
 
bool GncOptionAccountListValue::is_internal ()
 
bool GncOptionAccountListValue::is_multiselect () const noexcept
 
std::string GncOptionAccountListValue::serialize () const noexcept
 
bool GncOptionAccountListValue::deserialize (const std::string &str) noexcept
 
 GncOptionAccountSelValue::GncOptionAccountSelValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type)
 
 GncOptionAccountSelValue::GncOptionAccountSelValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, const Account *value)
 
 GncOptionAccountSelValue::GncOptionAccountSelValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, GncOptionAccountTypeList &&allowed)
 
 GncOptionAccountSelValue::GncOptionAccountSelValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, const Account *value, GncOptionAccountTypeList &&allowed)
 
const AccountGncOptionAccountSelValue::get_value () const
 
const AccountGncOptionAccountSelValue::get_default_value () const
 
bool GncOptionAccountSelValue::validate (const Account *value) const
 
void GncOptionAccountSelValue::set_value (const Account *value)
 
void GncOptionAccountSelValue::set_default_value (const Account *value)
 
GList * GncOptionAccountSelValue::account_type_list () const noexcept
 Create a GList of account types to pass to gnc_account_sel_set_acct_filters.
 
void GncOptionAccountSelValue::reset_default_value ()
 
void GncOptionAccountSelValue::mark_saved () noexcept
 
bool GncOptionAccountSelValue::is_dirty () const noexcept
 
bool GncOptionAccountSelValue::is_changed () const noexcept
 
GncOptionUIType GncOptionAccountSelValue::get_ui_type () const noexcept
 
void GncOptionAccountSelValue::make_internal ()
 
bool GncOptionAccountSelValue::is_internal ()
 
std::string GncOptionAccountSelValue::serialize () const noexcept
 
bool GncOptionAccountSelValue::deserialize (const std::string &str) noexcept
 
 GncOptionDateValue::GncOptionDateValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type)
 
 GncOptionDateValue::GncOptionDateValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, time64 time)
 
 GncOptionDateValue::GncOptionDateValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, RelativeDatePeriod period)
 
 GncOptionDateValue::GncOptionDateValue (const char *section, const char *name, const char *key, const char *doc_string, GncOptionUIType ui_type, const RelativeDatePeriodVec &period_set)
 
 GncOptionDateValue::GncOptionDateValue (const GncOptionDateValue &)=default
 
 GncOptionDateValue::GncOptionDateValue (GncOptionDateValue &&)=default
 
GncOptionDateValueGncOptionDateValue::operator= (const GncOptionDateValue &)=default
 
GncOptionDateValueGncOptionDateValue::operator= (GncOptionDateValue &&)=default
 
time64 GncOptionDateValue::get_value () const noexcept
 
time64 GncOptionDateValue::get_default_value () const noexcept
 
RelativeDatePeriod GncOptionDateValue::get_period () const noexcept
 
RelativeDatePeriod GncOptionDateValue::get_default_period () const noexcept
 
uint16_t GncOptionDateValue::get_period_index () const noexcept
 
uint16_t GncOptionDateValue::get_default_period_index () const noexcept
 
std::ostream & GncOptionDateValue::out_stream (std::ostream &oss) const noexcept
 
std::istream & GncOptionDateValue::in_stream (std::istream &iss)
 
bool GncOptionDateValue::validate (RelativeDatePeriod value)
 
bool GncOptionDateValue::validate (time64 time)
 
void GncOptionDateValue::set_value (RelativeDatePeriod value)
 
void GncOptionDateValue::set_value (time64 time)
 
void GncOptionDateValue::set_value (uint16_t index) noexcept
 
void GncOptionDateValue::set_default_value (RelativeDatePeriod value)
 
void GncOptionDateValue::set_default_value (time64 time)
 
uint16_t GncOptionDateValue::num_permissible_values () const noexcept
 
uint16_t GncOptionDateValue::permissible_value_index (const char *key) const noexcept
 
const char * GncOptionDateValue::permissible_value (uint16_t index) const
 
const char * GncOptionDateValue::permissible_value_name (uint16_t index) const
 
void GncOptionDateValue::reset_default_value ()
 
void GncOptionDateValue::mark_saved () noexcept
 
bool GncOptionDateValue::is_dirty () const noexcept
 
bool GncOptionDateValue::is_changed () const noexcept
 
GncOptionUIType GncOptionDateValue::get_ui_type () const noexcept
 
void GncOptionDateValue::make_internal ()
 
bool GncOptionDateValue::is_internal ()
 
const RelativeDatePeriodVec & GncOptionDateValue::get_period_set () const
 
std::string GncOptionDateValue::serialize () const noexcept
 
bool GncOptionDateValue::deserialize (const std::string &str) noexcept
 
template<typename OptionType , typename std::enable_if_t< is_OptionClassifier_v< OptionType >, int > = 0>
 GncOption::GncOption (OptionType option)
 
template<typename ValueType , typename std::enable_if_t<!is_OptionClassifier_v< ValueType >, int > = 0>
 GncOption::GncOption (const char *section, const char *name, const char *key, const char *doc_string, ValueType value, GncOptionUIType ui_type=GncOptionUIType::INTERNAL)
 
template<typename ValueType >
void GncOption::set_value (ValueType value)
 
template<typename ValueType >
void GncOption::set_default_value (ValueType value)
 
template<typename ValueType >
ValueType GncOption::get_default_value () const
 
template<typename ValueType >
ValueType GncOption::get_value () const
 
void GncOption::reset_default_value ()
 
const std::string & GncOption::get_section () const
 
const std::string & GncOption::get_name () const
 
const std::string & GncOption::get_key () const
 
const std::string & GncOption::get_docstring () const
 
void GncOption::set_ui_item (GncOptionUIItemPtr &&ui_elem)
 
const GncOptionUIType GncOption::get_ui_type () const
 
void GncOption::set_ui_item_selectable (bool) const noexcept
 
GncOptionUIItem *const GncOption::get_ui_item () const
 
void GncOption::set_ui_item_from_option ()
 
void GncOption::set_option_from_ui_item ()
 
void GncOption::make_internal ()
 
bool GncOption::is_internal ()
 
void GncOption::mark_saved () noexcept
 Mark the option as needing to be saved.
 
bool GncOption::is_dirty () const noexcept
 
bool GncOption::is_changed () const noexcept
 
bool GncOption::is_multiselect () const noexcept
 
template<typename ValueType >
void GncOption::get_limits (ValueType &, ValueType &, ValueType &) const noexcept
 Implemented only for GncOptionNumericRange.
 
template<typename ValueType >
bool GncOption::validate (ValueType value) const
 Not implemented for GncOptionValue.
 
uint16_t GncOption::num_permissible_values () const
 Implemented only for GncOptionMultiselectValue.
 
uint16_t GncOption::permissible_value_index (const char *value) const
 Implemented only for GncOptionMultiselectValue.
 
const char * GncOption::permissible_value (uint16_t index) const
 Implemented only for GncOptionMultiselectValue.
 
const char * GncOption::permissible_value_name (uint16_t index) const
 Implemented only for GncOptionMultiselectValue.
 
GList * GncOption::account_type_list () const noexcept
 Implemented only for GncOptionAccountListValue.
 
bool GncOption::is_alternate () const noexcept
 
void GncOption::set_alternate (bool) noexcept
 
std::string GncOption::serialize () const
 Get a string suitable for storage representing the option's value.
 
bool GncOption::deserialize (const std::string &str)
 Set the option's value from a character sequence.
 
std::istream & GncOption::in_stream (std::istream &iss)
 Set the option's value from an input stream.
 
void GncOption::set_widget_changed (std::any cb)
 
std::any & GncOption::get_widget_changed ()
 
 GncOptionSection::GncOptionSection (const char *name)
 
void GncOptionSection::foreach_option (std::function< void(GncOption &)> func)
 
void GncOptionSection::foreach_option (std::function< void(const GncOption &)> func) const
 
const std::string & GncOptionSection::get_name () const noexcept
 
size_t GncOptionSection::get_num_options () const noexcept
 
void GncOptionSection::add_option (GncOption &&option)
 
void GncOptionSection::remove_option (const char *name)
 
const GncOptionGncOptionSection::find_option (const char *name) const
 
 GncOptionDBCallback::GncOptionDBCallback (size_t id, GncOptionDBChangeCallback func, void *data)
 
 GncOptionDBCallback::GncOptionDBCallback (const GncOptionDBCallback &)=delete
 
 GncOptionDBCallback::GncOptionDBCallback (GncOptionDBCallback &&)=default
 
GncOptionDBCallbackGncOptionDBCallback::operator= (const GncOptionDBCallback &)=default
 
GncOptionDBCallbackGncOptionDBCallback::operator= (GncOptionDBCallback &&)=default
 
 GncOptionDB::GncOptionDB (QofBook *book)
 
void GncOptionDB::foreach_section (std::function< void(GncOptionSectionPtr &)> func)
 
void GncOptionDB::foreach_section (std::function< void(const GncOptionSectionPtr &)> func) const
 
size_t GncOptionDB::num_sections () const noexcept
 
bool GncOptionDB::get_changed () const noexcept
 
void GncOptionDB::register_option (const char *section, GncOption &&option)
 
void GncOptionDB::register_option (const char *section, GncOption *option)
 
void GncOptionDB::unregister_option (const char *section, const char *name)
 
void GncOptionDB::set_default_section (const char *section)
 
const GncOptionSection *const GncOptionDB::get_default_section () const noexcept
 
std::string GncOptionDB::lookup_string_option (const char *section, const char *name)
 
bool GncOptionDB::set_string_option (const char *section, const char *name, const std::string &value)
 
template<typename ValueType >
bool GncOptionDB::set_option (const char *section, const char *name, ValueType value)
 
void GncOptionDB::make_internal (const char *section, const char *name)
 
void GncOptionDB::commit ()
 
GncOptionSectionGncOptionDB::find_section (const std::string &sectname)
 
const GncOptionSectionGncOptionDB::find_section (const std::string &sectname) const
 
GncOptionGncOptionDB::find_option (const std::string &section, const char *name)
 
const GncOptionGncOptionDB::find_option (const std::string &section, const char *name) const
 
std::ostream & GncOptionDB::save_to_key_value (std::ostream &oss) const noexcept
 
std::istream & GncOptionDB::load_from_key_value (std::istream &iss)
 
void GncOptionDB::save_to_kvp (QofBook *book, bool clear_book) const noexcept
 
void GncOptionDB::load_from_kvp (QofBook *book) noexcept
 
std::ostream & GncOptionDB::save_option_key_value (std::ostream &oss, const std::string &section, const std::string &name) const noexcept
 
std::istream & GncOptionDB::load_option_key_value (std::istream &iss)
 
size_t GncOptionDB::register_callback (GncOptionDBChangeCallback, void *)
 
void GncOptionDB::unregister_callback (size_t)
 
void GncOptionDB::run_callbacks ()
 
GType gnc_transaction_get_type (void)
 
void xaccTransRecordPrice (Transaction *trans, PriceSource source)
 The xaccTransRecordPrice() method iterates through the splits and and record the non-currency equivalent prices in the price database.
 

Variables

std::string OptionClassifier::m_section
 
std::string OptionClassifier::m_name
 
std::string OptionClassifier::m_sort_tag
 
std::string OptionClassifier::m_doc_string
 
static constexpr bool is_GncOwnerValue< T >::value
 
static constexpr bool is_QofInstanceValue< T >::value
 
static constexpr bool is_QofQueryValue< T >::value
 
static constexpr bool is_OptionClassifier< T >::value
 
static constexpr bool is_same_decayed< T, U >::value
 
static constexpr bool is_RangeValue< T >::value
 
size_t GncOptionDBCallback::m_id
 
GncOptionDBChangeCallback GncOptionDBCallback::m_func
 
void * GncOptionDBCallback::m_data
 

Friends

GncOptionVariant & GncOption::swig_get_option (GncOption *)
 

QofLogModule identifiers

typedef GList AccountList
 GList of Account.
 
typedef GList LotList
 GList of GNCLots.
 
typedef GList SplitList
 GList of Split.
 
typedef GList TransList
 GList of Transaction.
 
typedef GList AccountGUIDList
 GList of GUIDs of a Account.
 
typedef GList BookGUIDList
 GList of GUIDs of a QofBook.
 
typedef void(* EngineCommitErrorCallback) (gpointer data, QofBackendError errcode)
 
typedef gint(* SplitCallback) (Split *s, gpointer data)
 
typedef gint(* TransactionCallback) (Transaction *t, void *data)
 
typedef void(* gnc_engine_init_hook_t) (int, char **)
 Function type for init hooks in the engine.
 
void gnc_engine_init (int argc, char **argv)
 PROTOTYPES.
 
void gnc_engine_init_static (int argc, char **argv)
 This is the statically linked-in version of gnc_engine_init.
 
void gnc_engine_shutdown (void)
 Called to shutdown the engine.
 
gboolean gnc_engine_is_initialized (void)
 check the engine is fully initialized
 
void gnc_log_default (void)
 enable default log modules
 
void gnc_engine_add_init_hook (gnc_engine_init_hook_t hook)
 Pass a function pointer to gnc_engine_add_init_hook and it will be called during the evaluation of gnc_engine_init.
 
void gnc_engine_add_commit_error_callback (EngineCommitErrorCallback cb, gpointer data)
 Set a callback function to be called in case an engine commit fails.
 
void gnc_engine_signal_commit_error (QofBackendError errcode)
 
#define GNC_MOD_ROOT   "gnc"
 
#define GNC_MOD_ENGINE   "gnc.engine"
 
#define GNC_MOD_ACCOUNT   "gnc.account"
 
#define GNC_MOD_SX   "gnc.engine.sx"
 
#define GNC_MOD_QUERY   "gnc.query"
 
#define GNC_MOD_SCRUB   "gnc.scrub"
 
#define GNC_MOD_LOT   "gnc.lots"
 
#define GNC_MOD_COMMODITY   "gnc.commodity"
 
#define GNC_MOD_BACKEND   "gnc.backend"
 
#define GNC_MOD_PRICE   "gnc.pricedb"
 
#define GNC_MOD_BUSINESS   "gnc.business"
 
#define GNC_MOD_IO   "gnc.io"
 
#define GNC_MOD_BOOK   "gnc.book-period"
 
#define GNC_MOD_GUI   "gnc.gui"
 
#define GNC_MOD_GUI_SX   "gnc.gui.sx"
 
#define GNC_MOD_GUILE   "gnc.guile"
 
#define GNC_MOD_LEDGER   "gnc.ledger"
 
#define GNC_MOD_REGISTER   "gnc.register"
 
#define GNC_MOD_HTML   "gnc.html"
 
#define GNC_MOD_PREFS   "gnc.pref"
 
#define GNC_MOD_IMPORT   "gnc.import"
 
#define GNC_MOD_ASSISTANT   "gnc.assistant"
 
#define GNC_MOD_BUDGET   "gnc.budget"
 
#define GNC_ID_NONE   QOF_ID_NONE
 IDENTIFIERS GncGUID Identifiers can be used to reference Accounts, Transactions, Splits and other objects.
 
#define GNC_ID_BOOK   QOF_ID_BOOK
 
#define GNC_ID_SESSION   QOF_ID_SESSION
 
#define GNC_ID_NULL   QOF_ID_NULL
 
#define GNC_ID_ACCOUNT   "Account"
 
#define GNC_ID_COMMODITY   "Commodity"
 
#define GNC_ID_COMMODITY_NAMESPACE   "CommodityNamespace"
 
#define GNC_ID_COMMODITY_TABLE   "CommodityTable"
 
#define GNC_ID_LOT   "Lot"
 
#define GNC_ID_PERIOD   "Period"
 
#define GNC_ID_PRICE   "Price"
 
#define GNC_ID_PRICEDB   "PriceDB"
 
#define GNC_ID_SPLIT   "Split"
 
#define GNC_ID_BUDGET   "Budget"
 
#define GNC_ID_SCHEDXACTION   "SchedXaction"
 
#define GNC_ID_SXES   "SchedXactions"
 
#define GNC_ID_SXTG   "SXTGroup"
 
#define GNC_ID_SXTT   "SXTTrans"
 
#define GNC_ID_TRANS   "Trans"
 
#define GNC_INVOICE_ID   "gncInvoice"
 STRING CONSTANTS ********************************************** Used to declare constant KVP keys used in more than one class.
 
#define GNC_INVOICE_GUID   "invoice-guid"
 
#define GNC_OWNER_ID   "gncOwner"
 
#define GNC_OWNER_TYPE   "owner-type"
 
#define GNC_OWNER_GUID   "owner-guid"
 
#define GNC_SX_ID   "sched-xaction"
 

Lookup Accounts and Subaccounts by name or code

Accountgnc_account_lookup_by_name (const Account *parent, const char *name)
 The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the specified account.
 
Accountgnc_account_lookup_by_full_name (const Account *any_account, const gchar *name)
 The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.
 
Accountgnc_account_lookup_by_code (const Account *parent, const char *code)
 The gnc_account_lookup_by_code() subroutine works like gnc_account_lookup_by_name, but uses the account code.
 
Accountgnc_account_lookup_by_opening_balance (Account *account, gnc_commodity *commodity)
 Find the opening balance account for the currency.
 
GList * gnc_account_lookup_by_type_and_commodity (Account *root, const char *name, GNCAccountType acctype, gnc_commodity *commodity)
 Find a direct child account matching name, GNCAccountType, and/or commodity.
 

GNCAccountType conversion/checking

const char * xaccAccountTypeEnumAsString (GNCAccountType type)
 Conversion routines for the account types to/from strings that are used in persistent storage, communications.
 
gboolean xaccAccountStringToType (const char *str, GNCAccountType *type)
 Conversion routines for the account types to/from strings that are used in persistent storage, communications.
 
GNCAccountType xaccAccountStringToEnum (const char *str)
 Conversion routines for the account types to/from strings that are used in persistent storage, communications.
 
const char * xaccAccountGetTypeStr (GNCAccountType type)
 The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
 
guint32 xaccAccountTypesCompatibleWith (GNCAccountType type)
 Return the bitmask of account types compatible with a given type.
 
guint32 xaccParentAccountTypesCompatibleWith (GNCAccountType type)
 Return the bitmask of parent account types compatible with a given type.
 
gboolean xaccAccountTypesCompatible (GNCAccountType parent_type, GNCAccountType child_type)
 Return TRUE if accounts of type parent_type can have accounts of type child_type as children.
 
guint32 xaccAccountTypesValid (void)
 Returns the bitmask of the account type enums that are valid.
 
gboolean xaccAccountIsAssetLiabType (GNCAccountType t)
 Convenience function to check if the account is a valid Asset or Liability type, but not a business account type (meaning not an Accounts Payable/Accounts Receivable).
 
GNCAccountType xaccAccountTypeGetFundamental (GNCAccountType t)
 Convenience function to return the fundamental type asset/liability/income/expense/equity given an account type.
 
gboolean xaccAccountIsAPARType (GNCAccountType t)
 Convenience function to check if the account is a valid business account type (meaning an Accounts Payable/Accounts Receivable).
 
gboolean xaccAccountIsEquityType (GNCAccountType t)
 Convenience function to check if the account is a valid Equity type.
 

Account split/transaction list management

SplitListxaccAccountGetSplitList (const Account *account)
 The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account.
 
size_t xaccAccountGetSplitsSize (const Account *account)
 
void xaccAccountMoveAllSplits (Account *accfrom, Account *accto)
 The xaccAccountMoveAllSplits() routine reassigns each of the splits in accfrom to accto.
 
gint xaccAccountForEachTransaction (const Account *account, TransactionCallback proc, void *data)
 The xaccAccountForEachTransaction() routine will traverse all of the transactions in account and call the callback function proc on each transaction.
 
Transaction * xaccAccountFindTransByDesc (const Account *account, const char *description)
 Returns a pointer to the transaction, not a copy.
 
Split * xaccAccountFindSplitByDesc (const Account *account, const char *description)
 Returns a pointer to the split, not a copy.
 
#define xaccAccountInsertSplit(acc, s)   xaccSplitSetAccount((s), (acc))
 The xaccAccountInsertSplit() method will insert the indicated split into the indicated account.
 

Account lots

void xaccAccountInsertLot (Account *, GNCLot *)
 The xaccAccountInsertLot() method will register the indicated lot with this account.
 
void xaccAccountRemoveLot (Account *, GNCLot *)
 
LotListxaccAccountGetLotList (const Account *account)
 The xaccAccountGetLotList() routine returns a list of all lots in this account.
 
gpointer xaccAccountForEachLot (const Account *acc, gpointer(*proc)(GNCLot *lot, gpointer user_data), gpointer user_data)
 The xaccAccountForEachLot() method will apply the function 'proc' to each lot in the account.
 
LotListxaccAccountFindOpenLots (const Account *acc, gboolean(*match_func)(GNCLot *lot, gpointer user_data), gpointer user_data, GCompareFunc sort_func)
 Find a list of open lots that match the match_func.
 

Account Reconciliation information getters/setters

gboolean xaccAccountGetReconcileLastDate (const Account *account, time64 *last_date)
 DOCUMENT ME!
 
void xaccAccountSetReconcileLastDate (Account *account, time64 last_date)
 DOCUMENT ME!
 
gboolean xaccAccountGetReconcileLastInterval (const Account *account, int *months, int *days)
 DOCUMENT ME!
 
void xaccAccountSetReconcileLastInterval (Account *account, int months, int days)
 DOCUMENT ME!
 
gboolean xaccAccountGetReconcilePostponeDate (const Account *account, time64 *postpone_date)
 DOCUMENT ME!
 
void xaccAccountSetReconcilePostponeDate (Account *account, time64 postpone_date)
 DOCUMENT ME!
 
gboolean xaccAccountGetReconcilePostponeBalance (const Account *account, gnc_numeric *balance)
 DOCUMENT ME!
 
void xaccAccountSetReconcilePostponeBalance (Account *account, gnc_numeric balance)
 DOCUMENT ME!
 
void xaccAccountClearReconcilePostpone (Account *account)
 DOCUMENT ME!
 

Account Balance Limits

gboolean xaccAccountGetHigherBalanceLimit (const Account *account, gnc_numeric *balance)
 Get the higher balance limit for the account.
 
void xaccAccountSetHigherBalanceLimit (Account *account, gnc_numeric balance)
 Set the higher balance limit for the account.
 
void xaccAccountClearHigherBalanceLimit (Account *account)
 Clear the higher balance limit for the account.
 
gboolean xaccAccountGetLowerBalanceLimit (const Account *account, gnc_numeric *balance)
 Get the lower balance limit for the account.
 
void xaccAccountSetLowerBalanceLimit (Account *account, gnc_numeric balance)
 Set the lower balance limit for the account.
 
void xaccAccountClearLowerBalanceLimit (Account *account)
 Clear the lower balance limit for the account.
 
gboolean xaccAccountGetIncludeSubAccountBalances (const Account *account)
 Get whether to include balances of sub accounts.
 
void xaccAccountSetIncludeSubAccountBalances (Account *account, gboolean include)
 Set whether to include balances of sub accounts.
 

Account Placeholder flag

gboolean xaccAccountGetPlaceholder (const Account *account)
 Get the "placeholder" flag for an account.
 
void xaccAccountSetPlaceholder (Account *account, gboolean val)
 Set the "placeholder" flag for an account.
 

Account Append Text flag

gboolean xaccAccountGetAppendText (const Account *account)
 Get the "import-append-text" flag for an account.
 
void xaccAccountSetAppendText (Account *account, gboolean val)
 Set the "import-append-text" flag for an account.
 
gboolean xaccAccountGetIsOpeningBalance (const Account *account)
 Get the "opening-balance" flag for an account.
 
void xaccAccountSetIsOpeningBalance (Account *account, gboolean val)
 Set the "opening-balance" flag for an account.
 
GNCPlaceholderType xaccAccountGetDescendantPlaceholder (const Account *account)
 Returns PLACEHOLDER_NONE if account is NULL or neither account nor any descendant of account is a placeholder.
 

Account Hidden flag

gboolean xaccAccountGetHidden (const Account *acc)
 Get the "hidden" flag for an account.
 
void xaccAccountSetHidden (Account *acc, gboolean val)
 Set the "hidden" flag for an account.
 
gboolean xaccAccountIsHidden (const Account *acc)
 Should this account be "hidden".
 

Account Auto Interest flag

gboolean xaccAccountGetAutoInterest (const Account *acc)
 Get the "auto interest" flag for an account.
 
void xaccAccountSetAutoInterest (Account *acc, gboolean val)
 Set the "auto interest" flag for an account.
 

Account Tax related getters/setters

gboolean xaccAccountGetTaxRelated (const Account *account)
 DOCUMENT ME!
 
void xaccAccountSetTaxRelated (Account *account, gboolean tax_related)
 DOCUMENT ME!
 
const char * xaccAccountGetTaxUSCode (const Account *account)
 DOCUMENT ME!
 
void xaccAccountSetTaxUSCode (Account *account, const char *code)
 DOCUMENT ME!
 
const char * xaccAccountGetTaxUSPayerNameSource (const Account *account)
 DOCUMENT ME!
 
void xaccAccountSetTaxUSPayerNameSource (Account *account, const char *source)
 DOCUMENT ME!
 
gint64 xaccAccountGetTaxUSCopyNumber (const Account *account)
 Returns copy_number stored in KVP; if KVP doesn't exist or copy_number is zero, returns 1.
 
void xaccAccountSetTaxUSCopyNumber (Account *account, gint64 copy_number)
 Saves copy_number in KVP if it is greater than 1; if copy_number is zero, deletes KVP.
 

Account type debit/credit string getters

@ { *

const char * gnc_account_get_debit_string (GNCAccountType acct_type)
 Get the debit string associated with this account type.
 
const char * gnc_account_get_credit_string (GNCAccountType acct_type)
 Get the credit string associated with this account type.
 

Account marking

void xaccAccountSetMark (Account *account, short mark)
 Set a mark on the account.
 
void xaccClearMark (Account *account, short val)
 Get the mark set by xaccAccountSetMark short xaccAccountGetMark (const Account *account);.
 
void xaccClearMarkDown (Account *account, short val)
 The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
 

Staged Traversal

The following functions provide support for "staged traversals" over all of the transactions in an account or group.

The idea is to be able to perform a sequence of traversals ("stages"), and perform an operation on each transaction exactly once for that stage.

Only transactions whose current "stage" is less than the stage of the current traversal will be affected, and they will be "brought up" to the current stage when they are processed.

For example, you could perform a stage 1 traversal of all the transactions in an account, and then perform a stage 1 traversal of the transactions in a second account. Presuming the traversal of the first account didn't abort prematurely, any transactions shared by both accounts would be ignored during the traversal of the second account since they had been processed while traversing the first account.

However, if you had traversed the second account using a stage of 2, then all the transactions in the second account would have been processed.

Traversal can be aborted by having the callback function return a non-zero value. The traversal is aborted immediately, and the non-zero value is returned. Note that an aborted traversal can be restarted; no information is lost due to an abort.

The initial impetus for this particular approach came from generalizing a mark/sweep practice that was already being used in FileIO.c.

Note that currently, there is a hard limit of 256 stages, which can be changed by enlarging "marker" in the transaction struct.

void gnc_account_tree_begin_staged_transaction_traversals (Account *acc)
 gnc_account_tree_begin_staged_transaction_traversals() resets the traversal marker inside every transactions of every account in the account tree originating with the specified node.
 
void xaccAccountBeginStagedTransactionTraversals (const Account *account)
 xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which is a parent of one of the splits in the account.
 
gboolean xaccTransactionTraverse (Transaction *trans, int stage)
 xaccTransactionTraverse() checks the stage of the given transaction.
 
int xaccAccountStagedTransactionTraversal (const Account *a, unsigned int stage, TransactionCallback thunk, void *data)
 xaccAccountStagedTransactionTraversal() calls thunk on each transaction in account a whose current marker is less than the given stage and updates each transaction's marker to be stage.
 
int gnc_account_tree_staged_transaction_traversal (const Account *account, unsigned int stage, TransactionCallback thunk, void *data)
 gnc_account_tree_staged_transaction_traversal() calls thunk on each transaction in the group whose current marker is less than the given stage and updates each transaction's marker to be stage.
 
int xaccAccountTreeForEachTransaction (Account *acc, TransactionCallback proc, void *data)
 Traverse all of the transactions in the given account group.
 
time64 gnc_account_get_earliest_date (const Account *account)
 Returns the date of the earliest split in the account, or INT64_MAX.
 
Accountgnc_account_imap_find_account (Account *acc, const char *category, const char *key)
 
Accountgnc_account_imap_find_any (QofBook *book, const char *category, const char *key)
 
void gnc_account_imap_add_account (Account *acc, const char *category, const char *key, Account *added_acc)
 
void gnc_account_imap_delete_account (Account *acc, const char *category, const char *key)
 
Accountgnc_account_imap_find_account_bayes (Account *acc, GList *tokens)
 Look up an Account in the map using Baysian.
 
void gnc_account_imap_add_account_bayes (Account *acc, GList *tokens, Account *added_acc)
 Updates the imap for a given account using a list of tokens.
 
void gnc_account_imap_info_destroy (GncImapInfo *)
 Clean destructor for the imap_info structure of Bayesian mappings.
 
GList * gnc_account_imap_get_info_bayes (Account *acc)
 Returns a GList of structure imap_info of all Bayesian mappings for required Account.
 
GList * gnc_account_imap_get_info (Account *acc, const char *category)
 Returns a GList of structure imap_info of all Non Bayesian mappings for required Account.
 
gchar * gnc_account_get_map_entry (Account *acc, const char *head, const char *category)
 Returns the text string pointed to by head and category for the Account, free the returned text.
 
GncGUIDgnc_account_get_map_guid_entry (Account *acc, const char *head, const char *category)
 Returns the guid pointed to by head and category for the Account, free the returned guid.
 
void gnc_account_delete_map_entry (Account *acc, char *head, char *category, char *match_string, gboolean empty)
 Delete the entry for Account pointed to by head,category and match_string, if empty is TRUE then use delete if empty.
 
void gnc_account_delete_all_bayes_maps (Account *acc)
 Delete all bayes entries for Account.
 
void gnc_account_reset_convert_bayes_to_flat (void)
 Reset the flag that indicates the function imap_convert_bayes_to_flat has been run.
 

Deprecated Routines.

void DxaccAccountSetCurrency (Account *account, gnc_commodity *currency)
 
gnc_commodity * DxaccAccountGetCurrency (const Account *account)
 
void dxaccAccountSetQuoteTZ (Account *account, const char *tz)
 Set the timezone to be used when interpreting the results from a given Finance::Quote backend.
 
const char * dxaccAccountGetQuoteTZ (const Account *account)
 Get the timezone to be used when interpreting the results from a given Finance::Quote backend.
 

Transaction creation and editing

Transaction * xaccMallocTransaction (QofBook *book)
 The xaccMallocTransaction() will malloc memory and initialize it.
 
void xaccTransDestroy (Transaction *trans)
 Destroys a transaction.
 
Transaction * xaccTransClone (const Transaction *t)
 The xaccTransClone() method will create a complete copy of an existing transaction.
 
Transaction * xaccTransCloneNoKvp (const Transaction *t)
 The xaccTransCloneNoKvp() method will create a complete copy of an existing transaction except that the KVP slots will be empty.
 
gboolean xaccTransEqual (const Transaction *ta, const Transaction *tb, gboolean check_guids, gboolean check_splits, gboolean check_balances, gboolean assume_ordered)
 Equality.
 
void xaccTransBeginEdit (Transaction *trans)
 The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of its component splits.
 
void xaccTransCommitEdit (Transaction *trans)
 The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are complete and should be made permanent.
 
void xaccTransRollbackEdit (Transaction *trans)
 The xaccTransRollbackEdit() routine rejects all edits made, and sets the transaction back to where it was before the editing started.
 
gboolean xaccTransIsOpen (const Transaction *trans)
 The xaccTransIsOpen() method returns TRUE if the transaction is open for editing.
 
Transaction * xaccTransLookup (const GncGUID *guid, QofBook *book)
 The xaccTransLookup() subroutine will return the transaction associated with the given id, or NULL if there is no such transaction.
 
Transaction * xaccTransCopyToClipBoard (const Transaction *from_trans)
 Copy a transaction to the 'clipboard' transaction using dupe_transaction.
 
void xaccTransCopyOnto (const Transaction *from_trans, Transaction *to_trans)
 Copy a transaction to another using the function below without changing any account information.
 
void xaccTransCopyFromClipBoard (const Transaction *from_trans, Transaction *to_trans, const Account *from_acc, Account *to_acc, gboolean no_date)
 This function explicitly must robustly handle some unusual input.
 
Split * xaccTransFindSplitByAccount (const Transaction *trans, const Account *acc)
 
void xaccTransScrubGains (Transaction *trans, Account *gain_acc)
 The xaccTransScrubGains() routine performs a number of cleanup functions on the indicated transaction, with the end-goal of setting up a consistent set of gains/losses for all the splits in the transaction.
 
guint gnc_book_count_transactions (QofBook *book)
 
#define xaccTransLookupDirect(g, b)   xaccTransLookup(&(g),b)
 

Transaction general getters/setters

gboolean xaccTransUseTradingAccounts (const Transaction *trans)
 Determine whether this transaction should use commodity trading accounts.
 
void xaccTransSortSplits (Transaction *trans)
 Sorts the splits in a transaction, putting the debits first, followed by the credits.
 
void xaccTransSetTxnType (Transaction *trans, char type)
 Set the Transaction Type: note the type will be saved into the Transaction kvp property as a backward compatibility measure, for previous GnuCash versions whose xaccTransGetTxnType reads from the kvp slots.
 
char xaccTransGetTxnType (Transaction *trans)
 Returns the Transaction Type: note this type will be derived from the transaction splits, returning TXN_TYPE_NONE, TXN_TYPE_INVOICE, TXN_TYPE_LINK, or TXN_TYPE_PAYMENT according to heuristics.
 
void xaccTransSetNum (Transaction *trans, const char *num)
 Sets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_set_num_action' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically

 
void xaccTransSetDescription (Transaction *trans, const char *desc)
 Sets the transaction Description.
 
void xaccTransSetDocLink (Transaction *trans, const char *doclink)
 Sets the transaction Document Link.
 
void xaccTransSetNotes (Transaction *trans, const char *notes)
 Sets the transaction Notes.
 
const char * xaccTransGetNum (const Transaction *trans)
 Gets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_get_num_action' and 'gnc_get_action_num' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically

 
const char * xaccTransGetDescription (const Transaction *trans)
 Gets the transaction Description.
 
const char * xaccTransGetDocLink (const Transaction *trans)
 Gets the transaction Document Link.
 
const char * xaccTransGetNotes (const Transaction *trans)
 Gets the transaction Notes.
 
void xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
 Sets whether or not this transaction is a "closing transaction".
 
gboolean xaccTransGetIsClosingTxn (const Transaction *trans)
 Returns whether this transaction is a "closing transaction".
 
void xaccTransClearSplits (Transaction *trans)
 Remove all splits from the transaction.
 
Split * xaccTransGetSplit (const Transaction *trans, int i)
 Return a pointer to the indexed split in this transaction's split list.
 
int xaccTransGetSplitIndex (const Transaction *trans, const Split *split)
 Inverse of xaccTransGetSplit()
 
SplitListxaccTransGetSplitList (const Transaction *trans)
 The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
 
SplitListxaccTransGetPaymentAcctSplitList (const Transaction *trans)
 The xaccTransGetPaymentAcctSplitList() method returns a GList of the splits in a transaction that belong to an account which is considered a valid account for business payments.
 
SplitListxaccTransGetAPARAcctSplitList (const Transaction *trans, gboolean strict)
 The xaccTransGetAPARSplitList() method returns a GList of the splits in a transaction that belong to an AR or AP account.
 
gboolean xaccTransStillHasSplit (const Transaction *trans, const Split *s)
 
Split * xaccTransGetFirstPaymentAcctSplit (const Transaction *trans)
 The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an account which is considered a valid account for business payments.
 
Split * xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict)
 The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an AR or AP account.
 
void xaccTransSetReadOnly (Transaction *trans, const char *reason)
 Set the transaction to be ReadOnly by setting a non-NULL value as "reason".
 
void xaccTransClearReadOnly (Transaction *trans)
 
const char * xaccTransGetReadOnly (Transaction *trans)
 Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text.
 
gboolean xaccTransIsReadonlyByPostedDate (const Transaction *trans)
 Returns TRUE if this Transaction is read-only because its posted-date is older than the "auto-readonly" threshold of this book.
 
int xaccTransCountSplits (const Transaction *trans)
 Returns the number of splits in this transaction.
 
gboolean xaccTransHasReconciledSplits (const Transaction *trans)
 FIXME: document me.
 
gboolean xaccTransHasReconciledSplitsByAccount (const Transaction *trans, const Account *account)
 FIXME: document me.
 
gboolean xaccTransHasSplitsInState (const Transaction *trans, const char state)
 FIXME: document me.
 
gboolean xaccTransHasSplitsInStateByAccount (const Transaction *trans, const char state, const Account *account)
 FIXME: document me.
 
gnc_commodity * xaccTransGetCurrency (const Transaction *trans)
 Returns the valuation commodity of this transaction.
 
void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr)
 Set the commodity of this transaction.
 
gnc_numeric xaccTransGetImbalanceValue (const Transaction *trans)
 The xaccTransGetImbalanceValue() method returns the total value of the transaction.
 
MonetaryList * xaccTransGetImbalance (const Transaction *trans)
 The xaccTransGetImbalance method returns a list giving the value of the transaction in each currency for which the balance is not zero.
 
gboolean xaccTransIsBalanced (const Transaction *trans)
 Returns true if the transaction is balanced according to the rules currently in effect.
 
gnc_numeric xaccTransGetAccountValue (const Transaction *trans, const Account *account)
 The xaccTransGetAccountValue() method returns the total value applied to a particular account.
 
gnc_numeric xaccTransGetAccountAmount (const Transaction *trans, const Account *account)
 Same as xaccTransGetAccountValue, but uses the Account's commodity.
 
gnc_numeric xaccTransGetAccountConvRate (const Transaction *txn, const Account *acc)
 
gnc_numeric xaccTransGetAccountBalance (const Transaction *trans, const Account *account)
 Get the account balance for the specified account after the last split in the specified transaction.
 
int xaccTransOrder (const Transaction *ta, const Transaction *tb)
 The xaccTransOrder(ta,tb) method is useful for sorting.
 
int xaccTransOrder_num_action (const Transaction *ta, const char *actna, const Transaction *tb, const char *actnb)
 The xaccTransOrder_num_action(ta,actna,tb,actnb) method is useful for sorting.
 
#define xaccTransAppendSplit(t, s)   xaccSplitSetParent((s), (t))
 Add a split to the transaction.
 

Transaction date setters/getters

void xaccTransSetDate (Transaction *trans, int day, int mon, int year)
 The xaccTransSetDate() method does the same thing as xaccTransSetDate[Posted]Secs(), but takes a convenient day-month-year format.
 
void xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
 This method modifies posted date of the transaction, specified by a GDate.
 
void xaccTransSetDatePostedSecs (Transaction *trans, time64 time)
 The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction, specified by a time64 (see ctime(3)).
 
void xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time)
 This function sets the posted date of the transaction, specified by a time64 (see ctime(3)).
 
void xaccTransSetDateEnteredSecs (Transaction *trans, time64 time)
 Modify the date of when the transaction was entered.
 
void xaccTransSetDateDue (Transaction *trans, time64 time)
 Dates and txn-type for A/R and A/P "invoice" postings.
 
time64 xaccTransGetDate (const Transaction *trans)
 Retrieve the posted date of the transaction.
 
time64 xaccTransRetDatePosted (const Transaction *trans)
 Retrieve the posted date of the transaction.
 
GDate xaccTransGetDatePostedGDate (const Transaction *trans)
 Retrieve the posted date of the transaction.
 
time64 xaccTransGetDateEntered (const Transaction *trans)
 Retrieve the date of when the transaction was entered.
 
time64 xaccTransRetDateEntered (const Transaction *trans)
 Retrieve the date of when the transaction was entered.
 
time64 xaccTransRetDateDue (const Transaction *trans)
 Dates and txn-type for A/R and A/P "invoice" postings.
 

Transaction voiding

void xaccTransVoid (Transaction *transaction, const char *reason)
 xaccTransVoid voids a transaction.
 
void xaccTransUnvoid (Transaction *transaction)
 xaccTransUnvoid restores a voided transaction to its original state.
 
Transaction * xaccTransReverse (Transaction *transaction)
 xaccTransReverse creates a Transaction that reverses the given transaction by inverting all the numerical values in the given transaction.
 
Transaction * xaccTransGetReversedBy (const Transaction *trans)
 Returns the transaction that reversed the given transaction.
 
gboolean xaccTransGetVoidStatus (const Transaction *transaction)
 Retrieve information on whether or not a transaction has been voided.
 
const char * xaccTransGetVoidReason (const Transaction *transaction)
 Returns the user supplied textual reason why a transaction was voided.
 
time64 xaccTransGetVoidTime (const Transaction *tr)
 Returns the time that a transaction was voided.
 

Account parameter names

#define ACCOUNT_KVP   "kvp"
 
#define ACCOUNT_NAME_   "name"
 
#define ACCOUNT_CODE_   "code"
 
#define ACCOUNT_DESCRIPTION_   "desc"
 
#define ACCOUNT_COLOR_   "color"
 
#define ACCOUNT_FILTER_   "filter"
 
#define ACCOUNT_SORT_ORDER_   "sort-order"
 
#define ACCOUNT_SORT_REVERSED_   "sort-reversed"
 
#define ACCOUNT_NOTES_   "notes"
 
#define ACCOUNT_BALANCE_   "balance"
 
#define ACCOUNT_NOCLOSING_   "noclosing"
 
#define ACCOUNT_OPENING_BALANCE_   "opening-balance"
 
#define ACCOUNT_CLEARED_   "cleared"
 
#define ACCOUNT_RECONCILED_   "reconciled"
 
#define ACCOUNT_PRESENT_   "present"
 
#define ACCOUNT_FUTURE_MINIMUM_   "future-minimum"
 
#define ACCOUNT_TAX_RELATED   "tax-related-p"
 
#define ACCOUNT_TYPE_   "account-type"
 
#define ACCOUNT_SCU   "smallest-commodity-unit"
 
#define ACCOUNT_NSCU   "non-standard-scu"
 
#define ACCOUNT_PARENT   "parent-account"
 

Transaction Type field values

#define TXN_TYPE_UNCACHED   '?' /** Transaction type not yet cached */
 
#define TXN_TYPE_NONE   '\0'
 No transaction type

 
#define TXN_TYPE_INVOICE   'I'
 Transaction is an invoice.
 
#define TXN_TYPE_PAYMENT   'P'
 Transaction is a payment

 
#define TXN_TYPE_LINK   'L'
 Transaction is a link between (invoice and payment) lots

 

Transaction Parameter names

#define TRANS_KVP   "kvp"
 
#define TRANS_NUM   "num"
 
#define TRANS_DESCRIPTION   "desc"
 
#define TRANS_DATE_ENTERED   "date-entered"
 
#define TRANS_DATE_POSTED   "date-posted"
 
#define TRANS_DATE_DUE   "date-due"
 
#define TRANS_IMBALANCE   "trans-imbalance"
 
#define TRANS_IS_BALANCED   "trans-balanced?"
 
#define TRANS_IS_CLOSING   "trans-is-closing?"
 
#define TRANS_NOTES   "notes"
 
#define TRANS_DOCLINK   "doclink"
 
#define TRANS_TYPE   "type"
 
#define TRANS_VOID_STATUS   "void-p"
 
#define TRANS_VOID_REASON   "void-reason"
 
#define TRANS_VOID_TIME   "void-time"
 
#define TRANS_SPLITLIST   "split-list" /* for guid_match_all */
 

Detailed Description

The GnuCash Engine provides a set of objects and classes that encapsulate typical financial accounting concepts.

The GnuCash GUI is expected to manipulate these objects through the provided engine API.

Macro Definition Documentation

◆ ACCOUNT_BALANCE_

#define ACCOUNT_BALANCE_   "balance"

Definition at line 1737 of file Account.h.

◆ ACCOUNT_CLEARED_

#define ACCOUNT_CLEARED_   "cleared"

Definition at line 1740 of file Account.h.

◆ ACCOUNT_CODE_

#define ACCOUNT_CODE_   "code"

Definition at line 1730 of file Account.h.

◆ ACCOUNT_COLOR_

#define ACCOUNT_COLOR_   "color"

Definition at line 1732 of file Account.h.

◆ ACCOUNT_DESCRIPTION_

#define ACCOUNT_DESCRIPTION_   "desc"

Definition at line 1731 of file Account.h.

◆ ACCOUNT_FILTER_

#define ACCOUNT_FILTER_   "filter"

Definition at line 1733 of file Account.h.

◆ ACCOUNT_FUTURE_MINIMUM_

#define ACCOUNT_FUTURE_MINIMUM_   "future-minimum"

Definition at line 1743 of file Account.h.

◆ ACCOUNT_KVP

#define ACCOUNT_KVP   "kvp"

Definition at line 1728 of file Account.h.

◆ ACCOUNT_MATCH_ALL_TYPE

#define ACCOUNT_MATCH_ALL_TYPE   "account-match-all"

This is the type-override when you want to match all accounts.

Used in the gnome-search parameter list. Be careful when you use this.

Definition at line 1754 of file Account.h.

◆ ACCOUNT_NAME_

#define ACCOUNT_NAME_   "name"

Definition at line 1729 of file Account.h.

◆ ACCOUNT_NOCLOSING_

#define ACCOUNT_NOCLOSING_   "noclosing"

Definition at line 1738 of file Account.h.

◆ ACCOUNT_NOTES_

#define ACCOUNT_NOTES_   "notes"

Definition at line 1736 of file Account.h.

◆ ACCOUNT_NSCU

#define ACCOUNT_NSCU   "non-standard-scu"

Definition at line 1747 of file Account.h.

◆ ACCOUNT_OPENING_BALANCE_

#define ACCOUNT_OPENING_BALANCE_   "opening-balance"

Definition at line 1739 of file Account.h.

◆ ACCOUNT_PARENT

#define ACCOUNT_PARENT   "parent-account"

Definition at line 1748 of file Account.h.

◆ ACCOUNT_PRESENT_

#define ACCOUNT_PRESENT_   "present"

Definition at line 1742 of file Account.h.

◆ ACCOUNT_RECONCILED_

#define ACCOUNT_RECONCILED_   "reconciled"

Definition at line 1741 of file Account.h.

◆ ACCOUNT_SCU

#define ACCOUNT_SCU   "smallest-commodity-unit"

Definition at line 1746 of file Account.h.

◆ ACCOUNT_SORT_ORDER_

#define ACCOUNT_SORT_ORDER_   "sort-order"

Definition at line 1734 of file Account.h.

◆ ACCOUNT_SORT_REVERSED_

#define ACCOUNT_SORT_REVERSED_   "sort-reversed"

Definition at line 1735 of file Account.h.

◆ ACCOUNT_TAX_RELATED

#define ACCOUNT_TAX_RELATED   "tax-related-p"

Definition at line 1744 of file Account.h.

◆ ACCOUNT_TYPE_

#define ACCOUNT_TYPE_   "account-type"

Definition at line 1745 of file Account.h.

◆ GNC_ID_ACCOUNT

#define GNC_ID_ACCOUNT   "Account"

Definition at line 96 of file gnc-engine.h.

◆ GNC_ID_BOOK

#define GNC_ID_BOOK   QOF_ID_BOOK

Definition at line 92 of file gnc-engine.h.

◆ GNC_ID_BUDGET

#define GNC_ID_BUDGET   "Budget"

Definition at line 105 of file gnc-engine.h.

◆ GNC_ID_COMMODITY

#define GNC_ID_COMMODITY   "Commodity"

Definition at line 97 of file gnc-engine.h.

◆ GNC_ID_COMMODITY_NAMESPACE

#define GNC_ID_COMMODITY_NAMESPACE   "CommodityNamespace"

Definition at line 98 of file gnc-engine.h.

◆ GNC_ID_COMMODITY_TABLE

#define GNC_ID_COMMODITY_TABLE   "CommodityTable"

Definition at line 99 of file gnc-engine.h.

◆ GNC_ID_LOT

#define GNC_ID_LOT   "Lot"

Definition at line 100 of file gnc-engine.h.

◆ GNC_ID_NONE

#define GNC_ID_NONE   QOF_ID_NONE

IDENTIFIERS GncGUID Identifiers can be used to reference Accounts, Transactions, Splits and other objects.

These Gnucash types are referred to as Gnucash entities. GncGUID Identifiers are globally-unique and permanent, i.e., once an entity has been assigned an identifier, it retains that same identifier for its lifetime.

  • Identifiers are 'typed' with strings. The ids used in gnucash are defined below. An id with type GNC_ID_NONE does not refer to any entity, although that may change as new ids are created. An id with type GNC_ID_NULL does not refer to any entity, and will never refer to any entity. An identifier with any other type may refer to an actual entity, but that is not guaranteed. If an id does refer to an entity, the type of the entity will match the type of the identifier.

Definition at line 91 of file gnc-engine.h.

◆ GNC_ID_NULL

#define GNC_ID_NULL   QOF_ID_NULL

Definition at line 94 of file gnc-engine.h.

◆ GNC_ID_PERIOD

#define GNC_ID_PERIOD   "Period"

Definition at line 101 of file gnc-engine.h.

◆ GNC_ID_PRICE

#define GNC_ID_PRICE   "Price"

Definition at line 102 of file gnc-engine.h.

◆ GNC_ID_PRICEDB

#define GNC_ID_PRICEDB   "PriceDB"

Definition at line 103 of file gnc-engine.h.

◆ GNC_ID_SCHEDXACTION

#define GNC_ID_SCHEDXACTION   "SchedXaction"

Definition at line 106 of file gnc-engine.h.

◆ GNC_ID_SESSION

#define GNC_ID_SESSION   QOF_ID_SESSION

Definition at line 93 of file gnc-engine.h.

◆ GNC_ID_SPLIT

#define GNC_ID_SPLIT   "Split"

Definition at line 104 of file gnc-engine.h.

◆ GNC_ID_SXES

#define GNC_ID_SXES   "SchedXactions"

Definition at line 107 of file gnc-engine.h.

◆ GNC_ID_SXTG

#define GNC_ID_SXTG   "SXTGroup"

Definition at line 108 of file gnc-engine.h.

◆ GNC_ID_SXTT

#define GNC_ID_SXTT   "SXTTrans"

Definition at line 109 of file gnc-engine.h.

◆ GNC_ID_TRANS

#define GNC_ID_TRANS   "Trans"

Definition at line 110 of file gnc-engine.h.

◆ GNC_INVOICE_GUID

#define GNC_INVOICE_GUID   "invoice-guid"

Definition at line 258 of file gnc-engine.h.

◆ GNC_INVOICE_ID

#define GNC_INVOICE_ID   "gncInvoice"

STRING CONSTANTS ********************************************** Used to declare constant KVP keys used in more than one class.

Definition at line 257 of file gnc-engine.h.

◆ GNC_IS_TRANS

#define GNC_IS_TRANS (   obj)    GNC_IS_TRANSACTION(obj)

Definition at line 118 of file Transaction.h.

◆ GNC_IS_TRANSACTION

#define GNC_IS_TRANSACTION (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TRANSACTION))

Definition at line 108 of file Transaction.h.

◆ GNC_IS_TRANSACTION_CLASS

#define GNC_IS_TRANSACTION_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TRANSACTION))

Definition at line 110 of file Transaction.h.

◆ GNC_MOD_ACCOUNT

#define GNC_MOD_ACCOUNT   "gnc.account"

Definition at line 51 of file gnc-engine.h.

◆ GNC_MOD_ASSISTANT

#define GNC_MOD_ASSISTANT   "gnc.assistant"

Definition at line 70 of file gnc-engine.h.

◆ GNC_MOD_BACKEND

#define GNC_MOD_BACKEND   "gnc.backend"

Definition at line 57 of file gnc-engine.h.

◆ GNC_MOD_BOOK

#define GNC_MOD_BOOK   "gnc.book-period"

Definition at line 61 of file gnc-engine.h.

◆ GNC_MOD_BUDGET

#define GNC_MOD_BUDGET   "gnc.budget"

Definition at line 71 of file gnc-engine.h.

◆ GNC_MOD_BUSINESS

#define GNC_MOD_BUSINESS   "gnc.business"

Definition at line 59 of file gnc-engine.h.

◆ GNC_MOD_COMMODITY

#define GNC_MOD_COMMODITY   "gnc.commodity"

Definition at line 56 of file gnc-engine.h.

◆ GNC_MOD_ENGINE

#define GNC_MOD_ENGINE   "gnc.engine"

Definition at line 50 of file gnc-engine.h.

◆ GNC_MOD_GUI

#define GNC_MOD_GUI   "gnc.gui"

Definition at line 62 of file gnc-engine.h.

◆ GNC_MOD_GUI_SX

#define GNC_MOD_GUI_SX   "gnc.gui.sx"

Definition at line 63 of file gnc-engine.h.

◆ GNC_MOD_GUILE

#define GNC_MOD_GUILE   "gnc.guile"

Definition at line 64 of file gnc-engine.h.

◆ GNC_MOD_HTML

#define GNC_MOD_HTML   "gnc.html"

Definition at line 67 of file gnc-engine.h.

◆ GNC_MOD_IMPORT

#define GNC_MOD_IMPORT   "gnc.import"

Definition at line 69 of file gnc-engine.h.

◆ GNC_MOD_IO

#define GNC_MOD_IO   "gnc.io"

Definition at line 60 of file gnc-engine.h.

◆ GNC_MOD_LEDGER

#define GNC_MOD_LEDGER   "gnc.ledger"

Definition at line 65 of file gnc-engine.h.

◆ GNC_MOD_LOT

#define GNC_MOD_LOT   "gnc.lots"

Definition at line 55 of file gnc-engine.h.

◆ GNC_MOD_PREFS

#define GNC_MOD_PREFS   "gnc.pref"

Definition at line 68 of file gnc-engine.h.

◆ GNC_MOD_PRICE

#define GNC_MOD_PRICE   "gnc.pricedb"

Definition at line 58 of file gnc-engine.h.

◆ GNC_MOD_QUERY

#define GNC_MOD_QUERY   "gnc.query"

Definition at line 53 of file gnc-engine.h.

◆ GNC_MOD_REGISTER

#define GNC_MOD_REGISTER   "gnc.register"

Definition at line 66 of file gnc-engine.h.

◆ GNC_MOD_ROOT

#define GNC_MOD_ROOT   "gnc"

Definition at line 49 of file gnc-engine.h.

◆ GNC_MOD_SCRUB

#define GNC_MOD_SCRUB   "gnc.scrub"

Definition at line 54 of file gnc-engine.h.

◆ GNC_MOD_SX

#define GNC_MOD_SX   "gnc.engine.sx"

Definition at line 52 of file gnc-engine.h.

◆ GNC_OWNER_GUID

#define GNC_OWNER_GUID   "owner-guid"

Definition at line 261 of file gnc-engine.h.

◆ GNC_OWNER_ID

#define GNC_OWNER_ID   "gncOwner"

Definition at line 259 of file gnc-engine.h.

◆ GNC_OWNER_TYPE

#define GNC_OWNER_TYPE   "owner-type"

Definition at line 260 of file gnc-engine.h.

◆ GNC_SX_ID

#define GNC_SX_ID   "sched-xaction"

Definition at line 262 of file gnc-engine.h.

◆ GNC_TRANS

#define GNC_TRANS (   obj)    GNC_TRANSACTION(obj)

Definition at line 119 of file Transaction.h.

◆ GNC_TRANSACTION

#define GNC_TRANSACTION (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, Transaction))

Definition at line 104 of file Transaction.h.

◆ GNC_TRANSACTION_CLASS

#define GNC_TRANSACTION_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, TransactionClass))

Definition at line 106 of file Transaction.h.

◆ GNC_TRANSACTION_GET_CLASS

#define GNC_TRANSACTION_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TRANSACTION, TransactionClass))

Definition at line 112 of file Transaction.h.

◆ GNC_TYPE_TRANSACTION

#define GNC_TYPE_TRANSACTION   (gnc_transaction_get_type ())

Definition at line 103 of file Transaction.h.

◆ RECONCILED_MATCH_TYPE

#define RECONCILED_MATCH_TYPE   "reconciled-match"

Definition at line 782 of file Transaction.h.

◆ TRANS_DATE_DUE

#define TRANS_DATE_DUE   "date-due"

Definition at line 756 of file Transaction.h.

◆ TRANS_DATE_ENTERED

#define TRANS_DATE_ENTERED   "date-entered"

Definition at line 754 of file Transaction.h.

◆ TRANS_DATE_POSTED

#define TRANS_DATE_POSTED   "date-posted"

Definition at line 755 of file Transaction.h.

◆ TRANS_DESCRIPTION

#define TRANS_DESCRIPTION   "desc"

Definition at line 753 of file Transaction.h.

◆ TRANS_DOCLINK

#define TRANS_DOCLINK   "doclink"

Definition at line 761 of file Transaction.h.

◆ TRANS_IMBALANCE

#define TRANS_IMBALANCE   "trans-imbalance"

Definition at line 757 of file Transaction.h.

◆ TRANS_IS_BALANCED

#define TRANS_IS_BALANCED   "trans-balanced?"

Definition at line 758 of file Transaction.h.

◆ TRANS_IS_CLOSING

#define TRANS_IS_CLOSING   "trans-is-closing?"

Definition at line 759 of file Transaction.h.

◆ TRANS_KVP

#define TRANS_KVP   "kvp"

Definition at line 751 of file Transaction.h.

◆ TRANS_NOTES

#define TRANS_NOTES   "notes"

Definition at line 760 of file Transaction.h.

◆ TRANS_NUM

#define TRANS_NUM   "num"

Definition at line 752 of file Transaction.h.

◆ TRANS_SPLITLIST

#define TRANS_SPLITLIST   "split-list" /* for guid_match_all */

Definition at line 766 of file Transaction.h.

◆ TRANS_TYPE

#define TRANS_TYPE   "type"

Definition at line 762 of file Transaction.h.

◆ TRANS_VOID_REASON

#define TRANS_VOID_REASON   "void-reason"

Definition at line 764 of file Transaction.h.

◆ TRANS_VOID_STATUS

#define TRANS_VOID_STATUS   "void-p"

Definition at line 763 of file Transaction.h.

◆ TRANS_VOID_TIME

#define TRANS_VOID_TIME   "void-time"

Definition at line 765 of file Transaction.h.

◆ TXN_TYPE_INVOICE

#define TXN_TYPE_INVOICE   'I'

Transaction is an invoice.

Definition at line 126 of file Transaction.h.

◆ TXN_TYPE_LINK

#define TXN_TYPE_LINK   'L'

Transaction is a link between (invoice and payment) lots

Definition at line 128 of file Transaction.h.

◆ TXN_TYPE_NONE

#define TXN_TYPE_NONE   '\0'

No transaction type

Definition at line 125 of file Transaction.h.

◆ TXN_TYPE_PAYMENT

#define TXN_TYPE_PAYMENT   'P'

Transaction is a payment

Definition at line 127 of file Transaction.h.

◆ TXN_TYPE_UNCACHED

#define TXN_TYPE_UNCACHED   '?' /** Transaction type not yet cached */

Definition at line 124 of file Transaction.h.

◆ xaccAccountInsertSplit

#define xaccAccountInsertSplit (   acc,
 
)    xaccSplitSetAccount((s), (acc))

The xaccAccountInsertSplit() method will insert the indicated split into the indicated account.

If the split already belongs to another account, it will be removed from that account first.

Definition at line 1069 of file Account.h.

◆ xaccTransAppendSplit

#define xaccTransAppendSplit (   t,
 
)    xaccSplitSetParent((s), (t))

Add a split to the transaction.

The xaccTransAppendSplit() method will append the indicated split to the collection of splits in this transaction.

Note
If the split is already a part of another transaction, it will be removed from that transaction first.

Definition at line 380 of file Transaction.h.

◆ xaccTransGetBook

#define xaccTransGetBook (   X)    qof_instance_get_book (QOF_INSTANCE(X))
Deprecated:

Definition at line 785 of file Transaction.h.

◆ xaccTransGetGUID

#define xaccTransGetGUID (   X)    qof_entity_get_guid(QOF_INSTANCE(X))
Deprecated:

Definition at line 787 of file Transaction.h.

◆ xaccTransLookupDirect

#define xaccTransLookupDirect (   g,
 
)    xaccTransLookup(&(g),b)

Definition at line 233 of file Transaction.h.

Typedef Documentation

◆ AccountGUIDList

typedef GList AccountGUIDList

GList of GUIDs of a Account.

Definition at line 211 of file gnc-engine.h.

◆ AccountList

typedef GList AccountList

GList of Account.

Definition at line 203 of file gnc-engine.h.

◆ BookGUIDList

typedef GList BookGUIDList

GList of GUIDs of a QofBook.

Definition at line 213 of file gnc-engine.h.

◆ EngineCommitErrorCallback

typedef void(* EngineCommitErrorCallback) (gpointer data, QofBackendError errcode)

Definition at line 215 of file gnc-engine.h.

◆ gnc_engine_init_hook_t

typedef void(* gnc_engine_init_hook_t) (int, char **)

Function type for init hooks in the engine.


Definition at line 221 of file gnc-engine.h.

◆ LotList

typedef GList LotList

GList of GNCLots.

Definition at line 205 of file gnc-engine.h.

◆ SplitCallback

typedef gint(* SplitCallback) (Split *s, gpointer data)

Definition at line 217 of file gnc-engine.h.

◆ SplitList

typedef GList SplitList

GList of Split.

Definition at line 207 of file gnc-engine.h.

◆ TransactionCallback

typedef gint(* TransactionCallback) (Transaction *t, void *data)

Definition at line 218 of file gnc-engine.h.

◆ TransList

typedef GList TransList

GList of Transaction.

Definition at line 209 of file gnc-engine.h.

Enumeration Type Documentation

◆ GNCPlaceholderType

DOCUMENT ME!

Definition at line 1282 of file Account.h.

1283 {
1284 PLACEHOLDER_NONE,
1285 PLACEHOLDER_THIS,
1286 PLACEHOLDER_CHILD,
GNCPlaceholderType
DOCUMENT ME!
Definition Account.h:1283

Function Documentation

◆ account_type_list() [1/3]

GList * GncOptionAccountListValue::account_type_list ( ) const
noexcept

Create a GList of account types to pass to gnc_account_sel_set_acct_filters.

gnc_account_sel_set_acct_filters copies the list so the intermediary caller is responsible for freeing the list.

Returns
an allocated GList* or nullptr if the list is empty.

Definition at line 462 of file gnc-option-impl.cpp.

463{
464 if (m_allowed.empty())
465 return nullptr;
466 GList* retval{nullptr};
467 for (auto type : m_allowed)
468 retval = g_list_prepend(retval, GINT_TO_POINTER(type));
469 return g_list_reverse(retval);
470}

◆ account_type_list() [2/3]

GList * GncOptionAccountSelValue::account_type_list ( ) const
noexcept

Create a GList of account types to pass to gnc_account_sel_set_acct_filters.

gnc_account_sel_set_acct_filters copies the list so the intermediary caller is responsible for freeing the list.

Returns
an allocated GList* or nullptr if the list is empty.

Definition at line 533 of file gnc-option-impl.cpp.

534{
535 if (m_allowed.empty())
536 return nullptr;
537 GList* retval{nullptr};
538 for (auto type : m_allowed)
539 retval = g_list_prepend(retval, GINT_TO_POINTER(type));
540 return g_list_reverse(retval);
541}

◆ account_type_list() [3/3]

GList * GncOption::account_type_list ( ) const
noexcept

Implemented only for GncOptionAccountListValue.

Definition at line 414 of file gnc-option.cpp.

415{
416 return std::visit([] (const auto& option) -> GList* {
417 if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
419 return option.account_type_list();
420 else
421 return nullptr;
422 }, *m_option);
423}
Set one or more accounts on which to report, optionally restricted to certain account types.

◆ add_option()

void GncOptionSection::add_option ( GncOption &&  option)

Definition at line 143 of file gnc-optiondb.cpp.

144{
145 m_options.push_back(std::move(option));
146 if (!std::is_sorted(m_options.begin(), m_options.end()))
147 std::sort(m_options.begin(), m_options.end());
148}

◆ commit()

void GncOptionDB::commit ( )
inline

Definition at line 158 of file gnc-optiondb-impl.hpp.

158{};

◆ deserialize() [1/10]

bool GncOption::deserialize ( const std::string &  str)

Set the option's value from a character sequence.

Parameters
strThe character sequence representing the value
Returns
true if the value was set, false otherwise.

Definition at line 455 of file gnc-option.cpp.

456{
457 return std::visit([&str](auto& option) -> bool {
458 return option.deserialize(str);
459 }, *m_option);
460}

◆ deserialize() [2/10]

template<typename ValueType >
template bool GncOptionValue< ValueType >::deserialize ( const std::string &  str)
noexcept

Definition at line 795 of file gnc-option-impl.cpp.

796{
797 if constexpr(std::is_same_v<ValueType, const QofInstance*>)
798 set_value(qof_instance_from_string(str, get_ui_type()));
799 if constexpr(std::is_same_v<ValueType, const GncOwner*>)
800 {
801 std::istringstream istr{str};
802 std::string type, guid;
803 istr >> type >> guid;
804 auto inst{qof_instance_from_string(guid, get_ui_type())};
805 qofOwnerSetEntity(const_cast<GncOwner*>(m_value), inst);
806 }
807 if constexpr(std::is_same_v<ValueType, GncOptionReportPlacementVec>)
808 {
809 std::istringstream istr{str};
810 GncOptionReportPlacementVec rpv;
811 while (istr)
812 {
813 uint32_t id, wide, high;
814 istr >> id >> wide >> high;
815 rpv.emplace_back(id, wide, high);
816 }
817 set_value(rpv);
818 }
819 else if constexpr(is_same_decayed_v<ValueType, std::string>)
820 set_value(str);
821 else if constexpr(is_same_decayed_v<ValueType, bool>)
822 set_value(str == "True");
823 else if constexpr(is_same_decayed_v<ValueType, int>)
824 set_value(stoi(str));
825 else if constexpr(is_same_decayed_v<ValueType, int64_t>)
826 set_value(stoll(str));
827 else if constexpr(is_same_decayed_v<ValueType, double>)
828 set_value(stod(str));
829 else
830 return false;
831 return true;
832}
void qofOwnerSetEntity(GncOwner *owner, QofInstance *ent)
set the owner from the entity.
Definition gncOwner.c:319

◆ deserialize() [3/10]

bool GncOptionGncOwnerValue::deserialize ( const std::string &  str)
noexcept

Definition at line 118 of file gnc-option-impl.cpp.

119{
120 try {
121 auto guid{static_cast<GncGUID>(gnc::GUID::from_string(str))};
122 auto inst = qof_instance_from_guid(&guid, m_ui_type);
123 if (inst)
124 {
125 GncOwner owner{};
126 owner.type = ui_type_to_owner_type(m_ui_type);
127 owner.owner.undefined = inst;
128 set_default_value(&owner);
129 return true;
130 }
131 }
132 catch (const gnc::guid_syntax_exception& err)
133 {
134 PWARN("Failed to convert %s to a GUID", str.c_str());
135 }
136 return false;
137}
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
The type used to store guids in C.
Definition guid.h:75

◆ deserialize() [4/10]

bool GncOptionQofInstanceValue::deserialize ( const std::string &  str)
noexcept

Definition at line 238 of file gnc-option-impl.cpp.

239{
240 QofInstance* inst{};
241 // Commodities are often serialized as Namespace::Mnemonic or just Mnemonic
242 try {
243 auto guid{static_cast<GncGUID>(gnc::GUID::from_string(str))};
244 inst = qof_instance_from_guid(&guid, m_ui_type);
245 if (inst)
246 {
247 m_value = make_gnc_item(inst);
248 return true;
249 }
250 }
251 catch (const gnc::guid_syntax_exception& err)
252 {
253 PWARN("Failed to convert %s to a GUID", str.c_str());
254 }
255 return false;
256}

◆ deserialize() [5/10]

bool GncOptionCommodityValue::deserialize ( const std::string &  str)
noexcept

Definition at line 361 of file gnc-option-impl.cpp.

362{
363 auto sep{str.find(":")};
364 gnc_commodity* comm{};
365 std::string mnemonic, name_space;
366 if (sep != std::string::npos)
367 {
368 name_space = str.substr(0, sep);
369 mnemonic = str.substr(sep + 1, -1);
370 }
371 else
372 {
373 name_space = "CURRENCY";
374 mnemonic = str;
375 }
376 comm = gnc_commodity_from_namespace_and_mnemonic(name_space, mnemonic);
377 if (!validate(comm))
378 return false;
379 m_namespace = std::move(name_space);
380 m_mnemonic = std::move(mnemonic);
381 return true;
382}

◆ deserialize() [6/10]

template<typename ValueType >
template bool GncOptionRangeValue< ValueType >::deserialize ( const std::string &  str)
noexcept

Definition at line 957 of file gnc-option-impl.cpp.

958{
959 if constexpr(is_same_decayed_v<ValueType, int>)
960 set_value(stoi(str));
961 else if constexpr(is_same_decayed_v<ValueType, double>)
962 set_value(stod(str));
963 return true;
964}

◆ deserialize() [7/10]

bool GncOptionMultichoiceValue::deserialize ( const std::string &  str)
noexcept

Definition at line 920 of file gnc-option-impl.cpp.

921{
922 static const auto uint16_t_max = std::numeric_limits<uint16_t>::max();
923 if (str.empty())
924
925 return false;
926 uint16_t pos{};
927 while (pos < str.size())
928 {
929 auto endpos{str.find(' ', pos)};
930 if (endpos == std::string::npos)
931 endpos = str.size();
932 //need a null-terminated char* to pass to permissible_value_index
933 auto index{permissible_value_index(str.substr(pos, endpos).c_str())};
934 if (index == uint16_t_max)
935 return false;
936 m_value.push_back(index);
937 pos = endpos + 1;
938 }
939 return true;
940}

◆ deserialize() [8/10]

bool GncOptionAccountListValue::deserialize ( const std::string &  str)
noexcept

Definition at line 855 of file gnc-option-impl.cpp.

856{
857 if (str.empty() || str.size() < GUID_ENCODING_LENGTH)
858 return false;
859 m_value.clear();
860 m_value.reserve(str.size() / GUID_ENCODING_LENGTH);
861 bool first = true;
862 size_t pos{};
863 while (pos + GUID_ENCODING_LENGTH < str.size())
864 {
865 if (!first)
866 ++pos;
867 first = false;
868 GncGUID guid{};
869 string_to_guid(str.substr(pos, pos + GUID_ENCODING_LENGTH).c_str(), &guid);
870 m_value.push_back(guid);
872 }
873 return true;
874}
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition guid.h:84

◆ deserialize() [9/10]

bool GncOptionAccountSelValue::deserialize ( const std::string &  str)
noexcept

Definition at line 889 of file gnc-option-impl.cpp.

890{
891 set_value(reinterpret_cast<Account*>(qof_instance_from_string(str, get_ui_type())));
892 return true;
893}
STRUCTS.

◆ deserialize() [10/10]

bool GncOptionDateValue::deserialize ( const std::string &  str)
noexcept

Definition at line 987 of file gnc-option-impl.cpp.

988{
989 //The length of both "absolute" and "relative".
990 static constexpr size_t date_type_len{9};
991 // date_type_len plus the length of " . ".
992 static constexpr size_t date_value_pos{12};
993 auto type_str{str.substr(0, date_type_len)};
994 auto period_str{str.substr(date_value_pos)};
995 if (type_str == "absolute")
996 {
997 // Need a cast to disambiguate from time64.
998 set_value(static_cast<uint16_t>(std::stoll(period_str)));
999 return true;
1000 }
1001 else if (type_str == "relative ")
1002 {
1003 auto period = gnc_relative_date_from_storage_string(period_str.c_str());
1004 if (period == RelativeDatePeriod::ABSOLUTE)
1005 {
1006 PWARN("Unknown period string in date option: '%s'",
1007 period_str.c_str());
1008 return false;
1009 }
1010
1011 set_value(period);
1012 return true;
1013 }
1014 else
1015 {
1016 PWARN("Unknown date type string in date option: '%s'",
1017 type_str.c_str());
1018 return false;
1019 }
1020}
RelativeDatePeriod gnc_relative_date_from_storage_string(const char *str)
Convert a relative date storage string back to a RelativeDatePeriod value.

◆ DxaccAccountGetCurrency()

gnc_commodity * DxaccAccountGetCurrency ( const Account account)
Deprecated:
The current API associates only one thing with an account: the 'commodity'. Use xaccAccountGetCommodity() to fetch it.

Definition at line 3396 of file Account.cpp.

3397{
3398 if (auto s = get_kvp_string_path (acc, {"old-currency"}))
3399 {
3401 return gnc_commodity_table_lookup_unique (table, s);
3402 }
3403
3404 return nullptr;
3405}
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.

◆ dxaccAccountGetQuoteTZ()

const char * dxaccAccountGetQuoteTZ ( const Account account)

Get the timezone to be used when interpreting the results from a given Finance::Quote backend.

Unfortunately, the upstream sources don't label their output, so the user has to specify this bit. This function uses a static char*.

Deprecated:
Price quote information is now stored on the commodity, not the account.

Definition at line 4871 of file Account.cpp.

4872{
4873 if (!acc) return nullptr;
4874 if (!xaccAccountIsPriced(acc)) return nullptr;
4875 return get_kvp_string_path (acc, {"old-quote-tz"});
4876}
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false.
Definition Account.cpp:4551

◆ DxaccAccountSetCurrency()

void DxaccAccountSetCurrency ( Account account,
gnc_commodity *  currency 
)
Deprecated:
The current API associates only one thing with an account: the 'commodity'. Use xaccAccountGetCommodity() to fetch it.

These two funcs take control of their gnc_commodity args. Don't free

Definition at line 2785 of file Account.cpp.

2786{
2787 if ((!acc) || (!currency)) return;
2788
2789 auto s = gnc_commodity_get_unique_name (currency);
2790 set_kvp_string_path (acc, {"old-currency"}, s);
2791
2792 auto book = qof_instance_get_book(acc);
2794 auto commodity = gnc_commodity_table_lookup_unique (table, s);
2795
2796 if (!commodity)
2798}
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
Add a new commodity to the commodity table.
const char * gnc_commodity_get_unique_name(const gnc_commodity *cm)
Retrieve the 'unique' name for the specified commodity.

◆ dxaccAccountSetQuoteTZ()

void dxaccAccountSetQuoteTZ ( Account account,
const char *  tz 
)

Set the timezone to be used when interpreting the results from a given Finance::Quote backend.

Unfortunately, the upstream sources don't label their output, so the user has to specify this bit.

Deprecated:
Price quote information is now stored on the commodity, not the account.

Definition at line 4860 of file Account.cpp.

4861{
4862 if (!acc) return;
4863 if (!xaccAccountIsPriced(acc)) return;
4864 set_kvp_string_path (acc, {"old-quote-tz"}, tz);
4865}

◆ find_option() [1/3]

const GncOption * GncOptionSection::find_option ( const char *  name) const

Definition at line 161 of file gnc-optiondb.cpp.

162{
163 auto option = std::find_if(m_options.begin(), m_options.end(),
164 [name](auto& option) -> bool {
165 return option.get_name() == name;
166 });
167 if (option != m_options.end())
168 return &*option;
169
170 auto alias = Aliases::find_alias(name);
171 if (!alias || alias->first) // No alias or the alias
172 return nullptr; // is in a different section.
173 return find_option(alias->second);
174}

◆ find_option() [2/3]

GncOption * GncOptionDB::find_option ( const std::string &  section,
const char *  name 
)
inline

Definition at line 164 of file gnc-optiondb-impl.hpp.

165 {
166 return const_cast<GncOption*>(static_cast<const GncOptionDB&>(*this).find_option(section, name));
167 }
Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections.
Represents the public interface for an option.

◆ find_option() [3/3]

const GncOption * GncOptionDB::find_option ( const std::string &  section,
const char *  name 
) const

Definition at line 236 of file gnc-optiondb.cpp.

237{
238 auto db_section = const_cast<GncOptionDB*>(this)->find_section(section);
239 const GncOption* option = nullptr;
240 if (db_section)
241 option = db_section->find_option(name);
242 if (option)
243 return option;
244 auto alias = Aliases::find_alias(name);
245 /* Only try again if alias.first isn't
246 * nullptr. GncOptionSection::find_option already checked if the alias
247 * should have been in the same section.
248 */
249 if (alias && alias->first && section != alias->first)
250 return find_option(alias->first, alias->second);
251 return nullptr;
252}

◆ find_section() [1/2]

GncOptionSection * GncOptionDB::find_section ( const std::string &  sectname)
inline

Definition at line 159 of file gnc-optiondb-impl.hpp.

160 {
161 return const_cast<GncOptionSection*>(static_cast<const GncOptionDB&>(*this).find_section(sectname));
162 }
class GncOptionSection The upper-level classification implementation.

◆ find_section() [2/2]

const GncOptionSection * GncOptionDB::find_section ( const std::string &  sectname) const

Definition at line 225 of file gnc-optiondb.cpp.

226{
227 auto db_section = std::find_if(m_sections.begin(), m_sections.end(),
228 [&section](auto& sect) -> bool
229 {
230 return section == sect->get_name();
231 });
232 return db_section == m_sections.end() ? nullptr : db_section->get();
233}

◆ foreach_option() [1/2]

void GncOptionSection::foreach_option ( std::function< void(const GncOption &)>  func) const

Definition at line 137 of file gnc-optiondb.cpp.

138{
139 std::for_each(m_options.begin(), m_options.end(), func);
140}

◆ foreach_option() [2/2]

void GncOptionSection::foreach_option ( std::function< void(GncOption &)>  func)

Definition at line 131 of file gnc-optiondb.cpp.

132{
133 std::for_each(m_options.begin(), m_options.end(), func);
134}

◆ foreach_section() [1/2]

void GncOptionDB::foreach_section ( std::function< void(const GncOptionSectionPtr &)>  func) const
inline

Definition at line 122 of file gnc-optiondb-impl.hpp.

123 {
124 for (auto& section : m_sections)
125 func(section);
126 }

◆ foreach_section() [2/2]

void GncOptionDB::foreach_section ( std::function< void(GncOptionSectionPtr &)>  func)
inline

Definition at line 117 of file gnc-optiondb-impl.hpp.

118 {
119 for (auto& section : m_sections)
120 func(section);
121 }

◆ get_changed()

bool GncOptionDB::get_changed ( ) const
inlinenoexcept

Definition at line 128 of file gnc-optiondb-impl.hpp.

128{ return m_dirty; }

◆ get_default_item()

GncItem GncOptionQofInstanceValue::get_default_item ( ) const
inline

Definition at line 188 of file gnc-option-impl.hpp.

188{ return m_default_value; }

◆ get_default_multiple()

const GncMultichoiceOptionIndexVec & GncOptionMultichoiceValue::get_default_multiple ( ) const
inlinenoexcept

Definition at line 614 of file gnc-option-impl.hpp.

615 {
616 return m_default_value;
617 }

◆ get_default_period()

RelativeDatePeriod GncOptionDateValue::get_default_period ( ) const
inlinenoexcept

Definition at line 1088 of file gnc-option-impl.hpp.

1088{ return m_default_period; }

◆ get_default_period_index()

uint16_t GncOptionDateValue::get_default_period_index ( ) const
noexcept

Definition at line 583 of file gnc-option-impl.cpp.

584{
585 assert(m_period != RelativeDatePeriod::ABSOLUTE);
586 assert(!m_period_set.empty());
587 auto item{std::find(m_period_set.begin(), m_period_set.end(),
588 m_default_period)};
589 assert (item != m_period_set.end());
590 return item - m_period_set.begin();
591}

◆ get_default_section()

const GncOptionSection *const GncOptionDB::get_default_section ( ) const
noexcept

Definition at line 219 of file gnc-optiondb.cpp.

220{
221 return m_default_section;
222}

◆ get_default_value() [1/10]

template<typename ValueType >
ValueType GncOptionValue< ValueType >::get_default_value ( ) const
inline

Definition at line 102 of file gnc-option-impl.hpp.

102{ return m_default_value; }

◆ get_default_value() [2/10]

const GncOwner * GncOptionGncOwnerValue::get_default_value ( ) const

Definition at line 100 of file gnc-option-impl.cpp.

101{
102 return m_default_value.get();
103}

◆ get_default_value() [3/10]

const QofInstance * GncOptionQofInstanceValue::get_default_value ( ) const

Definition at line 220 of file gnc-option-impl.cpp.

221{
222 return qof_instance_from_gnc_item(m_default_value);
223}

◆ get_default_value() [4/10]

gnc_commodity * GncOptionCommodityValue::get_default_value ( ) const

Definition at line 303 of file gnc-option-impl.cpp.

304{
305 return gnc_commodity_from_namespace_and_mnemonic(m_default_namespace,
306 m_default_mnemonic);
307}

◆ get_default_value() [5/10]

template<typename ValueType >
ValueType GncOptionRangeValue< ValueType >::get_default_value ( ) const
inline

Definition at line 421 of file gnc-option-impl.hpp.

421{ return m_default_value; }

◆ get_default_value() [6/10]

const std::string & GncOptionMultichoiceValue::get_default_value ( ) const
inline

Definition at line 592 of file gnc-option-impl.hpp.

593 {
594 if (m_default_value.size() == 1)
595 return std::get<0>(m_choices.at(m_default_value[0]));
596 else if (m_default_value.size() == 0)
597 return c_empty_string;
598 else
599 return c_list_string;
600 }

◆ get_default_value() [7/10]

GncOptionAccountList GncOptionAccountListValue::get_default_value ( ) const

Definition at line 416 of file gnc-option-impl.cpp.

417{
418 if (!m_default_value.empty())
419 return m_default_value;
420
421 /* If no default has been set and there's an allowed set then find the first
422 * account that matches one of the allowed account types.
423 */
424 GncOptionAccountList retval{};
425 if (m_allowed.empty())
426 return retval;
427
428 auto root{get_current_root_account()};
429 auto account_list{gnc_account_get_descendants_sorted(root)};
430 if (!account_list)
431 return retval;
432
433 for (auto node = account_list; node; node = g_list_next (node))
434 {
435 if (std::find(m_allowed.begin(), m_allowed.end(),
436 xaccAccountGetType(GNC_ACCOUNT(node->data))) != m_allowed.end())
437 {
438 retval.push_back(*qof_entity_get_guid(GNC_ACCOUNT(node->data)));
439 break;
440 }
441 }
442 g_list_free(account_list);
443 return retval;
444}
GList * gnc_account_get_descendants_sorted(const Account *account)
This function returns a GList containing all the descendants of the specified account,...
Definition Account.cpp:3052
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition Account.cpp:3267
const GncGUID * qof_entity_get_guid(gconstpointer ent)

◆ get_default_value() [8/10]

const Account * GncOptionAccountSelValue::get_default_value ( ) const

Definition at line 492 of file gnc-option-impl.cpp.

493{
494
495 if (!guid_equal(guid_null(), &m_default_value))
496 {
497 auto book{get_current_book()};
498 return xaccAccountLookup(&m_default_value, book);
499 }
500
501 /* If no default has been set and there's an allowed set then find the first
502 * account that matches one of the allowed account types.
503 */
504 if (m_allowed.empty())
505 return nullptr;
506
507 const Account* retval{nullptr};
508 auto root{get_current_root_account()};
509 auto account_list{gnc_account_get_descendants_sorted(root)};
510 if (!account_list)
511 return nullptr;
512
513 for (auto node = account_list; node; node = g_list_next (node))
514 if (std::find(m_allowed.begin(), m_allowed.end(),
515 xaccAccountGetType(GNC_ACCOUNT(node->data))) != m_allowed.end())
516 {
517 retval = GNC_ACCOUNT(node->data);
518 break;
519 }
520 g_list_free(account_list);
521 return retval;
522}
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id,...
Definition Account.cpp:2050
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition guid.cpp:165
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Definition guid.cpp:237

◆ get_default_value() [9/10]

template<typename ValueType >
template GncOptionDateFormat GncOption::get_default_value< GncOptionDateFormat > ( ) const

Definition at line 81 of file gnc-option.cpp.

82{
83 return std::visit(
84 [](const auto& option)->ValueType {
85 if constexpr (is_same_decayed_v<decltype(option.get_value()),
86 ValueType>)
87 return option.get_default_value();
88 if constexpr (is_same_decayed_v<decltype(option),
90 {
91 if constexpr (is_same_decayed_v<ValueType,
93 return option.get_default_period();
94 if constexpr (std::is_same_v<ValueType, time64>)
95 return option.get_value();
96 if constexpr (std::is_same_v<ValueType, uint16_t>)
97 return option.get_default_period_index();
98 return ValueType{};
99 }
100 if constexpr
101 (is_same_decayed_v<decltype(option),
103 is_same_decayed_v<ValueType,
104 GncMultichoiceOptionIndexVec>)
105 return option.get_default_multiple();
106 return ValueType {};
107 }, *m_option);
108
109}
A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64,...
Multichoice options have a vector of valid options (GncMultichoiceOptionChoices) and validate the sel...
RelativeDatePeriod
Reporting periods relative to the current date.

◆ get_default_value() [10/10]

time64 GncOptionDateValue::get_default_value ( ) const
noexcept

Definition at line 562 of file gnc-option-impl.cpp.

563{
564 if (m_default_period == RelativeDatePeriod::ABSOLUTE)
565 return m_default_date;
566 return gnc_relative_date_to_time64(m_default_period);
567}
time64 gnc_relative_date_to_time64(RelativeDatePeriod period, time64 now_t)
Convert a RelativeDatePeriod value to a concrete time64 by applying the value to the current time.

◆ get_docstring()

const std::string & GncOption::get_docstring ( ) const

Definition at line 212 of file gnc-option.cpp.

213{
214 return std::visit([](const auto& option)->const std::string& {
215 return option.m_doc_string;
216 }, *m_option);
217}

◆ get_index()

uint16_t GncOptionMultichoiceValue::get_index ( ) const
inline

Definition at line 602 of file gnc-option-impl.hpp.

603 {
604 if (m_value.size() > 0)
605 return m_value[0];
606 if (m_default_value.size() > 0)
607 return m_default_value[0];
608 return 0;
609 }

◆ get_item()

GncItem GncOptionQofInstanceValue::get_item ( ) const
inline

Definition at line 187 of file gnc-option-impl.hpp.

187{ return m_value; }

◆ get_key()

const std::string & GncOption::get_key ( ) const

Definition at line 204 of file gnc-option.cpp.

205{
206 return std::visit([](const auto& option)->const std::string& {
207 return option.m_sort_tag;
208 }, *m_option);
209}

◆ get_keytype()

GncOptionMultichoiceKeyType GncOptionMultichoiceValue::get_keytype ( unsigned  i) const
inline

Definition at line 721 of file gnc-option-impl.hpp.

721{ return std::get<2>(m_choices.at(i)); }

◆ get_limits() [1/2]

template<typename ValueType >
template void GncOption::get_limits ( ValueType &  ,
ValueType &  ,
ValueType &   
) const
noexcept

Implemented only for GncOptionNumericRange.

Definition at line 177 of file gnc-option.cpp.

178{
179 std::visit([&max, &min, &step](const auto& option) {
180 if constexpr
181 (is_same_decayed_v<decltype(option),
183 option.get_limits(max, min, step);
184 }, *m_option);
185}
Used for numeric ranges and plot sizes.

◆ get_limits() [2/2]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::get_limits ( ValueType &  upper,
ValueType &  lower,
ValueType &  step 
) const
inlinenoexcept

Definition at line 440 of file gnc-option-impl.hpp.

441 {
442 upper = m_max;
443 lower = m_min;
444 step = m_step;
445 }

◆ get_multiple()

const GncMultichoiceOptionIndexVec & GncOptionMultichoiceValue::get_multiple ( ) const
inlinenoexcept

Definition at line 610 of file gnc-option-impl.hpp.

611 {
612 return m_value;
613 }

◆ get_name() [1/2]

const std::string & GncOption::get_name ( ) const

Definition at line 196 of file gnc-option.cpp.

197{
198 return std::visit([](const auto& option)->const std::string& {
199 return option.m_name;
200 }, *m_option);
201}

◆ get_name() [2/2]

const std::string & GncOptionSection::get_name ( ) const
inlinenoexcept

Definition at line 68 of file gnc-optiondb-impl.hpp.

68{ return m_name; }

◆ get_num_options()

size_t GncOptionSection::get_num_options ( ) const
inlinenoexcept

Definition at line 69 of file gnc-optiondb-impl.hpp.

69{ return m_options.size(); }

◆ get_period()

RelativeDatePeriod GncOptionDateValue::get_period ( ) const
inlinenoexcept

Definition at line 1087 of file gnc-option-impl.hpp.

1087{ return m_period; }

◆ get_period_index()

uint16_t GncOptionDateValue::get_period_index ( ) const
noexcept

Definition at line 573 of file gnc-option-impl.cpp.

574{
575 assert (m_period != RelativeDatePeriod::ABSOLUTE);
576 assert(!m_period_set.empty());
577 auto item{std::find(m_period_set.begin(), m_period_set.end(), m_period)};
578 assert(item != m_period_set.end());
579 return item - m_period_set.begin();
580}

◆ get_period_set()

const RelativeDatePeriodVec & GncOptionDateValue::get_period_set ( ) const
inline

Definition at line 1154 of file gnc-option-impl.hpp.

1154{ return m_period_set; }

◆ get_section()

const std::string & GncOption::get_section ( ) const

Definition at line 188 of file gnc-option.cpp.

189{
190 return std::visit([](const auto& option)->const std::string& {
191 return option.m_section;
192 }, *m_option);
193}

◆ get_ui_item()

GncOptionUIItem *const GncOption::get_ui_item ( ) const

Definition at line 254 of file gnc-option.cpp.

255{
256 return m_ui_item.get();
257}

◆ get_ui_type() [1/10]

const GncOptionUIType GncOption::get_ui_type ( ) const

Definition at line 246 of file gnc-option.cpp.

247{
248 return std::visit([](const auto& option)->GncOptionUIType {
249 return option.get_ui_type();
250 }, *m_option);
251}
GncOptionUIType
Used by GncOptionClassifier to indicate to dialog-options what control should be displayed for the op...

◆ get_ui_type() [2/10]

template<typename ValueType >
GncOptionUIType GncOptionValue< ValueType >::get_ui_type ( ) const
inlinenoexcept

Definition at line 109 of file gnc-option-impl.hpp.

109{ return m_ui_type; }

◆ get_ui_type() [3/10]

GncOptionUIType GncOptionGncOwnerValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 155 of file gnc-option-impl.hpp.

155{ return m_ui_type; }

◆ get_ui_type() [4/10]

GncOptionUIType GncOptionQofInstanceValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 195 of file gnc-option-impl.hpp.

195{ return m_ui_type; }

◆ get_ui_type() [5/10]

GncOptionUIType GncOptionCommodityValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 246 of file gnc-option-impl.hpp.

246{ return m_ui_type; }

◆ get_ui_type() [6/10]

template<typename ValueType >
GncOptionUIType GncOptionRangeValue< ValueType >::get_ui_type ( ) const
inlinenoexcept

Definition at line 450 of file gnc-option-impl.hpp.

450{ return m_ui_type; }

◆ get_ui_type() [7/10]

GncOptionUIType GncOptionMultichoiceValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 718 of file gnc-option-impl.hpp.

718{ return m_ui_type; }

◆ get_ui_type() [8/10]

GncOptionUIType GncOptionAccountListValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 877 of file gnc-option-impl.hpp.

877{ return m_ui_type; }

◆ get_ui_type() [9/10]

GncOptionUIType GncOptionAccountSelValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 997 of file gnc-option-impl.hpp.

997{ return m_ui_type; }

◆ get_ui_type() [10/10]

GncOptionUIType GncOptionDateValue::get_ui_type ( ) const
inlinenoexcept

Definition at line 1151 of file gnc-option-impl.hpp.

1151{ return m_ui_type; }

◆ get_value() [1/10]

template<typename ValueType >
ValueType GncOptionValue< ValueType >::get_value ( ) const
inline

Definition at line 101 of file gnc-option-impl.hpp.

101{ return m_value; }

◆ get_value() [2/10]

const GncOwner * GncOptionGncOwnerValue::get_value ( ) const

Definition at line 94 of file gnc-option-impl.cpp.

95{
96 return m_value.get();
97}

◆ get_value() [3/10]

const QofInstance * GncOptionQofInstanceValue::get_value ( ) const

Definition at line 214 of file gnc-option-impl.cpp.

215{
216 return qof_instance_from_gnc_item(m_value);
217}

◆ get_value() [4/10]

gnc_commodity * GncOptionCommodityValue::get_value ( ) const

Definition at line 297 of file gnc-option-impl.cpp.

298{
299 return gnc_commodity_from_namespace_and_mnemonic(m_namespace, m_mnemonic);
300}

◆ get_value() [5/10]

template<typename ValueType >
ValueType GncOptionRangeValue< ValueType >::get_value ( ) const
inline

Definition at line 420 of file gnc-option-impl.hpp.

420{ return m_value; }

◆ get_value() [6/10]

const std::string & GncOptionMultichoiceValue::get_value ( ) const
inline

Definition at line 581 of file gnc-option-impl.hpp.

582 {
583 auto vec{m_value.size() > 0 ? m_value : m_default_value};
584 if (vec.size() == 0)
585 return c_empty_string;
586 if (vec.size() == 1)
587 return std::get<0>(m_choices.at(vec[0]));
588 else
589 return c_list_string;
590
591 }

◆ get_value() [7/10]

GncOptionAccountList GncOptionAccountListValue::get_value ( ) const

Definition at line 410 of file gnc-option-impl.cpp.

411{
412 return !m_value.empty() ? m_value : get_default_value();
413}

◆ get_value() [8/10]

const Account * GncOptionAccountSelValue::get_value ( ) const

Definition at line 484 of file gnc-option-impl.cpp.

485{
486 auto book{get_current_book()};
487 return guid_equal(guid_null(), &m_value) ? get_default_value() :
488 xaccAccountLookup(&m_value, book);
489}

◆ get_value() [9/10]

template<typename ValueType >
template GncOptionDateFormat GncOption::get_value< GncOptionDateFormat > ( ) const

Definition at line 48 of file gnc-option.cpp.

49{
50 return std::visit(
51 [](const auto& option)->ValueType {
52 if constexpr (is_same_decayed_v<decltype(option.get_value()),
53 ValueType>)
54 return option.get_value();
55 if constexpr (is_same_decayed_v<decltype(option),
57 {
58 if constexpr (is_same_decayed_v<ValueType,
60 return option.get_period();
61 if constexpr (std::is_same_v<ValueType, time64>)
62 return option.get_value();
63 if constexpr (std::is_same_v<ValueType, uint16_t>)
64 return option.get_period_index();
65 return ValueType{};
66 }
67 if constexpr (is_same_decayed_v<decltype(option),
69 {
70 if constexpr (std::is_same_v<ValueType, uint16_t>)
71 return option.get_index();
72 if constexpr (is_same_decayed_v<ValueType,
73 GncMultichoiceOptionIndexVec>)
74 return option.get_multiple();
75 }
76 return ValueType {};
77 }, *m_option);
78}

◆ get_value() [10/10]

time64 GncOptionDateValue::get_value ( ) const
noexcept

Definition at line 554 of file gnc-option-impl.cpp.

555{
556 if (m_period == RelativeDatePeriod::ABSOLUTE)
557 return m_date;
558 return gnc_relative_date_to_time64(m_period);
559}

◆ get_widget_changed()

std::any & GncOption::get_widget_changed ( )
inline

Definition at line 213 of file gnc-option.hpp.

213{ return m_widget_changed; }

◆ gnc_account_delete_all_bayes_maps()

void gnc_account_delete_all_bayes_maps ( Account acc)

Delete all bayes entries for Account.

Definition at line 5775 of file Account.cpp.

5776{
5777 if (acc != nullptr)
5778 {
5779 auto slots = qof_instance_get_slots_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES);
5780 if (!slots.size()) return;
5782 for (auto const & entry : slots)
5783 {
5784 qof_instance_slot_path_delete (QOF_INSTANCE (acc), {entry.first});
5785 }
5786 qof_instance_set_dirty (QOF_INSTANCE(acc));
5788 }
5789}
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition Account.cpp:1516
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition Account.cpp:1475

◆ gnc_account_delete_map_entry()

void gnc_account_delete_map_entry ( Account acc,
char *  head,
char *  category,
char *  match_string,
gboolean  empty 
)

Delete the entry for Account pointed to by head,category and match_string, if empty is TRUE then use delete if empty.

Definition at line 5748 of file Account.cpp.

5750{
5751 if (acc != nullptr)
5752 {
5753 std::vector<std::string> path {head};
5754 if (category)
5755 path.emplace_back (category);
5756 if (match_string)
5757 path.emplace_back (match_string);
5758
5759 if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
5760 {
5762 if (empty)
5763 qof_instance_slot_path_delete_if_empty (QOF_INSTANCE(acc), path);
5764 else
5765 qof_instance_slot_path_delete (QOF_INSTANCE(acc), path);
5766 PINFO("Account is '%s', head is '%s', category is '%s', match_string is'%s'",
5767 xaccAccountGetName (acc), head, category, match_string);
5768 qof_instance_set_dirty (QOF_INSTANCE(acc));
5770 }
5771 }
5772}
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition Account.cpp:3289
#define PINFO(format, args...)
Print an informational note.
Definition qoflog.h:256

◆ gnc_account_get_credit_string()

const char * gnc_account_get_credit_string ( GNCAccountType  acct_type)

Get the credit string associated with this account type.

Definition at line 4103 of file Account.cpp.

4104{
4105 if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS))
4106 return _(dflt_acct_credit_str);
4107
4108 auto result = gnc_acct_credit_strs.find(acct_type);
4109 if (result != gnc_acct_credit_strs.end())
4110 return _(result->second);
4111 else
4112 return _(dflt_acct_credit_str);
4113}
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_account_get_debit_string()

const char * gnc_account_get_debit_string ( GNCAccountType  acct_type)

Get the debit string associated with this account type.

Definition at line 4091 of file Account.cpp.

4092{
4093 if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS))
4094 return _(dflt_acct_debit_str);
4095
4096 auto result = gnc_acct_debit_strs.find(acct_type);
4097 if (result != gnc_acct_debit_strs.end())
4098 return _(result->second);
4099 else
4100 return _(dflt_acct_debit_str);
4101}

◆ gnc_account_get_earliest_date()

time64 gnc_account_get_earliest_date ( const Account account)

Returns the date of the earliest split in the account, or INT64_MAX.

Parameters
accountThe account to retrieve data about.
Returns
posted_date of first split in the account, or INT64_MAX

Definition at line 5127 of file Account.cpp.

5128{
5129 g_return_val_if_fail (GNC_IS_ACCOUNT(account), INT64_MAX);
5130 const auto& splits = xaccAccountGetSplits (account);
5131 return splits.empty() ? INT64_MAX : xaccTransGetDate (xaccSplitGetParent (splits.front()));
5132}
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.

◆ gnc_account_get_map_entry()

gchar * gnc_account_get_map_entry ( Account acc,
const char *  head,
const char *  category 
)

Returns the text string pointed to by head and category for the Account, free the returned text.

Definition at line 5732 of file Account.cpp.

5733{
5734 return g_strdup (category ?
5735 get_kvp_string_path (acc, {head, category}) :
5736 get_kvp_string_path (acc, {head}));
5737}

◆ gnc_account_get_map_guid_entry()

GncGUID * gnc_account_get_map_guid_entry ( Account acc,
const char *  head,
const char *  category 
)

Returns the guid pointed to by head and category for the Account, free the returned guid.

Definition at line 5740 of file Account.cpp.

5741{
5742 return category ?
5743 get_kvp_guid_path (acc, {head, category}) :
5744 get_kvp_guid_path (acc, {head});
5745}

◆ gnc_account_imap_add_account()

void gnc_account_imap_add_account ( Account acc,
const char *  category,
const char *  key,
Account added_acc 
)

Definition at line 5208 of file Account.cpp.

5212{
5213 if (!acc || !key || !added_acc || !*key) return;
5214
5215 auto path = category ? Path{IMAP_FRAME, category, key} : Path{IMAP_FRAME, key};
5216
5217 set_kvp_account_path (acc, path, added_acc);
5218}

◆ gnc_account_imap_add_account_bayes()

void gnc_account_imap_add_account_bayes ( Account acc,
GList *  tokens,
Account added_acc 
)

Updates the imap for a given account using a list of tokens.

Definition at line 5571 of file Account.cpp.

5574{
5575 GList *current_token;
5576 gint64 token_count;
5577 char *account_fullname;
5578 char *guid_string;
5579
5580 ENTER(" ");
5581 if (!acc)
5582 {
5583 LEAVE(" ");
5584 return;
5585 }
5586 check_import_map_data (gnc_account_get_book(acc));
5587
5588 g_return_if_fail (added_acc != nullptr);
5589 account_fullname = gnc_account_get_full_name(added_acc);
5591
5592 PINFO("account name: '%s'", account_fullname);
5593
5594 guid_string = guid_to_string (xaccAccountGetGUID (added_acc));
5595
5596 /* process each token in the list */
5597 for (current_token = g_list_first(tokens); current_token;
5598 current_token = current_token->next)
5599 {
5600 char* token = static_cast<char*>(current_token->data);
5601 /* Jump to next iteration if the pointer is not valid or if the
5602 string is empty. In HBCI import we almost always get an empty
5603 string, which doesn't work in the kvp loopkup later. So we
5604 skip this case here. */
5605 if (!token || !token[0])
5606 continue;
5607 /* start off with one token for this account */
5608 token_count = 1;
5609 PINFO("adding token '%s'", token);
5610 auto path = std::string {IMAP_FRAME_BAYES} + '/' + token + '/' + guid_string;
5611 /* change the imap entry for the account */
5612 change_imap_entry (acc, path, token_count);
5613 }
5614 /* free up the account fullname and guid string */
5616 gnc_features_set_used (gnc_account_get_book(acc), GNC_FEATURE_GUID_FLAT_BAYESIAN);
5617 g_free (account_fullname);
5618 g_free (guid_string);
5619 LEAVE(" ");
5620}
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Definition Account.cpp:3305
#define xaccAccountGetGUID(X)
Definition Account.h:252
gchar * guid_to_string(const GncGUID *guid)
The guid_to_string() routine returns a null-terminated string encoding of the id.
Definition guid.cpp:199
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.

◆ gnc_account_imap_delete_account()

void gnc_account_imap_delete_account ( Account acc,
const char *  category,
const char *  key 
)

Definition at line 5222 of file Account.cpp.

5225{
5226 if (!acc || !key) return;
5227
5228 auto path = category ? Path{IMAP_FRAME, category, key} : Path{IMAP_FRAME, key};
5229 if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
5230 {
5231 qof_instance_slot_path_delete (QOF_INSTANCE (acc), path);
5232 if (category)
5233 qof_instance_slot_path_delete_if_empty (QOF_INSTANCE (acc), {IMAP_FRAME, category});
5234 qof_instance_slot_path_delete_if_empty (QOF_INSTANCE (acc), {IMAP_FRAME});
5235 }
5236 qof_instance_set_dirty (QOF_INSTANCE (acc));
5237}

◆ gnc_account_imap_find_account()

Account * gnc_account_imap_find_account ( Account acc,
const char *  category,
const char *  key 
)

Definition at line 5169 of file Account.cpp.

5172{
5173 if (!acc || !key) return nullptr;
5174 std::vector<std::string> path {IMAP_FRAME};
5175 if (category)
5176 path.push_back (category);
5177 path.push_back (key);
5178 return get_kvp_account_path (acc, path);
5179}

◆ gnc_account_imap_find_account_bayes()

Account * gnc_account_imap_find_account_bayes ( Account acc,
GList *  tokens 
)

Look up an Account in the map using Baysian.

Look up an Account in the map using Baysian.

Definition at line 5525 of file Account.cpp.

5526{
5527 if (!acc)
5528 return nullptr;
5529 auto book = gnc_account_get_book(acc);
5530 check_import_map_data (book);
5531 auto first_pass = get_first_pass_probabilities(acc, tokens);
5532 if (!first_pass.size())
5533 return nullptr;
5534 auto final_probabilities = build_probabilities(first_pass);
5535 if (!final_probabilities.size())
5536 return nullptr;
5537 auto best = highest_probability(final_probabilities);
5538 if (best.account_guid == "")
5539 return nullptr;
5540 if (best.probability < threshold)
5541 return nullptr;
5542 gnc::GUID guid;
5543 try {
5544 guid = gnc::GUID::from_string(best.account_guid);
5545 } catch (gnc::guid_syntax_exception&) {
5546 return nullptr;
5547 }
5548 auto account = xaccAccountLookup (reinterpret_cast<GncGUID*>(&guid), book);
5549 return account;
5550}

◆ gnc_account_imap_find_any()

Account * gnc_account_imap_find_any ( QofBook book,
const char *  category,
const char *  key 
)

Definition at line 5182 of file Account.cpp.

5183{
5184 Account *account = nullptr;
5185
5186 /* Get list of Accounts */
5187 auto root = gnc_book_get_root_account (book);
5188 auto accts = gnc_account_get_descendants_sorted (root);
5189
5190 /* Go through list of accounts */
5191 for (auto ptr = accts; ptr; ptr = g_list_next (ptr))
5192 {
5193 auto tmp_acc = static_cast<Account*> (ptr->data);
5194
5195 if (gnc_account_imap_find_account (tmp_acc, category, key))
5196 {
5197 account = tmp_acc;
5198 break;
5199 }
5200 }
5201 g_list_free (accts);
5202
5203return account;
5204}

◆ gnc_account_imap_get_info()

GList * gnc_account_imap_get_info ( Account acc,
const char *  category 
)

Returns a GList of structure imap_info of all Non Bayesian mappings for required Account.

Definition at line 5703 of file Account.cpp.

5704{
5705 GList *list = nullptr;
5706
5707 GncImapInfo imapInfo;
5708
5709 std::vector<std::string> path {IMAP_FRAME};
5710 if (category)
5711 path.emplace_back (category);
5712
5713 imapInfo.source_account = acc;
5714 imapInfo.list = list;
5715
5716 imapInfo.head = g_strdup (IMAP_FRAME);
5717 imapInfo.category = g_strdup (category);
5718
5719 if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
5720 {
5721 qof_instance_foreach_slot (QOF_INSTANCE(acc), IMAP_FRAME, category,
5722 build_non_bayes, &imapInfo);
5723 }
5724 g_free (imapInfo.head);
5725 g_free (imapInfo.category);
5726 return g_list_reverse(imapInfo.list);
5727}

◆ gnc_account_imap_get_info_bayes()

GList * gnc_account_imap_get_info_bayes ( Account acc)

Returns a GList of structure imap_info of all Bayesian mappings for required Account.

Definition at line 5692 of file Account.cpp.

5693{
5694 check_import_map_data (gnc_account_get_book (acc));
5695 /* A dummy object which is used to hold the specified account, and the list
5696 * of data about which we care. */
5697 GncImapInfo imapInfo {acc, nullptr};
5698 qof_instance_foreach_slot_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES, &build_bayes, imapInfo);
5699 return g_list_reverse(imapInfo.list);
5700}

◆ gnc_account_imap_info_destroy()

void gnc_account_imap_info_destroy ( GncImapInfo imapInfo)

Clean destructor for the imap_info structure of Bayesian mappings.

Definition at line 5682 of file Account.cpp.

5683{
5684 g_free (imapInfo->head);
5685 g_free (imapInfo->category);
5686 g_free (imapInfo->match_string);
5687 g_free (imapInfo->count);
5688 g_free (imapInfo);
5689}

◆ gnc_account_lookup_by_code()

Account * gnc_account_lookup_by_code ( const Account parent,
const char *  code 
)

The gnc_account_lookup_by_code() subroutine works like gnc_account_lookup_by_name, but uses the account code.

Definition at line 3106 of file Account.cpp.

3107{
3108 return (Account*)account_foreach_descendant_breadthfirst_until (parent, is_acct_code, (char*)code);
3109}

◆ gnc_account_lookup_by_full_name()

Account * gnc_account_lookup_by_full_name ( const Account any_account,
const gchar *  name 
)

The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.

Definition at line 3163 of file Account.cpp.

3165{
3166 const AccountPrivate *rpriv;
3167 const Account *root;
3168 Account *found;
3169 gchar **names;
3170
3171 g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), nullptr);
3172 g_return_val_if_fail(name, nullptr);
3173
3174 root = any_acc;
3175 rpriv = GET_PRIVATE(root);
3176 while (rpriv->parent)
3177 {
3178 root = rpriv->parent;
3179 rpriv = GET_PRIVATE(root);
3180 }
3181 names = g_strsplit(name, gnc_get_account_separator_string(), -1);
3182 found = gnc_account_lookup_by_full_name_helper(root, names);
3183 g_strfreev(names);
3184 return found;
3185}
const gchar * gnc_get_account_separator_string(void)
Returns the account separation character chosen by the user.
Definition Account.cpp:205

◆ gnc_account_lookup_by_name()

Account * gnc_account_lookup_by_name ( const Account parent,
const char *  name 
)

The gnc_account_lookup_by_name() subroutine fetches the account by name from the descendants of the specified account.

The immediate children are searched first. If there is no match, then a recursive search of all descendants is performed looking for a match.

Returns
A pointer to the account with the specified name, or NULL if the account was not found.

Definition at line 3093 of file Account.cpp.

3094{
3095 return (Account*)account_foreach_descendant_breadthfirst_until (parent, is_acct_name, (char*)name);
3096}

◆ gnc_account_lookup_by_opening_balance()

Account * gnc_account_lookup_by_opening_balance ( Account account,
gnc_commodity *  commodity 
)

Find the opening balance account for the currency.

Parameters
accountThe account of which the sought-for account is a descendant.
commodityThe commodity in which the account should be denominated
Returns
The descendant account of EQUITY_TYPE_OPENING_BALANCE or NULL if one doesn't exist.

Definition at line 3121 of file Account.cpp.

3122{
3123 return (Account *)gnc_account_foreach_descendant_until (account, is_opening_balance_account, commodity);
3124}
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling 'func' on each...
Definition Account.cpp:3244

◆ gnc_account_lookup_by_type_and_commodity()

GList * gnc_account_lookup_by_type_and_commodity ( Account root,
const char *  name,
GNCAccountType  acctype,
gnc_commodity *  commodity 
)

Find a direct child account matching name, GNCAccountType, and/or commodity.

Name and commodity may be nullptr in which case the accounts in the list may have any value for those properties. Note that commodity matching is by equivalence: If the mnemonic/symbol and namespace are the same, it matches.

Parameters
rootThe account among whose children one expects to find the account.
nameThe name of the account to look for or nullptr.
acctypeThe GNCAccountType to match.
commodityThe commodity in which the account should be denominated or nullptr.
Returns
A GList of children matching the supplied parameters.

Definition at line 3188 of file Account.cpp.

3192{
3193 GList *retval{};
3194 auto rpriv{GET_PRIVATE(root)};
3195 for (auto account : rpriv->children)
3196 {
3197 if (xaccAccountGetType (account) == acctype)
3198 {
3199 if (commodity &&
3201 commodity))
3202 continue;
3203
3204 if (name && strcmp(name, xaccAccountGetName(account)))
3205 continue;
3206
3207 retval = g_list_prepend(retval, account);
3208 }
3209 }
3210
3211 if (!retval) // Recurse through the children
3212 for (auto account : rpriv->children)
3213 {
3214 auto result = gnc_account_lookup_by_type_and_commodity(account,
3215 name,
3216 acctype,
3217 commodity);
3218 if (result)
3219 retval = g_list_concat(result, retval);
3220 }
3221 return retval;
3222}
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
Definition Account.cpp:3408
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
GList * gnc_account_lookup_by_type_and_commodity(Account *root, const char *name, GNCAccountType acctype, gnc_commodity *commodity)
Find a direct child account matching name, GNCAccountType, and/or commodity.
Definition Account.cpp:3188

◆ gnc_account_reset_convert_bayes_to_flat()

void gnc_account_reset_convert_bayes_to_flat ( void  )

Reset the flag that indicates the function imap_convert_bayes_to_flat has been run.

Definition at line 5493 of file Account.cpp.

5494{
5495 imap_convert_bayes_to_flat_run = false;
5496}

◆ gnc_account_tree_begin_staged_transaction_traversals()

void gnc_account_tree_begin_staged_transaction_traversals ( Account acc)

gnc_account_tree_begin_staged_transaction_traversals() resets the traversal marker inside every transactions of every account in the account tree originating with the specified node.

This is done so that a new sequence of staged traversals can begin.

Definition at line 5054 of file Account.cpp.

5055{
5056 auto do_one_account = [](auto acc)
5057 { gnc_account_foreach_split (acc, [](auto s){ s->parent->marker = 0; }); };
5058 gnc_account_foreach_descendant (account, do_one_account);
5059}

◆ gnc_account_tree_staged_transaction_traversal()

int gnc_account_tree_staged_transaction_traversal ( const Account account,
unsigned int  stage,
TransactionCallback  thunk,
void *  data 
)

gnc_account_tree_staged_transaction_traversal() calls thunk on each transaction in the group whose current marker is less than the given stage and updates each transaction's marker to be stage.

The traversal will stop if thunk returns a non-zero value. gnc_account_tree_staged_transaction_traversal() function will return zero or the non-zero value returned by thunk. This API does not handle handle recursive traversals.

Warning
For performance reasons, the transaction callback thunk must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.

Definition at line 5089 of file Account.cpp.

5093{
5094 const AccountPrivate *priv;
5095 Transaction *trans;
5096 int retval;
5097
5098 if (!acc) return 0;
5099
5100 /* depth first traversal */
5101 priv = GET_PRIVATE(acc);
5102 for (auto acc_p : priv->children)
5103 {
5104 retval = gnc_account_tree_staged_transaction_traversal(acc_p, stage, thunk, cb_data);
5105 if (retval) return retval;
5106 }
5107
5108 /* Now this account */
5109 for (auto s : priv->splits)
5110 {
5111 trans = s->parent;
5112 if (trans && (trans->marker < stage))
5113 {
5114 trans->marker = stage;
5115 if (thunk)
5116 {
5117 retval = thunk(trans, cb_data);
5118 if (retval) return retval;
5119 }
5120 }
5121 }
5122
5123 return 0;
5124}
int gnc_account_tree_staged_transaction_traversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
gnc_account_tree_staged_transaction_traversal() calls thunk on each transaction in the group whose cu...
Definition Account.cpp:5089

◆ gnc_book_count_transactions()

guint gnc_book_count_transactions ( QofBook book)
Warning
XXX FIXME gnc_book_count_transactions is a utility function, probably needs to be moved to a utility file somewhere.

Definition at line 2504 of file Transaction.cpp.

2505{
2506 guint count = 0;
2507 xaccAccountTreeForEachTransaction(gnc_book_get_root_account(book),
2508 counter_thunk, (void*)&count);
2509 return count;
2510}

◆ gnc_engine_add_commit_error_callback()

void gnc_engine_add_commit_error_callback ( EngineCommitErrorCallback  cb,
gpointer  data 
)

Set a callback function to be called in case an engine commit fails.

Definition at line 166 of file gnc-engine.cpp.

167{
168 g_error_cb = cb;
169 g_error_cb_data = data;
170}

◆ gnc_engine_add_init_hook()

void gnc_engine_add_init_hook ( gnc_engine_init_hook_t  hook)

Pass a function pointer to gnc_engine_add_init_hook and it will be called during the evaluation of gnc_engine_init.

Definition at line 154 of file gnc-engine.cpp.

155{
156 engine_init_hooks = g_list_append(engine_init_hooks, (gpointer)h);
157}

◆ gnc_engine_init()

void gnc_engine_init ( int  argc,
char **  argv 
)

PROTOTYPES.

gnc_engine_init should be called before gnc engine functions can be used.

Definition at line 116 of file gnc-engine.cpp.

117{
118 if (1 == engine_is_initialized) return;
119
120 gnc_engine_init_part1();
121 gnc_engine_init_part2();
122 gnc_engine_init_part3(argc, argv);
123}

◆ gnc_engine_init_static()

void gnc_engine_init_static ( int  argc,
char **  argv 
)

This is the statically linked-in version of gnc_engine_init.

It is identical to that function except that it doesn't load any backend library.

Definition at line 126 of file gnc-engine.cpp.

127{
128 if (1 == engine_is_initialized) return;
129
130 gnc_engine_init_part1();
131 gnc_engine_init_part3(argc, argv);
132}

◆ gnc_engine_is_initialized()

gboolean gnc_engine_is_initialized ( void  )

check the engine is fully initialized

Definition at line 160 of file gnc-engine.cpp.

161{
162 return (engine_is_initialized == 1) ? TRUE : FALSE;
163}

◆ gnc_engine_shutdown()

void gnc_engine_shutdown ( void  )

Called to shutdown the engine.

Definition at line 141 of file gnc-engine.cpp.

142{
144 qof_close();
145 engine_is_initialized = 0;
146}
void qof_log_shutdown(void)
Be nice, close the logfile if possible.
Definition qoflog.cpp:264
void qof_close(void)
Safely close down the Query Object Framework.
Definition qofutil.cpp:269

◆ gnc_engine_signal_commit_error()

void gnc_engine_signal_commit_error ( QofBackendError  errcode)

Definition at line 173 of file gnc-engine.cpp.

174{
175 if ( g_error_cb != nullptr )
176 {
177 (*g_error_cb)( g_error_cb_data, errcode );
178 }
179}

◆ gnc_transaction_get_type()

GType gnc_transaction_get_type ( void  )

Definition at line 29 of file gmock-Transaction.cpp.

30{
31 return gnc_mocktransaction_get_type();
32}

◆ GncOption() [1/2]

template<typename ValueType , typename std::enable_if_t<!is_OptionClassifier_v< ValueType >, int > >
GncOption::GncOption ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
ValueType  value,
GncOptionUIType  ui_type = GncOptionUIType::INTERNAL 
)

Definition at line 38 of file gnc-option.cpp.

40 :
41 m_option{std::make_unique<GncOptionVariant>(
42 std::in_place_type<GncOptionValue<ValueType>>,
43 section, name, key, doc_string, value, ui_type)}
44{
45}
The generic option-value class.

◆ GncOption() [2/2]

template<typename OptionType , typename std::enable_if_t< is_OptionClassifier_v< OptionType >, int > = 0>
GncOption::GncOption ( OptionType  option)
inline

Definition at line 143 of file gnc-option.hpp.

143 :
144 m_option{std::make_unique<GncOptionVariant>(option)} {}

◆ GncOptionAccountListValue() [1/4]

GncOptionAccountListValue::GncOptionAccountListValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
bool  multi = true 
)
inline

Definition at line 817 of file gnc-option-impl.hpp.

819 :
820 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
821 m_value{}, m_default_value{}, m_allowed{}, m_multiselect{multi} {}
This class is the parent of all option implementations.

◆ GncOptionAccountListValue() [2/4]

GncOptionAccountListValue::GncOptionAccountListValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
const GncOptionAccountList &  value,
bool  multi = true 
)
inline

Definition at line 823 of file gnc-option-impl.hpp.

826 :
827 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
828 m_value{value}, m_default_value{std::move(value)}, m_allowed{},
829 m_multiselect{multi} {}

◆ GncOptionAccountListValue() [3/4]

GncOptionAccountListValue::GncOptionAccountListValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
const GncOptionAccountList &  value,
GncOptionAccountTypeList &&  allowed,
bool  multi = true 
)
inline

Definition at line 837 of file gnc-option-impl.hpp.

841 :
842 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
843 m_value{}, m_default_value{}, m_allowed{std::move(allowed)},
844 m_multiselect{multi} {
845 if (!validate(value))
846 throw std::invalid_argument("Supplied Value not in allowed set.");
847 m_value = value;
848 m_default_value = std::move(value);
849 }

◆ GncOptionAccountListValue() [4/4]

GncOptionAccountListValue::GncOptionAccountListValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
GncOptionAccountTypeList &&  allowed,
bool  multi = true 
)
inline

Definition at line 830 of file gnc-option-impl.hpp.

833 :
834 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
835 m_value{}, m_default_value{}, m_allowed{std::move(allowed)},
836 m_multiselect{multi} {}

◆ GncOptionAccountSelValue() [1/4]

GncOptionAccountSelValue::GncOptionAccountSelValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type 
)
inline

Definition at line 940 of file gnc-option-impl.hpp.

942 :
943 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
944 m_value{*guid_null()}, m_default_value{*guid_null()}, m_allowed{} {}

◆ GncOptionAccountSelValue() [2/4]

GncOptionAccountSelValue::GncOptionAccountSelValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
const Account value 
)
inline

Definition at line 946 of file gnc-option-impl.hpp.

949 :
950 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
951 m_value{*qof_entity_get_guid(value)},
952 m_default_value{*qof_entity_get_guid(value)}, m_allowed{} {}

◆ GncOptionAccountSelValue() [3/4]

GncOptionAccountSelValue::GncOptionAccountSelValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
const Account value,
GncOptionAccountTypeList &&  allowed 
)
inline

Definition at line 960 of file gnc-option-impl.hpp.

964 :
965 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
966 m_value{*guid_null()}, m_default_value{*guid_null()}, m_allowed{std::move(allowed)} {
967 if (!validate(value))
968 throw std::invalid_argument("Supplied Value not in allowed set.");
969 m_value = m_default_value = *qof_entity_get_guid(value);
970 }

◆ GncOptionAccountSelValue() [4/4]

GncOptionAccountSelValue::GncOptionAccountSelValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
GncOptionAccountTypeList &&  allowed 
)
inline

Definition at line 953 of file gnc-option-impl.hpp.

956 :
957 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui_type},
958 m_value{*guid_null()}, m_default_value{*guid_null()},
959 m_allowed{std::move(allowed)} {}

◆ GncOptionCommodityValue()

GncOptionCommodityValue::GncOptionCommodityValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
gnc_commodity *  value,
GncOptionUIType  ui_type = GncOptionUIType::COMMODITY 
)
inline

Definition at line 219 of file gnc-option-impl.hpp.

222 :
223 OptionClassifier{section, name, key, doc_string},
224 m_ui_type{ui_type}, m_is_currency{ui_type == GncOptionUIType::CURRENCY},
225 m_namespace{gnc_commodity_get_namespace(value)},
226 m_mnemonic{gnc_commodity_get_mnemonic(value)},
227 m_default_namespace{gnc_commodity_get_namespace(value)},
228 m_default_mnemonic{gnc_commodity_get_mnemonic(value)}
229 {
230 if (!validate(value))
231 throw std::invalid_argument("Attempt to create GncOptionCommodityValue with currency UIType and non-currency value.");
232 }
const char * gnc_commodity_get_namespace(const gnc_commodity *cm)
Retrieve the namespace for the specified commodity.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.

◆ GncOptionDateValue() [1/4]

GncOptionDateValue::GncOptionDateValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type 
)
inline

Definition at line 1048 of file gnc-option-impl.hpp.

1050 :
1051 OptionClassifier{section, name, key, doc_string},
1052 m_ui_type{ui_type}, m_date{INT64_MAX}, m_default_date{INT64_MAX},
1053 m_period{RelativeDatePeriod::TODAY},
1054 m_default_period{RelativeDatePeriod::TODAY},
1055 m_period_set{} {}

◆ GncOptionDateValue() [2/4]

GncOptionDateValue::GncOptionDateValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
const RelativeDatePeriodVec &  period_set 
)
inline

Definition at line 1072 of file gnc-option-impl.hpp.

1075 :
1076 OptionClassifier{section, name, key, doc_string},
1077 m_ui_type{ui_type}, m_date{INT64_MAX}, m_default_date{INT64_MAX},
1078 m_period{period_set.back()},
1079 m_default_period{period_set.back()},
1080 m_period_set{period_set} {}

◆ GncOptionDateValue() [3/4]

GncOptionDateValue::GncOptionDateValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
RelativeDatePeriod  period 
)
inline

Definition at line 1064 of file gnc-option-impl.hpp.

1067 :
1068 OptionClassifier{section, name, key, doc_string},
1069 m_ui_type{ui_type}, m_date{INT64_MAX}, m_default_date{INT64_MAX},
1070 m_period{period}, m_default_period{period},
1071 m_period_set{} {}

◆ GncOptionDateValue() [4/4]

GncOptionDateValue::GncOptionDateValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncOptionUIType  ui_type,
time64  time 
)
inline

Definition at line 1056 of file gnc-option-impl.hpp.

1058 :
1059 OptionClassifier{section, name, key, doc_string},
1060 m_ui_type{ui_type}, m_date{time}, m_default_date{time},
1061 m_period{RelativeDatePeriod::ABSOLUTE},
1062 m_default_period{RelativeDatePeriod::ABSOLUTE},
1063 m_period_set{} {}

◆ GncOptionDB() [1/2]

GncOptionDB::GncOptionDB ( )

Definition at line 176 of file gnc-optiondb.cpp.

176: m_default_section{} {}

◆ GncOptionDB() [2/2]

GncOptionDB::GncOptionDB ( QofBook book)

Definition at line 178 of file gnc-optiondb.cpp.

178: GncOptionDB() {}

◆ GncOptionDBCallback()

GncOptionDBCallback::GncOptionDBCallback ( size_t  id,
GncOptionDBChangeCallback  func,
void *  data 
)
inline

Definition at line 87 of file gnc-optiondb-impl.hpp.

88 :
89 m_id{id}, m_func{func}, m_data{data} {}

◆ GncOptionGncOwnerValue() [1/2]

GncOptionGncOwnerValue::GncOptionGncOwnerValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const GncOwner value,
GncOptionUIType  ui_type = GncOptionUIType::INTERNAL 
)

Definition at line 65 of file gnc-option-impl.cpp.

68 :
69 OptionClassifier{section, name, key, doc_string},
70 m_ui_type(ui_type), m_value{make_owner_ptr(value)},
71 m_default_value{make_owner_ptr(value)} {}

◆ GncOptionGncOwnerValue() [2/2]

GncOptionGncOwnerValue::GncOptionGncOwnerValue ( const GncOptionGncOwnerValue from)

Definition at line 73 of file gnc-option-impl.cpp.

73 :
74 OptionClassifier{from.m_section, from.m_name, from.m_sort_tag,
75 from.m_doc_string},
76 m_ui_type(from.get_ui_type()), m_value{make_owner_ptr(from.get_value())},
77 m_default_value{make_owner_ptr(from.get_default_value())} {}

◆ GncOptionMultichoiceValue() [1/3]

GncOptionMultichoiceValue::GncOptionMultichoiceValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const char *  value,
GncMultichoiceOptionChoices &&  choices,
GncOptionUIType  ui_type = GncOptionUIType::MULTICHOICE 
)
inline

Definition at line 531 of file gnc-option-impl.hpp.

535 :
536 OptionClassifier{section, name, key, doc_string},
537 m_ui_type{ui_type},
538 m_value{}, m_default_value{}, m_choices{std::move(choices)}
539 {
540 if (value)
541 {
542 if (auto index = find_key(value);
543 index != uint16_t_max)
544 {
545 m_value.push_back(index);
546 m_default_value.push_back(index);
547 }
548 }
549 }

◆ GncOptionMultichoiceValue() [2/3]

GncOptionMultichoiceValue::GncOptionMultichoiceValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncMultichoiceOptionIndexVec &&  indices,
GncMultichoiceOptionChoices &&  choices,
GncOptionUIType  ui_type = GncOptionUIType::LIST 
)
inline

Definition at line 567 of file gnc-option-impl.hpp.

571 :
572 OptionClassifier{section, name, key, doc_string},
573 m_ui_type{ui_type},
574 m_value{indices}, m_default_value{std::move(indices)},
575 m_choices{std::move(choices)} {}

◆ GncOptionMultichoiceValue() [3/3]

GncOptionMultichoiceValue::GncOptionMultichoiceValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
uint16_t  index,
GncMultichoiceOptionChoices &&  choices,
GncOptionUIType  ui_type = GncOptionUIType::MULTICHOICE 
)
inline

Definition at line 551 of file gnc-option-impl.hpp.

555 :
556 OptionClassifier{section, name, key, doc_string},
557 m_ui_type{ui_type},
558 m_value{}, m_default_value{}, m_choices{std::move(choices)}
559 {
560 if (index < m_choices.size())
561 {
562 m_value.push_back(index);
563 m_default_value.push_back(index);
564 }
565 }

◆ GncOptionQofInstanceValue() [1/2]

GncOptionQofInstanceValue::GncOptionQofInstanceValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const QofInstance value,
GncOptionUIType  ui_type = GncOptionUIType::INTERNAL 
)

Definition at line 181 of file gnc-option-impl.cpp.

184 :
185 OptionClassifier{section, name, key, doc_string},
186 m_ui_type(ui_type), m_value{},
187 m_default_value{} {
188 m_value = make_gnc_item(value);
189 m_default_value = make_gnc_item(value);
190}

◆ GncOptionQofInstanceValue() [2/2]

GncOptionQofInstanceValue::GncOptionQofInstanceValue ( const GncOptionQofInstanceValue from)

Definition at line 192 of file gnc-option-impl.cpp.

192 :
193 OptionClassifier{from.m_section, from.m_name, from.m_sort_tag,
194 from.m_doc_string},
195 m_ui_type(from.get_ui_type()), m_value{from.get_item()},
196 m_default_value{from.get_default_item()}
197{
198}

◆ GncOptionRangeValue() [1/2]

template<typename ValueType >
GncOptionRangeValue< ValueType >::GncOptionRangeValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
ValueType  value,
ValueType  min,
ValueType  max,
ValueType  step 
)
inline

Definition at line 400 of file gnc-option-impl.hpp.

403 :
404 GncOptionRangeValue<ValueType>{section, name, key, doc_string, value, min,
405 max, step, GncOptionUIType::NUMBER_RANGE} {}

◆ GncOptionRangeValue() [2/2]

template<typename ValueType >
GncOptionRangeValue< ValueType >::GncOptionRangeValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
ValueType  value,
ValueType  min,
ValueType  max,
ValueType  step,
GncOptionUIType  ui 
)
inline

Definition at line 406 of file gnc-option-impl.hpp.

409 :
410 OptionClassifier{section, name, key, doc_string}, m_ui_type{ui},
411 m_value{value >= min && value <= max ? value : min},
412 m_default_value{value >= min && value <= max ? value : min},
413 m_min{min}, m_max{max}, m_step{step} {
414 if constexpr(is_same_decayed_v<ValueType, int>)
415 set_alternate(true);}

◆ GncOptionSection()

GncOptionSection::GncOptionSection ( const char *  name)
inline

Definition at line 63 of file gnc-optiondb-impl.hpp.

63: m_name{name}, m_options{} {}

◆ GncOptionValue()

template<typename ValueType >
GncOptionValue< ValueType >::GncOptionValue ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
ValueType  value,
GncOptionUIType  ui_type = GncOptionUIType::INTERNAL 
)
inline

Definition at line 90 of file gnc-option-impl.hpp.

93 :
94 OptionClassifier{section, name, key, doc_string},
95 m_ui_type(ui_type), m_value{value}, m_default_value{value} { }

◆ in_stream() [1/2]

std::istream & GncOptionDateValue::in_stream ( std::istream &  iss)

Definition at line 628 of file gnc-option-impl.cpp.

629{
630 char type_str[10]; //The length of both "absolute" and "relative" plus 1.
631 iss.getline(type_str, sizeof(type_str), '.');
632 if(!iss)
633 throw std::invalid_argument("Date Type separator missing");
634 /* strcmp is safe, istream::getline null terminates the buffer. */
635 if (strcmp(type_str, "absolute ") == 0)
636 {
637 time64 time;
638 iss >> time;
639 set_value(time);
640 if (iss.get() != ')')
641 iss.unget();
642 }
643 else if (strcmp(type_str, "relative ") == 0)
644 {
645 std::string period_str;
646 iss >> period_str;
647 if (period_str.back() == ')')
648 period_str.pop_back();
649 auto period = gnc_relative_date_from_storage_string(period_str.c_str());
650 if (period == RelativeDatePeriod::ABSOLUTE)
651 {
652 std::string err{"Unknown period string in date option: '"};
653 err += period_str;
654 err += "'";
655 throw std::invalid_argument(err);
656 }
657
658 set_value(period);
659 }
660 else
661 {
662 std::string err{"Unknown date type string in date option: '"};
663 err += type_str;
664 err += "'";
665 throw std::invalid_argument{err};
666 }
667 return iss;
668}
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87

◆ in_stream() [2/2]

std::istream & GncOption::in_stream ( std::istream &  iss)

Set the option's value from an input stream.

Parameters
issAn input stream reference.
Returns
the stream reference for chaining.

Definition at line 463 of file gnc-option.cpp.

464{
465 return std::visit([&iss](auto& option) -> std::istream& {
466 iss >> option;
467 return iss;
468 }, *m_option);
469}

◆ is_alternate() [1/2]

template<typename ValueType >
bool GncOptionRangeValue< ValueType >::is_alternate ( ) const
inlinenoexcept

Definition at line 453 of file gnc-option-impl.hpp.

453{ return m_alternate; }

◆ is_alternate() [2/2]

bool GncOption::is_alternate ( ) const
noexcept

Definition at line 426 of file gnc-option.cpp.

427{
428 return std::visit([](auto& option) -> bool {
429 if constexpr(is_RangeValue_v<decltype(option)>)
430 return option.is_alternate();
431 return false;
432 }, *m_option);
433}

◆ is_changed() [1/10]

template<typename ValueType >
bool GncOptionValue< ValueType >::is_changed ( ) const
inlinenoexcept

Definition at line 108 of file gnc-option-impl.hpp.

108{ return m_value != m_default_value; }

◆ is_changed() [2/10]

bool GncOptionGncOwnerValue::is_changed ( ) const
noexcept

Definition at line 112 of file gnc-option-impl.cpp.

113{
114 return gncOwnerEqual(m_value.get(), m_default_value.get());
115}
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
Assess equality by checking.
Definition gncOwner.c:404

◆ is_changed() [3/10]

bool GncOptionQofInstanceValue::is_changed ( ) const
noexcept

Definition at line 232 of file gnc-option-impl.cpp.

233{
234 return m_value != m_default_value;
235}

◆ is_changed() [4/10]

bool GncOptionCommodityValue::is_changed ( ) const
noexcept

Definition at line 336 of file gnc-option-impl.cpp.

337{
338 return m_namespace != m_default_namespace || m_mnemonic != m_default_mnemonic;
339}

◆ is_changed() [5/10]

template<typename ValueType >
bool GncOptionRangeValue< ValueType >::is_changed ( ) const
inlinenoexcept

Definition at line 449 of file gnc-option-impl.hpp.

449{ return m_value != m_default_value; }

◆ is_changed() [6/10]

bool GncOptionMultichoiceValue::is_changed ( ) const
inlinenoexcept

Definition at line 717 of file gnc-option-impl.hpp.

717{ return m_value != m_default_value; }

◆ is_changed() [7/10]

bool GncOptionAccountListValue::is_changed ( ) const
noexcept

Definition at line 447 of file gnc-option-impl.cpp.

448{
449 return m_value != m_default_value;
450}

◆ is_changed() [8/10]

bool GncOptionAccountSelValue::is_changed ( ) const
inlinenoexcept

Definition at line 996 of file gnc-option-impl.hpp.

996{ return !guid_equal(&m_value, &m_default_value); }

◆ is_changed() [9/10]

bool GncOptionDateValue::is_changed ( ) const
inlinenoexcept

Definition at line 1149 of file gnc-option-impl.hpp.

1149 { return m_period != m_default_period &&
1150 m_date != m_default_date; }

◆ is_changed() [10/10]

bool GncOption::is_changed ( ) const
noexcept
Returns
true if the option value differs from its default value.

Definition at line 314 of file gnc-option.cpp.

315{
316 return std::visit([](const auto& option)->bool {
317 return option.is_changed();
318 }, *m_option);
319}

◆ is_dirty() [1/10]

template<typename ValueType >
bool GncOptionValue< ValueType >::is_dirty ( ) const
inlinenoexcept

Definition at line 107 of file gnc-option-impl.hpp.

107{ return m_dirty; }

◆ is_dirty() [2/10]

bool GncOptionGncOwnerValue::is_dirty ( ) const
inlinenoexcept

Definition at line 153 of file gnc-option-impl.hpp.

153{ return m_dirty; }

◆ is_dirty() [3/10]

bool GncOptionQofInstanceValue::is_dirty ( ) const
inlinenoexcept

Definition at line 193 of file gnc-option-impl.hpp.

193{ return m_dirty; }

◆ is_dirty() [4/10]

bool GncOptionCommodityValue::is_dirty ( ) const
inlinenoexcept

Definition at line 244 of file gnc-option-impl.hpp.

244{ return m_dirty; }

◆ is_dirty() [5/10]

template<typename ValueType >
bool GncOptionRangeValue< ValueType >::is_dirty ( ) const
inlinenoexcept

Definition at line 448 of file gnc-option-impl.hpp.

448{ return m_dirty; }

◆ is_dirty() [6/10]

bool GncOptionMultichoiceValue::is_dirty ( ) const
inlinenoexcept

Definition at line 716 of file gnc-option-impl.hpp.

716{ return m_dirty; }

◆ is_dirty() [7/10]

bool GncOptionAccountListValue::is_dirty ( ) const
inlinenoexcept

Definition at line 875 of file gnc-option-impl.hpp.

875{ return m_dirty; }

◆ is_dirty() [8/10]

bool GncOptionAccountSelValue::is_dirty ( ) const
inlinenoexcept

Definition at line 995 of file gnc-option-impl.hpp.

995{ return m_dirty; }

◆ is_dirty() [9/10]

bool GncOptionDateValue::is_dirty ( ) const
inlinenoexcept

Definition at line 1148 of file gnc-option-impl.hpp.

1148{ return m_dirty; }

◆ is_dirty() [10/10]

bool GncOption::is_dirty ( ) const
noexcept
Returns
true if the option has been marked as needing to be saved.

Definition at line 306 of file gnc-option.cpp.

307{
308 return std::visit([](const auto& option)->bool {
309 return option.is_dirty();
310 }, *m_option);
311}

◆ is_internal() [1/10]

template<typename ValueType >
bool GncOptionValue< ValueType >::is_internal ( )
inline

Definition at line 111 of file gnc-option-impl.hpp.

111{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [2/10]

bool GncOptionGncOwnerValue::is_internal ( )
inline

Definition at line 157 of file gnc-option-impl.hpp.

157{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [3/10]

bool GncOptionQofInstanceValue::is_internal ( )
inline

Definition at line 197 of file gnc-option-impl.hpp.

197{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [4/10]

bool GncOptionCommodityValue::is_internal ( )
inline

Definition at line 248 of file gnc-option-impl.hpp.

248{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [5/10]

template<typename ValueType >
bool GncOptionRangeValue< ValueType >::is_internal ( )
inline

Definition at line 452 of file gnc-option-impl.hpp.

452{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [6/10]

bool GncOptionMultichoiceValue::is_internal ( )
inline

Definition at line 720 of file gnc-option-impl.hpp.

720{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [7/10]

bool GncOptionAccountListValue::is_internal ( )
inline

Definition at line 879 of file gnc-option-impl.hpp.

879{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [8/10]

bool GncOptionAccountSelValue::is_internal ( )
inline

Definition at line 999 of file gnc-option-impl.hpp.

999{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [9/10]

bool GncOptionDateValue::is_internal ( )
inline

Definition at line 1153 of file gnc-option-impl.hpp.

1153{ return m_ui_type == GncOptionUIType::INTERNAL; }

◆ is_internal() [10/10]

bool GncOption::is_internal ( )

Definition at line 290 of file gnc-option.cpp.

291{
292 return std::visit([](auto& option)->bool {
293 return option.is_internal();
294 }, *m_option);
295}

◆ is_multiselect() [1/2]

bool GncOptionAccountListValue::is_multiselect ( ) const
inlinenoexcept

Definition at line 880 of file gnc-option-impl.hpp.

880{ return m_multiselect; }

◆ is_multiselect() [2/2]

bool GncOption::is_multiselect ( ) const
noexcept
Returns
false unless m_option contains a GncOptionMultiselectValue or GncOptionAccountListValue for which multiple selections have been enabled.

Definition at line 322 of file gnc-option.cpp.

323{
324 return std::visit(
325 [](const auto& option)->bool {
326 if constexpr (is_same_decayed_v<decltype(option),
328 return option.is_multiselect();
329 else
330 return false;
331 }, *m_option);
332}

◆ load_from_key_value()

std::istream & GncOptionDB::load_from_key_value ( std::istream &  iss)

Definition at line 331 of file gnc-optiondb.cpp.

332{
333 if (iss.peek() == '[')
334 {
335 char buf[classifier_size_max];
336 iss.getline(buf, classifier_size_max);
337 if (strcmp(buf, "[Options]") != 0) // safe
338 throw std::runtime_error("Wrong secion header for options.");
339 }
340 // Otherwise assume we were sent here correctly:
341 while (iss.peek() != '[') //Indicates the start of the next file section
342 {
343 load_option_key_value(iss);
344 }
345 return iss;
346}

◆ load_from_kvp()

void GncOptionDB::load_from_kvp ( QofBook book)
noexcept

Definition at line 564 of file gnc-optiondb.cpp.

565{
566 foreach_section(
567 [book](GncOptionSectionPtr& section)
568 {
569 section->foreach_option(
570 [book, &section](GncOption& option)
571 {
572 // Make path list as above.
573 std::string name;
574 /* qof_book_set_option wants a GSList path. Let's avoid
575 * allocating and make one here. */
576 GSList list_tail{}, list_head{nullptr, &list_tail};
577 if (strcmp(section->get_name().c_str(), "Counters") == 0)
578 counter_option_path(option, &list_head, name);
579 else
580 option_path(option, &list_head);
581 auto kvp = qof_book_get_option(book, &list_head);
582 if (!kvp)
583 return;
584
585 auto set_double = [&option, kvp, &list_head]() {
586 /*counters might have been set as doubles
587 * because of
588 * https://bugs.gnucash.org/show_bug.cgi?id=798930. They
589 * should be int.
590 */
591 constexpr const char *counters{"counters"};
592 auto value{kvp->get<double>()};
593 if (strcmp(static_cast<char*>(list_head.data), counters) == 0)
594 option.set_value(static_cast<int>(value));
595 else
596 option.set_value(value);
597 };
598
599 switch (kvp->get_type())
600 {
601 case KvpValue::Type::DOUBLE:
602 set_double();
603 break;
604 case KvpValue::Type::INT64:
605 option.set_value(static_cast<int>(kvp->get<int64_t>()));
606 break;
607 case KvpValue::Type::STRING:
608 fill_option_from_string_kvp(option, kvp);
609 break;
610 case KvpValue::Type::GUID:
611 fill_option_from_guid_kvp(option, kvp);
612 break;
613 case KvpValue::Type::FRAME:
614 if (g_strcmp0(option.get_name().c_str(), date_format_frame_key) == 0)
615 fill_option_from_date_format_kvp(option, kvp);
616 break;
617 default:
618 return;
619 break;
620 }
621 });
622 });
623}
KvpValue * qof_book_get_option(QofBook *book, GSList *path)
Read a single option value.
Definition qofbook.cpp:1392

◆ load_option_key_value()

std::istream & GncOptionDB::load_option_key_value ( std::istream &  iss)

Definition at line 289 of file gnc-optiondb.cpp.

290{
291
292 char section[classifier_size_max], name[classifier_size_max];
293 iss.getline(section, classifier_size_max, ':');
294 iss.getline(name, classifier_size_max, '=');
295 if (!iss)
296 throw std::invalid_argument("Section or name delimiter not found or values too long");
297 auto option = find_option(section, name);
298 if (!option)
299 iss.ignore(stream_max, ';');
300 else
301 {
302 std::string value;
303 std::getline(iss, value, ';');
304 std::istringstream item_iss{value};
305 item_iss >> *option;
306 }
307 return iss;
308}

◆ lookup_string_option()

std::string GncOptionDB::lookup_string_option ( const char *  section,
const char *  name 
)

Definition at line 255 of file gnc-optiondb.cpp.

256{
257 static const std::string empty_string{};
258
259 auto db_opt = find_option(section, name);
260 if (!db_opt)
261 return empty_string;
262 return db_opt->get_value<std::string>();
263}

◆ make_internal() [1/11]

template<typename ValueType >
void GncOptionValue< ValueType >::make_internal ( )
inline

Definition at line 110 of file gnc-option-impl.hpp.

110{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [2/11]

void GncOptionGncOwnerValue::make_internal ( )
inline

Definition at line 156 of file gnc-option-impl.hpp.

156{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [3/11]

void GncOptionQofInstanceValue::make_internal ( )
inline

Definition at line 196 of file gnc-option-impl.hpp.

196{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [4/11]

void GncOptionCommodityValue::make_internal ( )
inline

Definition at line 247 of file gnc-option-impl.hpp.

247{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [5/11]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::make_internal ( )
inline

Definition at line 451 of file gnc-option-impl.hpp.

451{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [6/11]

void GncOptionMultichoiceValue::make_internal ( )
inline

Definition at line 719 of file gnc-option-impl.hpp.

719{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [7/11]

void GncOptionAccountListValue::make_internal ( )
inline

Definition at line 878 of file gnc-option-impl.hpp.

878{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [8/11]

void GncOptionAccountSelValue::make_internal ( )
inline

Definition at line 998 of file gnc-option-impl.hpp.

998{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [9/11]

void GncOptionDateValue::make_internal ( )
inline

Definition at line 1152 of file gnc-option-impl.hpp.

1152{ m_ui_type = GncOptionUIType::INTERNAL; }

◆ make_internal() [10/11]

void GncOption::make_internal ( )

Definition at line 276 of file gnc-option.cpp.

277{
278 if (m_ui_item)
279 {
280 PERR("Option %s:%s has a UI Element, can't be INTERNAL.",
281 get_section().c_str(), get_name().c_str());
282 return;
283 }
284 std::visit([](auto& option) {
285 option.make_internal();
286 }, *m_option);
287}
#define PERR(format, args...)
Log a serious error.
Definition qoflog.h:244

◆ make_internal() [11/11]

void GncOptionDB::make_internal ( const char *  section,
const char *  name 
)

Definition at line 266 of file gnc-optiondb.cpp.

267{
268
269 auto db_opt = find_option(section, name);
270 if (db_opt)
271 db_opt->make_internal();
272}

◆ mark_saved() [1/10]

template<typename ValueType >
void GncOptionValue< ValueType >::mark_saved ( )
inlinenoexcept

Definition at line 106 of file gnc-option-impl.hpp.

106{ m_dirty = false; }

◆ mark_saved() [2/10]

void GncOptionGncOwnerValue::mark_saved ( )
inlinenoexcept

Definition at line 152 of file gnc-option-impl.hpp.

152{ m_dirty = false; }

◆ mark_saved() [3/10]

void GncOptionQofInstanceValue::mark_saved ( )
inlinenoexcept

Definition at line 192 of file gnc-option-impl.hpp.

192{ m_dirty = false; }

◆ mark_saved() [4/10]

void GncOptionCommodityValue::mark_saved ( )
inlinenoexcept

Definition at line 243 of file gnc-option-impl.hpp.

243{ m_dirty = false; }

◆ mark_saved() [5/10]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::mark_saved ( )
inlinenoexcept

Definition at line 447 of file gnc-option-impl.hpp.

447{ m_dirty = false; }

◆ mark_saved() [6/10]

void GncOptionMultichoiceValue::mark_saved ( )
inlinenoexcept

Definition at line 715 of file gnc-option-impl.hpp.

715{ m_dirty = false; }

◆ mark_saved() [7/10]

void GncOptionAccountListValue::mark_saved ( )
inlinenoexcept

Definition at line 874 of file gnc-option-impl.hpp.

874{ m_dirty = false; }

◆ mark_saved() [8/10]

void GncOptionAccountSelValue::mark_saved ( )
inlinenoexcept

Definition at line 994 of file gnc-option-impl.hpp.

994{ m_dirty = false; }

◆ mark_saved() [9/10]

void GncOptionDateValue::mark_saved ( )
inlinenoexcept

Definition at line 1147 of file gnc-option-impl.hpp.

1147{ m_dirty = false; }

◆ mark_saved() [10/10]

void GncOption::mark_saved ( )
noexcept

Mark the option as needing to be saved.

Definition at line 298 of file gnc-option.cpp.

299{
300 std::visit([](auto& option)->void {
301 option.mark_saved();
302 }, *m_option);
303}

◆ num_permissible_values() [1/3]

std::uint16_t GncOption::num_permissible_values ( ) const

Implemented only for GncOptionMultiselectValue.

Definition at line 356 of file gnc-option.cpp.

357{
358 return std::visit(
359 [] (const auto& option) -> uint16_t {
360 if constexpr (is_same_decayed_v<decltype(option),
362 is_same_decayed_v<decltype(option),
364 return option.num_permissible_values();
365 else
366 return uint16_t_max;
367 }, *m_option);
368}

◆ num_permissible_values() [2/3]

uint16_t GncOptionMultichoiceValue::num_permissible_values ( ) const
inlinenoexcept

Definition at line 698 of file gnc-option-impl.hpp.

699 {
700 return m_choices.size();
701 }

◆ num_permissible_values() [3/3]

uint16_t GncOptionDateValue::num_permissible_values ( ) const
inlinenoexcept

Definition at line 1130 of file gnc-option-impl.hpp.

1131 {
1132 return m_period_set.size();
1133 }

◆ num_sections()

size_t GncOptionDB::num_sections ( ) const
inlinenoexcept

Definition at line 127 of file gnc-optiondb-impl.hpp.

127{ return m_sections.size(); }

◆ operator()()

void GncOwnerDeleter::operator() ( GncOwner o)
inline

Definition at line 130 of file gnc-option-impl.hpp.

130 {
131 g_free(o);
132 }

◆ out_stream()

std::ostream & GncOptionDateValue::out_stream ( std::ostream &  oss) const
noexcept

Definition at line 617 of file gnc-option-impl.cpp.

618{
619 if (m_period == RelativeDatePeriod::ABSOLUTE)
620 oss << date_type_str[0] << " . " << m_date;
621 else
622 oss << date_type_str[1] << " . " <<
624 return oss;
625}
const char * gnc_relative_date_storage_string(RelativeDatePeriod per)
Provide the string representation of a relative date for persisting the value.

◆ permissible_value() [1/3]

const char * GncOptionMultichoiceValue::permissible_value ( uint16_t  index) const
inline

Definition at line 706 of file gnc-option-impl.hpp.

707 {
708 return std::get<0>(m_choices.at(index)).c_str();
709 }

◆ permissible_value() [2/3]

const char * GncOptionDateValue::permissible_value ( uint16_t  index) const
inline

Definition at line 1135 of file gnc-option-impl.hpp.

1136 {
1137 return gnc_relative_date_storage_string(m_period_set.at(index));
1138 }

◆ permissible_value() [3/3]

const char * GncOption::permissible_value ( uint16_t  index) const

Implemented only for GncOptionMultiselectValue.

Definition at line 386 of file gnc-option.cpp.

387{
388 return std::visit([index] (const auto& option) -> const char* {
389 if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
391 std::is_same_v<std::decay_t<decltype(option)>,
393 return option.permissible_value(index);
394 else
395 return "";
396 }, *m_option);
397}

◆ permissible_value_index() [1/3]

uint16_t GncOptionMultichoiceValue::permissible_value_index ( const char *  key) const
inlinenoexcept

Definition at line 702 of file gnc-option-impl.hpp.

703 {
704 return find_key(key);
705 }

◆ permissible_value_index() [2/3]

uint16_t GncOptionDateValue::permissible_value_index ( const char *  key) const
noexcept

Definition at line 604 of file gnc-option-impl.cpp.

605{
606 auto index = std::find_if(m_period_set.begin(), m_period_set.end(),
607 [key](auto period) -> bool {
608 return strcmp(gnc_relative_date_display_string(period),
609 key) == 0;
610 });
611 return index != m_period_set.end() ? index - m_period_set.begin() : 0;
612}

◆ permissible_value_index() [3/3]

std::uint16_t GncOption::permissible_value_index ( const char *  value) const

Implemented only for GncOptionMultiselectValue.

Definition at line 371 of file gnc-option.cpp.

372{
373 return std::visit(
374 [&value] (const auto& option) -> uint16_t {
375 if constexpr (is_same_decayed_v<decltype(option),
377 is_same_decayed_v<decltype(option),
379 return option.permissible_value_index(value);
380 else
381 return uint16_t_max;
382 }, *m_option);
383}

◆ permissible_value_name() [1/3]

const char * GncOptionMultichoiceValue::permissible_value_name ( uint16_t  index) const
inline

Definition at line 710 of file gnc-option-impl.hpp.

711 {
712 return std::get<1>(m_choices.at(index)).c_str();
713 }

◆ permissible_value_name() [2/3]

const char * GncOptionDateValue::permissible_value_name ( uint16_t  index) const
inline

Definition at line 1139 of file gnc-option-impl.hpp.

1140 {
1141 return gnc_relative_date_display_string(m_period_set.at(index));
1142 }
const char * gnc_relative_date_display_string(RelativeDatePeriod per)
Provide the string representation of a relative date for displaying value to a user.

◆ permissible_value_name() [3/3]

const char * GncOption::permissible_value_name ( uint16_t  index) const

Implemented only for GncOptionMultiselectValue.

Definition at line 400 of file gnc-option.cpp.

401{
402 return std::visit([index] (const auto& option) -> const char* {
403 if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
405 std::is_same_v<std::decay_t<decltype(option)>,
407 return option.permissible_value_name(index);
408 else
409 return "";
410 }, *m_option);
411}

◆ register_callback()

size_t GncOptionDB::register_callback ( GncOptionDBChangeCallback  cb,
void *  data 
)

Definition at line 349 of file gnc-optiondb.cpp.

350{
351 constexpr std::hash<GncOptionDBChangeCallback> cb_hash;
352 auto id{cb_hash(cb)};
353 if (std::find_if(m_callbacks.begin(), m_callbacks.end(),
354 [id](auto&cb)->bool{ return cb.m_id == id; }) == m_callbacks.end())
355 m_callbacks.emplace_back(id, cb, data);
356 return id;
357}

◆ register_option() [1/2]

void GncOptionDB::register_option ( const char *  section,
GncOption &&  option 
)

Definition at line 181 of file gnc-optiondb.cpp.

182{
183 auto section = find_section(sectname);
184
185 if (section)
186 {
187 section->add_option(std::move(option));
188 return;
189 }
190
191 m_sections.push_back(std::make_shared<GncOptionSection>(sectname));
192 m_sections.back()->add_option(std::move(option));
193 if (!std::is_sorted(m_sections.begin(), m_sections.end()))
194 std::sort(m_sections.begin(), m_sections.end());
195}

◆ register_option() [2/2]

void GncOptionDB::register_option ( const char *  section,
GncOption option 
)

Definition at line 198 of file gnc-optiondb.cpp.

199{
200 register_option(sectname, std::move(*option));
201 delete option;
202}

◆ remove_option()

void GncOptionSection::remove_option ( const char *  name)

Definition at line 151 of file gnc-optiondb.cpp.

152{
153 m_options.erase(std::remove_if(m_options.begin(), m_options.end(),
154 [name](const auto& option) -> bool
155 {
156 return option.get_name() == name;
157 }), m_options.end());
158}

◆ reset_default_value() [1/10]

template<typename ValueType >
template void GncOptionValue< ValueType >::reset_default_value ( )

Definition at line 746 of file gnc-option-impl.cpp.

747{
748 m_value = m_default_value;
749}

◆ reset_default_value() [2/10]

void GncOptionGncOwnerValue::reset_default_value ( )

Definition at line 106 of file gnc-option-impl.cpp.

107{
108 gncOwnerCopy(m_default_value.get(), m_value.get());
109}

◆ reset_default_value() [3/10]

void GncOptionQofInstanceValue::reset_default_value ( )

Definition at line 226 of file gnc-option-impl.cpp.

227{
228 m_value = m_default_value;
229}

◆ reset_default_value() [4/10]

void GncOptionCommodityValue::reset_default_value ( )

Definition at line 329 of file gnc-option-impl.cpp.

330{
331 m_mnemonic = m_default_mnemonic;
332 m_namespace = m_default_namespace;
333}

◆ reset_default_value() [5/10]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::reset_default_value ( )
inline

Definition at line 446 of file gnc-option-impl.hpp.

446{ m_value = m_default_value; }

◆ reset_default_value() [6/10]

void GncOptionMultichoiceValue::reset_default_value ( )
inline

Definition at line 714 of file gnc-option-impl.hpp.

714{ m_value = m_default_value; }

◆ reset_default_value() [7/10]

void GncOptionAccountListValue::reset_default_value ( )
inline

Definition at line 873 of file gnc-option-impl.hpp.

873{ m_value = m_default_value; }

◆ reset_default_value() [8/10]

void GncOptionAccountSelValue::reset_default_value ( )
inline

Definition at line 993 of file gnc-option-impl.hpp.

993{ m_value = m_default_value; }

◆ reset_default_value() [9/10]

void GncOptionDateValue::reset_default_value ( )
inline

Definition at line 1143 of file gnc-option-impl.hpp.

1143 {
1144 m_period = m_default_period;
1145 m_date = m_default_date;
1146 }

◆ reset_default_value() [10/10]

void GncOption::reset_default_value ( )

Definition at line 171 of file gnc-option.cpp.

172{
173 std::visit([](auto& option) { option.reset_default_value(); }, *m_option);
174}

◆ run_callbacks()

void GncOptionDB::run_callbacks ( )

Definition at line 368 of file gnc-optiondb.cpp.

369{
370 std::for_each(m_callbacks.begin(), m_callbacks.end(),
371 [](auto& cb)->void { cb.m_func(cb.m_data); });
372}

◆ save_option_key_value()

std::ostream & GncOptionDB::save_option_key_value ( std::ostream &  oss,
const std::string &  section,
const std::string &  name 
) const
noexcept

Definition at line 275 of file gnc-optiondb.cpp.

278{
279
280 auto db_opt = find_option(section, name.c_str());
281 if (!db_opt || !db_opt->is_changed())
282 return oss;
283 oss << section.substr(0, classifier_size_max) << ":" <<
284 name.substr(0, classifier_size_max) << "=" << *db_opt << ";";
285 return oss;
286}

◆ save_to_key_value()

std::ostream & GncOptionDB::save_to_key_value ( std::ostream &  oss) const
noexcept

Definition at line 311 of file gnc-optiondb.cpp.

312{
313
314 foreach_section(
315 [&oss](const GncOptionSectionPtr& section)
316 {
317 oss << "[Options]\n";
318 section->foreach_option(
319 [&oss, &section](auto& option)
320 {
321 if (option.is_changed())
322 oss << section->get_name().substr(0, classifier_size_max) <<
323 ':' << option.get_name().substr(0, classifier_size_max) <<
324 '=' << option << '\n';
325 });
326 });
327 return oss;
328}

◆ save_to_kvp()

void GncOptionDB::save_to_kvp ( QofBook book,
bool  clear_book 
) const
noexcept

Definition at line 465 of file gnc-optiondb.cpp.

466{
467 if (clear_options)
468 qof_book_options_delete(book, nullptr);
469 const_cast<GncOptionDB*>(this)->foreach_section(
470 [book](GncOptionSectionPtr& section)
471 {
472 section->foreach_option(
473 [book, &section](GncOption& option) {
474 if (option.is_dirty())
475 {
476 /* We need the string name out here so that it stays in
477 * scope long enough to pass its c_str to
478 * gnc_book_set_option. */
479 std::string name;
480 /* qof_book_set_option wants a GSList path. Let's avoid
481 * allocating and make one here. */
482 GSList list_tail{}, list_head{nullptr, &list_tail};
483 if (strcmp(section->get_name().c_str(), "Counters") == 0)
484 counter_option_path(option, &list_head, name);
485 else
486 option_path(option, &list_head);
487 auto type{option.get_ui_type()};
488 KvpValue* kvp{};
489 if (type == GncOptionUIType::BOOLEAN)
490 kvp = kvp_value_from_bool_option(option);
491 else if (is_qofinstance_ui_type(type))
492 kvp = kvp_value_from_qof_instance_option(option);
493 else if (type == GncOptionUIType::NUMBER_RANGE)
494 {
495 if (option.is_alternate())
496 {
497 kvp = new KvpValue(static_cast<int64_t>(option.template get_value<int>()));
498 }
499 else
500 {
501 kvp = new KvpValue(option.template get_value<double>());
502 }
503 }
504 else if (type == GncOptionUIType::DATE_FORMAT)
505 kvp = kvp_frame_from_date_format_option(option);
506 else
507 {
508 auto str{option.template get_value<std::string>()};
509 kvp = new KvpValue{g_strdup(str.c_str())};
510 }
511 qof_book_set_option(book, kvp, &list_head);
512 option.mark_saved();
513 }
514 });
515 });
516}
void qof_book_set_option(QofBook *book, KvpValue *value, GSList *path)
Save a single option value.
Definition qofbook.cpp:1379
void qof_book_options_delete(QofBook *book, GSList *path)
Delete the options.
Definition qofbook.cpp:1399
void mark_saved() noexcept
Mark the option as needing to be saved.
bool is_dirty() const noexcept

◆ serialize() [1/10]

std::string GncOption::serialize ( ) const

Get a string suitable for storage representing the option's value.

Returns
a std::string

Definition at line 445 of file gnc-option.cpp.

446{
447 if (m_option->valueless_by_exception())
448 return "Valueless Option";
449 return std::visit([&](auto& option) -> std::string {
450 return option.serialize();
451 }, *m_option);
452}

◆ serialize() [2/10]

template<typename ValueType >
template std::string GncOptionValue< ValueType >::serialize ( ) const
noexcept

Definition at line 757 of file gnc-option-impl.cpp.

758{
759 static const std::string no_value{"No Value"};
760 if constexpr(std::is_same_v<ValueType, const QofInstance*>)
761 return m_value ? qof_instance_to_string(m_value) : no_value;
762 if constexpr(std::is_same_v<ValueType, const GncOwner*>)
763 {
764 if (!m_value)
765 return no_value;
766 auto guid{qof_instance_to_string(qofOwnerGetOwner(m_value))};
767 auto type{qofOwnerGetType(m_value)};
768 std::ostringstream ostr{};
769 ostr << type << " " << guid;
770 return ostr.str();
771 }
772 if constexpr(std::is_same_v<ValueType, GncOptionReportPlacementVec>)
773 {
774 std::ostringstream ostr{};
775 ostr << "'(";
776 std::for_each(m_value.begin(), m_value.end(),
777 [&ostr](auto rp){
778 auto [id, wide, high] = rp;
779 ostr << "(" << id << " " << wide << " " << high << " #f) ";
780 });
781 ostr << ")";
782 return ostr.str();
783 }
784 else if constexpr(is_same_decayed_v<ValueType, std::string>)
785 return m_value;
786 else if constexpr(is_same_decayed_v<ValueType, bool>)
787 return m_value ? "True" : "False";
788 else if constexpr(std::is_arithmetic_v<ValueType>)
789 return std::to_string(m_value);
790 else
791 return "Serialization not implemented";
792}
QofIdTypeConst qofOwnerGetType(const GncOwner *owner)
return the type for the collection.
Definition gncOwner.c:230
QofInstance * qofOwnerGetOwner(const GncOwner *owner)
return the owner itself as an entity.
Definition gncOwner.c:275

◆ serialize() [3/10]

std::string GncOptionGncOwnerValue::serialize ( ) const
noexcept

Definition at line 140 of file gnc-option-impl.cpp.

141{
142
143 auto owner{m_value.get()};
144 gnc::GUID guid{*qof_instance_get_guid(static_cast<QofInstance*>(owner->owner.undefined))};
145 std::string retval{guid.to_string()};
146
147 return retval;
148}
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.

◆ serialize() [4/10]

std::string GncOptionQofInstanceValue::serialize ( ) const
noexcept

Definition at line 259 of file gnc-option-impl.cpp.

260{
261 auto inst{get_value()};
262 std::string retval;
263 if (GNC_IS_COMMODITY(inst))
264 {
265 auto commodity{GNC_COMMODITY(inst)};
266 if (!gnc_commodity_is_currency(commodity))
267 {
268 auto name_space{gnc_commodity_get_namespace(GNC_COMMODITY(inst))};
269 if (name_space && *name_space != '\0')
270 {
271 retval = name_space;
272 retval += ":";
273 }
274 }
275 retval += gnc_commodity_get_mnemonic(GNC_COMMODITY(inst));
276 return retval;
277 }
278 else
279 {
280 gnc::GUID guid{m_value.second};
281 retval = guid.to_string();
282 }
283 return retval;
284}
gboolean gnc_commodity_is_currency(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency.

◆ serialize() [5/10]

std::string GncOptionCommodityValue::serialize ( ) const
noexcept

Definition at line 352 of file gnc-option-impl.cpp.

353{
354 if (m_is_currency)
355 return m_mnemonic;
356 else
357 return m_namespace + ":" + m_mnemonic;
358}

◆ serialize() [6/10]

template<typename ValueType >
template std::string GncOptionRangeValue< ValueType >::serialize ( ) const
noexcept

Definition at line 943 of file gnc-option-impl.cpp.

944{
945 if constexpr (std::is_arithmetic_v<ValueType>)
946 {
947 std::ostringstream ostr;
948 if constexpr(is_same_decayed_v<ValueType, double>)
949 ostr << std::showpoint << std::fixed;
950 ostr << m_value;
951 return ostr.str();
952 }
953 return "";
954}

◆ serialize() [7/10]

std::string GncOptionMultichoiceValue::serialize ( ) const
noexcept

Definition at line 896 of file gnc-option-impl.cpp.

897{
898 static const std::string no_value{""};
899 std::string retval;
900 bool first = true;
901 bool list_context = m_ui_type == GncOptionUIType::LIST;
902 if (m_value.empty())
903 return no_value;
904
905 if (list_context)
906 retval += '(';
907 for (auto index : m_value)
908 {
909 if (!first)
910 retval += " ";
911 first = false;
912 retval += std::get<0>(m_choices[index]);
913 }
914 if (list_context)
915 retval += ')';
916 return retval;
917}

◆ serialize() [8/10]

std::string GncOptionAccountListValue::serialize ( ) const
noexcept

Definition at line 835 of file gnc-option-impl.cpp.

836{
837 static const std::string no_value{"No Value"};
838 std::string retval;
839 bool first = true;
840 if (m_value.empty())
841 return no_value;
842 gchar guidstr[GUID_ENCODING_LENGTH + 1];
843 for (auto val : m_value)
844 {
845 if (!first)
846 retval += " ";
847 first = false;
848 guid_to_string_buff (&val, guidstr);
849 retval += guidstr;
850 }
851 return retval;
852}
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Definition guid.cpp:208

◆ serialize() [9/10]

std::string GncOptionAccountSelValue::serialize ( ) const
noexcept

Definition at line 877 of file gnc-option-impl.cpp.

878{
879 static const std::string no_value{"No Value"};
880 if (guid_equal(guid_null(), &m_value))
881 return no_value;
882
883 gchar strbuff[GUID_ENCODING_LENGTH + 1];
884 guid_to_string_buff (&m_value, strbuff);
885 return strbuff;
886}

◆ serialize() [10/10]

std::string GncOptionDateValue::serialize ( ) const
noexcept

Definition at line 967 of file gnc-option-impl.cpp.

968{
969 std::string retval{"("};
970 if (m_period == RelativeDatePeriod::ABSOLUTE)
971 {
972 retval += date_type_str[0];
973 retval += " . ";
974 retval += std::to_string(m_date);
975 }
976 else
977 {
978 retval += date_type_str[1];
979 retval += " . ";
980 retval += gnc_relative_date_storage_string(m_period);
981 }
982 retval += ")";
983 return retval;
984}

◆ set_alternate() [1/2]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::set_alternate ( bool  value)
inlinenoexcept

Definition at line 454 of file gnc-option-impl.hpp.

454{ m_alternate = value; }

◆ set_alternate() [2/2]

void GncOption::set_alternate ( bool  alt)
noexcept

Definition at line 436 of file gnc-option.cpp.

437{
438 std::visit([alt](auto& option) {
439 if constexpr(is_RangeValue_v<decltype(option)>)
440 option.set_alternate(alt);
441 }, *m_option);
442}

◆ set_default_multiple()

void GncOptionMultichoiceValue::set_default_multiple ( const GncMultichoiceOptionIndexVec &  indexes)
inline

Definition at line 691 of file gnc-option-impl.hpp.

692 {
693 if (validate(indexes))
694 m_value = m_default_value = indexes;
695 else
696 throw std::invalid_argument("One of the supplied indexes was out of range.");
697 }

◆ set_default_section()

void GncOptionDB::set_default_section ( const char *  section)

Definition at line 213 of file gnc-optiondb.cpp.

214{
215 m_default_section = find_section(sectname);
216}

◆ set_default_value() [1/12]

void GncOptionAccountSelValue::set_default_value ( const Account value)
inline

Definition at line 984 of file gnc-option-impl.hpp.

984 {
985 if (validate(value))
986 {
987 auto guid{qof_entity_get_guid(value)};
988 m_value = m_default_value = *guid;
989 }
990 //else throw
991 }

◆ set_default_value() [2/12]

void GncOptionGncOwnerValue::set_default_value ( const GncOwner new_value)

Definition at line 87 of file gnc-option-impl.cpp.

88{
89 m_value.reset(make_owner_ptr(new_value));
90 m_default_value.reset(make_owner_ptr(new_value));
91}

◆ set_default_value() [3/12]

void GncOptionQofInstanceValue::set_default_value ( const QofInstance new_value)

Definition at line 207 of file gnc-option-impl.cpp.

208{
209 m_value = m_default_value = make_gnc_item(new_value);
210
211}

◆ set_default_value() [4/12]

void GncOptionMultichoiceValue::set_default_value ( const std::string &  value)
inline

Definition at line 657 of file gnc-option-impl.hpp.

658 {
659 auto index = find_key(value);
660 if (index != uint16_t_max)
661 {
662 m_value.clear();
663 m_value.push_back(index);
664 m_default_value.clear();
665 m_default_value.push_back(index);
666 }
667 else
668 throw std::invalid_argument("Value not a valid choice.");
669
670 }

◆ set_default_value() [5/12]

void GncOptionCommodityValue::set_default_value ( gnc_commodity *  value)

Definition at line 320 of file gnc-option-impl.cpp.

321{
322 if (!validate(value))
323 throw std::invalid_argument("Value not a currency when required or not a commodity. Value not set.");
324 m_mnemonic = m_default_mnemonic = gnc_commodity_get_mnemonic(value);
325 m_namespace = m_default_namespace = gnc_commodity_get_namespace(value);
326}

◆ set_default_value() [6/12]

void GncOptionAccountListValue::set_default_value ( GncOptionAccountList  values)
inline

Definition at line 867 of file gnc-option-impl.hpp.

867 {
868 if (validate(values))
869 //throw!
870 m_value = m_default_value = values;
871 }

◆ set_default_value() [7/12]

void GncOptionDateValue::set_default_value ( RelativeDatePeriod  value)
inline

Definition at line 1116 of file gnc-option-impl.hpp.

1116 {
1117 if (validate(value))
1118 {
1119 m_period = m_default_period = value;
1120 m_date = m_default_date = INT64_MAX;
1121 }
1122 }

◆ set_default_value() [8/12]

void GncOptionDateValue::set_default_value ( time64  time)
inline

Definition at line 1123 of file gnc-option-impl.hpp.

1123 {
1124 if (validate(time))
1125 {
1126 m_period = m_default_period = RelativeDatePeriod::ABSOLUTE;
1127 m_date = m_default_date = time;
1128 }
1129 }

◆ set_default_value() [9/12]

void GncOptionMultichoiceValue::set_default_value ( uint16_t  index)
inline

Definition at line 671 of file gnc-option-impl.hpp.

672 {
673 if (index < m_choices.size())
674 {
675 m_value.clear();
676 m_value.push_back(index);
677 m_default_value.clear();
678 m_default_value.push_back(index);
679 }
680 else
681 throw std::invalid_argument("Value not a valid choice.");
682
683 }

◆ set_default_value() [10/12]

template<typename ValueType >
template void GncOptionValue< ValueType >::set_default_value ( ValueType  new_value)

Definition at line 740 of file gnc-option-impl.cpp.

741{
742 m_value = m_default_value = new_value;
743}

◆ set_default_value() [11/12]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::set_default_value ( ValueType  value)
inline

Definition at line 433 of file gnc-option-impl.hpp.

434 {
435 if (this->validate(value))
436 m_value = m_default_value = value;
437 else
438 throw std::invalid_argument("Validation failed, value not set.");
439 }

◆ set_default_value() [12/12]

template<typename ValueType >
template void GncOption::set_default_value ( ValueType  value)

Definition at line 144 of file gnc-option.cpp.

145{
146 std::visit(
147 [value](auto& option) {
148 if constexpr
149 (is_same_decayed_v<decltype(option.get_value()), ValueType>||
150 is_same_decayed_v<decltype(option), GncOptionDateFormat> ||
151 (is_same_decayed_v<decltype(option), GncOptionDateValue> &&
152 (is_same_decayed_v<ValueType, RelativeDatePeriod> ||
153 std::is_same_v<ValueType, time64> ||
154 std::is_same_v<ValueType, uint16_t>)))
155 option.set_default_value(value);
156 if constexpr (is_same_decayed_v<decltype(option),
158 {
159 if constexpr (is_same_decayed_v<ValueType,
160 GncMultichoiceOptionIndexVec>)
161 option.set_default_multiple(value);
162 else if constexpr
163 (std::is_same_v<ValueType, uint16_t> ||
164 is_same_decayed_v<ValueType, std::string> ||
165 std::is_same_v<std::remove_cv<ValueType>, char*>)
166 option.set_default_value(value);
167 }
168 }, *m_option);
169}

◆ set_multiple()

void GncOptionMultichoiceValue::set_multiple ( const GncMultichoiceOptionIndexVec &  indexes)
inline

Definition at line 684 of file gnc-option-impl.hpp.

685 {
686 if (validate(indexes))
687 m_value = indexes;
688 else
689 throw std::invalid_argument("One of the supplied indexes was out of range.");
690 }

◆ set_option()

template<typename ValueType >
bool GncOptionDB::set_option ( const char *  section,
const char *  name,
ValueType  value 
)
inline

Definition at line 140 of file gnc-optiondb-impl.hpp.

141 {
142 try
143 {
144 auto option{find_option(section, name)};
145 if (!option)
146 return false;
147 option->set_value(value);
148 return true;
149 }
150 catch(const std::invalid_argument& err)
151 {
152 printf("Set Failed: %s\n", err.what());
153 return false;
154 }
155 }

◆ set_option_from_ui_item()

void GncOption::set_option_from_ui_item ( )

Definition at line 268 of file gnc-option.cpp.

269{
270 if (!m_ui_item)
271 return;
272 m_ui_item->set_option_from_ui_item(*this);
273}

◆ set_string_option()

bool GncOptionDB::set_string_option ( const char *  section,
const char *  name,
const std::string &  value 
)
inline

Definition at line 135 of file gnc-optiondb-impl.hpp.

136 {
137 return set_option<std::string>(section, name, value);
138 }

◆ set_ui_item()

void GncOption::set_ui_item ( GncOptionUIItemPtr &&  ui_elem)

Definition at line 220 of file gnc-option.cpp.

221{
222
223 auto opt_ui_type = std::visit([](const auto& option)->GncOptionUIType {
224 return option.get_ui_type();
225 }, *m_option);
226
227 //ui_item may be nullptr to free the old m_ui_item.
228 if (ui_item && ui_item->get_ui_type() != opt_ui_type)
229 {
230 PERR("Setting option %s:%s UI element failed, mismatched UI types.",
231 get_section().c_str(), get_name().c_str());
232 return;
233 }
234
235 m_ui_item = std::move(ui_item);
236}

◆ set_ui_item_from_option()

void GncOption::set_ui_item_from_option ( )

Definition at line 260 of file gnc-option.cpp.

261{
262 if (!m_ui_item)
263 return;
264 m_ui_item->set_ui_item_from_option(*this);
265}

◆ set_ui_item_selectable()

void GncOption::set_ui_item_selectable ( bool  selectable) const
noexcept

Definition at line 239 of file gnc-option.cpp.

240{
241 if (m_ui_item)
242 m_ui_item->set_selectable(selectable);
243}

◆ set_value() [1/13]

void GncOptionAccountSelValue::set_value ( const Account value)
inline

Definition at line 975 of file gnc-option-impl.hpp.

975 {
976 if (validate(value))
977 {
978 auto guid{qof_entity_get_guid(value)};
979 m_value = *guid;
980 m_dirty = true;
981 }
982 //else throw
983 }

◆ set_value() [2/13]

void GncOptionGncOwnerValue::set_value ( const GncOwner new_value)

Definition at line 80 of file gnc-option-impl.cpp.

81{
82 m_value.reset(make_owner_ptr(new_value));
83 m_dirty = true;
84}

◆ set_value() [3/13]

void GncOptionQofInstanceValue::set_value ( const QofInstance new_value)

Definition at line 200 of file gnc-option-impl.cpp.

201{
202 m_value = make_gnc_item(new_value);
203 m_dirty = true;
204}

◆ set_value() [4/13]

void GncOptionMultichoiceValue::set_value ( const std::string &  value)
inline

Definition at line 632 of file gnc-option-impl.hpp.

633 {
634 auto index = find_key(value);
635 if (index != uint16_t_max)
636 {
637 m_value.clear();
638 m_value.push_back(index);
639 m_dirty = true;
640 }
641 else
642 throw std::invalid_argument("Value not a valid choice.");
643
644 }

◆ set_value() [5/13]

void GncOptionCommodityValue::set_value ( gnc_commodity *  value)

Definition at line 310 of file gnc-option-impl.cpp.

311{
312 if (!validate(value))
313 throw std::invalid_argument("Value not a currency when required or not a commodity. Value not set.");
314 m_mnemonic = gnc_commodity_get_mnemonic(value);
315 m_namespace = gnc_commodity_get_namespace(value);
316 m_dirty = true;
317}

◆ set_value() [6/13]

void GncOptionAccountListValue::set_value ( GncOptionAccountList  values)
inline

Definition at line 859 of file gnc-option-impl.hpp.

859 {
860 if (validate(values))
861 {
862 //throw!
863 m_value = values;
864 m_dirty = true;
865 }
866 }

◆ set_value() [7/13]

void GncOptionDateValue::set_value ( RelativeDatePeriod  value)
inline

Definition at line 1099 of file gnc-option-impl.hpp.

1099 {
1100 if (validate(value))
1101 {
1102 m_period = value;
1103 m_date = INT64_MAX;
1104 m_dirty = true;
1105 }
1106 }

◆ set_value() [8/13]

void GncOptionDateValue::set_value ( time64  time)
inline

Definition at line 1107 of file gnc-option-impl.hpp.

1107 {
1108 if (validate(time))
1109 {
1110 m_period = RelativeDatePeriod::ABSOLUTE;
1111 m_date = time;
1112 m_dirty = true;
1113 }
1114 }

◆ set_value() [9/13]

void GncOptionMultichoiceValue::set_value ( uint16_t  index)
inline

Definition at line 645 of file gnc-option-impl.hpp.

646 {
647 if (index < m_choices.size())
648 {
649 m_value.clear();
650 m_value.push_back(index);
651 m_dirty = true;
652 }
653 else
654 throw std::invalid_argument("Value not a valid choice.");
655
656 }

◆ set_value() [10/13]

void GncOptionDateValue::set_value ( uint16_t  index)
noexcept

Definition at line 594 of file gnc-option-impl.cpp.

595{
596 assert(!m_period_set.empty());
597 assert(index < m_period_set.size());
598 m_date = INT64_MAX;
599 m_period = m_period_set[index];
600 m_dirty = true;
601}

◆ set_value() [11/13]

template<typename ValueType >
template void GncOptionValue< ValueType >::set_value ( ValueType  new_value)

Definition at line 733 of file gnc-option-impl.cpp.

734{
735 m_value = new_value;
736 m_dirty = true;
737}

◆ set_value() [12/13]

template<typename ValueType >
void GncOptionRangeValue< ValueType >::set_value ( ValueType  value)
inline

Definition at line 423 of file gnc-option-impl.hpp.

424 {
425 if (this->validate(value))
426 {
427 m_value = value;
428 m_dirty = true;
429 }
430 else
431 throw std::invalid_argument("Validation failed, value not set.");
432 }

◆ set_value() [13/13]

template<typename ValueType >
template void GncOption::set_value ( ValueType  value)

Definition at line 112 of file gnc-option.cpp.

113{
114 std::visit(
115 [value](auto& option) {
116 if constexpr
117 (is_same_decayed_v<decltype(option.get_value()), ValueType> ||
118 is_same_decayed_v<decltype(option), GncOptionDateFormat> ||
119 (is_same_decayed_v<decltype(option),
121 (is_same_decayed_v<ValueType, RelativeDatePeriod> ||
122 std::is_same_v<ValueType, time64> ||
123 std::is_same_v<ValueType, uint16_t>)))
124 option.set_value(value);
125 else if constexpr (is_same_decayed_v<decltype(option),
127 {
128 if constexpr (is_same_decayed_v<ValueType,
129 GncMultichoiceOptionIndexVec>)
130 option.set_multiple(value);
131 else if constexpr
132 (std::is_same_v<ValueType, uint16_t> ||
133 is_same_decayed_v<ValueType, std::string> ||
134 std::is_same_v<std::remove_cv<ValueType>, char*>)
135 option.set_value(value);
136 }
137 else
138 PWARN("No set_value handler: get_value returns %s, value_type is %s",
139 typeid(option.get_value()).name(), typeid(value).name());
140 }, *m_option);
141}

◆ set_widget_changed()

void GncOption::set_widget_changed ( std::any  cb)
inline

Definition at line 212 of file gnc-option.hpp.

212{ m_widget_changed = cb; }

◆ unregister_callback()

void GncOptionDB::unregister_callback ( size_t  id)

Definition at line 360 of file gnc-optiondb.cpp.

361{
362 m_callbacks.erase(std::remove_if(m_callbacks.begin(), m_callbacks.end(),
363 [id](auto& cb)->bool { return cb.m_id == id; }),
364 m_callbacks.end());
365}

◆ unregister_option()

void GncOptionDB::unregister_option ( const char *  section,
const char *  name 
)

Definition at line 205 of file gnc-optiondb.cpp.

206{
207 auto section = find_section(sectname);
208 if (section)
209 section->remove_option(name);
210}

◆ validate() [1/9]

bool GncOptionAccountSelValue::validate ( const Account value) const

Definition at line 473 of file gnc-option-impl.cpp.

474{
475 if (m_allowed.empty() || !value)
476 return true;
477 if (std::find(m_allowed.begin(), m_allowed.end(),
478 xaccAccountGetType(value)) == m_allowed.end())
479 return false;
480 return true;
481}

◆ validate() [2/9]

bool GncOptionMultichoiceValue::validate ( const GncMultichoiceOptionIndexVec &  indexes) const
inlinenoexcept

Definition at line 624 of file gnc-option-impl.hpp.

625 {
626 for (auto index : indexes)
627 if (index >= m_choices.size())
628 return false;
629 return true;
630
631 }

◆ validate() [3/9]

bool GncOptionAccountListValue::validate ( const GncOptionAccountList &  values) const

Definition at line 385 of file gnc-option-impl.cpp.

386{
387 if (values.empty())
388 return true;
389 if ((get_ui_type() == GncOptionUIType::ACCOUNT_SEL || !m_multiselect) &&
390 values.size() != 1)
391 {
392 PWARN("GncOptionAccountListValue::validate: Multiple values for a non-multiselect option.");
393 return false;
394 }
395 if (m_allowed.empty())
396 return true;
397 auto book{get_current_book()};
398 for(auto& guid : values)
399 {
400 if (std::find(m_allowed.begin(), m_allowed.end(),
401 xaccAccountGetType(xaccAccountLookup(&guid, book))) == m_allowed.end())
402 {
403 PWARN("GncOptionAccountListValue::validate: Account %s is not of an allowed type", gnc::GUID(guid).to_string().c_str());
404 return false; }
405 }
406 return true;
407}

◆ validate() [4/9]

bool GncOptionMultichoiceValue::validate ( const std::string &  value) const
inlinenoexcept

Definition at line 618 of file gnc-option-impl.hpp.

619 {
620 auto index = find_key(value);
621 return index != uint16_t_max;
622
623 }

◆ validate() [5/9]

bool GncOptionCommodityValue::validate ( gnc_commodity *  comm) const
noexcept

Definition at line 342 of file gnc-option-impl.cpp.

343{
344 if (!GNC_IS_COMMODITY(comm))
345 return false;
346 if (m_is_currency && !gnc_commodity_is_currency(comm))
347 return false;
348 return true;
349}

◆ validate() [6/9]

bool GncOptionDateValue::validate ( RelativeDatePeriod  value)

Definition at line 544 of file gnc-option-impl.cpp.

544 {
545 if (m_period_set.empty())
546 return true; // No restrictions
547 if (std::find(m_period_set.begin(), m_period_set.end(),
548 value) != m_period_set.end())
549 return true;
550 return false;
551}

◆ validate() [7/9]

bool GncOptionDateValue::validate ( time64  time)
inline

Definition at line 1094 of file gnc-option-impl.hpp.

1094 {
1095 if (time > MINTIME && time < MAXTIME)
1096 return true;
1097 return false;
1098 }

◆ validate() [8/9]

template<typename ValueType >
bool GncOptionRangeValue< ValueType >::validate ( ValueType  value)
inline

Definition at line 422 of file gnc-option-impl.hpp.

422{ return value >= m_min && value <= m_max; }

◆ validate() [9/9]

template<typename ValueType >
template bool GncOption::validate ( ValueType  value) const

Not implemented for GncOptionValue.

Definition at line 335 of file gnc-option.cpp.

336{
337 return std::visit(
338 [value] (const auto& option) -> bool {
339 if constexpr ((is_same_decayed_v<decltype(option),
341 is_same_decayed_v<ValueType, std::string>) ||
342 (is_same_decayed_v<decltype(option),
344 is_same_decayed_v<ValueType,
345 GncMultichoiceOptionIndexVec>) ||
346 (is_same_decayed_v<decltype(option),
348 is_same_decayed_v<ValueType, gnc_commodity*>))
349 return option.validate(value);
350 else
351 return false;
352 }, *m_option);
353}
class GncOptionCommodityValue Commodities are stored with their namespace and mnemonic instead of the...

◆ xaccAccountBeginStagedTransactionTraversals()

void xaccAccountBeginStagedTransactionTraversals ( const Account account)

xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which is a parent of one of the splits in the account.

Definition at line 5031 of file Account.cpp.

5032{
5033 if (!account)
5034 return;
5035 xaccSplitsBeginStagedTransactionTraversals(GET_PRIVATE (account)->splits);
5036}

◆ xaccAccountClearHigherBalanceLimit()

void xaccAccountClearHigherBalanceLimit ( Account account)

Clear the higher balance limit for the account.

Parameters
accountThe account to clear the limit on

Definition at line 4745 of file Account.cpp.

4746{
4747 set_balance_limit (acc, KEY_BALANCE_HIGHER_LIMIT_VALUE, {});
4748}

◆ xaccAccountClearLowerBalanceLimit()

void xaccAccountClearLowerBalanceLimit ( Account account)

Clear the lower balance limit for the account.

Parameters
accountThe account to clear the limit on

Definition at line 4751 of file Account.cpp.

4752{
4753 set_balance_limit (acc, KEY_BALANCE_LOWER_LIMIT_VALUE, {});
4754}

◆ xaccAccountClearReconcilePostpone()

void xaccAccountClearReconcilePostpone ( Account account)

DOCUMENT ME!

Definition at line 4674 of file Account.cpp.

4675{
4676 set_kvp_gnc_numeric_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE}, {});
4677}

◆ xaccAccountFindOpenLots()

LotList * xaccAccountFindOpenLots ( const Account acc,
gboolean(*)(GNCLot *lot, gpointer user_data)  match_func,
gpointer  user_data,
GCompareFunc  sort_func 
)

Find a list of open lots that match the match_func.

Sort according to sort_func. If match_func is NULL, then all open lots are returned. If sort_func is NULL, then the returned list has no particular order. The caller must free to returned list.

Definition at line 3982 of file Account.cpp.

3986{
3987 AccountPrivate *priv;
3988 GList *lot_list;
3989 GList *retval = nullptr;
3990
3991 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr);
3992
3993 priv = GET_PRIVATE(acc);
3994 for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
3995 {
3996 GNCLot *lot = static_cast<GNCLot*>(lot_list->data);
3997
3998 /* If this lot is closed, then ignore it */
3999 if (gnc_lot_is_closed (lot))
4000 continue;
4001
4002 if (match_func && !(match_func)(lot, user_data))
4003 continue;
4004
4005 /* Ok, this is a valid lot. Add it to our list of lots */
4006 retval = g_list_prepend (retval, lot);
4007 }
4008
4009 if (sort_func)
4010 retval = g_list_sort (retval, sort_func);
4011
4012 return retval;
4013}
gboolean gnc_lot_is_closed(GNCLot *lot)
Returns closed status of the given lot.
Definition gnc-lot.cpp:367

◆ xaccAccountFindSplitByDesc()

Split * xaccAccountFindSplitByDesc ( const Account account,
const char *  description 
)

Returns a pointer to the split, not a copy.

Definition at line 4908 of file Account.cpp.

4909{
4910 auto has_description = [description](const Split* s) -> bool
4911 { return !g_strcmp0 (description, xaccTransGetDescription (xaccSplitGetParent (s))); };
4912 return gnc_account_find_split (acc, has_description, true);
4913}
Split * gnc_account_find_split(const Account *acc, std::function< bool(const Split *)> predicate, bool reverse)
scans account split list (in forward or reverse order) until predicate split->bool returns true.
Definition Account.cpp:1167
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.

◆ xaccAccountFindTransByDesc()

Transaction * xaccAccountFindTransByDesc ( const Account account,
const char *  description 
)

Returns a pointer to the transaction, not a copy.

Definition at line 4921 of file Account.cpp.

4922{
4923 auto split = xaccAccountFindSplitByDesc (acc, description);
4924 return split ? xaccSplitGetParent (split) : nullptr;
4925}
Split * xaccAccountFindSplitByDesc(const Account *acc, const char *description)
Returns a pointer to the split, not a copy.
Definition Account.cpp:4908

◆ xaccAccountForEachLot()

gpointer xaccAccountForEachLot ( const Account acc,
gpointer(*)(GNCLot *lot, gpointer user_data)  proc,
gpointer  user_data 
)

The xaccAccountForEachLot() method will apply the function 'proc' to each lot in the account.

If 'proc' returns a non-NULL value, further application will be stopped, and the resulting value will be returned. There is no guaranteed order over which the Lots will be traversed.

◆ xaccAccountForEachTransaction()

gint xaccAccountForEachTransaction ( const Account account,
TransactionCallback  proc,
void *  data 
)

The xaccAccountForEachTransaction() routine will traverse all of the transactions in account and call the callback function proc on each transaction.

Processing will continue if-and-only-if proc returns 0. The user data pointer data will be passed on to the callback function proc.

This function does not descend recursively to traverse transactions in child accounts.

proc will be called exactly once for each transaction that is pointed to by at least one split in the given account.

The result of this function will be 0 if and only if every relevant transaction was traversed exactly once. Else the return value is the last non-zero value returned by proc.

Warning
For performance reasons, the transaction callback proc must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.
The traversal occurs only over the transactions that are locally cached in the local gnucash engine. If the gnucash engine is attached to a remote database, the database may contain (many) transactions that are not mirrored in the local cache. This routine will not cause an SQL database query to be performed; it will not traverse transactions present only in the remote database.

Definition at line 5150 of file Account.cpp.

5152{
5153 if (!acc || !proc) return 0;
5155 return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
5156}
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which ...
Definition Account.cpp:5031
int xaccAccountStagedTransactionTraversal(const Account *acc, unsigned int stage, TransactionCallback thunk, void *cb_data)
xaccAccountStagedTransactionTraversal() calls thunk on each transaction in account a whose current ma...
Definition Account.cpp:5062

◆ xaccAccountGetAppendText()

gboolean xaccAccountGetAppendText ( const Account account)

Get the "import-append-text" flag for an account.

This is the saved state of the Append checkbox in the "Generic import transaction matcher" used to set the initial state of the Append checkbox next time this account is imported.

Parameters
accountThe account whose flag should be retrieved.
Returns
The current state of the account's "import-append-text" flag.

Definition at line 4131 of file Account.cpp.

4132{
4133 return get_kvp_boolean_path(acc, {"import-append-text"});
4134}

◆ xaccAccountGetAutoInterest()

gboolean xaccAccountGetAutoInterest ( const Account acc)

Get the "auto interest" flag for an account.

If this flag is set then the account (and any children) will trigger an interest transfer after reconciling.

Parameters
accThe account whose flag should be retrieved.
Returns
The current state of the account's "auto interest" flag.

Definition at line 4175 of file Account.cpp.

4176{
4177 return get_kvp_boolean_path (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"});
4178}

◆ xaccAccountGetDescendantPlaceholder()

GNCPlaceholderType xaccAccountGetDescendantPlaceholder ( const Account account)

Returns PLACEHOLDER_NONE if account is NULL or neither account nor any descendant of account is a placeholder.

If account is a placeholder, returns PLACEHOLDER_THIS. Otherwise, if any descendant of account is a placeholder, return PLACEHOLDER_CHILD.

Definition at line 4162 of file Account.cpp.

4163{
4164 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
4165 if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
4166
4167 return gnc_account_foreach_descendant_until (acc, (AccountCb2)xaccAccountGetPlaceholder, nullptr)
4168 ? PLACEHOLDER_CHILD : PLACEHOLDER_NONE;
4169}
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition Account.cpp:4119

◆ xaccAccountGetHidden()

gboolean xaccAccountGetHidden ( const Account acc)

Get the "hidden" flag for an account.

If this flag is set then the account (and any children) will be hidden from the user unless they explicitly ask to see them.

Parameters
accThe account whose flag should be retrieved.
Returns
The current state of the account's "hidden" flag.

Definition at line 4190 of file Account.cpp.

4191{
4192 return get_kvp_boolean_path (acc, {"hidden"});
4193}

◆ xaccAccountGetHigherBalanceLimit()

gboolean xaccAccountGetHigherBalanceLimit ( const Account account,
gnc_numeric *  balance 
)

Get the higher balance limit for the account.

Parameters
accountThe account whose higher limit is to be retrieved
balanceThe placeholder to store the retrieved balance
Returns
True if the limit is valid.

Definition at line 4719 of file Account.cpp.

4721{
4722 return get_balance_limit (acc, KEY_BALANCE_HIGHER_LIMIT_VALUE, balance);
4723}

◆ xaccAccountGetIncludeSubAccountBalances()

gboolean xaccAccountGetIncludeSubAccountBalances ( const Account account)

Get whether to include balances of sub accounts.

Parameters
accountThe account to get setting on
Returns
TRUE to include, default is FALSE

Definition at line 4757 of file Account.cpp.

4758{
4759 return get_kvp_boolean_path (acc, {KEY_BALANCE_LIMIT, KEY_BALANCE_INCLUDE_SUB_ACCTS});
4760}

◆ xaccAccountGetIsOpeningBalance()

gboolean xaccAccountGetIsOpeningBalance ( const Account account)

Get the "opening-balance" flag for an account.

If this flag is set then the account is used for opening balance transactions.

Parameters
accountThe account whose flag should be retrieved.
Returns
The current state of the account's "opening-balance" flag.

Definition at line 4143 of file Account.cpp.

4144{
4145 g_return_val_if_fail (GNC_IS_ACCOUNT(acc), false);
4146 if (GET_PRIVATE(acc)->type != ACCT_TYPE_EQUITY)
4147 return false;
4148
4149 return !g_strcmp0 (get_kvp_string_path (acc, {"equity-type"}), "opening-balance");
4150}

◆ xaccAccountGetLotList()

LotList * xaccAccountGetLotList ( const Account account)

The xaccAccountGetLotList() routine returns a list of all lots in this account.

Parameters
accountThe account whose lots should be returned.
Returns
A GList of lot pointers, or NULL if there are no lots in this account children. It is the callers responsibility to free any returned list with the g_list_free() function.

Definition at line 3975 of file Account.cpp.

3976{
3977 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr);
3978 return g_list_copy(GET_PRIVATE(acc)->lots);
3979}

◆ xaccAccountGetLowerBalanceLimit()

gboolean xaccAccountGetLowerBalanceLimit ( const Account account,
gnc_numeric *  balance 
)

Get the lower balance limit for the account.

Parameters
accountThe account whose lower limit is to be retrieved
balanceThe placeholder to store the retrieved balance
Returns
True if the limit is valid.

Definition at line 4726 of file Account.cpp.

4728{
4729 return get_balance_limit (acc, KEY_BALANCE_LOWER_LIMIT_VALUE, balance);
4730}

◆ xaccAccountGetPlaceholder()

gboolean xaccAccountGetPlaceholder ( const Account account)

Get the "placeholder" flag for an account.

If this flag is set then the account may not be modified by the user.

Parameters
accountThe account whose flag should be retrieved.
Returns
The current state of the account's "placeholder" flag.

Definition at line 4119 of file Account.cpp.

4120{
4121 return get_kvp_boolean_path(acc, {"placeholder"});
4122}

◆ xaccAccountGetReconcileLastDate()

gboolean xaccAccountGetReconcileLastDate ( const Account account,
time64 last_date 
)

DOCUMENT ME!

Definition at line 4566 of file Account.cpp.

4567{
4568 gboolean retval = FALSE;
4569 auto date = get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-date"});
4570
4571 if (date)
4572 {
4573 if (last_date)
4574 *last_date = *date;
4575 retval = TRUE;
4576 }
4577 return retval;
4578}

◆ xaccAccountGetReconcileLastInterval()

gboolean xaccAccountGetReconcileLastInterval ( const Account account,
int *  months,
int *  days 
)

DOCUMENT ME!

Definition at line 4593 of file Account.cpp.

4595{
4596 if (!acc) return FALSE;
4597 auto m{get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "months"})};
4598 auto d{get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "days"})};
4599 if (m && d)
4600 {
4601 if (months)
4602 *months = *m;
4603 if (days)
4604 *days = *d;
4605 return true;
4606 }
4607 return false;
4608}

◆ xaccAccountGetReconcilePostponeBalance()

gboolean xaccAccountGetReconcilePostponeBalance ( const Account account,
gnc_numeric *  balance 
)

DOCUMENT ME!

Definition at line 4648 of file Account.cpp.

4650{
4651 if (auto bal = get_kvp_gnc_numeric_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"}))
4652 {
4653 if (balance)
4654 *balance = *bal;
4655 return true;
4656 }
4657 return false;
4658}

◆ xaccAccountGetReconcilePostponeDate()

gboolean xaccAccountGetReconcilePostponeDate ( const Account account,
time64 postpone_date 
)

DOCUMENT ME!

Definition at line 4624 of file Account.cpp.

4625{
4626 if (auto date = get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "date"}))
4627 {
4628 if (postpone_date)
4629 *postpone_date = *date;
4630 return true;
4631 }
4632 return false;
4633}

◆ xaccAccountGetSplitList()

SplitList * xaccAccountGetSplitList ( const Account account)

The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account.

Note
This GList is the account's internal data structure: do not delete it when done; treat it as a read-only structure. Note that some routines (such as xaccAccountRemoveSplit()) modify this list directly, and could leave you with a corrupted pointer.
This should be changed so that the returned value is a copy of the list. No other part of the code should have access to the internal data structure used by this object.

Definition at line 3949 of file Account.cpp.

3950{
3951 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr);
3952 auto priv{GET_PRIVATE(acc)};
3953 return std::accumulate (priv->splits.rbegin(), priv->splits.rend(),
3954 static_cast<GList*>(nullptr), g_list_prepend);
3955}

◆ xaccAccountGetSplitsSize()

size_t xaccAccountGetSplitsSize ( const Account account)

Definition at line 3958 of file Account.cpp.

3959{
3960 g_return_val_if_fail (GNC_IS_ACCOUNT(account), 0);
3961 return GNC_IS_ACCOUNT(account) ? GET_PRIVATE(account)->splits.size() : 0;
3962}

◆ xaccAccountGetTaxRelated()

gboolean xaccAccountGetTaxRelated ( const Account account)

DOCUMENT ME!

Definition at line 4035 of file Account.cpp.

4036{
4037 return get_kvp_boolean_path(acc, {"tax-related"});
4038}

◆ xaccAccountGetTaxUSCode()

const char * xaccAccountGetTaxUSCode ( const Account account)

DOCUMENT ME!

Definition at line 4047 of file Account.cpp.

4048{
4049 return get_kvp_string_path (acc, {"tax-US", "code"});
4050}

◆ xaccAccountGetTaxUSCopyNumber()

gint64 xaccAccountGetTaxUSCopyNumber ( const Account account)

Returns copy_number stored in KVP; if KVP doesn't exist or copy_number is zero, returns 1.

Definition at line 4071 of file Account.cpp.

4072{
4073 auto copy_number = get_kvp_int64_path (acc, {"tax-US", "copy-number"});
4074 return (copy_number && (*copy_number != 0)) ? *copy_number : 1;
4075}

◆ xaccAccountGetTaxUSPayerNameSource()

const char * xaccAccountGetTaxUSPayerNameSource ( const Account account)

DOCUMENT ME!

Definition at line 4059 of file Account.cpp.

4060{
4061 return get_kvp_string_path (acc, {"tax-US", "payer-name-source"});
4062}

◆ xaccAccountGetTypeStr()

const char * xaccAccountGetTypeStr ( GNCAccountType  type)

The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.

These strings should be translated to the local language.

Definition at line 4357 of file Account.cpp.

4358{
4359 if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
4360 return _(account_type_name [type]);
4361}
@ NUM_ACCOUNT_TYPES
stop here; the following types just aren't ready for prime time
Definition Account.h:161

◆ xaccAccountInsertLot()

void xaccAccountInsertLot ( Account acc,
GNCLot *  lot 
)

The xaccAccountInsertLot() method will register the indicated lot with this account.

Any splits later inserted into this lot must belong to this account. If the lot is already in another account, the lot, and all of the splits in it, will be moved from that account to this account.

Definition at line 2140 of file Account.cpp.

2141{
2142 /* errors */
2143 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2144 g_return_if_fail(GNC_IS_LOT(lot));
2145
2146 /* optimizations */
2147 auto lot_acc = gnc_lot_get_account(lot);
2148 if (lot_acc == acc)
2149 return;
2150
2151 ENTER ("(acc=%p, lot=%p)", acc, lot);
2152
2153 /* pull it out of the old account */
2154 if (lot_acc)
2155 {
2156 auto priv = GET_PRIVATE(lot_acc);
2157 priv->lots = g_list_remove(priv->lots, lot);
2158 qof_event_gen (&lot_acc->inst, QOF_EVENT_MODIFY, nullptr);
2159 }
2160
2161 auto priv = GET_PRIVATE(acc);
2162 priv->lots = g_list_prepend(priv->lots, lot);
2163 gnc_lot_set_account(lot, acc);
2164
2165 /* Don't move the splits to the new account. The caller will do this
2166 * if appropriate, and doing it here will not work if we are being
2167 * called from gnc_book_close_period since xaccAccountInsertSplit
2168 * will try to balance capital gains and things aren't ready for that. */
2169
2170 qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, nullptr);
2171 qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr);
2172
2173 LEAVE ("(acc=%p, lot=%p)", acc, lot);
2174}
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition qofevent.cpp:231
Account * gnc_lot_get_account(const GNCLot *lot)
Returns the account with which this lot is associated.
Definition gnc-lot.cpp:377

◆ xaccAccountIsAPARType()

gboolean xaccAccountIsAPARType ( GNCAccountType  t)

Convenience function to check if the account is a valid business account type (meaning an Accounts Payable/Accounts Receivable).

Definition at line 4527 of file Account.cpp.

4528{
4529 switch (t)
4530 {
4532 case ACCT_TYPE_PAYABLE:
4533 return TRUE;
4534 default:
4535 return FALSE;
4536 }
4537}
@ ACCT_TYPE_PAYABLE
A/P account type.
Definition Account.h:151
@ ACCT_TYPE_RECEIVABLE
A/R account type.
Definition Account.h:149

◆ xaccAccountIsAssetLiabType()

gboolean xaccAccountIsAssetLiabType ( GNCAccountType  t)

Convenience function to check if the account is a valid Asset or Liability type, but not a business account type (meaning not an Accounts Payable/Accounts Receivable).

Definition at line 4481 of file Account.cpp.

4482{
4483 switch (t)
4484 {
4486 case ACCT_TYPE_PAYABLE:
4487 return FALSE;
4488 default:
4489 return (xaccAccountTypesCompatible(ACCT_TYPE_ASSET, t)
4490 || xaccAccountTypesCompatible(ACCT_TYPE_LIABILITY, t));
4491 }
4492}
gboolean xaccAccountTypesCompatible(GNCAccountType parent_type, GNCAccountType child_type)
Return TRUE if accounts of type parent_type can have accounts of type child_type as children.
Definition Account.cpp:4454

◆ xaccAccountIsEquityType()

gboolean xaccAccountIsEquityType ( GNCAccountType  t)

Convenience function to check if the account is a valid Equity type.

Definition at line 4539 of file Account.cpp.

4540{
4541 switch (t)
4542 {
4543 case ACCT_TYPE_EQUITY:
4544 return TRUE;
4545 default:
4546 return FALSE;
4547 }
4548}
@ ACCT_TYPE_EQUITY
Equity account is used to balance the balance sheet.
Definition Account.h:146

◆ xaccAccountIsHidden()

gboolean xaccAccountIsHidden ( const Account acc)

Should this account be "hidden".

If this flag is set for this account (or any parent account) then the account should be hidden from the user unless they explicitly ask to see it. This function is different from the xaccAccountGetHidden() function because it checks the flag in parent accounts in addition to this account.

Parameters
accThe account whose flag should be retrieved.
Returns
Whether or not this account should be "hidden".

Definition at line 4202 of file Account.cpp.

4203{
4204 AccountPrivate *priv;
4205
4206 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4207
4208 if (xaccAccountGetHidden(acc))
4209 return TRUE;
4210 priv = GET_PRIVATE(acc);
4211 while ((acc = priv->parent) != nullptr)
4212 {
4213 priv = GET_PRIVATE(acc);
4214 if (xaccAccountGetHidden(acc))
4215 return TRUE;
4216 }
4217 return FALSE;
4218}
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
Definition Account.cpp:4190

◆ xaccAccountMoveAllSplits()

void xaccAccountMoveAllSplits ( Account accfrom,
Account accto 
)

The xaccAccountMoveAllSplits() routine reassigns each of the splits in accfrom to accto.

Definition at line 2196 of file Account.cpp.

2197{
2198 AccountPrivate *from_priv;
2199
2200 /* errors */
2201 g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
2202 g_return_if_fail(GNC_IS_ACCOUNT(accto));
2203
2204 /* optimizations */
2205 from_priv = GET_PRIVATE(accfrom);
2206 if (from_priv->splits.empty() || accfrom == accto)
2207 return;
2208
2209 /* check for book mix-up */
2210 g_return_if_fail (qof_instance_books_equal(accfrom, accto));
2211 ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
2212
2213 xaccAccountBeginEdit(accfrom);
2214 xaccAccountBeginEdit(accto);
2215 /* Begin editing both accounts and all transactions in accfrom. */
2216 std::for_each (from_priv->splits.begin(), from_priv->splits.end(), xaccPreSplitMove);
2217
2218 /* Concatenate accfrom's lists of splits and lots to accto's lists. */
2219 //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
2220 //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
2221
2222 /* Set appropriate flags. */
2223 //from_priv->balance_dirty = TRUE;
2224 //from_priv->sort_dirty = FALSE;
2225 //to_priv->balance_dirty = TRUE;
2226 //to_priv->sort_dirty = TRUE;
2227
2228 /*
2229 * Change each split's account back pointer to accto.
2230 * Convert each split's amount to accto's commodity.
2231 * Commit to editing each transaction.
2232 */
2233 auto splits = from_priv->splits;
2234 std::for_each (splits.begin(), splits.end(), [accto](auto s){ xaccPostSplitMove (s, accto); });
2235
2236 /* Finally empty accfrom. */
2237 g_assert(from_priv->splits.empty());
2238 g_assert(from_priv->lots == nullptr);
2239 xaccAccountCommitEdit(accfrom);
2240 xaccAccountCommitEdit(accto);
2241
2242 LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
2243}
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.

◆ xaccAccountRemoveLot()

void xaccAccountRemoveLot ( Account acc,
GNCLot *  lot 
)

Definition at line 2122 of file Account.cpp.

2123{
2124 AccountPrivate *priv;
2125
2126 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2127 g_return_if_fail(GNC_IS_LOT(lot));
2128
2129 priv = GET_PRIVATE(acc);
2130 g_return_if_fail(priv->lots);
2131
2132 ENTER ("(acc=%p, lot=%p)", acc, lot);
2133 priv->lots = g_list_remove(priv->lots, lot);
2134 qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_REMOVE, nullptr);
2135 qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr);
2136 LEAVE ("(acc=%p, lot=%p)", acc, lot);
2137}

◆ xaccAccountSetAppendText()

void xaccAccountSetAppendText ( Account account,
gboolean  val 
)

Set the "import-append-text" flag for an account.

This is the saved state of the Append checkbox in the "Generic import transaction matcher" used to set the initial state of the Append checkbox next time this account is imported.

Parameters
accountThe account whose flag should be retrieved.
valThe new state for the account's "import-append-text" flag.

Definition at line 4137 of file Account.cpp.

4138{
4139 set_kvp_boolean_path(acc, {"import-append-text"}, val);
4140}

◆ xaccAccountSetAutoInterest()

void xaccAccountSetAutoInterest ( Account acc,
gboolean  val 
)

Set the "auto interest" flag for an account.

If this flag is set then the account (and any children) will trigger an interest transfer after reconciling.

Parameters
accThe account whose flag should be retrieved.
valThe new state for the account's "auto interest" flag.

Definition at line 4181 of file Account.cpp.

4182{
4183 set_kvp_boolean_path (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"}, val);
4184}

◆ xaccAccountSetHidden()

void xaccAccountSetHidden ( Account acc,
gboolean  val 
)

Set the "hidden" flag for an account.

If this flag is set then the account (and any children) will be hidden from the user unless they explicitly ask to see them.

Parameters
accThe account whose flag should be retrieved.
valThe new state for the account's "hidden" flag.

Definition at line 4196 of file Account.cpp.

4197{
4198 set_kvp_boolean_path (acc, {"hidden"}, val);
4199}

◆ xaccAccountSetHigherBalanceLimit()

void xaccAccountSetHigherBalanceLimit ( Account account,
gnc_numeric  balance 
)

Set the higher balance limit for the account.

Parameters
accountThe account whose higher limit is to be saved
balanceThe balance to be saved

Definition at line 4733 of file Account.cpp.

4734{
4735 set_balance_limit (acc, KEY_BALANCE_HIGHER_LIMIT_VALUE, balance);
4736}

◆ xaccAccountSetIncludeSubAccountBalances()

void xaccAccountSetIncludeSubAccountBalances ( Account account,
gboolean  include 
)

Set whether to include balances of sub accounts.

Parameters
accountThe account to set the setting on
includeSet to TRUE for including sub account balances

Definition at line 4763 of file Account.cpp.

4764{
4765 set_kvp_boolean_path (acc, {KEY_BALANCE_LIMIT, KEY_BALANCE_INCLUDE_SUB_ACCTS}, inc_sub);
4766}

◆ xaccAccountSetIsOpeningBalance()

void xaccAccountSetIsOpeningBalance ( Account account,
gboolean  val 
)

Set the "opening-balance" flag for an account.

If this flag is set then the account is used for opening balance transactions.

Parameters
accountThe account whose flag should be set.
valThe new state for the account's "opening-balance" flag.

Definition at line 4153 of file Account.cpp.

4154{
4155 g_return_if_fail (GNC_IS_ACCOUNT(acc));
4156 if (GET_PRIVATE(acc)->type != ACCT_TYPE_EQUITY)
4157 return;
4158 set_kvp_string_path(acc, {"equity-type"}, val ? "opening-balance" : nullptr);
4159}

◆ xaccAccountSetLowerBalanceLimit()

void xaccAccountSetLowerBalanceLimit ( Account account,
gnc_numeric  balance 
)

Set the lower balance limit for the account.

Parameters
accountThe account whose lower limit is to be saved
balanceThe balance to be saved

Definition at line 4739 of file Account.cpp.

4740{
4741 set_balance_limit (acc, KEY_BALANCE_LOWER_LIMIT_VALUE, balance);
4742}

◆ xaccAccountSetMark()

void xaccAccountSetMark ( Account account,
short  mark 
)

Set a mark on the account.

The meaning of this mark is completely undefined. Its presented here as a utility for the programmer, to use as desired. Handy for performing customer traversals over the account tree. The mark is not stored in the database/file format. When accounts are newly created, the mark is set to zero.

Definition at line 2062 of file Account.cpp.

2063{
2064 AccountPrivate *priv;
2065
2066 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2067
2068 priv = GET_PRIVATE(acc);
2069 priv->mark = m;
2070}

◆ xaccAccountSetPlaceholder()

void xaccAccountSetPlaceholder ( Account account,
gboolean  val 
)

Set the "placeholder" flag for an account.

If this flag is set then the account may not be modified by the user.

Parameters
accountThe account whose flag should be retrieved.
valThe new state for the account's "placeholder" flag.

Definition at line 4125 of file Account.cpp.

4126{
4127 set_kvp_boolean_path(acc, {"placeholder"}, val);
4128}

◆ xaccAccountSetReconcileLastDate()

void xaccAccountSetReconcileLastDate ( Account account,
time64  last_date 
)

DOCUMENT ME!

Definition at line 4584 of file Account.cpp.

4585{
4586 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-date"}, last_date);
4587}

◆ xaccAccountSetReconcileLastInterval()

void xaccAccountSetReconcileLastInterval ( Account account,
int  months,
int  days 
)

DOCUMENT ME!

Definition at line 4614 of file Account.cpp.

4615{
4616 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "months"}, months);
4617 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "days"}, days);
4618}

◆ xaccAccountSetReconcilePostponeBalance()

void xaccAccountSetReconcilePostponeBalance ( Account account,
gnc_numeric  balance 
)

DOCUMENT ME!

Definition at line 4664 of file Account.cpp.

4665{
4666 set_kvp_gnc_numeric_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"}, balance);
4667}

◆ xaccAccountSetReconcilePostponeDate()

void xaccAccountSetReconcilePostponeDate ( Account account,
time64  postpone_date 
)

DOCUMENT ME!

Definition at line 4639 of file Account.cpp.

4640{
4641 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "date"}, postpone_date);
4642}

◆ xaccAccountSetTaxRelated()

void xaccAccountSetTaxRelated ( Account account,
gboolean  tax_related 
)

DOCUMENT ME!

Definition at line 4041 of file Account.cpp.

4042{
4043 set_kvp_boolean_path(acc, {"tax-related"}, tax_related);
4044}

◆ xaccAccountSetTaxUSCode()

void xaccAccountSetTaxUSCode ( Account account,
const char *  code 
)

DOCUMENT ME!

Definition at line 4053 of file Account.cpp.

4054{
4055 set_kvp_string_path (acc, {"tax-US", "code"}, code);
4056}

◆ xaccAccountSetTaxUSCopyNumber()

void xaccAccountSetTaxUSCopyNumber ( Account account,
gint64  copy_number 
)

Saves copy_number in KVP if it is greater than 1; if copy_number is zero, deletes KVP.

Definition at line 4078 of file Account.cpp.

4079{
4080 if (copy_number != 0)
4081 set_kvp_int64_path (acc, {"tax-US", "copy-number"}, copy_number);
4082 else
4083 /* deletes KVP if it exists */
4084 set_kvp_int64_path (acc, {"tax-US", "copy-number"}, std::nullopt);
4085}

◆ xaccAccountSetTaxUSPayerNameSource()

void xaccAccountSetTaxUSPayerNameSource ( Account account,
const char *  source 
)

DOCUMENT ME!

Definition at line 4065 of file Account.cpp.

4066{
4067 set_kvp_string_path (acc, {"tax-US", "payer-name-source"}, source);
4068}

◆ xaccAccountStagedTransactionTraversal()

int xaccAccountStagedTransactionTraversal ( const Account a,
unsigned int  stage,
TransactionCallback  thunk,
void *  data 
)

xaccAccountStagedTransactionTraversal() calls thunk on each transaction in account a whose current marker is less than the given stage and updates each transaction's marker to be stage.

The traversal will stop if thunk returns a non-zero value. xaccAccountStagedTransactionTraversal() function will return zero or the non-zero value returned by thunk. This API does not handle handle recursive traversals.

Warning
For performance reasons, the transaction callback thunk must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.

Definition at line 5062 of file Account.cpp.

5066{
5067 if (!acc) return 0;
5068
5069 // iterate on copy of splits. some callers modify the splitsvec.
5070 auto splits = GET_PRIVATE(acc)->splits;
5071 for (auto s : splits)
5072 {
5073 auto trans = s->parent;
5074 if (trans && (trans->marker < stage))
5075 {
5076 trans->marker = stage;
5077 if (thunk)
5078 {
5079 auto retval = thunk(trans, cb_data);
5080 if (retval) return retval;
5081 }
5082 }
5083 }
5084
5085 return 0;
5086}

◆ xaccAccountStringToEnum()

GNCAccountType xaccAccountStringToEnum ( const char *  str)

Conversion routines for the account types to/from strings that are used in persistent storage, communications.

These strings should not be translated to the local language. Typical conversion is "INCOME" -> ACCT_TYPE_INCOME.

Definition at line 4318 of file Account.cpp.

4319{
4320 GNCAccountType type;
4321 gboolean rc;
4322 rc = xaccAccountStringToType(str, &type);
4323 if (FALSE == rc) return ACCT_TYPE_INVALID;
4324 return type;
4325}
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed.
Definition Account.h:103
@ ACCT_TYPE_INVALID
Not a type.
Definition Account.h:104
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Conversion routines for the account types to/from strings that are used in persistent storage,...
Definition Account.cpp:4284

◆ xaccAccountStringToType()

gboolean xaccAccountStringToType ( const char *  str,
GNCAccountType type 
)

Conversion routines for the account types to/from strings that are used in persistent storage, communications.

These strings should not be translated to the local language. Typical conversion is "INCOME" -> ACCT_TYPE_INCOME.

Definition at line 4284 of file Account.cpp.

4285{
4286
4287 GNC_RETURN_ON_MATCH(NONE);
4288 GNC_RETURN_ON_MATCH(BANK);
4289 GNC_RETURN_ON_MATCH(CASH);
4290 GNC_RETURN_ON_MATCH(CREDIT);
4291 GNC_RETURN_ON_MATCH(ASSET);
4292 GNC_RETURN_ON_MATCH(LIABILITY);
4293 GNC_RETURN_ON_MATCH(STOCK);
4294 GNC_RETURN_ON_MATCH(MUTUAL);
4295 GNC_RETURN_ON_MATCH(CURRENCY);
4296 GNC_RETURN_ON_MATCH(INCOME);
4297 GNC_RETURN_ON_MATCH(EXPENSE);
4298 GNC_RETURN_ON_MATCH(EQUITY);
4299 GNC_RETURN_ON_MATCH(RECEIVABLE);
4300 GNC_RETURN_ON_MATCH(PAYABLE);
4301 GNC_RETURN_ON_MATCH(ROOT);
4302 GNC_RETURN_ON_MATCH(TRADING);
4303 GNC_RETURN_ON_MATCH(CHECKING);
4304 GNC_RETURN_ON_MATCH(SAVINGS);
4305 GNC_RETURN_ON_MATCH(MONEYMRKT);
4306 GNC_RETURN_ON_MATCH(CREDITLINE);
4307
4308 PERR("asked to translate unknown account type string %s.\n",
4309 str ? str : "(null)");
4310
4311 return(FALSE);
4312}

◆ xaccAccountTreeForEachTransaction()

int xaccAccountTreeForEachTransaction ( Account acc,
TransactionCallback  proc,
void *  data 
)

Traverse all of the transactions in the given account group.

Continue processing IF proc returns 0. This function will descend recursively to traverse transactions in the children of the accounts in the group.

Proc will be called exactly once for each transaction that is pointed to by at least one split in any account in the hierarchy topped by the root Account acc.

The result of this function will be 0 IF every relevant transaction was traversed exactly once; otherwise, the return value is the last non-zero value returned by the callback.

Warning
For performance reasons, the transaction callback proc must never destroy any of the transaction's splits, nor assign any of them to a different account. To do so risks a crash.
The traversal occurs only over the transactions that are locally cached in the local gnucash engine. If the gnucash engine is attached to a remote database, the database may contain (many) transactions that are not mirrored in the local cache. This routine will not cause an SQL database query to be performed; it will not traverse transactions present only in the remote database.

Note that this routine is just a trivial wrapper for

gnc_account_tree_begin_staged_transaction_traversals(g); gnc_account_tree_staged_transaction_traversal(g, 42, proc, data);

◆ xaccAccountTypeEnumAsString()

const char * xaccAccountTypeEnumAsString ( GNCAccountType  type)

Conversion routines for the account types to/from strings that are used in persistent storage, communications.

These strings should not be translated to the local language. Typical conversion is ACCT_TYPE_INCOME -> "INCOME".

Definition at line 4247 of file Account.cpp.

4248{
4249 switch (type)
4250 {
4251 GNC_RETURN_ENUM_AS_STRING(NONE);
4252 GNC_RETURN_ENUM_AS_STRING(BANK);
4253 GNC_RETURN_ENUM_AS_STRING(CASH);
4254 GNC_RETURN_ENUM_AS_STRING(CREDIT);
4255 GNC_RETURN_ENUM_AS_STRING(ASSET);
4256 GNC_RETURN_ENUM_AS_STRING(LIABILITY);
4257 GNC_RETURN_ENUM_AS_STRING(STOCK);
4258 GNC_RETURN_ENUM_AS_STRING(MUTUAL);
4259 GNC_RETURN_ENUM_AS_STRING(CURRENCY);
4260 GNC_RETURN_ENUM_AS_STRING(INCOME);
4261 GNC_RETURN_ENUM_AS_STRING(EXPENSE);
4262 GNC_RETURN_ENUM_AS_STRING(EQUITY);
4263 GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
4264 GNC_RETURN_ENUM_AS_STRING(PAYABLE);
4265 GNC_RETURN_ENUM_AS_STRING(ROOT);
4266 GNC_RETURN_ENUM_AS_STRING(TRADING);
4267 GNC_RETURN_ENUM_AS_STRING(CHECKING);
4268 GNC_RETURN_ENUM_AS_STRING(SAVINGS);
4269 GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
4270 GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
4271 default:
4272 PERR ("asked to translate unknown account type %d.\n", type);
4273 break;
4274 }
4275 return(nullptr);
4276}

◆ xaccAccountTypeGetFundamental()

GNCAccountType xaccAccountTypeGetFundamental ( GNCAccountType  t)

Convenience function to return the fundamental type asset/liability/income/expense/equity given an account type.

Definition at line 4495 of file Account.cpp.

4496{
4497 switch (t)
4498 {
4499 case ACCT_TYPE_BANK:
4500 case ACCT_TYPE_STOCK:
4502 case ACCT_TYPE_CHECKING:
4503 case ACCT_TYPE_SAVINGS:
4504 case ACCT_TYPE_MUTUAL:
4505 case ACCT_TYPE_CURRENCY:
4506 case ACCT_TYPE_CASH:
4507 case ACCT_TYPE_ASSET:
4509 return ACCT_TYPE_ASSET;
4510 case ACCT_TYPE_CREDIT:
4512 case ACCT_TYPE_PAYABLE:
4514 return ACCT_TYPE_LIABILITY;
4515 case ACCT_TYPE_INCOME:
4516 return ACCT_TYPE_INCOME;
4517 case ACCT_TYPE_EXPENSE:
4518 return ACCT_TYPE_EXPENSE;
4519 case ACCT_TYPE_EQUITY:
4520 return ACCT_TYPE_EQUITY;
4521 case ACCT_TYPE_TRADING:
4522 default:
4523 return ACCT_TYPE_NONE;
4524 }
4525}
@ ACCT_TYPE_INCOME
Income accounts are used to denote income.
Definition Account.h:140
@ ACCT_TYPE_MUTUAL
Mutual Fund accounts will typically be shown in registers which show three columns: price,...
Definition Account.h:125
@ ACCT_TYPE_CREDITLINE
line of credit – don't use this for now, see NUM_ACCOUNT_TYPES
Definition Account.h:171
@ ACCT_TYPE_TRADING
Account used to record multiple commodity transactions.
Definition Account.h:155
@ ACCT_TYPE_EXPENSE
Expense accounts are used to denote expenses.
Definition Account.h:143
@ ACCT_TYPE_BANK
The bank account type denotes a savings or checking account held at a bank.
Definition Account.h:107
@ ACCT_TYPE_ASSET
asset (and liability) accounts indicate generic, generalized accounts that are none of the above.
Definition Account.h:116
@ ACCT_TYPE_CURRENCY
The currency account type indicates that the account is a currency trading account.
Definition Account.h:129
@ ACCT_TYPE_MONEYMRKT
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition Account.h:169
@ ACCT_TYPE_CASH
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Definition Account.h:110
@ ACCT_TYPE_LIABILITY
liability (and asset) accounts indicate generic, generalized accounts that are none of the above.
Definition Account.h:119
@ ACCT_TYPE_CHECKING
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition Account.h:165
@ ACCT_TYPE_CREDIT
The Credit card account is used to denote credit (e.g.
Definition Account.h:113
@ ACCT_TYPE_STOCK
Stock accounts will typically be shown in registers which show three columns: price,...
Definition Account.h:122
@ ACCT_TYPE_SAVINGS
bank account type – don't use this for now, see NUM_ACCOUNT_TYPES
Definition Account.h:167
@ ACCT_TYPE_NONE
Not a type.
Definition Account.h:105

◆ xaccAccountTypesCompatible()

gboolean xaccAccountTypesCompatible ( GNCAccountType  parent_type,
GNCAccountType  child_type 
)

Return TRUE if accounts of type parent_type can have accounts of type child_type as children.

Definition at line 4454 of file Account.cpp.

4456{
4457 /* ACCT_TYPE_NONE isn't compatible with anything, even ACCT_TYPE_NONE. */
4458 if (parent_type == ACCT_TYPE_NONE || child_type == ACCT_TYPE_NONE)
4459 return FALSE;
4460
4461 /* ACCT_TYPE_ROOT can't have a parent account, and asking will raise
4462 * an error. */
4463 if (child_type == ACCT_TYPE_ROOT)
4464 return FALSE;
4465
4466 return ((xaccParentAccountTypesCompatibleWith (child_type) &
4467 (1 << parent_type))
4468 != 0);
4469}
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Return the bitmask of parent account types compatible with a given type.
Definition Account.cpp:4407

◆ xaccAccountTypesCompatibleWith()

guint32 xaccAccountTypesCompatibleWith ( GNCAccountType  type)

Return the bitmask of account types compatible with a given type.

That is, you could switch to any of the account types in the compatible list without unwanted side-effects.

Definition at line 4367 of file Account.cpp.

4368{
4369 switch (type)
4370 {
4371 case ACCT_TYPE_BANK:
4372 case ACCT_TYPE_CASH:
4373 case ACCT_TYPE_ASSET:
4374 case ACCT_TYPE_CREDIT:
4376 case ACCT_TYPE_INCOME:
4377 case ACCT_TYPE_EXPENSE:
4378 case ACCT_TYPE_EQUITY:
4379 return
4380 (1 << ACCT_TYPE_BANK) |
4381 (1 << ACCT_TYPE_CASH) |
4382 (1 << ACCT_TYPE_ASSET) |
4383 (1 << ACCT_TYPE_CREDIT) |
4384 (1 << ACCT_TYPE_LIABILITY) |
4385 (1 << ACCT_TYPE_INCOME) |
4386 (1 << ACCT_TYPE_EXPENSE) |
4387 (1 << ACCT_TYPE_EQUITY);
4388 case ACCT_TYPE_STOCK:
4389 case ACCT_TYPE_MUTUAL:
4390 case ACCT_TYPE_CURRENCY:
4391 return
4392 (1 << ACCT_TYPE_STOCK) |
4393 (1 << ACCT_TYPE_MUTUAL) |
4394 (1 << ACCT_TYPE_CURRENCY);
4396 return (1 << ACCT_TYPE_RECEIVABLE);
4397 case ACCT_TYPE_PAYABLE:
4398 return (1 << ACCT_TYPE_PAYABLE);
4399 case ACCT_TYPE_TRADING:
4400 return (1 << ACCT_TYPE_TRADING);
4401 default:
4402 PERR("bad account type: %d", type);
4403 return 0;
4404 }
4405}

◆ xaccAccountTypesValid()

guint32 xaccAccountTypesValid ( void  )

Returns the bitmask of the account type enums that are valid.

Deprecated and root account types are stripped.

Definition at line 4472 of file Account.cpp.

4473{
4474 guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4475 mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4476 (1 << ACCT_TYPE_ROOT)); /* ROOT */
4477
4478 return mask;
4479}

◆ xaccClearMark()

void xaccClearMark ( Account account,
short  val 
)

Get the mark set by xaccAccountSetMark short xaccAccountGetMark (const Account *account);.

The xaccClearMark will find the root account, and clear the mark in the entire account tree.

Definition at line 2073 of file Account.cpp.

2074{
2075 Account *root;
2076
2077 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2078
2079 root = gnc_account_get_root(acc);
2080 xaccClearMarkDown(root ? root : acc, val);
2081}
Account * gnc_account_get_root(Account *acc)
This routine returns the root account of the account tree that the specified account belongs to.
Definition Account.cpp:2942
void xaccClearMarkDown(Account *acc, short val)
The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
Definition Account.cpp:2084

◆ xaccClearMarkDown()

void xaccClearMarkDown ( Account account,
short  val 
)

The xaccClearMarkDown will clear the mark only in this and in sub-accounts.

Definition at line 2084 of file Account.cpp.

2085{
2086 AccountPrivate *priv;
2087
2088 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2089
2090 priv = GET_PRIVATE(acc);
2091 priv->mark = val;
2092 std::for_each (priv->children.begin(), priv->children.end(),
2093 [val](auto acc){ xaccClearMarkDown(acc, val); });
2094}

◆ xaccMallocTransaction()

Transaction * xaccMallocTransaction ( QofBook book)

The xaccMallocTransaction() will malloc memory and initialize it.

Once created, it is usually unsafe to merely "free" this memory; the xaccTransDestroy() method should be called.

Definition at line 485 of file Transaction.cpp.

486{
487 Transaction *trans;
488
489 g_return_val_if_fail (book, nullptr);
490
491 trans = GNC_TRANSACTION(g_object_new(GNC_TYPE_TRANSACTION, nullptr));
492 xaccInitTransaction (trans, book);
493 qof_event_gen (&trans->inst, QOF_EVENT_CREATE, nullptr);
494
495 return trans;
496}

◆ xaccParentAccountTypesCompatibleWith()

guint32 xaccParentAccountTypesCompatibleWith ( GNCAccountType  type)

Return the bitmask of parent account types compatible with a given type.

Definition at line 4407 of file Account.cpp.

4408{
4409 switch (type)
4410 {
4411 case ACCT_TYPE_BANK:
4412 case ACCT_TYPE_CASH:
4413 case ACCT_TYPE_ASSET:
4414 case ACCT_TYPE_STOCK:
4415 case ACCT_TYPE_MUTUAL:
4416 case ACCT_TYPE_CURRENCY:
4417 case ACCT_TYPE_CREDIT:
4420 case ACCT_TYPE_PAYABLE:
4421 return
4422 (1 << ACCT_TYPE_BANK) |
4423 (1 << ACCT_TYPE_CASH) |
4424 (1 << ACCT_TYPE_ASSET) |
4425 (1 << ACCT_TYPE_STOCK) |
4426 (1 << ACCT_TYPE_MUTUAL) |
4427 (1 << ACCT_TYPE_CURRENCY) |
4428 (1 << ACCT_TYPE_CREDIT) |
4429 (1 << ACCT_TYPE_LIABILITY) |
4430 (1 << ACCT_TYPE_RECEIVABLE) |
4431 (1 << ACCT_TYPE_PAYABLE) |
4432 (1 << ACCT_TYPE_ROOT);
4433 case ACCT_TYPE_INCOME:
4434 case ACCT_TYPE_EXPENSE:
4435 return
4436 (1 << ACCT_TYPE_INCOME) |
4437 (1 << ACCT_TYPE_EXPENSE) |
4438 (1 << ACCT_TYPE_ROOT);
4439 case ACCT_TYPE_EQUITY:
4440 return
4441 (1 << ACCT_TYPE_EQUITY) |
4442 (1 << ACCT_TYPE_ROOT);
4443 case ACCT_TYPE_TRADING:
4444 return
4445 (1 << ACCT_TYPE_TRADING) |
4446 (1 << ACCT_TYPE_ROOT);
4447 default:
4448 PERR("bad account type: %d", type);
4449 return 0;
4450 }
4451}
@ ACCT_TYPE_ROOT
The hidden root account of an account tree.
Definition Account.h:153

◆ xaccTransactionTraverse()

gboolean xaccTransactionTraverse ( Transaction *  trans,
int  stage 
)

xaccTransactionTraverse() checks the stage of the given transaction.

If the transaction hasn't reached the given stage, the transaction is updated to that stage and the function returns TRUE. Otherwise no change is made and the function returns FALSE.

Definition at line 5039 of file Account.cpp.

5040{
5041 if (trans == nullptr) return FALSE;
5042
5043 if (trans->marker < stage)
5044 {
5045 trans->marker = stage;
5046 return TRUE;
5047 }
5048
5049 return FALSE;
5050}

◆ xaccTransBeginEdit()

void xaccTransBeginEdit ( Transaction *  trans)

The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of its component splits.

If this is not done, errors will result.

Definition at line 35 of file gmock-Transaction.cpp.

36{
37 ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
38 gnc_mocktransaction(trans)->begin_edit();
39}

◆ xaccTransClearReadOnly()

void xaccTransClearReadOnly ( Transaction *  trans)

Definition at line 1983 of file Transaction.cpp.

1984{
1985 set_kvp_string_path (trans, {TRANS_READ_ONLY_REASON}, nullptr);
1986}

◆ xaccTransClearSplits()

void xaccTransClearSplits ( Transaction *  trans)

Remove all splits from the transaction.

Clears the split list of the transaction. All splits that the transaction still owns will be destroyed, and others will be unlinked.

Opens and commits an edit on the transaction, so this will destroy the transaction if it isn't already open, as will committing the outer edits if new splits are not added before hand.

Definition at line 2074 of file Transaction.cpp.

2075{
2076 xaccTransBeginEdit(trans);
2077 /* We only own the splits that still think they belong to us. This is done
2078 in 2 steps. In the first, the splits are marked as being destroyed, but they
2079 are not destroyed yet. In the second, the destruction is committed which will
2080 do the actual destruction. If both steps are done for a split before they are
2081 done for the next split, then a split will still be on the split list after it
2082 has been freed. This can cause other parts of the code (e.g. in xaccSplitDestroy())
2083 to reference the split after it has been freed. */
2084 for (auto node = trans->splits; node; node = node->next)
2085 {
2086 auto s = GNC_SPLIT(node->data);
2087 if (s && s->parent == trans)
2088 {
2090 }
2091 }
2092 for (auto node = trans->splits; node; node = node->next)
2093 {
2094 auto s = GNC_SPLIT(node->data);
2095 if (s && s->parent == trans)
2096 {
2097 xaccSplitCommitEdit(s);
2098 }
2099 }
2100 g_list_free (trans->splits);
2101 trans->splits = nullptr;
2102
2103 xaccTransCommitEdit(trans);
2104}
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
gboolean xaccSplitDestroy(Split *split)
Destructor.
Definition Split.cpp:1506

◆ xaccTransClone()

Transaction * xaccTransClone ( const Transaction *  t)

The xaccTransClone() method will create a complete copy of an existing transaction.

Definition at line 650 of file Transaction.cpp.

651{
652 Transaction *to = xaccTransCloneNoKvp (from);
653
654 if (g_list_length (to->splits) != g_list_length (from->splits))
655 {
656 PERR ("Cloned transaction has different number of splits from original");
657 xaccTransDestroy (to);
658 return nullptr;
659 }
660
662 qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from));
663
664 for (GList* lfrom = from->splits, *lto = to->splits; lfrom && lto;
665 lfrom = g_list_next (lfrom), lto = g_list_next (lto))
666 xaccSplitCopyKvp (GNC_SPLIT(lfrom->data), GNC_SPLIT(lto->data));
667
669 return to;
670}
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
Transaction * xaccTransCloneNoKvp(const Transaction *from)
The xaccTransCloneNoKvp() method will create a complete copy of an existing transaction except that t...

◆ xaccTransCloneNoKvp()

Transaction * xaccTransCloneNoKvp ( const Transaction *  t)

The xaccTransCloneNoKvp() method will create a complete copy of an existing transaction except that the KVP slots will be empty.

Definition at line 620 of file Transaction.cpp.

621{
622 Transaction *to;
623
625 to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, nullptr));
626
627 to->date_entered = from->date_entered;
628 to->date_posted = from->date_posted;
629 CACHE_REPLACE (to->num, from->num);
630 CACHE_REPLACE (to->description, from->description);
631 to->common_currency = from->common_currency;
632 qof_instance_copy_version(to, from);
633 qof_instance_copy_version_check(to, from);
634
635 to->orig = nullptr;
636
637 qof_instance_init_data (&to->inst, GNC_ID_TRANS,
639
641 to->splits = g_list_copy_deep (from->splits, copy_split, to);
642 qof_instance_set_dirty(QOF_INSTANCE(to));
645
646 return to;
647}
void qof_event_resume(void)
Resume engine event generation.
Definition qofevent.cpp:156
void qof_event_suspend(void)
Suspend all engine events.
Definition qofevent.cpp:145
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.

◆ xaccTransCommitEdit()

void xaccTransCommitEdit ( Transaction *  trans)

The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are complete and should be made permanent.

Note this routine may result in the deletion of the transaction, if the transaction is "empty" (has no splits), or of xaccTransDestroy() was called on the transaction.

Definition at line 42 of file gmock-Transaction.cpp.

43{
44 ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
45 gnc_mocktransaction(trans)->commit_edit();
46}

◆ xaccTransCopyFromClipBoard()

void xaccTransCopyFromClipBoard ( const Transaction *  from_trans,
Transaction *  to_trans,
const Account from_acc,
Account to_acc,
gboolean  no_date 
)

This function explicitly must robustly handle some unusual input.

'from_trans' may be a duped trans (see xaccDupeTransaction), so its splits may not really belong to the accounts that they say they do.

'from_acc' need not be a valid account. It may be an already freed Account. Therefore, it must not be dereferenced at all.

Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may be modified in any way.

'no_date' if TRUE will not copy the date posted.

The 'to_trans' transaction will end up with valid copies of from's splits. In addition, the copies of any of from's splits that were in from_acc (or at least claimed to be) will end up in to_acc.

Definition at line 719 of file Transaction.cpp.

721{
722 gboolean change_accounts = FALSE;
723 GList *node;
724
725 if (!from_trans || !to_trans)
726 return;
727
728 change_accounts = from_acc && GNC_IS_ACCOUNT(to_acc) && from_acc != to_acc;
729 xaccTransBeginEdit(to_trans);
730
731 xaccTransClearSplits(to_trans);
732 xaccTransSetCurrency(to_trans, xaccTransGetCurrency(from_trans));
734
735 if ((xaccTransGetNum(to_trans) == nullptr) || (g_strcmp0 (xaccTransGetNum(to_trans), "") == 0))
736 xaccTransSetNum(to_trans, xaccTransGetNum(from_trans));
737
738 xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
739 xaccTransSetDocLink(to_trans, xaccTransGetDocLink (from_trans));
740 if(!no_date)
741 {
743 }
744
745 /* Each new split will be parented to 'to' */
746 for (node = from_trans->splits; node; node = node->next)
747 {
748 Split *new_split = xaccMallocSplit( qof_instance_get_book(QOF_INSTANCE(from_trans)));
749 xaccSplitCopyOnto(GNC_SPLIT(node->data), new_split);
750 if (change_accounts && xaccSplitGetAccount(GNC_SPLIT(node->data)) == from_acc)
751 xaccSplitSetAccount(new_split, to_acc);
752 xaccSplitSetParent(new_split, to_trans);
753 }
754 xaccTransCommitEdit(to_trans);
755}
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
gnc_commodity * xaccTransGetCurrency(const Transaction *trans)
Returns the valuation commodity of this transaction.
void xaccTransSetNum(Transaction *trans, const char *xnum)
Sets the transaction Number (or ID) field; rather than use this function directly,...
const char * xaccTransGetDocLink(const Transaction *trans)
Gets the transaction Document Link.
void xaccTransClearSplits(Transaction *trans)
Remove all splits from the transaction.
time64 xaccTransRetDatePosted(const Transaction *trans)
Retrieve the posted date of the transaction.
const char * xaccTransGetNotes(const Transaction *trans)
Gets the transaction Notes.
void xaccTransSetDatePostedSecs(Transaction *trans, time64 secs)
The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction,...
void xaccTransSetDocLink(Transaction *trans, const char *doclink)
Sets the transaction Document Link.
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
const char * xaccTransGetNum(const Transaction *trans)
Gets the transaction Number (or ID) field; rather than use this function directly,...
void xaccTransSetNotes(Transaction *trans, const char *notes)
Sets the transaction Notes.
Split * xaccMallocSplit(QofBook *book)
Constructor.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
void xaccSplitCopyOnto(const Split *from_split, Split *to_split)
This is really a helper for xaccTransCopyOnto.
Definition Split.cpp:648

◆ xaccTransCopyOnto()

void xaccTransCopyOnto ( const Transaction *  from_trans,
Transaction *  to_trans 
)

Copy a transaction to another using the function below without changing any account information.

Definition at line 695 of file Transaction.cpp.

696{
697 xaccTransCopyFromClipBoard(from_trans, to_trans, nullptr, nullptr, TRUE);
698}
void xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans, const Account *from_acc, Account *to_acc, gboolean no_date)
This function explicitly must robustly handle some unusual input.

◆ xaccTransCopyToClipBoard()

Transaction * xaccTransCopyToClipBoard ( const Transaction *  from_trans)

Copy a transaction to the 'clipboard' transaction using dupe_transaction.

The 'clipboard' transaction must never be dereferenced.

Definition at line 679 of file Transaction.cpp.

680{
681 Transaction *to_trans;
682
683 if (!from_trans)
684 return nullptr;
685
686 to_trans = dupe_trans(from_trans);
687 return to_trans;
688}

◆ xaccTransCountSplits()

int xaccTransCountSplits ( const Transaction *  trans)

Returns the number of splits in this transaction.

Definition at line 2210 of file Transaction.cpp.

2211{
2212 gint i = 0;
2213 g_return_val_if_fail (trans != nullptr, 0);
2214 FOR_EACH_SPLIT(trans, i++);
2215 return i;
2216}

◆ xaccTransDestroy()

void xaccTransDestroy ( Transaction *  trans)

Destroys a transaction.

Each split in transaction trans is removed from its account and destroyed as well.

If the transaction has not already been opened for editing with xaccTransBeginEdit() then the changes are committed immediately. Otherwise, the caller must follow up with either xaccTransCommitEdit(), in which case the transaction and split memory will be freed, or xaccTransRollbackEdit(), in which case nothing at all is freed, and everything is put back into original order.

Parameters
transthe transaction to destroy

Definition at line 150 of file gmock-Transaction.cpp.

151{
152 ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
153 gnc_mocktransaction(trans)->destroy();
154}

◆ xaccTransEqual()

gboolean xaccTransEqual ( const Transaction *  ta,
const Transaction *  tb,
gboolean  check_guids,
gboolean  check_splits,
gboolean  check_balances,
gboolean  assume_ordered 
)

Equality.

Parameters
taFirst transaction to compare
tbSecond transaction to compare
check_guidsIf TRUE, try a guid_equal() on the GUIDs of both transactions if their pointers are not equal in the first place. Also passed to subsidiary calls to xaccSplitEqual.
check_splitsIf TRUE, after checking the transaction data structures for equality, also check all splits attached to the transaction for equality.
check_balancesIf TRUE, when checking splits also compare balances between the two splits. Balances are recalculated whenever a split is added or removed from an account, so YMMV on whether this should be set.
assume_orderedIf TRUE, assume that the splits in each transaction appear in the same order. This saves some time looking up splits by GncGUID, and is required for checking duplicated transactions because all the splits have new GUIDs.

Definition at line 824 of file Transaction.cpp.

829{
830 gboolean same_book;
831
832 if (!ta && !tb) return TRUE; /* Arguable. FALSE may be better. */
833
834 if (!ta || !tb)
835 {
836 PINFO ("one is nullptr");
837 return FALSE;
838 }
839
840 if (ta == tb) return TRUE;
841
842 same_book = qof_instance_get_book(QOF_INSTANCE(ta)) == qof_instance_get_book(QOF_INSTANCE(tb));
843
844 if (check_guids)
845 {
846 if (qof_instance_guid_compare(ta, tb) != 0)
847 {
848 PINFO ("GUIDs differ");
849 return FALSE;
850 }
851 }
852
853 if (!gnc_commodity_equal(ta->common_currency, tb->common_currency))
854 {
855 PINFO ("commodities differ %s vs %s",
856 gnc_commodity_get_unique_name (ta->common_currency),
857 gnc_commodity_get_unique_name (tb->common_currency));
858 return FALSE;
859 }
860
861 if (ta->date_entered != tb->date_entered)
862 {
863 char buf1[100];
864 char buf2[100];
865
866 (void)gnc_time64_to_iso8601_buff(ta->date_entered, buf1);
867 (void)gnc_time64_to_iso8601_buff(tb->date_entered, buf2);
868 PINFO ("date entered differs: '%s' vs '%s'", buf1, buf2);
869 return FALSE;
870 }
871
872 if (ta->date_posted != tb->date_posted)
873 {
874 char buf1[100];
875 char buf2[100];
876
877 (void)gnc_time64_to_iso8601_buff(ta->date_posted, buf1);
878 (void)gnc_time64_to_iso8601_buff(tb->date_posted, buf2);
879 PINFO ("date posted differs: '%s' vs '%s'", buf1, buf2);
880 return FALSE;
881 }
882
883 /* If the same book, since we use cached strings, we can just compare pointer
884 * equality for num and description
885 */
886 if ((same_book && ta->num != tb->num) || (!same_book && g_strcmp0(ta->num, tb->num) != 0))
887 {
888 PINFO ("num differs: %s vs %s", ta->num, tb->num);
889 return FALSE;
890 }
891
892 if ((same_book && ta->description != tb->description)
893 || (!same_book && g_strcmp0(ta->description, tb->description)))
894 {
895 PINFO ("descriptions differ: %s vs %s", ta->description, tb->description);
896 return FALSE;
897 }
898
899 if (qof_instance_compare_kvp (QOF_INSTANCE (ta), QOF_INSTANCE (tb)) != 0)
900 {
901 char *frame_a;
902 char *frame_b;
903
904 frame_a = qof_instance_kvp_as_string (QOF_INSTANCE (ta));
905 frame_b = qof_instance_kvp_as_string (QOF_INSTANCE (tb));
906
907
908 PINFO ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
909
910 g_free (frame_a);
911 g_free (frame_b);
912
913 return FALSE;
914 }
915
916 if (check_splits)
917 {
918 if ((!ta->splits && tb->splits) || (!tb->splits && ta->splits))
919 {
920 PINFO ("only one has splits");
921 return FALSE;
922 }
923
924 if (ta->splits && tb->splits)
925 {
926 GList *node_a, *node_b;
927
928 for (node_a = ta->splits, node_b = tb->splits;
929 node_a;
930 node_a = node_a->next, node_b = node_b->next)
931 {
932 Split *split_a = GNC_SPLIT(node_a->data);
933 Split *split_b;
934
935 /* don't presume that the splits are in the same order */
936 if (!assume_ordered)
937 node_b = g_list_find_custom (tb->splits, split_a,
938 compare_split_guids);
939
940 if (!node_b)
941 {
942 gchar guidstr[GUID_ENCODING_LENGTH+1];
943 guid_to_string_buff (xaccSplitGetGUID (split_a),guidstr);
944
945 PINFO ("first has split %s and second does not",guidstr);
946 return FALSE;
947 }
948
949 split_b = GNC_SPLIT(node_b->data);
950
951 if (!xaccSplitEqual (split_a, split_b, check_guids, check_balances,
952 FALSE))
953 {
954 char str_a[GUID_ENCODING_LENGTH + 1];
955 char str_b[GUID_ENCODING_LENGTH + 1];
956
957 guid_to_string_buff (xaccSplitGetGUID (split_a), str_a);
958 guid_to_string_buff (xaccSplitGetGUID (split_b), str_b);
959
960 PINFO ("splits %s and %s differ", str_a, str_b);
961 return FALSE;
962 }
963 }
964
965 if (g_list_length (ta->splits) != g_list_length (tb->splits))
966 {
967 PINFO ("different number of splits");
968 return FALSE;
969 }
970 }
971 }
972
973 return TRUE;
974}
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
char * gnc_time64_to_iso8601_buff(time64 time, char *buff)
The gnc_time64_to_iso8601_buff() routine takes the input UTC time64 value and prints it as an ISO-860...
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.
#define xaccSplitGetGUID(X)
Definition Split.h:579
gboolean xaccSplitEqual(const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits)
Equality.
Definition Split.cpp:819

◆ xaccTransFindSplitByAccount()

Split * xaccTransFindSplitByAccount ( const Transaction *  trans,
const Account acc 
)

Definition at line 64 of file gmock-Transaction.cpp.

65{
66 SCOPED_TRACE("");
67 auto mocktrans = gnc_mocktransaction(trans);
68 EXPECT_TRUE(GNC_IS_ACCOUNT(acc));
69 return mocktrans ? mocktrans->find_split_by_account(acc) : nullptr;
70}

◆ xaccTransGetAccountAmount()

gnc_numeric xaccTransGetAccountAmount ( const Transaction *  trans,
const Account account 
)

Same as xaccTransGetAccountValue, but uses the Account's commodity.

Definition at line 1154 of file Transaction.cpp.

1155{
1156 gnc_numeric total = gnc_numeric_zero ();
1157 if (!trans || !acc) return total;
1158
1159 total = gnc_numeric_convert (total, xaccAccountGetCommoditySCU (acc),
1160 GNC_HOW_RND_ROUND_HALF_UP);
1161 FOR_EACH_SPLIT(trans, if (acc == xaccSplitGetAccount(s))
1162 total = gnc_numeric_add_fixed(
1163 total, xaccSplitGetAmount(s)));
1164 return total;
1165}
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
Definition Account.cpp:2745
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.

◆ xaccTransGetAccountBalance()

gnc_numeric xaccTransGetAccountBalance ( const Transaction *  trans,
const Account account 
)

Get the account balance for the specified account after the last split in the specified transaction.

Definition at line 1228 of file Transaction.cpp.

1230{
1231 GList *node;
1232 Split *last_split = nullptr;
1233
1234 // Not really the appropriate error value.
1235 g_return_val_if_fail(account && trans, gnc_numeric_error(GNC_ERROR_ARG));
1236
1237 for (node = trans->splits; node; node = node->next)
1238 {
1239 Split *split = GNC_SPLIT(node->data);
1240
1241 if (!xaccTransStillHasSplit(trans, split))
1242 continue;
1243 if (xaccSplitGetAccount(split) != account)
1244 continue;
1245
1246 if (!last_split)
1247 {
1248 last_split = split;
1249 continue;
1250 }
1251
1252 /* This test needs to correspond to the comparison function used when
1253 sorting the splits for computing the running balance. */
1254 if (xaccSplitOrder (last_split, split) < 0)
1255 last_split = split;
1256 }
1257
1258 return xaccSplitGetBalance (last_split);
1259}
gnc_numeric gnc_numeric_error(GNCNumericErrorCode error_code)
Create a gnc_numeric object that signals the error condition noted by error_code, rather than a numbe...
@ GNC_ERROR_ARG
Argument is not a valid number.
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
Definition Split.cpp:1536
gnc_numeric xaccSplitGetBalance(const Split *s)
Returns the running balance up to and including the indicated split.
Definition Split.cpp:1316

◆ xaccTransGetAccountConvRate()

gnc_numeric xaccTransGetAccountConvRate ( const Transaction *  txn,
const Account acc 
)

Definition at line 1168 of file Transaction.cpp.

1169{
1170 gnc_numeric amount, value, convrate;
1171 GList *splits;
1172 Split *s;
1173 gboolean found_acc_match = FALSE;
1174 gnc_commodity *acc_commod = xaccAccountGetCommodity(acc);
1175
1176 /* We need to compute the conversion rate into _this account_. So,
1177 * find the first split into this account, compute the conversion
1178 * rate (based on amount/value), and then return this conversion
1179 * rate.
1180 */
1181 if (gnc_commodity_equal(acc_commod, xaccTransGetCurrency(txn)))
1182 return gnc_numeric_create(1, 1);
1183
1184 for (splits = txn->splits; splits; splits = splits->next)
1185 {
1186 Account *split_acc;
1187 gnc_commodity *split_commod;
1188
1189 s = GNC_SPLIT(splits->data);
1190
1191 if (!xaccTransStillHasSplit(txn, s))
1192 continue;
1193 split_acc = xaccSplitGetAccount (s);
1194 split_commod = xaccAccountGetCommodity (split_acc);
1195 if (! (split_acc == acc ||
1196 gnc_commodity_equal (split_commod, acc_commod)))
1197 continue;
1198
1199 found_acc_match = TRUE;
1200 amount = xaccSplitGetAmount (s);
1201
1202 /* Ignore splits with "zero" amount */
1203 if (gnc_numeric_zero_p (amount))
1204 continue;
1205
1206 value = xaccSplitGetValue (s);
1207 if (gnc_numeric_zero_p (value))
1208 PWARN("How can amount be nonzero and value be zero?");
1209
1210 convrate = gnc_numeric_div(amount, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
1211 return convrate;
1212 }
1213
1214 if (acc)
1215 {
1216 /* If we did find a matching account but its amount was zero,
1217 * then perhaps this is a "special" income/loss transaction
1218 */
1219 if (found_acc_match)
1220 return gnc_numeric_zero();
1221 else
1222 PERR("Cannot convert transaction -- no splits with proper conversion ratio");
1223 }
1224 return gnc_numeric_create (100, 100);
1225}
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
gnc_numeric gnc_numeric_div(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Division.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.

◆ xaccTransGetAccountValue()

gnc_numeric xaccTransGetAccountValue ( const Transaction *  trans,
const Account account 
)

The xaccTransGetAccountValue() method returns the total value applied to a particular account.

In some cases there may be multiple Splits in a single Transaction applied to one account (in particular when trying to balance Lots) – this function is just a convenience to view everything at once.

Definition at line 1138 of file Transaction.cpp.

1140{
1141 gnc_numeric total = gnc_numeric_zero ();
1142 if (!trans || !acc) return total;
1143
1144 FOR_EACH_SPLIT(trans, if (acc == xaccSplitGetAccount(s))
1145{
1146 total = gnc_numeric_add (total, xaccSplitGetValue (s),
1148 GNC_HOW_DENOM_EXACT);
1149 });
1150 return total;
1151}
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.

◆ xaccTransGetAPARAcctSplitList()

SplitList * xaccTransGetAPARAcctSplitList ( const Transaction *  trans,
gboolean  strict 
)

The xaccTransGetAPARSplitList() method returns a GList of the splits in a transaction that belong to an AR or AP account.

Parameters
transThe transaction
strictThis slightly modifies the test to only consider splits in an AR or AP account and the split is part of a business lot
Returns
The list of splits. This list must be freed when you are done with it.

Definition at line 2147 of file Transaction.cpp.

2148{
2149 GList *apar_splits = nullptr;
2150 if (!trans) return nullptr;
2151
2152 FOR_EACH_SPLIT (trans,
2153 const Account *account = xaccSplitGetAccount(s);
2154 if (account && xaccAccountIsAPARType(xaccAccountGetType(account)))
2155 {
2156
2157 if (!strict)
2158 apar_splits = g_list_prepend (apar_splits, s);
2159 else
2160 {
2161 GncOwner owner;
2162 GNCLot *lot = xaccSplitGetLot(s);
2163 if (lot &&
2164 (gncInvoiceGetInvoiceFromLot (lot) ||
2165 gncOwnerGetOwnerFromLot (lot, &owner)))
2166 apar_splits = g_list_prepend (apar_splits, s);
2167 }
2168 }
2169 );
2170
2171 apar_splits = g_list_reverse (apar_splits);
2172 return apar_splits;
2173}
gboolean xaccAccountIsAPARType(GNCAccountType t)
Convenience function to check if the account is a valid business account type (meaning an Accounts Pa...
Definition Account.cpp:4527
gboolean gncOwnerGetOwnerFromLot(GNCLot *lot, GncOwner *owner)
Get the owner from the lot.
Definition gncOwner.c:636
GNCLot * xaccSplitGetLot(const Split *split)
Returns the pointer to the debited/credited Lot where this split belongs to, or NULL if it doesn't be...
Definition Split.cpp:1920

◆ xaccTransGetCurrency()

gnc_commodity * xaccTransGetCurrency ( const Transaction *  trans)

Returns the valuation commodity of this transaction.

Each transaction's valuation commodity, or 'currency' is, by definition, the common currency in which all splits in the transaction can be valued. The total value of the transaction must be zero when all splits are valued in this currency.

Note
What happens if the Currency isn't set? Ans: bad things.

Definition at line 134 of file gmock-Transaction.cpp.

135{
136 SCOPED_TRACE("");
137 auto mocktrans = gnc_mocktransaction(trans);
138 return mocktrans ? mocktrans->get_currency() : nullptr;
139}

◆ xaccTransGetDate()

time64 xaccTransGetDate ( const Transaction *  trans)

Retrieve the posted date of the transaction.

The posted date is the date when this transaction was posted at the bank. (Although having different function names, GetDate and GetDatePosted refer to the same single date.)

Definition at line 73 of file gmock-Transaction.cpp.

74{
75 SCOPED_TRACE("");
76 auto mocktrans = gnc_mocktransaction(trans);
77 return mocktrans ? mocktrans->get_date() : 0;
78}

◆ xaccTransGetDateEntered()

time64 xaccTransGetDateEntered ( const Transaction *  trans)

Retrieve the date of when the transaction was entered.

The entered date is the date when the register entry was made.

Definition at line 2260 of file Transaction.cpp.

2261{
2262 return trans ? trans->date_entered : 0;
2263}

◆ xaccTransGetDatePostedGDate()

GDate xaccTransGetDatePostedGDate ( const Transaction *  trans)

Retrieve the posted date of the transaction.

The posted date is the date when this transaction was posted at the bank.

Definition at line 2273 of file Transaction.cpp.

2274{
2275 GDate result;
2276 g_date_clear (&result, 1);
2277 if (trans)
2278 {
2279 /* Can we look up this value in the kvp slot? If yes, use it
2280 * from there because it doesn't suffer from time zone
2281 * shifts. */
2282 if (auto res = qof_instance_get_path_kvp<GDate> (QOF_INSTANCE(trans), {TRANS_DATE_POSTED}))
2283 result = *res;
2284 if (! g_date_valid (&result) || gdate_to_time64 (result) == INT64_MAX)
2285 {
2286 /* Well, this txn doesn't have a valid GDate saved in a slot.
2287 * time64_to_gdate() uses local time and we want UTC so we have
2288 * to write it out.
2289 */
2290 time64 time = xaccTransGetDate(trans);
2291 struct tm *stm = gnc_gmtime(&time);
2292 if (stm)
2293 {
2294 g_date_set_dmy(&result, stm->tm_mday,
2295 (GDateMonth)(stm->tm_mon + 1),
2296 stm->tm_year + 1900);
2297 free(stm);
2298 }
2299 }
2300 }
2301 return result;
2302}
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
struct tm * gnc_gmtime(const time64 *secs)
fill out a time struct from a 64-bit time value
Definition gnc-date.cpp:178

◆ xaccTransGetDescription()

const char * xaccTransGetDescription ( const Transaction *  trans)

Gets the transaction Description.

Definition at line 88 of file gmock-Transaction.cpp.

89{
90 SCOPED_TRACE("");
91 auto mocktrans = gnc_mocktransaction(trans);
92 return mocktrans ? mocktrans->get_description() : "";
93}

◆ xaccTransGetDocLink()

const char * xaccTransGetDocLink ( const Transaction *  trans)

Gets the transaction Document Link.

Definition at line 2231 of file Transaction.cpp.

2232{
2233 return get_kvp_string_path (trans, {doclink_uri_str});
2234}

◆ xaccTransGetFirstAPARAcctSplit()

Split * xaccTransGetFirstAPARAcctSplit ( const Transaction *  trans,
gboolean  strict 
)

The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an AR or AP account.

Parameters
transThe transaction
strictThis slightly modifies the test to only consider splits in an AR or AP account and the split is part of a business lot

If there is no such split in the transaction NULL will be returned.

Definition at line 2186 of file Transaction.cpp.

2187{
2188 FOR_EACH_SPLIT (trans,
2189 const Account *account = xaccSplitGetAccount(s);
2190 if (account && xaccAccountIsAPARType(xaccAccountGetType(account)))
2191 {
2192 GNCLot *lot;
2193 GncOwner owner;
2194
2195 if (!strict)
2196 return s;
2197
2198 lot = xaccSplitGetLot(s);
2199 if (lot &&
2200 (gncInvoiceGetInvoiceFromLot (lot) ||
2201 gncOwnerGetOwnerFromLot (lot, &owner)))
2202 return s;
2203 }
2204 );
2205
2206 return nullptr;
2207}

◆ xaccTransGetFirstPaymentAcctSplit()

Split * xaccTransGetFirstPaymentAcctSplit ( const Transaction *  trans)

The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transaction that belongs to an account which is considered a valid account for business payments.

Parameters
transThe transaction

If there is no such split in the transaction NULL will be returned.

Definition at line 2175 of file Transaction.cpp.

2176{
2177 FOR_EACH_SPLIT (trans,
2178 const Account *account = xaccSplitGetAccount(s);
2179 if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account)))
2180 return s;
2181 );
2182
2183 return nullptr;
2184}

◆ xaccTransGetImbalance()

MonetaryList * xaccTransGetImbalance ( const Transaction *  trans)

The xaccTransGetImbalance method returns a list giving the value of the transaction in each currency for which the balance is not zero.

If the use of currency accounts is disabled, then this will be only the common currency for the transaction and xaccTransGetImbalance becomes equivalent to xaccTransGetImbalanceValue. Otherwise it will return a list containing the imbalance in each currency.

Definition at line 1020 of file Transaction.cpp.

1021{
1022 /* imbal_value is used if either (1) the transaction has a non currency
1023 split or (2) all the splits are in the same currency. If there are
1024 no non-currency splits and not all splits are in the same currency then
1025 imbal_list is used to compute the imbalance. */
1026 MonetaryList *imbal_list = nullptr;
1027 gnc_numeric imbal_value = gnc_numeric_zero();
1028 gboolean trading_accts;
1029
1030 if (!trans) return imbal_list;
1031
1032 ENTER("(trans=%p)", trans);
1033
1034 trading_accts = xaccTransUseTradingAccounts (trans);
1035
1036 /* If using trading accounts and there is at least one split that is not
1037 in the transaction currency or a split that has a price or exchange
1038 rate other than 1, then compute the balance in each commodity in the
1039 transaction. Otherwise (all splits are in the transaction's currency)
1040 then compute the balance using the value fields.
1041
1042 Optimize for the common case of only one currency and a balanced
1043 transaction. */
1044 FOR_EACH_SPLIT(trans,
1045 {
1046 gnc_commodity *commodity;
1048 if (trading_accts &&
1049 (imbal_list ||
1050 ! gnc_commodity_equiv(commodity, trans->common_currency) ||
1052 {
1053 /* Need to use (or already are using) a list of imbalances in each of
1054 the currencies used in the transaction. */
1055 if (! imbal_list)
1056 {
1057 /* All previous splits have been in the transaction's common
1058 currency, so imbal_value is in this currency. */
1059 imbal_list = gnc_monetary_list_add_value(imbal_list,
1060 trans->common_currency,
1061 imbal_value);
1062 }
1063 imbal_list = gnc_monetary_list_add_value(imbal_list, commodity,
1065 }
1066
1067 /* Add it to the value accumulator in case we need it. */
1068 imbal_value = gnc_numeric_add(imbal_value, xaccSplitGetValue(s),
1069 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
1070 } );
1071
1072
1073 if (!imbal_list && !gnc_numeric_zero_p(imbal_value))
1074 {
1075 /* Not balanced and no list, create one. If we found multiple currencies
1076 and no non-currency commodity then imbal_list will already exist and
1077 we won't get here. */
1078 imbal_list = gnc_monetary_list_add_value(imbal_list,
1079 trans->common_currency,
1080 imbal_value);
1081 }
1082
1083 /* Delete all the zero entries from the list, perhaps leaving an
1084 empty list */
1085 imbal_list = gnc_monetary_list_delete_zeros(imbal_list);
1086
1087 LEAVE("(trans=%p), imbal=%p", trans, imbal_list);
1088 return imbal_list;
1089}
MonetaryList * gnc_monetary_list_delete_zeros(MonetaryList *list)
Delete all entries in the list that have zero value.
gboolean xaccTransUseTradingAccounts(const Transaction *trans)
Determine whether this transaction should use commodity trading accounts.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.

◆ xaccTransGetImbalanceValue()

gnc_numeric xaccTransGetImbalanceValue ( const Transaction *  trans)

The xaccTransGetImbalanceValue() method returns the total value of the transaction.

In a pure double-entry system, this imbalance should be exactly zero, and if it is not, something is broken. However, when double-entry semantics are not enforced, unbalanced transactions can sneak in, and this routine can be used to find out how much things are off by. The value returned is denominated in the currency that is returned by the xaccTransFindCommonCurrency() method.

If the use of currency exchange accounts is enabled then the a a transaction must be balanced in each currency it uses to be considered to be balanced. The method xaccTransGetImbalance is used by most code to take this into consideration. This method is only used in a few places that want the transaction value even if currency exchange accounts are enabled.

Definition at line 118 of file gmock-Transaction.cpp.

119{
120 SCOPED_TRACE("");
121 auto mocktrans = gnc_mocktransaction(trans);
122 return mocktrans ? mocktrans->get_imbalance_value() : gnc_numeric_zero();
123}

◆ xaccTransGetIsClosingTxn()

gboolean xaccTransGetIsClosingTxn ( const Transaction *  trans)

Returns whether this transaction is a "closing transaction".

Definition at line 2243 of file Transaction.cpp.

2244{
2245 auto rv{qof_instance_get_path_kvp<int64_t> (QOF_INSTANCE(trans), {trans_is_closing_str})};
2246 return rv ? *rv != 0 : FALSE;
2247}

◆ xaccTransGetNotes()

const char * xaccTransGetNotes ( const Transaction *  trans)

Gets the transaction Notes.

The Notes field is only visible in the register in double-line mode

Definition at line 103 of file gmock-Transaction.cpp.

104{
105 SCOPED_TRACE("");
106 auto mocktrans = gnc_mocktransaction(trans);
107 return mocktrans ? mocktrans->get_notes() : "";
108}

◆ xaccTransGetNum()

const char * xaccTransGetNum ( const Transaction *  trans)

Gets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_get_num_action' and 'gnc_get_action_num' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically

Definition at line 126 of file gmock-Transaction.cpp.

127{
128 SCOPED_TRACE("");
129 auto mocktrans = gnc_mocktransaction(trans);
130 return mocktrans ? mocktrans->get_num() : "";
131}

◆ xaccTransGetPaymentAcctSplitList()

SplitList * xaccTransGetPaymentAcctSplitList ( const Transaction *  trans)

The xaccTransGetPaymentAcctSplitList() method returns a GList of the splits in a transaction that belong to an account which is considered a valid account for business payments.

Parameters
transThe transaction
Returns
The list of splits. This list must be freed when you are done with it.

Definition at line 2133 of file Transaction.cpp.

2134{
2135 GList *pay_splits = nullptr;
2136 FOR_EACH_SPLIT (trans,
2137 const Account *account = xaccSplitGetAccount(s);
2138 if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account)))
2139 pay_splits = g_list_prepend (pay_splits, s);
2140 );
2141
2142 pay_splits = g_list_reverse (pay_splits);
2143 return pay_splits;
2144}

◆ xaccTransGetReadOnly()

const char * xaccTransGetReadOnly ( Transaction *  trans)

Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text.

Definition at line 2358 of file Transaction.cpp.

2359{
2360 return get_kvp_string_path (trans, {TRANS_READ_ONLY_REASON});
2361}

◆ xaccTransGetReversedBy()

Transaction * xaccTransGetReversedBy ( const Transaction *  trans)

Returns the transaction that reversed the given transaction.

Parameters
transa Transaction that has been reversed
Returns
the transaction that reversed the given transaction, or NULL if the given transaction has not been reversed.

Definition at line 2626 of file Transaction.cpp.

2627{
2628 g_return_val_if_fail(trans, nullptr);
2629 auto g = qof_instance_get_path_kvp<GncGUID*> (QOF_INSTANCE(trans), {TRANS_REVERSED_BY});
2630 return g ? xaccTransLookup (*g, qof_instance_get_book (trans)) : nullptr;
2631}
Transaction * xaccTransLookup(const GncGUID *guid, QofBook *book)
The xaccTransLookup() subroutine will return the transaction associated with the given id,...

◆ xaccTransGetSplit()

Split * xaccTransGetSplit ( const Transaction *  trans,
int  i 
)

Return a pointer to the indexed split in this transaction's split list.

Note that the split list is a linked list and that indexed access is O(N). Do not use this method for iteration.

Parameters
transThe transaction
iThe split number. Valid values for i are zero to (number_of__splits-1).
Returns
A Split* or NULL if i is out of range.

Definition at line 49 of file gmock-Transaction.cpp.

50{
51 SCOPED_TRACE("");
52 auto mocktrans = gnc_mocktransaction(trans);
53 return mocktrans ? mocktrans->get_split(i) : nullptr;
54}

◆ xaccTransGetSplitIndex()

int xaccTransGetSplitIndex ( const Transaction *  trans,
const Split *  split 
)

Inverse of xaccTransGetSplit()

Definition at line 2117 of file Transaction.cpp.

2118{
2119 int j = 0;
2120 g_return_val_if_fail(trans && split, -1);
2121
2122 FOR_EACH_SPLIT(trans, { if (s == split) return j; j++; });
2123 return -1;
2124}

◆ xaccTransGetSplitList()

SplitList * xaccTransGetSplitList ( const Transaction *  trans)

The xaccTransGetSplitList() method returns a GList of the splits in a transaction.

Parameters
transThe transaction
Returns
The list of splits. This list must NOT be modified. Do NOT free this list when you are done with it.

Definition at line 57 of file gmock-Transaction.cpp.

58{
59 g_return_val_if_fail(GNC_IS_MOCKTRANSACTION(trans), NULL);
60 return trans ? ((MockTransaction*)trans)->get_split_list() : NULL;
61}

◆ xaccTransGetTxnType()

char xaccTransGetTxnType ( Transaction *  trans)

Returns the Transaction Type: note this type will be derived from the transaction splits, returning TXN_TYPE_NONE, TXN_TYPE_INVOICE, TXN_TYPE_LINK, or TXN_TYPE_PAYMENT according to heuristics.

It does not query the transaction kvp slots.

See TXN_TYPE_NONE, TXN_TYPE_INVOICE and TXN_TYPE_PAYMENT

Definition at line 2319 of file Transaction.cpp.

2320{
2321 gboolean has_nonAPAR_split = FALSE;
2322
2323 if (!trans) return TXN_TYPE_NONE;
2324
2325 if (trans->txn_type != TXN_TYPE_UNCACHED)
2326 return trans->txn_type;
2327
2328 trans->txn_type = TXN_TYPE_NONE;
2329 for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
2330 {
2331 Account *acc = xaccSplitGetAccount (GNC_SPLIT(n->data));
2332
2333 if (!acc)
2334 continue;
2335
2337 has_nonAPAR_split = TRUE;
2338 else if (trans->txn_type == TXN_TYPE_NONE)
2339 {
2340 GNCLot *lot = xaccSplitGetLot (GNC_SPLIT(n->data));
2341 GncInvoice *invoice = gncInvoiceGetInvoiceFromLot (lot);
2342 GncOwner owner;
2343
2344 if (invoice && trans == gncInvoiceGetPostedTxn (invoice))
2345 trans->txn_type = TXN_TYPE_INVOICE;
2346 else if (invoice || gncOwnerGetOwnerFromLot (lot, &owner))
2347 trans->txn_type = TXN_TYPE_PAYMENT;
2348 }
2349 }
2350
2351 if (!has_nonAPAR_split && (trans->txn_type == TXN_TYPE_PAYMENT))
2352 trans->txn_type = TXN_TYPE_LINK;
2353
2354 return trans->txn_type;
2355}
#define TXN_TYPE_NONE
No transaction type
#define TXN_TYPE_INVOICE
Transaction is an invoice.
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
#define TXN_TYPE_PAYMENT
Transaction is a payment
#define TXN_TYPE_LINK
Transaction is a link between (invoice and payment) lots
GncInvoice * gncInvoiceGetInvoiceFromLot(GNCLot *lot)
Given a LOT, find and return the Invoice attached to the lot.

◆ xaccTransGetVoidReason()

const char * xaccTransGetVoidReason ( const Transaction *  transaction)

Returns the user supplied textual reason why a transaction was voided.

Parameters
transactionThe transaction in question.
Returns
A pointer to the user supplied reason for voiding.

Definition at line 2554 of file Transaction.cpp.

2555{
2556 return get_kvp_string_path (trans, {void_reason_str});
2557}

◆ xaccTransGetVoidStatus()

gboolean xaccTransGetVoidStatus ( const Transaction *  transaction)

Retrieve information on whether or not a transaction has been voided.

Parameters
transactionThe transaction in question.
Returns
TRUE if the transaction is void, FALSE otherwise. Also returns FALSE upon an error.

Definition at line 2547 of file Transaction.cpp.

2548{
2549 auto t = xaccTransGetVoidTime (trans);
2550 return t != INT64_MAX;
2551}
time64 xaccTransGetVoidTime(const Transaction *tr)
Returns the time that a transaction was voided.

◆ xaccTransGetVoidTime()

time64 xaccTransGetVoidTime ( const Transaction *  tr)

Returns the time that a transaction was voided.

Parameters
trThe transaction in question.
Returns
A time64 containing the time that this transaction was voided. Returns INT64_MAX if there is no voided date.

Definition at line 2560 of file Transaction.cpp.

2561{
2562 auto void_str{get_kvp_string_path (tr, {void_time_str})};
2563 return void_str ? gnc_iso8601_to_time64_gmt (void_str) : INT64_MAX;
2564}

◆ xaccTransHasReconciledSplits()

gboolean xaccTransHasReconciledSplits ( const Transaction *  trans)

FIXME: document me.

Definition at line 2454 of file Transaction.cpp.

2455{
2456 return xaccTransHasReconciledSplitsByAccount (trans, nullptr);
2457}
gboolean xaccTransHasReconciledSplitsByAccount(const Transaction *trans, const Account *account)
FIXME: document me.

◆ xaccTransHasReconciledSplitsByAccount()

gboolean xaccTransHasReconciledSplitsByAccount ( const Transaction *  trans,
const Account account 
)

FIXME: document me.

Definition at line 2425 of file Transaction.cpp.

2427{
2428 GList *node;
2429
2430 for (node = xaccTransGetSplitList (trans); node; node = node->next)
2431 {
2432 Split *split = GNC_SPLIT(node->data);
2433
2434 if (!xaccTransStillHasSplit(trans, split))
2435 continue;
2436 if (account && (xaccSplitGetAccount(split) != account))
2437 continue;
2438
2439 switch (xaccSplitGetReconcile (split))
2440 {
2441 case YREC:
2442 case FREC:
2443 return TRUE;
2444
2445 default:
2446 break;
2447 }
2448 }
2449
2450 return FALSE;
2451}
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
#define FREC
frozen into accounting period
Definition Split.h:75
#define YREC
The Split has been reconciled.
Definition Split.h:74

◆ xaccTransHasSplitsInState()

gboolean xaccTransHasSplitsInState ( const Transaction *  trans,
const char  state 
)

FIXME: document me.

Definition at line 2484 of file Transaction.cpp.

2485{
2486 return xaccTransHasSplitsInStateByAccount (trans, state, nullptr);
2487}
gboolean xaccTransHasSplitsInStateByAccount(const Transaction *trans, const char state, const Account *account)
FIXME: document me.

◆ xaccTransHasSplitsInStateByAccount()

gboolean xaccTransHasSplitsInStateByAccount ( const Transaction *  trans,
const char  state,
const Account account 
)

FIXME: document me.

Definition at line 2461 of file Transaction.cpp.

2464{
2465 GList *node;
2466
2467 for (node = xaccTransGetSplitList (trans); node; node = node->next)
2468 {
2469 Split *split = GNC_SPLIT(node->data);
2470
2471 if (!xaccTransStillHasSplit(trans, split))
2472 continue;
2473 if (account && (xaccSplitGetAccount(split) != account))
2474 continue;
2475
2476 if (split->reconciled == state)
2477 return TRUE;
2478 }
2479
2480 return FALSE;
2481}

◆ xaccTransIsBalanced()

gboolean xaccTransIsBalanced ( const Transaction *  trans)

Returns true if the transaction is balanced according to the rules currently in effect.

Definition at line 1092 of file Transaction.cpp.

1093{
1094 MonetaryList *imbal_list;
1095 gboolean result;
1096 gnc_numeric imbal = gnc_numeric_zero();
1097 gnc_numeric imbal_trading = gnc_numeric_zero();
1098
1099 if (trans == nullptr) return FALSE;
1100
1101 if (xaccTransUseTradingAccounts(trans))
1102 {
1103 /* Transaction is imbalanced if the value is imbalanced in either
1104 trading or non-trading splits. One can't be used to balance
1105 the other. */
1106 FOR_EACH_SPLIT(trans,
1107 {
1108 Account *acc = xaccSplitGetAccount(s);
1109 if (!acc || xaccAccountGetType(acc) != ACCT_TYPE_TRADING)
1110 {
1111 imbal = gnc_numeric_add(imbal, xaccSplitGetValue(s),
1112 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
1113 }
1114 else
1115 {
1116 imbal_trading = gnc_numeric_add(imbal_trading, xaccSplitGetValue(s),
1117 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
1118 }
1119 }
1120 );
1121 }
1122 else
1123 imbal = xaccTransGetImbalanceValue(trans);
1124
1125 if (! gnc_numeric_zero_p(imbal) || ! gnc_numeric_zero_p(imbal_trading))
1126 return FALSE;
1127
1128 if (!xaccTransUseTradingAccounts (trans))
1129 return TRUE;
1130
1131 imbal_list = xaccTransGetImbalance(trans);
1132 result = imbal_list == nullptr;
1133 gnc_monetary_list_free(imbal_list);
1134 return result;
1135}
void gnc_monetary_list_free(MonetaryList *list)
Free a MonetaryList and all the monetaries it points to.
MonetaryList * xaccTransGetImbalance(const Transaction *trans)
The xaccTransGetImbalance method returns a list giving the value of the transaction in each currency ...
gnc_numeric xaccTransGetImbalanceValue(const Transaction *trans)
The xaccTransGetImbalanceValue() method returns the total value of the transaction.

◆ xaccTransIsOpen()

gboolean xaccTransIsOpen ( const Transaction *  trans)

The xaccTransIsOpen() method returns TRUE if the transaction is open for editing.

Otherwise, it returns false. XXX this routine should probably be deprecated. its, umm, hard to imagine legitimate uses (but it is used by the import/export code for reasons I can't understand.)

Definition at line 142 of file gmock-Transaction.cpp.

143{
144 SCOPED_TRACE("");
145 auto mocktrans = gnc_mocktransaction(trans);
146 return mocktrans ? mocktrans->is_open() : FALSE;
147}

◆ xaccTransIsReadonlyByPostedDate()

gboolean xaccTransIsReadonlyByPostedDate ( const Transaction *  trans)

Returns TRUE if this Transaction is read-only because its posted-date is older than the "auto-readonly" threshold of this book.

See qof_book_uses_autofreeze() and qof_book_get_autofreeze_gdate().

Definition at line 2386 of file Transaction.cpp.

2387{
2388 GDate *threshold_date;
2389 GDate trans_date;
2390 const QofBook *book = xaccTransGetBook (trans);
2391 gboolean result;
2392 g_assert(trans);
2393
2394 if (!qof_book_uses_autoreadonly(book))
2395 {
2396 return FALSE;
2397 }
2398
2399 if (xaccTransIsSXTemplate (trans))
2400 return FALSE;
2401
2402 threshold_date = qof_book_get_autoreadonly_gdate(book);
2403 g_assert(threshold_date); // ok because we checked uses_autoreadonly before
2404 trans_date = xaccTransGetDatePostedGDate(trans);
2405
2406// g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",
2407// qof_book_get_num_days_autofreeze(book),
2408// g_date_get_day(&trans_date),
2409// g_date_get_day(threshold_date));
2410
2411 if (g_date_compare(&trans_date, threshold_date) < 0)
2412 {
2413 //g_warning("we are auto-read-only");
2414 result = TRUE;
2415 }
2416 else
2417 {
2418 result = FALSE;
2419 }
2420 g_date_free(threshold_date);
2421 return result;
2422}
GDate * qof_book_get_autoreadonly_gdate(const QofBook *book)
Returns the GDate that is the threshold for auto-read-only.
Definition qofbook.cpp:1006
gboolean qof_book_uses_autoreadonly(const QofBook *book)
Returns TRUE if the auto-read-only feature should be used, otherwise FALSE.
Definition qofbook.cpp:974
GDate xaccTransGetDatePostedGDate(const Transaction *trans)
Retrieve the posted date of the transaction.
#define xaccTransGetBook(X)
QofBook reference.
Definition qofbook-p.hpp:47

◆ xaccTransLookup()

Transaction * xaccTransLookup ( const GncGUID guid,
QofBook book 
)

The xaccTransLookup() subroutine will return the transaction associated with the given id, or NULL if there is no such transaction.

Definition at line 992 of file Transaction.cpp.

993{
994 QofCollection *col;
995 if (!guid || !book) return nullptr;
996 col = qof_book_get_collection (book, GNC_ID_TRANS);
997 return (Transaction *) qof_collection_lookup_entity (col, guid);
998}
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition qofbook.cpp:521
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
Definition qofid.cpp:209

◆ xaccTransOrder()

int xaccTransOrder ( const Transaction *  ta,
const Transaction *  tb 
)

The xaccTransOrder(ta,tb) method is useful for sorting.

Orders ta and tb return <0 if ta sorts before tb return >0 if ta sorts after tb return 0 if they are absolutely equal

The comparrison uses the following fields, in order: date posted (compare as a date) num field (compare as an integer) date entered (compare as a date) description field (comcpare as a string using strcmp()) GncGUID (compare as a guid) Finally, it returns zero if all of the above match. Note that it does NOT compare its member splits. Note also that it calls xaccTransOrder_num_action with actna and actnb set as NULL.

Definition at line 1771 of file Transaction.cpp.

1772{
1773 return xaccTransOrder_num_action (ta, nullptr, tb, nullptr);
1774}
int xaccTransOrder_num_action(const Transaction *ta, const char *actna, const Transaction *tb, const char *actnb)
The xaccTransOrder_num_action(ta,actna,tb,actnb) method is useful for sorting.

◆ xaccTransOrder_num_action()

int xaccTransOrder_num_action ( const Transaction *  ta,
const char *  actna,
const Transaction *  tb,
const char *  actnb 
)

The xaccTransOrder_num_action(ta,actna,tb,actnb) method is useful for sorting.

Orders ta and tb return <0 if ta sorts before tb return >0 if ta sorts after tb return 0 if they are absolutely equal

The comparrison uses the following fields, in order: date posted (compare as a date) if actna and actnb are NULL, num field (compare as an integer) else actna and actnb (compare as an integer) date entered (compare as a date) description field (comcpare as a string using strcmp()) GncGUID (compare as a guid) Finally, it returns zero if all of the above match. Note that it does NOT compare its member splits (except action as specified above).

Definition at line 1807 of file Transaction.cpp.

1809{
1810 const char *da, *db;
1811 int retval;
1812
1813 if (ta == tb) return 0;
1814 if (!tb) return -1;
1815 if (!ta) return +1;
1816
1817 if (ta->date_posted != tb->date_posted)
1818 return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
1819
1820 /* Always sort closing transactions after normal transactions */
1821 {
1822 gboolean ta_is_closing = xaccTransGetIsClosingTxn (ta);
1823 gboolean tb_is_closing = xaccTransGetIsClosingTxn (tb);
1824 if (ta_is_closing != tb_is_closing)
1825 return (ta_is_closing - tb_is_closing);
1826 }
1827
1828 /* otherwise, sort on number string */
1829 if (actna && actnb) /* split action string, if not nullptr */
1830 {
1831 retval = order_by_int64_or_string (actna, actnb);
1832 }
1833 else /* else transaction num string */
1834 {
1835 retval = order_by_int64_or_string (ta->num, tb->num);
1836 }
1837 if (retval)
1838 return retval;
1839
1840 if (ta->date_entered != tb->date_entered)
1841 return (ta->date_entered > tb->date_entered) - (ta->date_entered < tb->date_entered);
1842
1843 /* otherwise, sort on description string */
1844 da = ta->description ? ta->description : "";
1845 db = tb->description ? tb->description : "";
1846 retval = g_utf8_collate (da, db);
1847 if (retval)
1848 return retval;
1849
1850 /* else, sort on guid - keeps sort stable. */
1851 return qof_instance_guid_compare(ta, tb);
1852}
gboolean xaccTransGetIsClosingTxn(const Transaction *trans)
Returns whether this transaction is a "closing transaction".

◆ xaccTransRecordPrice()

void xaccTransRecordPrice ( Transaction *  trans,
PriceSource  source 
)

The xaccTransRecordPrice() method iterates through the splits and and record the non-currency equivalent prices in the price database.

Parameters
transThe transaction whose price is recorded
sourceThe price priority level

Definition at line 157 of file gmock-Transaction.cpp.

158{
159 g_return_if_fail(GNC_IS_MOCKTRANSACTION(trans));
160 ((MockTransaction*)trans)->recordPrice();
161}

◆ xaccTransRetDateDue()

time64 xaccTransRetDateDue ( const Transaction *  trans)

Dates and txn-type for A/R and A/P "invoice" postings.

Definition at line 2311 of file Transaction.cpp.

2312{
2313 if (!trans) return 0;
2314 auto res = qof_instance_get_path_kvp<Time64> (QOF_INSTANCE (trans), {TRANS_DATE_DUE_KVP});
2315 return res ? res->t : xaccTransRetDatePosted (trans);
2316}

◆ xaccTransRetDateEntered()

time64 xaccTransRetDateEntered ( const Transaction *  trans)

Retrieve the date of when the transaction was entered.

The entered date is the date when the register entry was made.

Definition at line 2305 of file Transaction.cpp.

2306{
2307 return trans ? trans->date_entered : 0;
2308}

◆ xaccTransRetDatePosted()

time64 xaccTransRetDatePosted ( const Transaction *  trans)

Retrieve the posted date of the transaction.

The posted date is the date when this transaction was posted at the bank. (Although having different function names, GetDate and GetDatePosted refer to the same single date.)

Definition at line 2267 of file Transaction.cpp.

2268{
2269 return trans ? trans->date_posted : 0;
2270}

◆ xaccTransReverse()

Transaction * xaccTransReverse ( Transaction *  transaction)

xaccTransReverse creates a Transaction that reverses the given transaction by inverting all the numerical values in the given transaction.

This function cancels out the effect of an earlier transaction. This will be needed by write only accounts as a way to void a previous transaction (since you can't alter the existing transaction).

Parameters
transactionThe transaction to create a reverse of.
Returns
a new transaction which reverses the given transaction

Definition at line 2589 of file Transaction.cpp.

2590{
2591 Transaction *trans;
2592 g_return_val_if_fail(orig, nullptr);
2593
2594 /* First edit, dirty, and commit orig to ensure that any trading
2595 * splits are correctly balanced.
2596 */
2597 xaccTransBeginEdit (orig);
2598 qof_instance_set_dirty (QOF_INSTANCE (orig));
2599 xaccTransCommitEdit (orig);
2600
2601 trans = xaccTransClone(orig);
2602 g_return_val_if_fail (trans, nullptr);
2603 xaccTransBeginEdit(trans);
2604
2605 /* Reverse the values on each split. Clear per-split info. */
2606 FOR_EACH_SPLIT(trans,
2607 {
2611 });
2612
2613 /* Now update the original with a pointer to the new one */
2614 qof_instance_set_path_kvp<GncGUID*> (QOF_INSTANCE (orig), guid_copy(xaccTransGetGUID(trans)),
2615 {TRANS_REVERSED_BY});
2616
2617 /* Make sure the reverse transaction is not read-only */
2618 xaccTransClearReadOnly(trans);
2619
2620 qof_instance_set_dirty(QOF_INSTANCE(trans));
2621 xaccTransCommitEdit(trans);
2622 return trans;
2623}
#define xaccTransGetGUID(X)
Transaction * xaccTransClone(const Transaction *from)
The xaccTransClone() method will create a complete copy of an existing transaction.
GncGUID * guid_copy(const GncGUID *guid)
Returns a newly allocated GncGUID that matches the passed-in GUID.
Definition guid.cpp:155
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
#define NREC
not reconciled or cleared
Definition Split.h:76

◆ xaccTransRollbackEdit()

void xaccTransRollbackEdit ( Transaction *  trans)

The xaccTransRollbackEdit() routine rejects all edits made, and sets the transaction back to where it was before the editing started.

This includes restoring any deleted splits, removing any added splits, and undoing the effects of xaccTransDestroy, as well as restoring share quantities, memos, descriptions, etc.

Todo:
Fix transrollbackedit in QOF so that rollback is exposed via the API.

Definition at line 1604 of file Transaction.cpp.

1605{
1606 GList *node, *onode;
1607 QofBackend *be;
1608 Transaction *orig;
1609 GList *slist;
1610 int num_preexist, i;
1611
1612/* FIXME: This isn't quite the right way to handle nested edits --
1613 * there should be a stack of transaction states that are popped off
1614 * and restored at each level -- but it does prevent restoring to the
1615 * editlevel 0 state until one is returning to editlevel 0, and
1616 * thereby prevents a crash caused by trans->orig getting nullptred too
1617 * soon.
1618 */
1619 if (!qof_instance_get_editlevel (QOF_INSTANCE (trans))) return;
1620 if (qof_instance_get_editlevel (QOF_INSTANCE (trans)) > 1) {
1621 qof_instance_decrease_editlevel (QOF_INSTANCE (trans));
1622 return;
1623 }
1624
1625 ENTER ("trans addr=%p\n", trans);
1626
1627 check_open(trans);
1628
1629 /* copy the original values back in. */
1630
1631 orig = trans->orig;
1632 std::swap (trans->num, orig->num);
1633 std::swap (trans->description, orig->description);
1634 trans->date_entered = orig->date_entered;
1635 trans->date_posted = orig->date_posted;
1636 std::swap (trans->common_currency, orig->common_currency);
1637 qof_instance_swap_kvp (QOF_INSTANCE (trans), QOF_INSTANCE (orig));
1638
1639 /* The splits at the front of trans->splits are exactly the same
1640 splits as in the original, but some of them may have changed, so
1641 we restore only those. */
1642/* FIXME: Runs off the transaction's splits, so deleted splits are not
1643 * restored!
1644 */
1645 num_preexist = g_list_length(orig->splits);
1646 slist = g_list_copy(trans->splits);
1647 for (i = 0, node = slist, onode = orig->splits; node;
1648 i++, node = node->next, onode = onode ? onode->next : nullptr)
1649 {
1650 Split *s = GNC_SPLIT(node->data);
1651
1652 if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
1653 continue;
1654
1655 if (i < num_preexist && onode)
1656 {
1657 Split *so = GNC_SPLIT(onode->data);
1658
1659 xaccSplitRollbackEdit(s);
1660 std::swap (s->action, so->action);
1661 std::swap (s->memo, so->memo);
1662 qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so));
1663 s->reconciled = so->reconciled;
1664 s->amount = so->amount;
1665 s->value = so->value;
1666 s->lot = so->lot;
1667 s->gains_split = so->gains_split;
1668 //SET_GAINS_A_VDIRTY(s);
1669 s->date_reconciled = so->date_reconciled;
1670 qof_instance_mark_clean(QOF_INSTANCE(s));
1671 }
1672 else
1673 {
1674 /* Potentially added splits */
1675 if (trans != xaccSplitGetParent(s))
1676 {
1677 trans->splits = g_list_remove(trans->splits, s);
1678 /* New split added, but then moved to another
1679 transaction */
1680 continue;
1681 }
1682 xaccSplitRollbackEdit(s);
1683 trans->splits = g_list_remove(trans->splits, s);
1684 g_assert(trans != xaccSplitGetParent(s));
1685 /* NB: our memory management policy here is that a new split
1686 added to the transaction which is then rolled-back still
1687 belongs to the engine. Specifically, it's freed by the
1688 transaction to which it was added. Don't add the Split to
1689 more than one transaction during the begin/commit block! */
1690 if (nullptr == xaccSplitGetParent(s))
1691 {
1692 xaccFreeSplit(s); // a newly malloc'd split
1693 }
1694 }
1695 }
1696 g_list_free(slist);
1697
1698 // orig->splits may still have duped splits so free them
1699 g_list_free_full (orig->splits, (GDestroyNotify)xaccFreeSplit);
1700 orig->splits = nullptr;
1701
1702 /* Now that the engine copy is back to its original version,
1703 * get the backend to fix it in the database */
1707 if (qof_backend_can_rollback (be))
1708 {
1709 QofBackendError errcode;
1710
1711 /* clear errors */
1712 do
1713 {
1714 errcode = qof_backend_get_error (be);
1715 }
1716 while (ERR_BACKEND_NO_ERR != errcode);
1717
1718 qof_backend_rollback_instance (be, &(trans->inst));
1719
1720 errcode = qof_backend_get_error (be);
1721 if (ERR_BACKEND_MOD_DESTROY == errcode)
1722 {
1723 /* The backend is asking us to delete this transaction.
1724 * This typically happens because another (remote) user
1725 * has deleted this transaction, and we haven't found
1726 * out about it until this user tried to edit it.
1727 */
1728 xaccTransDestroy (trans);
1729 do_destroy (QOF_INSTANCE(trans));
1730
1731 /* push error back onto the stack */
1732 qof_backend_set_error (be, errcode);
1733 LEAVE ("deleted trans addr=%p\n", trans);
1734 return;
1735 }
1736 if (ERR_BACKEND_NO_ERR != errcode)
1737 {
1738 PERR ("Rollback Failed. Ouch!");
1739 /* push error back onto the stack */
1740 qof_backend_set_error (be, errcode);
1741 }
1742 }
1743
1745 xaccTransWriteLog (trans, 'R');
1746
1747 xaccFreeTransaction (trans->orig);
1748
1749 trans->orig = nullptr;
1750 qof_instance_set_destroying(trans, FALSE);
1751
1752 /* Put back to zero. */
1753 qof_instance_decrease_editlevel(trans);
1754 /* FIXME: The register code seems to depend on the engine to
1755 generate an event during rollback, even though the state is just
1756 reverting to what it was. */
1757 gen_event_trans (trans);
1758
1759 LEAVE ("trans addr=%p\n", trans);
1760}
void qof_backend_set_error(QofBackend *qof_be, QofBackendError err)
Set the error on the specified QofBackend.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
Definition qofbackend.h:58
QofBackend * qof_book_get_backend(const QofBook *book)
Retrieve the backend used by this book.
Definition qofbook.cpp:440
QofBackendError qof_backend_get_error(QofBackend *qof_be)
Get the last backend error.
@ ERR_BACKEND_MOD_DESTROY
commit of object update failed because another user has deleted the object
Definition qofbackend.h:77
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
Definition qofbook.cpp:497
#define qof_instance_is_dirty
Return value of is_dirty flag.
void xaccTransWriteLog(Transaction *trans, char flag)
Definition TransLog.cpp:222

◆ xaccTransScrubGains()

void xaccTransScrubGains ( Transaction *  trans,
Account gain_acc 
)

The xaccTransScrubGains() routine performs a number of cleanup functions on the indicated transaction, with the end-goal of setting up a consistent set of gains/losses for all the splits in the transaction.

This includes making sure that the lot assignments of all the splits are good, and that the lots balance appropriately.

Definition at line 2676 of file Transaction.cpp.

2677{
2678 SplitList *node;
2679
2680 ENTER("(trans=%p)", trans);
2681 /* Lock down posted date, its to be synced to the posted date
2682 * for the source of the cap gains. */
2683 xaccTransScrubGainsDate(trans);
2684
2685 /* Fix up the split amount */
2686restart:
2687 for (node = trans->splits; node; node = node->next)
2688 {
2689 Split *s = GNC_SPLIT(node->data);
2690
2691 if (!xaccTransStillHasSplit(trans, s)) continue;
2692
2693 xaccSplitDetermineGainStatus(s);
2694 if (s->gains & GAINS_STATUS_ADIRTY)
2695 {
2696 gboolean altered = FALSE;
2697 s->gains &= ~GAINS_STATUS_ADIRTY;
2698 if (s->lot)
2699 altered = xaccScrubLot(s->lot);
2700 else
2701 altered = xaccSplitAssign(s);
2702 if (altered) goto restart;
2703 }
2704 }
2705
2706 /* Fix up gains split value */
2707 FOR_EACH_SPLIT(trans,
2708 if ((s->gains & GAINS_STATUS_VDIRTY) ||
2709 (s->gains_split &&
2710 (s->gains_split->gains & GAINS_STATUS_VDIRTY)))
2711 xaccSplitComputeCapGains(s, gain_acc);
2712 );
2713
2714 LEAVE("(trans=%p)", trans);
2715}
gboolean xaccSplitAssign(Split *split)
The`xaccSplitAssign() routine will take the indicated split and, if it doesn't already belong to a lo...
void xaccSplitComputeCapGains(Split *split, Account *gain_acc)
The xaccSplitComputeCapGains() routine computes the cap gains or losses for the indicated split.
GList SplitList
GList of Split.
Definition gnc-engine.h:207
gboolean xaccScrubLot(GNCLot *lot)
The xaccScrubLot() routine makes sure that the indicated lot is self-consistent and properly balanced...
Definition Scrub3.cpp:85

◆ xaccTransSetCurrency()

void xaccTransSetCurrency ( Transaction *  trans,
gnc_commodity *  curr 
)

Set the commodity of this transaction.

Set the commodity of this transaction.

When we do that to a transaction with splits we need to re-value all of the splits in the new currency.

Parameters
transThe transaction to change
currThe new currency to set.

Definition at line 1325 of file Transaction.cpp.

1326{
1327 gnc_commodity *old_curr = trans->common_currency;
1328 if (!trans || !curr || trans->common_currency == curr) return;
1329 xaccTransBeginEdit(trans);
1330
1331 trans->common_currency = curr;
1332 if (old_curr != nullptr && trans->splits != nullptr)
1333 {
1334 gnc_numeric rate = find_new_rate(trans, curr);
1335 if (!gnc_numeric_zero_p (rate))
1336 {
1337 FOR_EACH_SPLIT(trans, split_set_new_value(s, curr, old_curr, rate));
1338 }
1339 else
1340 {
1341 FOR_EACH_SPLIT(trans, xaccSplitSetValue(s, xaccSplitGetValue(s)));
1342 }
1343 }
1344
1345 qof_instance_set_dirty(QOF_INSTANCE(trans));
1346 mark_trans(trans); /* Dirty balance of every account in trans */
1347 xaccTransCommitEdit(trans);
1348}

◆ xaccTransSetDate()

void xaccTransSetDate ( Transaction *  trans,
int  day,
int  mon,
int  year 
)

The xaccTransSetDate() method does the same thing as xaccTransSetDate[Posted]Secs(), but takes a convenient day-month-year format.

(Footnote: this shouldn't matter to a user, but anyone modifying the engine should understand that when xaccTransCommitEdit() is called, the date order of each of the component splits will be checked, and will be restored in ascending date order.)

Definition at line 1950 of file Transaction.cpp.

1951{
1952 if (!trans) return;
1953 GDate date;
1954 g_date_clear (&date, 1);
1955 if (g_date_valid_dmy (day, static_cast<GDateMonth>(mon), year))
1956 g_date_set_dmy (&date, day, static_cast<GDateMonth>(mon), year);
1957 else
1958 {
1959 PWARN("Attempted to set invalid date %d-%d-%d; set today's date instead.",
1960 year, mon, day);
1961 gnc_gdate_set_today (&date);
1962 }
1963 xaccTransSetDatePostedGDate(trans, date);
1964}
void gnc_gdate_set_today(GDate *gd)
Set a GDate to the current day.
void xaccTransSetDatePostedGDate(Transaction *trans, GDate date)
This method modifies posted date of the transaction, specified by a GDate.

◆ xaccTransSetDateDue()

void xaccTransSetDateDue ( Transaction *  trans,
time64  time 
)

Dates and txn-type for A/R and A/P "invoice" postings.

Definition at line 1967 of file Transaction.cpp.

1968{
1969 if (!trans) return;
1970 xaccTransBeginEdit(trans);
1971 qof_instance_set_path_kvp<Time64> (QOF_INSTANCE (trans), Time64{time}, {TRANS_DATE_DUE_KVP});
1972 qof_instance_set_dirty(QOF_INSTANCE(trans));
1973 xaccTransCommitEdit(trans);
1974}

◆ xaccTransSetDateEnteredSecs()

void xaccTransSetDateEnteredSecs ( Transaction *  trans,
time64  time 
)

Modify the date of when the transaction was entered.

The entered date is the date when the register entry was made.

Definition at line 1943 of file Transaction.cpp.

1944{
1945 if (!trans) return;
1946 xaccTransSetDateInternal(trans, &trans->date_entered, secs);
1947}

◆ xaccTransSetDatePostedGDate()

void xaccTransSetDatePostedGDate ( Transaction *  trans,
GDate  date 
)

This method modifies posted date of the transaction, specified by a GDate.

The posted date is the date when this transaction was posted at the bank.

This is identical to xaccTransSetDate(), but different from xaccTransSetDatePostedSecs which artificially introduces the time-of-day part, which needs to be ignored.

Definition at line 1927 of file Transaction.cpp.

1928{
1929 if (!trans) return;
1930
1931 /* We additionally save this date into a kvp frame to ensure in
1932 * the future a date which was set as *date* (without time) can
1933 * clearly be distinguished from the time64. */
1934 qof_instance_set_path_kvp<GDate> (QOF_INSTANCE(trans), date, {TRANS_DATE_POSTED});
1935 qof_instance_set_dirty (QOF_INSTANCE(trans));
1936 /* mark dirty and commit handled by SetDateInternal */
1937 xaccTransSetDateInternal(trans, &trans->date_posted,
1938 gdate_to_time64(date));
1939 set_gains_date_dirty (trans);
1940}

◆ xaccTransSetDatePostedSecs()

void xaccTransSetDatePostedSecs ( Transaction *  trans,
time64  time 
)

The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction, specified by a time64 (see ctime(3)).

The posted date is the date when this transaction was posted at the bank.

Please do not use this function, as the extra time-of-day part messes up a lot of places. Rather, please use xaccTransSetDatePostedGDate() or xaccTransSetDatePostedSecsNormalized().

Definition at line 1911 of file Transaction.cpp.

1912{
1913 if (!trans) return;
1914 xaccTransSetDateInternal(trans, &trans->date_posted, secs);
1915 set_gains_date_dirty(trans);
1916}

◆ xaccTransSetDatePostedSecsNormalized()

void xaccTransSetDatePostedSecsNormalized ( Transaction *  trans,
time64  time 
)

This function sets the posted date of the transaction, specified by a time64 (see ctime(3)).

Contrary to xaccTransSetDatePostedSecs(), the time will be normalized to only the date part, and the time-of-day will be ignored. The resulting date is the same as if it had been set as a GDate through xaccTransSetDatePostedGDate().

Please prefer this function over xaccTransSetDatePostedSecs().

The posted date is the date when this transaction was posted at the bank.

Definition at line 81 of file gmock-Transaction.cpp.

82{
83 ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
84 gnc_mocktransaction(trans)->set_date_posted_secs_normalized(time);
85}

◆ xaccTransSetDescription()

void xaccTransSetDescription ( Transaction *  trans,
const char *  desc 
)

Sets the transaction Description.

Definition at line 96 of file gmock-Transaction.cpp.

97{
98 ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
99 gnc_mocktransaction(trans)->set_description(desc);
100}

◆ xaccTransSetDocLink()

void xaccTransSetDocLink ( Transaction *  trans,
const char *  doclink 
)

Sets the transaction Document Link.

Definition at line 2040 of file Transaction.cpp.

2041{
2042 if (!trans || !doclink) return;
2043 set_kvp_string_path (trans, {doclink_uri_str}, doclink);
2044}

◆ xaccTransSetIsClosingTxn()

void xaccTransSetIsClosingTxn ( Transaction *  trans,
gboolean  is_closing 
)

Sets whether or not this transaction is a "closing transaction".

Definition at line 2062 of file Transaction.cpp.

2063{
2064 xaccTransBeginEdit(trans);
2065 auto val = is_closing ? std::make_optional<int64_t>(1) : std::nullopt;
2066 qof_instance_set_path_kvp<int64_t> (QOF_INSTANCE(trans), val, {trans_is_closing_str});
2067 xaccTransCommitEdit(trans);
2068}

◆ xaccTransSetNotes()

void xaccTransSetNotes ( Transaction *  trans,
const char *  notes 
)

Sets the transaction Notes.

The Notes field is only visible in the register in double-line mode

Definition at line 111 of file gmock-Transaction.cpp.

112{
113 ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
114 gnc_mocktransaction(trans)->set_notes(notes);
115}

◆ xaccTransSetNum()

void xaccTransSetNum ( Transaction *  trans,
const char *  num 
)

Sets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_set_num_action' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically

Definition at line 2009 of file Transaction.cpp.

2010{
2011 if (!trans || !xnum) return;
2012 xaccTransBeginEdit(trans);
2013
2014 CACHE_REPLACE(trans->num, xnum);
2015 qof_instance_set_dirty(QOF_INSTANCE(trans));
2016 mark_trans(trans); /* Dirty balance of every account in trans */
2017 xaccTransCommitEdit(trans);
2018}

◆ xaccTransSetReadOnly()

void xaccTransSetReadOnly ( Transaction *  trans,
const char *  reason 
)

Set the transaction to be ReadOnly by setting a non-NULL value as "reason".

FIXME: If "reason" is NULL, this function does nothing, instead of removing the readonly flag; the actual removal is possible only through xaccTransClearReadOnly().

Definition at line 1989 of file Transaction.cpp.

1990{
1991 if (trans && reason)
1992 set_kvp_string_path (trans, {TRANS_READ_ONLY_REASON}, reason);
1993}

◆ xaccTransSetTxnType()

void xaccTransSetTxnType ( Transaction *  trans,
char  type 
)

Set the Transaction Type: note the type will be saved into the Transaction kvp property as a backward compatibility measure, for previous GnuCash versions whose xaccTransGetTxnType reads from the kvp slots.

See TXN_TYPE_NONE, TXN_TYPE_INVOICE and TXN_TYPE_PAYMENT

Definition at line 1977 of file Transaction.cpp.

1978{
1979 char s[2] = {type, '\0'};
1980 set_kvp_string_path (trans, {TRANS_TXN_TYPE_KVP}, s);
1981}

◆ xaccTransSortSplits()

void xaccTransSortSplits ( Transaction *  trans)

Sorts the splits in a transaction, putting the debits first, followed by the credits.

Definition at line 541 of file Transaction.cpp.

542{
543 GList *node, *new_list = nullptr;
544 Split *split;
545
546 /* first debits */
547 for (node = trans->splits; node; node = node->next)
548 {
549 split = GNC_SPLIT(node->data);
551 continue;
552 new_list = g_list_prepend (new_list, split);
553 }
554
555 /* then credits */
556 for (node = trans->splits; node; node = node->next)
557 {
558 split = GNC_SPLIT(node->data);
560 continue;
561 new_list = g_list_prepend (new_list, split);
562 }
563
564 /* install newly sorted list */
565 g_list_free(trans->splits);
566 trans->splits = g_list_reverse (new_list);
567}
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.

◆ xaccTransStillHasSplit()

gboolean xaccTransStillHasSplit ( const Transaction *  trans,
const Split *  s 
)

Definition at line 214 of file Transaction.cpp.

215{
216 return (s && s->parent == trans && !qof_instance_get_destroying(s));
217}
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.

◆ xaccTransUnvoid()

void xaccTransUnvoid ( Transaction *  transaction)

xaccTransUnvoid restores a voided transaction to its original state.

At some point when gnucash is enhanced to support an audit trail (i.e. write only transactions) this command should be automatically disabled when the audit trail feature is enabled.

Parameters
transactionThe transaction to restore from voided state.

Definition at line 2567 of file Transaction.cpp.

2568{
2569 g_return_if_fail(trans);
2570
2571 if (!xaccTransGetVoidStatus (trans))
2572 return; /* Transaction isn't voided. Bail. */
2573
2574 xaccTransBeginEdit(trans);
2575
2576 set_kvp_string_path (trans, {trans_notes_str}, get_kvp_string_path (trans, {void_former_notes_str}));
2577 set_kvp_string_path (trans, {void_former_notes_str}, nullptr);
2578 set_kvp_string_path (trans, {void_reason_str}, nullptr);
2579 set_kvp_string_path (trans, {void_time_str}, nullptr);
2580
2581 FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s));
2582
2583 /* Dirtying taken care of by ClearReadOnly */
2584 xaccTransClearReadOnly(trans);
2585 xaccTransCommitEdit(trans);
2586}
gboolean xaccTransGetVoidStatus(const Transaction *trans)
Retrieve information on whether or not a transaction has been voided.

◆ xaccTransUseTradingAccounts()

gboolean xaccTransUseTradingAccounts ( const Transaction *  trans)

Determine whether this transaction should use commodity trading accounts.

Definition at line 983 of file Transaction.cpp.

984{
986}
gboolean qof_book_use_trading_accounts(const QofBook *book)
Returns flag indicating whether this book uses trading accounts.
Definition qofbook.cpp:921

◆ xaccTransVoid()

void xaccTransVoid ( Transaction *  transaction,
const char *  reason 
)

xaccTransVoid voids a transaction.

A void transaction has no values, is unaffected by reconciliation, and, by default is not included in any queries. A voided transaction may not be altered.

Parameters
transactionThe transaction to void.
reasonThe textual reason why this transaction is being voided.

Definition at line 2516 of file Transaction.cpp.

2517{
2518 g_return_if_fail(trans && reason);
2519
2520 /* Prevent voiding transactions that are already marked
2521 * read only, for example generated by the business features.
2522 */
2523 if (xaccTransGetReadOnly (trans))
2524 {
2525 PWARN ("Refusing to void a read-only transaction!");
2526 return;
2527 }
2528 xaccTransBeginEdit(trans);
2529
2530 char iso8601_str[ISO_DATELENGTH + 1] = "";
2531 gnc_time64_to_iso8601_buff (gnc_time(nullptr), iso8601_str);
2532
2533 if (auto s = get_kvp_string_path (trans, {trans_notes_str}))
2534 set_kvp_string_path (trans, {void_former_notes_str}, s);
2535 set_kvp_string_path (trans, {trans_notes_str}, _("Voided transaction"));
2536 set_kvp_string_path (trans, {void_reason_str}, reason);
2537 set_kvp_string_path (trans, {void_time_str}, iso8601_str);
2538
2539 FOR_EACH_SPLIT(trans, xaccSplitVoid(s));
2540
2541 /* Dirtying taken care of by SetReadOnly */
2542 xaccTransSetReadOnly(trans, _("Transaction Voided"));
2543 xaccTransCommitEdit(trans);
2544}
time64 gnc_time(time64 *tbuf)
get the current time
Definition gnc-date.cpp:262
void xaccTransSetReadOnly(Transaction *trans, const char *reason)
Set the transaction to be ReadOnly by setting a non-NULL value as "reason".
const char * xaccTransGetReadOnly(Transaction *trans)
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text...

Variable Documentation

◆ m_data

void* GncOptionDBCallback::m_data

Definition at line 98 of file gnc-optiondb-impl.hpp.

◆ m_doc_string

std::string OptionClassifier::m_doc_string

Definition at line 75 of file gnc-option-impl.hpp.

◆ m_func

GncOptionDBChangeCallback GncOptionDBCallback::m_func

Definition at line 97 of file gnc-optiondb-impl.hpp.

◆ m_id

size_t GncOptionDBCallback::m_id

Definition at line 96 of file gnc-optiondb-impl.hpp.

◆ m_name

std::string OptionClassifier::m_name

Definition at line 72 of file gnc-option-impl.hpp.

◆ m_section

std::string OptionClassifier::m_section

Definition at line 71 of file gnc-option-impl.hpp.

◆ m_sort_tag

std::string OptionClassifier::m_sort_tag

Definition at line 73 of file gnc-option-impl.hpp.

◆ value [1/6]

template<typename T >
constexpr bool is_GncOwnerValue< T >::value
staticconstexpr
Initial value:
=
std::is_same_v<std::decay_t<T>, GncOptionGncOwnerValue>

Definition at line 269 of file gnc-option-impl.hpp.

◆ value [2/6]

template<typename T >
constexpr bool is_QofInstanceValue< T >::value
staticconstexpr
Initial value:

Definition at line 279 of file gnc-option-impl.hpp.

◆ value [3/6]

template<typename T >
constexpr bool is_QofQueryValue< T >::value
staticconstexpr
Initial value:
=
std::is_same_v<std::decay_t<T>, GncOptionValue<const QofQuery*>>

Definition at line 289 of file gnc-option-impl.hpp.

◆ value [4/6]

template<typename T >
constexpr bool is_OptionClassifier< T >::value
staticconstexpr
Initial value:
=
std::is_base_of_v<OptionClassifier, std::decay_t<T>>

Definition at line 76 of file gnc-option.hpp.

◆ value [5/6]

template<typename T , typename U >
constexpr bool is_same_decayed< T, U >::value
staticconstexpr
Initial value:
= std::is_same_v<std::decay_t<T>,
std::decay_t<U>>

Definition at line 86 of file gnc-option.hpp.

◆ value [6/6]

template<typename T >
constexpr bool is_RangeValue< T >::value
staticconstexpr
Initial value:
=
(is_same_decayed_v<T, GncOptionRangeValue<int>> ||
is_same_decayed_v<T, GncOptionRangeValue<double>>)

Definition at line 96 of file gnc-option.hpp.