DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::accounting::Account Class Reference

An entry location in the general ledger for similar kinds of transaction identified by a code. More...

#include <Account.h>

Collaboration diagram for drn::accounting::Account:

Public Member Functions

 Account ()
 Default constructs everything to their empty state.
 
 Account (const AccountTypes type, AccountCode code, const pecunia::Currency &currency)
 Simple constructor to establish the type of the account.
 
 Account (const AccountTypes type, AccountCode code, const pecunia::Money &balance, const bool isClosed=false)
 Full initialisation constructor.
 
const pecunia::Money & balance () const
 The current running balance of the account.
 
void close ()
 Marks the account as closed.
 
const AccountCodecode () const
 The unique identifier for the account.
 
void convertTo (const pecunia::Currency &currency)
 Converts the running balance currency into another currency.
 
void decrease (const pecunia::Money &amount, const internal::AccountTransactionKey &allowed)
 Decreases the account's running balance by the supplied amount. When the supplied decreasing amount is not in the account currency, the balance is rounded towards even.
 
void increase (const pecunia::Money &amount, const internal::AccountTransactionKey &allowed)
 Increases the account's running balance by the supplied amount. When the supplied increasing amount is not in the account currency, the balance is rounded towards even.
 
bool isClosed () const noexcept
 A flag that, when true, indicates the account is closed.
 
void open ()
 Marks the account as opened.
 
bool operator!= (const Account &other) const
 
bool operator< (const Account &other) const
 Less than operator that compares the unique identifier for the account to that of the supplied object.
 
bool operator== (const Account &other) const
 Equality operator that compares all members.
 
void setCode (AccountCode code)
 Changes the unique identifier for the account.
 
void setParent (std::optional< AccountNumber > parent)
 Changes the parent of the account.
 
const AccountTypestype () const
 An accessor to the type the account represents.
 

Detailed Description

An entry location in the general ledger for similar kinds of transaction identified by a code.

Constructor & Destructor Documentation

◆ Account() [1/3]

drn::accounting::Account::Account ( )

Default constructs everything to their empty state.

Here is the caller graph for this function:

◆ Account() [2/3]

drn::accounting::Account::Account ( const AccountTypes type,
AccountCode code,
const pecunia::Currency & currency )

Simple constructor to establish the type of the account.

Exceptions
AccountErrorWhen the supplied currency code is unknown.
AccountErrorWhen the supplied account type is unknown.
Parameters
typeThe type the account represents.
codeA unique identifier for the account.
currencyThe ISO currency code the account is using.
Here is the call graph for this function:

◆ Account() [3/3]

drn::accounting::Account::Account ( const AccountTypes type,
AccountCode code,
const pecunia::Money & balance,
const bool isClosed = false )

Full initialisation constructor.

Exceptions
AccountErrorWhen the supplied currency code is unknown.
AccountErrorWhen the supplied account type is unknown.
AccountErrorWhen the supplied account code is empty.
Parameters
typeThe type the account represents.
codeA unique identifier for the account.
balanceThe running balance of the account.
isClosedA flag that, when true, indicates that the account is closed.
Here is the call graph for this function:

Member Function Documentation

◆ balance()

const pecunia::Money & drn::accounting::Account::balance ( ) const

The current running balance of the account.

Here is the caller graph for this function:

◆ close()

void drn::accounting::Account::close ( )

Marks the account as closed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ code()

const AccountCode & drn::accounting::Account::code ( ) const

The unique identifier for the account.

Here is the caller graph for this function:

◆ convertTo()

void drn::accounting::Account::convertTo ( const pecunia::Currency & currency)

Converts the running balance currency into another currency.

Exceptions
AccountErrorWhen the supplied currency code is unknown.
AccountErrorWhen the account is closed.
Parameters
currencyThe new currency to track the running balance in.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrease()

void drn::accounting::Account::decrease ( const pecunia::Money & amount,
const internal::AccountTransactionKey & allowed )

Decreases the account's running balance by the supplied amount. When the supplied decreasing amount is not in the account currency, the balance is rounded towards even.

Exceptions
AccountErrorWhen the supplied amount is less-than zero.
AccountErrorWhen the account is closed.
Parameters
amountThe amount to decrease the balance by.
allowedThe object that allows access to modifying the balance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ increase()

void drn::accounting::Account::increase ( const pecunia::Money & amount,
const internal::AccountTransactionKey & allowed )

Increases the account's running balance by the supplied amount. When the supplied increasing amount is not in the account currency, the balance is rounded towards even.

Exceptions
AccountErrorWhen the supplied amount is less-than zero.
AccountErrorWhen the account is closed.
Parameters
amountThe amount to increase the balance by.
allowedThe object that allows access to modifying the balance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isClosed()

bool drn::accounting::Account::isClosed ( ) const
nodiscardnoexcept

A flag that, when true, indicates the account is closed.

Here is the caller graph for this function:

◆ open()

void drn::accounting::Account::open ( )

Marks the account as opened.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool drn::accounting::Account::operator!= ( const Account & other) const
Here is the call graph for this function:

◆ operator<()

bool drn::accounting::Account::operator< ( const Account & other) const

Less than operator that compares the unique identifier for the account to that of the supplied object.

Parameters
otherThe other object whose members should be compared.
Returns
True when the members are less-than the supplied.
Here is the call graph for this function:

◆ operator==()

bool drn::accounting::Account::operator== ( const Account & other) const

Equality operator that compares all members.

Parameters
otherThe other object whose members should all be equal.
Returns
When all member variables are the same it'll give true, else false.
Here is the call graph for this function:

◆ setCode()

void drn::accounting::Account::setCode ( AccountCode code)

Changes the unique identifier for the account.

Exceptions
AccountErrorWhen the account is closed.
Parameters
codeThe new unique identifier for the account.
Here is the call graph for this function:

◆ setParent()

void drn::accounting::Account::setParent ( std::optional< AccountNumber > parent)

Changes the parent of the account.

Exceptions
AccountErrorWhen the account is closed.
Parameters
parentThe parent to change to.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ type()

const AccountTypes & drn::accounting::Account::type ( ) const

An accessor to the type the account represents.

Here is the caller graph for this function: