/*******************************************************************************
***  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_ACCOUNTING_ACCOUNTNUMBER_H_
#define DRN_ACCOUNTING_ACCOUNTNUMBER_H_

#include <QtGlobal>

#include <iosfwd>

#include "accounting_export.h"
#include <foundation/Optional.hpp>


class QString;

namespace drn
{
namespace accounting
{

/**
 * @brief The representation of the unique identifier for an account.
 */
class DRN_ACCOUNTING_EXPORT AccountNumber
{
	quint32 value_;

public:
	/**
	 * @brief The underlying numeric type for the account number.
	 */
	using ValueType = quint32;

	/**
	 * @brief Default initialises the account number to an invalid state.
	 */
	AccountNumber();
	/**
	 * @brief Fully initialises the account number.
	 *
	 * @exception Error When the value is not set.
	 *
	 * @param value The value for the account.
	 */
	explicit AccountNumber(ValueType value);
	/**
	 * @brief The underlying value of the account number.
	 */
	const ValueType& integer() const;

	/// The number that is an invalid for an account code.
	static const quint32 invalid_;
	/// The number of characters that the account code number should always be, currently four.
	static const quint8 fieldWidth_;
};

DRN_ACCOUNTING_EXPORT bool operator<(const AccountNumber& lhs, const AccountNumber& rhs);
DRN_ACCOUNTING_EXPORT bool operator>(const AccountNumber& lhs, const AccountNumber& rhs);
DRN_ACCOUNTING_EXPORT bool operator==(const AccountNumber& lhs, const AccountNumber& rhs);
DRN_ACCOUNTING_EXPORT bool operator!=(const AccountNumber& lhs, const AccountNumber& rhs);
DRN_ACCOUNTING_EXPORT bool operator==(
	const AccountNumber::ValueType& lhs,
	const AccountNumber& rhs
);
DRN_ACCOUNTING_EXPORT bool operator!=(
	const AccountNumber::ValueType& lhs,
	const AccountNumber& rhs
);
DRN_ACCOUNTING_EXPORT std::ostream& operator<<(std::ostream& o, const AccountNumber& an);
DRN_ACCOUNTING_EXPORT ::QString presentationText(const AccountNumber& an);

}}

Q_DECLARE_METATYPE(drn::accounting::AccountNumber)

#endif
