Skip to content

Commit d94ccfc

Browse files
committed
Shared - CustomCurrency + AccountMetadata Models
1 parent d22ff2b commit d94ccfc

File tree

9 files changed

+541
-1
lines changed

9 files changed

+541
-1
lines changed

.github/workflows/windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
pkgs: libnick
3131
triplet: x64-windows
3232
cache-key: windows-latest
33-
revision: 80403036a665cb8fcc1a1b3e17593d20b03b2489
33+
revision: 710677da49b03885c65c8b5ca43072d4b1acde75
3434
token: ${{ secrets.GITHUB_TOKEN }}
3535
- name: "Build"
3636
working-directory: ${{github.workspace}}/build

libdenaro/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ endif()
55
add_library(libdenaro
66
"src/controllers/mainwindowcontroller.cpp"
77
"src/controllers/preferencesviewcontroller.cpp"
8+
"src/models/accountmetadata.cpp"
89
"src/models/color.cpp"
910
"src/models/configuration.cpp"
1011
"src/models/currencyconversion.cpp"
1112
"src/models/currencyconversionservice.cpp"
13+
"src/models/customcurrency.cpp"
1214
"src/models/group.cpp"
1315
"src/models/importresult.cpp"
1416
"src/models/receipt.cpp"
+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#ifndef ACCOUNTMETADATA_H
2+
#define ACCOUNTMETADATA_H
3+
4+
#include <string>
5+
#include "accounttype.h"
6+
#include "customcurrency.h"
7+
#include "remindersthreshold.h"
8+
#include "sortby.h"
9+
#include "transactiontype.h"
10+
11+
namespace Nickvision::Money::Shared::Models
12+
{
13+
/**
14+
* @brief A model of metadata for an account.
15+
*/
16+
class AccountMetadata
17+
{
18+
public:
19+
/**
20+
* @brief Constructs an AccountMetadata.
21+
* @param name The name of the account
22+
* @param type The type of the account
23+
*/
24+
AccountMetadata(const std::string& name, AccountType type);
25+
/**
26+
* @brief Gets the name of the account.
27+
* @return The name of the account
28+
*/
29+
const std::string& getName() const;
30+
/**
31+
* @brief Sets the name of the account.
32+
* @param name The new name of the account
33+
*/
34+
void setName(const std::string& name);
35+
/**
36+
* @brief Gets the type of the account.
37+
* @return The type of the account
38+
*/
39+
AccountType getType() const;
40+
/**
41+
* @brief Sets the type of the account.
42+
* @param type The new type of the account
43+
*/
44+
void setType(AccountType type);
45+
/**
46+
* @brief Gets whether or not to use the custom currency provided by the metadata.
47+
* @return True to use the custom currency, else false
48+
*/
49+
bool getUseCustomCurrency() const;
50+
/**
51+
* @brief Sets whether or not to use the custom currency provided by the metadata.
52+
* @param useCustomCurrency True to use the custom currency, else false
53+
*/
54+
void setUseCustomCurrency(bool useCustomCurrency);
55+
/**
56+
* @brief Gets the custom currency of the account.
57+
* @brief getUseCustomCurrency() should be checked first to determine whether or not to utilize this custom currency.
58+
* @return The custom currency of the account
59+
*/
60+
const CustomCurrency& getCustomCurrency() const;
61+
/**
62+
* @brief Sets the custom currency of the account.
63+
* @param customCurrency The new custom currency of the account
64+
*/
65+
void setCustomCurrency(const CustomCurrency& customCurrency);
66+
/**
67+
* @brief Gets the default transaction type of the account.
68+
* @return The default transaction type of the account
69+
*/
70+
TransactionType getDefaultTransactionType() const;
71+
/**
72+
* @brief Sets the default transaction type of the account.
73+
* @param defaultTransactionType The new default transaction type of the account
74+
*/
75+
void setDefaultTransactionType(TransactionType defaultTransactionType);
76+
/**
77+
* @brief Gets the threshold for showing transaction reminders of the account.
78+
* @return The threshold for showing transaction reminders of the account
79+
*/
80+
RemindersThreshold getTransactionRemindersThreshold() const;
81+
/**
82+
* @brief Sets the threshold for showing transaction reminders of the account.
83+
* @param remindersThreshold The new threshold for showing transaction reminders of the account
84+
*/
85+
void setTransactionRemindersThreshold(RemindersThreshold remindersThreshold);
86+
/**
87+
* @brief Gets whether or not to show the groups list on the account view.
88+
* @return True to show groups list, else false
89+
*/
90+
bool getShowGroupsList() const;
91+
/**
92+
* @brief Sets whether or not to show the groups list on the account view.
93+
* @param showGroupsList True to show groups list, else false
94+
*/
95+
void setShowGroupsList(bool showGroupsList);
96+
/**
97+
* @brief Gets whether or not to show the tags list on the account view.
98+
* @return True to show tags list, else false
99+
*/
100+
bool getShowTagsList() const;
101+
/**
102+
* @brief Sets whether or not to show the tags list on the account view.
103+
* @param showTagsList True to show tags list, else false
104+
*/
105+
void setShowTagsList(bool showTagsList);
106+
/**
107+
* @brief Gets the way in which to sort transactions on the account view.
108+
* @return The SortBy value
109+
*/
110+
SortBy getSortTransactionsBy() const;
111+
/**
112+
* @brief Sets the way in which to sort transactions on the account view.
113+
* @param sortTransactionBy The new SortBy value
114+
*/
115+
void setSortTransactionsBy(SortBy sortTransactionsBy);
116+
/**
117+
* @brief Gets whether or not to sort transactions from first to last on the account view.
118+
* @return True to sort first to last, else false
119+
*/
120+
bool getSortFirstToLast() const;
121+
/**
122+
* @brief Sets whether or not to sort transactions from first to last on the account view.
123+
* @param sortFirstToLast True to sort first to last, else false
124+
*/
125+
void setSortFirstToLast(bool sortFirstToLast);
126+
127+
private:
128+
std::string m_name;
129+
AccountType m_type;
130+
bool m_useCustomCurrency;
131+
CustomCurrency m_customCurrency;
132+
TransactionType m_defaultTransactionType;
133+
RemindersThreshold m_transactionRemindersThreshold;
134+
bool m_showGroupsList;
135+
bool m_showTagsList;
136+
SortBy m_sortTransactionsBy;
137+
bool m_sortFirstToLast;
138+
};
139+
}
140+
141+
#endif //ACCOUNTMETADATA_H
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef AMOUNTSTYLE_H
2+
#define AMOUNTSTYLE_H
3+
4+
namespace Nickvision::Money::Shared::Models
5+
{
6+
/**
7+
* @brief Styles for displaying an amount.
8+
*/
9+
enum class AmountStyle
10+
{
11+
/**
12+
* @brief $n
13+
*/
14+
SignNumber = 0,
15+
/**
16+
* @brief n$
17+
*/
18+
NumberSign,
19+
/**
20+
* @brief $ n
21+
*/
22+
SignSpaceNumber,
23+
/**
24+
* @brief n $
25+
*/
26+
NumberSpaceSign
27+
};
28+
}
29+
30+
#endif //AMOUNTSTYLE_H
+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#ifndef CUSTOMCURRENCY_H
2+
#define CUSTOMCURRENCY_H
3+
4+
#include <string>
5+
#include "amountstyle.h"
6+
7+
namespace Nickvision::Money::Shared::Models
8+
{
9+
/**
10+
* @brief A model of a custom currency.
11+
*/
12+
class CustomCurrency
13+
{
14+
public:
15+
/**
16+
* @brief Constructs a CustomCurrency.
17+
*/
18+
CustomCurrency();
19+
/**
20+
* @brief Constructs a CustomCurrency.
21+
* @param symbol The symbol of the custom currency
22+
* @param code The code of the custom currency
23+
*/
24+
CustomCurrency(const std::string& symbol, const std::string& code);
25+
/**
26+
* @brief Gets whether or not the CustomCurrency object represents an empty value.
27+
* @return True if empty, else false
28+
*/
29+
bool empty() const;
30+
/**
31+
* @brief Gets the symbol of the custom currency.
32+
* @return The symbol of the custom currency
33+
*/
34+
const std::string& getSymbol() const;
35+
/**
36+
* @brief Sets the symbol of the custom currency.
37+
* @brief If the new symbol is empty, the new symbol will not be set.
38+
* @param symbol The new symbol of the custom currency
39+
*/
40+
void setSymbol(const std::string& symbol);
41+
/**
42+
* @brief Gets the code of the custom currency.
43+
* @return The code of the custom currency
44+
*/
45+
const std::string& getCode() const;
46+
/**
47+
* @brief Sets the code of the custom currency.
48+
* @brief If the new code is empty, the new code will not be set.
49+
* @param code The new code of the custom currency
50+
*/
51+
void setCode(const std::string& code);
52+
/**
53+
* @brief Gets the decimal separator of the custom currency.
54+
* @return The decimal separator of the custom currency
55+
*/
56+
const std::string& getDecimalSeparator() const;
57+
/**
58+
* @brief Sets the decimal separator of the custom currency.
59+
* @brief If the new decimal separator is the same as the current group separator, the new decimal separator will not be set.
60+
* @brief If the new decimal separator is empty, the new decimal separator will not be set.
61+
* @param separator The new decimal separator of the custom currency
62+
*/
63+
void setDecimalSeparator(const std::string& separator);
64+
/**
65+
* @brief Gets the group separator of the custom currency.
66+
* @return The group separator of the custom currency
67+
*/
68+
const std::string& getGroupSeparator() const;
69+
/**
70+
* @brief Sets the group separator of the custom currency.
71+
* @brief If the new group separator is the same as the current decimal separator, the new group separator will not be set.
72+
* @param separator The new group separator of the custom currency
73+
*/
74+
void setGroupSeparator(const std::string& separator);
75+
/**
76+
* @brief Gets the number of decimal digits of the custom currency.
77+
* @return The number of decimal digits of the custom currency
78+
*/
79+
int getDecimalDigits() const;
80+
/**
81+
* @brief Sets the number of decimal digits of the custom currency.
82+
* @param digits The new number of decimal digits of the custom currency
83+
*/
84+
void setDecimalDigits(int digits);
85+
/**
86+
* @brief Gets the style to use for displaying amounts of the custom currency.
87+
* @return The style to use for displaying amounts of the custom currency
88+
*/
89+
AmountStyle getAmountStyle() const;
90+
/**
91+
* @brief Sets the style to use for displaying amounts of the custom currency.
92+
* @param style The new style to use for displaying amounts of the custom currency
93+
*/
94+
void setAmountStyle(AmountStyle style);
95+
/**
96+
* @brief Gets whether or not the object is valid or not.
97+
* @return True if valid (!empty), else false
98+
*/
99+
operator bool() const;
100+
101+
private:
102+
std::string m_symbol;
103+
std::string m_code;
104+
std::string m_decimalSeparator;
105+
std::string m_groupSeparator;
106+
int m_decimalDigits;
107+
AmountStyle m_amountStyle;
108+
};
109+
}
110+
111+
#endif //CUSTOMCURRENCY_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef REMINDERSTHRESHOLD_H
2+
#define REMINDERSTHRESHOLD_H
3+
4+
namespace Nickvision::Money::Shared::Models
5+
{
6+
/**
7+
* @brief Thresholds for when to show a reminder.
8+
*/
9+
enum class RemindersThreshold
10+
{
11+
Never = 0,
12+
OneDayBefore,
13+
OneWeekBefore,
14+
OneMonthBefore,
15+
TwoMonthsBefore
16+
};
17+
}
18+
19+
#endif //REMINDERSTHRESHOLD_H

libdenaro/include/models/sortby.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef SORTBY_H
2+
#define SORTBY_H
3+
4+
namespace Nickvision::Money::Shared::Models
5+
{
6+
/**
7+
* @brief Ways for sorting transactions.
8+
*/
9+
enum class SortBy
10+
{
11+
Id = 0,
12+
Date,
13+
Amount
14+
};
15+
}
16+
17+
#endif //SORTBY_H

0 commit comments

Comments
 (0)