From f6d8a5a5824a92f6682021503099206d3d826e49 Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Fri, 28 Oct 2022 20:06:38 -0400 Subject: [PATCH] V2022.10.0-beta1 --- org.nickvision.money.json | 2 +- org.nickvision.money.metainfo.xml | 2 +- src/models/account.hpp | 62 +++++++++++++++++++++ src/models/transaction.hpp | 93 +++++++++++++++++++++++++++++++ src/ui/application.cpp | 2 +- 5 files changed, 158 insertions(+), 3 deletions(-) diff --git a/org.nickvision.money.json b/org.nickvision.money.json index 0f850fead..aad9dff34 100644 --- a/org.nickvision.money.json +++ b/org.nickvision.money.json @@ -59,7 +59,7 @@ { "type": "git", "url": "https://github.com/nlogozzo/NickvisionMoney.git", - "tag": "2022.10.0-next" + "tag": "2022.10.0-beta1" } ] } diff --git a/org.nickvision.money.metainfo.xml b/org.nickvision.money.metainfo.xml index a7a727ee4..07aa34dbc 100644 --- a/org.nickvision.money.metainfo.xml +++ b/org.nickvision.money.metainfo.xml @@ -24,7 +24,7 @@ org.nickvision.money - +

- Redesign with GTK4 and libadwaita 1.2

diff --git a/src/models/account.hpp b/src/models/account.hpp index b1ecfe1fb..13911fd10 100644 --- a/src/models/account.hpp +++ b/src/models/account.hpp @@ -10,19 +10,81 @@ namespace NickvisionMoney::Models { + /** + * A model of an account + */ class Account { public: + /** + * Constructs an account + * + * @param path The path to the account file on disk + */ Account(const std::string& path); + /** + * Gets the path of the account + * + * @returns The path of the account + */ const std::string& getPath() const; + /** + * Gets a map of transactions in the account + * + * @returns The map of transaction in the account + */ const std::map& getTransactions() const; + /** + * Attempts to get a transaction from the account by id + * + * @param id The id of the transaction + * @returns The transaction if found, else std::nullopt + */ std::optional getTransactionById(unsigned int id) const; + /** + * Gets the next available id in the account + * + * @returns The next available id in the account + */ unsigned int getNextAvailableId() const; + /** + * Adds a transaction to the account + * + * @param transaction The transaction to add + * @returns True if successful, else false + */ bool addTransaction(const Transaction& transaction); + /** + * Updates a transaction in the account + * + * @param transaction The transaction to update + * @returns True if successful, else false + */ bool updateTransaction(const Transaction& transaction); + /** + * Deletes a transaction in the account + * + * @param id The id of the transaction to delete + * @returns True if successful, else false + */ bool deleteTransaction(unsigned int id); + /** + * Gets the income amount of the account + * + * @returns The income amount of the account + */ boost::multiprecision::cpp_dec_float_50 getIncome() const; + /** + * Gets the expense amount of the account + * + * @returns The expense amount of the account + */ boost::multiprecision::cpp_dec_float_50 getExpense() const; + /** + * Gets the total amount of the account + * + * @returns The total amount of the account + */ boost::multiprecision::cpp_dec_float_50 getTotal() const; private: diff --git a/src/models/transaction.hpp b/src/models/transaction.hpp index cf6152a47..6e1cf1d7c 100644 --- a/src/models/transaction.hpp +++ b/src/models/transaction.hpp @@ -6,12 +6,18 @@ namespace NickvisionMoney::Models { + /** + * Types of a transaction + */ enum class TransactionType { Income = 0, Expense }; + /** + * Repeat intervals of a transaction + */ enum class RepeatInterval { Never = 0, @@ -23,24 +29,111 @@ namespace NickvisionMoney::Models Biyearly }; + /** + * A model of a transaction + */ class Transaction { public: + /** + * Constructs a Transaction + * + * @param id The id of the transaction + */ Transaction(unsigned int id = 0); + /** + * Gets the id of the transaction + * + * @returns The id of the transaction + */ unsigned int getId() const; + /** + * Gets the date of the transaction + * + * @returns The date of the transaction + */ const boost::gregorian::date& getDate() const; + /** + * Sets the date of the transaction + * + * @param date The new date + */ void setDate(const boost::gregorian::date& date); + /** + * Gets the description of the transaction + * + * @returns The description of the transaction + */ const std::string& getDescription() const; + /** + * Sets the description of the transaction + * + * @param description The new description + */ void setDescription(const std::string& description); + /** + * Gets the type of the transaction + * + * @returns The type of the transaction + */ TransactionType getType() const; + /** + * Sets the type of the transaction + * + * @param type The new type + */ void setType(TransactionType type); + /** + * Gets the repeat interval of the transaction + * + * @returns The repeat interval of the transaction + */ RepeatInterval getRepeatInterval() const; + /** + * Sets the repeat interval of the transaction + * + * @param repeatInterval The new repeat interval + */ void setRepeatInterval(RepeatInterval repeatInterval); + /** + * Gets the amount of the transaction + * + * @returns The amount of the transaction + */ boost::multiprecision::cpp_dec_float_50 getAmount() const; + /** + * Sets the amount of the transaction + * + * @param amount The new amount + */ void setAmount(boost::multiprecision::cpp_dec_float_50 amount); + /** + * Compares two Transactions via less-than + * + * @param toComapre The transaction to compare + * @returns True if this transaction < toCompare, else false + */ bool operator<(const Transaction& toCompare) const; + /** + * Compares two Transactions via greater-than + * + * @param toComapre The transaction to compare + * @returns True if this transaction > toCompare, else false + */ bool operator>(const Transaction& toCompare) const; + /** + * Compares two Transactions via equals + * + * @param toComapre The transaction to compare + * @returns True if this transaction == toCompare, else false + */ bool operator==(const Transaction& toCompare) const; + /** + * Compares two Transactions via not equals + * + * @param toComapre The transaction to compare + * @returns True if this transaction != toCompare, else false + */ bool operator!=(const Transaction& toCompare) const; private: diff --git a/src/ui/application.cpp b/src/ui/application.cpp index 306f2a0eb..73ff426ca 100644 --- a/src/ui/application.cpp +++ b/src/ui/application.cpp @@ -13,7 +13,7 @@ Application::Application(const std::string& id, GApplicationFlags flags) : m_adw m_appInfo.setName("Nickvision Money"); m_appInfo.setShortName("Money"); m_appInfo.setDescription("A personal finance manager."); - m_appInfo.setVersion("2022.10.0-next"); + m_appInfo.setVersion("2022.10.0-beta1"); m_appInfo.setChangelog("
  • Redesign with GTK4 and libadwaita 1.2
"); m_appInfo.setGitHubRepo("https://github.com/nlogozzo/NickvisionMoney"); m_appInfo.setIssueTracker("https://github.com/nlogozzo/NickvisionMoney/issues/new");