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 SKGBUDGETRULEOBJECTT_H 0007 #define SKGBUDGETRULEOBJECTT_H 0008 /** @file 0009 * This file defines classes SKGBudgetRuleObject. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 0014 #include "skgbankmodeler_export.h" 0015 #include "skgcategoryobject.h" 0016 #include "skgerror.h" 0017 #include "skgobjectbase.h" 0018 0019 class SKGDocumentBank; 0020 0021 /** 0022 * This class is a budget rule 0023 */ 0024 class SKGBANKMODELER_EXPORT SKGBudgetRuleObject final : public SKGObjectBase 0025 { 0026 public: 0027 /** 0028 * Condition 0029 */ 0030 enum Condition {NEGATIVE = -1, 0031 ALL = 0, 0032 POSITIVE = 1 0033 }; 0034 /** 0035 * Condition 0036 */ 0037 Q_ENUM(Condition) 0038 0039 /** 0040 * Mode 0041 */ 0042 enum Mode {NEXT, 0043 CURRENT, 0044 YEAR 0045 }; 0046 /** 0047 * Mode 0048 */ 0049 Q_ENUM(Mode) 0050 0051 /** 0052 * Default constructor 0053 */ 0054 explicit SKGBudgetRuleObject(); 0055 0056 /** 0057 * Constructor 0058 * @param iDocument the document containing the object 0059 * @param iID the identifier in @p iTable of the object 0060 */ 0061 explicit SKGBudgetRuleObject(SKGDocument* iDocument, int iID = 0); 0062 0063 /** 0064 * Destructor 0065 */ 0066 virtual ~SKGBudgetRuleObject(); 0067 0068 /** 0069 * Copy constructor 0070 * @param iObject the object to copy 0071 */ 0072 SKGBudgetRuleObject(const SKGBudgetRuleObject& iObject); 0073 0074 /** 0075 * Copy constructor 0076 * @param iObject the object to copy 0077 */ 0078 explicit SKGBudgetRuleObject(const SKGObjectBase& iObject); 0079 0080 /** 0081 * Operator affectation 0082 * @param iObject the object to copy 0083 */ 0084 SKGBudgetRuleObject& operator= (const SKGObjectBase& iObject); 0085 0086 /** 0087 * Enable / disable condition on year of the budget 0088 * @param iEnable condition 0089 * @return an object managing the error 0090 * @see SKGError 0091 */ 0092 SKGError enableYearCondition(bool iEnable); 0093 0094 /** 0095 * To know if condition on year is enabled or disabled 0096 * @return condition 0097 */ 0098 bool isYearConditionEnabled() const; 0099 0100 /** 0101 * Set year of the condition of the rule 0102 * @param iYear the year (0=all year) 0103 * @return an object managing the error 0104 * @see SKGError 0105 */ 0106 SKGError setBudgetYear(int iYear); 0107 0108 /** 0109 * Get year of the condition of the rule 0110 * @return year of the condition of the rule 0111 */ 0112 int getBudgetYear() const; 0113 0114 /** 0115 * Enable / disable condition on month of the budget 0116 * @param iEnable condition 0117 * @return an object managing the error 0118 * @see SKGError 0119 */ 0120 SKGError enableMonthCondition(bool iEnable); 0121 0122 /** 0123 * To know if condition on month is enabled or disabled 0124 * @return condition 0125 */ 0126 bool isMonthConditionEnabled() const; 0127 0128 /** 0129 * Set month of the condition of the rule 0130 * @param iMonth the month 0131 * @return an object managing the error 0132 * @see SKGError 0133 */ 0134 SKGError setBudgetMonth(int iMonth); 0135 0136 /** 0137 * Get month of the condition of the rule 0138 * @return month of the budget 0139 */ 0140 int getBudgetMonth() const; 0141 0142 /** 0143 * Enable / disable condition on category of the budget 0144 * @param iEnable condition 0145 * @return an object managing the error 0146 * @see SKGError 0147 */ 0148 SKGError enableCategoryCondition(bool iEnable); 0149 0150 /** 0151 * To know if condition on category is enabled or disabled 0152 * @return condition 0153 */ 0154 bool isCategoryConditionEnabled() const; 0155 0156 /** 0157 * Set the category of the condition of the rule 0158 * @param iCategory the category 0159 * @return an object managing the error 0160 * @see SKGError 0161 */ 0162 SKGError setBudgetCategory(const SKGCategoryObject& iCategory); 0163 0164 /** 0165 * Remove the category of the condition of the rule 0166 * @return an object managing the error 0167 * @see SKGError 0168 */ 0169 SKGError removeBudgetCategory(); 0170 0171 /** 0172 * Get the category of the condition of the rule 0173 * @param oCategory the category 0174 * @return an object managing the error 0175 * @see SKGError 0176 */ 0177 SKGError getBudgetCategory(SKGCategoryObject& oCategory) const; 0178 0179 /** 0180 * Set the condition when the rule must be applied 0181 * @param iCondition the condition 0182 * @return an object managing the error 0183 * @see SKGError 0184 */ 0185 SKGError setCondition(SKGBudgetRuleObject::Condition iCondition); 0186 0187 /** 0188 * Get the condition when the rule must be applied 0189 * @return the condition 0190 */ 0191 SKGBudgetRuleObject::Condition getCondition() const; 0192 0193 /** 0194 * Set the quantity to transfer 0195 * @param iQuantity quantity 0196 * @param iAbsolute true means "an amount in primary unit", false means "a percentage" 0197 * @return an object managing the error 0198 * @see SKGError 0199 */ 0200 SKGError setQuantity(double iQuantity, bool iAbsolute); 0201 0202 /** 0203 * Get quantity to transfer 0204 * @return quantity to transfer 0205 */ 0206 double getQuantity() const; 0207 0208 /** 0209 * To know if the quantity is an amount or a percentage 0210 * @return true means "an amount in primary unit", false means "a percentage" 0211 */ 0212 bool isAbolute() const; 0213 0214 /** 0215 * Enable / disable transfer change the category of the budget 0216 * @param iEnable condition 0217 * @return an object managing the error 0218 * @see SKGError 0219 */ 0220 SKGError enableCategoryChange(bool iEnable); 0221 0222 /** 0223 * To know if transfer change the category 0224 * @return transfer change the category 0225 */ 0226 bool isCategoryChangeEnabled() const; 0227 0228 /** 0229 * Set the transfer to apply 0230 * @param iMode the mode (NEXT=same category but for following budget, CURRENT=same period but for another category, YEAR=period of same year) 0231 * @param iCategory the category 0232 * @return an object managing the error 0233 * @see SKGError 0234 */ 0235 SKGError setTransfer(SKGBudgetRuleObject::Mode iMode, const SKGCategoryObject& iCategory = SKGCategoryObject()); 0236 0237 /** 0238 * Get the mode of the transfer 0239 * @return the mode 0240 */ 0241 SKGBudgetRuleObject::Mode getTransferMode() const; 0242 0243 /** 0244 * Get the category of the transfer of the rule 0245 * @param oCategory the category 0246 * @return an object managing the error 0247 * @see SKGError 0248 */ 0249 SKGError getTransferCategory(SKGCategoryObject& oCategory) const; 0250 0251 /** 0252 * Set the order for the rule 0253 * @param iOrder the order. (-1 means "at the end") 0254 * @return an object managing the error 0255 * @see SKGError 0256 */ 0257 SKGError setOrder(double iOrder); 0258 0259 /** 0260 * Get the order for the rule 0261 * @return the order 0262 */ 0263 double getOrder() const; 0264 0265 /** 0266 * Process all rules 0267 * @param iDocument the document containing the object 0268 * @return an object managing the error 0269 * @see SKGError 0270 */ 0271 static SKGError processAllRules(SKGDocumentBank* iDocument); 0272 }; 0273 /** 0274 * Declare the class 0275 */ 0276 Q_DECLARE_TYPEINFO(SKGBudgetRuleObject, Q_MOVABLE_TYPE); 0277 #endif