Items for FdModelCoa. More...
#include <FdItemCoa.hpp>
Public Member Functions | |
FdItemCoa (FdItemCoa_p parent=FdItemCoa_p(0), QString id="", QString label="", AccountSignature signature=PlusMinus, double initial=0, double balance=0, double previous=0) | |
CoaItemType | type () const |
QString | id () const |
QString | label () const |
bool | onBalanceSheet () const |
AccountSignature | signature () const |
double | initialBalance () const |
double | balance () const |
double | previousBalance () const |
void | setId (QString id) |
void | setLabel (QString label) |
void | setOnBalanceSheet (bool var) |
void | setSignature (AccountSignature signature) |
void | setInitialBalance (double initial) |
void | setPreviousBalance (double previous) |
bool | wasUsed () const |
QString | displayLabel () const |
FdItemCoa_p | parent () |
void | setParent (FdItemCoa_p parent) |
FdItemCoa_p | child (int row) |
QList< FdItemCoa_p > | children () |
QList< FdItemCoa_p > | findChildren (QString text) |
int | childRow (const FdItemCoa *child) const |
int | childrenCount () const |
int | row () const |
void | appendChild (FdItemCoa_p item) |
bool | insertChild (FdItemCoa_p item, int row) |
bool | removeChild (int row) |
QStringList | childrenAccountsIds () const |
QStringList | childrenAccountsLabels () const |
QList< FdItemCoa_p > | childrenAccounts () const |
FdItemCoa_p | childById (QString id) const |
FdItemCoa_p | childByLabel (QString label) const |
void | resetBalance () |
void | computeBalances () |
void | debited (double amount) |
void | credited (double amount) |
QDomElement | toXml (QDomDocument &document) const |
Static Public Member Functions | |
static FdItemCoa_p | pointer (QDomElement item, FdItemCoa_p parent=FdItemCoa_p(0)) |
static FdItemCoa_p | pointer (FdItemCoa_p model, FdItemCoa_p parent=FdItemCoa_p(0)) |
Private Attributes | |
QString | mId |
QString | mLabel |
AccountSignature | mSignature |
bool | mOnBalanceSheet |
double | mInitialBalance |
double | mBalance |
double | mPreviousBalance |
FdItemCoa_p | mParent |
QList< FdItemCoa_p > | mChildren |
Items for FdModelCoa.
An item is a line in the char of accounts (a tree) and a field is a column, which are :
Those fields can be completed by the user (see FdModelCoa::setData()).
Further more, an item has a type (to make the difference between categories and accounts), which can be retrieved calling type() (see #CoaItemType).
Definition at line 43 of file FdItemCoa.hpp.
FdItemCoa::FdItemCoa | ( | FdItemCoa_p | parent = FdItemCoa_p(0) , |
QString | id = "" , |
||
QString | label = "" , |
||
AccountSignature | signature = PlusMinus , |
||
double | initial = 0 , |
||
double | balance = 0 , |
||
double | previous = 0 |
||
) |
Definition at line 22 of file FdItemCoa.cpp.
void FdItemCoa::appendChild | ( | FdItemCoa_p | item | ) |
Inserts a child at the end of children list.
Definition at line 282 of file FdItemCoa.cpp.
double FdItemCoa::balance | ( | ) | const |
Definition at line 145 of file FdItemCoa.cpp.
FdItemCoa_p FdItemCoa::child | ( | int | row | ) |
Returns the child item positionned at row.
Definition at line 220 of file FdItemCoa.cpp.
FdItemCoa_p FdItemCoa::childById | ( | QString | id | ) | const |
Search recursively in children items the child with id id.
Returns a #FdItemCoa_p, which is invalid if id does not exist. Therefore, the validity of the pointer returned by this function should always be tested calling QSharedPointer::isNull().
Definition at line 361 of file FdItemCoa.cpp.
FdItemCoa_p FdItemCoa::childByLabel | ( | QString | label | ) | const |
Search recursively in children items the child with label label.
Returns a #FdItemCoa_p, which is invalid if label does not exist. Therefore, the validity of the pointer returned by this function should always be tested calling QSharedPointer::isNull().
Definition at line 385 of file FdItemCoa.cpp.
QList< FdItemCoa_p > FdItemCoa::children | ( | ) |
Returns all the children of the item.
Definition at line 228 of file FdItemCoa.cpp.
QList< FdItemCoa_p > FdItemCoa::childrenAccounts | ( | ) | const |
Definition at line 343 of file FdItemCoa.cpp.
QStringList FdItemCoa::childrenAccountsIds | ( | ) | const |
Returns a list of all children accounts ids (recursive down to the bottom of the tree)
Definition at line 314 of file FdItemCoa.cpp.
QStringList FdItemCoa::childrenAccountsLabels | ( | ) | const |
Returns a list of all children accounts labels (recursive down to the bottom of the tree)
Definition at line 330 of file FdItemCoa.cpp.
int FdItemCoa::childrenCount | ( | ) | const |
Returns the number of children of the item.
Definition at line 266 of file FdItemCoa.cpp.
int FdItemCoa::childRow | ( | const FdItemCoa * | child | ) | const |
Returns the row the item child is positionned at in the children list (see also mChildren).
Definition at line 252 of file FdItemCoa.cpp.
void FdItemCoa::computeBalances | ( | ) |
Computes balance from children. This function calls itself recursively down the tree.
Definition at line 419 of file FdItemCoa.cpp.
void FdItemCoa::credited | ( | double | amount | ) |
Credits the account by amount.
Definition at line 459 of file FdItemCoa.cpp.
void FdItemCoa::debited | ( | double | amount | ) |
Debits the account by amount.
Definition at line 451 of file FdItemCoa.cpp.
QString FdItemCoa::displayLabel | ( | ) | const |
Returns its own label under the form id+label.
Definition at line 202 of file FdItemCoa.cpp.
QList< FdItemCoa_p > FdItemCoa::findChildren | ( | QString | text | ) |
Returns children containing text in either the id or label field.
Definition at line 236 of file FdItemCoa.cpp.
QString FdItemCoa::id | ( | ) | const |
Access function to read mId.
Definition at line 120 of file FdItemCoa.cpp.
double FdItemCoa::initialBalance | ( | ) | const |
Definition at line 140 of file FdItemCoa.cpp.
bool FdItemCoa::insertChild | ( | FdItemCoa_p | item, |
int | row | ||
) |
Inserts a child at position row in the children list.
Definition at line 290 of file FdItemCoa.cpp.
QString FdItemCoa::label | ( | ) | const |
Definition at line 125 of file FdItemCoa.cpp.
bool FdItemCoa::onBalanceSheet | ( | ) | const |
Definition at line 130 of file FdItemCoa.cpp.
FdItemCoa_p FdItemCoa::parent | ( | ) |
Definition at line 207 of file FdItemCoa.cpp.
|
static |
Creates a new item with the given parent, from the xml source. This function is recursive, it will call itself on child items.
Definition at line 46 of file FdItemCoa.cpp.
|
static |
Copy function to create a new item with the given parent, based on model.
Warning : this is not an exact copy. This function is used while creating a new year. Hence, initial of the new item balance is set to 0 and previous balance of model becomes previous balance field.
Definition at line 82 of file FdItemCoa.cpp.
double FdItemCoa::previousBalance | ( | ) | const |
Definition at line 150 of file FdItemCoa.cpp.
bool FdItemCoa::removeChild | ( | int | row | ) |
Removes the child at position row.
Definition at line 302 of file FdItemCoa.cpp.
void FdItemCoa::resetBalance | ( | ) |
This function set the balance to its initial value and calls itself on all children.
Definition at line 407 of file FdItemCoa.cpp.
int FdItemCoa::row | ( | ) | const |
Definition at line 271 of file FdItemCoa.cpp.
void FdItemCoa::setId | ( | QString | id | ) |
Definition at line 155 of file FdItemCoa.cpp.
void FdItemCoa::setInitialBalance | ( | double | initial | ) |
Definition at line 177 of file FdItemCoa.cpp.
void FdItemCoa::setLabel | ( | QString | label | ) |
Definition at line 160 of file FdItemCoa.cpp.
void FdItemCoa::setOnBalanceSheet | ( | bool | var | ) |
Definition at line 165 of file FdItemCoa.cpp.
void FdItemCoa::setParent | ( | FdItemCoa_p | parent | ) |
Definition at line 212 of file FdItemCoa.cpp.
void FdItemCoa::setPreviousBalance | ( | double | previous | ) |
Definition at line 182 of file FdItemCoa.cpp.
void FdItemCoa::setSignature | ( | AccountSignature | signature | ) |
Definition at line 172 of file FdItemCoa.cpp.
AccountSignature FdItemCoa::signature | ( | ) | const |
Definition at line 135 of file FdItemCoa.cpp.
QDomElement FdItemCoa::toXml | ( | QDomDocument & | document | ) | const |
Definition at line 464 of file FdItemCoa.cpp.
CoaItemType FdItemCoa::type | ( | ) | const |
Returns the type of the item, see #CoaItemType.
Definition at line 107 of file FdItemCoa.cpp.
bool FdItemCoa::wasUsed | ( | ) | const |
Returns true if the account was used during the previous accounting period. In other words, it returns true if either mInitialBalance or mPreviousBalance is non-zero
Definition at line 191 of file FdItemCoa.cpp.
|
private |
New balance of the item, after it has/its children items have been used in entries.
Access functions :
Definition at line 96 of file FdItemCoa.hpp.
|
private |
Children of a category item (if the item is of type #AccountType, this list must be empty). This list is ordered, ie the order of items in it defines the order of appearance in the item in the view.
The number of children is given by childrenCount().
Access functions :
Definition at line 124 of file FdItemCoa.hpp.
|
private |
Unique user defined identifier of the item. Accounts ids will be used in the journal to call accounts in entries.
Access functions :
Definition at line 53 of file FdItemCoa.hpp.
|
private |
Initial balance of the item. It can only be set for account and is computed automatically for categories.
Access functions :
Definition at line 85 of file FdItemCoa.hpp.
|
private |
Unique user defined label of the item. As mId, the label may be used to call an account in the journal.
Access functions :
Definition at line 61 of file FdItemCoa.hpp.
|
private |
Whether or not the item appears on balance sheet. This is particularly useful to create a new accounting year.
Access functions :
Definition at line 77 of file FdItemCoa.hpp.
|
private |
Parent category (items of type #AccountType can't have children) of the item.
Access function :
Definition at line 112 of file FdItemCoa.hpp.
|
private |
Previous year balance of the item, which can be non zera only for an account.
Access functions :
Definition at line 104 of file FdItemCoa.hpp.
|
private |
Signs of the item, see #AccountSignature.
Access functions :
Definition at line 69 of file FdItemCoa.hpp.