/*******************************************************************************
***  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_ADVISER_BUDGETHEALTH_H_
#define DRN_ADVISER_BUDGETHEALTH_H_

#include <QStringList>

#include <iosfwd>

#include "adviser_export.h"


namespace drn
{
namespace budgeting
{

struct BudgetTotals;

}
namespace adviser
{

/**
 * @brief The possible statuses the health of a budget may be in.
 */
enum class DRN_ADVISER_EXPORT HealthStatuses
{
	/// The budget is in a state where it's not over or under too much of the amount of
	/// wage coming in.
	Healthy,
	/// The budget is in a state where it's a little over the amount of wage coming in.
	Ailing,
	/// The budget is in a state where it's over or under the amount of wage coming in.
	Sick
};
/**
 * @brief Determines the health of a budget. Currently when only +/- 5% of the budgeted wage is
 * left it's deemed healthy, +/- 12.5% deemed ailing, and anything else as sick.
 */
class DRN_ADVISER_EXPORT BudgetHealth
{
	double percent_;
	HealthStatuses status_;
	::QStringList information_;

public:
	/// The lowest value that the ratio of outgoing to incoming can be to be considered a healthy
	/// budget.
	static const double lowerHealthyRange_;
	/// The lowest value that the ratio of outgoing to incoming can be to be considered an ailing
	/// budget.
	static const double lowerAilingRange_;
	/// The lowest value that the ratio of outgoing to incoming can be to be considered a sick
	/// budget.
	static const double nontrackWageRatioThreshold_;

	/**
	 * @brief Constructor to initialise in an empty, but healthy state.
	 */
	BudgetHealth();
	/**
	 * @brief Constructor to fully initialise the budget health using the budget data.
	 *
	 * @param budget The budget totals whose health is to be determined.
	 */
	BudgetHealth(const budgeting::BudgetTotals& budget);
	/**
	 * @brief Provides the percentage of incoming to the outgoing budgeted items when there is more
	 * incoming than ougoing and the inverse when there isn't. This will always be in the range of
	 * 0.0% and 100.0%.
	 */
	const double& percent() const;
	/**
	 * @brief Provides the health status of the budget.
	 */
	const HealthStatuses& status() const;
	/**
	 * @brief Provides the information details on the health of the budget with each detail per
	 * entry.
	 */
	const ::QStringList& information() const;
};

DRN_ADVISER_EXPORT std::ostream& operator<<(std::ostream& o, const HealthStatuses& hs);
DRN_ADVISER_EXPORT ::QString presentationText(const HealthStatuses& hs);

}}

#endif
