1 /*
2  * Copyright 2017-2018  Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MYMONEYENUMS_H
19 #define MYMONEYENUMS_H
20 
21 #include <QHashFunctions>
22 
23 namespace eMyMoney {
24   /**
25     * Account types currently supported.
26     */
27   namespace Account {
28     enum class Type {
29       Unknown = 0,          /**< For error handling */
30       Checkings,            /**< Standard checking account */
31       Savings,              /**< Typical savings account */
32       Cash,                 /**< Denotes a shoe-box or pillowcase stuffed
33                                  with cash */
34       CreditCard,           /**< Credit card accounts */
35       Loan,                 /**< Loan and mortgage accounts (liability) */
36       CertificateDep,       /**< Certificates of Deposit */
37       Investment,           /**< Investment account */
38       MoneyMarket,          /**< Money Market Account */
39       Asset,                /**< Denotes a generic asset account.*/
40       Liability,            /**< Denotes a generic liability account.*/
41       Currency,             /**< Denotes a currency trading account. */
42       Income,               /**< Denotes an income account */
43       Expense,              /**< Denotes an expense account */
44       AssetLoan,            /**< Denotes a loan (asset of the owner of this object) */
45       Stock,                /**< Denotes an security account as sub-account for an investment */
46       Equity,               /**< Denotes an equity account e.g. opening/closing balance */
47 
48       /* insert new account types above this line */
49       MaxAccountTypes       /**< Denotes the number of different account types */
50     };
qHash(const Type key,uint seed)51     inline uint qHash(const Type key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
52 
53     enum class Standard {
54       Liability,
55       Asset,
56       Expense,
57       Income,
58       Equity
59     };
60 
qHash(const Standard key,uint seed)61     inline uint qHash(const Standard key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
62   }
63 
64   namespace Payee {
65     enum class MatchType {
66       Disabled = 0,
67       Name,
68       Key,
69       NameExact
70     };
71   }
72 
73   namespace Security {
74     enum class Type {
75       Stock,
76       MutualFund,
77       Bond,
78       Currency,
79       None
80     };
81 
qHash(const Type key,uint seed)82     inline uint qHash(const Type key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
83   }
84 
85   namespace Report {
86     enum class RowType { NoRows = 0, AssetLiability, ExpenseIncome, Category, TopCategory, Account, Tag, Payee, Month, Week, TopAccount, AccountByTopAccount, EquityType, AccountType, Institution, Budget, BudgetActual, Schedule, AccountInfo, AccountLoanInfo, AccountReconcile, CashFlow, Invalid };
qHash(const RowType key,uint seed)87     inline uint qHash(const RowType key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
88 
89     enum class ColumnType { NoColumns = 0, Days = 1, Months = 1, BiMonths = 2, Quarters = 3, Weeks = 7, Years = 12, Invalid };
qHash(const ColumnType key,uint seed)90     inline uint qHash(const ColumnType key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
91 
92     enum class ReportType { NoReport = 0, PivotTable, QueryTable, InfoTable, Invalid };
93     // if you add bits to this bitmask, start with the value currently assigned to QCend and update its value afterwards
94     // also don't forget to add column names to kQueryColumnsText in mymoneyreport.cpp
95     enum QueryColumn : int { None = 0x0, Begin = 0x1, Number = 0x1, Payee = 0x2, Category = 0x4, Tag = 0x8, Memo = 0x10, Account = 0x20, Reconciled = 0x40, Action = 0x80, Shares = 0x100, Price = 0x200, Performance = 0x400, Loan = 0x800, Balance = 0x1000, CapitalGain = 0x2000, End = 0x4000 };
96 
97     enum class DetailLevel { None = 0, All, Top, Group, Total, End };
qHash(const DetailLevel key,uint seed)98     inline uint qHash(const DetailLevel key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
99 
100     enum class InvestmentSum { Period = 0, OwnedAndSold, Owned, Sold, Bought};
101     enum class ChartType { None = 0, Line, Bar, Pie, Ring, StackedBar, End };
qHash(const ChartType key,uint seed)102     inline uint qHash(const ChartType key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
103 
104     enum class DataLock { Automatic = 0, UserDefined, DataOptionCount };
qHash(const DataLock key,uint seed)105     inline uint qHash(const DataLock key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
106     enum class ChartPalette { Application = 0, Default, Rainbow, Subdued, End};
qHash(const ChartPalette key,uint seed)107     inline uint qHash(const ChartPalette key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
108   }
109 
110   namespace Schedule {
111     /**
112       * This enum is used to describe all the possible schedule frequencies.
113       * The special entry, Any, is used to combine all the other types.
114       */
115     enum class Occurrence {
116       Any = 0,
117       Once = 1,
118       Daily = 2,
119       Weekly = 4,
120       Fortnightly = 8,
121       EveryOtherWeek = 16,
122       EveryHalfMonth = 18,
123       EveryThreeWeeks = 20,
124       EveryThirtyDays = 30,
125       Monthly = 32,
126       EveryFourWeeks = 64,
127       EveryEightWeeks = 126,
128       EveryOtherMonth = 128,
129       EveryThreeMonths = 256,
130       TwiceYearly = 1024,
131       EveryOtherYear = 2048,
132       Quarterly = 4096,
133       EveryFourMonths = 8192,
134       Yearly = 16384
135     };
136 
137     /**
138       * This enum is used to describe the schedule type.
139       */
140     enum class Type {
141       Any = 0,
142       Bill = 1,
143       Deposit = 2,
144       Transfer = 4,
145       LoanPayment = 5
146     };
147 
148     /**
149       * This enum is used to describe the schedule's payment type.
150       */
151     enum class PaymentType {
152       Any = 0,
153       DirectDebit = 1,
154       DirectDeposit = 2,
155       ManualDeposit = 4,
156       Other = 8,
157       WriteChecque = 16,
158       StandingOrder = 32,
159       BankTransfer = 64
160     };
161 
162     /**
163       * This enum is used by the auto-commit functionality.
164       *
165       * Depending upon the value of m_weekendOption the schedule can
166       * be entered on a different date
167     **/
168     enum class WeekendOption {
169       MoveBefore = 0,
170       MoveAfter = 1,
171       MoveNothing = 2
172     };
173   }
174 
175   namespace Budget {
176     enum class Level {
177       None = 0,
178       Monthly,
179       MonthByMonth,
180       Yearly,
181       Max
182     };
183 
qHash(const Level key,uint seed)184     inline uint qHash(const Level key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
185   }
186 
187   namespace TransactionFilter {
188     // Make sure to keep the following enum values in sync with the values
189     // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui)
190     enum class Type {
191       All = 0,
192       Payments,
193       Deposits,
194       Transfers,
195       // insert new constants above of this line
196       LastType
197     };
198 
199     // Make sure to keep the following enum values in sync with the values
200     // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui)
201     enum class State {
202       All = 0,
203       NotReconciled,
204       Cleared,
205       Reconciled,
206       Frozen,
207       // insert new constants above of this line
208       LastState
209     };
210 
211     // Make sure to keep the following enum values in sync with the values
212     // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui)
213     enum class Validity {
214       Any = 0,
215       Valid,
216       Invalid,
217       // insert new constants above of this line
218       LastValidity
219     };
220 
221     // Make sure to keep the following enum values in sync with the values
222     // used by the GUI (for KMyMoney in kfindtransactiondlgdecl.ui)
223     enum class Date {
224       All = 0,
225       AsOfToday,
226       CurrentMonth,
227       CurrentYear,
228       MonthToDate,
229       YearToDate,
230       YearToMonth,
231       LastMonth,
232       LastYear,
233       Last7Days,
234       Last30Days,
235       Last3Months,
236       Last6Months,
237       Last12Months,
238       Next7Days,
239       Next30Days,
240       Next3Months,
241       Next6Months,
242       Next12Months,
243       UserDefined,
244       Last3ToNext3Months,
245       Last11Months,
246       CurrentQuarter,
247       LastQuarter,
248       NextQuarter,
249       CurrentFiscalYear,
250       LastFiscalYear,
251       Today,
252       Next18Months,
253       // insert new constants above of this line
254       LastDateItem
255     };
qHash(const Date key,uint seed)256     inline uint qHash(const Date key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
257   }
258 
259   namespace Split {
260     /**
261       * This enum defines the possible reconciliation states a split
262       * can be in. Possible values are as follows:
263       *
264       * @li NotReconciled
265       * @li Cleared
266       * @li Reconciled
267       * @li Frozen
268       *
269       * Whenever a new split is created, it has the status NotReconciled. It
270       * can be set to cleared when the transaction has been performed. Once the
271       * account is reconciled, cleared splits will be set to Reconciled. The
272       * state Frozen will be used, when the concept of books is introduced into
273       * the engine and a split must not be changed anymore.
274       */
275     enum class State {
276       Unknown = -1,
277       NotReconciled = 0,
278       Cleared,
279       Reconciled,
280       Frozen,
281       // insert new values above
282       MaxReconcileState
283     };
284 
285     enum class InvestmentTransactionType {
286       UnknownTransactionType = -1,
287       BuyShares = 0,
288       SellShares,
289       Dividend,
290       ReinvestDividend,
291       Yield,
292       AddShares,
293       RemoveShares,
294       SplitShares,
295       InterestIncome///
296     };
297 
qHash(const InvestmentTransactionType key,uint seed)298     inline uint qHash(const InvestmentTransactionType key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
299 
300     enum class Action {
301       Check,
302       Deposit,
303       Transfer,
304       Withdrawal,
305       ATM,
306       Amortization,
307       Interest,
308       BuyShares,
309       Dividend,
310       ReinvestDividend,
311       Yield,
312       AddShares,
313       SplitShares,
314       InterestIncome
315     };
316 
qHash(const Action key,uint seed)317     inline uint qHash(const Action key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
318   }
319 
320   namespace File {
321     /**
322       * notificationObject identifies the type of the object
323       * for which this notification is stored
324       */
325     enum class Object {
326       Account = 1,
327       Institution,
328       Payee,
329       Transaction,
330       Tag,
331       Schedule,
332       Security,
333       OnlineJob,
334       CostCenter
335     };
336 
337     /**
338       * notificationMode identifies the type of notification
339       * (add, modify, remove)
340       */
341     enum class Mode {
342       Add = 1,
343       Modify,
344       Remove
345     };
346 
347   }
348 
349   /**
350    * @brief Type of message
351    *
352    * An usually it is not easy to categorise log messages. This description is only a hint.
353    */
354   namespace OnlineJob {
355     enum class MessageType {
356       Debug, /**< Just for debug purposes. In normal scenarios the user should not see this. No need to store this message. Plugins should
357         not create them at all if debug mode is not enabled. */
358       Log, /**< A piece of information the user should not see during normal operation. It is not shown in any UI by default. It is stored persistently. */
359       Information, /**< Information that should be kept but without the need to burden the user. The user can
360         see this during normal operation. */
361       Warning, /**< A piece of information the user should see but not be enforced to do so (= no modal dialog). E.g. a task is expected to have
362         direct effect but instead you have to wait a day (and that is common behavior). */
363       Error /**< Important for the user - he must be warned. E.g. a task could unexpectedly not be executed */
364     };
365 
366     /**
367      * @brief The state of a job given by the onlinePlugin
368      */
369     enum class sendingState {
370       noBankAnswer, /**< Used during or before sending or if sendDate().isValid() the job was successfully sent */
371       acceptedByBank, /**< bank definitely confirmed the job */
372       rejectedByBank, /**< bank definitely rejected this job */
373       abortedByUser, /**< aborted by user during sending */
374       sendingError /**< an error occurred, the job is certainly not executed by the bank */
375     };
376   }
377 
378   namespace Statement {
379     enum class Type {
380       None = 0,
381       Checkings,
382       Savings,
383       Investment,
384       CreditCard,
385       Invalid
386     };
387 
qHash(const Type key,uint seed)388     inline uint qHash(const Type key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
389   }
390 
391   namespace Transaction {
392     // the following members are only used for investment accounts (m_eType==etInvestment)
393     // eaNone means the action, shares, and security can be ignored.
394     enum class Action {
395       None = 0,
396       Buy,
397       Sell,
398       ReinvestDividend,
399       CashDividend,
400       Shrsin,
401       Shrsout,
402       Stksplit,
403       Fees,
404       Interest,
405       Invalid
406     };
407 
qHash(const Action key,uint seed)408     inline uint qHash(const Action key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
409   }
410 
411   namespace Money {
412     enum signPosition : int {
413       // keep those in sync with the ones defined in localeconv
414       ParensAround = 0,
415       PreceedQuantityAndSymbol = 1,
416       SucceedQuantityAndSymbol = 2,
417       PreceedSymbol = 3,
418       SucceedSymbol = 4
419     };
420   }
421 
422 }
423 #endif
424