File indexing completed on 2024-04-28 16:30:09
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 #ifndef SKGBUDGETOBJECTT_H 0007 #define SKGBUDGETOBJECTT_H 0008 /** @file 0009 * This file defines classes SKGBudgetObject. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 0014 #include "skgbankmodeler_export.h" 0015 #include "skgerror.h" 0016 #include "skgobjectbase.h" 0017 0018 class SKGCategoryObject; 0019 class SKGDocumentBank; 0020 0021 /** 0022 * This class is a budget 0023 */ 0024 class SKGBANKMODELER_EXPORT SKGBudgetObject final : public SKGObjectBase 0025 { 0026 public: 0027 /** 0028 * Default constructor 0029 */ 0030 explicit SKGBudgetObject(); 0031 0032 /** 0033 * Constructor 0034 * @param iDocument the document containing the object 0035 * @param iID the identifier in @p iTable of the object 0036 */ 0037 explicit SKGBudgetObject(SKGDocument* iDocument, int iID = 0); 0038 0039 /** 0040 * Destructor 0041 */ 0042 virtual ~SKGBudgetObject(); 0043 0044 /** 0045 * Copy constructor 0046 * @param iObject the object to copy 0047 */ 0048 SKGBudgetObject(const SKGBudgetObject& iObject); 0049 0050 /** 0051 * Copy constructor 0052 * @param iObject the object to copy 0053 */ 0054 explicit SKGBudgetObject(const SKGObjectBase& iObject); 0055 0056 /** 0057 * Operator affectation 0058 * @param iObject the object to copy 0059 */ 0060 SKGBudgetObject& operator= (const SKGObjectBase& iObject); 0061 0062 /** 0063 * Set year of the budget 0064 * @param iYear the year 0065 * @return an object managing the error 0066 * @see SKGError 0067 */ 0068 SKGError setYear(int iYear); 0069 0070 /** 0071 * Get year of the budget 0072 * @return year of the budget 0073 */ 0074 int getYear() const; 0075 0076 /** 0077 * Set month of the budget 0078 * @param iMonth the month 0079 * @return an object managing the error 0080 * @see SKGError 0081 */ 0082 SKGError setMonth(int iMonth); 0083 0084 /** 0085 * Get month of the budget 0086 * @return month of the budget 0087 */ 0088 int getMonth() const; 0089 0090 /** 0091 * Set the category 0092 * @param iCategory the category 0093 * @return an object managing the error 0094 * @see SKGError 0095 */ 0096 SKGError setCategory(const SKGCategoryObject& iCategory); 0097 0098 /** 0099 * Remove the category 0100 * @return an object managing the error 0101 * @see SKGError 0102 */ 0103 SKGError removeCategory(); 0104 0105 /** 0106 * Get the category 0107 * @param oCategory the category 0108 * @return an object managing the error 0109 * @see SKGError 0110 */ 0111 SKGError getCategory(SKGCategoryObject& oCategory) const; 0112 0113 /** 0114 * Enable / disable the inclusion of sub categories 0115 * @param iEnable condition 0116 * @return an object managing the error 0117 * @see SKGError 0118 */ 0119 SKGError enableSubCategoriesInclusion(bool iEnable); 0120 0121 /** 0122 * To know if sub categories inclusion is enabled or disabled 0123 * @return condition 0124 */ 0125 bool isSubCategoriesInclusionEnabled() const; 0126 0127 /** 0128 * Set budgeted amount of the budget 0129 * @param iAmount the budgeted amount 0130 * @return an object managing the error 0131 * @see SKGError 0132 */ 0133 SKGError setBudgetedAmount(double iAmount); 0134 0135 /** 0136 * Get budgeted amount of the budget 0137 * @return budgeted amount of the budget 0138 */ 0139 double getBudgetedAmount() const; 0140 0141 /** 0142 * Get budgeted modified amount of the budget 0143 * @return budgeted modified amount of the budget 0144 */ 0145 double getBudgetedModifiedAmount() const; 0146 0147 /** 0148 * Get the text explaining the reasons of the modification 0149 * @return the text explaining the reasons of the modification 0150 */ 0151 QString getModificationReasons() const; 0152 0153 /** 0154 * Get delta 0155 * @return delta 0156 */ 0157 double getDelta() const; 0158 0159 /** 0160 * Process all rules 0161 * @return an object managing the error 0162 * @see SKGError 0163 */ 0164 SKGError process(); 0165 0166 /** 0167 * Create automatically budget items based on existing transactions 0168 * @param iDocument the document where to create* 0169 * @param iYear year of budget 0170 * @param iBaseYear year of the base for computation 0171 * @param iUseScheduledOperation use the scheduled transactions for a more accurate creation 0172 * @param iRemovePreviousBudget remove existing budget for @param iYear 0173 * @return an object managing the error 0174 * @see SKGError 0175 */ 0176 static SKGError createAutomaticBudget(SKGDocumentBank* iDocument, int iYear, int iBaseYear, bool iUseScheduledOperation, bool iRemovePreviousBudget); 0177 0178 /** 0179 * Create automatically budget items based on existing transactions 0180 * @param iDocument the document where to create* 0181 * @param iYear year of budget 0182 * @param iMonth month of the budget. 0 to balance all months. -1 to balance any month 0183 * @param iBalanceYear to balance the year 0184 * @return an object managing the error 0185 * @see SKGError 0186 */ 0187 static SKGError balanceBudget(SKGDocumentBank* iDocument, int iYear, int iMonth = 0, bool iBalanceYear = true); 0188 0189 private: 0190 QString getWhereclauseId() const override; 0191 }; 0192 /** 0193 * Declare the class 0194 */ 0195 Q_DECLARE_TYPEINFO(SKGBudgetObject, Q_MOVABLE_TYPE); 0196 #endif