File indexing completed on 2024-05-12 09:09:43
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 SKGRECURRENTOPERATIONOBJECT_H 0007 #define SKGRECURRENTOPERATIONOBJECT_H 0008 /** @file 0009 * This file defines classes SKGRecurrentOperationObject. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 0014 #include "skgbankmodeler_export.h" 0015 #include "skgobjectbase.h" 0016 class SKGOperationObject; 0017 class SKGDocumentBank; 0018 0019 /** 0020 * This class manages recurrent transaction object 0021 */ 0022 class SKGBANKMODELER_EXPORT SKGRecurrentOperationObject final : public SKGObjectBase 0023 { 0024 public: 0025 /** 0026 * This enumerate defines the period unit 0027 */ 0028 enum PeriodUnit {DAY = 0, /**< day */ 0029 WEEK = 1, /**< week */ 0030 MONTH = 2, /**< month */ 0031 YEAR = 3 /**< year */ 0032 }; 0033 /** 0034 * This enumerate defines the period unit 0035 */ 0036 Q_ENUM(PeriodUnit) 0037 0038 /** 0039 * Default constructor 0040 */ 0041 explicit SKGRecurrentOperationObject(); 0042 0043 /** 0044 * Constructor 0045 * @param iDocument the document containing the object 0046 * @param iID the identifier in @p iTable of the object 0047 */ 0048 explicit SKGRecurrentOperationObject(SKGDocument* iDocument, int iID = 0); 0049 0050 /** 0051 * Copy constructor 0052 * @param iObject the object to copy 0053 */ 0054 explicit SKGRecurrentOperationObject(const SKGObjectBase& iObject); 0055 0056 /** 0057 * Copy constructor 0058 * @param iObject the object to copy 0059 */ 0060 SKGRecurrentOperationObject(const SKGRecurrentOperationObject& iObject); 0061 0062 /** 0063 * Operator affectation 0064 * @param iObject the object to copy 0065 */ 0066 SKGRecurrentOperationObject& operator= (const SKGObjectBase& iObject); 0067 0068 /** 0069 * Operator affectation 0070 * @param iObject the object to copy 0071 */ 0072 SKGRecurrentOperationObject& operator= (const SKGRecurrentOperationObject& iObject); 0073 0074 /** 0075 * Destructor 0076 */ 0077 virtual ~SKGRecurrentOperationObject(); 0078 0079 /** 0080 * Get the parent operation 0081 * @param oOperation the parent operation 0082 * @return an object managing the error. 0083 * @see SKGError 0084 */ 0085 SKGError getParentOperation(SKGOperationObject& oOperation) const; 0086 0087 /** 0088 * Set the parent operation 0089 * @param iOperation the parent operation 0090 * @return an object managing the error. 0091 * @see SKGError 0092 */ 0093 SKGError setParentOperation(const SKGOperationObject& iOperation); 0094 0095 /** 0096 * Set the template mode of this recurrent operation 0097 * @param iTemplate the template status: true or false 0098 * @return an object managing the error. 0099 * @see SKGError 0100 */ 0101 SKGError setTemplate(bool iTemplate); 0102 0103 /** 0104 * Get the template mode of this recurrent operation 0105 * @return an object managing the error 0106 * @see SKGError 0107 */ 0108 bool isTemplate() const; 0109 0110 /** 0111 * Set the increment 0112 * @param iIncrement the number of @see setPeriodUnit 0113 * @return an object managing the error 0114 * @see SKGError 0115 */ 0116 SKGError setPeriodIncrement(int iIncrement); 0117 0118 /** 0119 * Get the increment 0120 * @return the number 0121 */ 0122 int getPeriodIncrement() const; 0123 0124 /** 0125 * Get the period unit of this recurrent operation 0126 * @return the status 0127 */ 0128 SKGRecurrentOperationObject::PeriodUnit getPeriodUnit() const; 0129 0130 /** 0131 * Set the period unit of this recurrent operation 0132 * @param iPeriod the period unit 0133 * @return an object managing the error 0134 * @see SKGError 0135 */ 0136 SKGError setPeriodUnit(SKGRecurrentOperationObject::PeriodUnit iPeriod); 0137 0138 /** 0139 * Set the number of days before term to create operation 0140 * @param iDays the number of days 0141 * @return an object managing the error 0142 * @see SKGError 0143 */ 0144 SKGError setAutoWriteDays(int iDays); 0145 0146 /** 0147 * Get the number of days before term to create operation 0148 * @return the number of days 0149 */ 0150 int getAutoWriteDays() const; 0151 0152 /** 0153 * Set the number of days before term to warn user 0154 * @param iDays the number of days 0155 * @return an object managing the error 0156 * @see SKGError 0157 */ 0158 SKGError setWarnDays(int iDays); 0159 0160 /** 0161 * Get the number of days before term to warn user 0162 * @return the number of days 0163 */ 0164 int getWarnDays() const; 0165 0166 /** 0167 * Set date of this recurrent operation 0168 * @param iDate the date 0169 * @return an object managing the error 0170 * @see SKGError 0171 */ 0172 // cppcheck-suppress passedByValue 0173 SKGError setDate(QDate iDate); 0174 0175 /** 0176 * Get date of this recurrent operation 0177 * @return the date 0178 */ 0179 QDate getDate() const; 0180 0181 /** 0182 * Get next date of this recurrent operation 0183 * @return the date 0184 */ 0185 QDate getNextDate() const; 0186 0187 /** 0188 * Get all transactions created by this recurrent operation 0189 * @param oOperations all transactions 0190 * @return an object managing the error 0191 * @see SKGError 0192 */ 0193 SKGError getRecurredOperations(SKGListSKGObjectBase& oOperations) const; 0194 0195 /** 0196 * To warn or not the end user 0197 * @param iWarn the warn: true or false 0198 * @return an object managing the error 0199 * @see SKGError 0200 */ 0201 SKGError warnEnabled(bool iWarn); 0202 0203 /** 0204 * To know if the end user is warned or not 0205 * @return an object managing the error 0206 * @see SKGError 0207 */ 0208 bool isWarnEnabled() const; 0209 0210 /** 0211 * To activate or not the auto write mode 0212 * @param iAutoWrite auto write mode: true or false 0213 * @return an object managing the error 0214 * @see SKGError 0215 */ 0216 SKGError autoWriteEnabled(bool iAutoWrite); 0217 0218 /** 0219 * To know if auto write mode is enabled or not 0220 * @return an object managing the error 0221 * @see SKGError 0222 */ 0223 bool isAutoWriteEnabled() const; 0224 0225 /** 0226 * To know if a time limit is enabled or not 0227 * @return an object managing the error 0228 * @see SKGError 0229 */ 0230 bool hasTimeLimit() const; 0231 0232 /** 0233 * To enable / disable a time limit 0234 * @param iTimeLimit the time limit: true or false 0235 * @return an object managing the error 0236 * @see SKGError 0237 */ 0238 SKGError timeLimit(bool iTimeLimit); 0239 0240 /** 0241 * Set the time limit 0242 * @param iTimeLimit the number of times transaction will be inserted 0243 * @return an object managing the error 0244 * @see SKGError 0245 */ 0246 SKGError setTimeLimit(int iTimeLimit); 0247 0248 /** 0249 * Set the time limit 0250 * @param iLastDate the last date of the transaction will be inserted. setDate, setPeriodIncrement and setPeriodUnit must be used before. 0251 * @return an object managing the error 0252 * @see SKGError 0253 */ 0254 // cppcheck-suppress passedByValue 0255 SKGError setTimeLimit(QDate iLastDate); 0256 0257 /** 0258 * Get the number of times transaction will be inserted 0259 * @return the number of times 0260 */ 0261 int getTimeLimit() const; 0262 0263 /** 0264 * Warn and/or create transactions for this recurrent operation 0265 * @param oNbInserted number of transactions inserted 0266 * @param iForce to force the insertion even if autowrite is not enable 0267 * @param iDate date limit for insertion 0268 * @return an object managing the error 0269 * @see SKGError 0270 */ 0271 // cppcheck-suppress passedByValue 0272 SKGError process(int& oNbInserted, bool iForce = false, QDate iDate = QDate::currentDate()); 0273 0274 /** 0275 * Warn and/or create transactions for all recurrent transactions of the document 0276 * @param iDocument the document containing the object 0277 * @param oNbInserted number of transactions inserted 0278 * @param iForce to force the insertion even if autowrite is not enable* 0279 * @param iDate date limit for insertion 0280 * @return an object managing the error 0281 * @see SKGError 0282 */ 0283 // cppcheck-suppress passedByValue 0284 static SKGError process(SKGDocumentBank* iDocument, int& oNbInserted, bool iForce = false, QDate iDate = QDate::currentDate()); 0285 }; 0286 /** 0287 * Declare the class 0288 */ 0289 Q_DECLARE_TYPEINFO(SKGRecurrentOperationObject, Q_MOVABLE_TYPE); 0290 #endif