/*******************************************************************************
***  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/>.    ***
*******************************************************************************/
#include "AccountTypes.h"
using std::array;
using drn::accounting::AccountTypes;
using drn::accounting::numberOfAccountTypes;
using drn::accounting::presentationText;

#include <QString>
using ::QString;

#include <ostream>
using std::ostream;

#include "AccountingErrors.h"
using drn::accounting::AccountError;
#include <foundation/EnumMacros.hpp>
// using BEGIN_ENUMERATION_TO_STRING
// using BEGIN_OTHER_TO_ENUMERATION
// using MAP_ENUMERATION_TO_STRING
// using MAP_OTHER_TO_ENUMERATION
// using END_ENUMERATION_TO_STRING
// using END_OTHER_TO_ENUMERATION


ostream& drn::accounting::operator<<(ostream& o, const AccountTypes& at)
{
	return o << presentationText(at).toStdString();
}

AccountTypes drn::accounting::toAccountTypes(const QString& weak)
{
	BEGIN_OTHER_TO_ENUMERATION(AccountTypes);
		MAP_OTHER_TO_ENUMERATION(weak, "Unknown", AccountTypes::Unknown);
		MAP_OTHER_TO_ENUMERATION(weak, "Asset", AccountTypes::Asset);
		MAP_OTHER_TO_ENUMERATION(weak, "Capital", AccountTypes::Capital);
		MAP_OTHER_TO_ENUMERATION(weak, "Expense", AccountTypes::Expense);
		MAP_OTHER_TO_ENUMERATION(weak, "Liability", AccountTypes::Liability);
		MAP_OTHER_TO_ENUMERATION(weak, "Revenue", AccountTypes::Revenue);
	END_OTHER_TO_ENUMERATION(weak, AccountTypes);
}

QString drn::accounting::presentationText(const AccountTypes& at)
{
	BEGIN_ENUMERATION_TO_OTHER(at)
		MAP_ENUMERATION_TO_OTHER(AccountTypes::Asset, "Asset");
		MAP_ENUMERATION_TO_OTHER(AccountTypes::Capital, "Capital");
		MAP_ENUMERATION_TO_OTHER(AccountTypes::Expense, "Expense");
		MAP_ENUMERATION_TO_OTHER(AccountTypes::Liability, "Liability");
		MAP_ENUMERATION_TO_OTHER(AccountTypes::Revenue, "Revenue");
		MAP_ENUMERATION_TO_OTHER(AccountTypes::Unknown, "Unknown");
	END_ENUMERATION_TO_OTHER(at, AccountTypes)
}

const array<AccountTypes, numberOfAccountTypes> drn::accounting::allAccountTypes{
	{
		AccountTypes::Unknown,
		AccountTypes::Asset,
		AccountTypes::Capital,
		AccountTypes::Expense,
		AccountTypes::Liability,
		AccountTypes::Revenue
	}
};
