|
DuxReiNummariae 1.1.0-alpha.19
Simple and powerful budgeting application
|
Represents a financial transaction, typically involving the transfer of money between two accounts. More...
#include <Transaction.hpp>
Public Member Functions | |
| Transaction () | |
| Default constructor with all values defaulted and the transaction status unreconciled. | |
| Transaction (const ::QDate &occurredOn) | |
| Basic date constructor. Useful for when constructing piece-wise. All other values are defaulted and the transaction status unreconciled. | |
| Transaction (const ::QDate &occurredOn, AccountNumber debiting, AccountNumber crediting, pecunia::Money amount, std::optional<::QString > description=std::nullopt, std::optional< TransactionNumber > id=std::nullopt, const TransactionStatuses &status=TransactionStatuses::Unreconciled) | |
| New transaction initialisation constructor. | |
| Transaction (const ::QDate &occurredOn, const AccountCode &debiting, const AccountCode &crediting, const pecunia::Money &amount, std::optional<::QString > description=std::nullopt, std::optional< TransactionNumber > id=std::nullopt, const TransactionStatuses &status=TransactionStatuses::Unreconciled) | |
| New transaction initialisation constructor. | |
| Transaction (const Transaction &)=default | |
| Transaction (Transaction &&) noexcept=default | |
| const pecunia::Money & | amount () const noexcept |
| Retrieves the monetary value associated with the transaction. | |
| void | changeCredit (const AccountCode &code, const internal::AccountTransactionKey &allowed) |
| Changes the crediting account code. | |
| void | changeDebit (const AccountCode &code, const internal::AccountTransactionKey &allowed) |
| Changes the debiting account code. | |
| void | convertAmount (const pecunia::Currency &changeTo, const internal::AccountTransactionKey &allowed) |
| Converts the transaction amount into a requested currency. | |
| const AccountCode & | crediting () const noexcept |
| Retrieves the account code associated with the crediting side of the transaction. | |
| const AccountCode & | debiting () const noexcept |
| Retrieves the account code associated with the debiting side of the transaction. | |
| const std::optional<::QString > & | description () const noexcept |
| Retrieves the description associated with the transaction if available. | |
| void | markCleared () |
| Changes the transaction to have cleared the account. | |
| void | markReconciled () |
| Changes the transaction to have reconciled with the account. | |
| void | markUnreconciled () |
| Changes the transaction to have not cleared nor reconciled with the account. | |
| const std::optional< TransactionNumber > & | number () const noexcept |
| Retrieves the current transaction number if it exists. | |
| const ::QDate & | occurredOn () const noexcept |
| Retrieves the date when the transaction occurred. | |
| bool | operator!= (const Transaction &other) const noexcept=default |
| std::strong_ordering | operator<=> (const Transaction &other) const noexcept |
| Performs a three-way comparison between this transaction and another transaction. | |
| Transaction & | operator= (const Transaction &other) |
| Assigns all attributes of another transaction to the current transaction. | |
| Transaction & | operator= (Transaction &&other) noexcept |
| Transfers the state of another transaction object to the current object, ensuring the current object’s data reflects that of the source. This is useful for operations involving ownership transfer of resources from one transaction to another. | |
| bool | operator== (const Transaction &other) const noexcept |
| Compares this transaction with another to determine if they are equal. | |
| void | setNumber (TransactionNumber value, const internal::AccountTransactionKey &allowed) |
| Changes the number of the transaction. Once set it cannot be changed. | |
| const TransactionStatuses & | status () const noexcept |
| Retrieves the current state of the transaction regarding its reconciliation status. | |
Represents a financial transaction, typically involving the transfer of money between two accounts.
This encapsulates all relevant details associated with a financial transaction, including the date of occurrence, the accounts involved (debited and credited), the amount transferred, a description of the transaction, its identifier if available, and its reconciliation status. This is immutable for most of its core attributes and is designed to safely manage essential transaction details. Mutation of the essential details is only allowed via a key enforced by the compiler.
| drn::accounting::Transaction::Transaction | ( | ) |
Default constructor with all values defaulted and the transaction status unreconciled.
|
explicit |
Basic date constructor. Useful for when constructing piece-wise. All other values are defaulted and the transaction status unreconciled.
| occurredOn | The date the transaction occurred on. |
| drn::accounting::Transaction::Transaction | ( | const ::QDate & | occurredOn, |
| const AccountCode & | debiting, | ||
| const AccountCode & | crediting, | ||
| const pecunia::Money & | amount, | ||
| std::optional<::QString > | description = std::nullopt, | ||
| std::optional< TransactionNumber > | id = std::nullopt, | ||
| const TransactionStatuses & | status = TransactionStatuses::Unreconciled ) |
New transaction initialisation constructor.
| TransactionError | When the transaction date is invalid. |
| TransactionError | When the code of the debit account is the same as the code of the credit account. |
| TransactionError | When the amount is less than zero. |
| occurredOn | The date the Transaction occurred on. |
| debiting | The code of the account that is debited. |
| crediting | The code of the account that is credited. |
| amount | The amount of money applied to each account. |
| description | A human friendly description of the transaction. |
| id | The identifier for the transaction in the general ledger book iff its posted. |
| status | The current status of the transaction. |
| drn::accounting::Transaction::Transaction | ( | const ::QDate & | occurredOn, |
| AccountNumber | debiting, | ||
| AccountNumber | crediting, | ||
| pecunia::Money | amount, | ||
| std::optional<::QString > | description = std::nullopt, | ||
| std::optional< TransactionNumber > | id = std::nullopt, | ||
| const TransactionStatuses & | status = TransactionStatuses::Unreconciled ) |
New transaction initialisation constructor.
| TransactionError | When the transaction date is invalid. |
| TransactionError | When the number of the debit account is the same as the number of the credit account. |
| TransactionError | When the amount is less than zero. |
| occurredOn | The date the Transaction occurred on. |
| debiting | The ledger number of the account that is debited. |
| crediting | The ledger number of the account that is credited. |
| amount | The amount of money applied to each account. |
| description | A human friendly description of the transaction. |
| id | The identifier for the transaction in the general ledger book iff its posted. |
| status | The current status of the transaction. |
|
default |
|
defaultnoexcept |
|
nodiscardnoexcept |
Retrieves the monetary value associated with the transaction.
| void drn::accounting::Transaction::changeCredit | ( | const AccountCode & | code, |
| const internal::AccountTransactionKey & | allowed ) |
Changes the crediting account code.
| TransactionError | When the new account code is the same as the debiting account. |
| code | The new account code. |
| allowed | The object that allows access to modifying the transaction. |
| void drn::accounting::Transaction::changeDebit | ( | const AccountCode & | code, |
| const internal::AccountTransactionKey & | allowed ) |
Changes the debiting account code.
| TransactionError | When the new account code is the same as the crediting account. |
| code | The new account code. |
| allowed | The object that allows access to modifying the transaction. |
| void drn::accounting::Transaction::convertAmount | ( | const pecunia::Currency & | changeTo, |
| const internal::AccountTransactionKey & | allowed ) |
Converts the transaction amount into a requested currency.
| TransactionError | When the currency of the amount is the same as the request currency. |
| changeTo | The currency to change the transaction into. |
| allowed | The object that allows access to modifying the transaction. |
|
nodiscardnoexcept |
Retrieves the account code associated with the crediting side of the transaction.
|
nodiscardnoexcept |
Retrieves the account code associated with the debiting side of the transaction.
|
nodiscardnoexcept |
Retrieves the description associated with the transaction if available.
This provides access to a textual description that explains the transaction. This description can be useful in providing contextual information for their purpose.
| void drn::accounting::Transaction::markCleared | ( | ) |
Changes the transaction to have cleared the account.
| TransactionError | When the transaction is already reconciled. |
| void drn::accounting::Transaction::markReconciled | ( | ) |
Changes the transaction to have reconciled with the account.
| void drn::accounting::Transaction::markUnreconciled | ( | ) |
Changes the transaction to have not cleared nor reconciled with the account.
| TransactionError | When the transaction is already reconciled. |
|
nodiscardnoexcept |
Retrieves the current transaction number if it exists.
|
nodiscardnoexcept |
Retrieves the date when the transaction occurred.
|
nodiscarddefaultnoexcept |
|
nodiscardnoexcept |
Performs a three-way comparison between this transaction and another transaction.
The purpose is to determine the order of transactions based on a set of prioritised attributes such as status, number, etc. This is helpful in sorting, equality checks, and other operations requiring transactional order evaluation.
| other | The transaction against which this transaction will be compared. |
| Transaction & drn::accounting::Transaction::operator= | ( | const Transaction & | other | ) |
Assigns all attributes of another transaction to the current transaction.
This copies the details of another transaction into the current transaction. It ensures that the current transaction has identical properties to the other transaction.
| other | The transaction whose attributes are to be assigned to the current transaction. |
|
noexcept |
Transfers the state of another transaction object to the current object, ensuring the current object’s data reflects that of the source. This is useful for operations involving ownership transfer of resources from one transaction to another.
| other | The source transaction object whose data will be transferred. |
|
nodiscardnoexcept |
Compares this transaction with another to determine if they are equal.
This method checks if two transactions are equivalent by comparing all their properties. It is useful for identifying whether two transactions represent the same entity, aiding in tasks such as deduplication, or validation within financial systems.
| other | The transaction to be compared against. |
| void drn::accounting::Transaction::setNumber | ( | TransactionNumber | value, |
| const internal::AccountTransactionKey & | allowed ) |
Changes the number of the transaction. Once set it cannot be changed.
| TransactionError | When the transaction number is already set. |
| value | The new unique identifier for the transaction in the accounting system. |
| allowed | The object that allows access to modify the transaction. |
|
nodiscardnoexcept |
Retrieves the current state of the transaction regarding its reconciliation status.