1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2021 S. MANKOWSKI stephane@mankowski.fr
3  * SPDX-FileCopyrightText: 2021 G. DE BURE support@mankowski.fr
4  * SPDX-License-Identifier: GPL-3.0-or-later
5  ***************************************************************************/
6 #ifndef SKGUNITVALUEOBJECT_H
7 #define SKGUNITVALUEOBJECT_H
8 /** @file
9  * This file defines classes SKGUnitValueObject.
10  *
11  * @author Stephane MANKOWSKI / Guillaume DE BURE
12  */
13 
14 #include "skgbankmodeler_export.h"
15 #include "skgerror.h"
16 #include "skgobjectbase.h"
17 
18 class SKGUnitObject;
19 
20 /**
21  * This class is a value at a time for a unit
22  */
23 class SKGBANKMODELER_EXPORT SKGUnitValueObject final : public SKGObjectBase
24 {
25 public:
26     /**
27      * Default constructor
28      */
29     explicit SKGUnitValueObject();
30 
31     /**
32      * Constructor
33      * @param iDocument the document containing the object
34      * @param iID the identifier in @p iTable of the object
35      */
36     explicit SKGUnitValueObject(SKGDocument* iDocument, int iID = 0);
37 
38     /**
39      * Copy constructor
40      * @param iObject the object to copy
41      */
42     SKGUnitValueObject(const SKGUnitValueObject& iObject);
43 
44     /**
45      * Copy constructor
46      * @param iObject the object to copy
47      */
48     explicit SKGUnitValueObject(const SKGObjectBase& iObject);
49 
50     /**
51      * Operator affectation
52      * @param iObject the object to copy
53      */
54     SKGUnitValueObject& operator= (const SKGObjectBase& iObject);
55 
56     /**
57      * Operator affectation
58      * @param iObject the object to copy
59      */
60     SKGUnitValueObject& operator= (const SKGUnitValueObject& iObject);
61 
62     /**
63      * Destructor
64      */
65     virtual ~SKGUnitValueObject();
66 
67     /**
68      * Set the quantity for the date of this unit
69      * @param iValue the quantity
70      * @return an object managing the error
71      *   @see SKGError
72      */
73     SKGError setQuantity(double iValue);
74 
75     /**
76      * Get the quantity for the date of this unit
77      * @return the quantity
78      */
79     double getQuantity() const;
80 
81     /**
82      * Set date of this value
83      * @param iDate the date
84      * @return an object managing the error
85      *   @see SKGError
86      */
87     // cppcheck-suppress passedByValue
88     SKGError setDate(QDate iDate);
89 
90     /**
91      * Get date of this value
92      * @return the date
93      */
94     QDate getDate() const;
95 
96     /**
97      * Get the parent unit
98      * @param oUnit the parent unit
99      * @return an object managing the error
100      *   @see SKGError
101      */
102     SKGError getUnit(SKGUnitObject& oUnit) const;
103 
104 protected:
105     /**
106      * Get where clause needed to identify objects.
107      * For this class, the whereclause is based on date + unit
108      * @return the where clause
109      */
110     QString getWhereclauseId() const override;
111 };
112 /**
113  * Declare the class
114  */
115 Q_DECLARE_TYPEINFO(SKGUnitValueObject, Q_MOVABLE_TYPE);
116 #endif
117