GnuCash fec5643+
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
 
GncOptionValue & GncOptionValue< ValueType >::operator= (const GncOptionValue &)=default
 
GncOptionValue & GncOptionValue< 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 GncOwner * GncOptionGncOwnerValue::get_value () const
 
const GncOwner * GncOptionGncOwnerValue::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
 
GncOptionQofInstanceValue & GncOptionQofInstanceValue::operator= (GncOptionQofInstanceValue &&)=default
 
const QofInstance * GncOptionQofInstanceValue::get_value () const
 
const QofInstance * GncOptionQofInstanceValue::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
 
GncOptionCommodityValue & GncOptionCommodityValue::operator= (const GncOptionCommodityValue &)=default
 
GncOptionCommodityValue & GncOptionCommodityValue::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
 
GncOptionMultichoiceValue & GncOptionMultichoiceValue::operator= (const GncOptionMultichoiceValue &)=default
 
GncOptionMultichoiceValue & GncOptionMultichoiceValue::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 Account * GncOptionAccountSelValue::get_value () const
 
const Account * GncOptionAccountSelValue::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
 
GncOptionDateValue & GncOptionDateValue::operator= (const GncOptionDateValue &)=default
 
GncOptionDateValue & GncOptionDateValue::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 GncOption * GncOptionSection::find_option (const char *name) const
 
 GncOptionDBCallback::GncOptionDBCallback (size_t id, GncOptionDBChangeCallback func, void *data)
 
 GncOptionDBCallback::GncOptionDBCallback (const GncOptionDBCallback &)=delete
 
 GncOptionDBCallback::GncOptionDBCallback (GncOptionDBCallback &&)=default
 
GncOptionDBCallback & GncOptionDBCallback::operator= (const GncOptionDBCallback &)=default
 
GncOptionDBCallback & GncOptionDBCallback::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 ()
 
GncOptionSection * GncOptionDB::find_section (const std::string &sectname)
 
const GncOptionSection * GncOptionDB::find_section (const std::string &sectname) const
 
GncOption * GncOptionDB::find_option (const std::string &section, const char *name)
 
const GncOption * GncOptionDB::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

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.
 
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.
 
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.
 
Account * gnc_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

SplitList * xaccAccountGetSplitList (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 *)
 
LotList * xaccAccountGetLotList (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.
 
LotList * xaccAccountFindOpenLots (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.
 
Account * gnc_account_imap_find_account (Account *acc, const char *category, const char *key)
 
Account * gnc_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)
 
Account * gnc_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.
 
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.
 
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()
 
SplitList * xaccTransGetSplitList (const Transaction *trans)
 The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
 
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.
 
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.
 
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,
  s 
)    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,
  s 
)    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,
  b 
)    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 3384 of file Account.cpp.

3385{
3386 if (auto s = get_kvp_string_path (acc, {"old-currency"}))
3387 {
3389 return gnc_commodity_table_lookup_unique (table, s);
3390 }
3391
3392 return nullptr;
3393}
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 4859 of file Account.cpp.

4860{
4861 if (!acc) return nullptr;
4862 if (!xaccAccountIsPriced(acc)) return nullptr;
4863 return get_kvp_string_path (acc, {"old-quote-tz"});
4864}
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false.
Definition Account.cpp:4539

◆ 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 2773 of file Account.cpp.

2774{
2775 if ((!acc) || (!currency)) return;
2776
2777 auto s = gnc_commodity_get_unique_name (currency);
2778 set_kvp_string_path (acc, {"old-currency"}, s);
2779
2780 auto book = qof_instance_get_book(acc);
2782 auto commodity = gnc_commodity_table_lookup_unique (table, s);
2783
2784 if (!commodity)
2786}
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 4848 of file Account.cpp.

4849{
4850 if (!acc) return;
4851 if (!xaccAccountIsPriced(acc)) return;
4852 set_kvp_string_path (acc, {"old-quote-tz"}, tz);
4853}

◆ 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:3040
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition Account.cpp:3255
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:2038
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 5763 of file Account.cpp.

5764{
5765 if (acc != nullptr)
5766 {
5767 auto slots = qof_instance_get_slots_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES);
5768 if (!slots.size()) return;
5770 for (auto const & entry : slots)
5771 {
5772 qof_instance_slot_path_delete (QOF_INSTANCE (acc), {entry.first});
5773 }
5774 qof_instance_set_dirty (QOF_INSTANCE(acc));
5776 }
5777}
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Definition Account.cpp:1504
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition Account.cpp:1463

◆ 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 5736 of file Account.cpp.

5738{
5739 if (acc != nullptr)
5740 {
5741 std::vector<std::string> path {head};
5742 if (category)
5743 path.emplace_back (category);
5744 if (match_string)
5745 path.emplace_back (match_string);
5746
5747 if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
5748 {
5750 if (empty)
5751 qof_instance_slot_path_delete_if_empty (QOF_INSTANCE(acc), path);
5752 else
5753 qof_instance_slot_path_delete (QOF_INSTANCE(acc), path);
5754 PINFO("Account is '%s', head is '%s', category is '%s', match_string is'%s'",
5755 xaccAccountGetName (acc), head, category, match_string);
5756 qof_instance_set_dirty (QOF_INSTANCE(acc));
5758 }
5759 }
5760}
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition Account.cpp:3277
#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 4091 of file Account.cpp.

4092{
4093 if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS))
4094 return _(dflt_acct_credit_str);
4095
4096 auto result = gnc_acct_credit_strs.find(acct_type);
4097 if (result != gnc_acct_credit_strs.end())
4098 return _(result->second);
4099 else
4100 return _(dflt_acct_credit_str);
4101}
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 4079 of file Account.cpp.

4080{
4081 if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS))
4082 return _(dflt_acct_debit_str);
4083
4084 auto result = gnc_acct_debit_strs.find(acct_type);
4085 if (result != gnc_acct_debit_strs.end())
4086 return _(result->second);
4087 else
4088 return _(dflt_acct_debit_str);
4089}

◆ 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 5115 of file Account.cpp.

5116{
5117 g_return_val_if_fail (GNC_IS_ACCOUNT(account), INT64_MAX);
5118 const auto& splits = xaccAccountGetSplits (account);
5119 return splits.empty() ? INT64_MAX : xaccTransGetDate (xaccSplitGetParent (splits.front()));
5120}
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 5720 of file Account.cpp.

5721{
5722 return g_strdup (category ?
5723 get_kvp_string_path (acc, {head, category}) :
5724 get_kvp_string_path (acc, {head}));
5725}

◆ 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 5728 of file Account.cpp.

5729{
5730 return category ?
5731 get_kvp_guid_path (acc, {head, category}) :
5732 get_kvp_guid_path (acc, {head});
5733}

◆ 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 5196 of file Account.cpp.

5200{
5201 if (!acc || !key || !added_acc || !*key) return;
5202
5203 auto path = category ? Path{IMAP_FRAME, category, key} : Path{IMAP_FRAME, key};
5204
5205 set_kvp_account_path (acc, path, added_acc);
5206}

◆ 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 5559 of file Account.cpp.

5562{
5563 GList *current_token;
5564 gint64 token_count;
5565 char *account_fullname;
5566 char *guid_string;
5567
5568 ENTER(" ");
5569 if (!acc)
5570 {
5571 LEAVE(" ");
5572 return;
5573 }
5574 check_import_map_data (gnc_account_get_book(acc));
5575
5576 g_return_if_fail (added_acc != nullptr);
5577 account_fullname = gnc_account_get_full_name(added_acc);
5579
5580 PINFO("account name: '%s'", account_fullname);
5581
5582 guid_string = guid_to_string (xaccAccountGetGUID (added_acc));
5583
5584 /* process each token in the list */
5585 for (current_token = g_list_first(tokens); current_token;
5586 current_token = current_token->next)
5587 {
5588 char* token = static_cast<char*>(current_token->data);
5589 /* Jump to next iteration if the pointer is not valid or if the
5590 string is empty. In HBCI import we almost always get an empty
5591 string, which doesn't work in the kvp loopkup later. So we
5592 skip this case here. */
5593 if (!token || !token[0])
5594 continue;
5595 /* start off with one token for this account */
5596 token_count = 1;
5597 PINFO("adding token '%s'", token);
5598 auto path = std::string {IMAP_FRAME_BAYES} + '/' + token + '/' + guid_string;
5599 /* change the imap entry for the account */
5600 change_imap_entry (acc, path, token_count);
5601 }
5602 /* free up the account fullname and guid string */
5604 gnc_features_set_used (gnc_account_get_book(acc), GNC_FEATURE_GUID_FLAT_BAYESIAN);
5605 g_free (account_fullname);
5606 g_free (guid_string);
5607 LEAVE(" ");
5608}
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:3293
#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 5210 of file Account.cpp.

5213{
5214 if (!acc || !key) return;
5215
5216 auto path = category ? Path{IMAP_FRAME, category, key} : Path{IMAP_FRAME, key};
5217 if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
5218 {
5219 qof_instance_slot_path_delete (QOF_INSTANCE (acc), path);
5220 if (category)
5221 qof_instance_slot_path_delete_if_empty (QOF_INSTANCE (acc), {IMAP_FRAME, category});
5222 qof_instance_slot_path_delete_if_empty (QOF_INSTANCE (acc), {IMAP_FRAME});
5223 }
5224 qof_instance_set_dirty (QOF_INSTANCE (acc));
5225}

◆ gnc_account_imap_find_account()

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

Definition at line 5157 of file Account.cpp.

5160{
5161 if (!acc || !key) return nullptr;
5162 std::vector<std::string> path {IMAP_FRAME};
5163 if (category)
5164 path.push_back (category);
5165 path.push_back (key);
5166 return get_kvp_account_path (acc, path);
5167}

◆ 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 5513 of file Account.cpp.

5514{
5515 if (!acc)
5516 return nullptr;
5517 auto book = gnc_account_get_book(acc);
5518 check_import_map_data (book);
5519 auto first_pass = get_first_pass_probabilities(acc, tokens);
5520 if (!first_pass.size())
5521 return nullptr;
5522 auto final_probabilities = build_probabilities(first_pass);
5523 if (!final_probabilities.size())
5524 return nullptr;
5525 auto best = highest_probability(final_probabilities);
5526 if (best.account_guid == "")
5527 return nullptr;
5528 if (best.probability < threshold)
5529 return nullptr;
5530 gnc::GUID guid;
5531 try {
5532 guid = gnc::GUID::from_string(best.account_guid);
5533 } catch (gnc::guid_syntax_exception&) {
5534 return nullptr;
5535 }
5536 auto account = xaccAccountLookup (reinterpret_cast<GncGUID*>(&guid), book);
5537 return account;
5538}

◆ gnc_account_imap_find_any()

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

Definition at line 5170 of file Account.cpp.

5171{
5172 Account *account = nullptr;
5173
5174 /* Get list of Accounts */
5175 auto root = gnc_book_get_root_account (book);
5176 auto accts = gnc_account_get_descendants_sorted (root);
5177
5178 /* Go through list of accounts */
5179 for (auto ptr = accts; ptr; ptr = g_list_next (ptr))
5180 {
5181 auto tmp_acc = static_cast<Account*> (ptr->data);
5182
5183 if (gnc_account_imap_find_account (tmp_acc, category, key))
5184 {
5185 account = tmp_acc;
5186 break;
5187 }
5188 }
5189 g_list_free (accts);
5190
5191return account;
5192}

◆ 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 5691 of file Account.cpp.

5692{
5693 GList *list = nullptr;
5694
5695 GncImapInfo imapInfo;
5696
5697 std::vector<std::string> path {IMAP_FRAME};
5698 if (category)
5699 path.emplace_back (category);
5700
5701 imapInfo.source_account = acc;
5702 imapInfo.list = list;
5703
5704 imapInfo.head = g_strdup (IMAP_FRAME);
5705 imapInfo.category = g_strdup (category);
5706
5707 if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
5708 {
5709 qof_instance_foreach_slot (QOF_INSTANCE(acc), IMAP_FRAME, category,
5710 build_non_bayes, &imapInfo);
5711 }
5712 g_free (imapInfo.head);
5713 g_free (imapInfo.category);
5714 return g_list_reverse(imapInfo.list);
5715}

◆ 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 5680 of file Account.cpp.

5681{
5682 check_import_map_data (gnc_account_get_book (acc));
5683 /* A dummy object which is used to hold the specified account, and the list
5684 * of data about which we care. */
5685 GncImapInfo imapInfo {acc, nullptr};
5686 qof_instance_foreach_slot_prefix (QOF_INSTANCE (acc), IMAP_FRAME_BAYES, &build_bayes, imapInfo);
5687 return g_list_reverse(imapInfo.list);
5688}

◆ 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 5670 of file Account.cpp.

5671{
5672 g_free (imapInfo->head);
5673 g_free (imapInfo->category);
5674 g_free (imapInfo->match_string);
5675 g_free (imapInfo->count);
5676 g_free (imapInfo);
5677}

◆ 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 3094 of file Account.cpp.

3095{
3096 return (Account*)account_foreach_descendant_breadthfirst_until (parent, is_acct_code, (char*)code);
3097}

◆ 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 3151 of file Account.cpp.

3153{
3154 const AccountPrivate *rpriv;
3155 const Account *root;
3156 Account *found;
3157 gchar **names;
3158
3159 g_return_val_if_fail(GNC_IS_ACCOUNT(any_acc), nullptr);
3160 g_return_val_if_fail(name, nullptr);
3161
3162 root = any_acc;
3163 rpriv = GET_PRIVATE(root);
3164 while (rpriv->parent)
3165 {
3166 root = rpriv->parent;
3167 rpriv = GET_PRIVATE(root);
3168 }
3169 names = g_strsplit(name, gnc_get_account_separator_string(), -1);
3170 found = gnc_account_lookup_by_full_name_helper(root, names);
3171 g_strfreev(names);
3172 return found;
3173}
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 3081 of file Account.cpp.

3082{
3083 return (Account*)account_foreach_descendant_breadthfirst_until (parent, is_acct_name, (char*)name);
3084}

◆ 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 3109 of file Account.cpp.

3110{
3111 return (Account *)gnc_account_foreach_descendant_until (account, is_opening_balance_account, commodity);
3112}
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:3232

◆ 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 3176 of file Account.cpp.

3180{
3181 GList *retval{};
3182 auto rpriv{GET_PRIVATE(root)};
3183 for (auto account : rpriv->children)
3184 {
3185 if (xaccAccountGetType (account) == acctype)
3186 {
3187 if (commodity &&
3189 commodity))
3190 continue;
3191
3192 if (name && strcmp(name, xaccAccountGetName(account)))
3193 continue;
3194
3195 retval = g_list_prepend(retval, account);
3196 }
3197 }
3198
3199 if (!retval) // Recurse through the children
3200 for (auto account : rpriv->children)
3201 {
3202 auto result = gnc_account_lookup_by_type_and_commodity(account,
3203 name,
3204 acctype,
3205 commodity);
3206 if (result)
3207 retval = g_list_concat(result, retval);
3208 }
3209 return retval;
3210}
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
Definition Account.cpp:3396
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:3176

◆ 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 5481 of file Account.cpp.

5482{
5483 imap_convert_bayes_to_flat_run = false;
5484}

◆ 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 5042 of file Account.cpp.

5043{
5044 auto do_one_account = [](auto acc)
5045 { gnc_account_foreach_split (acc, [](auto s){ s->parent->marker = 0; }); };
5046 gnc_account_foreach_descendant (account, do_one_account);
5047}

◆ 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 5077 of file Account.cpp.

5081{
5082 const AccountPrivate *priv;
5083 Transaction *trans;
5084 int retval;
5085
5086 if (!acc) return 0;
5087
5088 /* depth first traversal */
5089 priv = GET_PRIVATE(acc);
5090 for (auto acc_p : priv->children)
5091 {
5092 retval = gnc_account_tree_staged_transaction_traversal(acc_p, stage, thunk, cb_data);
5093 if (retval) return retval;
5094 }
5095
5096 /* Now this account */
5097 for (auto s : priv->splits)
5098 {
5099 trans = s->parent;
5100 if (trans && (trans->marker < stage))
5101 {
5102 trans->marker = stage;
5103 if (thunk)
5104 {
5105 retval = thunk(trans, cb_data);
5106 if (retval) return retval;
5107 }
5108 }
5109 }
5110
5111 return 0;
5112}
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:5077

◆ 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 2491 of file Transaction.cpp.

2492{
2493 guint count = 0;
2494 xaccAccountTreeForEachTransaction(gnc_book_get_root_account(book),
2495 counter_thunk, (void*)&count);
2496 return count;
2497}

◆ 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 5019 of file Account.cpp.

5020{
5021 if (!account)
5022 return;
5023 xaccSplitsBeginStagedTransactionTraversals(GET_PRIVATE (account)->splits);
5024}

◆ xaccAccountClearHigherBalanceLimit()

void xaccAccountClearHigherBalanceLimit ( Account *  account)

Clear the higher balance limit for the account.

Parameters
accountThe account to clear the limit on

Definition at line 4733 of file Account.cpp.

4734{
4735 set_balance_limit (acc, KEY_BALANCE_HIGHER_LIMIT_VALUE, {});
4736}

◆ xaccAccountClearLowerBalanceLimit()

void xaccAccountClearLowerBalanceLimit ( Account *  account)

Clear the lower balance limit for the account.

Parameters
accountThe account to clear the limit on

Definition at line 4739 of file Account.cpp.

4740{
4741 set_balance_limit (acc, KEY_BALANCE_LOWER_LIMIT_VALUE, {});
4742}

◆ xaccAccountClearReconcilePostpone()

void xaccAccountClearReconcilePostpone ( Account *  account)

DOCUMENT ME!

Definition at line 4662 of file Account.cpp.

4663{
4664 set_kvp_gnc_numeric_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE}, {});
4665}

◆ 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 3970 of file Account.cpp.

3974{
3975 AccountPrivate *priv;
3976 GList *lot_list;
3977 GList *retval = nullptr;
3978
3979 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr);
3980
3981 priv = GET_PRIVATE(acc);
3982 for (lot_list = priv->lots; lot_list; lot_list = lot_list->next)
3983 {
3984 GNCLot *lot = static_cast<GNCLot*>(lot_list->data);
3985
3986 /* If this lot is closed, then ignore it */
3987 if (gnc_lot_is_closed (lot))
3988 continue;
3989
3990 if (match_func && !(match_func)(lot, user_data))
3991 continue;
3992
3993 /* Ok, this is a valid lot. Add it to our list of lots */
3994 retval = g_list_prepend (retval, lot);
3995 }
3996
3997 if (sort_func)
3998 retval = g_list_sort (retval, sort_func);
3999
4000 return retval;
4001}
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 4896 of file Account.cpp.

4897{
4898 auto has_description = [description](const Split* s) -> bool
4899 { return !g_strcmp0 (description, xaccTransGetDescription (xaccSplitGetParent (s))); };
4900 return gnc_account_find_split (acc, has_description, true);
4901}
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:1155
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 4909 of file Account.cpp.

4910{
4911 auto split = xaccAccountFindSplitByDesc (acc, description);
4912 return split ? xaccSplitGetParent (split) : nullptr;
4913}
Split * xaccAccountFindSplitByDesc(const Account *acc, const char *description)
Returns a pointer to the split, not a copy.
Definition Account.cpp:4896

◆ 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 5138 of file Account.cpp.

5140{
5141 if (!acc || !proc) return 0;
5143 return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
5144}
void xaccAccountBeginStagedTransactionTraversals(const Account *account)
xaccAccountBeginStagedTransactionTraversals() resets the traversal marker for each transaction which ...
Definition Account.cpp:5019
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:5050

◆ 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 4119 of file Account.cpp.

4120{
4121 return get_kvp_boolean_path(acc, {"import-append-text"});
4122}

◆ 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 4163 of file Account.cpp.

4164{
4165 return get_kvp_boolean_path (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"});
4166}

◆ 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 4150 of file Account.cpp.

4151{
4152 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), PLACEHOLDER_NONE);
4153 if (xaccAccountGetPlaceholder(acc)) return PLACEHOLDER_THIS;
4154
4155 return gnc_account_foreach_descendant_until (acc, (AccountCb2)xaccAccountGetPlaceholder, nullptr)
4156 ? PLACEHOLDER_CHILD : PLACEHOLDER_NONE;
4157}
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition Account.cpp:4107

◆ 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 4178 of file Account.cpp.

4179{
4180 return get_kvp_boolean_path (acc, {"hidden"});
4181}

◆ 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 4707 of file Account.cpp.

4709{
4710 return get_balance_limit (acc, KEY_BALANCE_HIGHER_LIMIT_VALUE, balance);
4711}

◆ 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 4745 of file Account.cpp.

4746{
4747 return get_kvp_boolean_path (acc, {KEY_BALANCE_LIMIT, KEY_BALANCE_INCLUDE_SUB_ACCTS});
4748}

◆ 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 4131 of file Account.cpp.

4132{
4133 g_return_val_if_fail (GNC_IS_ACCOUNT(acc), false);
4134 if (GET_PRIVATE(acc)->type != ACCT_TYPE_EQUITY)
4135 return false;
4136
4137 return !g_strcmp0 (get_kvp_string_path (acc, {"equity-type"}), "opening-balance");
4138}

◆ 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 3963 of file Account.cpp.

3964{
3965 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr);
3966 return g_list_copy(GET_PRIVATE(acc)->lots);
3967}

◆ 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 4714 of file Account.cpp.

4716{
4717 return get_balance_limit (acc, KEY_BALANCE_LOWER_LIMIT_VALUE, balance);
4718}

◆ 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 4107 of file Account.cpp.

4108{
4109 return get_kvp_boolean_path(acc, {"placeholder"});
4110}

◆ xaccAccountGetReconcileLastDate()

gboolean xaccAccountGetReconcileLastDate ( const Account *  account,
time64 *  last_date 
)

DOCUMENT ME!

Definition at line 4554 of file Account.cpp.

4555{
4556 gboolean retval = FALSE;
4557 auto date = get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-date"});
4558
4559 if (date)
4560 {
4561 if (last_date)
4562 *last_date = *date;
4563 retval = TRUE;
4564 }
4565 return retval;
4566}

◆ xaccAccountGetReconcileLastInterval()

gboolean xaccAccountGetReconcileLastInterval ( const Account *  account,
int *  months,
int *  days 
)

DOCUMENT ME!

Definition at line 4581 of file Account.cpp.

4583{
4584 if (!acc) return FALSE;
4585 auto m{get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "months"})};
4586 auto d{get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "days"})};
4587 if (m && d)
4588 {
4589 if (months)
4590 *months = *m;
4591 if (days)
4592 *days = *d;
4593 return true;
4594 }
4595 return false;
4596}

◆ xaccAccountGetReconcilePostponeBalance()

gboolean xaccAccountGetReconcilePostponeBalance ( const Account *  account,
gnc_numeric *  balance 
)

DOCUMENT ME!

Definition at line 4636 of file Account.cpp.

4638{
4639 if (auto bal = get_kvp_gnc_numeric_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"}))
4640 {
4641 if (balance)
4642 *balance = *bal;
4643 return true;
4644 }
4645 return false;
4646}

◆ xaccAccountGetReconcilePostponeDate()

gboolean xaccAccountGetReconcilePostponeDate ( const Account *  account,
time64 *  postpone_date 
)

DOCUMENT ME!

Definition at line 4612 of file Account.cpp.

4613{
4614 if (auto date = get_kvp_int64_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "date"}))
4615 {
4616 if (postpone_date)
4617 *postpone_date = *date;
4618 return true;
4619 }
4620 return false;
4621}

◆ 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 3937 of file Account.cpp.

3938{
3939 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), nullptr);
3940 auto priv{GET_PRIVATE(acc)};
3941 return std::accumulate (priv->splits.rbegin(), priv->splits.rend(),
3942 static_cast<GList*>(nullptr), g_list_prepend);
3943}

◆ xaccAccountGetSplitsSize()

size_t xaccAccountGetSplitsSize ( const Account *  account)

Definition at line 3946 of file Account.cpp.

3947{
3948 g_return_val_if_fail (GNC_IS_ACCOUNT(account), 0);
3949 return GNC_IS_ACCOUNT(account) ? GET_PRIVATE(account)->splits.size() : 0;
3950}

◆ xaccAccountGetTaxRelated()

gboolean xaccAccountGetTaxRelated ( const Account *  account)

DOCUMENT ME!

Definition at line 4023 of file Account.cpp.

4024{
4025 return get_kvp_boolean_path(acc, {"tax-related"});
4026}

◆ xaccAccountGetTaxUSCode()

const char * xaccAccountGetTaxUSCode ( const Account *  account)

DOCUMENT ME!

Definition at line 4035 of file Account.cpp.

4036{
4037 return get_kvp_string_path (acc, {"tax-US", "code"});
4038}

◆ 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 4059 of file Account.cpp.

4060{
4061 auto copy_number = get_kvp_int64_path (acc, {"tax-US", "copy-number"});
4062 return (copy_number && (*copy_number != 0)) ? *copy_number : 1;
4063}

◆ xaccAccountGetTaxUSPayerNameSource()

const char * xaccAccountGetTaxUSPayerNameSource ( const Account *  account)

DOCUMENT ME!

Definition at line 4047 of file Account.cpp.

4048{
4049 return get_kvp_string_path (acc, {"tax-US", "payer-name-source"});
4050}

◆ 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 4345 of file Account.cpp.

4346{
4347 if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return "";
4348 return _(account_type_name [type]);
4349}
@ 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 2128 of file Account.cpp.

2129{
2130 /* errors */
2131 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2132 g_return_if_fail(GNC_IS_LOT(lot));
2133
2134 /* optimizations */
2135 auto lot_acc = gnc_lot_get_account(lot);
2136 if (lot_acc == acc)
2137 return;
2138
2139 ENTER ("(acc=%p, lot=%p)", acc, lot);
2140
2141 /* pull it out of the old account */
2142 if (lot_acc)
2143 {
2144 auto priv = GET_PRIVATE(lot_acc);
2145 priv->lots = g_list_remove(priv->lots, lot);
2146 qof_event_gen (&lot_acc->inst, QOF_EVENT_MODIFY, nullptr);
2147 }
2148
2149 auto priv = GET_PRIVATE(acc);
2150 priv->lots = g_list_prepend(priv->lots, lot);
2151 gnc_lot_set_account(lot, acc);
2152
2153 /* Don't move the splits to the new account. The caller will do this
2154 * if appropriate, and doing it here will not work if we are being
2155 * called from gnc_book_close_period since xaccAccountInsertSplit
2156 * will try to balance capital gains and things aren't ready for that. */
2157
2158 qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_ADD, nullptr);
2159 qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr);
2160
2161 LEAVE ("(acc=%p, lot=%p)", acc, lot);
2162}
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 4515 of file Account.cpp.

4516{
4517 switch (t)
4518 {
4520 case ACCT_TYPE_PAYABLE:
4521 return TRUE;
4522 default:
4523 return FALSE;
4524 }
4525}
@ 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 4469 of file Account.cpp.

4470{
4471 switch (t)
4472 {
4474 case ACCT_TYPE_PAYABLE:
4475 return FALSE;
4476 default:
4477 return (xaccAccountTypesCompatible(ACCT_TYPE_ASSET, t)
4478 || xaccAccountTypesCompatible(ACCT_TYPE_LIABILITY, t));
4479 }
4480}
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:4442

◆ xaccAccountIsEquityType()

gboolean xaccAccountIsEquityType ( GNCAccountType  t)

Convenience function to check if the account is a valid Equity type.

Definition at line 4527 of file Account.cpp.

4528{
4529 switch (t)
4530 {
4531 case ACCT_TYPE_EQUITY:
4532 return TRUE;
4533 default:
4534 return FALSE;
4535 }
4536}
@ 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 4190 of file Account.cpp.

4191{
4192 AccountPrivate *priv;
4193
4194 g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
4195
4196 if (xaccAccountGetHidden(acc))
4197 return TRUE;
4198 priv = GET_PRIVATE(acc);
4199 while ((acc = priv->parent) != nullptr)
4200 {
4201 priv = GET_PRIVATE(acc);
4202 if (xaccAccountGetHidden(acc))
4203 return TRUE;
4204 }
4205 return FALSE;
4206}
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
Definition Account.cpp:4178

◆ xaccAccountMoveAllSplits()

void xaccAccountMoveAllSplits ( Account *  accfrom,
Account *  accto 
)

The xaccAccountMoveAllSplits() routine reassigns each of the splits in accfrom to accto.

Definition at line 2184 of file Account.cpp.

2185{
2186 AccountPrivate *from_priv;
2187
2188 /* errors */
2189 g_return_if_fail(GNC_IS_ACCOUNT(accfrom));
2190 g_return_if_fail(GNC_IS_ACCOUNT(accto));
2191
2192 /* optimizations */
2193 from_priv = GET_PRIVATE(accfrom);
2194 if (from_priv->splits.empty() || accfrom == accto)
2195 return;
2196
2197 /* check for book mix-up */
2198 g_return_if_fail (qof_instance_books_equal(accfrom, accto));
2199 ENTER ("(accfrom=%p, accto=%p)", accfrom, accto);
2200
2201 xaccAccountBeginEdit(accfrom);
2202 xaccAccountBeginEdit(accto);
2203 /* Begin editing both accounts and all transactions in accfrom. */
2204 std::for_each (from_priv->splits.begin(), from_priv->splits.end(), xaccPreSplitMove);
2205
2206 /* Concatenate accfrom's lists of splits and lots to accto's lists. */
2207 //to_priv->splits = g_list_concat(to_priv->splits, from_priv->splits);
2208 //to_priv->lots = g_list_concat(to_priv->lots, from_priv->lots);
2209
2210 /* Set appropriate flags. */
2211 //from_priv->balance_dirty = TRUE;
2212 //from_priv->sort_dirty = FALSE;
2213 //to_priv->balance_dirty = TRUE;
2214 //to_priv->sort_dirty = TRUE;
2215
2216 /*
2217 * Change each split's account back pointer to accto.
2218 * Convert each split's amount to accto's commodity.
2219 * Commit to editing each transaction.
2220 */
2221 auto splits = from_priv->splits;
2222 std::for_each (splits.begin(), splits.end(), [accto](auto s){ xaccPostSplitMove (s, accto); });
2223
2224 /* Finally empty accfrom. */
2225 g_assert(from_priv->splits.empty());
2226 g_assert(from_priv->lots == nullptr);
2227 xaccAccountCommitEdit(accfrom);
2228 xaccAccountCommitEdit(accto);
2229
2230 LEAVE ("(accfrom=%p, accto=%p)", accfrom, accto);
2231}
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 2110 of file Account.cpp.

2111{
2112 AccountPrivate *priv;
2113
2114 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2115 g_return_if_fail(GNC_IS_LOT(lot));
2116
2117 priv = GET_PRIVATE(acc);
2118 g_return_if_fail(priv->lots);
2119
2120 ENTER ("(acc=%p, lot=%p)", acc, lot);
2121 priv->lots = g_list_remove(priv->lots, lot);
2122 qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_REMOVE, nullptr);
2123 qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, nullptr);
2124 LEAVE ("(acc=%p, lot=%p)", acc, lot);
2125}

◆ 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 4125 of file Account.cpp.

4126{
4127 set_kvp_boolean_path(acc, {"import-append-text"}, val);
4128}

◆ 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 4169 of file Account.cpp.

4170{
4171 set_kvp_boolean_path (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"}, val);
4172}

◆ 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 4184 of file Account.cpp.

4185{
4186 set_kvp_boolean_path (acc, {"hidden"}, val);
4187}

◆ 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 4721 of file Account.cpp.

4722{
4723 set_balance_limit (acc, KEY_BALANCE_HIGHER_LIMIT_VALUE, balance);
4724}

◆ 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 4751 of file Account.cpp.

4752{
4753 set_kvp_boolean_path (acc, {KEY_BALANCE_LIMIT, KEY_BALANCE_INCLUDE_SUB_ACCTS}, inc_sub);
4754}

◆ 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 4141 of file Account.cpp.

4142{
4143 g_return_if_fail (GNC_IS_ACCOUNT(acc));
4144 if (GET_PRIVATE(acc)->type != ACCT_TYPE_EQUITY)
4145 return;
4146 set_kvp_string_path(acc, {"equity-type"}, val ? "opening-balance" : nullptr);
4147}

◆ 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 4727 of file Account.cpp.

4728{
4729 set_balance_limit (acc, KEY_BALANCE_LOWER_LIMIT_VALUE, balance);
4730}

◆ 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 2050 of file Account.cpp.

2051{
2052 AccountPrivate *priv;
2053
2054 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2055
2056 priv = GET_PRIVATE(acc);
2057 priv->mark = m;
2058}

◆ 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 4113 of file Account.cpp.

4114{
4115 set_kvp_boolean_path(acc, {"placeholder"}, val);
4116}

◆ xaccAccountSetReconcileLastDate()

void xaccAccountSetReconcileLastDate ( Account *  account,
time64  last_date 
)

DOCUMENT ME!

Definition at line 4572 of file Account.cpp.

4573{
4574 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-date"}, last_date);
4575}

◆ xaccAccountSetReconcileLastInterval()

void xaccAccountSetReconcileLastInterval ( Account *  account,
int  months,
int  days 
)

DOCUMENT ME!

Definition at line 4602 of file Account.cpp.

4603{
4604 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "months"}, months);
4605 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, "last-interval", "days"}, days);
4606}

◆ xaccAccountSetReconcilePostponeBalance()

void xaccAccountSetReconcilePostponeBalance ( Account *  account,
gnc_numeric  balance 
)

DOCUMENT ME!

Definition at line 4652 of file Account.cpp.

4653{
4654 set_kvp_gnc_numeric_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"}, balance);
4655}

◆ xaccAccountSetReconcilePostponeDate()

void xaccAccountSetReconcilePostponeDate ( Account *  account,
time64  postpone_date 
)

DOCUMENT ME!

Definition at line 4627 of file Account.cpp.

4628{
4629 set_kvp_int64_path (acc, {KEY_RECONCILE_INFO, KEY_POSTPONE, "date"}, postpone_date);
4630}

◆ xaccAccountSetTaxRelated()

void xaccAccountSetTaxRelated ( Account *  account,
gboolean  tax_related 
)

DOCUMENT ME!

Definition at line 4029 of file Account.cpp.

4030{
4031 set_kvp_boolean_path(acc, {"tax-related"}, tax_related);
4032}

◆ xaccAccountSetTaxUSCode()

void xaccAccountSetTaxUSCode ( Account *  account,
const char *  code 
)

