/*******************************************************************************
***  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_BUDGETING_BUDGETITEMDUE_H_
#define DRN_BUDGETING_BUDGETITEMDUE_H_

#include <QDate>
#include <QtGlobal>
#include <pecunia/Money.h>

#include <iosfwd>
#include <vector>

#include "BudgetItemIdentifier.h"
#include "budgeting_export.h"
#include <foundation/CalendarTime.hpp>


namespace drn
{
namespace budgeting
{

class Budget;

/**
 * @brief A representation of a budget item that is due.
 */
struct DRN_BUDGETING_EXPORT BudgetItemDue
{
	/// The unique identifier of the budget item that is due.
	budgeting::BudgetItemIdentifier id_;
	/// the amount of money that is currently due for the item.
	pecunia::currency::Money amount_;
	/// The date the budget item is due on.
	::QDate dueOn_;
};

/**
 * @brief Compares the two objects by due date, then source, and finally amount.
 *
 * @param lhs The object on the left to compare is less than the other.
 * @param rhs The object on the right that is other to be compared.
 *
 * @return True when the first criteria is met for being less-than, else false.
 */
DRN_BUDGETING_EXPORT bool operator<(const BudgetItemDue& lhs, const BudgetItemDue& rhs);
/**
 * @brief Compares the two objects by due date, then source, and finally amount.
 *
 * @param lhs The object on the left to compare is greater than the other.
 * @param rhs The object on the right that is other to be compared.
 *
 * @return True when the first criteria is met for being greater-than, else false.
 */
DRN_BUDGETING_EXPORT bool operator>(const BudgetItemDue& lhs, const BudgetItemDue& rhs);
DRN_BUDGETING_EXPORT bool operator==(const BudgetItemDue& lhs, const BudgetItemDue& rhs);
DRN_BUDGETING_EXPORT bool operator!=(const BudgetItemDue& lhs, const BudgetItemDue& rhs);
/**
 * @brief Finds all budget items that are due within a given time-frame.
 *
 * @param within The number of days to search out for a budget item due.
 * @param b The budget to examine.
 *
 * @return All the budget items found to be due in ordered from most due to least due.
 */
DRN_BUDGETING_EXPORT std::vector<BudgetItemDue> budgetItemsDue(
	const foundation::Days& within,
	const budgeting::Budget& b
);
DRN_BUDGETING_EXPORT std::ostream& operator<<(std::ostream& o, const BudgetItemDue& bid);
DRN_BUDGETING_EXPORT std::ostream& operator<<(
	std::ostream& o,
	const std::vector<BudgetItemDue>& bids
);
/**
 * @brief Exchanges two BudgetItemDue objects without any conversion operation performed.
 *
 * @param lhs The object to swap to the right.
 * @param rhs The object to swap to the left.
 */
DRN_BUDGETING_EXPORT void swap(BudgetItemDue& lhs, BudgetItemDue& rhs);

}}


#endif
