An entry location in the general ledger for similar kinds of transaction identified by a code. More...
#include <Account.h>
Public Member Functions | |
Account () | |
Default constructs everything to their empty state. | |
Account (const AccountTypes type, AccountCode code, const pecunia::Currency ¤cy) | |
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 AccountCode & | code () const |
The unique identifier for the account. | |
void | convertTo (const pecunia::Currency ¤cy) |
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 AccountTypes & | type () const |
An accessor to the type the account represents. | |
An entry location in the general ledger for similar kinds of transaction identified by a code.
drn::accounting::Account::Account | ( | ) |
Default constructs everything to their empty state.
drn::accounting::Account::Account | ( | const AccountTypes | type, |
AccountCode | code, | ||
const pecunia::Currency & | currency ) |
Simple constructor to establish the type of the account.
AccountError | When the supplied currency code is unknown. |
AccountError | When the supplied account type is unknown. |
type | The type the account represents. |
code | A unique identifier for the account. |
currency | The ISO currency code the account is using. |
drn::accounting::Account::Account | ( | const AccountTypes | type, |
AccountCode | code, | ||
const pecunia::Money & | balance, | ||
const bool | isClosed = false ) |
Full initialisation constructor.
AccountError | When the supplied currency code is unknown. |
AccountError | When the supplied account type is unknown. |
AccountError | When the supplied account code is empty. |
type | The type the account represents. |
code | A unique identifier for the account. |
balance | The running balance of the account. |
isClosed | A flag that, when true, indicates that the account is closed. |
const pecunia::Money & drn::accounting::Account::balance | ( | ) | const |
The current running balance of the account.
void drn::accounting::Account::close | ( | ) |
Marks the account as closed.
const AccountCode & drn::accounting::Account::code | ( | ) | const |
The unique identifier for the account.
void drn::accounting::Account::convertTo | ( | const pecunia::Currency & | currency | ) |
Converts the running balance currency into another currency.
AccountError | When the supplied currency code is unknown. |
AccountError | When the account is closed. |
currency | The new currency to track the running balance in. |
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.
AccountError | When the supplied amount is less-than zero. |
AccountError | When the account is closed. |
amount | The amount to decrease the balance by. |
allowed | The object that allows access to modifying the balance. |
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.
AccountError | When the supplied amount is less-than zero. |
AccountError | When the account is closed. |
amount | The amount to increase the balance by. |
allowed | The object that allows access to modifying the balance. |
|
nodiscardnoexcept |
A flag that, when true, indicates the account is closed.
void drn::accounting::Account::open | ( | ) |
Marks the account as opened.
bool drn::accounting::Account::operator!= | ( | const Account & | other | ) | const |
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.
other | The other object whose members should be compared. |
bool drn::accounting::Account::operator== | ( | const Account & | other | ) | const |
Equality operator that compares all members.
other | The other object whose members should all be equal. |
void drn::accounting::Account::setCode | ( | AccountCode | code | ) |
Changes the unique identifier for the account.
AccountError | When the account is closed. |
code | The new unique identifier for the account. |
void drn::accounting::Account::setParent | ( | std::optional< AccountNumber > | parent | ) |
Changes the parent of the account.
AccountError | When the account is closed. |
parent | The parent to change to. |
const AccountTypes & drn::accounting::Account::type | ( | ) | const |
An accessor to the type the account represents.