DOCUMENT ME!

Definition at line 4041 of file Account.cpp.

4042{
4043 set_kvp_string_path (acc, {"tax-US", "code"}, code);
4044}

◆ 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 4066 of file Account.cpp.

4067{
4068 if (copy_number != 0)
4069 set_kvp_int64_path (acc, {"tax-US", "copy-number"}, copy_number);
4070 else
4071 /* deletes KVP if it exists */
4072 set_kvp_int64_path (acc, {"tax-US", "copy-number"}, std::nullopt);
4073}

◆ xaccAccountSetTaxUSPayerNameSource()

void xaccAccountSetTaxUSPayerNameSource ( Account *  account,
const char *  source 
)

DOCUMENT ME!

Definition at line 4053 of file Account.cpp.

4054{
4055 set_kvp_string_path (acc, {"tax-US", "payer-name-source"}, source);
4056}

◆ 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 5050 of file Account.cpp.

5054{
5055 if (!acc) return 0;
5056
5057 // iterate on copy of splits. some callers modify the splitsvec.
5058 auto splits = GET_PRIVATE(acc)->splits;
5059 for (auto s : splits)
5060 {
5061 auto trans = s->parent;
5062 if (trans && (trans->marker < stage))
5063 {
5064 trans->marker = stage;
5065 if (thunk)
5066 {
5067 auto retval = thunk(trans, cb_data);
5068 if (retval) return retval;
5069 }
5070 }
5071 }
5072
5073 return 0;
5074}

◆ 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 4306 of file Account.cpp.

4307{
4308 GNCAccountType type;
4309 gboolean rc;
4310 rc = xaccAccountStringToType(str, &type);
4311 if (FALSE == rc) return ACCT_TYPE_INVALID;
4312 return type;
4313}
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:4272

◆ 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 4272 of file Account.cpp.

4273{
4274
4275 GNC_RETURN_ON_MATCH(NONE);
4276 GNC_RETURN_ON_MATCH(BANK);
4277 GNC_RETURN_ON_MATCH(CASH);
4278 GNC_RETURN_ON_MATCH(CREDIT);
4279 GNC_RETURN_ON_MATCH(ASSET);
4280 GNC_RETURN_ON_MATCH(LIABILITY);
4281 GNC_RETURN_ON_MATCH(STOCK);
4282 GNC_RETURN_ON_MATCH(MUTUAL);
4283 GNC_RETURN_ON_MATCH(CURRENCY);
4284 GNC_RETURN_ON_MATCH(INCOME);
4285 GNC_RETURN_ON_MATCH(EXPENSE);
4286 GNC_RETURN_ON_MATCH(EQUITY);
4287 GNC_RETURN_ON_MATCH(RECEIVABLE);
4288 GNC_RETURN_ON_MATCH(PAYABLE);
4289 GNC_RETURN_ON_MATCH(ROOT);
4290 GNC_RETURN_ON_MATCH(TRADING);
4291 GNC_RETURN_ON_MATCH(CHECKING);
4292 GNC_RETURN_ON_MATCH(SAVINGS);
4293 GNC_RETURN_ON_MATCH(MONEYMRKT);
4294 GNC_RETURN_ON_MATCH(CREDITLINE);
4295
4296 PERR("asked to translate unknown account type string %s.\n",
4297 str ? str : "(null)");
4298
4299 return(FALSE);
4300}

◆ 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 4235 of file Account.cpp.

4236{
4237 switch (type)
4238 {
4239 GNC_RETURN_ENUM_AS_STRING(NONE);
4240 GNC_RETURN_ENUM_AS_STRING(BANK);
4241 GNC_RETURN_ENUM_AS_STRING(CASH);
4242 GNC_RETURN_ENUM_AS_STRING(CREDIT);
4243 GNC_RETURN_ENUM_AS_STRING(ASSET);
4244 GNC_RETURN_ENUM_AS_STRING(LIABILITY);
4245 GNC_RETURN_ENUM_AS_STRING(STOCK);
4246 GNC_RETURN_ENUM_AS_STRING(MUTUAL);
4247 GNC_RETURN_ENUM_AS_STRING(CURRENCY);
4248 GNC_RETURN_ENUM_AS_STRING(INCOME);
4249 GNC_RETURN_ENUM_AS_STRING(EXPENSE);
4250 GNC_RETURN_ENUM_AS_STRING(EQUITY);
4251 GNC_RETURN_ENUM_AS_STRING(RECEIVABLE);
4252 GNC_RETURN_ENUM_AS_STRING(PAYABLE);
4253 GNC_RETURN_ENUM_AS_STRING(ROOT);
4254 GNC_RETURN_ENUM_AS_STRING(TRADING);
4255 GNC_RETURN_ENUM_AS_STRING(CHECKING);
4256 GNC_RETURN_ENUM_AS_STRING(SAVINGS);
4257 GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
4258 GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
4259 default:
4260 PERR ("asked to translate unknown account type %d.\n", type);
4261 break;
4262 }
4263 return(nullptr);
4264}

◆ xaccAccountTypeGetFundamental()

GNCAccountType xaccAccountTypeGetFundamental ( GNCAccountType  t)

Convenience function to return the fundamental type asset/liability/income/expense/equity given an account type.

Definition at line 4483 of file Account.cpp.

4484{
4485 switch (t)
4486 {
4487 case ACCT_TYPE_BANK:
4488 case ACCT_TYPE_STOCK:
4490 case ACCT_TYPE_CHECKING:
4491 case ACCT_TYPE_SAVINGS:
4492 case ACCT_TYPE_MUTUAL:
4493 case ACCT_TYPE_CURRENCY:
4494 case ACCT_TYPE_CASH:
4495 case ACCT_TYPE_ASSET:
4497 return ACCT_TYPE_ASSET;
4498 case ACCT_TYPE_CREDIT:
4500 case ACCT_TYPE_PAYABLE:
4502 return ACCT_TYPE_LIABILITY;
4503 case ACCT_TYPE_INCOME:
4504 return ACCT_TYPE_INCOME;
4505 case ACCT_TYPE_EXPENSE:
4506 return ACCT_TYPE_EXPENSE;
4507 case ACCT_TYPE_EQUITY:
4508 return ACCT_TYPE_EQUITY;
4509 case ACCT_TYPE_TRADING:
4510 default:
4511 return ACCT_TYPE_NONE;
4512 }
4513}
@ 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 4442 of file Account.cpp.

4444{
4445 /* ACCT_TYPE_NONE isn't compatible with anything, even ACCT_TYPE_NONE. */
4446 if (parent_type == ACCT_TYPE_NONE || child_type == ACCT_TYPE_NONE)
4447 return FALSE;
4448
4449 /* ACCT_TYPE_ROOT can't have a parent account, and asking will raise
4450 * an error. */
4451 if (child_type == ACCT_TYPE_ROOT)
4452 return FALSE;
4453
4454 return ((xaccParentAccountTypesCompatibleWith (child_type) &
4455 (1 << parent_type))
4456 != 0);
4457}
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
Return the bitmask of parent account types compatible with a given type.
Definition Account.cpp:4395

◆ 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 4355 of file Account.cpp.

4356{
4357 switch (type)
4358 {
4359 case ACCT_TYPE_BANK:
4360 case ACCT_TYPE_CASH:
4361 case ACCT_TYPE_ASSET:
4362 case ACCT_TYPE_CREDIT:
4364 case ACCT_TYPE_INCOME:
4365 case ACCT_TYPE_EXPENSE:
4366 case ACCT_TYPE_EQUITY:
4367 return
4368 (1 << ACCT_TYPE_BANK) |
4369 (1 << ACCT_TYPE_CASH) |
4370 (1 << ACCT_TYPE_ASSET) |
4371 (1 << ACCT_TYPE_CREDIT) |
4372 (1 << ACCT_TYPE_LIABILITY) |
4373 (1 << ACCT_TYPE_INCOME) |
4374 (1 << ACCT_TYPE_EXPENSE) |
4375 (1 << ACCT_TYPE_EQUITY);
4376 case ACCT_TYPE_STOCK:
4377 case ACCT_TYPE_MUTUAL:
4378 case ACCT_TYPE_CURRENCY:
4379 return
4380 (1 << ACCT_TYPE_STOCK) |
4381 (1 << ACCT_TYPE_MUTUAL) |
4382 (1 << ACCT_TYPE_CURRENCY);
4384 return (1 << ACCT_TYPE_RECEIVABLE);
4385 case ACCT_TYPE_PAYABLE:
4386 return (1 << ACCT_TYPE_PAYABLE);
4387 case ACCT_TYPE_TRADING:
4388 return (1 << ACCT_TYPE_TRADING);
4389 default:
4390 PERR("bad account type: %d", type);
4391 return 0;
4392 }
4393}

◆ 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 4460 of file Account.cpp.

4461{
4462 guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
4463 mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
4464 (1 << ACCT_TYPE_ROOT)); /* ROOT */
4465
4466 return mask;
4467}

◆ 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 2061 of file Account.cpp.

2062{
2063 Account *root;
2064
2065 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2066
2067 root = gnc_account_get_root(acc);
2068 xaccClearMarkDown(root ? root : acc, val);
2069}
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:2930
void xaccClearMarkDown(Account *acc, short val)
The xaccClearMarkDown will clear the mark only in this and in sub-accounts.
Definition Account.cpp:2072

◆ xaccClearMarkDown()

void xaccClearMarkDown ( Account *  account,
short  val 
)

The xaccClearMarkDown will clear the mark only in this and in sub-accounts.

Definition at line 2072 of file Account.cpp.

2073{
2074 AccountPrivate *priv;
2075
2076 g_return_if_fail(GNC_IS_ACCOUNT(acc));
2077
2078 priv = GET_PRIVATE(acc);
2079 priv->mark = val;
2080 std::for_each (priv->children.begin(), priv->children.end(),
2081 [val](auto acc){ xaccClearMarkDown(acc, val); });
2082}

◆ 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 4395 of file Account.cpp.

4396{
4397 switch (type)
4398 {
4399 case ACCT_TYPE_BANK:
4400 case ACCT_TYPE_CASH:
4401 case ACCT_TYPE_ASSET:
4402 case ACCT_TYPE_STOCK:
4403 case ACCT_TYPE_MUTUAL:
4404 case ACCT_TYPE_CURRENCY:
4405 case ACCT_TYPE_CREDIT:
4408 case ACCT_TYPE_PAYABLE:
4409 return
4410 (1 << ACCT_TYPE_BANK) |
4411 (1 << ACCT_TYPE_CASH) |
4412 (1 << ACCT_TYPE_ASSET) |
4413 (1 << ACCT_TYPE_STOCK) |
4414 (1 << ACCT_TYPE_MUTUAL) |
4415 (1 << ACCT_TYPE_CURRENCY) |
4416 (1 << ACCT_TYPE_CREDIT) |
4417 (1 << ACCT_TYPE_LIABILITY) |
4418 (1 << ACCT_TYPE_RECEIVABLE) |
4419 (1 << ACCT_TYPE_PAYABLE) |
4420 (1 << ACCT_TYPE_ROOT);
4421 case ACCT_TYPE_INCOME:
4422 case ACCT_TYPE_EXPENSE:
4423 return
4424 (1 << ACCT_TYPE_INCOME) |
4425 (1 << ACCT_TYPE_EXPENSE) |
4426 (1 << ACCT_TYPE_ROOT);
4427 case ACCT_TYPE_EQUITY:
4428 return
4429 (1 << ACCT_TYPE_EQUITY) |
4430 (1 << ACCT_TYPE_ROOT);
4431 case ACCT_TYPE_TRADING:
4432 return
4433 (1 << ACCT_TYPE_TRADING) |
4434 (1 << ACCT_TYPE_ROOT);
4435 default:
4436 PERR("bad account type: %d", type);
4437 return 0;
4438 }
4439}
@ 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 5027 of file Account.cpp.

5028{
5029 if (trans == nullptr) return FALSE;
5030
5031 if (trans->marker < stage)
5032 {
5033 trans->marker = stage;
5034 return TRUE;
5035 }
5036
5037 return FALSE;
5038}

◆ 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 1970 of file Transaction.cpp.

1971{
1972 set_kvp_string_path (trans, {TRANS_READ_ONLY_REASON}, nullptr);
1973}

◆ 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 2061 of file Transaction.cpp.

2062{
2063 xaccTransBeginEdit(trans);
2064 /* We only own the splits that still think they belong to us. This is done
2065 in 2 steps. In the first, the splits are marked as being destroyed, but they
2066 are not destroyed yet. In the second, the destruction is committed which will
2067 do the actual destruction. If both steps are done for a split before they are
2068 done for the next split, then a split will still be on the split list after it
2069 has been freed. This can cause other parts of the code (e.g. in xaccSplitDestroy())
2070 to reference the split after it has been freed. */
2071 for (auto node = trans->splits; node; node = node->next)
2072 {
2073 auto s = GNC_SPLIT(node->data);
2074 if (s && s->parent == trans)
2075 {
2077 }
2078 }
2079 for (auto node = trans->splits; node; node = node->next)
2080 {
2081 auto s = GNC_SPLIT(node->data);
2082 if (s && s->parent == trans)
2083 {
2084 xaccSplitCommitEdit(s);
2085 }
2086 }
2087 g_list_free (trans->splits);
2088 trans->splits = nullptr;
2089
2090 xaccTransCommitEdit(trans);
2091}
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:1517

◆ xaccTransClone()

Transaction * xaccTransClone ( const Transaction *  t)

The xaccTransClone() method will create a complete copy of an existing transaction.

Definition at line 636 of file Transaction.cpp.

637{
638 Transaction *to = xaccTransCloneNoKvp (from);
639
640 if (g_list_length (to->splits) != g_list_length (from->splits))
641 {
642 PERR ("Cloned transaction has different number of splits from original");
643 xaccTransDestroy (to);
644 return nullptr;
645 }
646
648 qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from));
649
650 for (GList* lfrom = from->splits, *lto = to->splits; lfrom && lto;
651 lfrom = g_list_next (lfrom), lto = g_list_next (lto))
652 xaccSplitCopyKvp (GNC_SPLIT(lfrom->data), GNC_SPLIT(lto->data));
653
655 return to;
656}
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 606 of file Transaction.cpp.

607{
608 Transaction *to;
609
611 to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, nullptr));
612
613 to->date_entered = from->date_entered;
614 to->date_posted = from->date_posted;
615 CACHE_REPLACE (to->num, from->num);
616 CACHE_REPLACE (to->description, from->description);
617 to->common_currency = from->common_currency;
618 qof_instance_copy_version(to, from);
619 qof_instance_copy_version_check(to, from);
620
621 to->orig = nullptr;
622
623 qof_instance_init_data (&to->inst, GNC_ID_TRANS,
625
627 to->splits = g_list_copy_deep (from->splits, copy_split, to);
628 qof_instance_set_dirty(QOF_INSTANCE(to));
631
632 return to;
633}
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 705 of file Transaction.cpp.

707{
708 gboolean change_accounts = FALSE;
709 GList *node;
710
711 if (!from_trans || !to_trans)
712 return;
713
714 change_accounts = from_acc && GNC_IS_ACCOUNT(to_acc) && from_acc != to_acc;
715 xaccTransBeginEdit(to_trans);
716
717 xaccTransClearSplits(to_trans);
718 xaccTransSetCurrency(to_trans, xaccTransGetCurrency(from_trans));
720
721 if ((xaccTransGetNum(to_trans) == nullptr) || (g_strcmp0 (xaccTransGetNum(to_trans), "") == 0))
722 xaccTransSetNum(to_trans, xaccTransGetNum(from_trans));
723
724 xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
725 xaccTransSetDocLink(to_trans, xaccTransGetDocLink (from_trans));
726 if(!no_date)
727 {
729 }
730
731 /* Each new split will be parented to 'to' */
732 for (node = from_trans->splits; node; node = node->next)
733 {
734 Split *new_split = xaccMallocSplit( qof_instance_get_book(QOF_INSTANCE(from_trans)));
735 xaccSplitCopyOnto(GNC_SPLIT(node->data), new_split);
736 if (change_accounts && xaccSplitGetAccount(GNC_SPLIT(node->data)) == from_acc)
737 xaccSplitSetAccount(new_split, to_acc);
738 xaccSplitSetParent(new_split, to_trans);
739 }
740 xaccTransCommitEdit(to_trans);
741}
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 681 of file Transaction.cpp.

682{
683 xaccTransCopyFromClipBoard(from_trans, to_trans, nullptr, nullptr, TRUE);
684}
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 665 of file Transaction.cpp.

666{
667 Transaction *to_trans;
668
669 if (!from_trans)
670 return nullptr;
671
672 to_trans = dupe_trans(from_trans);
673 return to_trans;
674}

◆ xaccTransCountSplits()

int xaccTransCountSplits ( const Transaction *  trans)

Returns the number of splits in this transaction.

Definition at line 2197 of file Transaction.cpp.

2198{
2199 gint i = 0;
2200 g_return_val_if_fail (trans != nullptr, 0);
2201 FOR_EACH_SPLIT(trans, i++);
2202 return i;
2203}

◆ 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 810 of file Transaction.cpp.

815{
816 gboolean same_book;
817
818 if (!ta && !tb) return TRUE; /* Arguable. FALSE may be better. */
819
820 if (!ta || !tb)
821 {
822 PINFO ("one is nullptr");
823 return FALSE;
824 }
825
826 if (ta == tb) return TRUE;
827
828 same_book = qof_instance_get_book(QOF_INSTANCE(ta)) == qof_instance_get_book(QOF_INSTANCE(tb));
829
830 if (check_guids)
831 {
832 if (qof_instance_guid_compare(ta, tb) != 0)
833 {
834 PINFO ("GUIDs differ");
835 return FALSE;
836 }
837 }
838
839 if (!gnc_commodity_equal(ta->common_currency, tb->common_currency))
840 {
841 PINFO ("commodities differ %s vs %s",
842 gnc_commodity_get_unique_name (ta->common_currency),
843 gnc_commodity_get_unique_name (tb->common_currency));
844 return FALSE;
845 }
846
847 if (ta->date_entered != tb->date_entered)
848 {
849 char buf1[100];
850 char buf2[100];
851
852 (void)gnc_time64_to_iso8601_buff(ta->date_entered, buf1);
853 (void)gnc_time64_to_iso8601_buff(tb->date_entered, buf2);
854 PINFO ("date entered differs: '%s' vs '%s'", buf1, buf2);
855 return FALSE;
856 }
857
858 if (ta->date_posted != tb->date_posted)
859 {
860 char buf1[100];
861 char buf2[100];
862
863 (void)gnc_time64_to_iso8601_buff(ta->date_posted, buf1);
864 (void)gnc_time64_to_iso8601_buff(tb->date_posted, buf2);
865 PINFO ("date posted differs: '%s' vs '%s'", buf1, buf2);
866 return FALSE;
867 }
868
869 /* If the same book, since we use cached strings, we can just compare pointer
870 * equality for num and description
871 */
872 if ((same_book && ta->num != tb->num) || (!same_book && g_strcmp0(ta->num, tb->num) != 0))
873 {
874 PINFO ("num differs: %s vs %s", ta->num, tb->num);
875 return FALSE;
876 }
877
878 if ((same_book && ta->description != tb->description)
879 || (!same_book && g_strcmp0(ta->description, tb->description)))
880 {
881 PINFO ("descriptions differ: %s vs %s", ta->description, tb->description);
882 return FALSE;
883 }
884
885 if (qof_instance_compare_kvp (QOF_INSTANCE (ta), QOF_INSTANCE (tb)) != 0)
886 {
887 char *frame_a;
888 char *frame_b;
889
890 frame_a = qof_instance_kvp_as_string (QOF_INSTANCE (ta));
891 frame_b = qof_instance_kvp_as_string (QOF_INSTANCE (tb));
892
893
894 PINFO ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
895
896 g_free (frame_a);
897 g_free (frame_b);
898
899 return FALSE;
900 }
901
902 if (check_splits)
903 {
904 if ((!ta->splits && tb->splits) || (!tb->splits && ta->splits))
905 {
906 PINFO ("only one has splits");
907 return FALSE;
908 }
909
910 if (ta->splits && tb->splits)
911 {
912 GList *node_a, *node_b;
913
914 for (node_a = ta->splits, node_b = tb->splits;
915 node_a;
916 node_a = node_a->next, node_b = node_b->next)
917 {
918 Split *split_a = GNC_SPLIT(node_a->data);
919 Split *split_b;
920
921 /* don't presume that the splits are in the same order */
922 if (!assume_ordered)
923 node_b = g_list_find_custom (tb->splits, split_a,
924 compare_split_guids);
925
926 if (!node_b)
927 {
928 gchar guidstr[GUID_ENCODING_LENGTH+1];
929 guid_to_string_buff (xaccSplitGetGUID (split_a),guidstr);
930
931 PINFO ("first has split %s and second does not",guidstr);
932 return FALSE;
933 }
934
935 split_b = GNC_SPLIT(node_b->data);
936
937 if (!xaccSplitEqual (split_a, split_b, check_guids, check_balances,
938 FALSE))
939 {
940 char str_a[GUID_ENCODING_LENGTH + 1];
941 char str_b[GUID_ENCODING_LENGTH + 1];
942
943 guid_to_string_buff (xaccSplitGetGUID (split_a), str_a);
944 guid_to_string_buff (xaccSplitGetGUID (split_b), str_b);
945
946 PINFO ("splits %s and %s differ", str_a, str_b);
947 return FALSE;
948 }
949 }
950
951 if (g_list_length (ta->splits) != g_list_length (tb->splits))
952 {
953 PINFO ("different number of splits");
954 return FALSE;
955 }
956 }
957 }
958
959 return TRUE;
960}
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 1140 of file Transaction.cpp.

1141{
1142 gnc_numeric total = gnc_numeric_zero ();
1143 if (!trans || !acc) return total;
1144
1145 total = gnc_numeric_convert (total, xaccAccountGetCommoditySCU (acc),
1146 GNC_HOW_RND_ROUND_HALF_UP);
1147 FOR_EACH_SPLIT(trans, if (acc == xaccSplitGetAccount(s))
1148 total = gnc_numeric_add_fixed(
1149 total, xaccSplitGetAmount(s)));
1150 return total;
1151}
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
Definition Account.cpp:2733
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 1214 of file Transaction.cpp.

1216{
1217 GList *node;
1218 Split *last_split = nullptr;
1219
1220 // Not really the appropriate error value.
1221 g_return_val_if_fail(account && trans, gnc_numeric_error(GNC_ERROR_ARG));
1222
1223 for (node = trans->splits; node; node = node->next)
1224 {
1225 Split *split = GNC_SPLIT(node->data);
1226
1227 if (!xaccTransStillHasSplit(trans, split))
1228 continue;
1229 if (xaccSplitGetAccount(split) != account)
1230 continue;
1231
1232 if (!last_split)
1233 {
1234 last_split = split;
1235 continue;
1236 }
1237
1238 /* This test needs to correspond to the comparison function used when
1239 sorting the splits for computing the running balance. */
1240 if (xaccSplitOrder (last_split, split) < 0)
1241 last_split = split;
1242 }
1243
1244 return xaccSplitGetBalance (last_split);
1245}
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:1547
gnc_numeric xaccSplitGetBalance(const Split *s)
Returns the running balance up to and including the indicated split.
Definition Split.cpp:1327

