GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
GCW::Eng::Transaction::Manager Class Reference

Transaction Manager. More...

#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::Modelm_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
 

Detailed Description

Transaction Manager.

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.

Member Typedef Documentation

◆ RowItem

using GCW::Eng::Transaction::Manager::RowItem = std::vector< std::unique_ptr< Wt::WStandardItem > >

Definition at line 40 of file TransactionManager.h.

◆ SpItem

Definition at line 42 of file TransactionManager.h.

◆ TxItem

Definition at line 41 of file TransactionManager.h.

Constructor & Destructor Documentation

◆ Manager() [1/2]

GCW::Eng::Transaction::Manager::Manager ( )

Definition at line 7 of file TransactionManager.cpp.

◆ Manager() [2/2]

GCW::Eng::Transaction::Manager::Manager ( Gui::AccountRegister::Model _model)

Definition at line 14 of file TransactionManager.cpp.

Member Function Documentation

◆ appendAutosplitLedger()

auto GCW::Eng::Transaction::Manager::appendAutosplitLedger ( ) const -> void
private

Definition at line 777 of file TransactionManager.cpp.

◆ appendBasicLedger()

auto GCW::Eng::Transaction::Manager::appendBasicLedger ( ) const -> void
private

Definition at line 750 of file TransactionManager.cpp.

◆ appendGeneralJournal()

auto GCW::Eng::Transaction::Manager::appendGeneralJournal ( ) const -> void
private

Definition at line 851 of file TransactionManager.cpp.

◆ appendRow()

auto GCW::Eng::Transaction::Manager::appendRow ( ) -> void

◆ appendTransactionJournal()

auto GCW::Eng::Transaction::Manager::appendTransactionJournal ( ) const -> void
private

Definition at line 783 of file TransactionManager.cpp.

◆ balanceValue()

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

◆ createAccount()

auto GCW::Eng::Transaction::Manager::createAccount ( SpItem  _spItem) const -> std::unique_ptr< Wt::WStandardItem >
private
Another Imbalance
This is another problem... We have another split, but the account we are split-to doesn't exist. This is a problem and should not happen and represents an error in the database. This means the account containing this guid nolonger exists. That should never happen.

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.

◆ createBalance()

auto GCW::Eng::Transaction::Manager::createBalance ( ) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 712 of file TransactionManager.cpp.

References GCW::Cfg::decimal_format(), and Wt::DeferredToolTip.

◆ createBlank()

auto GCW::Eng::Transaction::Manager::createBlank ( ) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 367 of file TransactionManager.cpp.

◆ createCredit()

