/*******************************************************************************
***  This file is part of Dux Rei Nummariae.                                 ***
***                                                                          ***
***  Copyright (C) 2017, 2018, 2019, 2020, 2021                              ***
***  John Schneiderman <Licensing _AT_ Schneiderman _DOT_ me>                ***
***                                                                          ***
***  This program is free software: you can redistribute it and/or modify it ***
***  under the terms of the GNU Affero General Public License as published   ***
***  by the Free Software Foundation, either version 3 of the License, or    ***
***  (at your option) any later version.                                     ***
***                                                                          ***
***  This program is distributed in the hope that it will be useful, but     ***
***  WITHOUT ANY WARRANTY; without even the implied warranty of              ***
***  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                    ***
***  See the GNU Affero General Public License for more details.             ***
***                                                                          ***
***  You should have received a copy of the GNU Affero General Public License***
***  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
*******************************************************************************/
#ifndef DRN_BANKING_BANKACCOUNTTYPE_H_
#define DRN_BANKING_BANKACCOUNTTYPE_H_

#include <QtGlobal>

#include <array>
#include <iosfwd>

#include <accounting/AccountCode.h>
#include <accounting/AccountTypes.h>
#include "banking_export.h"


class QString;

namespace drn
{
namespace accounting
{

enum class AccountTypes : quint8;

}
namespace banking
{

/**
 * @brief The types of financial accounts supported.
 */
enum class DRN_BANKING_EXPORT SupportedAccountTypes
{
	/// The bank account type is not known.
	Unknown,
	/// The bank account type is a for chequeing/current account.
	Chequeing,
	/// The bank account type is a credit card.
	CreditCard,
	/// The bank account type is for a loan.
	Loan,
	/// The bank account type is an interest bearing savings account.
	Savings,
	/// The bank account type is a goal budget item account that is stored as a sub-total inside
	/// another bank account.
	Goal,
};
/**
 * @brief The representation of the bank account ledger code and the type of account for a financial
 * institution.
 */
struct DRN_BANKING_EXPORT BankAccountType
{
	/// The account ledger code for the bank account.
	accounting::AccountCode code_;
	/// The type of bank account for a financial institution.
	SupportedAccountTypes type_;
};

DRN_BANKING_EXPORT SupportedAccountTypes toSupportedAccountTypes(const ::QString& bankAccountType);
DRN_BANKING_EXPORT ::QString presentationText(const SupportedAccountTypes& sat);
DRN_BANKING_EXPORT accounting::AccountTypes toAccountTypes(const SupportedAccountTypes& sat);
DRN_BANKING_EXPORT std::ostream& operator<<(std::ostream& o, const SupportedAccountTypes& sat);
DRN_BANKING_EXPORT bool operator<(const BankAccountType& lhs, const BankAccountType& rhs);
DRN_BANKING_EXPORT bool operator==(const BankAccountType& lhs, const BankAccountType& rhs);
DRN_BANKING_EXPORT bool operator!=(const BankAccountType& lhs, const BankAccountType& rhs);
DRN_BANKING_EXPORT std::ostream& operator<<(std::ostream& out, const BankAccountType& bat);

constexpr quint8 numberOfSupportedAccountTypes{6};
extern DRN_BANKING_EXPORT const std::array<
	SupportedAccountTypes,
	numberOfSupportedAccountTypes
> allSupportedAccountTypes;

}}

Q_DECLARE_METATYPE(drn::banking::SupportedAccountTypes)

#endif