◆ xaccTransGetAccountConvRate()

gnc_numeric xaccTransGetAccountConvRate ( const Transaction *  txn,
const Account *  acc 
)

Definition at line 1154 of file Transaction.cpp.

1155{
1156 gnc_numeric amount, value, convrate;
1157 GList *splits;
1158 Split *s;
1159 gboolean found_acc_match = FALSE;
1160 gnc_commodity *acc_commod = xaccAccountGetCommodity(acc);
1161
1162 /* We need to compute the conversion rate into _this account_. So,
1163 * find the first split into this account, compute the conversion
1164 * rate (based on amount/value), and then return this conversion
1165 * rate.
1166 */
1167 if (gnc_commodity_equal(acc_commod, xaccTransGetCurrency(txn)))
1168 return gnc_numeric_create(1, 1);
1169
1170 for (splits = txn->splits; splits; splits = splits->next)
1171 {
1172 Account *split_acc;
1173 gnc_commodity *split_commod;
1174
1175 s = GNC_SPLIT(splits->data);
1176
1177 if (!xaccTransStillHasSplit(txn, s))
1178 continue;
1179 split_acc = xaccSplitGetAccount (s);
1180 split_commod = xaccAccountGetCommodity (split_acc);
1181 if (! (split_acc == acc ||
1182 gnc_commodity_equal (split_commod, acc_commod)))
1183 continue;
1184
1185 found_acc_match = TRUE;
1186 amount = xaccSplitGetAmount (s);
1187
1188 /* Ignore splits with "zero" amount */
1189 if (gnc_numeric_zero_p (amount))
1190 continue;
1191
1192 value = xaccSplitGetValue (s);
1193 if (gnc_numeric_zero_p (value))
1194 PWARN("How can amount be nonzero and value be zero?");
1195
1196 convrate = gnc_numeric_div(amount, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
1197 return convrate;
1198 }
1199
1200 if (acc)
1201 {
1202 /* If we did find a matching account but its amount was zero,
1203 * then perhaps this is a "special" income/loss transaction
1204 */
1205 if (found_acc_match)
1206 return gnc_numeric_zero();
1207 else
1208 PERR("Cannot convert transaction -- no splits with proper conversion ratio");
1209 }
1210 return gnc_numeric_create (100, 100);
1211}
#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 1124 of file Transaction.cpp.

1126{
1127 gnc_numeric total = gnc_numeric_zero ();
1128 if (!trans || !acc) return total;
1129
1130 FOR_EACH_SPLIT(trans, if (acc == xaccSplitGetAccount(s))
1131{
1132 total = gnc_numeric_add (total, xaccSplitGetValue (s),
1134 GNC_HOW_DENOM_EXACT);
1135 });
1136 return total;
1137}
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 2134 of file Transaction.cpp.

2135{
2136 GList *apar_splits = nullptr;
2137 if (!trans) return nullptr;
2138
2139 FOR_EACH_SPLIT (trans,
2140 const Account *account = xaccSplitGetAccount(s);
2141 if (account && xaccAccountIsAPARType(xaccAccountGetType(account)))
2142 {
2143
2144 if (!strict)
2145 apar_splits = g_list_prepend (apar_splits, s);
2146 else
2147 {
2148 GncOwner owner;
2149 GNCLot *lot = xaccSplitGetLot(s);
2150 if (lot &&
2151 (gncInvoiceGetInvoiceFromLot (lot) ||
2152 gncOwnerGetOwnerFromLot (lot, &owner)))
2153 apar_splits = g_list_prepend (apar_splits, s);
2154 }
2155 }
2156 );
2157
2158 apar_splits = g_list_reverse (apar_splits);
2159 return apar_splits;
2160}
gboolean xaccAccountIsAPARType(GNCAccountType t)
Convenience function to check if the account is a valid business account type (meaning an Accounts Pa...
Definition Account.cpp:4515
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:1931

◆ 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 2247 of file Transaction.cpp.

2248{
2249 return trans ? trans->date_entered : 0;
2250}

◆ 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 2260 of file Transaction.cpp.

2261{
2262 GDate result;
2263 g_date_clear (&result, 1);
2264 if (trans)
2265 {
2266 /* Can we look up this value in the kvp slot? If yes, use it
2267 * from there because it doesn't suffer from time zone
2268 * shifts. */
2269 if (auto res = qof_instance_get_path_kvp<GDate> (QOF_INSTANCE(trans), {TRANS_DATE_POSTED}))
2270 result = *res;
2271 if (! g_date_valid (&result) || gdate_to_time64 (result) == INT64_MAX)
2272 {
2273 /* Well, this txn doesn't have a valid GDate saved in a slot.
2274 * time64_to_gdate() uses local time and we want UTC so we have
2275 * to write it out.
2276 */
2277 time64 time = xaccTransGetDate(trans);
2278 struct tm *stm = gnc_gmtime(&time);
2279 if (stm)
2280 {
2281 g_date_set_dmy(&result, stm->tm_mday,
2282 (GDateMonth)(stm->tm_mon + 1),
2283 stm->tm_year + 1900);
2284 free(stm);
2285 }
2286 }
2287 }
2288 return result;
2289}
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 2218 of file Transaction.cpp.

2219{
2220 return get_kvp_string_path (trans, {doclink_uri_str});
2221}

◆ 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 2173 of file Transaction.cpp.

2174{
2175 FOR_EACH_SPLIT (trans,
2176 const Account *account = xaccSplitGetAccount(s);
2177 if (account && xaccAccountIsAPARType(xaccAccountGetType(account)))
2178 {
2179 GNCLot *lot;
2180 GncOwner owner;
2181
2182 if (!strict)
2183 return s;
2184
2185 lot = xaccSplitGetLot(s);
2186 if (lot &&
2187 (gncInvoiceGetInvoiceFromLot (lot) ||
2188 gncOwnerGetOwnerFromLot (lot, &owner)))
2189 return s;
2190 }
2191 );
2192
2193 return nullptr;
2194}

◆ 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 2162 of file Transaction.cpp.

2163{
2164 FOR_EACH_SPLIT (trans,
2165 const Account *account = xaccSplitGetAccount(s);
2166 if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account)))
2167 return s;
2168 );
2169
2170 return nullptr;
2171}

◆ 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 1006 of file Transaction.cpp.

