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

A representation of a financial institution. More...

#include <Bank.h>

Collaboration diagram for drn::banking::Bank:

Public Member Functions

 Bank ()=default
 
 Bank (BankName name, std::map< accounting::AccountNumber, BankAccountTypes > numbers={}, const bool isClosed=false)
 Full initialisation constructor.
 
const std::map< accounting::AccountNumber, BankAccountTypes > & accounts () const noexcept
 An accessor for all the accounts associated with this financial institution.
 
void add (const accounting::AccountNumber &number, const BankAccountTypes type)
 Adds a new account number along with its corresponding type to the financial institution.
 
void close ()
 Marks the financial institution as closed for usage.
 
bool isClosed () const noexcept
 An accessor for the flag to indicate if the financial institution is closed for usage.
 
void open ()
 Marks the financial institution as open for usage.
 
void remove (const accounting::AccountNumber &number)
 Removes an account number from the association with the financial institution.
 

Public Attributes

BankName name_
 The name of the financial institution, empty when not set.
 

Detailed Description

A representation of a financial institution.

Constructor & Destructor Documentation

◆ Bank() [1/2]

drn::banking::Bank::Bank ( )
default

◆ Bank() [2/2]

drn::banking::Bank::Bank ( BankName name,
std::map< accounting::AccountNumber, BankAccountTypes > numbers = {},
const bool isClosed = false )
explicit

Full initialisation constructor.

Exceptions
BankErrorThrown if the provided name is empty. This ensures that every financial institution always has a valid and meaningful name.
BankErrorWhen the account number is invalid.
BankErrorWhen the account type is unknown.
Parameters
nameThe name to assign to the financial institution. Must represent a valid name.
numbersA collection of account numbers to associate with the financial institution. Each account number must map to a valid bank account type.
isClosedIndicates whether the financial institution should be marked as closed for usage. Pass true to initialise the financial institution as closed; otherwise, false.

Member Function Documentation

◆ accounts()

const std::map< accounting::AccountNumber, BankAccountTypes > & drn::banking::Bank::accounts ( ) const
nodiscardnoexcept

An accessor for all the accounts associated with this financial institution.

Returns
The account numbers of the associated accounts, empty when not set.

◆ add()

void drn::banking::Bank::add ( const accounting::AccountNumber & number,
const BankAccountTypes type )

Adds a new account number along with its corresponding type to the financial institution.

It is designed to register an account number and its associated type to the list of accounts in the financial institution.

Exceptions
BankErrorWhen the account number is invalid.
BankErrorWhen the account type is unknown.
Parameters
numberThe account number being added to the financial institution.
typeThe account type corresponding to the account number.
Postcondition
The account number and its type will be registered in the system.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ close()

void drn::banking::Bank::close ( )

Marks the financial institution as closed for usage.

Exceptions
BankErrorWhen the financial institution is already closed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isClosed()

bool drn::banking::Bank::isClosed ( ) const
nodiscardnoexcept

An accessor for the flag to indicate if the financial institution is closed for usage.

Returns
Gives true when the financial institution is closed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

void drn::banking::Bank::open ( )

Marks the financial institution as open for usage.

Exceptions
BankErrorWhen the financial institution is already opened.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

void drn::banking::Bank::remove ( const accounting::AccountNumber & number)

Removes an account number from the association with the financial institution.

Exceptions
BankErrorWhen the account number to remove is not associated with the financial institution.
Parameters
numberThe number to remove.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ name_

BankName drn::banking::Bank::name_

The name of the financial institution, empty when not set.