GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
GCW::Dbo::Accounts Namespace Reference

Namespaces

namespace  Children
 Account Children Namespace.
 
namespace  Field
 

Classes

struct  ACCOUNTDEF_S
 Account Definition. More...
 
class  Item
 Account Item Class. More...
 

Typedefs

typedef struct GCW::Dbo::Accounts::ACCOUNTDEF_S AccountDef_t
 Account Definition.
 

Enumerations

enum class  DrCr { NONE = 0x00 , DEBIT = 0x01 , CREDIT = 0x02 }
 Account Debit/Credit Enum. More...
 
enum class  Type {
  INVALID = -1 , NONE = -1 , BANK = 0 , CASH = 1 ,
  CREDIT = 3 , ASSET = 2 , LIABILITY = 4 , STOCK = 5 ,
  MUTUAL = 6 , CURRENCY = 7 , INCOME = 8 , EXPENSE = 9 ,
  EQUITY = 10 , RECEIVABLE = 11 , PAYABLE = 12 , ROOT = 13 ,
  TRADING = 14 , NUM_ACCOUNT_TYPES = 15 , CHECKING = 15 , SAVINGS = 16 ,
  MONEYMRKT = 17 , CREDITLINE = 18 , LAST
}
 Account Type. More...
 

Functions

auto rootAccount () -> Item::Ptr
 Load Root Account.
 
auto load (const std::string &_guid) -> Item::Ptr
 Load Account by GUID.
 
auto byGuid (const std::string &_guid) -> Item::Ptr
 Load Account by GUID.
 
auto byChildName (const std::string &_parentGuid, const std::string &_childName) -> Item::Ptr
 Load Account by 'child name' and 'parent id'.
 
auto byFullName (const std::string &_fullName) -> Item::Ptr
 Load Account by 'full name' with ':' account separator.
 
auto byFullName (const Wt::WString &_fullName) -> Item::Ptr
 
auto allAccounts () -> Item::Vector
 Load all accounts.
 
auto activeAccounts () -> Item::Vector
 Load accounts as; if( !hidden() && !placeHolder() )
 
auto fullName (const std::string &_guid) -> std::string
 Account Fullname via GUID.
 
auto fullName (Item::Ptr _item) -> std::string
 Account Fullname via Item.
 
auto isType (const Item::Ptr _acctItem, GCW::Dbo::Accounts::Type _type) -> bool
 Is Account Type.
 
auto isType (const std::string &_guid, GCW::Dbo::Accounts::Type _type) -> bool
 

Variables

const char * s_tableName = "accounts"
 
const std::vector< AccountDef_ts_accountDefs
 

Typedef Documentation

◆ AccountDef_t

Account Definition.

This structure provides a set of account-definitions that are used in the various views and balance calculations.

Enumeration Type Documentation

◆ DrCr

enum class GCW::Dbo::Accounts::DrCr
strong

Account Debit/Credit Enum.

This indicates if this account is a 'debit' type account or a 'credit' type account.

See also
GCW::Dbo::Accounts::Item
Enumerator
NONE 

0x00 ~ invalid - should not happen

DEBIT 

0x01 ~ DEBIT type account

CREDIT 

0x02 ~ CREDIT type account

Definition at line 23 of file Accounts/Definition.h.

◆ Type

enum class GCW::Dbo::Accounts::Type
strong

Account Type.

These are used internally to switch the views depending on the account type. While these codes exactly match the codes in the native gnucash proper, they should not be relied on to match the native gnucash account type codes (those are textual, see; GCW::Dbo::Accounts::Item::accountTypeName). But, these are internal anyhow, and they don't get stored. They're just used to steer the application, especially as it pertains to debit/credit calculations.

The definition-table can be found here: s_accountDefs

Note
gnucash source reference: ..src/libgnucash/engine/Account.h
Enumerator
INVALID 

-1 ~ not a type

NONE 

-1 ~ not a type

BANK 

00 ~ bank institutionally held monies, can be interest bearing

CASH 

01 ~ pure cash (shoebox)

CREDIT 

03 ~ AMEX / VISA / DISCOVER type of credit cards

ASSET 

02 ~ generic generalized asset account

LIABILITY 

04 ~ generic generalized liability account

STOCK 

05 ~ stock account show as three-column registers: price, # shares, value

MUTUAL 

06 ~ similar to stock, shows: price, # shares, value

CURRENCY 

07 ~ currency trading account (DEPRECATED)

INCOME 

08 ~ income tracking account

