GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
|
#include <TransactionManager.h>
Public Types | |
using | RowItem = std::vector< std::unique_ptr< Wt::WStandardItem > > |
using | TxItem = GCW::Dbo::Transactions::Item::Ptr |
using | SpItem = GCW::Dbo::Splits::Item::Ptr |
Public Member Functions | |
Manager () | |
Manager (Gui::AccountRegister::Model *_model) | |
auto | model () const -> Gui::AccountRegister::Model * |
auto | loadTransaction (const std::string &_transactionGuid) -> void |
Set Transaction. | |
auto | deleteTransaction () -> void |
Delete Transaction. | |
auto | setSplitItem (GCW::Dbo::Splits::Item::Ptr _splitItem) -> void |
auto | loadSplit (const std::string &_splitGuid) -> void |
Set Split. | |
auto | sortSplits () -> void |
Sort Splits. | |
auto | isBalanced () -> bool |
Is Transaction Balanced. | |
auto | balanceValue () -> GCW_NUMERIC |
Balance Value. | |
auto | newTransaction (const std::string &_accountGuid1, const std::string &_accountGuid2) -> void |
New Transaction. | |
auto | transactionItem () const -> GCW::Dbo::Transactions::Item::Ptr |
Transaction Item. | |
auto | prefrenceItem () const -> const GCW::Dbo::Prefrences::Item & |
auto | splits () const -> GCW::Dbo::Splits::Item::Vector |
Splits Vector. | |
auto | otherSplits () const -> GCW::Dbo::Splits::Item::Vector |
auto | otherGuid () const -> std::string |
Other GUID. | |
auto | getDate () const -> Wt::WDateTime |
Set Date. | |
auto | getDateAsString () const -> Wt::WString |
auto | setDate (const Wt::WDateTime &_value) -> void |
auto | setDate (const Wt::WDate &_value) -> void |
auto | setAction (const std::string &_value) -> void |
Set Action. | |
auto | getDescription () const -> std::string |
Set Description. | |
auto | setDescription (const std::string &_value) -> void |
auto | setDescription (const Wt::WString &_value) -> void |
auto | getNum () const -> std::string |
Set Num. | |
auto | setNum (const std::string &_value) -> void |
auto | setNum (const Wt::WString &_value) -> void |
auto | setTransferGuid (const std::string &_value) -> void |
Set Transfer GUID. | |
auto | setReconcile (const std::string &_value) -> void |
auto | getValue () const -> GCW_NUMERIC |
auto | getValueAsString () const -> std::string |
auto | setValue (GCW_NUMERIC _value) -> void |
auto | setValue (const std::string &_acctGuid, GCW_NUMERIC _value) -> void |
auto | setNotes (const std::string &_acctGuid, const std::string &_value) -> void |
auto | split (const std::string &_splitGuid) const -> GCW::Dbo::Splits::Item::Ptr |
auto | forAccountSplit (const std::string &_accountGuid) const -> GCW::Dbo::Splits::Item::Ptr |
Load Split for Account. | |
auto | thisSplit () const -> GCW::Dbo::Splits::Item::Ptr |
auto | thatSplit () const -> GCW::Dbo::Splits::Item::Ptr |
auto | setReadOnly (bool _value) -> void |
auto | appendRow () -> void |
Private Member Functions | |
auto | highlightNegativeBalance (RowItem &_row) const -> void |
auto | createText (const std::string &_text) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createBlank () const -> std::unique_ptr< Wt::WStandardItem > |
auto | createEmpty () const -> std::unique_ptr< Wt::WStandardItem > |
auto | createDate (TxItem _txItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createNum (TxItem _txItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createNum (SpItem _spItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createDescription (TxItem _txItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createDescription (SpItem _spItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createAccount (SpItem _spItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createReconcile (SpItem _spItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createDebit (SpItem _spItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createCredit (SpItem _spItem) const -> std::unique_ptr< Wt::WStandardItem > |
auto | createBalance () const -> std::unique_ptr< Wt::WStandardItem > |
auto | appendBasicLedger () const -> void |
auto | appendAutosplitLedger () const -> void |
auto | appendTransactionJournal () const -> void |
auto | appendGeneralJournal () const -> void |
Private Attributes | |
Gui::AccountRegister::Model * | m_model = nullptr |
Wt::WModelIndex | m_index |
std::string | m_splitGuid |
GCW::Dbo::Transactions::Item::Ptr | m_transactionItem |
GCW::Dbo::Prefrences::Item | m_prefrenceItem |
GCW::Dbo::Splits::Item::Vector | m_splits |
This is a convenience class for grouping all the transaction manipulation tasks in to one place. It allows new transactions to be created, and takes care of insuring that the transaction is always in balance, and always contains the requisite debits and credits to insure a properly balanced transaction.
The Transaction Manager is a 'friend' class to the AccountRegisterModel. This allows the manager to poke directly in to the model and manipulate it.
Definition at line 36 of file TransactionManager.h.
using GCW::Eng::Transaction::Manager::RowItem = std::vector< std::unique_ptr< Wt::WStandardItem > > |
Definition at line 40 of file TransactionManager.h.
Definition at line 42 of file TransactionManager.h.
Definition at line 41 of file TransactionManager.h.
GCW::Eng::Transaction::Manager::Manager | ( | ) |
Definition at line 7 of file TransactionManager.cpp.
GCW::Eng::Transaction::Manager::Manager | ( | Gui::AccountRegister::Model * | _model | ) |
Definition at line 14 of file TransactionManager.cpp.
|
private |
Definition at line 777 of file TransactionManager.cpp.
|
private |
Definition at line 750 of file TransactionManager.cpp.
|
private |
Definition at line 851 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::appendRow | ( | ) | -> void |
Definition at line 859 of file TransactionManager.cpp.
References GCW::Gui::AccountRegister::AUTOSPLIT_LEDGER, GCW::Gui::AccountRegister::BASIC_LEDGER, GCW::Gui::AccountRegister::GENERAL_JOURNAL, and GCW::Gui::AccountRegister::TRANSACTION_JOURNAL.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
|
private |
Definition at line 783 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::balanceValue | ( | ) | -> GCW_NUMERIC |
Balance Value.
This checks the splits on the transaction and returns the 'balance value' which should be zero when the transaction is in balance.
see; gnucash/libgnucash/engine/Transaction.cpp:1030
|
private |
Definition at line 599 of file TransactionManager.cpp.
References Wt::WString::arg(), GCW::Dbo::Accounts::byGuid(), Wt::DeferredToolTip, GCW::Dbo::Accounts::fullName(), Wt::WString::toUTF8(), and TR.
|
private |
Definition at line 712 of file TransactionManager.cpp.
References GCW::Cfg::decimal_format(), and Wt::DeferredToolTip.
|
private |
Definition at line 367 of file TransactionManager.cpp.
|
private |
Definition at line 688 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 391 of file TransactionManager.cpp.
References Wt::DeferredToolTip, Wt::ItemDataRole::Edit, and Wt::ItemDataRole::User.
|
private |
Definition at line 667 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 473 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 459 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 379 of file TransactionManager.cpp.
|
private |
Definition at line 445 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 431 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 654 of file TransactionManager.cpp.
References Wt::DeferredToolTip.
|
private |
Definition at line 355 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::deleteTransaction | ( | ) | -> void |
Delete Transaction.
This insures all splits and any other data associated with the transaction is properly removed.
Definition at line 81 of file TransactionManager.cpp.
References GCW::app().
auto GCW::Eng::Transaction::Manager::forAccountSplit | ( | const std::string & | _accountGuid | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Load Split for Account.
When we know the account guid, this will fetch the associated split
Definition at line 168 of file TransactionManager.cpp.
References split().
auto GCW::Eng::Transaction::Manager::getDate | ( | ) | const -> Wt::WDateTime |
Set Date.
This sets the date on the Transaction of the element.
Definition at line 182 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::getDateAsString | ( | ) | const -> Wt::WString |
Definition at line 190 of file TransactionManager.cpp.
References GCW_DATE_FORMAT_DISPLAY.
auto GCW::Eng::Transaction::Manager::getDescription | ( | ) | const -> std::string |
Set Description.
This sets the description on the Transaction of the element.
Definition at line 227 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::getNum | ( | ) | const -> std::string |
Set Num.
On the Transaction, the 'num' is the action field, on the splits it is the action value. So, in transaction it's called 'num' and in the splits it's called 'action'.
Definition at line 252 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::getValue | ( | ) | const -> GCW_NUMERIC |
Definition at line 295 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::getValueAsString | ( | ) | const -> std::string |
Definition at line 303 of file TransactionManager.cpp.
|
private |
Definition at line 725 of file TransactionManager.cpp.
References GCW::Dbo::Prefrences::NEGVAL_EXTRA, and GCW::Dbo::Prefrences::NORMAL.
auto GCW::Eng::Transaction::Manager::isBalanced | ( | ) | -> bool |
Is Transaction Balanced.
This checks the transaction and indicates if it is in balance or not.
see; gnucash/libgnucash/engine/Transaction.cpp:1030
auto GCW::Eng::Transaction::Manager::loadSplit | ( | const std::string & | _splitGuid | ) | -> void |
Set Split.
Set transaction based on any one of the splits.
This will load the split, then load the transaction for that split, causing all the other splits to load.
Definition at line 104 of file TransactionManager.cpp.
References GCW::Dbo::Splits::load().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::loadTransaction | ( | const std::string & | _transactionGuid | ) | -> void |
Set Transaction.
Set transaction based on the transaction Guid. This will load the transaction as well as all the splits associated with it.
Definition at line 65 of file TransactionManager.cpp.
References GCW::Dbo::Splits::byTransaction(), and GCW::Dbo::Transactions::load().
|
inline |
Definition at line 47 of file TransactionManager.h.
References m_model.
auto GCW::Eng::Transaction::Manager::newTransaction | ( | const std::string & | _accountGuid1, |
const std::string & | _accountGuid2 | ||
) | -> void |
New Transaction.
This will create a new Transaction for an account within the system fully populated with at least two splits.
The process begins by loading up the two accounts.
Definition at line 23 of file TransactionManager.cpp.
References GCW::Dbo::Splits::add(), GCW::Dbo::Transactions::add(), GCW::app(), Wt::WDateTime::currentDateTime(), GCW_DEFAULT_DATE, GCW_RECONCILE_NO, GCW::Dbo::Accounts::load(), and GCW::Core::newGuid().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::otherGuid | ( | ) | const -> std::string |
Other GUID.
When there are only two splits, this will return the guid of the split item that does not match the guid provided.
Definition at line 128 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::otherSplits | ( | ) | const -> GCW::Dbo::Splits::Item::Vector |
Definition at line 340 of file TransactionManager.cpp.
References GCW::Dbo::Splits::bySplitExcept().
|
inline |
Definition at line 119 of file TransactionManager.h.
References m_prefrenceItem.
auto GCW::Eng::Transaction::Manager::setAction | ( | const std::string & | _value | ) | -> void |
Set Action.
This sets the Action on the split. The 'action' is stored in the Split item and this function will apply the value to both sides of the split.
Definition at line 218 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::setDate | ( | const Wt::WDate & | _value | ) | -> void |
Definition at line 207 of file TransactionManager.cpp.
References GCW::app().
auto GCW::Eng::Transaction::Manager::setDate | ( | const Wt::WDateTime & | _value | ) | -> void |
Definition at line 198 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::setDescription | ( | const std::string & | _value | ) | -> void |
Definition at line 235 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::setDescription | ( | const Wt::WString & | _value | ) | -> void |
Definition at line 244 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::setNotes | ( | const std::string & | _acctGuid, |
const std::string & | _value | ||
) | -> void |
Definition at line 330 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::setNum | ( | const std::string & | _value | ) | -> void |
Definition at line 260 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData().
auto GCW::Eng::Transaction::Manager::setNum | ( | const Wt::WString & | _value | ) | -> void |
Definition at line 269 of file TransactionManager.cpp.
auto GCW::Eng::Transaction::Manager::setReadOnly | ( | bool | _value | ) | -> void |
Definition at line 348 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
auto GCW::Eng::Transaction::Manager::setReconcile | ( | const std::string & | _value | ) | -> void |
Definition at line 286 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::setSplitItem | ( | GCW::Dbo::Splits::Item::Ptr | _splitItem | ) | -> void |
Definition at line 93 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
auto GCW::Eng::Transaction::Manager::setTransferGuid | ( | const std::string & | _value | ) | -> void |
Set Transfer GUID.
This sets the (other) split (identified by guid) to the account given.
Definition at line 277 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::setValue | ( | const std::string & | _acctGuid, |
GCW_NUMERIC | _value | ||
) | -> void |
Definition at line 321 of file TransactionManager.cpp.
References GCW::app().
auto GCW::Eng::Transaction::Manager::setValue | ( | GCW_NUMERIC | _value | ) | -> void |
Definition at line 311 of file TransactionManager.cpp.
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
auto GCW::Eng::Transaction::Manager::sortSplits | ( | ) | -> void |
Sort Splits.
Sorts first Debits, then Credits
auto GCW::Eng::Transaction::Manager::split | ( | const std::string & | _splitGuid | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 140 of file TransactionManager.cpp.
|
inline |
Splits Vector.
This returns the splits vector
Definition at line 126 of file TransactionManager.h.
References m_splits.
auto GCW::Eng::Transaction::Manager::thatSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 160 of file TransactionManager.cpp.
References split().
auto GCW::Eng::Transaction::Manager::thisSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 152 of file TransactionManager.cpp.
References split().
|
inline |
Transaction Item.
This returns the transaction pointer object
Definition at line 118 of file TransactionManager.h.
References m_transactionItem.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
|
private |
Definition at line 254 of file TransactionManager.h.
|
private |
Definition at line 253 of file TransactionManager.h.
Referenced by model().
|
private |
Definition at line 257 of file TransactionManager.h.
Referenced by prefrenceItem().
|
private |
Definition at line 255 of file TransactionManager.h.
|
private |
Definition at line 258 of file TransactionManager.h.
Referenced by splits().
|
private |
Definition at line 256 of file TransactionManager.h.
Referenced by transactionItem().