1007{
1008 /* imbal_value is used if either (1) the transaction has a non currency
1009 split or (2) all the splits are in the same currency. If there are
1010 no non-currency splits and not all splits are in the same currency then
1011 imbal_list is used to compute the imbalance. */
1012 MonetaryList *imbal_list = nullptr;
1013 gnc_numeric imbal_value = gnc_numeric_zero();
1014 gboolean trading_accts;
1015
1016 if (!trans) return imbal_list;
1017
1018 ENTER("(trans=%p)", trans);
1019
1020 trading_accts = xaccTransUseTradingAccounts (trans);
1021
1022 /* If using trading accounts and there is at least one split that is not
1023 in the transaction currency or a split that has a price or exchange
1024 rate other than 1, then compute the balance in each commodity in the
1025 transaction. Otherwise (all splits are in the transaction's currency)
1026 then compute the balance using the value fields.
1027
1028 Optimize for the common case of only one currency and a balanced
1029 transaction. */
1030 FOR_EACH_SPLIT(trans,
1031 {
1032 gnc_commodity *commodity;
1034 if (trading_accts &&
1035 (imbal_list ||
1036 ! gnc_commodity_equiv(commodity, trans->common_currency) ||
1038 {
1039 /* Need to use (or already are using) a list of imbalances in each of
1040 the currencies used in the transaction. */
1041 if (! imbal_list)
1042 {
1043 /* All previous splits have been in the transaction's common
1044 currency, so imbal_value is in this currency. */
1045 imbal_list = gnc_monetary_list_add_value(imbal_list,
1046 trans->common_currency,
1047 imbal_value);
1048 }
1049 imbal_list = gnc_monetary_list_add_value(imbal_list, commodity,
1051 }
1052
1053 /* Add it to the value accumulator in case we need it. */
1054 imbal_value = gnc_numeric_add(imbal_value, xaccSplitGetValue(s),
1055 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
1056 } );
1057
1058
1059 if (!imbal_list && !gnc_numeric_zero_p(imbal_value))
1060 {
1061 /* Not balanced and no list, create one. If we found multiple currencies
1062 and no non-currency commodity then imbal_list will already exist and
1063 we won't get here. */
1064 imbal_list = gnc_monetary_list_add_value(imbal_list,
1065 trans->common_currency,
1066 imbal_value);
1067 }
1068
1069 /* Delete all the zero entries from the list, perhaps leaving an
1070 empty list */
1071 imbal_list = gnc_monetary_list_delete_zeros(imbal_list);
1072
1073 LEAVE("(trans=%p), imbal=%p", trans, imbal_list);
1074 return imbal_list;
1075}
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 2230 of file Transaction.cpp.

2231{
2232 auto rv{qof_instance_get_path_kvp<int64_t> (QOF_INSTANCE(trans), {trans_is_closing_str})};
2233 return rv ? *rv != 0 : FALSE;
2234}

◆ 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 2120 of file Transaction.cpp.

2121{
2122 GList *pay_splits = nullptr;
2123 FOR_EACH_SPLIT (trans,
2124 const Account *account = xaccSplitGetAccount(s);
2125 if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account)))
2126 pay_splits = g_list_prepend (pay_splits, s);
2127 );
2128
2129 pay_splits = g_list_reverse (pay_splits);
2130 return pay_splits;
2131}

◆ 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 2345 of file Transaction.cpp.

2346{
2347 return get_kvp_string_path (trans, {TRANS_READ_ONLY_REASON});
2348}

◆ 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 2613 of file Transaction.cpp.

2614{
2615 g_return_val_if_fail(trans, nullptr);
2616 auto g = qof_instance_get_path_kvp<GncGUID*> (QOF_INSTANCE(trans), {TRANS_REVERSED_BY});
2617 return g ? xaccTransLookup (*g, qof_instance_get_book (trans)) : nullptr;
2618}
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 2104 of file Transaction.cpp.

2105{
2106 int j = 0;
2107 g_return_val_if_fail(trans && split, -1);
2108
2109 FOR_EACH_SPLIT(trans, { if (s == split) return j; j++; });
2110 return -1;
2111}

◆ 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 2306 of file Transaction.cpp.

2307{
2308 gboolean has_nonAPAR_split = FALSE;
2309
2310 if (!trans) return TXN_TYPE_NONE;
2311
2312 if (trans->txn_type != TXN_TYPE_UNCACHED)
2313 return trans->txn_type;
2314
2315 trans->txn_type = TXN_TYPE_NONE;
2316 for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
2317 {
2318 Account *acc = xaccSplitGetAccount (GNC_SPLIT(n->data));
2319
2320 if (!acc)
2321 continue;
2322
2324 has_nonAPAR_split = TRUE;
2325 else if (trans->txn_type == TXN_TYPE_NONE)
2326 {
2327 GNCLot *lot = xaccSplitGetLot (GNC_SPLIT(n->data));
2328 GncInvoice *invoice = gncInvoiceGetInvoiceFromLot (lot);
2329 GncOwner owner;
2330
2331 if (invoice && trans == gncInvoiceGetPostedTxn (invoice))
2332 trans->txn_type = TXN_TYPE_INVOICE;
2333 else if (invoice || gncOwnerGetOwnerFromLot (lot, &owner))
2334 trans->txn_type = TXN_TYPE_PAYMENT;
2335 }
2336 }
2337
2338 if (!has_nonAPAR_split && (trans->txn_type == TXN_TYPE_PAYMENT))
2339 trans->txn_type = TXN_TYPE_LINK;
2340
2341 return trans->txn_type;
2342}
#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 2541 of file Transaction.cpp.

2542{
2543 return get_kvp_string_path (trans, {void_reason_str});
2544}

◆ 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 2534 of file Transaction.cpp.

2535{
2536 auto t = xaccTransGetVoidTime (trans);
2537 return t != INT64_MAX;
2538}
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 2547 of file Transaction.cpp.

2548{
2549 auto void_str{get_kvp_string_path (tr, {void_time_str})};
2550 return void_str ? gnc_iso8601_to_time64_gmt (void_str) : INT64_MAX;
2551}

◆ xaccTransHasReconciledSplits()

gboolean xaccTransHasReconciledSplits ( const Transaction *  trans)

FIXME: document me.

Definition at line 2441 of file Transaction.cpp.

2442{
2443 return xaccTransHasReconciledSplitsByAccount (trans, nullptr);
2444}
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 2412 of file Transaction.cpp.

2414{
2415 GList *node;
2416
2417 for (node = xaccTransGetSplitList (trans); node; node = node->next)
2418 {
2419 Split *split = GNC_SPLIT(node->data);
2420
2421 if (!xaccTransStillHasSplit(trans, split))
2422 continue;
2423 if (account && (xaccSplitGetAccount(split) != account))
2424 continue;
2425
2426 switch (xaccSplitGetReconcile (split))
2427 {
2428 case YREC:
2429 case FREC:
2430 return TRUE;
2431
2432 default:
2433 break;
2434 }
2435 }
2436
2437 return FALSE;
2438}
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 2471 of file Transaction.cpp.

2472{
2473 return xaccTransHasSplitsInStateByAccount (trans, state, nullptr);
2474}
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 2448 of file Transaction.cpp.

2451{
2452 GList *node;
2453
2454 for (node = xaccTransGetSplitList (trans); node; node = node->next)
2455 {
2456 Split *split = GNC_SPLIT(node->data);
2457
2458 if (!xaccTransStillHasSplit(trans, split))
2459 continue;
2460 if (account && (xaccSplitGetAccount(split) != account))
2461 continue;
2462
2463 if (split->reconciled == state)
2464 return TRUE;
2465 }
2466
2467 return FALSE;
2468}

◆ xaccTransIsBalanced()

gboolean xaccTransIsBalanced ( const Transaction *  trans)

Returns true if the transaction is balanced according to the rules currently in effect.

Definition at line 1078 of file Transaction.cpp.

1079{
1080 MonetaryList *imbal_list;
1081 gboolean result;
1082 gnc_numeric imbal = gnc_numeric_zero();
1083 gnc_numeric imbal_trading = gnc_numeric_zero();
1084
1085 if (trans == nullptr) return FALSE;
1086
1087 if (xaccTransUseTradingAccounts(trans))
1088 {
1089 /* Transaction is imbalanced if the value is imbalanced in either
1090 trading or non-trading splits. One can't be used to balance
1091 the other. */
1092 FOR_EACH_SPLIT(trans,
1093 {
1094 Account *acc = xaccSplitGetAccount(s);
1095 if (!acc || xaccAccountGetType(acc) != ACCT_TYPE_TRADING)
1096 {
1097 imbal = gnc_numeric_add(imbal, xaccSplitGetValue(s),
1098 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
1099 }
1100 else
1101 {
1102 imbal_trading = gnc_numeric_add(imbal_trading, xaccSplitGetValue(s),
1103 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
1104 }
1105 }
1106 );
1107 }
1108 else
1109 imbal = xaccTransGetImbalanceValue(trans);
1110
1111 if (! gnc_numeric_zero_p(imbal) || ! gnc_numeric_zero_p(imbal_trading))
1112 return FALSE;
1113
1114 if (!xaccTransUseTradingAccounts (trans))
1115 return TRUE;
1116
1117 imbal_list = xaccTransGetImbalance(trans);
1118 result = imbal_list == nullptr;
1119 gnc_monetary_list_free(imbal_list);
1120 return result;
1121}
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 2373 of file Transaction.cpp.

2374{
2375 GDate *threshold_date;
2376 GDate trans_date;
2377 const QofBook *book = xaccTransGetBook (trans);
2378 gboolean result;
2379 g_assert(trans);
2380
2381 if (!qof_book_uses_autoreadonly(book))
2382 {
2383 return FALSE;
2384 }
2385
2386 if (xaccTransIsSXTemplate (trans))
2387 return FALSE;
2388
2389 threshold_date = qof_book_get_autoreadonly_gdate(book);
2390 g_assert(threshold_date); // ok because we checked uses_autoreadonly before
2391 trans_date = xaccTransGetDatePostedGDate(trans);
2392
2393// g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",
2394// qof_book_get_num_days_autofreeze(book),
2395// g_date_get_day(&trans_date),
2396// g_date_get_day(threshold_date));
2397
2398 if (g_date_compare(&trans_date, threshold_date) < 0)
2399 {
2400 //g_warning("we are auto-read-only");
2401 result = TRUE;
2402 }
2403 else
2404 {
2405 result = FALSE;
2406 }
2407 g_date_free(threshold_date);
2408 return result;
2409}
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 978 of file Transaction.cpp.

979{
980 QofCollection *col;
981 if (!guid || !book) return nullptr;
982 col = qof_book_get_collection (book, GNC_ID_TRANS);
983 return (Transaction *) qof_collection_lookup_entity (col, guid);
984}
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 1758 of file Transaction.cpp.

1759{
1760 return xaccTransOrder_num_action (ta, nullptr, tb, nullptr);
1761}
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 1794 of file Transaction.cpp.

1796{
1797 const char *da, *db;
1798 int retval;
1799
1800 if (ta == tb) return 0;
1801 if (!tb) return -1;
1802 if (!ta) return +1;
1803
1804 if (ta->date_posted != tb->date_posted)
1805 return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
1806
1807 /* Always sort closing transactions after normal transactions */
1808 {
1809 gboolean ta_is_closing = xaccTransGetIsClosingTxn (ta);
1810 gboolean tb_is_closing = xaccTransGetIsClosingTxn (tb);
1811 if (ta_is_closing != tb_is_closing)
1812 return (ta_is_closing - tb_is_closing);
1813 }
1814
1815 /* otherwise, sort on number string */
1816 if (actna && actnb) /* split action string, if not nullptr */
1817 {
1818 retval = order_by_int64_or_string (actna, actnb);
1819 }
1820 else /* else transaction num string */
1821 {
1822 retval = order_by_int64_or_string (ta->num, tb->num);
1823 }
1824 if (retval)
1825 return retval;
1826
1827 if (ta->date_entered != tb->date_entered)
1828 return (ta->date_entered > tb->date_entered) - (ta->date_entered < tb->date_entered);
1829
1830 /* otherwise, sort on description string */
1831 da = ta->description ? ta->description : "";
1832 db = tb->description ? tb->description : "";
1833 retval = g_utf8_collate (da, db);
1834 if (retval)
1835 return retval;
1836
1837 /* else, sort on guid - keeps sort stable. */
1838 return qof_instance_guid_compare(ta, tb);
1839}
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 2298 of file Transaction.cpp.

2299{
2300 if (!trans) return 0;
2301 auto res = qof_instance_get_path_kvp<Time64> (QOF_INSTANCE (trans), {TRANS_DATE_DUE_KVP});
2302 return res ? res->t : xaccTransRetDatePosted (trans);
2303}

◆ 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 2292 of file Transaction.cpp.

2293{
2294 return trans ? trans->date_entered : 0;
2295}

◆ 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 2254 of file Transaction.cpp.

2255{
2256 return trans ? trans->date_posted : 0;
2257}

◆ 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 2576 of file Transaction.cpp.

2577{
2578 Transaction *trans;
2579 g_return_val_if_fail(orig, nullptr);
2580
2581 /* First edit, dirty, and commit orig to ensure that any trading
2582 * splits are correctly balanced.
2583 */
2584 xaccTransBeginEdit (orig);
2585 qof_instance_set_dirty (QOF_INSTANCE (orig));
2586 xaccTransCommitEdit (orig);
2587
2588 trans = xaccTransClone(orig);
2589 g_return_val_if_fail (trans, nullptr);
2590 xaccTransBeginEdit(trans);
2591
2592 /* Reverse the values on each split. Clear per-split info. */
2593 FOR_EACH_SPLIT(trans,
2594 {
2598 });
2599
2600 /* Now update the original with a pointer to the new one */
2601 qof_instance_set_path_kvp<GncGUID*> (QOF_INSTANCE (orig), guid_copy(xaccTransGetGUID(trans)),
2602 {TRANS_REVERSED_BY});
2603
2604 /* Make sure the reverse transaction is not read-only */
2605 xaccTransClearReadOnly(trans);
2606
2607 qof_instance_set_dirty(QOF_INSTANCE(trans));
2608 xaccTransCommitEdit(trans);
2609 return trans;
2610}
#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 1591 of file Transaction.cpp.

1592{
1593 GList *node, *onode;
1594 QofBackend *be;
1595 Transaction *orig;
1596 GList *slist;
1597 int num_preexist, i;
1598
1599/* FIXME: This isn't quite the right way to handle nested edits --
1600 * there should be a stack of transaction states that are popped off
1601 * and restored at each level -- but it does prevent restoring to the
1602 * editlevel 0 state until one is returning to editlevel 0, and
1603 * thereby prevents a crash caused by trans->orig getting nullptred too
1604 * soon.
1605 */
1606 if (!qof_instance_get_editlevel (QOF_INSTANCE (trans))) return;
1607 if (qof_instance_get_editlevel (QOF_INSTANCE (trans)) > 1) {
1608 qof_instance_decrease_editlevel (QOF_INSTANCE (trans));
1609 return;
1610 }
1611
1612 ENTER ("trans addr=%p\n", trans);
1613
1614 check_open(trans);
1615
1616 /* copy the original values back in. */
1617
1618 orig = trans->orig;
1619 std::swap (trans->num, orig->num);
1620 std::swap (trans->description, orig->description);
1621 trans->date_entered = orig->date_entered;
1622 trans->date_posted = orig->date_posted;
1623 std::swap (trans->common_currency, orig->common_currency);
1624 qof_instance_swap_kvp (QOF_INSTANCE (trans), QOF_INSTANCE (orig));
1625
1626 /* The splits at the front of trans->splits are exactly the same
1627 splits as in the original, but some of them may have changed, so
1628 we restore only those. */
1629/* FIXME: Runs off the transaction's splits, so deleted splits are not
1630 * restored!
1631 */
1632 num_preexist = g_list_length(orig->splits);
1633 slist = g_list_copy(trans->splits);
1634 for (i = 0, node = slist, onode = orig->splits; node;
1635 i++, node = node->next, onode = onode ? onode->next : nullptr)
1636 {
1637 Split *s = GNC_SPLIT(node->data);
1638
1639 if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
1640 continue;
1641
1642 if (i < num_preexist && onode)
1643 {
1644 Split *so = GNC_SPLIT(onode->data);
1645
1646 xaccSplitRollbackEdit(s);
1647 std::swap (s->action, so->action);
1648 std::swap (s->memo, so->memo);
1649 qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so));
1650 s->reconciled = so->reconciled;
1651 s->amount = so->amount;
1652 s->value = so->value;
1653 s->lot = so->lot;
1654 s->gains_split = so->gains_split;
1655 //SET_GAINS_A_VDIRTY(s);
1656 s->date_reconciled = so->date_reconciled;
1657 qof_instance_mark_clean(QOF_INSTANCE(s));
1658 }
1659 else
1660 {
1661 /* Potentially added splits */
1662 if (trans != xaccSplitGetParent(s))
1663 {
1664 trans->splits = g_list_remove(trans->splits, s);
1665 /* New split added, but then moved to another
1666 transaction */
1667 continue;
1668 }
1669 xaccSplitRollbackEdit(s);
1670 trans->splits = g_list_remove(trans->splits, s);
1671 g_assert(trans != xaccSplitGetParent(s));
1672 /* NB: our memory management policy here is that a new split
1673 added to the transaction which is then rolled-back still
1674 belongs to the engine. Specifically, it's freed by the
1675 transaction to which it was added. Don't add the Split to
1676 more than one transaction during the begin/commit block! */
1677 if (nullptr == xaccSplitGetParent(s))
1678 {
1679 xaccFreeSplit(s); // a newly malloc'd split
1680 }
1681 }
1682 }
1683 g_list_free(slist);
1684
1685 // orig->splits may still have duped splits so free them
1686 g_list_free_full (orig->splits, (GDestroyNotify)xaccFreeSplit);
1687 orig->splits = nullptr;
1688
1689 /* Now that the engine copy is back to its original version,
1690 * get the backend to fix it in the database */
1694 if (qof_backend_can_rollback (be))
1695 {
1696 QofBackendError errcode;
1697
1698 /* clear errors */
1699 do
1700 {
1701 errcode = qof_backend_get_error (be);
1702 }
1703 while (ERR_BACKEND_NO_ERR != errcode);
1704
1705 qof_backend_rollback_instance (be, &(trans->inst));
1706
1707 errcode = qof_backend_get_error (be);
1708 if (ERR_BACKEND_MOD_DESTROY == errcode)
1709 {
1710 /* The backend is asking us to delete this transaction.
1711 * This typically happens because another (remote) user
1712 * has deleted this transaction, and we haven't found
1713 * out about it until this user tried to edit it.
1714 */
1715 xaccTransDestroy (trans);
1716 do_destroy (QOF_INSTANCE(trans));
1717
1718 /* push error back onto the stack */
1719 qof_backend_set_error (be, errcode);
1720 LEAVE ("deleted trans addr=%p\n", trans);
1721 return;
1722 }
1723 if (ERR_BACKEND_NO_ERR != errcode)
1724 {
1725 PERR ("Rollback Failed. Ouch!");
1726 /* push error back onto the stack */
1727 qof_backend_set_error (be, errcode);
1728 }
1729 }
1730
1732 xaccTransWriteLog (trans, 'R');
1733
1734 xaccFreeTransaction (trans->orig);
1735
1736 trans->orig = nullptr;
1737 qof_instance_set_destroying(trans, FALSE);
1738
1739 /* Put back to zero. */
1740 qof_instance_decrease_editlevel(trans);
1741 /* FIXME: The register code seems to depend on the engine to
1742 generate an event during rollback, even though the state is just
1743 reverting to what it was. */
1744 gen_event_trans (trans);
1745
1746 LEAVE ("trans addr=%p\n", trans);
1747}
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 2663 of file Transaction.cpp.

2664{
2665 SplitList *node;
2666
2667 ENTER("(trans=%p)", trans);
2668 /* Lock down posted date, its to be synced to the posted date
2669 * for the source of the cap gains. */
2670 xaccTransScrubGainsDate(trans);
2671
2672 /* Fix up the split amount */
2673restart:
2674 for (node = trans->splits; node; node = node->next)
2675 {
2676 Split *s = GNC_SPLIT(node->data);
2677
2678 if (!xaccTransStillHasSplit(trans, s)) continue;
2679
2680 xaccSplitDetermineGainStatus(s);
2681 if (s->gains & GAINS_STATUS_ADIRTY)
2682 {
2683 gboolean altered = FALSE;
2684 s->gains &= ~GAINS_STATUS_ADIRTY;
2685 if (s->lot)
2686 altered = xaccScrubLot(s->lot);
2687 else
2688 altered = xaccSplitAssign(s);
2689 if (altered) goto restart;
2690 }
2691 }
2692
2693 /* Fix up gains split value */
2694 FOR_EACH_SPLIT(trans,
2695 if ((s->gains & GAINS_STATUS_VDIRTY) ||
2696 (s->gains_split &&
2697 (s->gains_split->gains & GAINS_STATUS_VDIRTY)))
2698 xaccSplitComputeCapGains(s, gain_acc);
2699 );
2700
2701 LEAVE("(trans=%p)", trans);
2702}
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 1311 of file Transaction.cpp.

1312{
1313 if (!trans || !curr || trans->common_currency == curr) return;
1314
1315 gnc_commodity *old_curr = trans->common_currency;
1316 xaccTransBeginEdit(trans);
1317
1318 trans->common_currency = curr;
1319 if (old_curr != nullptr && trans->splits != nullptr)
1320 {
1321 gnc_numeric rate = find_new_rate(trans, curr);
1322 if (!gnc_numeric_zero_p (rate))
1323 {
1324 FOR_EACH_SPLIT(trans, split_set_new_value(s, curr, old_curr, rate));
1325 }
1326 else
1327 {
1328 FOR_EACH_SPLIT(trans, xaccSplitSetValue(s, xaccSplitGetValue(s)));
1329 }
1330 }
1331
1332 qof_instance_set_dirty(QOF_INSTANCE(trans));
1333 mark_trans(trans); /* Dirty balance of every account in trans */
1334 xaccTransCommitEdit(trans);
1335}

◆ 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 1937 of file Transaction.cpp.

1938{
1939 if (!trans) return;
1940 GDate date;
1941 g_date_clear (&date, 1);
1942 if (g_date_valid_dmy (day, static_cast<GDateMonth>(mon), year))
1943 g_date_set_dmy (&date, day, static_cast<GDateMonth>(mon), year);
1944 else
1945 {
1946 PWARN("Attempted to set invalid date %d-%d-%d; set today's date instead.",
1947 year, mon, day);
1948 gnc_gdate_set_today (&date);
1949 }
1950 xaccTransSetDatePostedGDate(trans, date);
1951}
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 1954 of file Transaction.cpp.

1955{
1956 if (!trans) return;
1957 xaccTransBeginEdit(trans);
1958 qof_instance_set_path_kvp<Time64> (QOF_INSTANCE (trans), Time64{time}, {TRANS_DATE_DUE_KVP});
1959 qof_instance_set_dirty(QOF_INSTANCE(trans));
1960 xaccTransCommitEdit(trans);
1961}

◆ 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 1930 of file Transaction.cpp.

1931{
1932 if (!trans) return;
1933 xaccTransSetDateInternal(trans, &trans->date_entered, secs);
1934}

◆ 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 1914 of file Transaction.cpp.

1915{
1916 if (!trans) return;
1917
1918 /* We additionally save this date into a kvp frame to ensure in
1919 * the future a date which was set as *date* (without time) can
1920 * clearly be distinguished from the time64. */
1921 qof_instance_set_path_kvp<GDate> (QOF_INSTANCE(trans), date, {TRANS_DATE_POSTED});
1922 qof_instance_set_dirty (QOF_INSTANCE(trans));
1923 /* mark dirty and commit handled by SetDateInternal */
1924 xaccTransSetDateInternal(trans, &trans->date_posted,
1925 gdate_to_time64(date));
1926 set_gains_date_dirty (trans);
1927}

◆ 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 1898 of file Transaction.cpp.

1899{
1900 if (!trans) return;
1901 xaccTransSetDateInternal(trans, &trans->date_posted, secs);
1902 set_gains_date_dirty(trans);
1903}

◆ 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 2027 of file Transaction.cpp.

2028{
2029 if (!trans || !doclink) return;
2030 set_kvp_string_path (trans, {doclink_uri_str}, doclink);
2031}

◆ xaccTransSetIsClosingTxn()

void xaccTransSetIsClosingTxn ( Transaction *  trans,
gboolean  is_closing 
)

Sets whether or not this transaction is a "closing transaction".

Definition at line 2049 of file Transaction.cpp.

2050{
2051 xaccTransBeginEdit(trans);
2052 auto val = is_closing ? std::make_optional<int64_t>(1) : std::nullopt;
2053 qof_instance_set_path_kvp<int64_t> (QOF_INSTANCE(trans), val, {trans_is_closing_str});
2054 xaccTransCommitEdit(trans);
2055}

◆ 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 1996 of file Transaction.cpp.

1997{
1998 if (!trans || !xnum) return;
1999 xaccTransBeginEdit(trans);
2000
2001 CACHE_REPLACE(trans->num, xnum);
2002 qof_instance_set_dirty(QOF_INSTANCE(trans));
2003 mark_trans(trans); /* Dirty balance of every account in trans */
2004 xaccTransCommitEdit(trans);
2005}

◆ 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 1976 of file Transaction.cpp.

1977{
1978 if (trans && reason)
1979 set_kvp_string_path (trans, {TRANS_READ_ONLY_REASON}, reason);
1980}

◆ 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 1964 of file Transaction.cpp.

1965{
1966 char s[2] = {type, '\0'};
1967 set_kvp_string_path (trans, {TRANS_TXN_TYPE_KVP}, s);
1968}

◆ xaccTransSortSplits()

void xaccTransSortSplits ( Transaction *  trans)

Sorts the splits in a transaction, putting the debits first, followed by the credits.

Definition at line 549 of file Transaction.cpp.

550{
551 g_return_if_fail (trans);
552 trans->splits = g_list_sort (trans->splits, split_sign_cmp);
553}

◆ 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 2554 of file Transaction.cpp.

2555{
2556 g_return_if_fail(trans);
2557
2558 if (!xaccTransGetVoidStatus (trans))
2559 return; /* Transaction isn't voided. Bail. */
2560
2561 xaccTransBeginEdit(trans);
2562
2563 set_kvp_string_path (trans, {trans_notes_str}, get_kvp_string_path (trans, {void_former_notes_str}));
2564 set_kvp_string_path (trans, {void_former_notes_str}, nullptr);
2565 set_kvp_string_path (trans, {void_reason_str}, nullptr);
2566 set_kvp_string_path (trans, {void_time_str}, nullptr);
2567
2568 FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s));
2569
2570 /* Dirtying taken care of by ClearReadOnly */
2571 xaccTransClearReadOnly(trans);
2572 xaccTransCommitEdit(trans);
2573}
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 969 of file Transaction.cpp.