EXPENSE 

09 ~ expense tracking account

EQUITY 

10 ~ used to balance the balance sheet

RECEIVABLE 

11 ~ A/R receivable account

PAYABLE 

12 ~ A/R payable account

ROOT 

13 ~ hidden root account for the account tree

TRADING 

14 ~ used to record multiple commodify transactions

NUM_ACCOUNT_TYPES 

15 ~ end of account types

CHECKING 

15 ~ do not use

SAVINGS 

16 ~ do not use

MONEYMRKT 

17 ~ do not use

CREDITLINE 

18 ~ do not use

LAST 

end of list

Definition at line 50 of file Accounts/Definition.h.

Function Documentation

◆ activeAccounts()

auto GCW::Dbo::Accounts::activeAccounts ( ) -> Item::Vector

Load accounts as; if( !hidden() && !placeHolder() )

Definition at line 253 of file Dbo/Accounts/Accounts.cpp.

References GCW::app().

◆ allAccounts()

auto GCW::Dbo::Accounts::allAccounts ( ) -> Item::Vector

Load all accounts.

Definition at line 233 of file Dbo/Accounts/Accounts.cpp.

References GCW::app().

Referenced by GCW::Eng::AccountComboModel::AccountComboModel().

◆ byChildName()

auto GCW::Dbo::Accounts::byChildName ( const std::string &  _parentGuid,
const std::string &  _childName 
) -> Item::Ptr

Load Account by 'child name' and 'parent id'.

Definition at line 179 of file Dbo/Accounts/Accounts.cpp.

References GCW::app().

Referenced by byFullName().

◆ byFullName() [1/2]

auto GCW::Dbo::Accounts::byFullName ( const std::string &  _fullName) -> Item::Ptr

Load Account by 'full name' with ':' account separator.

Definition at line 197 of file Dbo/Accounts/Accounts.cpp.

References GCW::app(), byChildName(), rootAccount(), split(), and GCW::Core::split().

Referenced by byFullName(), GCW::Gui::AccountRegister::Model::getTransferGuid(), and GCW::Gui::BillPay::PaymentWidget::saveData().

◆ byFullName() [2/2]

auto GCW::Dbo::Accounts::byFullName ( const Wt::WString _fullName) -> Item::Ptr

Definition at line 226 of file Dbo/Accounts/Accounts.cpp.

References byFullName().

◆ byGuid()

auto GCW::Dbo::Accounts::byGuid ( const std::string &  _guid) -> Item::Ptr

◆ fullName() [1/2]

auto GCW::Dbo::Accounts::fullName ( const std::string &  _accountGuid) -> std::string

Account Fullname via GUID.

Compute Account Full-Name from Heirarchy.

This function will calculate the "full account name" from the accountGuid up to the root parent.

If the provided account guid is blank, then just return an empty string.

During the building process, even though the "root account" is a valid account, it is ignored and not included in the results.

Recursively, this should generate a name such as; "Assets:2023:Cash:FGB:OLB:2300-LSI"

Definition at line 298 of file Dbo/Accounts/Accounts.cpp.

References byGuid(), fullName(), and rootAccount().

Referenced by GCW::Eng::AccountComboModel::AccountComboModel(), GCW::Gui::BillPay::Item::accountFullName(), GCW::Eng::Transaction::Manager::createAccount(), GCW::Dbo::Accounts::Item::fullName(), fullName(), fullName(), GCW::Gui::BillPay::EditWidget::loadData(), GCW::Gui::BillPay::PaymentWidget::loadData(), and GCW::Gui::BillPay::TableModel::loadData().

◆ fullName() [2/2]

auto GCW::Dbo::Accounts::fullName ( Item::Ptr  _item) -> std::string

Account Fullname via Item.

Definition at line 361 of file Dbo/Accounts/Accounts.cpp.

References fullName().

◆ isType() [1/2]

auto GCW::Dbo::Accounts::isType ( const Item::Ptr  _acctItem,
GCW::Dbo::Accounts::Type  _type 
) -> bool

Is Account Type.

This returns .true. if the account is an _type account, meaning, if the acccount itself is not designated as an _type (could be BANK or CASH or something), then the parent tree is walked all the way to root and returns .true. if any of the parent accounts are an _type account.

Definition at line 370 of file Dbo/Accounts/Accounts.cpp.

References isType().

Referenced by isType(), isType(), and GCW::Gui::BillPay::SummaryWidget::setMonth().

◆ isType() [2/2]

