File indexing completed on 2024-04-28 16:30:11

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 SKGINTERESTOBJECT_H
0007 #define SKGINTERESTOBJECT_H
0008 /** @file
0009  * This file defines classes SKGInterestObject.
0010  *
0011  * @author Stephane MANKOWSKI / Guillaume DE BURE
0012  */
0013 
0014 #include "skgaccountobject.h"
0015 #include "skgbankmodeler_export.h"
0016 #include "skgerror.h"
0017 #include "skgobjectbase.h"
0018 
0019 class SKGInterestObject;
0020 
0021 /**
0022  * This class is interest option for an account
0023  */
0024 class SKGBANKMODELER_EXPORT SKGInterestObject final : public SKGObjectBase
0025 {
0026 public:
0027     /**
0028      * This enumerate defines how to compute value date
0029      */
0030     enum ValueDateMode {FIFTEEN = 0,
0031                         J0,
0032                         J1,
0033                         J2,
0034                         J3,
0035                         J4,
0036                         J5
0037                        };
0038     /**
0039      * This enumerate defines how to compute value date
0040      */
0041     Q_ENUM(ValueDateMode)
0042 
0043     /**
0044      * This enumerate defines how to compute interest
0045      */
0046     enum InterestMode {FIFTEEN24 = 0,
0047                        DAYS360,
0048                        DAYS365
0049                       };
0050     /**
0051      * This enumerate defines how to compute interest
0052      */
0053     Q_ENUM(InterestMode)
0054 
0055     /**
0056      * Default constructor
0057      */
0058     explicit SKGInterestObject();
0059 
0060     /**
0061      * Constructor
0062      * @param iDocument the document containing the object
0063      * @param iID the identifier in @p iTable of the object
0064      */
0065     explicit SKGInterestObject(SKGDocument* iDocument, int iID = 0);
0066 
0067     /**
0068      * Copy constructor
0069      * @param iObject the object to copy
0070      */
0071     SKGInterestObject(const SKGInterestObject& iObject);
0072 
0073     /**
0074      * Copy constructor
0075      * @param iObject the object to copy
0076      */
0077     explicit SKGInterestObject(const SKGObjectBase& iObject);
0078 
0079     /**
0080      * Operator affectation
0081      * @param iObject the object to copy
0082      */
0083     SKGInterestObject& operator= (const SKGObjectBase& iObject);
0084 
0085     /**
0086      * Operator affectation
0087      * @param iObject the object to copy
0088      */
0089     SKGInterestObject& operator= (const SKGInterestObject& iObject);
0090 
0091     /**
0092      * Destructor
0093      */
0094     virtual ~SKGInterestObject();
0095 
0096     /**
0097      * Get the parent account
0098      * @param oAccount the parent account
0099      * @return an object managing the error
0100      *   @see SKGError
0101      */
0102     SKGError getAccount(SKGAccountObject& oAccount) const;
0103 
0104     /**
0105      * Set the parent account
0106      * @param iAccount the parent account
0107      * @return an object managing the error
0108      *   @see SKGError
0109      */
0110     SKGError setAccount(const SKGAccountObject& iAccount);
0111 
0112     /**
0113      * Set the quantity for the date of this unit
0114      * @param iValue the quantity
0115      * @return an object managing the error
0116      *   @see SKGError
0117      */
0118     SKGError setRate(double iValue);
0119 
0120     /**
0121      * Get the quantity for the date of this unit
0122      * @return the quantity
0123      */
0124     double getRate() const;
0125 
0126     /**
0127      * Set date of this value
0128      * @param iDate the date
0129      * @return an object managing the error
0130      *   @see SKGError
0131      */
0132     // cppcheck-suppress passedByValue
0133     SKGError setDate(QDate iDate);
0134 
0135     /**
0136      * Get date of this value
0137      * @return the date
0138      */
0139     QDate getDate() const;
0140 
0141     /**
0142      * Set income value date mode
0143      * @param iMode the mode
0144      * @return an object managing the error
0145      *   @see SKGError
0146      */
0147     SKGError setIncomeValueDateMode(SKGInterestObject::ValueDateMode iMode);
0148 
0149     /**
0150      * Get income value date mode
0151      * @return the income value date mode
0152      */
0153     SKGInterestObject::ValueDateMode getIncomeValueDateMode() const;
0154 
0155     /**
0156      * Set expenditue value date mode
0157      * @param iMode the mode
0158      * @return an object managing the error
0159      *   @see SKGError
0160      */
0161     SKGError setExpenditueValueDateMode(SKGInterestObject::ValueDateMode iMode);
0162 
0163     /**
0164      * Get expenditue value date mode
0165      * @return the expenditue value date mode
0166      */
0167     SKGInterestObject::ValueDateMode getExpenditueValueDateMode() const;
0168 
0169     /**
0170      * Set interest computation mode
0171      * @param iMode the mode
0172      * @return an object managing the error
0173      *   @see SKGError
0174      */
0175     SKGError setInterestComputationMode(SKGInterestObject::InterestMode iMode);
0176 
0177     /**
0178      * Get interest computation mode
0179      * @return the interest computation mode
0180      */
0181     SKGInterestObject::InterestMode getInterestComputationMode() const;
0182 
0183 protected:
0184     /**
0185      * Get where clause needed to identify objects.
0186      * For this class, the whereclause is based on date + unit
0187      * @return the where clause
0188      */
0189     QString getWhereclauseId() const override;
0190 };
0191 /**
0192  * Declare the class
0193  */
0194 Q_DECLARE_TYPEINFO(SKGInterestObject, Q_MOVABLE_TYPE);
0195 #endif