|
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 () -> bool |
| 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, const Wt::WDate &_date=Wt::WDate::currentDate(), GCW_NUMERIC _value=GCW_NUMERIC(0), const std::string &_description="") -> 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 | fromSplit () const -> GCW::Dbo::Splits::Item::Ptr |
| auto | toSplit () const -> GCW::Dbo::Splits::Item::Ptr |
| auto | getFromAccount () const -> std::string |
| auto | getToAccount () const -> std::string |
| auto | setReadOnly (bool _value) -> void |
| auto | appendRow (bool _editable) -> void |
| auto | appendEmptyRow (bool _editable) -> void |
| auto | insertDoubleLine (int _row) -> void |
Private Member Functions | |
| auto | highlightNegativeBalance (RowItem &_row) const -> void |
| auto | flags (bool _editable) const -> Wt::WFlags< Wt::ItemFlag > |
| 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 (const TxItem &_txItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createNum (const TxItem &_txItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createNum (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDescription (const TxItem &_txItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDescription (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createAccount (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createReconcile (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDebit (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createCredit (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createBalance () const -> std::unique_ptr< Wt::WStandardItem > |
| auto | appendBasicLedger (bool _editable) const -> void |
| auto | appendAutosplitLedger (bool _editable) const -> void |
| auto | appendTransactionJournal (bool _editable) const -> void |
| auto | appendGeneralJournal (bool _editable) 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 9 of file TransactionManager.cpp.
| GCW::Eng::Transaction::Manager::Manager | ( | Gui::AccountRegister::Model * | _model | ) |
Definition at line 16 of file TransactionManager.cpp.
|
private |
Definition at line 1016 of file TransactionManager.cpp.
|
private |
Definition at line 985 of file TransactionManager.cpp.
References GCW_RECONCILE_NO.
| auto GCW::Eng::Transaction::Manager::appendEmptyRow | ( | bool | _editable | ) | -> void |
Definition at line 1146 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
|
private |
Definition at line 1076 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::appendRow | ( | bool | _editable | ) | -> void |
Definition at line 1084 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 1022 of file TransactionManager.cpp.
References GCW_RECONCILE_NO.
| 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 816 of file TransactionManager.cpp.
References Wt::WString::arg(), GCW::Dbo::Accounts::byGuid(), GCW::Dbo::Accounts::fullName(), Wt::WString::toUTF8(), and TR.
|
private |
Definition at line 943 of file TransactionManager.cpp.
References GCW::Cfg::decimal_format().
|
private |
Definition at line 508 of file TransactionManager.cpp.
|
private |
Definition at line 917 of file TransactionManager.cpp.
|
private |
Definition at line 534 of file TransactionManager.cpp.
References Wt::WDate::currentDate(), Wt::ItemDataRole::Edit, GCW_DATE_DEFAULT_TIME, and Wt::ItemDataRole::User.
|
private |
Definition at line 894 of file TransactionManager.cpp.
|
private |
Definition at line 686 of file TransactionManager.cpp.
|
private |
Definition at line 636 of file TransactionManager.cpp.
|
private |
Definition at line 521 of file TransactionManager.cpp.
|
private |
Definition at line 615 of file TransactionManager.cpp.
|
private |
Definition at line 594 of file TransactionManager.cpp.
|
private |
Definition at line 877 of file TransactionManager.cpp.
|
private |
Definition at line 495 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::deleteTransaction | ( | ) | -> bool |
Delete Transaction.
This insures all splits and any other data associated with the transaction is properly removed.
Definition at line 114 of file TransactionManager.cpp.
References GCW::app().
|
private |
Definition at line 480 of file TransactionManager.cpp.
References Wt::DeferredToolTip, Wt::Editable, and Wt::Selectable.
| 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 293 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::fromSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 203 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 307 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getDateAsString | ( | ) | const -> Wt::WString |
Definition at line 315 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 352 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getFromAccount | ( | ) | const -> std::string |
Definition at line 254 of file TransactionManager.cpp.
References Wt::WString::arg(), GCW::Dbo::Accounts::fullName(), Wt::WString::toUTF8(), and TR8.
| 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 377 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getToAccount | ( | ) | const -> std::string |
Definition at line 273 of file TransactionManager.cpp.
References Wt::WString::arg(), GCW::Dbo::Accounts::fullName(), Wt::WString::toUTF8(), and TR8.
| auto GCW::Eng::Transaction::Manager::getValue | ( | ) | const -> GCW_NUMERIC |
Definition at line 420 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getValueAsString | ( | ) | const -> std::string |
Definition at line 428 of file TransactionManager.cpp.
|
private |
Definition at line 960 of file TransactionManager.cpp.
References GCW::Dbo::Prefrences::NEGVAL_EXTRA, and GCW::Dbo::Prefrences::NORMAL.
| auto GCW::Eng::Transaction::Manager::insertDoubleLine | ( | int | _row | ) | -> void |
Definition at line 1158 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::applyDoubleLine().
| 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 139 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 98 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, | ||
| const Wt::WDate & | _date = Wt::WDate::currentDate(), |
||
| GCW_NUMERIC | _value = GCW_NUMERIC(0), |
||
| const std::string & | _description = "" |
||
| ) | -> 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.
this transaction posting shows that .value. as well as .quantity. are set at the same time. If .quantity. is not set, then when re-opening the sql file in gnucash native causes the gnucash to take a very long time to load. This only happens once, and upon examining the database afterwords, all the splits have the same .value. set to .quantity. So, some sort of massive update is happening there on file-open. Therefore, we will set .quantity. along with .value. Doing so seems to mitigate the long/slow load time.
Definition at line 25 of file TransactionManager.cpp.
References GCW::Dbo::Splits::add(), GCW::Dbo::Transactions::add(), GCW::app(), Wt::WDate::currentDate(), GCW::Dbo::Accounts::fullName(), 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 163 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::otherSplits | ( | ) | const -> GCW::Dbo::Splits::Item::Vector |
Definition at line 465 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 343 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 332 of file TransactionManager.cpp.
References GCW::app().
| auto GCW::Eng::Transaction::Manager::setDate | ( | const Wt::WDateTime & | _value | ) | -> void |
Definition at line 323 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setDescription | ( | const std::string & | _value | ) | -> void |
Definition at line 360 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setDescription | ( | const Wt::WString & | _value | ) | -> void |
Definition at line 369 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::setNotes | ( | const std::string & | _acctGuid, |
| const std::string & | _value | ||
| ) | -> void |
Definition at line 455 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 385 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 394 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::setReadOnly | ( | bool | _value | ) | -> void |
Definition at line 473 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::setReconcile | ( | const std::string & | _value | ) | -> void |
Definition at line 411 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 128 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 402 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 446 of file TransactionManager.cpp.
References GCW::app().
| auto GCW::Eng::Transaction::Manager::setValue | ( | GCW_NUMERIC | _value | ) | -> void |
Definition at line 436 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::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 175 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 195 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::thisSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 187 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::toSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 217 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 264 of file TransactionManager.h.
|
private |
Definition at line 263 of file TransactionManager.h.
Referenced by model().
|
private |
Definition at line 267 of file TransactionManager.h.
Referenced by prefrenceItem().
|
private |
Definition at line 265 of file TransactionManager.h.
|
private |
Definition at line 268 of file TransactionManager.h.
Referenced by splits().
|
private |
Definition at line 266 of file TransactionManager.h.
Referenced by transactionItem().