-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.h
117 lines (111 loc) · 2.89 KB
/
account.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include "json_macros.h"
class Account {
public:
QString Name;
int SortOrder;
Payperiode PayPeriode;
int Payment;
bool Active;
bool NoWeekend;
const QString get_DailyColumn() const
{
if (Active && PayPeriode == Payperiode::Daily)
return QLocale().toCurrencyString(Payment) + (NoWeekend ? "*" : "");
return "";
}
const QString get_WeeklyColumn() const
{
if (PayPeriode != Payperiode::Daily)
{
if (PayPeriode != Payperiode::Weekly)
return "";
return QLocale().toCurrencyString(Payment);
}
return QLocale().toCurrencyString(Payment * (NoWeekend ? 5 : 7));
}
const QString get_MonthlyColumn() const
{
switch (PayPeriode)
{
case Payperiode::Daily:
return QLocale().toCurrencyString(Payment * (NoWeekend ? 22 : 30));
case Payperiode::Weekly:
return QLocale().toCurrencyString(Payment * 4);
case Payperiode::Monthly:
return QLocale().toCurrencyString(Payment);
default:
return "";
}
}
const bool get_LessThanZero() const
{
return Payment < 0;
}
Account(QJsonObject *d = NULL):
Name(""), SortOrder(0), Active(false), NoWeekend(false)
{
if (d) init(d);
}
void init(QJsonObject *d)
{
for (QJsonObject::iterator it = d->begin(); it != d->end(); ++it) {
__IF_VAR_FROM_JSON_AS(it, Name, toString)
else __IF_VAR_FROM_JSON_AS(it, SortOrder, toInt)
else __IF_ENUM_FROM_JSON_AS(it, PayPeriode, Payperiode)
else __IF_VAR_FROM_JSON_AS(it, Payment, toInt)
else __IF_VAR_FROM_JSON_AS(it, Active, toBool)
else __IF_VAR_FROM_JSON_AS(it, NoWeekend, toBool)
}
}
bool ShouldSerializePayment()
{
return Payment != 0;
}
bool ShouldSerializeActive()
{
return Active;
}
bool ShouldSerializeNoWeekend()
{
return NoWeekend;
}
QString ToString()
{
return "Account: " + Name;
}
double GetMonthlyBalance()
{
double balance = 0.0;
/*IEnumerator<Account> enumerator = Game.DictOfAccounts.Values.GetEnumerator();
while (enumerator.MoveNext())
{
Account ac = enumerator.Current;
if (ac.Active)
{
switch (ac.PayPeriode)
{
case Payperiode.Daily:
if (ac.NoWeekend)
{
balance += ac.Payment * 260.0 / 12.0;
}
else
{
balance += ac.Payment * 365.0 / 12.0;
}
break;
case Payperiode.Weekly:
balance += ac.Payment * 52.1429 / 12.0;
break;
case Payperiode.Monthly:
balance += ac.Payment;
break;
}
}
}*/
return balance;
}
};
#endif // ACCOUNT_H