auto GCW::Dbo::Accounts::isType ( const std::string &  _guid,
GCW::Dbo::Accounts::Type  _type 
) -> bool

Definition at line 393 of file Dbo/Accounts/Accounts.cpp.

References byGuid(), and isType().

◆ load()

auto GCW::Dbo::Accounts::load ( const std::string &  _guid) -> Item::Ptr

◆ rootAccount()

auto GCW::Dbo::Accounts::rootAccount ( ) -> Item::Ptr

Load Root Account.

Definition at line 125 of file Dbo/Accounts/Accounts.cpp.

Referenced by byFullName(), fullName(), and GCW::Eng::AccountsTreeViewModel::load().

Variable Documentation

◆ s_accountDefs

const std::vector< GCW::Dbo::Accounts::AccountDef_t > GCW::Dbo::Accounts::s_accountDefs
extern
Initial value:
=
{
{ Type::INVALID , DrCr::NONE , "INVALID" , "account" , "fundsin" , "fundsout" , },
{ Type::NONE , DrCr::NONE , "NONE" , "account" , "fundsin" , "fundsout" , },
{ Type::ROOT , DrCr::NONE , "ROOT" , "account" , "debit" , "credit" , },
{ Type::BANK , DrCr::DEBIT , "BANK" , "transfer" , "deposit" , "withdrawal" , Type::ASSET },
{ Type::CASH , DrCr::DEBIT , "CASH" , "transfer" , "receive" , "spend" , Type::ASSET },
{ Type::CREDIT , DrCr::CREDIT , "CREDIT" , "blank" , "payment" , "charge" , Type::LIABILITY },
{ Type::ASSET , DrCr::DEBIT , "ASSET" , "transfer" , "increase" , "decrease" , Type::ASSET },
{ Type::LIABILITY , DrCr::CREDIT , "LIABILITY" , "account" , "decrease" , "increase" , Type::LIABILITY },
{ Type::STOCK , DrCr::DEBIT , "STOCK" , "account" , "buy" , "sell" , Type::ASSET },
{ Type::MUTUAL , DrCr::DEBIT , "MUTUAL" , "account" , "buy" , "sell" , Type::ASSET },
{ Type::CURRENCY , DrCr::DEBIT , "CURRENCY" , "account" , "buy" , "sell" , Type::ASSET },
{ Type::INCOME , DrCr::CREDIT , "INCOME" , "account" , "charge" , "income" , Type::INCOME },
{ Type::EXPENSE , DrCr::DEBIT , "EXPENSE" , "transfer" , "expense" , "rebate" , Type::EXPENSE },
{ Type::EQUITY , DrCr::CREDIT , "EQUITY" , "transfer" , "decrease" , "increase" , Type::EQUITY },
{ Type::RECEIVABLE , DrCr::DEBIT , "RECEIVABLE" , "transfer" , "invoice" , "payment" , Type::ASSET },
{ Type::PAYABLE , DrCr::CREDIT , "PAYABLE" , "account" , "payment" , "bill" , Type::LIABILITY },
{ Type::TRADING , DrCr::DEBIT , "TRADING" , "account" , "decrease" , "increase" , Type::ASSET },
{ Type::CHECKING , DrCr::DEBIT , "CHECKING" , "account" , "debit" , "credit" , Type::ASSET },
{ Type::SAVINGS , DrCr::DEBIT , "SAVINGS" , "account" , "debit" , "credit" , Type::ASSET },
{ Type::MONEYMRKT , DrCr::DEBIT , "MONEYMRKT" , "account" , "debit" , "credit" , Type::ASSET },
{ Type::CREDITLINE , DrCr::CREDIT , "CREDITLINE" , "account" , "decrease" , "increase" , Type::LIABILITY },
}
; type drcr name colAccount colDr colCr parentType

These are the account-types, debit/credit types, and register column labels for said accounts.

See also
refreshFromDisk()
Account Type Labels

Definition at line 20 of file Dbo/Accounts/Accounts.cpp.

Referenced by GCW::Dbo::Accounts::Item::accountDef(), GCW::Dbo::Accounts::Item::accountDrCr(), GCW::Dbo::Accounts::Item::accountType(), AccountTypeCombo::AccountTypeCombo(), and GCW::Gui::AccountRegister::Model::refreshFromDisk().

◆ s_tableName

const char * GCW::Dbo::Accounts::s_tableName = "accounts"
extern

Definition at line 7 of file Dbo/Accounts/Accounts.cpp.