970{
972}
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 2503 of file Transaction.cpp.

2504{
2505 g_return_if_fail(trans && reason);
2506
2507 /* Prevent voiding transactions that are already marked
2508 * read only, for example generated by the business features.
2509 */
2510 if (xaccTransGetReadOnly (trans))
2511 {
2512 PWARN ("Refusing to void a read-only transaction!");
2513 return;
2514 }
2515 xaccTransBeginEdit(trans);
2516
2517 char iso8601_str[ISO_DATELENGTH + 1] = "";
2518 gnc_time64_to_iso8601_buff (gnc_time(nullptr), iso8601_str);
2519
2520 if (auto s = get_kvp_string_path (trans, {trans_notes_str}))
2521 set_kvp_string_path (trans, {void_former_notes_str}, s);
2522 set_kvp_string_path (trans, {trans_notes_str}, _("Voided transaction"));
2523 set_kvp_string_path (trans, {void_reason_str}, reason);
2524 set_kvp_string_path (trans, {void_time_str}, iso8601_str);
2525
2526 FOR_EACH_SPLIT(trans, xaccSplitVoid(s));
2527
2528 /* Dirtying taken care of by SetReadOnly */
2529 xaccTransSetReadOnly(trans, _("Transaction Voided"));
2530 xaccTransCommitEdit(trans);
2531}
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.