auto GCW::Eng::Transaction::Manager::createCredit ( SpItem  _spItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 688 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createDate()

auto GCW::Eng::Transaction::Manager::createDate ( TxItem  _txItem) const -> std::unique_ptr< Wt::WStandardItem >
private
Note
The post_date column (col-0) also carries with it the guid of the split item itself, so that the originating split can be located from the table view. The guid can be accessed by;
Wt::WString splitRowGuid = Wt::asString( standardItem.data( Wt::ItemDataRole::User ) )
static constexpr const int User
WString asString(const cpp17::any &v, const WString &formatString=WString())
See also
getSplitGuid

Definition at line 391 of file TransactionManager.cpp.

References Wt::DeferredToolTip, Wt::ItemDataRole::Edit, and Wt::ItemDataRole::User.

◆ createDebit()

auto GCW::Eng::Transaction::Manager::createDebit ( SpItem  _spItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 667 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createDescription() [1/2]

auto GCW::Eng::Transaction::Manager::createDescription ( SpItem  _spItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 473 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createDescription() [2/2]

auto GCW::Eng::Transaction::Manager::createDescription ( TxItem  _txItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 459 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createEmpty()

auto GCW::Eng::Transaction::Manager::createEmpty ( ) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 379 of file TransactionManager.cpp.

◆ createNum() [1/2]

auto GCW::Eng::Transaction::Manager::createNum ( SpItem  _spItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 445 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createNum() [2/2]

auto GCW::Eng::Transaction::Manager::createNum ( TxItem  _txItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 431 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createReconcile()

auto GCW::Eng::Transaction::Manager::createReconcile ( SpItem  _spItem) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 654 of file TransactionManager.cpp.

References Wt::DeferredToolTip.

◆ createText()

auto GCW::Eng::Transaction::Manager::createText ( const std::string &  _text) const -> std::unique_ptr< Wt::WStandardItem >
private

Definition at line 355 of file TransactionManager.cpp.

◆ deleteTransaction()

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().

◆ forAccountSplit()

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

Note
this assumes an account only has a single split

Definition at line 168 of file TransactionManager.cpp.

References split().

◆ getDate()

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.

◆ getDateAsString()

auto GCW::Eng::Transaction::Manager::getDateAsString ( ) const -> Wt::WString

Definition at line 190 of file TransactionManager.cpp.

References GCW_DATE_FORMAT_DISPLAY.

◆ getDescription()

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.

◆ getNum()

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.

◆ getValue()

auto GCW::Eng::Transaction::Manager::getValue ( ) const -> GCW_NUMERIC

Definition at line 295 of file TransactionManager.cpp.

◆ getValueAsString()

auto GCW::Eng::Transaction::Manager::getValueAsString ( ) const -> std::string

Definition at line 303 of file TransactionManager.cpp.

◆ highlightNegativeBalance()

auto GCW::Eng::Transaction::Manager::highlightNegativeBalance ( RowItem _row) const -> void
private

◆ isBalanced()

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

◆ loadSplit()

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().

◆ loadTransaction()

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().

◆ model()

auto GCW::Eng::Transaction::Manager::model ( ) const -> Gui::AccountRegister::Model *
inline

Definition at line 47 of file TransactionManager.h.

References m_model.

◆ newTransaction()

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().

◆ otherGuid()

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.

◆ otherSplits()

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().

◆ prefrenceItem()

auto GCW::Eng::Transaction::Manager::prefrenceItem ( ) const -> const GCW::Dbo::Prefrences::Item &
inline

Definition at line 119 of file TransactionManager.h.

References m_prefrenceItem.

◆ setAction()

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().

◆ setDate() [1/2]

auto GCW::Eng::Transaction::Manager::setDate ( const Wt::WDate _value) -> void

Definition at line 207 of file TransactionManager.cpp.

References GCW::app().

◆ setDate() [2/2]

auto GCW::Eng::Transaction::Manager::setDate ( const Wt::WDateTime _value) -> void

◆ setDescription() [1/2]

auto GCW::Eng::Transaction::Manager::setDescription ( const std::string &  _value) -> void

◆ setDescription() [2/2]

auto GCW::Eng::Transaction::Manager::setDescription ( const Wt::WString _value) -> void

Definition at line 244 of file TransactionManager.cpp.

◆ setNotes()

auto GCW::Eng::Transaction::Manager::setNotes ( const std::string &  _acctGuid,
const std::string &  _value 
) -> void

◆ setNum() [1/2]

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().

◆ setNum() [2/2]

auto GCW::Eng::Transaction::Manager::setNum ( const Wt::WString _value) -> void

Definition at line 269 of file TransactionManager.cpp.

◆ setReadOnly()

auto GCW::Eng::Transaction::Manager::setReadOnly ( bool  _value) -> void

◆ setReconcile()

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().

◆ setSplitItem()

auto GCW::Eng::Transaction::Manager::setSplitItem ( GCW::Dbo::Splits::Item::Ptr  _splitItem) -> void

◆ setTransferGuid()

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().

◆ setValue() [1/2]

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().

◆ setValue() [2/2]

auto GCW::Eng::Transaction::Manager::setValue ( GCW_NUMERIC  _value) -> void

◆ sortSplits()

auto GCW::Eng::Transaction::Manager::sortSplits ( ) -> void

Sort Splits.

Sorts first Debits, then Credits

◆ split()

auto GCW::Eng::Transaction::Manager::split ( const std::string &  _splitGuid) const -> GCW::Dbo::Splits::Item::Ptr

Definition at line 140 of file TransactionManager.cpp.

◆ splits()

auto GCW::Eng::Transaction::Manager::splits ( ) const -> GCW::Dbo::Splits::Item::Vector
inline

Splits Vector.

This returns the splits vector

Definition at line 126 of file TransactionManager.h.

References m_splits.

◆ thatSplit()

auto GCW::Eng::Transaction::Manager::thatSplit ( ) const -> GCW::Dbo::Splits::Item::Ptr

Definition at line 160 of file TransactionManager.cpp.

References split().

◆ thisSplit()

auto GCW::Eng::Transaction::Manager::thisSplit ( ) const -> GCW::Dbo::Splits::Item::Ptr

Definition at line 152 of file TransactionManager.cpp.

References split().

◆ transactionItem()

auto GCW::Eng::Transaction::Manager::transactionItem ( ) const -> GCW::Dbo::Transactions::Item::Ptr
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().

Member Data Documentation

◆ m_index

Wt::WModelIndex GCW::Eng::Transaction::Manager::m_index
private

Definition at line 254 of file TransactionManager.h.

◆ m_model

Gui::AccountRegister::Model* GCW::Eng::Transaction::Manager::m_model = nullptr
private

Definition at line 253 of file TransactionManager.h.

Referenced by model().

◆ m_prefrenceItem

GCW::Dbo::Prefrences::Item GCW::Eng::Transaction::Manager::m_prefrenceItem
private

Definition at line 257 of file TransactionManager.h.

Referenced by prefrenceItem().

◆ m_splitGuid

std::string GCW::Eng::Transaction::Manager::m_splitGuid
private

Definition at line 255 of file TransactionManager.h.

◆ m_splits

GCW::Dbo::Splits::Item::Vector GCW::Eng::Transaction::Manager::m_splits
private

Definition at line 258 of file TransactionManager.h.

Referenced by splits().

◆ m_transactionItem

GCW::Dbo::Transactions::Item::Ptr GCW::Eng::Transaction::Manager::m_transactionItem
private

Definition at line 256 of file TransactionManager.h.

Referenced by transactionItem().


The documentation for this class was generated from the following files: